Skip to content

Commit

Permalink
support pico-sdk-2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
elehobica committed Aug 15, 2024
1 parent 437f81b commit d24344a
Show file tree
Hide file tree
Showing 14 changed files with 73 additions and 178 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Change Log
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [1.0.0] - 2024-08-15
* Initial release
23 changes: 11 additions & 12 deletions CmakeLists.txt → CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
cmake_minimum_required(VERSION 3.12)
cmake_minimum_required(VERSION 3.13)

set(PICO_SDK_PATH ${CMAKE_CURRENT_LIST_DIR}/../pico-sdk)
include(pico_sdk_import.cmake)
include(pico_extras_import.cmake)
include($ENV{PICO_SDK_PATH}/external/pico_sdk_import.cmake)
include($ENV{PICO_EXTRAS_PATH}/external/pico_extras_import.cmake)

set(project_name "pico_battery_op")
set(project_name "pico_battery_op" C CXX)
project(${project_name})
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)

pico_sdk_init()

add_subdirectory(lib/pico-ssd1306)
add_subdirectory(lib/my_pico_stdio_usb)
add_subdirectory(lib/pico_stdio_usb_revised)

set(bin_name "pico_battery_op")
set(bin_name ${PROJECT_NAME})
add_executable(${bin_name}
main.cpp
power_management.cpp
Expand All @@ -24,14 +23,14 @@ add_executable(${bin_name}
#pico_enable_stdio_uart(${bin_name} 1)

target_link_libraries(${bin_name}
pico_stdlib
pico_stdio_uart
my_pico_stdio_usb
hardware_uart
hardware_sleep
hardware_adc
hardware_sleep
hardware_uart
hardware_watchdog
pico_runtime_init
pico_stdlib
pico-ssd1306
pico_stdio_usb_revised
)

target_include_directories(${bin_name} INTERFACE lib/)
Expand Down
35 changes: 22 additions & 13 deletions Readme.md → README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,29 +68,38 @@ This project supports:

## How to build
* See ["Getting started with Raspberry Pi Pico"](https://datasheets.raspberrypi.org/pico/getting-started-with-pico.pdf)
* Build is confirmed only in Developer Command Prompt for VS 2019 and Visual Studio Code on Windows enviroment
* Put "pico-sdk", "pico-examples", "pico-extras" and "pico-playground" on the same level with this project folder.
* Put "pico-sdk", "pico-examples" and "pico-extras" on the same level with this project folder.
* Set environmental variables for PICO_SDK_PATH, PICO_EXTRAS_PATH and PICO_EXAMPLES_PATH
* Confirmed with Pico SDK 2.0.0
```
> git clone -b master https://github.com/raspberrypi/pico-sdk.git
> git clone -b 2.0.0 https://github.com/raspberrypi/pico-sdk.git
> cd pico-sdk
> git submodule update -i
> cd ..
> git clone -b master https://github.com/raspberrypi/pico-examples.git
>
> git clone https://github.com/raspberrypi/pico-extras.git
> cd pico-extras
> git submodule update -i
> cd ..
> git clone https://github.com/raspberrypi/pico-playground.git
> git clone -b sdk-2.0.0 https://github.com/raspberrypi/pico-examples.git
>
> git clone -b sdk-2.0.0 https://github.com/raspberrypi/pico-extras.git
>
> git clone -b main https://github.com/elehobica/pico_battery_op.git
```
* Lanuch "Developer Command Prompt for VS 2019"
### Windows
* Build is confirmed in Developer Command Prompt for VS 2022 and Visual Studio Code on Windows environment
* Confirmed with cmake-3.27.2-windows-x86_64 and gcc-arm-none-eabi-10.3-2021.10-win32
* Lanuch "Developer Command Prompt for VS 2022"
```
> cd pico_battery_op
> mkdir build
> cd build
> mkdir build && cd build
> cmake -G "NMake Makefiles" ..
> nmake
```
### Linux
* Build is confirmed with [pico-sdk-dev-docker:sdk-2.0.0-1.0.0]( https://hub.docker.com/r/elehobica/pico-sdk-dev-docker)
* Confirmed with cmake-3.22.1 and arm-none-eabi-gcc (15:10.3-2021.07-4) 10.3.1
```
$ cd pico_battery_op
$ mkdir build && cd build
$ cmake ..
$ make -j4
```
### Upload
* Put "pico_battery_op.uf2" on RPI-RP2 drive
18 changes: 0 additions & 18 deletions lib/my_pico_stdio_usb/CMakeLists.txt

This file was deleted.

17 changes: 17 additions & 0 deletions lib/pico_stdio_usb_revised/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
if (NOT TARGET pico_stdio_usb_revised)
add_library(pico_stdio_usb_revised INTERFACE)

target_sources(pico_stdio_usb_revised INTERFACE
${CMAKE_CURRENT_LIST_DIR}/reset_interface.c
${CMAKE_CURRENT_LIST_DIR}/stdio_usb.c
${CMAKE_CURRENT_LIST_DIR}/stdio_usb_descriptors.c
)

target_link_libraries(pico_stdio_usb_revised INTERFACE
tinyusb_device_unmarked
pico_stdio
pico_time
pico_unique_id
)
target_include_directories(pico_stdio_usb_revised INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
endif()
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ extern stdio_driver_t stdio_usb;
bool stdio_usb_init(void);

/*! \brief Explicitly de-initialize USB stdio and add it to the current set of stdin drivers
* \ingroup pico_stdio_uart
* \ingroup pico_stdio_uart (added by elehobica)
*/
void stdio_usb_deinit(void);

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ bool stdio_usb_init(void) {
return (bool) alarm_id;
}

// added by elehobica
void stdio_usb_deinit(void) {
stdio_set_driver_enabled(&stdio_usb, false);
if ((bool) alarm_id) {
Expand All @@ -127,6 +128,7 @@ void stdio_usb_deinit(void) {
bool stdio_usb_init(void) {
return false;
}
// added by elehobica
void stdio_usb_deinit(void) {
}
#endif
62 changes: 0 additions & 62 deletions pico_extras_import.cmake

This file was deleted.

62 changes: 0 additions & 62 deletions pico_sdk_import.cmake

This file was deleted.

22 changes: 12 additions & 10 deletions power_management.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,22 @@
#include "power_management.h"

#include <cstdio>
#include "pico/stdlib.h"
#include "pico/sleep.h"
#include "pico/stdio_uart.h"
#include "pico/stdio_usb.h" // use lib/my_pico_stdio_usb/
#include "pico/util/queue.h"
#include "hardware/pll.h"

#include "hardware/adc.h"
#include "hardware/clocks.h"
#include "hardware/gpio.h"
#include "hardware/pll.h"
#include "hardware/rosc.h"
#include "hardware/structs/clocks.h"
#include "hardware/structs/scb.h"
#include "hardware/rosc.h"
#include "hardware/gpio.h"
#include "hardware/adc.h"
#include "hardware/sync.h"
#include "hardware/watchdog.h"
#include "pico/runtime_init.h"
#include "pico/stdlib.h"
#include "pico/sleep.h"
#include "pico/stdio_uart.h"
#include "pico/stdio_usb.h" // use lib/my_pico_stdio_usb/
#include "pico/util/queue.h"

// === Pin Settings for power management ===
// DC/DC mode selection Pin
Expand Down Expand Up @@ -335,7 +337,7 @@ static void _recover_clock_after_sleep()
scb_hw->scr = _scr;
clocks_hw->sleep_en0 = _sleep_en0;
clocks_hw->sleep_en1 = _sleep_en1;
clocks_init(); // reset clocks
runtime_init_clocks(); // reset clocks
}
// === 'recover_from_sleep' part (end) ===================================

Expand Down

0 comments on commit d24344a

Please sign in to comment.