Initial commit
This commit is contained in:
commit
a0fb6775e3
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
.cache/
|
6
.gitmodules
vendored
Normal file
6
.gitmodules
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
[submodule "lib/pico-ice-sdk"]
|
||||||
|
path = lib/pico-ice-sdk
|
||||||
|
url = https://github.com/tinyvision-ai-inc/pico-ice-sdk.git
|
||||||
|
[submodule "lib/--recurse-submodules"]
|
||||||
|
path = lib/--recurse-submodules
|
||||||
|
url = https://github.com/tinyvision-ai-inc/pico-ice-sdk.git
|
21
CMakeLists.txt
Normal file
21
CMakeLists.txt
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.13...3.27)
|
||||||
|
|
||||||
|
set(PICO_BOARD pico2_ice)
|
||||||
|
list(APPEND PICO_BOARD_HEADER_DIRS lib/pico-ice-sdk/include/boards)
|
||||||
|
file(WRITE "${CMAKE_BINARY_DIR}/.gitignore" "*")
|
||||||
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
|
||||||
|
include(lib/pico-ice-sdk/cmake/preinit_pico_ice_sdk.cmake)
|
||||||
|
set(PICO_SDK_PATH ${CMAKE_SOURCE_DIR}/lib/pico-ice-sdk/lib/pico-sdk)
|
||||||
|
include(${PICO_SDK_PATH}/external/pico_sdk_import.cmake)
|
||||||
|
|
||||||
|
project(pico2-ice-projects C CXX ASM)
|
||||||
|
|
||||||
|
set(CMAKE_C_STANDARD 11)
|
||||||
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
|
pico_sdk_init()
|
||||||
|
|
||||||
|
add_subdirectory(lib/pico-ice-sdk)
|
||||||
|
|
||||||
|
add_subdirectory(blinky)
|
9
blinky/CMakeLists.txt
Normal file
9
blinky/CMakeLists.txt
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.13...3.27)
|
||||||
|
|
||||||
|
add_executable(blinky src/main.cpp)
|
||||||
|
|
||||||
|
target_link_libraries(blinky
|
||||||
|
pico_ice_sdk
|
||||||
|
hardware_pwm
|
||||||
|
)
|
||||||
|
pico_add_extra_outputs(blinky)
|
48
blinky/src/main.cpp
Normal file
48
blinky/src/main.cpp
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
#include <hardware/gpio.h>
|
||||||
|
#include <hardware/irq.h>
|
||||||
|
#include <hardware/pwm.h>
|
||||||
|
|
||||||
|
void on_pwm_wrap()
|
||||||
|
{
|
||||||
|
static int fade = 0;
|
||||||
|
static bool going_up = true;
|
||||||
|
|
||||||
|
pwm_clear_irq(pwm_gpio_to_slice_num(ICE_LED_RED_PIN));
|
||||||
|
|
||||||
|
if (going_up)
|
||||||
|
{
|
||||||
|
if (++fade > 255)
|
||||||
|
{
|
||||||
|
fade = 255;
|
||||||
|
going_up = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (--fade < 0)
|
||||||
|
{
|
||||||
|
fade = 0;
|
||||||
|
going_up = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pwm_set_gpio_level(ICE_LED_RED_PIN, fade * fade);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
gpio_set_function(ICE_LED_RED_PIN, GPIO_FUNC_PWM);
|
||||||
|
uint slice_num = pwm_gpio_to_slice_num(ICE_LED_RED_PIN);
|
||||||
|
|
||||||
|
pwm_clear_irq(slice_num);
|
||||||
|
pwm_set_irq_enabled(slice_num, true);
|
||||||
|
irq_set_exclusive_handler(PWM_DEFAULT_IRQ_NUM(), on_pwm_wrap);
|
||||||
|
irq_set_enabled(PWM_DEFAULT_IRQ_NUM(), true);
|
||||||
|
|
||||||
|
pwm_config config = pwm_get_default_config();
|
||||||
|
pwm_config_set_clkdiv(&config, 1.0f);
|
||||||
|
|
||||||
|
pwm_init(slice_num, &config, true);
|
||||||
|
|
||||||
|
while (true);
|
||||||
|
}
|
1
compile_commands.json
Symbolic link
1
compile_commands.json
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
build/compile_commands.json
|
1
lib/pico-ice-sdk
Submodule
1
lib/pico-ice-sdk
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 8de8106296b09d4db68638a7eb32280f8c09a654
|
Loading…
x
Reference in New Issue
Block a user