Files
puya32-playground/CMakeLists.txt
Matthias Blankertz c36dd58539 Run PY32F002A as PY32F003; Add neopixel driver
The PY32F002A seems to be the same silicon as PY32F003, and the DMA is
present and usable.

Implement a NeoPixel driver using PWM timer for pulse length encoding
and DMA to reprogram the pulse length for each bit.

Signed-off-by: Matthias Blankertz <matthias@blankertz.org>
2025-11-21 20:52:36 +01:00

91 lines
3.0 KiB
CMake

cmake_minimum_required(VERSION 3.29)
project(puya32-playground LANGUAGES C ASM)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS ON)
set(HAL_DEFINES
# PY32F002Ax5
PY32F003x6
# USE_FULL_LL_DRIVER
)
set(HAL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/py32f0-sdk)
add_library(py32-hal STATIC)
target_include_directories(py32-hal PUBLIC
${HAL_DIR}/Libraries/CMSIS/Core/Include
${HAL_DIR}/Libraries/CMSIS/Device/PY32F0xx/Include
${HAL_DIR}/Libraries/PY32F0xx_LL_Driver/Inc
${HAL_DIR}/Libraries/PY32F0xx_LL_BSP/Inc
)
target_compile_definitions(py32-hal PUBLIC
${HAL_DEFINES}
)
target_sources(py32-hal PRIVATE
# LL drivers
${HAL_DIR}/Libraries/PY32F0xx_LL_Driver/Src/py32f0xx_ll_adc.c
${HAL_DIR}/Libraries/PY32F0xx_LL_Driver/Src/py32f0xx_ll_crc.c
${HAL_DIR}/Libraries/PY32F0xx_LL_Driver/Src/py32f0xx_ll_exti.c
${HAL_DIR}/Libraries/PY32F0xx_LL_Driver/Src/py32f0xx_ll_gpio.c
${HAL_DIR}/Libraries/PY32F0xx_LL_Driver/Src/py32f0xx_ll_led.c
${HAL_DIR}/Libraries/PY32F0xx_LL_Driver/Src/py32f0xx_ll_pwr.c
${HAL_DIR}/Libraries/PY32F0xx_LL_Driver/Src/py32f0xx_ll_rtc.c
${HAL_DIR}/Libraries/PY32F0xx_LL_Driver/Src/py32f0xx_ll_tim.c
${HAL_DIR}/Libraries/PY32F0xx_LL_Driver/Src/py32f0xx_ll_utils.c
${HAL_DIR}/Libraries/PY32F0xx_LL_Driver/Src/py32f0xx_ll_comp.c
${HAL_DIR}/Libraries/PY32F0xx_LL_Driver/Src/py32f0xx_ll_dma.c
${HAL_DIR}/Libraries/PY32F0xx_LL_Driver/Src/py32f0xx_ll_flash.c
${HAL_DIR}/Libraries/PY32F0xx_LL_Driver/Src/py32f0xx_ll_i2c.c
${HAL_DIR}/Libraries/PY32F0xx_LL_Driver/Src/py32f0xx_ll_lptim.c
${HAL_DIR}/Libraries/PY32F0xx_LL_Driver/Src/py32f0xx_ll_rcc.c
${HAL_DIR}/Libraries/PY32F0xx_LL_Driver/Src/py32f0xx_ll_spi.c
${HAL_DIR}/Libraries/PY32F0xx_LL_Driver/Src/py32f0xx_ll_usart.c
${HAL_DIR}/Libraries/PY32F0xx_LL_BSP/Src/py32f0xx_bsp_clock.c
${HAL_DIR}/Libraries/PY32F0xx_LL_BSP/Src/py32f0xx_bsp_led.c
${HAL_DIR}/Libraries/PY32F0xx_LL_BSP/Src/py32f0xx_bsp_printf.c
# Startup code
${HAL_DIR}/Libraries/CMSIS/Device/PY32F0xx/Source/system_py32f0xx.c
#${HAL_DIR}/Libraries/CMSIS/Device/PY32F0xx/Source/gcc/startup_py32f002a.s
${HAL_DIR}/Libraries/CMSIS/Device/PY32F0xx/Source/gcc/startup_py32f003.s
)
# Set up target executable
add_executable(puya32-playground)
target_link_libraries(puya32-playground
PRIVATE py32-hal
)
target_sources(puya32-playground PRIVATE
src/main.c
src/neopixel.c
)
# # example
# add_executable(ll_tim1_dma)
# target_link_libraries(ll_tim1_dma
# PRIVATE py32-hal
# )
# target_sources(ll_tim1_dma PRIVATE
# py32f0-sdk/Examples/PY32F0xx/LL/TIM/TIM1_DMA/main.c
# py32f0-sdk/Examples/PY32F0xx/LL/TIM/TIM1_DMA/py32f0xx_it.c
# )
# clang-format
add_custom_target(check-format
find include/ src/ -iname '*.[ch]' -exec clang-format -Werror --dry-run {} +
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
add_custom_target(clang-format
find include/ src/ -iname '*.[ch]' -exec clang-format -i {} +
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)