From 9fa7266f376206239fcfdce510c1d5f5feda0ecd Mon Sep 17 00:00:00 2001 From: Grigoris Pavlakis Date: Mon, 29 Jul 2024 12:05:21 +0300 Subject: [PATCH 1/3] docs: add blinky source example Interrupts to be included too --- examples/blinky/CMakeLists.txt | 21 + examples/blinky/README.md | 8 + .../blinky/atmel_samv71_xplained_ultra.cfg | 15 + examples/blinky/conanfile.py | 40 + examples/blinky/mcu-config/core.yml | 757 ++++++++++++++++++ examples/blinky/mcu-config/dfp.yml | 6 + examples/blinky/mcu-config/efc.yml | 15 + examples/blinky/src/main.c | 36 + 8 files changed, 898 insertions(+) create mode 100644 examples/blinky/CMakeLists.txt create mode 100644 examples/blinky/README.md create mode 100644 examples/blinky/atmel_samv71_xplained_ultra.cfg create mode 100644 examples/blinky/conanfile.py create mode 100644 examples/blinky/mcu-config/core.yml create mode 100644 examples/blinky/mcu-config/dfp.yml create mode 100644 examples/blinky/mcu-config/efc.yml create mode 100644 examples/blinky/src/main.c diff --git a/examples/blinky/CMakeLists.txt b/examples/blinky/CMakeLists.txt new file mode 100644 index 0000000..0ba0e35 --- /dev/null +++ b/examples/blinky/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 3.19.2) + +project(OBC_SOFTWARE C CXX ASM) + +find_package(Harmony REQUIRED) +find_package(SAMV71-DFP COMPONENTS SAMV71Q21B REQUIRED) + +# TODO: support multiple config names in separate directories (CONFIG_NAME argument) +add_harmony_config( + MCU_MODEL ATSAMV71Q21B + YAML_FILES + ./mcu-config/core.yml + ./mcu-config/dfp.yml + ./mcu-config/efc.yml + ./mcu-config/usart1.yml +) + +add_executable(${PROJECT_NAME}) +target_include_directories(${PROJECT_NAME} PRIVATE include/) +target_sources(${PROJECT_NAME} PRIVATE src/main.c) +target_link_libraries(${PROJECT_NAME} PRIVATE samv71-dfp::SAMV71Q21B::Startup samv71-dfp::SAMV71Q21B::Linker::Flash Harmony::SysInit Harmony::PeripheralDrivers) diff --git a/examples/blinky/README.md b/examples/blinky/README.md new file mode 100644 index 0000000..6768308 --- /dev/null +++ b/examples/blinky/README.md @@ -0,0 +1,8 @@ +# SAMV71 blinky + +## Building +To build this, run the following: +- `cmake . -Bbuild -DCMAKE_TOOLCHAIN_FILE=./cmake/samv71-toolchain.cmake` +- `cd build` +- `make` + diff --git a/examples/blinky/atmel_samv71_xplained_ultra.cfg b/examples/blinky/atmel_samv71_xplained_ultra.cfg new file mode 100644 index 0000000..c7f559b --- /dev/null +++ b/examples/blinky/atmel_samv71_xplained_ultra.cfg @@ -0,0 +1,15 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +# +# Atmel SAMV71 Xplained Ultra evaluation kit. +# http://www.atmel.com/tools/ATSAMV71-XULT.aspx +# +# To connect using the EDBG chip on the dev kit over USB, you will +# first need to source [find interface/cmsis-dap.cfg] +# however, since this board also has a SWD+ETM connector, we don't +# automatically source that file here. + +set CHIPNAME samv71 + +source [find interface/cmsis-dap.cfg] +source [find target/atsamv.cfg] diff --git a/examples/blinky/conanfile.py b/examples/blinky/conanfile.py new file mode 100644 index 0000000..5d42102 --- /dev/null +++ b/examples/blinky/conanfile.py @@ -0,0 +1,40 @@ +from conan import ConanFile +from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps + + +class SAMV71BlinkyRecipe(ConanFile): + name = "SAMV71-Conan-Blinky" + version = "1.0" + package_type = "application" + + # Optional metadata + license = "MIT" + author = "Grigoris Pavlakis " + url = "https://github.com/PeakSat/minimal_dev_setup" + description = "Minimal bring-up (blinky) for ATSAMV71Q21B using CMake and Conan" + # Binary configuration + settings = "os", "compiler", "build_type", "arch" + + requires = "samv71-dfp/4.9.117", "harmony/3.0" + + # Sources are located in the same place as this recipe, copy them to the recipe + exports_sources = "CMakeLists.txt", "src/*" + + def layout(self): + cmake_layout(self) + + def generate(self): + deps = CMakeDeps(self) + deps.generate() + tc = CMakeToolchain(self) + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + cmake = CMake(self) + cmake.install() + diff --git a/examples/blinky/mcu-config/core.yml b/examples/blinky/mcu-config/core.yml new file mode 100644 index 0000000..db8046e --- /dev/null +++ b/examples/blinky/mcu-config/core.yml @@ -0,0 +1,757 @@ +format_version: v1.0 +type: UniqueComponent +attributes: {id: core} +children: +- type: Symbols + children: + - type: Integer + attributes: {id: ACC_CLOCK_FREQUENCY} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: '150000000'} + - type: Integer + attributes: {id: AES_CLOCK_FREQUENCY} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: '150000000'} + - type: Integer + attributes: {id: AFEC0_CLOCK_FREQUENCY} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: '150000000'} + - type: Integer + attributes: {id: AFEC1_CLOCK_FREQUENCY} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: '150000000'} + - type: KeyValueSet + attributes: {id: COMPILER_CHOICE} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: '0'} + - type: String + attributes: {id: CPU_CLOCK_FREQUENCY} + children: + - type: Values + children: + - type: User + attributes: {value: '300000000'} + - type: Menu + attributes: {id: CoreIARMenu} + children: + - type: Attributes + children: + - type: Boolean + attributes: {id: visible} + children: + - {type: Value, value: 'false'} + - type: Menu + attributes: {id: CoreKEILMenu} + children: + - type: Attributes + children: + - type: Boolean + attributes: {id: visible} + children: + - {type: Value, value: 'false'} + - type: Integer + attributes: {id: DACC_CLOCK_FREQUENCY} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: '150000000'} + - type: KeyValueSet + attributes: {id: DEVICE_BOOT} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: '1'} + - type: KeyValueSet + attributes: {id: DEVICE_SECURITY} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: '0'} + - type: KeyValueSet + attributes: {id: DEVICE_TCM_SIZE} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: '0'} + - type: Integer + attributes: {id: GMAC_CLOCK_FREQUENCY} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: '150000000'} + - type: Integer + attributes: {id: HSMCI_CLOCK_FREQUENCY} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: '150000000'} + - type: String + attributes: {id: I2S0_CLOCK_FREQUENCY} + children: + - type: Values + children: + - type: User + attributes: {value: '32000'} + - type: Integer + attributes: {id: ICM_CLOCK_FREQUENCY} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: '150000000'} + - type: Integer + attributes: {id: ISI_CLOCK_FREQUENCY} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: '150000000'} + - type: String + attributes: {id: KEIL_STACK_HEAP_SIZE} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: '0x1200'} + - type: String + attributes: {id: MASTER_CLOCK_FREQUENCY} + children: + - type: Values + children: + - type: User + attributes: {value: '150000000'} + - type: Integer + attributes: {id: MLB_CLOCK_FREQUENCY} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: '150000000'} + - type: Boolean + attributes: {id: NVIC_-1_0_ENABLE} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: 'true'} + - type: Boolean + attributes: {id: NVIC_-1_0_HANDLER_LOCK} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: 'true'} + - type: Boolean + attributes: {id: NVIC_14_0_ENABLE} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: 'true'} + - type: String + attributes: {id: NVIC_14_0_HANDLER} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: USART1_InterruptHandler} + - type: Boolean + attributes: {id: NVIC_14_0_HANDLER_LOCK} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: 'true'} + - type: Boolean + attributes: {id: NVIC_4_0_ENABLE} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: 'false'} + - type: String + attributes: {id: NVIC_4_0_HANDLER} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: WDT_Handler} + - type: Boolean + attributes: {id: NVIC_4_0_HANDLER_LOCK} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: 'false'} + - type: Boolean + attributes: {id: NVIC_63_0_ENABLE} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: 'false'} + - type: String + attributes: {id: NVIC_63_0_HANDLER} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: RSWDT_Handler} + - type: Boolean + attributes: {id: NVIC_63_0_HANDLER_LOCK} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: 'false'} + - type: String + attributes: {id: PCK0_CLOCK_FREQUENCY} + children: + - type: Values + children: + - type: User + attributes: {value: '32000'} + - type: String + attributes: {id: PIN_46_DIR} + children: + - type: Values + children: + - type: User + attributes: {value: Out} + - type: String + attributes: {id: PIN_46_DRIVER} + children: + - type: Values + children: + - type: User + attributes: {value: ''} + - type: String + attributes: {id: PIN_46_FUNCTION_NAME} + children: + - type: Values + children: + - type: User + attributes: {value: GPIO_PA23} + - type: String + attributes: {id: PIN_46_FUNCTION_TYPE} + children: + - type: Values + children: + - type: User + attributes: {value: GPIO} + - type: String + attributes: {id: PIN_46_LAT} + children: + - type: Values + children: + - type: User + attributes: {value: High} + - type: String + attributes: {id: PIN_46_PD} + children: + - type: Values + children: + - type: User + attributes: {value: ''} + - type: String + attributes: {id: PIN_46_PERIPHERAL_FUNCTION} + children: + - type: Values + children: + - type: User + attributes: {value: GPIO} + - type: String + attributes: {id: PIN_46_PU} + children: + - type: Values + children: + - type: User + attributes: {value: ''} + - type: Hex + attributes: {id: PIOA_ABCDSR1_VALUE} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: '0'} + - type: Hex + attributes: {id: PIOA_ABCDSR2_VALUE} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: '0'} + - type: Boolean + attributes: {id: PIOA_CLOCK_ENABLE} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: 'true'} + - type: Integer + attributes: {id: PIOA_CLOCK_FREQUENCY} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: '150000000'} + - type: Hex + attributes: {id: PIOA_DRIVER_VALUE} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: '0'} + - type: Hex + attributes: {id: PIOA_OER_VALUE} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: '8388608'} + - type: Hex + attributes: {id: PIOA_PDR_VALUE} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: '0'} + - type: Hex + attributes: {id: PIOA_PPDEN_VALUE} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: '0'} + - type: Hex + attributes: {id: PIOA_PUER_VALUE} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: '0'} + - type: Hex + attributes: {id: PIOA_SODR_VALUE} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: '8388608'} + - type: Boolean + attributes: {id: PIOB_CLOCK_ENABLE} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: 'true'} + - type: Integer + attributes: {id: PIOB_CLOCK_FREQUENCY} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: '150000000'} + - type: Boolean + attributes: {id: PIOC_CLOCK_ENABLE} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: 'true'} + - type: Integer + attributes: {id: PIOC_CLOCK_FREQUENCY} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: '150000000'} + - type: Boolean + attributes: {id: PIOD_CLOCK_ENABLE} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: 'true'} + - type: Integer + attributes: {id: PIOD_CLOCK_FREQUENCY} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: '150000000'} + - type: Boolean + attributes: {id: PIOE_CLOCK_ENABLE} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: 'true'} + - type: Integer + attributes: {id: PIOE_CLOCK_FREQUENCY} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: '150000000'} + - type: Hex + attributes: {id: PMC_PCER0} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: '220160'} + - type: KeyValueSet + attributes: {id: PMC_PCR_GCLK0CSS} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: '0'} + - type: KeyValueSet + attributes: {id: PMC_PCR_GCLK1CSS} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: '0'} + - type: Boolean + attributes: {id: PMC_SCER_PCK6} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: 'false'} + - type: Boolean + attributes: {id: PMC_SCER_PCK7} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: 'false'} + - type: Integer + attributes: {id: PMC_USB_USBDIV} + children: + - type: Values + children: + - type: User + attributes: {value: '16'} + - type: Integer + attributes: {id: PWM0_CLOCK_FREQUENCY} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: '150000000'} + - type: Integer + attributes: {id: PWM1_CLOCK_FREQUENCY} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: '150000000'} + - type: Integer + attributes: {id: QSPI_CLOCK_FREQUENCY} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: '150000000'} + - type: Boolean + attributes: {id: RSWDT_INTERRUPT_ENABLE} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: 'false'} + - type: Boolean + attributes: {id: RSWDT_INTERRUPT_ENABLE_UPDATE} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: 'true'} + - type: String + attributes: {id: RSWDT_INTERRUPT_HANDLER} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: RSWDT_Handler} + - type: Boolean + attributes: {id: RSWDT_INTERRUPT_HANDLER_LOCK} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: 'false'} + - type: Integer + attributes: {id: SMC_CLOCK_FREQUENCY} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: '150000000'} + - type: Integer + attributes: {id: SPI0_CLOCK_FREQUENCY} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: '150000000'} + - type: Integer + attributes: {id: SPI1_CLOCK_FREQUENCY} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: '150000000'} + - type: Integer + attributes: {id: SSC_CLOCK_FREQUENCY} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: '150000000'} + - type: String + attributes: {id: SYSTICK_CLOCK_FREQUENCY} + children: + - type: Values + children: + - type: User + attributes: {value: '150000000'} + - type: File + attributes: {id: SYSTICK_FILE_0} + children: + - type: Attributes + children: + - type: Boolean + attributes: {id: enabled} + children: + - {type: Value, value: 'true'} + - type: File + attributes: {id: SYSTICK_FILE_1} + children: + - type: Attributes + children: + - type: Boolean + attributes: {id: enabled} + children: + - {type: Value, value: 'true'} + - type: File + attributes: {id: SYSTICK_FILE_2} + children: + - type: Attributes + children: + - type: Boolean + attributes: {id: enabled} + children: + - {type: Value, value: 'true'} + - type: Menu + attributes: {id: SYSTICK_MENU_0} + children: + - type: Attributes + children: + - type: Boolean + attributes: {id: visible} + children: + - {type: Value, value: 'true'} + - type: String + attributes: {id: SYSTICK_PERIOD} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: '0x493E0'} + - type: Integer + attributes: {id: SYSTICK_PERIOD_US} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: '1000'} + - type: Boolean + attributes: {id: SysTick_INTERRUPT_ENABLE} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: 'true'} + - type: Boolean + attributes: {id: SysTick_INTERRUPT_ENABLE_UPDATE} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: 'false'} + - type: Boolean + attributes: {id: SysTick_INTERRUPT_HANDLER_LOCK} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: 'true'} + - type: Boolean + attributes: {id: TCM_ENABLE} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: 'false'} + - type: String + attributes: {id: TCM_SIZE} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: 0 KB} + - type: Integer + attributes: {id: TRNG_CLOCK_FREQUENCY} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: '150000000'} + - type: Integer + attributes: {id: TWIHS0_CLOCK_FREQUENCY} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: '150000000'} + - type: Integer + attributes: {id: TWIHS1_CLOCK_FREQUENCY} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: '150000000'} + - type: Integer + attributes: {id: TWIHS2_CLOCK_FREQUENCY} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: '150000000'} + - type: Boolean + attributes: {id: USART1_CLOCK_ENABLE} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: usart1, value: 'true'} + - type: Integer + attributes: {id: USART1_CLOCK_FREQUENCY} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: '150000000'} + - type: Boolean + attributes: {id: USART1_INTERRUPT_ENABLE} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: usart1, value: 'true'} + - type: Boolean + attributes: {id: USART1_INTERRUPT_ENABLE_UPDATE} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: 'false'} + - type: String + attributes: {id: USART1_INTERRUPT_HANDLER} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: usart1, value: USART1_InterruptHandler} + - type: Boolean + attributes: {id: USART1_INTERRUPT_HANDLER_LOCK} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: usart1, value: 'true'} + - type: Boolean + attributes: {id: USE_SYSTICK_INTERRUPT} + children: + - type: Values + children: + - type: User + attributes: {value: 'true'} + - type: Boolean + attributes: {id: WDT_INTERRUPT_ENABLE} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: 'false'} + - type: Boolean + attributes: {id: WDT_INTERRUPT_ENABLE_UPDATE} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: 'true'} + - type: String + attributes: {id: WDT_INTERRUPT_HANDLER} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: WDT_Handler} + - type: Boolean + attributes: {id: WDT_INTERRUPT_HANDLER_LOCK} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: 'false'} + - type: Integer + attributes: {id: XDMAC_CLOCK_FREQUENCY} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: core, value: '150000000'} + - type: Boolean + attributes: {id: systickEnable} + children: + - type: Values + children: + - type: User + attributes: {value: 'true'} + - type: File + attributes: {id: systickSystemInitFile} + children: + - type: Attributes + children: + - type: Boolean + attributes: {id: enabled} + children: + - {type: Value, value: 'true'} +- type: ElementPosition + attributes: {x: '240', y: '20', id: core} diff --git a/examples/blinky/mcu-config/dfp.yml b/examples/blinky/mcu-config/dfp.yml new file mode 100644 index 0000000..eff2f08 --- /dev/null +++ b/examples/blinky/mcu-config/dfp.yml @@ -0,0 +1,6 @@ +format_version: v1.0 +type: UniqueComponent +attributes: {id: dfp} +children: +- type: ElementPosition + attributes: {x: '20', y: '20', id: dfp} diff --git a/examples/blinky/mcu-config/efc.yml b/examples/blinky/mcu-config/efc.yml new file mode 100644 index 0000000..ed3a8c3 --- /dev/null +++ b/examples/blinky/mcu-config/efc.yml @@ -0,0 +1,15 @@ +format_version: v1.0 +type: UniqueComponent +attributes: {id: efc} +children: +- type: Symbols + children: + - type: Integer + attributes: {id: NVM_RWS} + children: + - type: Values + children: + - type: Dynamic + attributes: {id: efc, value: '6'} +- type: ElementPosition + attributes: {x: '30', y: '60', id: efc} diff --git a/examples/blinky/src/main.c b/examples/blinky/src/main.c new file mode 100644 index 0000000..b41b567 --- /dev/null +++ b/examples/blinky/src/main.c @@ -0,0 +1,36 @@ +/* + * main.c - Blinky with UART for SAMV71 Xplained Ultra + * + * Created: 24 July 2024 + * Author : Grigoris Pavlakis + */ + +/* + * IWYU (include what you use) is best practice! + * Here, the peripheral headers are transitively included by + */ + +#include "pio/plib_pio.h" +#include "systick/plib_systick.h" +//#include "usart/plib_usart1.h" + +void SYS_Initialize ( void* data ); + +int main(void) +{ + /* Replace with your application code */ + + SYS_Initialize(NULL); + SYSTICK_TimerStart(); + char string[15] = "Hello World!\r\n"; + + while (1) + { + SYSTICK_DelayMs(1000); + PIO_PinClear(PIO_PIN_PA23); + SYSTICK_DelayMs(1000); + PIO_PinSet(PIO_PIN_PA23); + +// USART1_Write(&string, 15); + } +} From 337e2b889e06801957c83f713344171c592c25c1 Mon Sep 17 00:00:00 2001 From: Grigoris Pavlakis Date: Thu, 1 Aug 2024 11:40:20 +0300 Subject: [PATCH 2/3] examples(blinky): remove extraneous detail --- examples/blinky/CMakeLists.txt | 12 +- examples/blinky/conanfile.py | 22 +- examples/blinky/mcu-config/core.yml | 368 +--------------------------- examples/blinky/src/main.c | 8 +- 4 files changed, 17 insertions(+), 393 deletions(-) diff --git a/examples/blinky/CMakeLists.txt b/examples/blinky/CMakeLists.txt index 0ba0e35..b711afd 100644 --- a/examples/blinky/CMakeLists.txt +++ b/examples/blinky/CMakeLists.txt @@ -1,21 +1,19 @@ cmake_minimum_required(VERSION 3.19.2) -project(OBC_SOFTWARE C CXX ASM) +project(Blinky C) find_package(Harmony REQUIRED) find_package(SAMV71-DFP COMPONENTS SAMV71Q21B REQUIRED) -# TODO: support multiple config names in separate directories (CONFIG_NAME argument) add_harmony_config( MCU_MODEL ATSAMV71Q21B YAML_FILES ./mcu-config/core.yml ./mcu-config/dfp.yml ./mcu-config/efc.yml - ./mcu-config/usart1.yml ) -add_executable(${PROJECT_NAME}) -target_include_directories(${PROJECT_NAME} PRIVATE include/) -target_sources(${PROJECT_NAME} PRIVATE src/main.c) -target_link_libraries(${PROJECT_NAME} PRIVATE samv71-dfp::SAMV71Q21B::Startup samv71-dfp::SAMV71Q21B::Linker::Flash Harmony::SysInit Harmony::PeripheralDrivers) +add_executable(Blinky) +target_include_directories(Blinky PRIVATE include/) +target_sources(Blinky PRIVATE src/main.c) +target_link_libraries(Blinky PRIVATE samv71-dfp::SAMV71Q21B::Startup samv71-dfp::SAMV71Q21B::Linker::Flash Harmony::SysInit Harmony::PeripheralDrivers) diff --git a/examples/blinky/conanfile.py b/examples/blinky/conanfile.py index 5d42102..0ebe803 100644 --- a/examples/blinky/conanfile.py +++ b/examples/blinky/conanfile.py @@ -1,20 +1,22 @@ from conan import ConanFile -from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps +from conan.tools.cmake import CMake, cmake_layout -class SAMV71BlinkyRecipe(ConanFile): - name = "SAMV71-Conan-Blinky" +class BlinkyRecipe(ConanFile): + name = "BlinkyExample" version = "1.0" package_type = "application" - # Optional metadata + # Authorship metadata license = "MIT" author = "Grigoris Pavlakis " url = "https://github.com/PeakSat/minimal_dev_setup" - description = "Minimal bring-up (blinky) for ATSAMV71Q21B using CMake and Conan" - # Binary configuration - settings = "os", "compiler", "build_type", "arch" + description = "Blinky example for Atmel SAMV71 Xplained Ultra" + settings = "build_type", "arch" + generators = "CMakeToolchain", "CMakeDeps" + + # Dependencies requires = "samv71-dfp/4.9.117", "harmony/3.0" # Sources are located in the same place as this recipe, copy them to the recipe @@ -23,12 +25,6 @@ class SAMV71BlinkyRecipe(ConanFile): def layout(self): cmake_layout(self) - def generate(self): - deps = CMakeDeps(self) - deps.generate() - tc = CMakeToolchain(self) - tc.generate() - def build(self): cmake = CMake(self) cmake.configure() diff --git a/examples/blinky/mcu-config/core.yml b/examples/blinky/mcu-config/core.yml index db8046e..e3991a8 100644 --- a/examples/blinky/mcu-config/core.yml +++ b/examples/blinky/mcu-config/core.yml @@ -4,34 +4,6 @@ attributes: {id: core} children: - type: Symbols children: - - type: Integer - attributes: {id: ACC_CLOCK_FREQUENCY} - children: - - type: Values - children: - - type: Dynamic - attributes: {id: core, value: '150000000'} - - type: Integer - attributes: {id: AES_CLOCK_FREQUENCY} - children: - - type: Values - children: - - type: Dynamic - attributes: {id: core, value: '150000000'} - - type: Integer - attributes: {id: AFEC0_CLOCK_FREQUENCY} - children: - - type: Values - children: - - type: Dynamic - attributes: {id: core, value: '150000000'} - - type: Integer - attributes: {id: AFEC1_CLOCK_FREQUENCY} - children: - - type: Values - children: - - type: Dynamic - attributes: {id: core, value: '150000000'} - type: KeyValueSet attributes: {id: COMPILER_CHOICE} children: @@ -39,13 +11,6 @@ children: children: - type: Dynamic attributes: {id: core, value: '0'} - - type: String - attributes: {id: CPU_CLOCK_FREQUENCY} - children: - - type: Values - children: - - type: User - attributes: {value: '300000000'} - type: Menu attributes: {id: CoreIARMenu} children: @@ -64,13 +29,6 @@ children: attributes: {id: visible} children: - {type: Value, value: 'false'} - - type: Integer - attributes: {id: DACC_CLOCK_FREQUENCY} - children: - - type: Values - children: - - type: Dynamic - attributes: {id: core, value: '150000000'} - type: KeyValueSet attributes: {id: DEVICE_BOOT} children: @@ -92,41 +50,6 @@ children: children: - type: Dynamic attributes: {id: core, value: '0'} - - type: Integer - attributes: {id: GMAC_CLOCK_FREQUENCY} - children: - - type: Values - children: - - type: Dynamic - attributes: {id: core, value: '150000000'} - - type: Integer - attributes: {id: HSMCI_CLOCK_FREQUENCY} - children: - - type: Values - children: - - type: Dynamic - attributes: {id: core, value: '150000000'} - - type: String - attributes: {id: I2S0_CLOCK_FREQUENCY} - children: - - type: Values - children: - - type: User - attributes: {value: '32000'} - - type: Integer - attributes: {id: ICM_CLOCK_FREQUENCY} - children: - - type: Values - children: - - type: Dynamic - attributes: {id: core, value: '150000000'} - - type: Integer - attributes: {id: ISI_CLOCK_FREQUENCY} - children: - - type: Values - children: - - type: Dynamic - attributes: {id: core, value: '150000000'} - type: String attributes: {id: KEIL_STACK_HEAP_SIZE} children: @@ -134,20 +57,6 @@ children: children: - type: Dynamic attributes: {id: core, value: '0x1200'} - - type: String - attributes: {id: MASTER_CLOCK_FREQUENCY} - children: - - type: Values - children: - - type: User - attributes: {value: '150000000'} - - type: Integer - attributes: {id: MLB_CLOCK_FREQUENCY} - children: - - type: Values - children: - - type: Dynamic - attributes: {id: core, value: '150000000'} - type: Boolean attributes: {id: NVIC_-1_0_ENABLE} children: @@ -162,27 +71,6 @@ children: children: - type: Dynamic attributes: {id: core, value: 'true'} - - type: Boolean - attributes: {id: NVIC_14_0_ENABLE} - children: - - type: Values - children: - - type: Dynamic - attributes: {id: core, value: 'true'} - - type: String - attributes: {id: NVIC_14_0_HANDLER} - children: - - type: Values - children: - - type: Dynamic - attributes: {id: core, value: USART1_InterruptHandler} - - type: Boolean - attributes: {id: NVIC_14_0_HANDLER_LOCK} - children: - - type: Values - children: - - type: Dynamic - attributes: {id: core, value: 'true'} - type: Boolean attributes: {id: NVIC_4_0_ENABLE} children: @@ -225,13 +113,6 @@ children: children: - type: Dynamic attributes: {id: core, value: 'false'} - - type: String - attributes: {id: PCK0_CLOCK_FREQUENCY} - children: - - type: Values - children: - - type: User - attributes: {value: '32000'} - type: String attributes: {id: PIN_46_DIR} children: @@ -239,13 +120,6 @@ children: children: - type: User attributes: {value: Out} - - type: String - attributes: {id: PIN_46_DRIVER} - children: - - type: Values - children: - - type: User - attributes: {value: ''} - type: String attributes: {id: PIN_46_FUNCTION_NAME} children: @@ -263,13 +137,6 @@ children: - type: String attributes: {id: PIN_46_LAT} children: - - type: Values - children: - - type: User - attributes: {value: High} - - type: String - attributes: {id: PIN_46_PD} - children: - type: Values children: - type: User @@ -281,13 +148,6 @@ children: children: - type: User attributes: {value: GPIO} - - type: String - attributes: {id: PIN_46_PU} - children: - - type: Values - children: - - type: User - attributes: {value: ''} - type: Hex attributes: {id: PIOA_ABCDSR1_VALUE} children: @@ -309,20 +169,6 @@ children: children: - type: Dynamic attributes: {id: core, value: 'true'} - - type: Integer - attributes: {id: PIOA_CLOCK_FREQUENCY} - children: - - type: Values - children: - - type: Dynamic - attributes: {id: core, value: '150000000'} - - type: Hex - attributes: {id: PIOA_DRIVER_VALUE} - children: - - type: Values - children: - - type: Dynamic - attributes: {id: core, value: '0'} - type: Hex attributes: {id: PIOA_OER_VALUE} children: @@ -337,27 +183,13 @@ children: children: - type: Dynamic attributes: {id: core, value: '0'} - - type: Hex - attributes: {id: PIOA_PPDEN_VALUE} - children: - - type: Values - children: - - type: Dynamic - attributes: {id: core, value: '0'} - - type: Hex - attributes: {id: PIOA_PUER_VALUE} - children: - - type: Values - children: - - type: Dynamic - attributes: {id: core, value: '0'} - type: Hex attributes: {id: PIOA_SODR_VALUE} children: - type: Values children: - type: Dynamic - attributes: {id: core, value: '8388608'} + attributes: {id: core, value: '0'} - type: Boolean attributes: {id: PIOB_CLOCK_ENABLE} children: @@ -365,13 +197,6 @@ children: children: - type: Dynamic attributes: {id: core, value: 'true'} - - type: Integer - attributes: {id: PIOB_CLOCK_FREQUENCY} - children: - - type: Values - children: - - type: Dynamic - attributes: {id: core, value: '150000000'} - type: Boolean attributes: {id: PIOC_CLOCK_ENABLE} children: @@ -379,13 +204,6 @@ children: children: - type: Dynamic attributes: {id: core, value: 'true'} - - type: Integer - attributes: {id: PIOC_CLOCK_FREQUENCY} - children: - - type: Values - children: - - type: Dynamic - attributes: {id: core, value: '150000000'} - type: Boolean attributes: {id: PIOD_CLOCK_ENABLE} children: @@ -393,13 +211,6 @@ children: children: - type: Dynamic attributes: {id: core, value: 'true'} - - type: Integer - attributes: {id: PIOD_CLOCK_FREQUENCY} - children: - - type: Values - children: - - type: Dynamic - attributes: {id: core, value: '150000000'} - type: Boolean attributes: {id: PIOE_CLOCK_ENABLE} children: @@ -407,20 +218,13 @@ children: children: - type: Dynamic attributes: {id: core, value: 'true'} - - type: Integer - attributes: {id: PIOE_CLOCK_FREQUENCY} - children: - - type: Values - children: - - type: Dynamic - attributes: {id: core, value: '150000000'} - type: Hex attributes: {id: PMC_PCER0} children: - type: Values children: - type: Dynamic - attributes: {id: core, value: '220160'} + attributes: {id: core, value: '203776'} - type: KeyValueSet attributes: {id: PMC_PCR_GCLK0CSS} children: @@ -435,48 +239,6 @@ children: children: - type: Dynamic attributes: {id: core, value: '0'} - - type: Boolean - attributes: {id: PMC_SCER_PCK6} - children: - - type: Values - children: - - type: Dynamic - attributes: {id: core, value: 'false'} - - type: Boolean - attributes: {id: PMC_SCER_PCK7} - children: - - type: Values - children: - - type: Dynamic - attributes: {id: core, value: 'false'} - - type: Integer - attributes: {id: PMC_USB_USBDIV} - children: - - type: Values - children: - - type: User - attributes: {value: '16'} - - type: Integer - attributes: {id: PWM0_CLOCK_FREQUENCY} - children: - - type: Values - children: - - type: Dynamic - attributes: {id: core, value: '150000000'} - - type: Integer - attributes: {id: PWM1_CLOCK_FREQUENCY} - children: - - type: Values - children: - - type: Dynamic - attributes: {id: core, value: '150000000'} - - type: Integer - attributes: {id: QSPI_CLOCK_FREQUENCY} - children: - - type: Values - children: - - type: Dynamic - attributes: {id: core, value: '150000000'} - type: Boolean attributes: {id: RSWDT_INTERRUPT_ENABLE} children: @@ -505,41 +267,6 @@ children: children: - type: Dynamic attributes: {id: core, value: 'false'} - - type: Integer - attributes: {id: SMC_CLOCK_FREQUENCY} - children: - - type: Values - children: - - type: Dynamic - attributes: {id: core, value: '150000000'} - - type: Integer - attributes: {id: SPI0_CLOCK_FREQUENCY} - children: - - type: Values - children: - - type: Dynamic - attributes: {id: core, value: '150000000'} - - type: Integer - attributes: {id: SPI1_CLOCK_FREQUENCY} - children: - - type: Values - children: - - type: Dynamic - attributes: {id: core, value: '150000000'} - - type: Integer - attributes: {id: SSC_CLOCK_FREQUENCY} - children: - - type: Values - children: - - type: Dynamic - attributes: {id: core, value: '150000000'} - - type: String - attributes: {id: SYSTICK_CLOCK_FREQUENCY} - children: - - type: Values - children: - - type: User - attributes: {value: '150000000'} - type: File attributes: {id: SYSTICK_FILE_0} children: @@ -576,20 +303,6 @@ children: attributes: {id: visible} children: - {type: Value, value: 'true'} - - type: String - attributes: {id: SYSTICK_PERIOD} - children: - - type: Values - children: - - type: Dynamic - attributes: {id: core, value: '0x493E0'} - - type: Integer - attributes: {id: SYSTICK_PERIOD_US} - children: - - type: Values - children: - - type: Dynamic - attributes: {id: core, value: '1000'} - type: Boolean attributes: {id: SysTick_INTERRUPT_ENABLE} children: @@ -625,76 +338,6 @@ children: children: - type: Dynamic attributes: {id: core, value: 0 KB} - - type: Integer - attributes: {id: TRNG_CLOCK_FREQUENCY} - children: - - type: Values - children: - - type: Dynamic - attributes: {id: core, value: '150000000'} - - type: Integer - attributes: {id: TWIHS0_CLOCK_FREQUENCY} - children: - - type: Values - children: - - type: Dynamic - attributes: {id: core, value: '150000000'} - - type: Integer - attributes: {id: TWIHS1_CLOCK_FREQUENCY} - children: - - type: Values - children: - - type: Dynamic - attributes: {id: core, value: '150000000'} - - type: Integer - attributes: {id: TWIHS2_CLOCK_FREQUENCY} - children: - - type: Values - children: - - type: Dynamic - attributes: {id: core, value: '150000000'} - - type: Boolean - attributes: {id: USART1_CLOCK_ENABLE} - children: - - type: Values - children: - - type: Dynamic - attributes: {id: usart1, value: 'true'} - - type: Integer - attributes: {id: USART1_CLOCK_FREQUENCY} - children: - - type: Values - children: - - type: Dynamic - attributes: {id: core, value: '150000000'} - - type: Boolean - attributes: {id: USART1_INTERRUPT_ENABLE} - children: - - type: Values - children: - - type: Dynamic - attributes: {id: usart1, value: 'true'} - - type: Boolean - attributes: {id: USART1_INTERRUPT_ENABLE_UPDATE} - children: - - type: Values - children: - - type: Dynamic - attributes: {id: core, value: 'false'} - - type: String - attributes: {id: USART1_INTERRUPT_HANDLER} - children: - - type: Values - children: - - type: Dynamic - attributes: {id: usart1, value: USART1_InterruptHandler} - - type: Boolean - attributes: {id: USART1_INTERRUPT_HANDLER_LOCK} - children: - - type: Values - children: - - type: Dynamic - attributes: {id: usart1, value: 'true'} - type: Boolean attributes: {id: USE_SYSTICK_INTERRUPT} children: @@ -730,13 +373,6 @@ children: children: - type: Dynamic attributes: {id: core, value: 'false'} - - type: Integer - attributes: {id: XDMAC_CLOCK_FREQUENCY} - children: - - type: Values - children: - - type: Dynamic - attributes: {id: core, value: '150000000'} - type: Boolean attributes: {id: systickEnable} children: diff --git a/examples/blinky/src/main.c b/examples/blinky/src/main.c index b41b567..262619e 100644 --- a/examples/blinky/src/main.c +++ b/examples/blinky/src/main.c @@ -1,5 +1,5 @@ /* - * main.c - Blinky with UART for SAMV71 Xplained Ultra + * main.c - Blinky for SAMV71 Xplained Ultra * * Created: 24 July 2024 * Author : Grigoris Pavlakis @@ -12,17 +12,13 @@ #include "pio/plib_pio.h" #include "systick/plib_systick.h" -//#include "usart/plib_usart1.h" void SYS_Initialize ( void* data ); int main(void) { - /* Replace with your application code */ - SYS_Initialize(NULL); SYSTICK_TimerStart(); - char string[15] = "Hello World!\r\n"; while (1) { @@ -30,7 +26,5 @@ int main(void) PIO_PinClear(PIO_PIN_PA23); SYSTICK_DelayMs(1000); PIO_PinSet(PIO_PIN_PA23); - -// USART1_Write(&string, 15); } } From df2f2025f0f0869eec86b2693efff336d36df47d Mon Sep 17 00:00:00 2001 From: Grigoris Pavlakis Date: Mon, 12 Aug 2024 16:18:49 +0300 Subject: [PATCH 3/3] examples(blinky): fix wrong build instructions --- examples/blinky/README.md | 28 +++++++++++++++++++++++----- examples/blinky/src/main.c | 9 +++++++-- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/examples/blinky/README.md b/examples/blinky/README.md index 6768308..7f56d31 100644 --- a/examples/blinky/README.md +++ b/examples/blinky/README.md @@ -1,8 +1,26 @@ -# SAMV71 blinky +# SAMV71 blinky example + +This example blinks the User LED on a SAMV71 Xplained Ultra board +with a 1 sec interval. ## Building -To build this, run the following: -- `cmake . -Bbuild -DCMAKE_TOOLCHAIN_FILE=./cmake/samv71-toolchain.cmake` -- `cd build` -- `make` + +To build this, run the following (assuming you have installed the +Conan packages) +- `conan build . -pr=baremetal-samv71-armv7 -s build_type=Debug` + +If for some reason you want to run the build manually, these are +the steps: +- `conan install . -pr=baremetal-samv71-armv7` +- `cmake . -Bbuild/Debug -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=./build/Debug/generators/conan_toolchain.cmake -GNinja` +- `cd build/Debug/` +- `ninja` + +The produced `Blinky.elf` file can be found under `./build/Debug/`. +For a release build, change `Debug` to `Release` in all the commands above. + +## Uploading + +Use your favorite debug/flash tool for uploading. Refer to your tool's documentation +or to the main `README.md` file for a basic procedure using [OpenOCD](https://openocd.org/) diff --git a/examples/blinky/src/main.c b/examples/blinky/src/main.c index 262619e..90b4a84 100644 --- a/examples/blinky/src/main.c +++ b/examples/blinky/src/main.c @@ -6,8 +6,13 @@ */ /* - * IWYU (include what you use) is best practice! - * Here, the peripheral headers are transitively included by + * Although SYS_Initialize() is declared for us in 'definitions.h', + * this header will transitively include all the peripheral + * libraries, which is a bad practice since it makes for + * 'spooky-action-at-a-distance' wrt. missing errors. + * + * Prefer directly including the peripheral headers you need. It's + * more verbose but the gain in explicitness helps when debugging. */ #include "pio/plib_pio.h"