diff --git a/.mxproject b/.mxproject index 894f428..9ddb7aa 100644 --- a/.mxproject +++ b/.mxproject @@ -1,32 +1,32 @@ -[PreviousLibFiles] -LibFiles=Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_adc.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_ll_adc.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_adc_ex.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_def.h;Drivers\STM32L4xx_HAL_Driver\Inc\Legacy\stm32_hal_legacy.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_i2c.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_i2c_ex.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_rcc.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_rcc_ex.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_flash.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_flash_ex.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_flash_ramfunc.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_gpio.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_gpio_ex.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_dma.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_dma_ex.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_pwr.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_pwr_ex.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_cortex.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_exti.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_can.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_dac.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_dac_ex.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_iwdg.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_spi.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_spi_ex.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_tim.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_tim_ex.h;Middlewares\Third_Party\FreeRTOS\Source\include\croutine.h;Middlewares\Third_Party\FreeRTOS\Source\include\deprecated_definitions.h;Middlewares\Third_Party\FreeRTOS\Source\include\event_groups.h;Middlewares\Third_Party\FreeRTOS\Source\include\FreeRTOS.h;Middlewares\Third_Party\FreeRTOS\Source\include\list.h;Middlewares\Third_Party\FreeRTOS\Source\include\message_buffer.h;Middlewares\Third_Party\FreeRTOS\Source\include\mpu_prototypes.h;Middlewares\Third_Party\FreeRTOS\Source\include\mpu_wrappers.h;Middlewares\Third_Party\FreeRTOS\Source\include\portable.h;Middlewares\Third_Party\FreeRTOS\Source\include\projdefs.h;Middlewares\Third_Party\FreeRTOS\Source\include\queue.h;Middlewares\Third_Party\FreeRTOS\Source\include\semphr.h;Middlewares\Third_Party\FreeRTOS\Source\include\stack_macros.h;Middlewares\Third_Party\FreeRTOS\Source\include\StackMacros.h;Middlewares\Third_Party\FreeRTOS\Source\include\stream_buffer.h;Middlewares\Third_Party\FreeRTOS\Source\include\task.h;Middlewares\Third_Party\FreeRTOS\Source\include\timers.h;Middlewares\Third_Party\FreeRTOS\Source\include\atomic.h;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os2.h;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os.h;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\freertos_mpool.h;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\freertos_os2.h;Middlewares\Third_Party\FreeRTOS\Source\portable\GCC\ARM_CM4F\portmacro.h;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_adc.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_adc_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_i2c.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_i2c_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_rcc.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_rcc_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_flash.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_flash_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_flash_ramfunc.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_gpio.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_dma.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_dma_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_pwr.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_pwr_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_cortex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_exti.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_can.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_dac.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_dac_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_iwdg.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_spi.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_spi_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_tim.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_tim_ex.c;Middlewares\Third_Party\FreeRTOS\Source\croutine.c;Middlewares\Third_Party\FreeRTOS\Source\event_groups.c;Middlewares\Third_Party\FreeRTOS\Source\list.c;Middlewares\Third_Party\FreeRTOS\Source\queue.c;Middlewares\Third_Party\FreeRTOS\Source\stream_buffer.c;Middlewares\Third_Party\FreeRTOS\Source\tasks.c;Middlewares\Third_Party\FreeRTOS\Source\timers.c;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os2.c;Middlewares\Third_Party\FreeRTOS\Source\portable\MemMang\heap_4.c;Middlewares\Third_Party\FreeRTOS\Source\portable\GCC\ARM_CM4F\port.c;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_adc.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_ll_adc.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_adc_ex.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_def.h;Drivers\STM32L4xx_HAL_Driver\Inc\Legacy\stm32_hal_legacy.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_i2c.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_i2c_ex.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_rcc.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_rcc_ex.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_flash.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_flash_ex.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_flash_ramfunc.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_gpio.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_gpio_ex.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_dma.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_dma_ex.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_pwr.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_pwr_ex.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_cortex.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_exti.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_can.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_dac.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_dac_ex.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_iwdg.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_spi.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_spi_ex.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_tim.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_tim_ex.h;Middlewares\Third_Party\FreeRTOS\Source\include\croutine.h;Middlewares\Third_Party\FreeRTOS\Source\include\deprecated_definitions.h;Middlewares\Third_Party\FreeRTOS\Source\include\event_groups.h;Middlewares\Third_Party\FreeRTOS\Source\include\FreeRTOS.h;Middlewares\Third_Party\FreeRTOS\Source\include\list.h;Middlewares\Third_Party\FreeRTOS\Source\include\message_buffer.h;Middlewares\Third_Party\FreeRTOS\Source\include\mpu_prototypes.h;Middlewares\Third_Party\FreeRTOS\Source\include\mpu_wrappers.h;Middlewares\Third_Party\FreeRTOS\Source\include\portable.h;Middlewares\Third_Party\FreeRTOS\Source\include\projdefs.h;Middlewares\Third_Party\FreeRTOS\Source\include\queue.h;Middlewares\Third_Party\FreeRTOS\Source\include\semphr.h;Middlewares\Third_Party\FreeRTOS\Source\include\stack_macros.h;Middlewares\Third_Party\FreeRTOS\Source\include\StackMacros.h;Middlewares\Third_Party\FreeRTOS\Source\include\stream_buffer.h;Middlewares\Third_Party\FreeRTOS\Source\include\task.h;Middlewares\Third_Party\FreeRTOS\Source\include\timers.h;Middlewares\Third_Party\FreeRTOS\Source\include\atomic.h;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os2.h;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os.h;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\freertos_mpool.h;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\freertos_os2.h;Middlewares\Third_Party\FreeRTOS\Source\portable\GCC\ARM_CM4F\portmacro.h;Drivers\CMSIS\Device\ST\STM32L4xx\Include\stm32l432xx.h;Drivers\CMSIS\Device\ST\STM32L4xx\Include\stm32l4xx.h;Drivers\CMSIS\Device\ST\STM32L4xx\Include\system_stm32l4xx.h;Drivers\CMSIS\Device\ST\STM32L4xx\Source\Templates\system_stm32l4xx.c;Drivers\CMSIS\Include\cmsis_armcc.h;Drivers\CMSIS\Include\cmsis_armclang.h;Drivers\CMSIS\Include\cmsis_armclang_ltm.h;Drivers\CMSIS\Include\cmsis_compiler.h;Drivers\CMSIS\Include\cmsis_gcc.h;Drivers\CMSIS\Include\cmsis_iccarm.h;Drivers\CMSIS\Include\cmsis_version.h;Drivers\CMSIS\Include\core_armv81mml.h;Drivers\CMSIS\Include\core_armv8mbl.h;Drivers\CMSIS\Include\core_armv8mml.h;Drivers\CMSIS\Include\core_cm0.h;Drivers\CMSIS\Include\core_cm0plus.h;Drivers\CMSIS\Include\core_cm1.h;Drivers\CMSIS\Include\core_cm23.h;Drivers\CMSIS\Include\core_cm3.h;Drivers\CMSIS\Include\core_cm33.h;Drivers\CMSIS\Include\core_cm35p.h;Drivers\CMSIS\Include\core_cm4.h;Drivers\CMSIS\Include\core_cm7.h;Drivers\CMSIS\Include\core_sc000.h;Drivers\CMSIS\Include\core_sc300.h;Drivers\CMSIS\Include\mpu_armv7.h;Drivers\CMSIS\Include\mpu_armv8.h;Drivers\CMSIS\Include\tz_context.h; - -[PreviousUsedCubeIDEFiles] -SourceFiles=Core\Src\main.c;Core\Src\freertos.c;Core\Src\stm32l4xx_it.c;Core\Src\stm32l4xx_hal_msp.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc_ex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c_ex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc_ex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ramfunc.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_gpio.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma_ex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr_ex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_cortex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_exti.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_can.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dac.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dac_ex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_spi.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_spi_ex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim_ex.c;Middlewares/Third_Party/FreeRTOS/Source/croutine.c;Middlewares/Third_Party/FreeRTOS/Source/event_groups.c;Middlewares/Third_Party/FreeRTOS/Source/list.c;Middlewares/Third_Party/FreeRTOS/Source/queue.c;Middlewares/Third_Party/FreeRTOS/Source/stream_buffer.c;Middlewares/Third_Party/FreeRTOS/Source/tasks.c;Middlewares/Third_Party/FreeRTOS/Source/timers.c;Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c;Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.c;Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c;Drivers/CMSIS/Device/ST/STM32L4xx/Source/Templates/system_stm32l4xx.c;Core\Src/system_stm32l4xx.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc_ex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c_ex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc_ex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ramfunc.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_gpio.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma_ex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr_ex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_cortex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_exti.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_can.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dac.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dac_ex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_spi.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_spi_ex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim_ex.c;Middlewares/Third_Party/FreeRTOS/Source/croutine.c;Middlewares/Third_Party/FreeRTOS/Source/event_groups.c;Middlewares/Third_Party/FreeRTOS/Source/list.c;Middlewares/Third_Party/FreeRTOS/Source/queue.c;Middlewares/Third_Party/FreeRTOS/Source/stream_buffer.c;Middlewares/Third_Party/FreeRTOS/Source/tasks.c;Middlewares/Third_Party/FreeRTOS/Source/timers.c;Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c;Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.c;Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c;Drivers/CMSIS/Device/ST/STM32L4xx/Source/Templates/system_stm32l4xx.c;Core\Src/system_stm32l4xx.c;;;Middlewares/Third_Party/FreeRTOS/Source/croutine.c;Middlewares/Third_Party/FreeRTOS/Source/event_groups.c;Middlewares/Third_Party/FreeRTOS/Source/list.c;Middlewares/Third_Party/FreeRTOS/Source/queue.c;Middlewares/Third_Party/FreeRTOS/Source/stream_buffer.c;Middlewares/Third_Party/FreeRTOS/Source/tasks.c;Middlewares/Third_Party/FreeRTOS/Source/timers.c;Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c;Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.c;Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c; -HeaderPath=Drivers\STM32L4xx_HAL_Driver\Inc;Drivers\STM32L4xx_HAL_Driver\Inc\Legacy;Middlewares\Third_Party\FreeRTOS\Source\include;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2;Middlewares\Third_Party\FreeRTOS\Source\portable\GCC\ARM_CM4F;Drivers\CMSIS\Device\ST\STM32L4xx\Include;Drivers\CMSIS\Include;Core\Inc; -CDefines=USE_HAL_DRIVER;STM32L432xx;USE_HAL_DRIVER;USE_HAL_DRIVER; - -[PreviousUsedMakefileFiles] -SourceFiles=Core\Src\main.c;Core\Src\freertos.c;Core\Src\stm32l4xx_it.c;Core\Src\stm32l4xx_hal_msp.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_adc.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_adc_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_i2c.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_i2c_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_rcc.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_rcc_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_flash.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_flash_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_flash_ramfunc.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_gpio.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_dma.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_dma_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_pwr.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_pwr_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_cortex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_exti.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_can.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_dac.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_dac_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_iwdg.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_spi.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_spi_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_tim.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_tim_ex.c;Middlewares\Third_Party\FreeRTOS\Source\croutine.c;Middlewares\Third_Party\FreeRTOS\Source\event_groups.c;Middlewares\Third_Party\FreeRTOS\Source\list.c;Middlewares\Third_Party\FreeRTOS\Source\queue.c;Middlewares\Third_Party\FreeRTOS\Source\stream_buffer.c;Middlewares\Third_Party\FreeRTOS\Source\tasks.c;Middlewares\Third_Party\FreeRTOS\Source\timers.c;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os2.c;Middlewares\Third_Party\FreeRTOS\Source\portable\MemMang\heap_4.c;Middlewares\Third_Party\FreeRTOS\Source\portable\GCC\ARM_CM4F\port.c;Drivers\CMSIS\Device\ST\STM32L4xx\Source\Templates\system_stm32l4xx.c;Core\Src\system_stm32l4xx.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_adc.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_adc_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_i2c.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_i2c_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_rcc.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_rcc_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_flash.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_flash_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_flash_ramfunc.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_gpio.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_dma.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_dma_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_pwr.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_pwr_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_cortex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_exti.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_can.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_dac.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_dac_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_iwdg.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_spi.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_spi_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_tim.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_tim_ex.c;Middlewares\Third_Party\FreeRTOS\Source\croutine.c;Middlewares\Third_Party\FreeRTOS\Source\event_groups.c;Middlewares\Third_Party\FreeRTOS\Source\list.c;Middlewares\Third_Party\FreeRTOS\Source\queue.c;Middlewares\Third_Party\FreeRTOS\Source\stream_buffer.c;Middlewares\Third_Party\FreeRTOS\Source\tasks.c;Middlewares\Third_Party\FreeRTOS\Source\timers.c;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os2.c;Middlewares\Third_Party\FreeRTOS\Source\portable\MemMang\heap_4.c;Middlewares\Third_Party\FreeRTOS\Source\portable\GCC\ARM_CM4F\port.c;Drivers\CMSIS\Device\ST\STM32L4xx\Source\Templates\system_stm32l4xx.c;Core\Src\system_stm32l4xx.c;;;Middlewares\Third_Party\FreeRTOS\Source\croutine.c;Middlewares\Third_Party\FreeRTOS\Source\event_groups.c;Middlewares\Third_Party\FreeRTOS\Source\list.c;Middlewares\Third_Party\FreeRTOS\Source\queue.c;Middlewares\Third_Party\FreeRTOS\Source\stream_buffer.c;Middlewares\Third_Party\FreeRTOS\Source\tasks.c;Middlewares\Third_Party\FreeRTOS\Source\timers.c;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os2.c;Middlewares\Third_Party\FreeRTOS\Source\portable\MemMang\heap_4.c;Middlewares\Third_Party\FreeRTOS\Source\portable\GCC\ARM_CM4F\port.c; -HeaderPath=Drivers\STM32L4xx_HAL_Driver\Inc;Drivers\STM32L4xx_HAL_Driver\Inc\Legacy;Middlewares\Third_Party\FreeRTOS\Source\include;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2;Middlewares\Third_Party\FreeRTOS\Source\portable\GCC\ARM_CM4F;Drivers\CMSIS\Device\ST\STM32L4xx\Include;Drivers\CMSIS\Include;Core\Inc; -CDefines=USE_HAL_DRIVER;STM32L432xx;USE_HAL_DRIVER;USE_HAL_DRIVER; - -[PreviousGenFiles] -AdvancedFolderStructure=true -HeaderFileListSize=4 -HeaderFiles#0=C:/Users/pique_n/Documents/GitHub/tec/Core/Inc/FreeRTOSConfig.h -HeaderFiles#1=C:/Users/pique_n/Documents/GitHub/tec/Core/Inc/stm32l4xx_it.h -HeaderFiles#2=C:/Users/pique_n/Documents/GitHub/tec/Core/Inc/stm32l4xx_hal_conf.h -HeaderFiles#3=C:/Users/pique_n/Documents/GitHub/tec/Core/Inc/main.h -HeaderFolderListSize=1 -HeaderPath#0=C:/Users/pique_n/Documents/GitHub/tec/Core/Inc -HeaderFiles=; -SourceFileListSize=4 -SourceFiles#0=C:/Users/pique_n/Documents/GitHub/tec/Core/Src/freertos.c -SourceFiles#1=C:/Users/pique_n/Documents/GitHub/tec/Core/Src/stm32l4xx_it.c -SourceFiles#2=C:/Users/pique_n/Documents/GitHub/tec/Core/Src/stm32l4xx_hal_msp.c -SourceFiles#3=C:/Users/pique_n/Documents/GitHub/tec/Core/Src/main.c -SourceFolderListSize=1 -SourcePath#0=C:/Users/pique_n/Documents/GitHub/tec/Core/Src -SourceFiles=; - +[PreviousLibFiles] +LibFiles=Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_adc.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_ll_adc.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_adc_ex.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_def.h;Drivers\STM32L4xx_HAL_Driver\Inc\Legacy\stm32_hal_legacy.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_i2c.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_i2c_ex.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_rcc.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_rcc_ex.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_flash.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_flash_ex.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_flash_ramfunc.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_gpio.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_gpio_ex.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_dma.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_dma_ex.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_pwr.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_pwr_ex.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_cortex.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_exti.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_can.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_dac.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_dac_ex.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_iwdg.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_spi.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_spi_ex.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_tim.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_tim_ex.h;Middlewares\Third_Party\FreeRTOS\Source\include\croutine.h;Middlewares\Third_Party\FreeRTOS\Source\include\deprecated_definitions.h;Middlewares\Third_Party\FreeRTOS\Source\include\event_groups.h;Middlewares\Third_Party\FreeRTOS\Source\include\FreeRTOS.h;Middlewares\Third_Party\FreeRTOS\Source\include\list.h;Middlewares\Third_Party\FreeRTOS\Source\include\message_buffer.h;Middlewares\Third_Party\FreeRTOS\Source\include\mpu_prototypes.h;Middlewares\Third_Party\FreeRTOS\Source\include\mpu_wrappers.h;Middlewares\Third_Party\FreeRTOS\Source\include\portable.h;Middlewares\Third_Party\FreeRTOS\Source\include\projdefs.h;Middlewares\Third_Party\FreeRTOS\Source\include\queue.h;Middlewares\Third_Party\FreeRTOS\Source\include\semphr.h;Middlewares\Third_Party\FreeRTOS\Source\include\stack_macros.h;Middlewares\Third_Party\FreeRTOS\Source\include\StackMacros.h;Middlewares\Third_Party\FreeRTOS\Source\include\stream_buffer.h;Middlewares\Third_Party\FreeRTOS\Source\include\task.h;Middlewares\Third_Party\FreeRTOS\Source\include\timers.h;Middlewares\Third_Party\FreeRTOS\Source\include\atomic.h;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os2.h;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os.h;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\freertos_mpool.h;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\freertos_os2.h;Middlewares\Third_Party\FreeRTOS\Source\portable\GCC\ARM_CM4F\portmacro.h;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_adc.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_adc_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_i2c.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_i2c_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_rcc.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_rcc_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_flash.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_flash_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_flash_ramfunc.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_gpio.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_dma.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_dma_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_pwr.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_pwr_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_cortex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_exti.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_can.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_dac.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_dac_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_iwdg.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_spi.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_spi_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_tim.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_tim_ex.c;Middlewares\Third_Party\FreeRTOS\Source\croutine.c;Middlewares\Third_Party\FreeRTOS\Source\event_groups.c;Middlewares\Third_Party\FreeRTOS\Source\list.c;Middlewares\Third_Party\FreeRTOS\Source\queue.c;Middlewares\Third_Party\FreeRTOS\Source\stream_buffer.c;Middlewares\Third_Party\FreeRTOS\Source\tasks.c;Middlewares\Third_Party\FreeRTOS\Source\timers.c;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os2.c;Middlewares\Third_Party\FreeRTOS\Source\portable\MemMang\heap_4.c;Middlewares\Third_Party\FreeRTOS\Source\portable\GCC\ARM_CM4F\port.c;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_adc.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_ll_adc.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_adc_ex.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_def.h;Drivers\STM32L4xx_HAL_Driver\Inc\Legacy\stm32_hal_legacy.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_i2c.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_i2c_ex.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_rcc.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_rcc_ex.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_flash.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_flash_ex.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_flash_ramfunc.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_gpio.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_gpio_ex.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_dma.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_dma_ex.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_pwr.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_pwr_ex.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_cortex.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_exti.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_can.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_dac.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_dac_ex.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_iwdg.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_spi.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_spi_ex.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_tim.h;Drivers\STM32L4xx_HAL_Driver\Inc\stm32l4xx_hal_tim_ex.h;Middlewares\Third_Party\FreeRTOS\Source\include\croutine.h;Middlewares\Third_Party\FreeRTOS\Source\include\deprecated_definitions.h;Middlewares\Third_Party\FreeRTOS\Source\include\event_groups.h;Middlewares\Third_Party\FreeRTOS\Source\include\FreeRTOS.h;Middlewares\Third_Party\FreeRTOS\Source\include\list.h;Middlewares\Third_Party\FreeRTOS\Source\include\message_buffer.h;Middlewares\Third_Party\FreeRTOS\Source\include\mpu_prototypes.h;Middlewares\Third_Party\FreeRTOS\Source\include\mpu_wrappers.h;Middlewares\Third_Party\FreeRTOS\Source\include\portable.h;Middlewares\Third_Party\FreeRTOS\Source\include\projdefs.h;Middlewares\Third_Party\FreeRTOS\Source\include\queue.h;Middlewares\Third_Party\FreeRTOS\Source\include\semphr.h;Middlewares\Third_Party\FreeRTOS\Source\include\stack_macros.h;Middlewares\Third_Party\FreeRTOS\Source\include\StackMacros.h;Middlewares\Third_Party\FreeRTOS\Source\include\stream_buffer.h;Middlewares\Third_Party\FreeRTOS\Source\include\task.h;Middlewares\Third_Party\FreeRTOS\Source\include\timers.h;Middlewares\Third_Party\FreeRTOS\Source\include\atomic.h;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os2.h;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os.h;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\freertos_mpool.h;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\freertos_os2.h;Middlewares\Third_Party\FreeRTOS\Source\portable\GCC\ARM_CM4F\portmacro.h;Drivers\CMSIS\Device\ST\STM32L4xx\Include\stm32l432xx.h;Drivers\CMSIS\Device\ST\STM32L4xx\Include\stm32l4xx.h;Drivers\CMSIS\Device\ST\STM32L4xx\Include\system_stm32l4xx.h;Drivers\CMSIS\Device\ST\STM32L4xx\Source\Templates\system_stm32l4xx.c;Drivers\CMSIS\Include\cmsis_armcc.h;Drivers\CMSIS\Include\cmsis_armclang.h;Drivers\CMSIS\Include\cmsis_armclang_ltm.h;Drivers\CMSIS\Include\cmsis_compiler.h;Drivers\CMSIS\Include\cmsis_gcc.h;Drivers\CMSIS\Include\cmsis_iccarm.h;Drivers\CMSIS\Include\cmsis_version.h;Drivers\CMSIS\Include\core_armv81mml.h;Drivers\CMSIS\Include\core_armv8mbl.h;Drivers\CMSIS\Include\core_armv8mml.h;Drivers\CMSIS\Include\core_cm0.h;Drivers\CMSIS\Include\core_cm0plus.h;Drivers\CMSIS\Include\core_cm1.h;Drivers\CMSIS\Include\core_cm23.h;Drivers\CMSIS\Include\core_cm3.h;Drivers\CMSIS\Include\core_cm33.h;Drivers\CMSIS\Include\core_cm35p.h;Drivers\CMSIS\Include\core_cm4.h;Drivers\CMSIS\Include\core_cm7.h;Drivers\CMSIS\Include\core_sc000.h;Drivers\CMSIS\Include\core_sc300.h;Drivers\CMSIS\Include\mpu_armv7.h;Drivers\CMSIS\Include\mpu_armv8.h;Drivers\CMSIS\Include\tz_context.h; + +[PreviousUsedCubeIDEFiles] +SourceFiles=Core\Src\main.c;Core\Src\freertos.c;Core\Src\stm32l4xx_it.c;Core\Src\stm32l4xx_hal_msp.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc_ex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c_ex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc_ex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ramfunc.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_gpio.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma_ex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr_ex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_cortex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_exti.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_can.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dac.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dac_ex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_spi.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_spi_ex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim_ex.c;Middlewares/Third_Party/FreeRTOS/Source/croutine.c;Middlewares/Third_Party/FreeRTOS/Source/event_groups.c;Middlewares/Third_Party/FreeRTOS/Source/list.c;Middlewares/Third_Party/FreeRTOS/Source/queue.c;Middlewares/Third_Party/FreeRTOS/Source/stream_buffer.c;Middlewares/Third_Party/FreeRTOS/Source/tasks.c;Middlewares/Third_Party/FreeRTOS/Source/timers.c;Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c;Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.c;Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c;Drivers/CMSIS/Device/ST/STM32L4xx/Source/Templates/system_stm32l4xx.c;Core\Src/system_stm32l4xx.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc_ex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c_ex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc_ex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ramfunc.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_gpio.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma_ex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr_ex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_cortex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_exti.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_can.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dac.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dac_ex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_spi.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_spi_ex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim_ex.c;Middlewares/Third_Party/FreeRTOS/Source/croutine.c;Middlewares/Third_Party/FreeRTOS/Source/event_groups.c;Middlewares/Third_Party/FreeRTOS/Source/list.c;Middlewares/Third_Party/FreeRTOS/Source/queue.c;Middlewares/Third_Party/FreeRTOS/Source/stream_buffer.c;Middlewares/Third_Party/FreeRTOS/Source/tasks.c;Middlewares/Third_Party/FreeRTOS/Source/timers.c;Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c;Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.c;Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c;Drivers/CMSIS/Device/ST/STM32L4xx/Source/Templates/system_stm32l4xx.c;Core\Src/system_stm32l4xx.c;;;Middlewares/Third_Party/FreeRTOS/Source/croutine.c;Middlewares/Third_Party/FreeRTOS/Source/event_groups.c;Middlewares/Third_Party/FreeRTOS/Source/list.c;Middlewares/Third_Party/FreeRTOS/Source/queue.c;Middlewares/Third_Party/FreeRTOS/Source/stream_buffer.c;Middlewares/Third_Party/FreeRTOS/Source/tasks.c;Middlewares/Third_Party/FreeRTOS/Source/timers.c;Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c;Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.c;Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c; +HeaderPath=Drivers\STM32L4xx_HAL_Driver\Inc;Drivers\STM32L4xx_HAL_Driver\Inc\Legacy;Middlewares\Third_Party\FreeRTOS\Source\include;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2;Middlewares\Third_Party\FreeRTOS\Source\portable\GCC\ARM_CM4F;Drivers\CMSIS\Device\ST\STM32L4xx\Include;Drivers\CMSIS\Include;Core\Inc; +CDefines=USE_HAL_DRIVER;STM32L432xx;USE_HAL_DRIVER;USE_HAL_DRIVER; + +[PreviousUsedMakefileFiles] +SourceFiles=Core\Src\main.c;Core\Src\freertos.c;Core\Src\stm32l4xx_it.c;Core\Src\stm32l4xx_hal_msp.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_adc.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_adc_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_i2c.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_i2c_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_rcc.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_rcc_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_flash.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_flash_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_flash_ramfunc.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_gpio.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_dma.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_dma_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_pwr.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_pwr_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_cortex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_exti.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_can.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_dac.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_dac_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_iwdg.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_spi.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_spi_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_tim.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_tim_ex.c;Middlewares\Third_Party\FreeRTOS\Source\croutine.c;Middlewares\Third_Party\FreeRTOS\Source\event_groups.c;Middlewares\Third_Party\FreeRTOS\Source\list.c;Middlewares\Third_Party\FreeRTOS\Source\queue.c;Middlewares\Third_Party\FreeRTOS\Source\stream_buffer.c;Middlewares\Third_Party\FreeRTOS\Source\tasks.c;Middlewares\Third_Party\FreeRTOS\Source\timers.c;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os2.c;Middlewares\Third_Party\FreeRTOS\Source\portable\MemMang\heap_4.c;Middlewares\Third_Party\FreeRTOS\Source\portable\GCC\ARM_CM4F\port.c;Drivers\CMSIS\Device\ST\STM32L4xx\Source\Templates\system_stm32l4xx.c;Core\Src\system_stm32l4xx.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_adc.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_adc_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_i2c.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_i2c_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_rcc.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_rcc_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_flash.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_flash_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_flash_ramfunc.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_gpio.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_dma.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_dma_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_pwr.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_pwr_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_cortex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_exti.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_can.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_dac.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_dac_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_iwdg.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_spi.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_spi_ex.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_tim.c;Drivers\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_tim_ex.c;Middlewares\Third_Party\FreeRTOS\Source\croutine.c;Middlewares\Third_Party\FreeRTOS\Source\event_groups.c;Middlewares\Third_Party\FreeRTOS\Source\list.c;Middlewares\Third_Party\FreeRTOS\Source\queue.c;Middlewares\Third_Party\FreeRTOS\Source\stream_buffer.c;Middlewares\Third_Party\FreeRTOS\Source\tasks.c;Middlewares\Third_Party\FreeRTOS\Source\timers.c;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os2.c;Middlewares\Third_Party\FreeRTOS\Source\portable\MemMang\heap_4.c;Middlewares\Third_Party\FreeRTOS\Source\portable\GCC\ARM_CM4F\port.c;Drivers\CMSIS\Device\ST\STM32L4xx\Source\Templates\system_stm32l4xx.c;Core\Src\system_stm32l4xx.c;;;Middlewares\Third_Party\FreeRTOS\Source\croutine.c;Middlewares\Third_Party\FreeRTOS\Source\event_groups.c;Middlewares\Third_Party\FreeRTOS\Source\list.c;Middlewares\Third_Party\FreeRTOS\Source\queue.c;Middlewares\Third_Party\FreeRTOS\Source\stream_buffer.c;Middlewares\Third_Party\FreeRTOS\Source\tasks.c;Middlewares\Third_Party\FreeRTOS\Source\timers.c;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2\cmsis_os2.c;Middlewares\Third_Party\FreeRTOS\Source\portable\MemMang\heap_4.c;Middlewares\Third_Party\FreeRTOS\Source\portable\GCC\ARM_CM4F\port.c; +HeaderPath=Drivers\STM32L4xx_HAL_Driver\Inc;Drivers\STM32L4xx_HAL_Driver\Inc\Legacy;Middlewares\Third_Party\FreeRTOS\Source\include;Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS_V2;Middlewares\Third_Party\FreeRTOS\Source\portable\GCC\ARM_CM4F;Drivers\CMSIS\Device\ST\STM32L4xx\Include;Drivers\CMSIS\Include;Core\Inc; +CDefines=USE_HAL_DRIVER;STM32L432xx;USE_HAL_DRIVER;USE_HAL_DRIVER; + +[PreviousGenFiles] +AdvancedFolderStructure=true +HeaderFileListSize=4 +HeaderFiles#0=..\Core\Inc\FreeRTOSConfig.h +HeaderFiles#1=..\Core\Inc\stm32l4xx_it.h +HeaderFiles#2=..\Core\Inc\stm32l4xx_hal_conf.h +HeaderFiles#3=..\Core\Inc\main.h +HeaderFolderListSize=1 +HeaderPath#0=..\Core\Inc +HeaderFiles=; +SourceFileListSize=4 +SourceFiles#0=..\Core\Src\freertos.c +SourceFiles#1=..\Core\Src\stm32l4xx_it.c +SourceFiles#2=..\Core\Src\stm32l4xx_hal_msp.c +SourceFiles#3=..\Core\Src\main.c +SourceFolderListSize=1 +SourcePath#0=..\Core\Src +SourceFiles=; + diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 76c9076..64c89c0 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -20,7 +20,7 @@ "STM32L432xx", "USE_HAL_DRIVER" ], - "compilerPath": "C:\\USERS\\PIQUE_N\\APPDATA\\ROAMING\\CODE\\USER\\GLOBALSTORAGE\\BMD.STM32-FOR-VSCODE\\@XPACK-DEV-TOOLS\\ARM-NONE-EABI-GCC\\10.3.1-2.3.1\\.CONTENT\\BIN\\ARM-NONE-EABI-GCC.EXE" + "compilerPath": "C:\\USERS\\PIQUE_N\\APPDATA\\ROAMING\\CODE\\USER\\GLOBALSTORAGE\\BMD.STM32-FOR-VSCODE\\@XPACK-DEV-TOOLS\\ARM-NONE-EABI-GCC\\11.3.1-1.1.2\\.CONTENT\\BIN\\ARM-NONE-EABI-GCC.EXE" } ], "version": 4 diff --git a/.vscode/settings.json b/.vscode/settings.json index 6228ea8..20165a9 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -5,8 +5,11 @@ "cmsis_os2.h": "c", "varh_variablehandler.h": "c" }, - "cortex-debug.armToolchainPath": "c:\\Users\\pique_n\\AppData\\Roaming\\Code\\User\\globalStorage\\bmd.stm32-for-vscode\\@xpack-dev-tools\\arm-none-eabi-gcc\\10.3.1-2.3.1\\.content\\bin", - "cortex-debug.openocdPath": "C:\\USERS\\PIQUE_N\\APPDATA\\ROAMING\\CODE\\USER\\GLOBALSTORAGE\\BMD.STM32-FOR-VSCODE\\@XPACK-DEV-TOOLS\\OPENOCD\\0.11.0-2.1\\.CONTENT\\BIN\\OPENOCD.EXE", - "cortex-debug.variableUseNaturalFormat": true + "cortex-debug.armToolchainPath": "c:\\Users\\pique_n\\AppData\\Roaming\\Code\\User\\globalStorage\\bmd.stm32-for-vscode\\@xpack-dev-tools\\arm-none-eabi-gcc\\11.3.1-1.1.2\\.content\\bin", + "cortex-debug.openocdPath": "C:\\USERS\\PIQUE_N\\APPDATA\\ROAMING\\CODE\\USER\\GLOBALSTORAGE\\BMD.STM32-FOR-VSCODE\\@XPACK-DEV-TOOLS\\OPENOCD\\0.11.0-5.1\\.CONTENT\\BIN\\OPENOCD.EXE", + "cortex-debug.variableUseNaturalFormat": true, + "stm32-for-vscode.openOCDPath": "C:\\USERS\\PIQUE_N\\APPDATA\\ROAMING\\CODE\\USER\\GLOBALSTORAGE\\BMD.STM32-FOR-VSCODE\\@XPACK-DEV-TOOLS\\OPENOCD\\0.11.0-5.1\\.CONTENT\\BIN\\OPENOCD.EXE", + "stm32-for-vscode.makePath": "C:\\USERS\\PIQUE_N\\APPDATA\\ROAMING\\CODE\\USER\\GLOBALSTORAGE\\BMD.STM32-FOR-VSCODE\\@XPACK-DEV-TOOLS\\WINDOWS-BUILD-TOOLS\\4.3.0-1.1\\.CONTENT\\BIN\\MAKE.EXE", + "stm32-for-vscode.armToolchainPath": "c:\\Users\\pique_n\\AppData\\Roaming\\Code\\User\\globalStorage\\bmd.stm32-for-vscode\\@xpack-dev-tools\\arm-none-eabi-gcc\\11.3.1-1.1.2\\.content\\bin" } \ No newline at end of file diff --git a/Core/Application/INIT_Initialization.c b/Core/Application/INIT_Initialization.c index bda9096..3446ae9 100644 --- a/Core/Application/INIT_Initialization.c +++ b/Core/Application/INIT_Initialization.c @@ -1,190 +1,190 @@ -//================================================================================================= -// -// Company: Paul Scherrer Institut -// 5232 Villigen PSI -// Switzerland -// -//------------------------------------------------------------------------------------------------- -// -// Project: Peltier Controller V2 -// Author: Noah Piqué (noah.pique@psi.ch) -// -//------------------------------------------------------------------------------------------------- -// -// Module: INIT_Initialization -// Filename: INIT_Initialization.c -// Date: Handled by Subversion (version control system) -// Revision: Handled by Subversion (version control system) -// History: Handled by Subversion (version control system) -// -//------------------------------------------------------------------------------------------------- -// -// Description: Initialization module -// -//================================================================================================= - - - -//================================================================================================= -// Section: INCLUDES -// Description: List of required include files. -//================================================================================================= - -#include "../SDEF_StandardDefinitions.h" -#include "INIT_Initialization.h" - -// Application -#include "VARH_VariableHandler.h" -#include "PECO_PeltierController.h" -#include "MAIN_MainApplication.h" - -// Drivers -#include "../Drivers/USFL_UserFlash.h" -#include "../Drivers/ANPI_AnalogPortsIn.h" -#include "../Drivers/ANPO_AnalogPortsOut.h" -#include "../Drivers/SPID_SpiDriver.h" -#include "../Drivers/DIPO_DigitalPorts.h" -#include "../Drivers/ADCD_AdcDriver.h" -#include "../Drivers/TEMP_Temperature.h" -#include "../Drivers/CAND_CanDriver.h" -#include "../Drivers/ERRH_ErrorHandler.h" - -// Toolbox -#include "../Toolbox/UTIL_Utility.h" - -#include "cmsis_os2.h" - -//================================================================================================= -// Section: DEFINITIONS -// Description: Definition of local constants (visible by this module only). -//================================================================================================= - - -//================================================================================================= -// Section: MACROS -// Description: Definition of local macros (visible by this module only). -//================================================================================================= - - -//================================================================================================= -// Section: ENUMERATIONS -// Description: Definition of local enumerations (visible by this module only). -//================================================================================================= - - -//================================================================================================= -// Section: STRUCTURES -// Description: Definition of local Structures (visible by this module only). -//================================================================================================= - - -//================================================================================================= -// Section: LOCAL VARIABLES -// Description: Definition of local variables (visible by this module only). -//================================================================================================= - -LOCAL osThreadId_t m_pstThreadID = NULL; - -//================================================================================================= -// Section: LOCAL CONSTANTS -// Description: Definition of local constants (visible by this module only). -//================================================================================================= - - -LOCAL CONST osThreadAttr_t stTaskAttribute = -{ - "INIT_Thread", // name of the thread - osThreadDetached, // attribute bits - NULL, // memory for control block - 0, // size of provided memory for control block - NULL, // memory for stack - 1024, // size of stack - osPriorityHigh7, // initial thread priority (default: osPriorityNormal) - 0, // TrustZone module identifier - 0, // reserved (must be 0) -}; - -//================================================================================================= -// Section: LOCAL FUNCTIONS (PROTOTYPES) -// Description: Definition of local functions (visible by this module only). -//================================================================================================= - -PRIVATE VOID vTask ( PVOID arg )__NORETURN; - -//================================================================================================= -// Section: EXTERNAL FUNCTIONS -// Description: Definition of external (global) functions. -//================================================================================================= - - - -//================================================================================================= -// Section: EXTERNAL VARIABLES -// Description: Definition of external (global) variables. -//================================================================================================= - - -//================================================================================================= -// Section: GLOBAL FUNCTIONS -// Description: Definition (implementation) of global functions. -//================================================================================================= - -//------------------------------------------------------------------------------------------------- -// Function: INIT_boCreateTask -// Description: Create the init Task -// Parameters: None -// Returns: Boolean TRUE if successful -//------------------------------------------------------------------------------------------------- -BOOL INIT_boCreateTask( VOID ) -{ - BOOL boOK = TRUE; - - boOK &= ((m_pstThreadID = osThreadNew( vTask, NULL, &stTaskAttribute )) != NULL); // create init Task - - return( boOK ); -} - - -//------------------------------------------------------------------------------------------------- -// Function: vInitTask -// Description: Initialization Task, priority must be high! -// Parameters: None -// Returns: None -//------------------------------------------------------------------------------------------------- -PRIVATE VOID vTask( PVOID arg ) -{ - UNUSED( arg ); - - BOOL boOK = TRUE; - - //boOK &= USFL_boInitializeModule(); - boOK &= VARH_boInitializeModule(); - - boOK &= DIPO_boInitializeModule(); - boOK &= ANPI_boInitializeModule(); - boOK &= ANPO_boInitializeModule(); - boOK &= SPID_boInitializeModule(); - boOK &= ADCD_boInitializeModule(); - boOK &= TEMP_boInitializeModule(); - boOK &= CAND_boInitializeModule(); - - boOK &= PECO_boInitializeModule(); - boOK &= MAIN_boInitializeModule(); - - if( !boOK ){ - osKernelLock(); // lock kernel to prevent task switch - while( 1 ){ // Toggle Error LED fast - DIPO_vToggleOutput( DIPO_eLED ); - DELAY_MS( 100 ); - } - } - - osThreadSuspend( m_pstThreadID ); - while( 1 ); -} - -//================================================================================================= -// Section: LOCAL FUNCTIONS -// Descriptionn: Definition (implementation) of local functions. -//================================================================================================= - +//================================================================================================= +// +// Company: Paul Scherrer Institut +// 5232 Villigen PSI +// Switzerland +// +//------------------------------------------------------------------------------------------------- +// +// Project: Peltier Controller V2 +// Author: Noah Piqué (noah.pique@psi.ch) +// +//------------------------------------------------------------------------------------------------- +// +// Module: INIT_Initialization +// Filename: INIT_Initialization.c +// Date: Handled by Subversion (version control system) +// Revision: Handled by Subversion (version control system) +// History: Handled by Subversion (version control system) +// +//------------------------------------------------------------------------------------------------- +// +// Description: Initialization module +// +//================================================================================================= + + + +//================================================================================================= +// Section: INCLUDES +// Description: List of required include files. +//================================================================================================= + +#include "../SDEF_StandardDefinitions.h" +#include "INIT_Initialization.h" + +// Application +#include "VARH_VariableHandler.h" +#include "PECO_PeltierController.h" +#include "MAIN_MainApplication.h" + +// Drivers +#include "../Drivers/USFL_UserFlash.h" +#include "../Drivers/ANPI_AnalogPortsIn.h" +#include "../Drivers/ANPO_AnalogPortsOut.h" +#include "../Drivers/SPID_SpiDriver.h" +#include "../Drivers/DIPO_DigitalPorts.h" +#include "../Drivers/ADCD_AdcDriver.h" +#include "../Drivers/TEMP_Temperature.h" +#include "../Drivers/CAND_CanDriver.h" +#include "../Drivers/ERRH_ErrorHandler.h" + +// Toolbox +#include "../Toolbox/UTIL_Utility.h" + +#include "cmsis_os2.h" + +//================================================================================================= +// Section: DEFINITIONS +// Description: Definition of local constants (visible by this module only). +//================================================================================================= + + +//================================================================================================= +// Section: MACROS +// Description: Definition of local macros (visible by this module only). +//================================================================================================= + + +//================================================================================================= +// Section: ENUMERATIONS +// Description: Definition of local enumerations (visible by this module only). +//================================================================================================= + + +//================================================================================================= +// Section: STRUCTURES +// Description: Definition of local Structures (visible by this module only). +//================================================================================================= + + +//================================================================================================= +// Section: LOCAL VARIABLES +// Description: Definition of local variables (visible by this module only). +//================================================================================================= + +LOCAL osThreadId_t m_pstThreadID = NULL; + +//================================================================================================= +// Section: LOCAL CONSTANTS +// Description: Definition of local constants (visible by this module only). +//================================================================================================= + + +LOCAL CONST osThreadAttr_t stTaskAttribute = +{ + "INIT_Thread", // name of the thread + osThreadDetached, // attribute bits + NULL, // memory for control block + 0, // size of provided memory for control block + NULL, // memory for stack + 1024, // size of stack + osPriorityHigh7, // initial thread priority (default: osPriorityNormal) + 0, // TrustZone module identifier + 0, // reserved (must be 0) +}; + +//================================================================================================= +// Section: LOCAL FUNCTIONS (PROTOTYPES) +// Description: Definition of local functions (visible by this module only). +//================================================================================================= + +PRIVATE VOID vTask ( PVOID arg )__NORETURN; + +//================================================================================================= +// Section: EXTERNAL FUNCTIONS +// Description: Definition of external (global) functions. +//================================================================================================= + + + +//================================================================================================= +// Section: EXTERNAL VARIABLES +// Description: Definition of external (global) variables. +//================================================================================================= + + +//================================================================================================= +// Section: GLOBAL FUNCTIONS +// Description: Definition (implementation) of global functions. +//================================================================================================= + +//------------------------------------------------------------------------------------------------- +// Function: INIT_boCreateTask +// Description: Create the init Task +// Parameters: None +// Returns: Boolean TRUE if successful +//------------------------------------------------------------------------------------------------- +BOOL INIT_boCreateTask( VOID ) +{ + BOOL boOK = TRUE; + + boOK &= ((m_pstThreadID = osThreadNew( vTask, NULL, &stTaskAttribute )) != NULL); // create init Task + + return( boOK ); +} + + +//------------------------------------------------------------------------------------------------- +// Function: vInitTask +// Description: Initialization Task, priority must be high! +// Parameters: None +// Returns: None +//------------------------------------------------------------------------------------------------- +PRIVATE VOID vTask( PVOID arg ) +{ + UNUSED( arg ); + + BOOL boOK = TRUE; + + //boOK &= USFL_boInitializeModule(); + boOK &= VARH_boInitializeModule(); + + boOK &= DIPO_boInitializeModule(); + boOK &= ANPI_boInitializeModule(); + boOK &= ANPO_boInitializeModule(); + boOK &= SPID_boInitializeModule(); + boOK &= ADCD_boInitializeModule(); + boOK &= TEMP_boInitializeModule(); + boOK &= CAND_boInitializeModule(); + + boOK &= PECO_boInitializeModule(); + boOK &= MAIN_boInitializeModule(); + + if( !boOK ){ + osKernelLock(); // lock kernel to prevent task switch + while( 1 ){ // Toggle Error LED fast + DIPO_vToggleOutput( DIPO_eLED ); + DELAY_MS( 100 ); + } + } + + osThreadSuspend( m_pstThreadID ); + while( 1 ); +} + +//================================================================================================= +// Section: LOCAL FUNCTIONS +// Descriptionn: Definition (implementation) of local functions. +//================================================================================================= + diff --git a/Core/Application/MAIN_MainApplication.c b/Core/Application/MAIN_MainApplication.c index 518711e..35fdb38 100644 --- a/Core/Application/MAIN_MainApplication.c +++ b/Core/Application/MAIN_MainApplication.c @@ -1,316 +1,319 @@ -//================================================================================================= -// -// Company: Paul Scherrer Institut -// 5232 Villigen PSI -// Switzerland -// -//------------------------------------------------------------------------------------------------- -// -// Project: Peltier Controller V2 -// Author: Noah Piqué (noah.pique@psi.ch) -// -//------------------------------------------------------------------------------------------------- -// -// Module: Main Application -// Filename: MAIN_MainApplication.c -// Date: Handled by Subversion (version control system) -// Revision: Handled by Subversion (version control system) -// History: Handled by Subversion (version control system) -// -//------------------------------------------------------------------------------------------------- -// -// Description: TEC - Peltier Controller Communication handler -// -//================================================================================================= - - - -//================================================================================================= -// Section: INCLUDES -// Description: List of required include files. -//================================================================================================= - -#include "MAIN_MainApplication.h" - -// Application -#include "VARH_VariableHandler.h" -#include "PECO_PeltierController.h" - -// Drivers -#include "../Drivers/TEMP_Temperature.h" -#include "../Drivers/DIPO_DigitalPorts.h" -#include "../Drivers/CAND_CanDriver.h" -#include "../Drivers/ANPI_AnalogPortsIn.h" - -// Toolbox -#include "../Toolbox/UTIL_Utility.h" - -// include STM32 drivers -#include "stm32l4xx_hal.h" - -#include "cmsis_os2.h" - -//================================================================================================= -// Section: DEFINITIONS -// Description: Definition of local constants (visible by this module only). -//================================================================================================= - -#define MSG_QUEUE_SIZE 8 - -#define EVENT_NEW_MESSAGE ((U32)(1<<0)) -#define EVENT_TIMER_UPDATE ((U32)(1<<1)) -#define EVENT_WATCHDOG ((U32)(1<<2)) - -#define EVENT_FLAGS_ALL ( EVENT_NEW_MESSAGE | EVENT_TIMER_UPDATE | EVENT_WATCHDOG ) - -#define COMMAND_NONE 0 -#define COMMAND_ON 1 -#define COMMAND_OFF 2 -#define COMMAND_WATCHDOG 3 - -#define WATCHDOG 33000 - -//================================================================================================= -// Section: MACROS -// Description: Definition of local macros (visible by this module only). -//================================================================================================= - - - -//================================================================================================= -// Section: ENUMERATIONS -// Description: Definition of local enumerations (visible by this module only). -//================================================================================================= - - - -//================================================================================================= -// Section: STRUCTURES -// Description: Definition of local Structures (visible by this module only). -//================================================================================================= - - - -//================================================================================================= -// Section: LOCAL FUNCTIONS (PROTOTYPES) -// Description: Definition of local functions (visible by this module only). -//================================================================================================= - -PRIVATE VOID vTask( PVOID arg ); -PRIVATE VOID vEventCallback( PVOID pvData ); -PRIVATE VOID vMsgRxCallback( CAND_Message stMessage ); - -//================================================================================================= -// Section: LOCAL VARIABLES -// Description: Definition of local variables (visible by this module only). -//================================================================================================= - -LOCAL osThreadId_t m_pstThreadID = NULL; -LOCAL osMessageQueueId_t m_pstCANRxMsgQueueID = NULL; -LOCAL osEventFlagsId_t m_pstEventID = NULL; - -LOCAL osTimerId_t m_pstUpdateTimer = NULL; -LOCAL osTimerId_t m_pstWatchdogTimer = NULL; - -//================================================================================================= -// Section: LOCAL CONSTANTS -// Description: Definition of local constants (visible by this module only). -//================================================================================================= - -LOCAL CONST osThreadAttr_t stTaskAttribute = -{ - "MAIN_Thread", // name of the thread - osThreadDetached, // attribute bits - NULL, // memory for control block - 0, // size of provided memory for control block - NULL, // memory for stack - 1024, // size of stack - osPriorityAboveNormal1, // initial thread priority (default: osPriorityNormal) - 0, // TrustZone module identifier - 0, // reserved (must be 0) -}; - -LOCAL CONST osMessageQueueAttr_t stCANRxMsgQueueAttribute = -{ - "MAIN_CAN_Rx_Queue", // name of the message queue - 0, // attribute bits - NULL, // memory for control block - 0, // size of provided memory for control block - NULL, // memory for data storage - 0, // size of provided memory for data storage -}; - -LOCAL CONST osEventFlagsAttr_t stEventAttribute = -{ - "MAIN_Event_Flags", // name of the event flags - 0, // attribute bits - NULL, // memory for control block - 0, // size of provided memory for control block -}; - -LOCAL CONST osTimerAttr_t stTimerAttribute = -{ - "MAIN_UpdateTimer", // name of the timer - 0, // attribute bits - NULL, // memory for control block - 0, // size of provided memory for control block -}; - -LOCAL CONST osTimerAttr_t stWatchdogTimerAttribute = -{ - "MAIN_Watchdog", // name of the timer - 0, // attribute bits - NULL, // memory for control block - 0, // size of provided memory for control block -}; - -//================================================================================================= -// Section: EXTERNAL FUNCTIONS -// Description: Definition of external (global) functions. -//================================================================================================= - - - -//================================================================================================= -// Section: EXTERNAL VARIABLES -// Description: Definition of external (global) variables. -//================================================================================================= - -//================================================================================================= -// Section: GLOBAL FUNCTIONS -// Description: Definition (implementation) of global functions. -//================================================================================================= - - -//------------------------------------------------------------------------------------------------- -// Function: MAIN_boInitializeModule -// Description: Initializes the module. Function must be called once immediately after power-up. -// Parameters: None -// Returns: Boolean TRUE if successful -//------------------------------------------------------------------------------------------------- - -BOOL MAIN_boInitializeModule( VOID ) -{ - BOOL boOK = TRUE; - - boOK &= ( ( m_pstEventID = osEventFlagsNew( &stEventAttribute ) ) == NULL ) ? FALSE : TRUE; - boOK &= ( ( m_pstThreadID = osThreadNew( vTask, NULL, &stTaskAttribute ) ) == NULL ) ? FALSE : TRUE; - boOK &= ( ( m_pstCANRxMsgQueueID = osMessageQueueNew( MSG_QUEUE_SIZE, sizeof( CAND_Message ), &stCANRxMsgQueueAttribute ) ) == NULL ) ? FALSE : TRUE; - boOK &= ( m_pstUpdateTimer = osTimerNew( vEventCallback, osTimerPeriodic, (PVOID)EVENT_TIMER_UPDATE, &stTimerAttribute ) ) == NULL ? FALSE : TRUE; - boOK &= ( m_pstWatchdogTimer = osTimerNew( vEventCallback, osTimerPeriodic, (PVOID)EVENT_TIMER_UPDATE, &stWatchdogTimerAttribute ) ) == NULL ? FALSE : TRUE; - - boOK &= (osTimerStart( m_pstUpdateTimer, 1000 ) == osOK ) ? TRUE : FALSE; - //boOK &= (osTimerStart( m_pstWatchdogTimer, WATCHDOG ) == osOK ) ? TRUE : FALSE; - - CAND_vSetRxCallback( vMsgRxCallback ); - - return( boOK ); -} - -//================================================================================================= -// Section: LOCAL FUNCTIONS -// Descriptionn: Definition (implementation) of local functions. -//================================================================================================= - -//------------------------------------------------------------------------------------------------- -// Function: vMainTask -// Description: Main Application Task -// Parameters: None -// Returns: None -//------------------------------------------------------------------------------------------------- -PRIVATE VOID vTask( PVOID arg ) -{ - UNUSED( arg ); - U32 u32Flags; - - U8 au8Buffer[8]; - - while( TRUE ) - { - - u32Flags = osEventFlagsWait( m_pstEventID, EVENT_FLAGS_ALL, osFlagsWaitAny, osWaitForever ); // wait until flags getting triggered - - if( u32Flags & EVENT_NEW_MESSAGE ) { // New message from CAN - - CAND_Message stMessage; - osMessageQueueGet( m_pstCANRxMsgQueueID, &stMessage, NULL, 0 ); // get message from queue - - U8 u8Register = stMessage.au8Data[0]; - U8 u8Type = stMessage.u8Type; - - if( u8Type == MESSAGE_TYPE_READ ){ // Message type read - if( u8Register >= VARH_eNumberOfVariables ){ // check register - // send register not found - au8Buffer[0] = 0xFF; - CAND_boSendMessage( au8Buffer, 1 ); - } else { - VARH_UVariable uVariable = VARH_uGetVariableData(u8Register); // get data - au8Buffer[0] = u8Register; - UTIL_vMemCopy(&uVariable, &au8Buffer[1], 4); // copy data in buffer - - CAND_boSendMessage( au8Buffer, 5 ); - } - - } else if( u8Type == MESSAGE_TYPE_WRITE ){ // Message type write - VARH_UVariable uData; - UTIL_vMemCopy(&stMessage.au8Data[1], &uData, 4); - - VARH_vSetVariableData(u8Register, uData); - } else if( u8Type == MESSAGE_TYPE_COMMAND ){ // Message type command - - switch (u8Register) - { - case COMMAND_ON: - PECO_Enable( TRUE ); - break; - - case COMMAND_OFF: - PECO_Enable( FALSE ); - break; - case COMMAND_WATCHDOG: - osTimerStart( m_pstWatchdogTimer, WATCHDOG ); - break; - default: - break; - } - } - } - - if( u32Flags & EVENT_TIMER_UPDATE ) - { - DIPO_vToggleOutput( DIPO_eLED ); - } - - if( u32Flags & EVENT_WATCHDOG ) - { - PECO_Enable( FALSE ); - // TODO: WATCHDOG: what else? - } - - } -} - -//------------------------------------------------------------------------------------------------- -// Function: vEventCallback -// Description: Callback for events -// Parameters: None -// Returns: None -//------------------------------------------------------------------------------------------------- -PRIVATE VOID vEventCallback( PVOID pvData ) -{ - osEventFlagsSet( m_pstEventID, (U32)pvData ); -} - -//------------------------------------------------------------------------------------------------- -// Function: vEventCallback -// Description: Callback for events -// Parameters: None -// Returns: None -//------------------------------------------------------------------------------------------------- -PRIVATE VOID vMsgRxCallback( CAND_Message stMessage ) -{ - osMessageQueuePut( m_pstCANRxMsgQueueID, &stMessage, 0, 0 ); - osEventFlagsSet( m_pstEventID, EVENT_NEW_MESSAGE ); -} - - +//================================================================================================= +// +// Company: Paul Scherrer Institut +// 5232 Villigen PSI +// Switzerland +// +//------------------------------------------------------------------------------------------------- +// +// Project: Peltier Controller V2 +// Author: Noah Piqué (noah.pique@psi.ch) +// +//------------------------------------------------------------------------------------------------- +// +// Module: Main Application +// Filename: MAIN_MainApplication.c +// Date: Handled by Subversion (version control system) +// Revision: Handled by Subversion (version control system) +// History: Handled by Subversion (version control system) +// +//------------------------------------------------------------------------------------------------- +// +// Description: TEC - Peltier Controller Communication handler +// +//================================================================================================= + + + +//================================================================================================= +// Section: INCLUDES +// Description: List of required include files. +//================================================================================================= + +#include "MAIN_MainApplication.h" + +// Application +#include "VARH_VariableHandler.h" +#include "PECO_PeltierController.h" + +// Drivers +#include "../Drivers/TEMP_Temperature.h" +#include "../Drivers/DIPO_DigitalPorts.h" +#include "../Drivers/CAND_CanDriver.h" +#include "../Drivers/ANPI_AnalogPortsIn.h" + +// Toolbox +#include "../Toolbox/UTIL_Utility.h" + +// include STM32 drivers +#include "stm32l4xx_hal.h" + +#include "cmsis_os2.h" + +//================================================================================================= +// Section: DEFINITIONS +// Description: Definition of local constants (visible by this module only). +//================================================================================================= + +#define MSG_QUEUE_SIZE 8 + +#define EVENT_NEW_MESSAGE ((U32)(1<<0)) +#define EVENT_TIMER_UPDATE ((U32)(1<<1)) +#define EVENT_WATCHDOG ((U32)(1<<2)) + +#define EVENT_FLAGS_ALL ( EVENT_NEW_MESSAGE | EVENT_TIMER_UPDATE | EVENT_WATCHDOG ) + +#define COMMAND_NONE 0 +#define COMMAND_ON 1 +#define COMMAND_OFF 2 +#define COMMAND_WATCHDOG 3 + +#define WATCHDOG 33000 + +//================================================================================================= +// Section: MACROS +// Description: Definition of local macros (visible by this module only). +//================================================================================================= + + + +//================================================================================================= +// Section: ENUMERATIONS +// Description: Definition of local enumerations (visible by this module only). +//================================================================================================= + + + +//================================================================================================= +// Section: STRUCTURES +// Description: Definition of local Structures (visible by this module only). +//================================================================================================= + + + +//================================================================================================= +// Section: LOCAL FUNCTIONS (PROTOTYPES) +// Description: Definition of local functions (visible by this module only). +//================================================================================================= + +PRIVATE VOID vTask( PVOID arg ); +PRIVATE VOID vEventCallback( PVOID pvData ); +PRIVATE VOID vMsgRxCallback( CAND_Message stMessage ); + +//================================================================================================= +// Section: LOCAL VARIABLES +// Description: Definition of local variables (visible by this module only). +//================================================================================================= + +LOCAL osThreadId_t m_pstThreadID = NULL; +LOCAL osMessageQueueId_t m_pstCANRxMsgQueueID = NULL; +LOCAL osEventFlagsId_t m_pstEventID = NULL; + +LOCAL osTimerId_t m_pstUpdateTimer = NULL; +LOCAL osTimerId_t m_pstWatchdogTimer = NULL; + +//================================================================================================= +// Section: LOCAL CONSTANTS +// Description: Definition of local constants (visible by this module only). +//================================================================================================= + +LOCAL CONST osThreadAttr_t stTaskAttribute = +{ + "MAIN_Thread", // name of the thread + osThreadDetached, // attribute bits + NULL, // memory for control block + 0, // size of provided memory for control block + NULL, // memory for stack + 1024, // size of stack + osPriorityAboveNormal1, // initial thread priority (default: osPriorityNormal) + 0, // TrustZone module identifier + 0, // reserved (must be 0) +}; + +LOCAL CONST osMessageQueueAttr_t stCANRxMsgQueueAttribute = +{ + "MAIN_CAN_Rx_Queue", // name of the message queue + 0, // attribute bits + NULL, // memory for control block + 0, // size of provided memory for control block + NULL, // memory for data storage + 0, // size of provided memory for data storage +}; + +LOCAL CONST osEventFlagsAttr_t stEventAttribute = +{ + "MAIN_Event_Flags", // name of the event flags + 0, // attribute bits + NULL, // memory for control block + 0, // size of provided memory for control block +}; + +LOCAL CONST osTimerAttr_t stTimerAttribute = +{ + "MAIN_UpdateTimer", // name of the timer + 0, // attribute bits + NULL, // memory for control block + 0, // size of provided memory for control block +}; + +LOCAL CONST osTimerAttr_t stWatchdogTimerAttribute = +{ + "MAIN_Watchdog", // name of the timer + 0, // attribute bits + NULL, // memory for control block + 0, // size of provided memory for control block +}; + +//================================================================================================= +// Section: EXTERNAL FUNCTIONS +// Description: Definition of external (global) functions. +//================================================================================================= + + + +//================================================================================================= +// Section: EXTERNAL VARIABLES +// Description: Definition of external (global) variables. +//================================================================================================= + +//================================================================================================= +// Section: GLOBAL FUNCTIONS +// Description: Definition (implementation) of global functions. +//================================================================================================= + + +//------------------------------------------------------------------------------------------------- +// Function: MAIN_boInitializeModule +// Description: Initializes the module. Function must be called once immediately after power-up. +// Parameters: None +// Returns: Boolean TRUE if successful +//------------------------------------------------------------------------------------------------- + +BOOL MAIN_boInitializeModule( VOID ) +{ + BOOL boOK = TRUE; + + boOK &= ( ( m_pstEventID = osEventFlagsNew( &stEventAttribute ) ) == NULL ) ? FALSE : TRUE; + boOK &= ( ( m_pstThreadID = osThreadNew( vTask, NULL, &stTaskAttribute ) ) == NULL ) ? FALSE : TRUE; + boOK &= ( ( m_pstCANRxMsgQueueID = osMessageQueueNew( MSG_QUEUE_SIZE, sizeof( CAND_Message ), &stCANRxMsgQueueAttribute ) ) == NULL ) ? FALSE : TRUE; + boOK &= ( m_pstUpdateTimer = osTimerNew( vEventCallback, osTimerPeriodic, (PVOID)EVENT_TIMER_UPDATE, &stTimerAttribute ) ) == NULL ? FALSE : TRUE; + boOK &= ( m_pstWatchdogTimer = osTimerNew( vEventCallback, osTimerPeriodic, (PVOID)EVENT_TIMER_UPDATE, &stWatchdogTimerAttribute ) ) == NULL ? FALSE : TRUE; + + boOK &= (osTimerStart( m_pstUpdateTimer, 1000 ) == osOK ) ? TRUE : FALSE; + //boOK &= (osTimerStart( m_pstWatchdogTimer, WATCHDOG ) == osOK ) ? TRUE : FALSE; + + CAND_vSetRxCallback( vMsgRxCallback ); + + return( boOK ); +} + +//================================================================================================= +// Section: LOCAL FUNCTIONS +// Descriptionn: Definition (implementation) of local functions. +//================================================================================================= + +//------------------------------------------------------------------------------------------------- +// Function: vMainTask +// Description: Main Application Task +// Parameters: None +// Returns: None +//------------------------------------------------------------------------------------------------- +PRIVATE VOID vTask( PVOID arg ) +{ + UNUSED( arg ); + U32 u32Flags; + + U8 au8Buffer[8]; + + while( TRUE ) + { + + u32Flags = osEventFlagsWait( m_pstEventID, EVENT_FLAGS_ALL, osFlagsWaitAny, osWaitForever ); // wait until flags getting triggered + + if( u32Flags & EVENT_NEW_MESSAGE ) { // New message from CAN + + CAND_Message stMessage; + osMessageQueueGet( m_pstCANRxMsgQueueID, &stMessage, NULL, 0 ); // get message from queue + + U8 u8Register = stMessage.au8Data[0]; + U8 u8Type = stMessage.u8Type; + + if( u8Type == MESSAGE_TYPE_READ ){ // Message type read + + osDelay(100); + + if( u8Register >= VARH_eNumberOfVariables ){ // check register + // send register not found + au8Buffer[0] = 0xFF; + CAND_boSendMessage( stMessage.u16Id, au8Buffer, 1 ); + } else { + VARH_UVariable uVariable = VARH_uGetVariableData(u8Register); // get data + au8Buffer[0] = u8Register; + UTIL_vMemCopy(&uVariable, &au8Buffer[1], 4); // copy data in buffer + + CAND_boSendMessage( stMessage.u16Id, au8Buffer, 5 ); + } + + } else if( u8Type == MESSAGE_TYPE_WRITE ){ // Message type writeset + VARH_UVariable uData; + UTIL_vMemCopy(&stMessage.au8Data[1], &uData, 4); + + VARH_vSetVariableData(u8Register, uData); + } else if( u8Type == MESSAGE_TYPE_COMMAND ){ // Message type command + + switch (u8Register) + { + case COMMAND_ON: + PECO_Enable( TRUE ); + break; + + case COMMAND_OFF: + PECO_Enable( FALSE ); + break; + case COMMAND_WATCHDOG: + osTimerStart( m_pstWatchdogTimer, WATCHDOG ); + break; + default: + break; + } + } + } + + if( u32Flags & EVENT_TIMER_UPDATE ) + { + DIPO_vToggleOutput( DIPO_eLED ); + } + + if( u32Flags & EVENT_WATCHDOG ) + { + PECO_Enable( FALSE ); + // TODO: WATCHDOG: what else? + } + + } +} + +//------------------------------------------------------------------------------------------------- +// Function: vEventCallback +// Description: Callback for events +// Parameters: None +// Returns: None +//------------------------------------------------------------------------------------------------- +PRIVATE VOID vEventCallback( PVOID pvData ) +{ + osEventFlagsSet( m_pstEventID, (U32)pvData ); +} + +//------------------------------------------------------------------------------------------------- +// Function: vEventCallback +// Description: Callback for events +// Parameters: None +// Returns: None +//------------------------------------------------------------------------------------------------- +PRIVATE VOID vMsgRxCallback( CAND_Message stMessage ) +{ + osMessageQueuePut( m_pstCANRxMsgQueueID, &stMessage, 0, 0 ); + osEventFlagsSet( m_pstEventID, EVENT_NEW_MESSAGE ); +} + + diff --git a/Core/Application/PECO_PeltierController.c b/Core/Application/PECO_PeltierController.c index 4c3b663..4bb8de6 100644 --- a/Core/Application/PECO_PeltierController.c +++ b/Core/Application/PECO_PeltierController.c @@ -88,9 +88,7 @@ LOCAL osThreadId_t m_pstThreadID = NULL; LOCAL osTimerId_t m_pstUpdateTimer = NULL; -LOCAL osEventFlagsId_t m_pstEventID = NULL; - -BOOL boEnableOutput = FALSE; +LOCAL osEventFlagsId_t m_pstEventID = NULL; //================================================================================================= // Section: LOCAL CONSTANTS @@ -105,7 +103,7 @@ LOCAL CONST osThreadAttr_t stTaskAttribute = 0, // size of provided memory for control block NULL, // memory for stack 1024, // size of stack - osPriorityHigh, // initial thread priority (default: osPriorityNormal) + osPriorityHigh, // initial thread priority (default: osPriorityNormal) 0, // TrustZone module identifier 0, // reserved (must be 0) }; @@ -184,7 +182,7 @@ BOOL PECO_boInitializeModule( VOID ) //------------------------------------------------------------------------------------------------- VOID PECO_Enable( BOOL boEnable ){ DIPO_vSetState(DIPO_eEN, boEnable); - boEnableOutput = boEnable; + VARH_vSetVariableDataFromSystemU32( VARH_ePowerState, (U32)boEnable ); } //------------------------------------------------------------------------------------------------- @@ -194,7 +192,7 @@ VOID PECO_Enable( BOOL boEnable ){ // Returns: BOOL boEnableOutput //------------------------------------------------------------------------------------------------- BOOL PECO_isEnabled( VOID ){ - return boEnableOutput; + return (BOOL)VARH_u32GetVariableData( VARH_ePowerState ); } //================================================================================================= diff --git a/Core/Application/VARH_VariableHandler.c b/Core/Application/VARH_VariableHandler.c index f4500da..e9b4578 100644 --- a/Core/Application/VARH_VariableHandler.c +++ b/Core/Application/VARH_VariableHandler.c @@ -94,6 +94,8 @@ LOCAL CONST VARH_StVarInfo m_astVarInfo[VARH_eNumberOfVariables] = { VARH_FLAGINFO_READONLY | VARH_FLAGINFO_FLOAT, (VARH_UVariable)0.0f, (VARH_UVariable)20.0f, (VARH_UVariable)30.0f }, // VARH_eSupply_U { VARH_FLAGINFO_READONLY | VARH_FLAGINFO_FLOAT, (VARH_UVariable)0.0f, (VARH_UVariable)0.0f, (VARH_UVariable)5.0f }, // VARH_eSupply_I { VARH_FLAGINFO_READONLY | VARH_FLAGINFO_FLOAT, (VARH_UVariable)0.0f, (VARH_UVariable)0.0f, (VARH_UVariable)150.0f }, // VARH_eSupply_P + + { VARH_FLAGINFO_READONLY, (VARH_UVariable)(U32)0, (VARH_UVariable)(U32)0, (VARH_UVariable)(U32)1 }, // VARH_ePowerState }; LOCAL CONST osMutexAttr_t m_stMutexAttr = @@ -217,7 +219,7 @@ VOID VARH_vSetVariableDataFloat( U8 u8Variable, FLOAT flData ) VOID VARH_vSetVariableDataFromSystem( U8 u8Variable, VARH_UVariable uData ) { osMutexAcquire( m_pstMutexID, osWaitForever ); // aquire mutex - if( boCheckRange( u8Variable, uData ) ) + if( !boCheckRange( u8Variable, uData ) ) { m_auVariable[u8Variable].u8Flags |= VARH_FLAG_OUTOFRANGE; // check the value } diff --git a/Core/Application/VARH_VariableHandler.h b/Core/Application/VARH_VariableHandler.h index e78790a..36d706d 100644 --- a/Core/Application/VARH_VariableHandler.h +++ b/Core/Application/VARH_VariableHandler.h @@ -89,6 +89,8 @@ typedef enum VARH_eSupply_I, VARH_eSupply_P, + VARH_ePowerState, + VARH_eNumberOfVariables, // Must be last entry } VARH_EnVariables; diff --git a/Core/Drivers/CAND_CanDriver.c b/Core/Drivers/CAND_CanDriver.c index 981b5f5..70e4c03 100644 --- a/Core/Drivers/CAND_CanDriver.c +++ b/Core/Drivers/CAND_CanDriver.c @@ -48,12 +48,13 @@ // Description: Definition of local constants (visible by this module only). //================================================================================================= -#define CAND_SHIFT 0x0 // Shift address space (0-3) +#define CAND_SHIFT 0x1 // Shift address space (0-3) #define CAND_PRIVATE 1 #define CAND_PUBLIC 0 -#define MASTER_ID ((CAND_SHIFT<<8) | 0x0000) +#define CAND_RECEIVE 0 +#define CAND_SEND 1 //================================================================================================= // Section: MACROS @@ -80,10 +81,12 @@ //================================================================================================= CAND_pfnRxCallback m_pfnRxCallback = NULL; +U8 u8BoardId = 0x00; + CAN_FilterTypeDef stFilter_public = { - (CAND_SHIFT<<14)|(CAND_PUBLIC<<13), // FilterIdHigh + (CAND_SHIFT<<14)|(CAND_PUBLIC<<13)|(CAND_RECEIVE<<11), // FilterIdHigh 0x0000, // FilterIdLow - 0xE000, // FilterMaskIdHigh + 0xE800, // FilterMaskIdHigh 0x0000, // FilterMaskIdLow CAN_FILTER_FIFO0, // FilterFIFOAssignment 0x00, // FilterBank @@ -94,9 +97,9 @@ CAN_FilterTypeDef stFilter_public = { }; CAN_FilterTypeDef stFilter_private = { - (CAND_SHIFT<<14)|(CAND_PRIVATE<<13), // FilterIdHigh + (CAND_SHIFT<<14)|(CAND_PRIVATE<<13)|(CAND_RECEIVE<<11), // FilterIdHigh 0x0000, // FilterIdLow - 0xE1E0, // FilterMaskIdHigh + 0xE9E0, // FilterMaskIdHigh 0x0000, // FilterMaskIdLow CAN_FILTER_FIFO0, // FilterFIFOAssignment 0x01, // FilterBank @@ -146,8 +149,7 @@ extern CAN_HandleTypeDef hcan1; BOOL CAND_boInitializeModule( VOID ) { BOOL boOK = TRUE; - - U8 u8BoardId = 0x00; + u8BoardId |= DIPO_boGetInput(DIPO_eADR0) << 0; u8BoardId |= DIPO_boGetInput(DIPO_eADR1) << 1; u8BoardId |= DIPO_boGetInput(DIPO_eADR2) << 2; @@ -165,6 +167,15 @@ BOOL CAND_boInitializeModule( VOID ) return( boOK ); } +//------------------------------------------------------------------------------------------------- +// Function: CAND_u8GetBoardId +// Description: Returns the Board ID +// Parameters: None +// Returns: U8 Board ID +//------------------------------------------------------------------------------------------------- +U8 CAND_u8GetBoardId( VOID ){ + return u8BoardId; +} //------------------------------------------------------------------------------------------------- // Function: CAND_boSendMessage @@ -174,13 +185,13 @@ BOOL CAND_boInitializeModule( VOID ) // PU8 Data Buffer // Returns: Boolean, TRUE if successful //------------------------------------------------------------------------------------------------- -BOOL CAND_boSendMessage( PU8 pu8Buffer, U8 u8Len ){ +BOOL CAND_boSendMessage( U16 u16Id, PU8 pu8Buffer, U8 u8Len ){ BOOL boOK = TRUE; if( u8Len > 8 ) return FALSE; CAN_TxHeaderTypeDef header = { - MASTER_ID, + u16Id | (CAND_SEND<<6), 0, CAN_ID_STD, CAN_RTR_DATA, @@ -227,6 +238,7 @@ void HAL_CAN_RxFifo0MsgPendingCallback( CAN_HandleTypeDef *hcan ){ CAND_Message stMessage; + stMessage.u16Id = header.StdId; stMessage.u8Type = (header.StdId & 0x030) >> 4; stMessage.u8Len = header.DLC; UTIL_vMemCopy( au8Data,stMessage.au8Data,stMessage.u8Len ); diff --git a/Core/Drivers/CAND_CanDriver.h b/Core/Drivers/CAND_CanDriver.h index 68dfda1..eeb38b9 100644 --- a/Core/Drivers/CAND_CanDriver.h +++ b/Core/Drivers/CAND_CanDriver.h @@ -67,6 +67,7 @@ typedef struct { U8 au8Data[8]; U8 u8Len; U8 u8Type; + U16 u16Id; } CAND_Message; // callback functions @@ -78,7 +79,6 @@ typedef VOID (*CAND_pfnRxCallback)( CAND_Message stMessage ); //================================================================================================= - //================================================================================================= // Section: GLOBAL CONSTANTS // Description: Definition of global constants (visible by all modules). @@ -92,8 +92,9 @@ typedef VOID (*CAND_pfnRxCallback)( CAND_Message stMessage ); //================================================================================================= BOOL CAND_boInitializeModule( VOID ); -BOOL CAND_boSendMessage( PU8 pu8Buffer, U8 u8Len ); +BOOL CAND_boSendMessage( U16 u16Id, PU8 pu8Buffer, U8 u8Len ); VOID CAND_vSetRxCallback( CAND_pfnRxCallback pfnRxCallback ); +U8 CAND_u8GetBoardId( VOID ); #ifdef __cplusplus } diff --git a/Core/Drivers/TEMP_Temperature.c b/Core/Drivers/TEMP_Temperature.c index f1dc4fe..231b298 100644 --- a/Core/Drivers/TEMP_Temperature.c +++ b/Core/Drivers/TEMP_Temperature.c @@ -1,190 +1,190 @@ -//================================================================================================= -// -// Company: Paul Scherrer Institut -// 5232 Villigen PSI -// Switzerland -// -//------------------------------------------------------------------------------------------------- -// -// Project: Peltier Controller V2 -// Author: Noah Piqué (noah.pique@psi.ch) -// -//------------------------------------------------------------------------------------------------- -// -// Module: Temp -// Filename: TEMP_Temperature.c -// Date: Handled by Subversion (version control system) -// Revision: Handled by Subversion (version control system) -// History: Handled by Subversion (version control system) -// -//------------------------------------------------------------------------------------------------- -// -// Description: This source file contains all functions dealing with the temperature readout -// -//================================================================================================= - -//================================================================================================= -// Section: INCLUDES -// Description: List of required include files. -//================================================================================================= - -#include "TEMP_Temperature.h" - -// Application -#include "../Application/VARH_VariableHandler.h" - -// Toolbox -#include "../Toolbox/UTIL_Utility.h" - -// Drivers -#include "ADCD_AdcDriver.h" - -// include STM32 drivers -#include "stm32l4xx_hal.h" - -#include "cmsis_os2.h" - -//================================================================================================= -// Section: DEFINITIONS -// Description: Definition of local constants (visible by this module only). -//================================================================================================= - -#define REFRESH_MS 100 - -//================================================================================================= -// Section: MACROS -// Description: Definition of local macros (visible by this module only). -//================================================================================================= - -//================================================================================================= -// Section: ENUMERATIONS -// Description: Definition of local enumerations (visible by this module only). -//================================================================================================= - -//================================================================================================= -// Section: STRUCTURES -// Description: Definition of local Structures (visible by this module only). -//================================================================================================= - -//================================================================================================= -// Section: LOCAL FUNCTIONS (PROTOTYPES) -// Description: Definition of local functions (visible by this module only). -//================================================================================================= - -PRIVATE FLOAT flConvertADCData( U16 dbRTemp ); -PRIVATE VOID vTask( PVOID arg ); - -//================================================================================================= -// Section: LOCAL CONSTANTS -// Description: Definition of local constants (visible by this module only). -//================================================================================================= - -LOCAL CONST osThreadAttr_t stTaskAttribute = -{ - "TEMP_Thread", // name of the thread - osThreadDetached, // attribute bits - NULL, // memory for control block - 0, // size of provided memory for control block - NULL, // memory for stack - 1024, // size of stack - osPriorityNormal, // initial thread priority (default: osPriorityNormal) - 0, // TrustZone module identifier - 0, // reserved (must be 0) -}; - -//================================================================================================= -// Section: LOCAL VARIABLES -// Description: Definition of local variables (visible by this module only). -//================================================================================================= - -LOCAL osThreadId_t m_pstThreadID = NULL; - -//================================================================================================= -// Section: EXTERNAL FUNCTIONS -// Description: Definition of external (global) functions. -//================================================================================================= - -//================================================================================================= -// Section: EXTERNAL VARIABLES -// Description: Definition of external (global) variables. -//================================================================================================= - -//================================================================================================= -// Section: GLOBAL FUNCTIONS -// Description: Definition (implementation) of global functions. -//================================================================================================= - -//------------------------------------------------------------------------------------------------- -// Function: TEMP_boInitializeModule -// Description: Initializes the module. Function must be called once immediately after power-up. -// This function is thread save -// Parameters: None -// Returns: Boolean TRUE if successful -//------------------------------------------------------------------------------------------------- -BOOL TEMP_boInitializeModule( VOID ) -{ - BOOL boOK = TRUE; - - boOK &= ((m_pstThreadID = osThreadNew( vTask, NULL, &stTaskAttribute )) == NULL ) ? FALSE : TRUE; - - return( boOK ); -} - -//================================================================================================= -// Section: LOCAL FUNCTIONS -// Descriptionn: Definition (implementation) of local functions. -//================================================================================================= - -//------------------------------------------------------------------------------------------------- -// Function: vTempTask -// Description: vTempTask -// Parameters: None -// Returns: None -//------------------------------------------------------------------------------------------------- -PRIVATE VOID vTask( PVOID arg ) -{ - UNUSED( arg ); - - BOOL boOK = TRUE; - U8 error; - U16 u16ADC_data[ADCD_eNumberOfTemps]; - FLOAT flTempData[ADCD_eNumberOfTemps]; - - osDelay(10); - - while( TRUE ) - { - boOK &= ADCD_boReadData( ADCD_eHot, &error, &u16ADC_data[ADCD_eHot] ); - boOK &= ADCD_boReadData( ADCD_eCold, &error, &u16ADC_data[ADCD_eCold] ); - if( boOK ) - { - flTempData[ADCD_eHot] = flConvertADCData( u16ADC_data[ADCD_eHot] ); - flTempData[ADCD_eCold] = flConvertADCData( u16ADC_data[ADCD_eCold] ); - VARH_vSetVariableDataFromSystemFloat( VARH_eTemp_H, flTempData[ADCD_eHot] ); - VARH_vSetVariableDataFromSystemFloat( VARH_eTemp_C, flTempData[ADCD_eCold] ); - VARH_vSetVariableDataFromSystemFloat( VARH_eTemp_Diff, flTempData[ADCD_eHot] - flTempData[ADCD_eCold] ); - - } - - osDelay(REFRESH_MS); - } -} - -//------------------------------------------------------------------------------------------------- -// Function: flConvertADCData -// Description: Converts resistor value to temperature data -// Parameters: U16 u16RTemp -// Returns: U16, temperature in Celcius -//------------------------------------------------------------------------------------------------- -PRIVATE FLOAT flConvertADCData( U16 u16RTemp ) -{ - - FLOAT u16R = u16RTemp / 8192.0f; - - FLOAT flT = 9.9714f * u16R; - flT += 235.904f; - flT *= u16R; - flT += -245.876f; - - return( flT ); -} +//================================================================================================= +// +// Company: Paul Scherrer Institut +// 5232 Villigen PSI +// Switzerland +// +//------------------------------------------------------------------------------------------------- +// +// Project: Peltier Controller V2 +// Author: Noah Piqué (noah.pique@psi.ch) +// +//------------------------------------------------------------------------------------------------- +// +// Module: Temp +// Filename: TEMP_Temperature.c +// Date: Handled by Subversion (version control system) +// Revision: Handled by Subversion (version control system) +// History: Handled by Subversion (version control system) +// +//------------------------------------------------------------------------------------------------- +// +// Description: This source file contains all functions dealing with the temperature readout +// +//================================================================================================= + +//================================================================================================= +// Section: INCLUDES +// Description: List of required include files. +//================================================================================================= + +#include "TEMP_Temperature.h" + +// Application +#include "../Application/VARH_VariableHandler.h" + +// Toolbox +#include "../Toolbox/UTIL_Utility.h" + +// Drivers +#include "ADCD_AdcDriver.h" + +// include STM32 drivers +#include "stm32l4xx_hal.h" + +#include "cmsis_os2.h" + +//================================================================================================= +// Section: DEFINITIONS +// Description: Definition of local constants (visible by this module only). +//================================================================================================= + +#define REFRESH_MS 100 + +//================================================================================================= +// Section: MACROS +// Description: Definition of local macros (visible by this module only). +//================================================================================================= + +//================================================================================================= +// Section: ENUMERATIONS +// Description: Definition of local enumerations (visible by this module only). +//================================================================================================= + +//================================================================================================= +// Section: STRUCTURES +// Description: Definition of local Structures (visible by this module only). +//================================================================================================= + +//================================================================================================= +// Section: LOCAL FUNCTIONS (PROTOTYPES) +// Description: Definition of local functions (visible by this module only). +//================================================================================================= + +PRIVATE FLOAT flConvertADCData( U16 dbRTemp ); +PRIVATE VOID vTask( PVOID arg ); + +//================================================================================================= +// Section: LOCAL CONSTANTS +// Description: Definition of local constants (visible by this module only). +//================================================================================================= + +LOCAL CONST osThreadAttr_t stTaskAttribute = +{ + "TEMP_Thread", // name of the thread + osThreadDetached, // attribute bits + NULL, // memory for control block + 0, // size of provided memory for control block + NULL, // memory for stack + 1024, // size of stack + osPriorityNormal, // initial thread priority (default: osPriorityNormal) + 0, // TrustZone module identifier + 0, // reserved (must be 0) +}; + +//================================================================================================= +// Section: LOCAL VARIABLES +// Description: Definition of local variables (visible by this module only). +//================================================================================================= + +LOCAL osThreadId_t m_pstThreadID = NULL; + +//================================================================================================= +// Section: EXTERNAL FUNCTIONS +// Description: Definition of external (global) functions. +//================================================================================================= + +//================================================================================================= +// Section: EXTERNAL VARIABLES +// Description: Definition of external (global) variables. +//================================================================================================= + +//================================================================================================= +// Section: GLOBAL FUNCTIONS +// Description: Definition (implementation) of global functions. +//================================================================================================= + +//------------------------------------------------------------------------------------------------- +// Function: TEMP_boInitializeModule +// Description: Initializes the module. Function must be called once immediately after power-up. +// This function is thread save +// Parameters: None +// Returns: Boolean TRUE if successful +//------------------------------------------------------------------------------------------------- +BOOL TEMP_boInitializeModule( VOID ) +{ + BOOL boOK = TRUE; + + boOK &= ((m_pstThreadID = osThreadNew( vTask, NULL, &stTaskAttribute )) == NULL ) ? FALSE : TRUE; + + return( boOK ); +} + +//================================================================================================= +// Section: LOCAL FUNCTIONS +// Descriptionn: Definition (implementation) of local functions. +//================================================================================================= + +//------------------------------------------------------------------------------------------------- +// Function: vTempTask +// Description: vTempTask +// Parameters: None +// Returns: None +//------------------------------------------------------------------------------------------------- +PRIVATE VOID vTask( PVOID arg ) +{ + UNUSED( arg ); + + BOOL boOK = TRUE; + U8 error; + U16 u16ADC_data[ADCD_eNumberOfTemps]; + FLOAT flTempData[ADCD_eNumberOfTemps]; + + osDelay(10); + + while( TRUE ) + { + boOK &= ADCD_boReadData( ADCD_eHot, &error, &u16ADC_data[ADCD_eHot] ); + boOK &= ADCD_boReadData( ADCD_eCold, &error, &u16ADC_data[ADCD_eCold] ); + if( boOK ) + { + flTempData[ADCD_eHot] = flConvertADCData( u16ADC_data[ADCD_eHot] ); + flTempData[ADCD_eCold] = flConvertADCData( u16ADC_data[ADCD_eCold] ); + VARH_vSetVariableDataFromSystemFloat( VARH_eTemp_H, flTempData[ADCD_eHot] ); + VARH_vSetVariableDataFromSystemFloat( VARH_eTemp_C, flTempData[ADCD_eCold] ); + VARH_vSetVariableDataFromSystemFloat( VARH_eTemp_Diff, flTempData[ADCD_eHot] - flTempData[ADCD_eCold] ); + + } + + osDelay(REFRESH_MS); + } +} + +//------------------------------------------------------------------------------------------------- +// Function: flConvertADCData +// Description: Converts resistor value to temperature data +// Parameters: U16 u16RTemp +// Returns: U16, temperature in Celcius +//------------------------------------------------------------------------------------------------- +PRIVATE FLOAT flConvertADCData( U16 u16RTemp ) +{ + + FLOAT u16R = u16RTemp / 8192.0f; + + FLOAT flT = 9.9714f * u16R; + flT += 235.904f; + flT *= u16R; + flT += -245.876f; + + return( flT ); +} diff --git a/Core/Drivers/TEMP_Temperature.h b/Core/Drivers/TEMP_Temperature.h index 37ec93c..445aa95 100644 --- a/Core/Drivers/TEMP_Temperature.h +++ b/Core/Drivers/TEMP_Temperature.h @@ -1,87 +1,87 @@ -//================================================================================================= -// -// Company: Paul Scherrer Institut -// 5232 Villigen PSI -// Switzerland -// -//------------------------------------------------------------------------------------------------- -// -// Project: Peltier Controller V2 -// Author: Noah Piqué (noah.pique@psi.ch) -// -//------------------------------------------------------------------------------------------------- -// -// Module: Temperature -// Filename: TEMP_Temperature.h -// Date: Handled by Subversion (version control system) -// Revision: Handled by Subversion (version control system) -// History: Handled by Subversion (version control system) -// -//------------------------------------------------------------------------------------------------- - -#ifndef TEMP_TEMPERATURE_H -#define TEMP_TEMPERATURE_H - -#ifdef __cplusplus -extern "C" { -#endif - - - -//================================================================================================= -// Section: INCLUDES -// Description: List of required include files (visible by all modules). -//================================================================================================= - -#include "../SDEF_StandardDefinitions.h" -#include "ADCD_AdcDriver.h" - -//================================================================================================= -// Section: DEFINITIONS -// Description: Definition of global constants (visible by all modules). -//================================================================================================= - -//typedef VOID (*TEMP_pfnEventCallback)( PVOID pvData ); - -//================================================================================================= -// Section: MACROS -// Description: Definition of global macros (visible by all modules). -//================================================================================================= - - -//================================================================================================= -// Section: ENUMERATIONS -// Description: Definition of global enumerations (visible by all modules). -//================================================================================================= - - -//================================================================================================= -// Section: STRUCTURES -// Description: Definition of global Structures (visible by all modules). -//================================================================================================= - - -//================================================================================================= -// Section: GLOBAL VARIABLES -// Description: Definition of global variables (visible by all modules). -//================================================================================================= - - -//================================================================================================= -// Section: GLOBAL CONSTANTS -// Description: Definition of global constants (visible by all modules). -//================================================================================================= - - -//================================================================================================= -// Section: GLOBAL FUNCTIONS (PROTOTYPES) -// Description: Definition of global functions (visible by all modules). -//================================================================================================= - -BOOL TEMP_boInitializeModule( VOID ); - -#ifdef __cplusplus -} -#endif - -#endif +//================================================================================================= +// +// Company: Paul Scherrer Institut +// 5232 Villigen PSI +// Switzerland +// +//------------------------------------------------------------------------------------------------- +// +// Project: Peltier Controller V2 +// Author: Noah Piqué (noah.pique@psi.ch) +// +//------------------------------------------------------------------------------------------------- +// +// Module: Temperature +// Filename: TEMP_Temperature.h +// Date: Handled by Subversion (version control system) +// Revision: Handled by Subversion (version control system) +// History: Handled by Subversion (version control system) +// +//------------------------------------------------------------------------------------------------- + +#ifndef TEMP_TEMPERATURE_H +#define TEMP_TEMPERATURE_H + +#ifdef __cplusplus +extern "C" { +#endif + + + +//================================================================================================= +// Section: INCLUDES +// Description: List of required include files (visible by all modules). +//================================================================================================= + +#include "../SDEF_StandardDefinitions.h" +#include "ADCD_AdcDriver.h" + +//================================================================================================= +// Section: DEFINITIONS +// Description: Definition of global constants (visible by all modules). +//================================================================================================= + +//typedef VOID (*TEMP_pfnEventCallback)( PVOID pvData ); + +//================================================================================================= +// Section: MACROS +// Description: Definition of global macros (visible by all modules). +//================================================================================================= + + +//================================================================================================= +// Section: ENUMERATIONS +// Description: Definition of global enumerations (visible by all modules). +//================================================================================================= + + +//================================================================================================= +// Section: STRUCTURES +// Description: Definition of global Structures (visible by all modules). +//================================================================================================= + + +//================================================================================================= +// Section: GLOBAL VARIABLES +// Description: Definition of global variables (visible by all modules). +//================================================================================================= + + +//================================================================================================= +// Section: GLOBAL CONSTANTS +// Description: Definition of global constants (visible by all modules). +//================================================================================================= + + +//================================================================================================= +// Section: GLOBAL FUNCTIONS (PROTOTYPES) +// Description: Definition of global functions (visible by all modules). +//================================================================================================= + +BOOL TEMP_boInitializeModule( VOID ); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/Core/Inc/FreeRTOSConfig.h b/Core/Inc/FreeRTOSConfig.h index dc4c2ca..747b26a 100644 --- a/Core/Inc/FreeRTOSConfig.h +++ b/Core/Inc/FreeRTOSConfig.h @@ -1,174 +1,174 @@ -/* USER CODE BEGIN Header */ -/* - * FreeRTOS Kernel V10.3.1 - * Portion Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * Portion Copyright (C) 2019 StMicroelectronics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * http://www.FreeRTOS.org - * http://aws.amazon.com/freertos - * - * 1 tab == 4 spaces! - */ -/* USER CODE END Header */ - -#ifndef FREERTOS_CONFIG_H -#define FREERTOS_CONFIG_H - -/*----------------------------------------------------------- - * Application specific definitions. - * - * These definitions should be adjusted for your particular hardware and - * application requirements. - * - * These parameters and more are described within the 'configuration' section of the - * FreeRTOS API documentation available on the FreeRTOS.org web site. - * - * See http://www.freertos.org/a00110.html - *----------------------------------------------------------*/ - -/* USER CODE BEGIN Includes */ -/* Section where include file can be added */ -/* USER CODE END Includes */ - -/* Ensure definitions are only used by the compiler, and not by the assembler. */ -#if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__) - #include - extern uint32_t SystemCoreClock; - void xPortSysTickHandler(void); -#endif -#ifndef CMSIS_device_header -#define CMSIS_device_header "stm32l4xx.h" -#endif /* CMSIS_device_header */ - -#define configENABLE_FPU 0 -#define configENABLE_MPU 0 - -#define configUSE_PREEMPTION 1 -#define configSUPPORT_STATIC_ALLOCATION 1 -#define configSUPPORT_DYNAMIC_ALLOCATION 1 -#define configUSE_IDLE_HOOK 0 -#define configUSE_TICK_HOOK 0 -#define configCPU_CLOCK_HZ ( SystemCoreClock ) -#define configTICK_RATE_HZ ((TickType_t)1000) -#define configMAX_PRIORITIES ( 56 ) -#define configMINIMAL_STACK_SIZE ((uint16_t)128) -#define configTOTAL_HEAP_SIZE ((size_t)32768) -#define configMAX_TASK_NAME_LEN ( 16 ) -#define configUSE_TRACE_FACILITY 1 -#define configUSE_16_BIT_TICKS 0 -#define configUSE_MUTEXES 1 -#define configQUEUE_REGISTRY_SIZE 8 -#define configUSE_RECURSIVE_MUTEXES 1 -#define configUSE_COUNTING_SEMAPHORES 1 -#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0 -/* USER CODE BEGIN MESSAGE_BUFFER_LENGTH_TYPE */ -/* Defaults to size_t for backward compatibility, but can be changed - if lengths will always be less than the number of bytes in a size_t. */ -#define configMESSAGE_BUFFER_LENGTH_TYPE size_t -/* USER CODE END MESSAGE_BUFFER_LENGTH_TYPE */ - -/* Co-routine definitions. */ -#define configUSE_CO_ROUTINES 0 -#define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) - -/* Software timer definitions. */ -#define configUSE_TIMERS 1 -#define configTIMER_TASK_PRIORITY ( 2 ) -#define configTIMER_QUEUE_LENGTH 10 -#define configTIMER_TASK_STACK_DEPTH 256 - -/* The following flag must be enabled only when using newlib */ -#define configUSE_NEWLIB_REENTRANT 1 - -/* CMSIS-RTOS V2 flags */ -#define configUSE_OS2_THREAD_SUSPEND_RESUME 1 -#define configUSE_OS2_THREAD_ENUMERATE 1 -#define configUSE_OS2_EVENTFLAGS_FROM_ISR 1 -#define configUSE_OS2_THREAD_FLAGS 1 -#define configUSE_OS2_TIMER 1 -#define configUSE_OS2_MUTEX 1 - -/* Set the following definitions to 1 to include the API function, or zero -to exclude the API function. */ -#define INCLUDE_vTaskPrioritySet 1 -#define INCLUDE_uxTaskPriorityGet 1 -#define INCLUDE_vTaskDelete 1 -#define INCLUDE_vTaskCleanUpResources 0 -#define INCLUDE_vTaskSuspend 1 -#define INCLUDE_vTaskDelayUntil 1 -#define INCLUDE_vTaskDelay 1 -#define INCLUDE_xTaskGetSchedulerState 1 -#define INCLUDE_xTimerPendFunctionCall 1 -#define INCLUDE_xQueueGetMutexHolder 1 -#define INCLUDE_uxTaskGetStackHighWaterMark 1 -#define INCLUDE_xTaskGetCurrentTaskHandle 1 -#define INCLUDE_eTaskGetState 1 - -/* - * The CMSIS-RTOS V2 FreeRTOS wrapper is dependent on the heap implementation used - * by the application thus the correct define need to be enabled below - */ -#define USE_FreeRTOS_HEAP_4 - -/* Cortex-M specific definitions. */ -#ifdef __NVIC_PRIO_BITS - /* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */ - #define configPRIO_BITS __NVIC_PRIO_BITS -#else - #define configPRIO_BITS 4 -#endif - -/* The lowest interrupt priority that can be used in a call to a "set priority" -function. */ -#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 15 - -/* The highest interrupt priority that can be used by any interrupt service -routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL -INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER -PRIORITY THAN THIS! (higher priorities are lower numeric values. */ -#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5 - -/* Interrupt priorities used by the kernel port layer itself. These are generic -to all Cortex-M ports, and do not rely on any particular library functions. */ -#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) ) -/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!! -See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */ -#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) ) - -/* Normal assert() semantics without relying on the provision of an assert.h -header file. */ -/* USER CODE BEGIN 1 */ -#define configASSERT( x ) if ((x) == 0) {taskDISABLE_INTERRUPTS(); for( ;; );} -/* USER CODE END 1 */ - -/* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS -standard names. */ -#define vPortSVCHandler SVC_Handler -#define xPortPendSVHandler PendSV_Handler - -/* IMPORTANT: After 10.3.1 update, Systick_Handler comes from NVIC (if SYS timebase = systick), otherwise from cmsis_os2.c */ - -#define USE_CUSTOM_SYSTICK_HANDLER_IMPLEMENTATION 1 - -/* USER CODE BEGIN Defines */ -/* Section where parameter definitions can be added (for instance, to override default ones in FreeRTOS.h) */ -/* USER CODE END Defines */ - -#endif /* FREERTOS_CONFIG_H */ +/* USER CODE BEGIN Header */ +/* + * FreeRTOS Kernel V10.3.1 + * Portion Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Portion Copyright (C) 2019 StMicroelectronics, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ +/* USER CODE END Header */ + +#ifndef FREERTOS_CONFIG_H +#define FREERTOS_CONFIG_H + +/*----------------------------------------------------------- + * Application specific definitions. + * + * These definitions should be adjusted for your particular hardware and + * application requirements. + * + * These parameters and more are described within the 'configuration' section of the + * FreeRTOS API documentation available on the FreeRTOS.org web site. + * + * See http://www.freertos.org/a00110.html + *----------------------------------------------------------*/ + +/* USER CODE BEGIN Includes */ +/* Section where include file can be added */ +/* USER CODE END Includes */ + +/* Ensure definitions are only used by the compiler, and not by the assembler. */ +#if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__) + #include + extern uint32_t SystemCoreClock; + void xPortSysTickHandler(void); +#endif +#ifndef CMSIS_device_header +#define CMSIS_device_header "stm32l4xx.h" +#endif /* CMSIS_device_header */ + +#define configENABLE_FPU 0 +#define configENABLE_MPU 0 + +#define configUSE_PREEMPTION 1 +#define configSUPPORT_STATIC_ALLOCATION 1 +#define configSUPPORT_DYNAMIC_ALLOCATION 1 +#define configUSE_IDLE_HOOK 0 +#define configUSE_TICK_HOOK 0 +#define configCPU_CLOCK_HZ ( SystemCoreClock ) +#define configTICK_RATE_HZ ((TickType_t)1000) +#define configMAX_PRIORITIES ( 56 ) +#define configMINIMAL_STACK_SIZE ((uint16_t)128) +#define configTOTAL_HEAP_SIZE ((size_t)32768) +#define configMAX_TASK_NAME_LEN ( 16 ) +#define configUSE_TRACE_FACILITY 1 +#define configUSE_16_BIT_TICKS 0 +#define configUSE_MUTEXES 1 +#define configQUEUE_REGISTRY_SIZE 8 +#define configUSE_RECURSIVE_MUTEXES 1 +#define configUSE_COUNTING_SEMAPHORES 1 +#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0 +/* USER CODE BEGIN MESSAGE_BUFFER_LENGTH_TYPE */ +/* Defaults to size_t for backward compatibility, but can be changed + if lengths will always be less than the number of bytes in a size_t. */ +#define configMESSAGE_BUFFER_LENGTH_TYPE size_t +/* USER CODE END MESSAGE_BUFFER_LENGTH_TYPE */ + +/* Co-routine definitions. */ +#define configUSE_CO_ROUTINES 0 +#define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) + +/* Software timer definitions. */ +#define configUSE_TIMERS 1 +#define configTIMER_TASK_PRIORITY ( 2 ) +#define configTIMER_QUEUE_LENGTH 10 +#define configTIMER_TASK_STACK_DEPTH 256 + +/* The following flag must be enabled only when using newlib */ +#define configUSE_NEWLIB_REENTRANT 1 + +/* CMSIS-RTOS V2 flags */ +#define configUSE_OS2_THREAD_SUSPEND_RESUME 1 +#define configUSE_OS2_THREAD_ENUMERATE 1 +#define configUSE_OS2_EVENTFLAGS_FROM_ISR 1 +#define configUSE_OS2_THREAD_FLAGS 1 +#define configUSE_OS2_TIMER 1 +#define configUSE_OS2_MUTEX 1 + +/* Set the following definitions to 1 to include the API function, or zero +to exclude the API function. */ +#define INCLUDE_vTaskPrioritySet 1 +#define INCLUDE_uxTaskPriorityGet 1 +#define INCLUDE_vTaskDelete 1 +#define INCLUDE_vTaskCleanUpResources 0 +#define INCLUDE_vTaskSuspend 1 +#define INCLUDE_vTaskDelayUntil 1 +#define INCLUDE_vTaskDelay 1 +#define INCLUDE_xTaskGetSchedulerState 1 +#define INCLUDE_xTimerPendFunctionCall 1 +#define INCLUDE_xQueueGetMutexHolder 1 +#define INCLUDE_uxTaskGetStackHighWaterMark 1 +#define INCLUDE_xTaskGetCurrentTaskHandle 1 +#define INCLUDE_eTaskGetState 1 + +/* + * The CMSIS-RTOS V2 FreeRTOS wrapper is dependent on the heap implementation used + * by the application thus the correct define need to be enabled below + */ +#define USE_FreeRTOS_HEAP_4 + +/* Cortex-M specific definitions. */ +#ifdef __NVIC_PRIO_BITS + /* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */ + #define configPRIO_BITS __NVIC_PRIO_BITS +#else + #define configPRIO_BITS 4 +#endif + +/* The lowest interrupt priority that can be used in a call to a "set priority" +function. */ +#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 15 + +/* The highest interrupt priority that can be used by any interrupt service +routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL +INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER +PRIORITY THAN THIS! (higher priorities are lower numeric values. */ +#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5 + +/* Interrupt priorities used by the kernel port layer itself. These are generic +to all Cortex-M ports, and do not rely on any particular library functions. */ +#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) ) +/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!! +See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */ +#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) ) + +/* Normal assert() semantics without relying on the provision of an assert.h +header file. */ +/* USER CODE BEGIN 1 */ +#define configASSERT( x ) if ((x) == 0) {taskDISABLE_INTERRUPTS(); for( ;; );} +/* USER CODE END 1 */ + +/* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS +standard names. */ +#define vPortSVCHandler SVC_Handler +#define xPortPendSVHandler PendSV_Handler + +/* IMPORTANT: After 10.3.1 update, Systick_Handler comes from NVIC (if SYS timebase = systick), otherwise from cmsis_os2.c */ + +#define USE_CUSTOM_SYSTICK_HANDLER_IMPLEMENTATION 1 + +/* USER CODE BEGIN Defines */ +/* Section where parameter definitions can be added (for instance, to override default ones in FreeRTOS.h) */ +/* USER CODE END Defines */ + +#endif /* FREERTOS_CONFIG_H */ diff --git a/Core/Inc/main.h b/Core/Inc/main.h index 762754e..9cb3998 100644 --- a/Core/Inc/main.h +++ b/Core/Inc/main.h @@ -1,87 +1,87 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file : main.h - * @brief : Header for main.c file. - * This file contains the common defines of the application. - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2021 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** - */ -/* USER CODE END Header */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __MAIN_H -#define __MAIN_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "stm32l4xx_hal.h" - -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* Exported types ------------------------------------------------------------*/ -/* USER CODE BEGIN ET */ - -/* USER CODE END ET */ - -/* Exported constants --------------------------------------------------------*/ -/* USER CODE BEGIN EC */ - -/* USER CODE END EC */ - -/* Exported macro ------------------------------------------------------------*/ -/* USER CODE BEGIN EM */ - -/* USER CODE END EM */ - -/* Exported functions prototypes ---------------------------------------------*/ -void Error_Handler(void); - -/* USER CODE BEGIN EFP */ - -/* USER CODE END EFP */ - -/* Private defines -----------------------------------------------------------*/ -#define LED_Pin GPIO_PIN_14 -#define LED_GPIO_Port GPIOC -#define ADR3_Pin GPIO_PIN_15 -#define ADR3_GPIO_Port GPIOC -#define EN_Pin GPIO_PIN_8 -#define EN_GPIO_Port GPIOA -#define ADR0_Pin GPIO_PIN_15 -#define ADR0_GPIO_Port GPIOA -#define ADR1_Pin GPIO_PIN_3 -#define ADR1_GPIO_Port GPIOB -#define ADR2_Pin GPIO_PIN_4 -#define ADR2_GPIO_Port GPIOB -#define CS1_Pin GPIO_PIN_5 -#define CS1_GPIO_Port GPIOB -#define CS2_Pin GPIO_PIN_6 -#define CS2_GPIO_Port GPIOB -#define PG_Pin GPIO_PIN_7 -#define PG_GPIO_Port GPIOB -/* USER CODE BEGIN Private defines */ - -/* USER CODE END Private defines */ - -#ifdef __cplusplus -} -#endif - -#endif /* __MAIN_H */ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : main.h + * @brief : Header for main.c file. + * This file contains the common defines of the application. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __MAIN_H +#define __MAIN_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32l4xx_hal.h" + +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Exported types ------------------------------------------------------------*/ +/* USER CODE BEGIN ET */ + +/* USER CODE END ET */ + +/* Exported constants --------------------------------------------------------*/ +/* USER CODE BEGIN EC */ + +/* USER CODE END EC */ + +/* Exported macro ------------------------------------------------------------*/ +/* USER CODE BEGIN EM */ + +/* USER CODE END EM */ + +/* Exported functions prototypes ---------------------------------------------*/ +void Error_Handler(void); + +/* USER CODE BEGIN EFP */ + +/* USER CODE END EFP */ + +/* Private defines -----------------------------------------------------------*/ +#define LED_Pin GPIO_PIN_14 +#define LED_GPIO_Port GPIOC +#define ADR3_Pin GPIO_PIN_15 +#define ADR3_GPIO_Port GPIOC +#define EN_Pin GPIO_PIN_8 +#define EN_GPIO_Port GPIOA +#define ADR0_Pin GPIO_PIN_15 +#define ADR0_GPIO_Port GPIOA +#define ADR1_Pin GPIO_PIN_3 +#define ADR1_GPIO_Port GPIOB +#define ADR2_Pin GPIO_PIN_4 +#define ADR2_GPIO_Port GPIOB +#define CS1_Pin GPIO_PIN_5 +#define CS1_GPIO_Port GPIOB +#define CS2_Pin GPIO_PIN_6 +#define CS2_GPIO_Port GPIOB +#define PG_Pin GPIO_PIN_7 +#define PG_GPIO_Port GPIOB +/* USER CODE BEGIN Private defines */ + +/* USER CODE END Private defines */ + +#ifdef __cplusplus +} +#endif + +#endif /* __MAIN_H */ diff --git a/Core/Inc/stm32l4xx_hal_conf.h b/Core/Inc/stm32l4xx_hal_conf.h index 317c3e0..3540da6 100644 --- a/Core/Inc/stm32l4xx_hal_conf.h +++ b/Core/Inc/stm32l4xx_hal_conf.h @@ -1,482 +1,482 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file stm32l4xx_hal_conf.h - * @author MCD Application Team - * @brief HAL configuration template file. - * This file should be copied to the application folder and renamed - * to stm32l4xx_hal_conf.h. - ****************************************************************************** - * @attention - * - * Copyright (c) 2017 STMicroelectronics. - * All rights reserved. - * - * This software is licensed under terms that can be found in the LICENSE file - * in the root directory of this software component. - * If no LICENSE file comes with this software, it is provided AS-IS. - * - ****************************************************************************** - */ -/* USER CODE END Header */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef STM32L4xx_HAL_CONF_H -#define STM32L4xx_HAL_CONF_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Exported types ------------------------------------------------------------*/ -/* Exported constants --------------------------------------------------------*/ - -/* ########################## Module Selection ############################## */ -/** - * @brief This is the list of modules to be used in the HAL driver - */ -#define HAL_MODULE_ENABLED -#define HAL_ADC_MODULE_ENABLED -/*#define HAL_CRYP_MODULE_ENABLED */ -#define HAL_CAN_MODULE_ENABLED -/*#define HAL_COMP_MODULE_ENABLED */ -/*#define HAL_CRC_MODULE_ENABLED */ -/*#define HAL_CRYP_MODULE_ENABLED */ -#define HAL_DAC_MODULE_ENABLED -/*#define HAL_DCMI_MODULE_ENABLED */ -/*#define HAL_DMA2D_MODULE_ENABLED */ -/*#define HAL_DFSDM_MODULE_ENABLED */ -/*#define HAL_DSI_MODULE_ENABLED */ -/*#define HAL_FIREWALL_MODULE_ENABLED */ -/*#define HAL_GFXMMU_MODULE_ENABLED */ -/*#define HAL_HCD_MODULE_ENABLED */ -/*#define HAL_HASH_MODULE_ENABLED */ -/*#define HAL_I2S_MODULE_ENABLED */ -/*#define HAL_IRDA_MODULE_ENABLED */ -#define HAL_IWDG_MODULE_ENABLED -/*#define HAL_LTDC_MODULE_ENABLED */ -/*#define HAL_LCD_MODULE_ENABLED */ -/*#define HAL_LPTIM_MODULE_ENABLED */ -/*#define HAL_MMC_MODULE_ENABLED */ -/*#define HAL_NAND_MODULE_ENABLED */ -/*#define HAL_NOR_MODULE_ENABLED */ -/*#define HAL_OPAMP_MODULE_ENABLED */ -/*#define HAL_OSPI_MODULE_ENABLED */ -/*#define HAL_OSPI_MODULE_ENABLED */ -/*#define HAL_PCD_MODULE_ENABLED */ -/*#define HAL_PKA_MODULE_ENABLED */ -/*#define HAL_QSPI_MODULE_ENABLED */ -/*#define HAL_QSPI_MODULE_ENABLED */ -/*#define HAL_RNG_MODULE_ENABLED */ -/*#define HAL_RTC_MODULE_ENABLED */ -/*#define HAL_SAI_MODULE_ENABLED */ -/*#define HAL_SD_MODULE_ENABLED */ -/*#define HAL_SMBUS_MODULE_ENABLED */ -/*#define HAL_SMARTCARD_MODULE_ENABLED */ -#define HAL_SPI_MODULE_ENABLED -/*#define HAL_SRAM_MODULE_ENABLED */ -/*#define HAL_SWPMI_MODULE_ENABLED */ -/*#define HAL_TIM_MODULE_ENABLED */ -/*#define HAL_TSC_MODULE_ENABLED */ -/*#define HAL_UART_MODULE_ENABLED */ -/*#define HAL_USART_MODULE_ENABLED */ -/*#define HAL_WWDG_MODULE_ENABLED */ -/*#define HAL_EXTI_MODULE_ENABLED */ -/*#define HAL_PSSI_MODULE_ENABLED */ -#define HAL_GPIO_MODULE_ENABLED -#define HAL_EXTI_MODULE_ENABLED -#define HAL_I2C_MODULE_ENABLED -#define HAL_DMA_MODULE_ENABLED -#define HAL_RCC_MODULE_ENABLED -#define HAL_FLASH_MODULE_ENABLED -#define HAL_PWR_MODULE_ENABLED -#define HAL_CORTEX_MODULE_ENABLED - -/* ########################## Oscillator Values adaptation ####################*/ -/** - * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. - * This value is used by the RCC HAL module to compute the system frequency - * (when HSE is used as system clock source, directly or through the PLL). - */ -#if !defined (HSE_VALUE) - #define HSE_VALUE ((uint32_t)40000000U) /*!< Value of the External oscillator in Hz */ -#endif /* HSE_VALUE */ - -#if !defined (HSE_STARTUP_TIMEOUT) - #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */ -#endif /* HSE_STARTUP_TIMEOUT */ - -/** - * @brief Internal Multiple Speed oscillator (MSI) default value. - * This value is the default MSI range value after Reset. - */ -#if !defined (MSI_VALUE) - #define MSI_VALUE ((uint32_t)4000000U) /*!< Value of the Internal oscillator in Hz*/ -#endif /* MSI_VALUE */ -/** - * @brief Internal High Speed oscillator (HSI) value. - * This value is used by the RCC HAL module to compute the system frequency - * (when HSI is used as system clock source, directly or through the PLL). - */ -#if !defined (HSI_VALUE) - #define HSI_VALUE ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/ -#endif /* HSI_VALUE */ - -/** - * @brief Internal High Speed oscillator (HSI48) value for USB FS, SDMMC and RNG. - * This internal oscillator is mainly dedicated to provide a high precision clock to - * the USB peripheral by means of a special Clock Recovery System (CRS) circuitry. - * When the CRS is not used, the HSI48 RC oscillator runs on it default frequency - * which is subject to manufacturing process variations. - */ -#if !defined (HSI48_VALUE) - #define HSI48_VALUE ((uint32_t)48000000U) /*!< Value of the Internal High Speed oscillator for USB FS/SDMMC/RNG in Hz. - The real value my vary depending on manufacturing process variations.*/ -#endif /* HSI48_VALUE */ - -/** - * @brief Internal Low Speed oscillator (LSI) value. - */ -#if !defined (LSI_VALUE) - #define LSI_VALUE 32000U /*!< LSI Typical Value in Hz*/ -#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz - The real value may vary depending on the variations - in voltage and temperature.*/ - -/** - * @brief External Low Speed oscillator (LSE) value. - * This value is used by the UART, RTC HAL module to compute the system frequency - */ -#if !defined (LSE_VALUE) - #define LSE_VALUE 32768U /*!< Value of the External oscillator in Hz*/ -#endif /* LSE_VALUE */ - -#if !defined (LSE_STARTUP_TIMEOUT) - #define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ -#endif /* HSE_STARTUP_TIMEOUT */ - -/** - * @brief External clock source for SAI1 peripheral - * This value is used by the RCC HAL module to compute the SAI1 & SAI2 clock source - * frequency. - */ -#if !defined (EXTERNAL_SAI1_CLOCK_VALUE) - #define EXTERNAL_SAI1_CLOCK_VALUE 2097000U /*!< Value of the SAI1 External clock source in Hz*/ -#endif /* EXTERNAL_SAI1_CLOCK_VALUE */ - -/** - * @brief External clock source for SAI2 peripheral - * This value is used by the RCC HAL module to compute the SAI1 & SAI2 clock source - * frequency. - */ -#if !defined (EXTERNAL_SAI2_CLOCK_VALUE) - #define EXTERNAL_SAI2_CLOCK_VALUE 48000U /*!< Value of the SAI2 External clock source in Hz*/ -#endif /* EXTERNAL_SAI2_CLOCK_VALUE */ - -/* Tip: To avoid modifying this file each time you need to use different HSE, - === you can define the HSE value in your toolchain compiler preprocessor. */ - -/* ########################### System Configuration ######################### */ -/** - * @brief This is the HAL system configuration section - */ - -#define VDD_VALUE 3300U /*!< Value of VDD in mv */ -#define TICK_INT_PRIORITY 15U /*!< tick interrupt priority */ -#define USE_RTOS 0U -#define PREFETCH_ENABLE 0U -#define INSTRUCTION_CACHE_ENABLE 1U -#define DATA_CACHE_ENABLE 1U - -/* ########################## Assert Selection ############################## */ -/** - * @brief Uncomment the line below to expanse the "assert_param" macro in the - * HAL drivers code - */ -/* #define USE_FULL_ASSERT 1U */ - -/* ################## Register callback feature configuration ############### */ -/** - * @brief Set below the peripheral configuration to "1U" to add the support - * of HAL callback registration/deregistration feature for the HAL - * driver(s). This allows user application to provide specific callback - * functions thanks to HAL_PPP_RegisterCallback() rather than overwriting - * the default weak callback functions (see each stm32l4xx_hal_ppp.h file - * for possible callback identifiers defined in HAL_PPP_CallbackIDTypeDef - * for each PPP peripheral). - */ -#define USE_HAL_ADC_REGISTER_CALLBACKS 0U -#define USE_HAL_CAN_REGISTER_CALLBACKS 0U -#define USE_HAL_COMP_REGISTER_CALLBACKS 0U -#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U -#define USE_HAL_DAC_REGISTER_CALLBACKS 0U -#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U -#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U -#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U -#define USE_HAL_DSI_REGISTER_CALLBACKS 0U -#define USE_HAL_GFXMMU_REGISTER_CALLBACKS 0U -#define USE_HAL_HASH_REGISTER_CALLBACKS 0U -#define USE_HAL_HCD_REGISTER_CALLBACKS 0U -#define USE_HAL_I2C_REGISTER_CALLBACKS 0U -#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U -#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U -#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U -#define USE_HAL_MMC_REGISTER_CALLBACKS 0U -#define USE_HAL_OPAMP_REGISTER_CALLBACKS 0U -#define USE_HAL_OSPI_REGISTER_CALLBACKS 0U -#define USE_HAL_PCD_REGISTER_CALLBACKS 0U -#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U -#define USE_HAL_RNG_REGISTER_CALLBACKS 0U -#define USE_HAL_RTC_REGISTER_CALLBACKS 0U -#define USE_HAL_SAI_REGISTER_CALLBACKS 0U -#define USE_HAL_SD_REGISTER_CALLBACKS 0U -#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U -#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U -#define USE_HAL_SPI_REGISTER_CALLBACKS 0U -#define USE_HAL_SWPMI_REGISTER_CALLBACKS 0U -#define USE_HAL_TIM_REGISTER_CALLBACKS 0U -#define USE_HAL_TSC_REGISTER_CALLBACKS 0U -#define USE_HAL_UART_REGISTER_CALLBACKS 0U -#define USE_HAL_USART_REGISTER_CALLBACKS 0U -#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U - -/* ################## SPI peripheral configuration ########################## */ - -/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver - * Activated: CRC code is present inside driver - * Deactivated: CRC code cleaned from driver - */ - -#define USE_SPI_CRC 0U - -/* Includes ------------------------------------------------------------------*/ -/** - * @brief Include module's header file - */ - -#ifdef HAL_RCC_MODULE_ENABLED - #include "stm32l4xx_hal_rcc.h" -#endif /* HAL_RCC_MODULE_ENABLED */ - -#ifdef HAL_GPIO_MODULE_ENABLED - #include "stm32l4xx_hal_gpio.h" -#endif /* HAL_GPIO_MODULE_ENABLED */ - -#ifdef HAL_DMA_MODULE_ENABLED - #include "stm32l4xx_hal_dma.h" -#endif /* HAL_DMA_MODULE_ENABLED */ - -#ifdef HAL_DFSDM_MODULE_ENABLED - #include "stm32l4xx_hal_dfsdm.h" -#endif /* HAL_DFSDM_MODULE_ENABLED */ - -#ifdef HAL_CORTEX_MODULE_ENABLED - #include "stm32l4xx_hal_cortex.h" -#endif /* HAL_CORTEX_MODULE_ENABLED */ - -#ifdef HAL_ADC_MODULE_ENABLED - #include "stm32l4xx_hal_adc.h" -#endif /* HAL_ADC_MODULE_ENABLED */ - -#ifdef HAL_CAN_MODULE_ENABLED - #include "stm32l4xx_hal_can.h" -#endif /* HAL_CAN_MODULE_ENABLED */ - -#ifdef HAL_CAN_LEGACY_MODULE_ENABLED - #include "Legacy/stm32l4xx_hal_can_legacy.h" -#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */ - -#ifdef HAL_COMP_MODULE_ENABLED - #include "stm32l4xx_hal_comp.h" -#endif /* HAL_COMP_MODULE_ENABLED */ - -#ifdef HAL_CRC_MODULE_ENABLED - #include "stm32l4xx_hal_crc.h" -#endif /* HAL_CRC_MODULE_ENABLED */ - -#ifdef HAL_CRYP_MODULE_ENABLED - #include "stm32l4xx_hal_cryp.h" -#endif /* HAL_CRYP_MODULE_ENABLED */ - -#ifdef HAL_DAC_MODULE_ENABLED - #include "stm32l4xx_hal_dac.h" -#endif /* HAL_DAC_MODULE_ENABLED */ - -#ifdef HAL_DCMI_MODULE_ENABLED - #include "stm32l4xx_hal_dcmi.h" -#endif /* HAL_DCMI_MODULE_ENABLED */ - -#ifdef HAL_DMA2D_MODULE_ENABLED - #include "stm32l4xx_hal_dma2d.h" -#endif /* HAL_DMA2D_MODULE_ENABLED */ - -#ifdef HAL_DSI_MODULE_ENABLED - #include "stm32l4xx_hal_dsi.h" -#endif /* HAL_DSI_MODULE_ENABLED */ - -#ifdef HAL_EXTI_MODULE_ENABLED - #include "stm32l4xx_hal_exti.h" -#endif /* HAL_EXTI_MODULE_ENABLED */ - -#ifdef HAL_GFXMMU_MODULE_ENABLED - #include "stm32l4xx_hal_gfxmmu.h" -#endif /* HAL_GFXMMU_MODULE_ENABLED */ - -#ifdef HAL_FIREWALL_MODULE_ENABLED - #include "stm32l4xx_hal_firewall.h" -#endif /* HAL_FIREWALL_MODULE_ENABLED */ - -#ifdef HAL_FLASH_MODULE_ENABLED - #include "stm32l4xx_hal_flash.h" -#endif /* HAL_FLASH_MODULE_ENABLED */ - -#ifdef HAL_HASH_MODULE_ENABLED - #include "stm32l4xx_hal_hash.h" -#endif /* HAL_HASH_MODULE_ENABLED */ - -#ifdef HAL_HCD_MODULE_ENABLED - #include "stm32l4xx_hal_hcd.h" -#endif /* HAL_HCD_MODULE_ENABLED */ - -#ifdef HAL_I2C_MODULE_ENABLED - #include "stm32l4xx_hal_i2c.h" -#endif /* HAL_I2C_MODULE_ENABLED */ - -#ifdef HAL_IRDA_MODULE_ENABLED - #include "stm32l4xx_hal_irda.h" -#endif /* HAL_IRDA_MODULE_ENABLED */ - -#ifdef HAL_IWDG_MODULE_ENABLED - #include "stm32l4xx_hal_iwdg.h" -#endif /* HAL_IWDG_MODULE_ENABLED */ - -#ifdef HAL_LCD_MODULE_ENABLED - #include "stm32l4xx_hal_lcd.h" -#endif /* HAL_LCD_MODULE_ENABLED */ - -#ifdef HAL_LPTIM_MODULE_ENABLED - #include "stm32l4xx_hal_lptim.h" -#endif /* HAL_LPTIM_MODULE_ENABLED */ - -#ifdef HAL_LTDC_MODULE_ENABLED - #include "stm32l4xx_hal_ltdc.h" -#endif /* HAL_LTDC_MODULE_ENABLED */ - -#ifdef HAL_MMC_MODULE_ENABLED - #include "stm32l4xx_hal_mmc.h" -#endif /* HAL_MMC_MODULE_ENABLED */ - -#ifdef HAL_NAND_MODULE_ENABLED - #include "stm32l4xx_hal_nand.h" -#endif /* HAL_NAND_MODULE_ENABLED */ - -#ifdef HAL_NOR_MODULE_ENABLED - #include "stm32l4xx_hal_nor.h" -#endif /* HAL_NOR_MODULE_ENABLED */ - -#ifdef HAL_OPAMP_MODULE_ENABLED - #include "stm32l4xx_hal_opamp.h" -#endif /* HAL_OPAMP_MODULE_ENABLED */ - -#ifdef HAL_OSPI_MODULE_ENABLED - #include "stm32l4xx_hal_ospi.h" -#endif /* HAL_OSPI_MODULE_ENABLED */ - -#ifdef HAL_PCD_MODULE_ENABLED - #include "stm32l4xx_hal_pcd.h" -#endif /* HAL_PCD_MODULE_ENABLED */ - -#ifdef HAL_PKA_MODULE_ENABLED - #include "stm32l4xx_hal_pka.h" -#endif /* HAL_PKA_MODULE_ENABLED */ - -#ifdef HAL_PSSI_MODULE_ENABLED - #include "stm32l4xx_hal_pssi.h" -#endif /* HAL_PSSI_MODULE_ENABLED */ - -#ifdef HAL_PWR_MODULE_ENABLED - #include "stm32l4xx_hal_pwr.h" -#endif /* HAL_PWR_MODULE_ENABLED */ - -#ifdef HAL_QSPI_MODULE_ENABLED - #include "stm32l4xx_hal_qspi.h" -#endif /* HAL_QSPI_MODULE_ENABLED */ - -#ifdef HAL_RNG_MODULE_ENABLED - #include "stm32l4xx_hal_rng.h" -#endif /* HAL_RNG_MODULE_ENABLED */ - -#ifdef HAL_RTC_MODULE_ENABLED - #include "stm32l4xx_hal_rtc.h" -#endif /* HAL_RTC_MODULE_ENABLED */ - -#ifdef HAL_SAI_MODULE_ENABLED - #include "stm32l4xx_hal_sai.h" -#endif /* HAL_SAI_MODULE_ENABLED */ - -#ifdef HAL_SD_MODULE_ENABLED - #include "stm32l4xx_hal_sd.h" -#endif /* HAL_SD_MODULE_ENABLED */ - -#ifdef HAL_SMARTCARD_MODULE_ENABLED - #include "stm32l4xx_hal_smartcard.h" -#endif /* HAL_SMARTCARD_MODULE_ENABLED */ - -#ifdef HAL_SMBUS_MODULE_ENABLED - #include "stm32l4xx_hal_smbus.h" -#endif /* HAL_SMBUS_MODULE_ENABLED */ - -#ifdef HAL_SPI_MODULE_ENABLED - #include "stm32l4xx_hal_spi.h" -#endif /* HAL_SPI_MODULE_ENABLED */ - -#ifdef HAL_SRAM_MODULE_ENABLED - #include "stm32l4xx_hal_sram.h" -#endif /* HAL_SRAM_MODULE_ENABLED */ - -#ifdef HAL_SWPMI_MODULE_ENABLED - #include "stm32l4xx_hal_swpmi.h" -#endif /* HAL_SWPMI_MODULE_ENABLED */ - -#ifdef HAL_TIM_MODULE_ENABLED - #include "stm32l4xx_hal_tim.h" -#endif /* HAL_TIM_MODULE_ENABLED */ - -#ifdef HAL_TSC_MODULE_ENABLED - #include "stm32l4xx_hal_tsc.h" -#endif /* HAL_TSC_MODULE_ENABLED */ - -#ifdef HAL_UART_MODULE_ENABLED - #include "stm32l4xx_hal_uart.h" -#endif /* HAL_UART_MODULE_ENABLED */ - -#ifdef HAL_USART_MODULE_ENABLED - #include "stm32l4xx_hal_usart.h" -#endif /* HAL_USART_MODULE_ENABLED */ - -#ifdef HAL_WWDG_MODULE_ENABLED - #include "stm32l4xx_hal_wwdg.h" -#endif /* HAL_WWDG_MODULE_ENABLED */ - -/* Exported macro ------------------------------------------------------------*/ -#ifdef USE_FULL_ASSERT -/** - * @brief The assert_param macro is used for function's parameters check. - * @param expr If expr is false, it calls assert_failed function - * which reports the name of the source file and the source - * line number of the call that failed. - * If expr is true, it returns no value. - * @retval None - */ - #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) -/* Exported functions ------------------------------------------------------- */ - void assert_failed(uint8_t *file, uint32_t line); -#else - #define assert_param(expr) ((void)0U) -#endif /* USE_FULL_ASSERT */ - -#ifdef __cplusplus -} -#endif - -#endif /* STM32L4xx_HAL_CONF_H */ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file stm32l4xx_hal_conf.h + * @author MCD Application Team + * @brief HAL configuration template file. + * This file should be copied to the application folder and renamed + * to stm32l4xx_hal_conf.h. + ****************************************************************************** + * @attention + * + * Copyright (c) 2017 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef STM32L4xx_HAL_CONF_H +#define STM32L4xx_HAL_CONF_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ +/** + * @brief This is the list of modules to be used in the HAL driver + */ +#define HAL_MODULE_ENABLED +#define HAL_ADC_MODULE_ENABLED +/*#define HAL_CRYP_MODULE_ENABLED */ +#define HAL_CAN_MODULE_ENABLED +/*#define HAL_COMP_MODULE_ENABLED */ +/*#define HAL_CRC_MODULE_ENABLED */ +/*#define HAL_CRYP_MODULE_ENABLED */ +#define HAL_DAC_MODULE_ENABLED +/*#define HAL_DCMI_MODULE_ENABLED */ +/*#define HAL_DMA2D_MODULE_ENABLED */ +/*#define HAL_DFSDM_MODULE_ENABLED */ +/*#define HAL_DSI_MODULE_ENABLED */ +/*#define HAL_FIREWALL_MODULE_ENABLED */ +/*#define HAL_GFXMMU_MODULE_ENABLED */ +/*#define HAL_HCD_MODULE_ENABLED */ +/*#define HAL_HASH_MODULE_ENABLED */ +/*#define HAL_I2S_MODULE_ENABLED */ +/*#define HAL_IRDA_MODULE_ENABLED */ +#define HAL_IWDG_MODULE_ENABLED +/*#define HAL_LTDC_MODULE_ENABLED */ +/*#define HAL_LCD_MODULE_ENABLED */ +/*#define HAL_LPTIM_MODULE_ENABLED */ +/*#define HAL_MMC_MODULE_ENABLED */ +/*#define HAL_NAND_MODULE_ENABLED */ +/*#define HAL_NOR_MODULE_ENABLED */ +/*#define HAL_OPAMP_MODULE_ENABLED */ +/*#define HAL_OSPI_MODULE_ENABLED */ +/*#define HAL_OSPI_MODULE_ENABLED */ +/*#define HAL_PCD_MODULE_ENABLED */ +/*#define HAL_PKA_MODULE_ENABLED */ +/*#define HAL_QSPI_MODULE_ENABLED */ +/*#define HAL_QSPI_MODULE_ENABLED */ +/*#define HAL_RNG_MODULE_ENABLED */ +/*#define HAL_RTC_MODULE_ENABLED */ +/*#define HAL_SAI_MODULE_ENABLED */ +/*#define HAL_SD_MODULE_ENABLED */ +/*#define HAL_SMBUS_MODULE_ENABLED */ +/*#define HAL_SMARTCARD_MODULE_ENABLED */ +#define HAL_SPI_MODULE_ENABLED +/*#define HAL_SRAM_MODULE_ENABLED */ +/*#define HAL_SWPMI_MODULE_ENABLED */ +/*#define HAL_TIM_MODULE_ENABLED */ +/*#define HAL_TSC_MODULE_ENABLED */ +/*#define HAL_UART_MODULE_ENABLED */ +/*#define HAL_USART_MODULE_ENABLED */ +/*#define HAL_WWDG_MODULE_ENABLED */ +/*#define HAL_EXTI_MODULE_ENABLED */ +/*#define HAL_PSSI_MODULE_ENABLED */ +#define HAL_GPIO_MODULE_ENABLED +#define HAL_EXTI_MODULE_ENABLED +#define HAL_I2C_MODULE_ENABLED +#define HAL_DMA_MODULE_ENABLED +#define HAL_RCC_MODULE_ENABLED +#define HAL_FLASH_MODULE_ENABLED +#define HAL_PWR_MODULE_ENABLED +#define HAL_CORTEX_MODULE_ENABLED + +/* ########################## Oscillator Values adaptation ####################*/ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#if !defined (HSE_VALUE) + #define HSE_VALUE ((uint32_t)40000000U) /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (HSE_STARTUP_TIMEOUT) + #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief Internal Multiple Speed oscillator (MSI) default value. + * This value is the default MSI range value after Reset. + */ +#if !defined (MSI_VALUE) + #define MSI_VALUE ((uint32_t)4000000U) /*!< Value of the Internal oscillator in Hz*/ +#endif /* MSI_VALUE */ +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#if !defined (HSI_VALUE) + #define HSI_VALUE ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/** + * @brief Internal High Speed oscillator (HSI48) value for USB FS, SDMMC and RNG. + * This internal oscillator is mainly dedicated to provide a high precision clock to + * the USB peripheral by means of a special Clock Recovery System (CRS) circuitry. + * When the CRS is not used, the HSI48 RC oscillator runs on it default frequency + * which is subject to manufacturing process variations. + */ +#if !defined (HSI48_VALUE) + #define HSI48_VALUE ((uint32_t)48000000U) /*!< Value of the Internal High Speed oscillator for USB FS/SDMMC/RNG in Hz. + The real value my vary depending on manufacturing process variations.*/ +#endif /* HSI48_VALUE */ + +/** + * @brief Internal Low Speed oscillator (LSI) value. + */ +#if !defined (LSI_VALUE) + #define LSI_VALUE 32000U /*!< LSI Typical Value in Hz*/ +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz + The real value may vary depending on the variations + in voltage and temperature.*/ + +/** + * @brief External Low Speed oscillator (LSE) value. + * This value is used by the UART, RTC HAL module to compute the system frequency + */ +#if !defined (LSE_VALUE) + #define LSE_VALUE 32768U /*!< Value of the External oscillator in Hz*/ +#endif /* LSE_VALUE */ + +#if !defined (LSE_STARTUP_TIMEOUT) + #define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief External clock source for SAI1 peripheral + * This value is used by the RCC HAL module to compute the SAI1 & SAI2 clock source + * frequency. + */ +#if !defined (EXTERNAL_SAI1_CLOCK_VALUE) + #define EXTERNAL_SAI1_CLOCK_VALUE 2097000U /*!< Value of the SAI1 External clock source in Hz*/ +#endif /* EXTERNAL_SAI1_CLOCK_VALUE */ + +/** + * @brief External clock source for SAI2 peripheral + * This value is used by the RCC HAL module to compute the SAI1 & SAI2 clock source + * frequency. + */ +#if !defined (EXTERNAL_SAI2_CLOCK_VALUE) + #define EXTERNAL_SAI2_CLOCK_VALUE 48000U /*!< Value of the SAI2 External clock source in Hz*/ +#endif /* EXTERNAL_SAI2_CLOCK_VALUE */ + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ + +#define VDD_VALUE 3300U /*!< Value of VDD in mv */ +#define TICK_INT_PRIORITY 15U /*!< tick interrupt priority */ +#define USE_RTOS 0U +#define PREFETCH_ENABLE 0U +#define INSTRUCTION_CACHE_ENABLE 1U +#define DATA_CACHE_ENABLE 1U + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ +/* #define USE_FULL_ASSERT 1U */ + +/* ################## Register callback feature configuration ############### */ +/** + * @brief Set below the peripheral configuration to "1U" to add the support + * of HAL callback registration/deregistration feature for the HAL + * driver(s). This allows user application to provide specific callback + * functions thanks to HAL_PPP_RegisterCallback() rather than overwriting + * the default weak callback functions (see each stm32l4xx_hal_ppp.h file + * for possible callback identifiers defined in HAL_PPP_CallbackIDTypeDef + * for each PPP peripheral). + */ +#define USE_HAL_ADC_REGISTER_CALLBACKS 0U +#define USE_HAL_CAN_REGISTER_CALLBACKS 0U +#define USE_HAL_COMP_REGISTER_CALLBACKS 0U +#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U +#define USE_HAL_DAC_REGISTER_CALLBACKS 0U +#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U +#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U +#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U +#define USE_HAL_DSI_REGISTER_CALLBACKS 0U +#define USE_HAL_GFXMMU_REGISTER_CALLBACKS 0U +#define USE_HAL_HASH_REGISTER_CALLBACKS 0U +#define USE_HAL_HCD_REGISTER_CALLBACKS 0U +#define USE_HAL_I2C_REGISTER_CALLBACKS 0U +#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U +#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U +#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U +#define USE_HAL_MMC_REGISTER_CALLBACKS 0U +#define USE_HAL_OPAMP_REGISTER_CALLBACKS 0U +#define USE_HAL_OSPI_REGISTER_CALLBACKS 0U +#define USE_HAL_PCD_REGISTER_CALLBACKS 0U +#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U +#define USE_HAL_RNG_REGISTER_CALLBACKS 0U +#define USE_HAL_RTC_REGISTER_CALLBACKS 0U +#define USE_HAL_SAI_REGISTER_CALLBACKS 0U +#define USE_HAL_SD_REGISTER_CALLBACKS 0U +#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U +#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U +#define USE_HAL_SPI_REGISTER_CALLBACKS 0U +#define USE_HAL_SWPMI_REGISTER_CALLBACKS 0U +#define USE_HAL_TIM_REGISTER_CALLBACKS 0U +#define USE_HAL_TSC_REGISTER_CALLBACKS 0U +#define USE_HAL_UART_REGISTER_CALLBACKS 0U +#define USE_HAL_USART_REGISTER_CALLBACKS 0U +#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U + +/* ################## SPI peripheral configuration ########################## */ + +/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver + * Activated: CRC code is present inside driver + * Deactivated: CRC code cleaned from driver + */ + +#define USE_SPI_CRC 0U + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED + #include "stm32l4xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED + #include "stm32l4xx_hal_gpio.h" +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_DMA_MODULE_ENABLED + #include "stm32l4xx_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_DFSDM_MODULE_ENABLED + #include "stm32l4xx_hal_dfsdm.h" +#endif /* HAL_DFSDM_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED + #include "stm32l4xx_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED + #include "stm32l4xx_hal_adc.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_CAN_MODULE_ENABLED + #include "stm32l4xx_hal_can.h" +#endif /* HAL_CAN_MODULE_ENABLED */ + +#ifdef HAL_CAN_LEGACY_MODULE_ENABLED + #include "Legacy/stm32l4xx_hal_can_legacy.h" +#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */ + +#ifdef HAL_COMP_MODULE_ENABLED + #include "stm32l4xx_hal_comp.h" +#endif /* HAL_COMP_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED + #include "stm32l4xx_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_CRYP_MODULE_ENABLED + #include "stm32l4xx_hal_cryp.h" +#endif /* HAL_CRYP_MODULE_ENABLED */ + +#ifdef HAL_DAC_MODULE_ENABLED + #include "stm32l4xx_hal_dac.h" +#endif /* HAL_DAC_MODULE_ENABLED */ + +#ifdef HAL_DCMI_MODULE_ENABLED + #include "stm32l4xx_hal_dcmi.h" +#endif /* HAL_DCMI_MODULE_ENABLED */ + +#ifdef HAL_DMA2D_MODULE_ENABLED + #include "stm32l4xx_hal_dma2d.h" +#endif /* HAL_DMA2D_MODULE_ENABLED */ + +#ifdef HAL_DSI_MODULE_ENABLED + #include "stm32l4xx_hal_dsi.h" +#endif /* HAL_DSI_MODULE_ENABLED */ + +#ifdef HAL_EXTI_MODULE_ENABLED + #include "stm32l4xx_hal_exti.h" +#endif /* HAL_EXTI_MODULE_ENABLED */ + +#ifdef HAL_GFXMMU_MODULE_ENABLED + #include "stm32l4xx_hal_gfxmmu.h" +#endif /* HAL_GFXMMU_MODULE_ENABLED */ + +#ifdef HAL_FIREWALL_MODULE_ENABLED + #include "stm32l4xx_hal_firewall.h" +#endif /* HAL_FIREWALL_MODULE_ENABLED */ + +#ifdef HAL_FLASH_MODULE_ENABLED + #include "stm32l4xx_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_HASH_MODULE_ENABLED + #include "stm32l4xx_hal_hash.h" +#endif /* HAL_HASH_MODULE_ENABLED */ + +#ifdef HAL_HCD_MODULE_ENABLED + #include "stm32l4xx_hal_hcd.h" +#endif /* HAL_HCD_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED + #include "stm32l4xx_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED + #include "stm32l4xx_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED + #include "stm32l4xx_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_LCD_MODULE_ENABLED + #include "stm32l4xx_hal_lcd.h" +#endif /* HAL_LCD_MODULE_ENABLED */ + +#ifdef HAL_LPTIM_MODULE_ENABLED + #include "stm32l4xx_hal_lptim.h" +#endif /* HAL_LPTIM_MODULE_ENABLED */ + +#ifdef HAL_LTDC_MODULE_ENABLED + #include "stm32l4xx_hal_ltdc.h" +#endif /* HAL_LTDC_MODULE_ENABLED */ + +#ifdef HAL_MMC_MODULE_ENABLED + #include "stm32l4xx_hal_mmc.h" +#endif /* HAL_MMC_MODULE_ENABLED */ + +#ifdef HAL_NAND_MODULE_ENABLED + #include "stm32l4xx_hal_nand.h" +#endif /* HAL_NAND_MODULE_ENABLED */ + +#ifdef HAL_NOR_MODULE_ENABLED + #include "stm32l4xx_hal_nor.h" +#endif /* HAL_NOR_MODULE_ENABLED */ + +#ifdef HAL_OPAMP_MODULE_ENABLED + #include "stm32l4xx_hal_opamp.h" +#endif /* HAL_OPAMP_MODULE_ENABLED */ + +#ifdef HAL_OSPI_MODULE_ENABLED + #include "stm32l4xx_hal_ospi.h" +#endif /* HAL_OSPI_MODULE_ENABLED */ + +#ifdef HAL_PCD_MODULE_ENABLED + #include "stm32l4xx_hal_pcd.h" +#endif /* HAL_PCD_MODULE_ENABLED */ + +#ifdef HAL_PKA_MODULE_ENABLED + #include "stm32l4xx_hal_pka.h" +#endif /* HAL_PKA_MODULE_ENABLED */ + +#ifdef HAL_PSSI_MODULE_ENABLED + #include "stm32l4xx_hal_pssi.h" +#endif /* HAL_PSSI_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED + #include "stm32l4xx_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_QSPI_MODULE_ENABLED + #include "stm32l4xx_hal_qspi.h" +#endif /* HAL_QSPI_MODULE_ENABLED */ + +#ifdef HAL_RNG_MODULE_ENABLED + #include "stm32l4xx_hal_rng.h" +#endif /* HAL_RNG_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED + #include "stm32l4xx_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_SAI_MODULE_ENABLED + #include "stm32l4xx_hal_sai.h" +#endif /* HAL_SAI_MODULE_ENABLED */ + +#ifdef HAL_SD_MODULE_ENABLED + #include "stm32l4xx_hal_sd.h" +#endif /* HAL_SD_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED + #include "stm32l4xx_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_SMBUS_MODULE_ENABLED + #include "stm32l4xx_hal_smbus.h" +#endif /* HAL_SMBUS_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED + #include "stm32l4xx_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_SRAM_MODULE_ENABLED + #include "stm32l4xx_hal_sram.h" +#endif /* HAL_SRAM_MODULE_ENABLED */ + +#ifdef HAL_SWPMI_MODULE_ENABLED + #include "stm32l4xx_hal_swpmi.h" +#endif /* HAL_SWPMI_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED + #include "stm32l4xx_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_TSC_MODULE_ENABLED + #include "stm32l4xx_hal_tsc.h" +#endif /* HAL_TSC_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED + #include "stm32l4xx_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED + #include "stm32l4xx_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +#ifdef HAL_WWDG_MODULE_ENABLED + #include "stm32l4xx_hal_wwdg.h" +#endif /* HAL_WWDG_MODULE_ENABLED */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ + #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ + void assert_failed(uint8_t *file, uint32_t line); +#else + #define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + +#ifdef __cplusplus +} +#endif + +#endif /* STM32L4xx_HAL_CONF_H */ diff --git a/Core/Inc/stm32l4xx_it.h b/Core/Inc/stm32l4xx_it.h index ce4d541..354547c 100644 --- a/Core/Inc/stm32l4xx_it.h +++ b/Core/Inc/stm32l4xx_it.h @@ -1,74 +1,74 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file stm32l4xx_it.h - * @brief This file contains the headers of the interrupt handlers. - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2021 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** - */ -/* USER CODE END Header */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32L4xx_IT_H -#define __STM32L4xx_IT_H - -#ifdef __cplusplus - extern "C" { -#endif - -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* Exported types ------------------------------------------------------------*/ -/* USER CODE BEGIN ET */ - -/* USER CODE END ET */ - -/* Exported constants --------------------------------------------------------*/ -/* USER CODE BEGIN EC */ - -/* USER CODE END EC */ - -/* Exported macro ------------------------------------------------------------*/ -/* USER CODE BEGIN EM */ - -/* USER CODE END EM */ - -/* Exported functions prototypes ---------------------------------------------*/ -void NMI_Handler(void); -void HardFault_Handler(void); -void MemManage_Handler(void); -void BusFault_Handler(void); -void UsageFault_Handler(void); -void DebugMon_Handler(void); -void SysTick_Handler(void); -void DMA1_Channel2_IRQHandler(void); -void DMA1_Channel3_IRQHandler(void); -void ADC1_IRQHandler(void); -void CAN1_TX_IRQHandler(void); -void CAN1_RX0_IRQHandler(void); -void CAN1_RX1_IRQHandler(void); -void CAN1_SCE_IRQHandler(void); -void SPI1_IRQHandler(void); -void DMA2_Channel3_IRQHandler(void); -/* USER CODE BEGIN EFP */ - -/* USER CODE END EFP */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STM32L4xx_IT_H */ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file stm32l4xx_it.h + * @brief This file contains the headers of the interrupt handlers. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32L4xx_IT_H +#define __STM32L4xx_IT_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Exported types ------------------------------------------------------------*/ +/* USER CODE BEGIN ET */ + +/* USER CODE END ET */ + +/* Exported constants --------------------------------------------------------*/ +/* USER CODE BEGIN EC */ + +/* USER CODE END EC */ + +/* Exported macro ------------------------------------------------------------*/ +/* USER CODE BEGIN EM */ + +/* USER CODE END EM */ + +/* Exported functions prototypes ---------------------------------------------*/ +void NMI_Handler(void); +void HardFault_Handler(void); +void MemManage_Handler(void); +void BusFault_Handler(void); +void UsageFault_Handler(void); +void DebugMon_Handler(void); +void SysTick_Handler(void); +void DMA1_Channel2_IRQHandler(void); +void DMA1_Channel3_IRQHandler(void); +void ADC1_IRQHandler(void); +void CAN1_TX_IRQHandler(void); +void CAN1_RX0_IRQHandler(void); +void CAN1_RX1_IRQHandler(void); +void CAN1_SCE_IRQHandler(void); +void SPI1_IRQHandler(void); +void DMA2_Channel3_IRQHandler(void); +/* USER CODE BEGIN EFP */ + +/* USER CODE END EFP */ + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32L4xx_IT_H */ diff --git a/Core/Src/freertos.c b/Core/Src/freertos.c index 3bbda39..9d30963 100644 --- a/Core/Src/freertos.c +++ b/Core/Src/freertos.c @@ -1,60 +1,60 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * File Name : freertos.c - * Description : Code for freertos applications - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2021 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under Ultimate Liberty license - * SLA0044, the "License"; You may not use this file except in compliance with - * the License. You may obtain a copy of the License at: - * www.st.com/SLA0044 - * - ****************************************************************************** - */ -/* USER CODE END Header */ - -/* Includes ------------------------------------------------------------------*/ -#include "FreeRTOS.h" -#include "task.h" -#include "main.h" - -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* Private typedef -----------------------------------------------------------*/ -/* USER CODE BEGIN PTD */ - -/* USER CODE END PTD */ - -/* Private define ------------------------------------------------------------*/ -/* USER CODE BEGIN PD */ - -/* USER CODE END PD */ - -/* Private macro -------------------------------------------------------------*/ -/* USER CODE BEGIN PM */ - -/* USER CODE END PM */ - -/* Private variables ---------------------------------------------------------*/ -/* USER CODE BEGIN Variables */ - -/* USER CODE END Variables */ - -/* Private function prototypes -----------------------------------------------*/ -/* USER CODE BEGIN FunctionPrototypes */ - -/* USER CODE END FunctionPrototypes */ - -/* Private application code --------------------------------------------------*/ -/* USER CODE BEGIN Application */ - -/* USER CODE END Application */ - +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * File Name : freertos.c + * Description : Code for freertos applications + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "FreeRTOS.h" +#include "task.h" +#include "main.h" + +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Private typedef -----------------------------------------------------------*/ +/* USER CODE BEGIN PTD */ + +/* USER CODE END PTD */ + +/* Private define ------------------------------------------------------------*/ +/* USER CODE BEGIN PD */ + +/* USER CODE END PD */ + +/* Private macro -------------------------------------------------------------*/ +/* USER CODE BEGIN PM */ + +/* USER CODE END PM */ + +/* Private variables ---------------------------------------------------------*/ +/* USER CODE BEGIN Variables */ + +/* USER CODE END Variables */ + +/* Private function prototypes -----------------------------------------------*/ +/* USER CODE BEGIN FunctionPrototypes */ + +/* USER CODE END FunctionPrototypes */ + +/* Private application code --------------------------------------------------*/ +/* USER CODE BEGIN Application */ + +/* USER CODE END Application */ + diff --git a/Core/Src/main.c b/Core/Src/main.c index 3380d16..c762325 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -1,651 +1,651 @@ -/* USER CODE BEGIN Header */ -//================================================================================================= -// -// Company: Paul Scherrer Institut -// 5232 Villigen PSI -// Switzerland -// -//------------------------------------------------------------------------------------------------- -// -// Project: Peltier Controller V2 -// Author: Noah Piqué (noah.pique@psi.ch) -// -//------------------------------------------------------------------------------------------------- -// -// Filename: main.c -// Date: Handled by Subversion (version control system) -// Revision: Handled by Subversion (version control system) -// History: Handled by Subversion (version control system) -// -//------------------------------------------------------------------------------------------------- -// -// Description: This source file contains all functions for starting the PeltierController -// -//================================================================================================= -/* USER CODE END Header */ -/* Includes ------------------------------------------------------------------*/ -#include "main.h" -#include "cmsis_os.h" - -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ -#include "../Application/INIT_Initialization.h" -/* USER CODE END Includes */ - -/* Private typedef -----------------------------------------------------------*/ -/* USER CODE BEGIN PTD */ - -/* USER CODE END PTD */ - -/* Private define ------------------------------------------------------------*/ -/* USER CODE BEGIN PD */ -/* USER CODE END PD */ - -/* Private macro -------------------------------------------------------------*/ -/* USER CODE BEGIN PM */ - -/* USER CODE END PM */ - -/* Private variables ---------------------------------------------------------*/ -ADC_HandleTypeDef hadc1; -DMA_HandleTypeDef hdma_adc1; - -CAN_HandleTypeDef hcan1; - -DAC_HandleTypeDef hdac1; - -I2C_HandleTypeDef hi2c1; - -IWDG_HandleTypeDef hiwdg; - -SPI_HandleTypeDef hspi1; -DMA_HandleTypeDef hdma_spi1_rx; -DMA_HandleTypeDef hdma_spi1_tx; - -/* Definitions for Default */ -osThreadId_t DefaultHandle; -const osThreadAttr_t Default_attributes = { - .name = "Default", - .stack_size = 128 * 4, - .priority = (osPriority_t) osPriorityNormal, -}; -/* USER CODE BEGIN PV */ - -/* USER CODE END PV */ - -/* Private function prototypes -----------------------------------------------*/ -void SystemClock_Config(void); -static void MX_GPIO_Init(void); -static void MX_DMA_Init(void); -static void MX_ADC1_Init(void); -static void MX_CAN1_Init(void); -static void MX_DAC1_Init(void); -static void MX_SPI1_Init(void); -static void MX_I2C1_Init(void); -static void MX_IWDG_Init(void); -void vDefaultTask(void *argument); - -/* USER CODE BEGIN PFP */ - -/* USER CODE END PFP */ - -/* Private user code ---------------------------------------------------------*/ -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -/** - * @brief The application entry point. - * @retval int - */ -int main(void) -{ - /* USER CODE BEGIN 1 */ - - /* USER CODE END 1 */ - - /* MCU Configuration--------------------------------------------------------*/ - - /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ - HAL_Init(); - - /* USER CODE BEGIN Init */ - - /* USER CODE END Init */ - - /* Configure the system clock */ - SystemClock_Config(); - - /* USER CODE BEGIN SysInit */ - - /* USER CODE END SysInit */ - - /* Initialize all configured peripherals */ - MX_GPIO_Init(); - MX_DMA_Init(); - MX_ADC1_Init(); - MX_CAN1_Init(); - MX_DAC1_Init(); - MX_SPI1_Init(); - MX_I2C1_Init(); - MX_IWDG_Init(); - /* USER CODE BEGIN 2 */ - - /* USER CODE END 2 */ - - /* Init scheduler */ - osKernelInitialize(); - - /* USER CODE BEGIN RTOS_MUTEX */ - /* add mutexes, ... */ - /* USER CODE END RTOS_MUTEX */ - - /* USER CODE BEGIN RTOS_SEMAPHORES */ - /* add semaphores, ... */ - /* USER CODE END RTOS_SEMAPHORES */ - - /* USER CODE BEGIN RTOS_TIMERS */ - /* start timers, add new ones, ... */ - /* USER CODE END RTOS_TIMERS */ - - /* USER CODE BEGIN RTOS_QUEUES */ - /* add queues, ... */ - /* USER CODE END RTOS_QUEUES */ - - /* Create the thread(s) */ - /* creation of Default */ - DefaultHandle = osThreadNew(vDefaultTask, NULL, &Default_attributes); - - /* USER CODE BEGIN RTOS_THREADS */ - /* add threads, ... */ - /* USER CODE END RTOS_THREADS */ - - /* USER CODE BEGIN RTOS_EVENTS */ - /* add events, ... */ - /* USER CODE END RTOS_EVENTS */ - - /* Start scheduler */ - osKernelStart(); - - /* We should never get here as control is now taken by the scheduler */ - /* Infinite loop */ - /* USER CODE BEGIN WHILE */ - while (1) - { - /* USER CODE END WHILE */ - - /* USER CODE BEGIN 3 */ - } - /* USER CODE END 3 */ -} - -/** - * @brief System Clock Configuration - * @retval None - */ -void SystemClock_Config(void) -{ - RCC_OscInitTypeDef RCC_OscInitStruct = {0}; - RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; - - /** Configure the main internal regulator output voltage - */ - if (HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1) != HAL_OK) - { - Error_Handler(); - } - /** Initializes the RCC Oscillators according to the specified parameters - * in the RCC_OscInitTypeDef structure. - */ - RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI|RCC_OSCILLATORTYPE_HSE; - RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS; - RCC_OscInitStruct.LSIState = RCC_LSI_ON; - RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; - RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; - RCC_OscInitStruct.PLL.PLLM = 4; - RCC_OscInitStruct.PLL.PLLN = 16; - RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV7; - RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2; - RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2; - if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) - { - Error_Handler(); - } - /** Initializes the CPU, AHB and APB buses clocks - */ - RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK - |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; - RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; - RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; - RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; - RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; - - if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK) - { - Error_Handler(); - } -} - -/** - * @brief ADC1 Initialization Function - * @param None - * @retval None - */ -static void MX_ADC1_Init(void) -{ - - /* USER CODE BEGIN ADC1_Init 0 */ - - /* USER CODE END ADC1_Init 0 */ - - ADC_ChannelConfTypeDef sConfig = {0}; - - /* USER CODE BEGIN ADC1_Init 1 */ - - /* USER CODE END ADC1_Init 1 */ - /** Common config - */ - hadc1.Instance = ADC1; - hadc1.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV1; - hadc1.Init.Resolution = ADC_RESOLUTION_12B; - hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT; - hadc1.Init.ScanConvMode = ADC_SCAN_ENABLE; - hadc1.Init.EOCSelection = ADC_EOC_SEQ_CONV; - hadc1.Init.LowPowerAutoWait = DISABLE; - hadc1.Init.ContinuousConvMode = ENABLE; - hadc1.Init.NbrOfConversion = 4; - hadc1.Init.DiscontinuousConvMode = DISABLE; - hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START; - hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; - hadc1.Init.DMAContinuousRequests = ENABLE; - hadc1.Init.Overrun = ADC_OVR_DATA_PRESERVED; - hadc1.Init.OversamplingMode = ENABLE; - hadc1.Init.Oversampling.Ratio = ADC_OVERSAMPLING_RATIO_256; - hadc1.Init.Oversampling.RightBitShift = ADC_RIGHTBITSHIFT_4; - hadc1.Init.Oversampling.TriggeredMode = ADC_TRIGGEREDMODE_SINGLE_TRIGGER; - hadc1.Init.Oversampling.OversamplingStopReset = ADC_REGOVERSAMPLING_CONTINUED_MODE; - if (HAL_ADC_Init(&hadc1) != HAL_OK) - { - Error_Handler(); - } - /** Configure Regular Channel - */ - sConfig.Channel = ADC_CHANNEL_6; - sConfig.Rank = ADC_REGULAR_RANK_1; - sConfig.SamplingTime = ADC_SAMPLETIME_640CYCLES_5; - sConfig.SingleDiff = ADC_SINGLE_ENDED; - sConfig.OffsetNumber = ADC_OFFSET_NONE; - sConfig.Offset = 0; - if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) - { - Error_Handler(); - } - /** Configure Regular Channel - */ - sConfig.Channel = ADC_CHANNEL_16; - sConfig.Rank = ADC_REGULAR_RANK_2; - if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) - { - Error_Handler(); - } - /** Configure Regular Channel - */ - sConfig.Channel = ADC_CHANNEL_7; - sConfig.Rank = ADC_REGULAR_RANK_3; - if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) - { - Error_Handler(); - } - /** Configure Regular Channel - */ - sConfig.Channel = ADC_CHANNEL_15; - sConfig.Rank = ADC_REGULAR_RANK_4; - if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) - { - Error_Handler(); - } - /* USER CODE BEGIN ADC1_Init 2 */ - - HAL_ADCEx_Calibration_Start( &hadc1, ADC_SINGLE_ENDED ); - - /* USER CODE END ADC1_Init 2 */ - -} - -/** - * @brief CAN1 Initialization Function - * @param None - * @retval None - */ -static void MX_CAN1_Init(void) -{ - - /* USER CODE BEGIN CAN1_Init 0 */ - - /* USER CODE END CAN1_Init 0 */ - - /* USER CODE BEGIN CAN1_Init 1 */ - - /* USER CODE END CAN1_Init 1 */ - hcan1.Instance = CAN1; - hcan1.Init.Prescaler = 128; - hcan1.Init.Mode = CAN_MODE_NORMAL; - hcan1.Init.SyncJumpWidth = CAN_SJW_1TQ; - hcan1.Init.TimeSeg1 = CAN_BS1_3TQ; - hcan1.Init.TimeSeg2 = CAN_BS2_1TQ; - hcan1.Init.TimeTriggeredMode = DISABLE; - hcan1.Init.AutoBusOff = DISABLE; - hcan1.Init.AutoWakeUp = DISABLE; - hcan1.Init.AutoRetransmission = ENABLE; - hcan1.Init.ReceiveFifoLocked = DISABLE; - hcan1.Init.TransmitFifoPriority = DISABLE; - if (HAL_CAN_Init(&hcan1) != HAL_OK) - { - Error_Handler(); - } - /* USER CODE BEGIN CAN1_Init 2 */ - - /* USER CODE END CAN1_Init 2 */ - -} - -/** - * @brief DAC1 Initialization Function - * @param None - * @retval None - */ -static void MX_DAC1_Init(void) -{ - - /* USER CODE BEGIN DAC1_Init 0 */ - - /* USER CODE END DAC1_Init 0 */ - - DAC_ChannelConfTypeDef sConfig = {0}; - - /* USER CODE BEGIN DAC1_Init 1 */ - - /* USER CODE END DAC1_Init 1 */ - /** DAC Initialization - */ - hdac1.Instance = DAC1; - if (HAL_DAC_Init(&hdac1) != HAL_OK) - { - Error_Handler(); - } - /** DAC channel OUT1 config - */ - sConfig.DAC_SampleAndHold = DAC_SAMPLEANDHOLD_DISABLE; - sConfig.DAC_Trigger = DAC_TRIGGER_NONE; - sConfig.DAC_OutputBuffer = DAC_OUTPUTBUFFER_ENABLE; - sConfig.DAC_ConnectOnChipPeripheral = DAC_CHIPCONNECT_DISABLE; - sConfig.DAC_UserTrimming = DAC_TRIMMING_FACTORY; - if (HAL_DAC_ConfigChannel(&hdac1, &sConfig, DAC_CHANNEL_1) != HAL_OK) - { - Error_Handler(); - } - /* USER CODE BEGIN DAC1_Init 2 */ - - if (HAL_DACEx_SelfCalibrate( &hdac1, &sConfig , DAC_CHANNEL_1) != HAL_OK) - { - Error_Handler(); - } - - /* USER CODE END DAC1_Init 2 */ - -} - -/** - * @brief I2C1 Initialization Function - * @param None - * @retval None - */ -static void MX_I2C1_Init(void) -{ - - /* USER CODE BEGIN I2C1_Init 0 */ - - /* USER CODE END I2C1_Init 0 */ - - /* USER CODE BEGIN I2C1_Init 1 */ - - /* USER CODE END I2C1_Init 1 */ - hi2c1.Instance = I2C1; - hi2c1.Init.Timing = 0x10909CEC; - hi2c1.Init.OwnAddress1 = 0; - hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT; - hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE; - hi2c1.Init.OwnAddress2 = 0; - hi2c1.Init.OwnAddress2Masks = I2C_OA2_NOMASK; - hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE; - hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE; - if (HAL_I2C_Init(&hi2c1) != HAL_OK) - { - Error_Handler(); - } - /** Configure Analogue filter - */ - if (HAL_I2CEx_ConfigAnalogFilter(&hi2c1, I2C_ANALOGFILTER_ENABLE) != HAL_OK) - { - Error_Handler(); - } - /** Configure Digital filter - */ - if (HAL_I2CEx_ConfigDigitalFilter(&hi2c1, 0) != HAL_OK) - { - Error_Handler(); - } - /* USER CODE BEGIN I2C1_Init 2 */ - - /* USER CODE END I2C1_Init 2 */ - -} - -/** - * @brief IWDG Initialization Function - * @param None - * @retval None - */ -static void MX_IWDG_Init(void) -{ - - /* USER CODE BEGIN IWDG_Init 0 */ - - /* USER CODE END IWDG_Init 0 */ - - /* USER CODE BEGIN IWDG_Init 1 */ - - /* USER CODE END IWDG_Init 1 */ - hiwdg.Instance = IWDG; - hiwdg.Init.Prescaler = IWDG_PRESCALER_256; - hiwdg.Init.Window = 4095; - hiwdg.Init.Reload = 150; - if (HAL_IWDG_Init(&hiwdg) != HAL_OK) - { - Error_Handler(); - } - /* USER CODE BEGIN IWDG_Init 2 */ - - /* USER CODE END IWDG_Init 2 */ - -} - -/** - * @brief SPI1 Initialization Function - * @param None - * @retval None - */ -static void MX_SPI1_Init(void) -{ - - /* USER CODE BEGIN SPI1_Init 0 */ - - /* USER CODE END SPI1_Init 0 */ - - /* USER CODE BEGIN SPI1_Init 1 */ - - /* USER CODE END SPI1_Init 1 */ - /* SPI1 parameter configuration*/ - hspi1.Instance = SPI1; - hspi1.Init.Mode = SPI_MODE_MASTER; - hspi1.Init.Direction = SPI_DIRECTION_2LINES; - hspi1.Init.DataSize = SPI_DATASIZE_8BIT; - hspi1.Init.CLKPolarity = SPI_POLARITY_LOW; - hspi1.Init.CLKPhase = SPI_PHASE_2EDGE; - hspi1.Init.NSS = SPI_NSS_SOFT; - hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_128; - hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB; - hspi1.Init.TIMode = SPI_TIMODE_DISABLE; - hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; - hspi1.Init.CRCPolynomial = 7; - hspi1.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE; - hspi1.Init.NSSPMode = SPI_NSS_PULSE_DISABLE; - if (HAL_SPI_Init(&hspi1) != HAL_OK) - { - Error_Handler(); - } - /* USER CODE BEGIN SPI1_Init 2 */ - - /* USER CODE END SPI1_Init 2 */ - -} - -/** - * Enable DMA controller clock - */ -static void MX_DMA_Init(void) -{ - - /* DMA controller clock enable */ - __HAL_RCC_DMA1_CLK_ENABLE(); - __HAL_RCC_DMA2_CLK_ENABLE(); - - /* DMA interrupt init */ - /* DMA1_Channel2_IRQn interrupt configuration */ - HAL_NVIC_SetPriority(DMA1_Channel2_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(DMA1_Channel2_IRQn); - /* DMA1_Channel3_IRQn interrupt configuration */ - HAL_NVIC_SetPriority(DMA1_Channel3_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(DMA1_Channel3_IRQn); - /* DMA2_Channel3_IRQn interrupt configuration */ - HAL_NVIC_SetPriority(DMA2_Channel3_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(DMA2_Channel3_IRQn); - -} - -/** - * @brief GPIO Initialization Function - * @param None - * @retval None - */ -static void MX_GPIO_Init(void) -{ - GPIO_InitTypeDef GPIO_InitStruct = {0}; - - /* GPIO Ports Clock Enable */ - __HAL_RCC_GPIOC_CLK_ENABLE(); - __HAL_RCC_GPIOA_CLK_ENABLE(); - __HAL_RCC_GPIOB_CLK_ENABLE(); - - /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_RESET); - - /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(EN_GPIO_Port, EN_Pin, GPIO_PIN_RESET); - - /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(GPIOB, CS1_Pin|CS2_Pin, GPIO_PIN_RESET); - - /*Configure GPIO pin : LED_Pin */ - GPIO_InitStruct.Pin = LED_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - HAL_GPIO_Init(LED_GPIO_Port, &GPIO_InitStruct); - - /*Configure GPIO pin : ADR3_Pin */ - GPIO_InitStruct.Pin = ADR3_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_INPUT; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(ADR3_GPIO_Port, &GPIO_InitStruct); - - /*Configure GPIO pin : EN_Pin */ - GPIO_InitStruct.Pin = EN_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - HAL_GPIO_Init(EN_GPIO_Port, &GPIO_InitStruct); - - /*Configure GPIO pin : ADR0_Pin */ - GPIO_InitStruct.Pin = ADR0_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_INPUT; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(ADR0_GPIO_Port, &GPIO_InitStruct); - - /*Configure GPIO pins : ADR1_Pin ADR2_Pin PG_Pin */ - GPIO_InitStruct.Pin = ADR1_Pin|ADR2_Pin|PG_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_INPUT; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - /*Configure GPIO pins : CS1_Pin CS2_Pin */ - GPIO_InitStruct.Pin = CS1_Pin|CS2_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - -} - -/* USER CODE BEGIN 4 */ - -/* USER CODE END 4 */ - -/* USER CODE BEGIN Header_vDefaultTask */ -/** - * @brief Function implementing the Default thread. - * @param argument: Not used - * @retval None - */ -/* USER CODE END Header_vDefaultTask */ -void vDefaultTask(void *argument) -{ - /* USER CODE BEGIN 5 */ - INIT_boCreateTask(); - osThreadSuspend( DefaultHandle ); - while(1); - /* USER CODE END 5 */ -} - -/** - * @brief This function is executed in case of error occurrence. - * @retval None - */ -void Error_Handler(void) -{ - /* USER CODE BEGIN Error_Handler_Debug */ - /* User can add his own implementation to report the HAL error return state */ - __disable_irq(); - while (1) - { - } - /* USER CODE END Error_Handler_Debug */ -} - -#ifdef USE_FULL_ASSERT -/** - * @brief Reports the name of the source file and the source line number - * where the assert_param error has occurred. - * @param file: pointer to the source file name - * @param line: assert_param error line source number - * @retval None - */ -void assert_failed(uint8_t *file, uint32_t line) -{ - /* USER CODE BEGIN 6 */ - /* User can add his own implementation to report the file name and line number, - ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ - /* USER CODE END 6 */ -} -#endif /* USE_FULL_ASSERT */ - +/* USER CODE BEGIN Header */ +//================================================================================================= +// +// Company: Paul Scherrer Institut +// 5232 Villigen PSI +// Switzerland +// +//------------------------------------------------------------------------------------------------- +// +// Project: Peltier Controller V2 +// Author: Noah Piqué (noah.pique@psi.ch) +// +//------------------------------------------------------------------------------------------------- +// +// Filename: main.c +// Date: Handled by Subversion (version control system) +// Revision: Handled by Subversion (version control system) +// History: Handled by Subversion (version control system) +// +//------------------------------------------------------------------------------------------------- +// +// Description: This source file contains all functions for starting the PeltierController +// +//================================================================================================= +/* USER CODE END Header */ +/* Includes ------------------------------------------------------------------*/ +#include "main.h" +#include "cmsis_os.h" + +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ +#include "../Application/INIT_Initialization.h" +/* USER CODE END Includes */ + +/* Private typedef -----------------------------------------------------------*/ +/* USER CODE BEGIN PTD */ + +/* USER CODE END PTD */ + +/* Private define ------------------------------------------------------------*/ +/* USER CODE BEGIN PD */ +/* USER CODE END PD */ + +/* Private macro -------------------------------------------------------------*/ +/* USER CODE BEGIN PM */ + +/* USER CODE END PM */ + +/* Private variables ---------------------------------------------------------*/ +ADC_HandleTypeDef hadc1; +DMA_HandleTypeDef hdma_adc1; + +CAN_HandleTypeDef hcan1; + +DAC_HandleTypeDef hdac1; + +I2C_HandleTypeDef hi2c1; + +IWDG_HandleTypeDef hiwdg; + +SPI_HandleTypeDef hspi1; +DMA_HandleTypeDef hdma_spi1_rx; +DMA_HandleTypeDef hdma_spi1_tx; + +/* Definitions for Default */ +osThreadId_t DefaultHandle; +const osThreadAttr_t Default_attributes = { + .name = "Default", + .stack_size = 128 * 4, + .priority = (osPriority_t) osPriorityNormal, +}; +/* USER CODE BEGIN PV */ + +/* USER CODE END PV */ + +/* Private function prototypes -----------------------------------------------*/ +void SystemClock_Config(void); +static void MX_GPIO_Init(void); +static void MX_DMA_Init(void); +static void MX_ADC1_Init(void); +static void MX_CAN1_Init(void); +static void MX_DAC1_Init(void); +static void MX_SPI1_Init(void); +static void MX_I2C1_Init(void); +static void MX_IWDG_Init(void); +void vDefaultTask(void *argument); + +/* USER CODE BEGIN PFP */ + +/* USER CODE END PFP */ + +/* Private user code ---------------------------------------------------------*/ +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +/** + * @brief The application entry point. + * @retval int + */ +int main(void) +{ + /* USER CODE BEGIN 1 */ + + /* USER CODE END 1 */ + + /* MCU Configuration--------------------------------------------------------*/ + + /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ + HAL_Init(); + + /* USER CODE BEGIN Init */ + + /* USER CODE END Init */ + + /* Configure the system clock */ + SystemClock_Config(); + + /* USER CODE BEGIN SysInit */ + + /* USER CODE END SysInit */ + + /* Initialize all configured peripherals */ + MX_GPIO_Init(); + MX_DMA_Init(); + MX_ADC1_Init(); + MX_CAN1_Init(); + MX_DAC1_Init(); + MX_SPI1_Init(); + MX_I2C1_Init(); + MX_IWDG_Init(); + /* USER CODE BEGIN 2 */ + + /* USER CODE END 2 */ + + /* Init scheduler */ + osKernelInitialize(); + + /* USER CODE BEGIN RTOS_MUTEX */ + /* add mutexes, ... */ + /* USER CODE END RTOS_MUTEX */ + + /* USER CODE BEGIN RTOS_SEMAPHORES */ + /* add semaphores, ... */ + /* USER CODE END RTOS_SEMAPHORES */ + + /* USER CODE BEGIN RTOS_TIMERS */ + /* start timers, add new ones, ... */ + /* USER CODE END RTOS_TIMERS */ + + /* USER CODE BEGIN RTOS_QUEUES */ + /* add queues, ... */ + /* USER CODE END RTOS_QUEUES */ + + /* Create the thread(s) */ + /* creation of Default */ + DefaultHandle = osThreadNew(vDefaultTask, NULL, &Default_attributes); + + /* USER CODE BEGIN RTOS_THREADS */ + /* add threads, ... */ + /* USER CODE END RTOS_THREADS */ + + /* USER CODE BEGIN RTOS_EVENTS */ + /* add events, ... */ + /* USER CODE END RTOS_EVENTS */ + + /* Start scheduler */ + osKernelStart(); + + /* We should never get here as control is now taken by the scheduler */ + /* Infinite loop */ + /* USER CODE BEGIN WHILE */ + while (1) + { + /* USER CODE END WHILE */ + + /* USER CODE BEGIN 3 */ + } + /* USER CODE END 3 */ +} + +/** + * @brief System Clock Configuration + * @retval None + */ +void SystemClock_Config(void) +{ + RCC_OscInitTypeDef RCC_OscInitStruct = {0}; + RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; + + /** Configure the main internal regulator output voltage + */ + if (HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1) != HAL_OK) + { + Error_Handler(); + } + /** Initializes the RCC Oscillators according to the specified parameters + * in the RCC_OscInitTypeDef structure. + */ + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI|RCC_OSCILLATORTYPE_HSE; + RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS; + RCC_OscInitStruct.LSIState = RCC_LSI_ON; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; + RCC_OscInitStruct.PLL.PLLM = 4; + RCC_OscInitStruct.PLL.PLLN = 16; + RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV7; + RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2; + RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2; + if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) + { + Error_Handler(); + } + /** Initializes the CPU, AHB and APB buses clocks + */ + RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK + |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; + + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK) + { + Error_Handler(); + } +} + +/** + * @brief ADC1 Initialization Function + * @param None + * @retval None + */ +static void MX_ADC1_Init(void) +{ + + /* USER CODE BEGIN ADC1_Init 0 */ + + /* USER CODE END ADC1_Init 0 */ + + ADC_ChannelConfTypeDef sConfig = {0}; + + /* USER CODE BEGIN ADC1_Init 1 */ + + /* USER CODE END ADC1_Init 1 */ + /** Common config + */ + hadc1.Instance = ADC1; + hadc1.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV1; + hadc1.Init.Resolution = ADC_RESOLUTION_12B; + hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT; + hadc1.Init.ScanConvMode = ADC_SCAN_ENABLE; + hadc1.Init.EOCSelection = ADC_EOC_SEQ_CONV; + hadc1.Init.LowPowerAutoWait = DISABLE; + hadc1.Init.ContinuousConvMode = ENABLE; + hadc1.Init.NbrOfConversion = 4; + hadc1.Init.DiscontinuousConvMode = DISABLE; + hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START; + hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; + hadc1.Init.DMAContinuousRequests = ENABLE; + hadc1.Init.Overrun = ADC_OVR_DATA_PRESERVED; + hadc1.Init.OversamplingMode = ENABLE; + hadc1.Init.Oversampling.Ratio = ADC_OVERSAMPLING_RATIO_256; + hadc1.Init.Oversampling.RightBitShift = ADC_RIGHTBITSHIFT_4; + hadc1.Init.Oversampling.TriggeredMode = ADC_TRIGGEREDMODE_SINGLE_TRIGGER; + hadc1.Init.Oversampling.OversamplingStopReset = ADC_REGOVERSAMPLING_CONTINUED_MODE; + if (HAL_ADC_Init(&hadc1) != HAL_OK) + { + Error_Handler(); + } + /** Configure Regular Channel + */ + sConfig.Channel = ADC_CHANNEL_6; + sConfig.Rank = ADC_REGULAR_RANK_1; + sConfig.SamplingTime = ADC_SAMPLETIME_640CYCLES_5; + sConfig.SingleDiff = ADC_SINGLE_ENDED; + sConfig.OffsetNumber = ADC_OFFSET_NONE; + sConfig.Offset = 0; + if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) + { + Error_Handler(); + } + /** Configure Regular Channel + */ + sConfig.Channel = ADC_CHANNEL_16; + sConfig.Rank = ADC_REGULAR_RANK_2; + if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) + { + Error_Handler(); + } + /** Configure Regular Channel + */ + sConfig.Channel = ADC_CHANNEL_7; + sConfig.Rank = ADC_REGULAR_RANK_3; + if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) + { + Error_Handler(); + } + /** Configure Regular Channel + */ + sConfig.Channel = ADC_CHANNEL_15; + sConfig.Rank = ADC_REGULAR_RANK_4; + if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN ADC1_Init 2 */ + + HAL_ADCEx_Calibration_Start( &hadc1, ADC_SINGLE_ENDED ); + + /* USER CODE END ADC1_Init 2 */ + +} + +/** + * @brief CAN1 Initialization Function + * @param None + * @retval None + */ +static void MX_CAN1_Init(void) +{ + + /* USER CODE BEGIN CAN1_Init 0 */ + + /* USER CODE END CAN1_Init 0 */ + + /* USER CODE BEGIN CAN1_Init 1 */ + + /* USER CODE END CAN1_Init 1 */ + hcan1.Instance = CAN1; + hcan1.Init.Prescaler = 32; + hcan1.Init.Mode = CAN_MODE_NORMAL; + hcan1.Init.SyncJumpWidth = CAN_SJW_1TQ; + hcan1.Init.TimeSeg1 = CAN_BS1_13TQ; + hcan1.Init.TimeSeg2 = CAN_BS2_6TQ; + hcan1.Init.TimeTriggeredMode = DISABLE; + hcan1.Init.AutoBusOff = DISABLE; + hcan1.Init.AutoWakeUp = DISABLE; + hcan1.Init.AutoRetransmission = ENABLE; + hcan1.Init.ReceiveFifoLocked = DISABLE; + hcan1.Init.TransmitFifoPriority = DISABLE; + if (HAL_CAN_Init(&hcan1) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN CAN1_Init 2 */ + + /* USER CODE END CAN1_Init 2 */ + +} + +/** + * @brief DAC1 Initialization Function + * @param None + * @retval None + */ +static void MX_DAC1_Init(void) +{ + + /* USER CODE BEGIN DAC1_Init 0 */ + + /* USER CODE END DAC1_Init 0 */ + + DAC_ChannelConfTypeDef sConfig = {0}; + + /* USER CODE BEGIN DAC1_Init 1 */ + + /* USER CODE END DAC1_Init 1 */ + /** DAC Initialization + */ + hdac1.Instance = DAC1; + if (HAL_DAC_Init(&hdac1) != HAL_OK) + { + Error_Handler(); + } + /** DAC channel OUT1 config + */ + sConfig.DAC_SampleAndHold = DAC_SAMPLEANDHOLD_DISABLE; + sConfig.DAC_Trigger = DAC_TRIGGER_NONE; + sConfig.DAC_OutputBuffer = DAC_OUTPUTBUFFER_ENABLE; + sConfig.DAC_ConnectOnChipPeripheral = DAC_CHIPCONNECT_DISABLE; + sConfig.DAC_UserTrimming = DAC_TRIMMING_FACTORY; + if (HAL_DAC_ConfigChannel(&hdac1, &sConfig, DAC_CHANNEL_1) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN DAC1_Init 2 */ + + if (HAL_DACEx_SelfCalibrate( &hdac1, &sConfig , DAC_CHANNEL_1) != HAL_OK) + { + Error_Handler(); + } + + /* USER CODE END DAC1_Init 2 */ + +} + +/** + * @brief I2C1 Initialization Function + * @param None + * @retval None + */ +static void MX_I2C1_Init(void) +{ + + /* USER CODE BEGIN I2C1_Init 0 */ + + /* USER CODE END I2C1_Init 0 */ + + /* USER CODE BEGIN I2C1_Init 1 */ + + /* USER CODE END I2C1_Init 1 */ + hi2c1.Instance = I2C1; + hi2c1.Init.Timing = 0x10909CEC; + hi2c1.Init.OwnAddress1 = 0; + hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT; + hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE; + hi2c1.Init.OwnAddress2 = 0; + hi2c1.Init.OwnAddress2Masks = I2C_OA2_NOMASK; + hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE; + hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE; + if (HAL_I2C_Init(&hi2c1) != HAL_OK) + { + Error_Handler(); + } + /** Configure Analogue filter + */ + if (HAL_I2CEx_ConfigAnalogFilter(&hi2c1, I2C_ANALOGFILTER_ENABLE) != HAL_OK) + { + Error_Handler(); + } + /** Configure Digital filter + */ + if (HAL_I2CEx_ConfigDigitalFilter(&hi2c1, 0) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN I2C1_Init 2 */ + + /* USER CODE END I2C1_Init 2 */ + +} + +/** + * @brief IWDG Initialization Function + * @param None + * @retval None + */ +static void MX_IWDG_Init(void) +{ + + /* USER CODE BEGIN IWDG_Init 0 */ + + /* USER CODE END IWDG_Init 0 */ + + /* USER CODE BEGIN IWDG_Init 1 */ + + /* USER CODE END IWDG_Init 1 */ + hiwdg.Instance = IWDG; + hiwdg.Init.Prescaler = IWDG_PRESCALER_256; + hiwdg.Init.Window = 4095; + hiwdg.Init.Reload = 150; + if (HAL_IWDG_Init(&hiwdg) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN IWDG_Init 2 */ + + /* USER CODE END IWDG_Init 2 */ + +} + +/** + * @brief SPI1 Initialization Function + * @param None + * @retval None + */ +static void MX_SPI1_Init(void) +{ + + /* USER CODE BEGIN SPI1_Init 0 */ + + /* USER CODE END SPI1_Init 0 */ + + /* USER CODE BEGIN SPI1_Init 1 */ + + /* USER CODE END SPI1_Init 1 */ + /* SPI1 parameter configuration*/ + hspi1.Instance = SPI1; + hspi1.Init.Mode = SPI_MODE_MASTER; + hspi1.Init.Direction = SPI_DIRECTION_2LINES; + hspi1.Init.DataSize = SPI_DATASIZE_8BIT; + hspi1.Init.CLKPolarity = SPI_POLARITY_LOW; + hspi1.Init.CLKPhase = SPI_PHASE_2EDGE; + hspi1.Init.NSS = SPI_NSS_SOFT; + hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_128; + hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB; + hspi1.Init.TIMode = SPI_TIMODE_DISABLE; + hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; + hspi1.Init.CRCPolynomial = 7; + hspi1.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE; + hspi1.Init.NSSPMode = SPI_NSS_PULSE_DISABLE; + if (HAL_SPI_Init(&hspi1) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN SPI1_Init 2 */ + + /* USER CODE END SPI1_Init 2 */ + +} + +/** + * Enable DMA controller clock + */ +static void MX_DMA_Init(void) +{ + + /* DMA controller clock enable */ + __HAL_RCC_DMA1_CLK_ENABLE(); + __HAL_RCC_DMA2_CLK_ENABLE(); + + /* DMA interrupt init */ + /* DMA1_Channel2_IRQn interrupt configuration */ + HAL_NVIC_SetPriority(DMA1_Channel2_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(DMA1_Channel2_IRQn); + /* DMA1_Channel3_IRQn interrupt configuration */ + HAL_NVIC_SetPriority(DMA1_Channel3_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(DMA1_Channel3_IRQn); + /* DMA2_Channel3_IRQn interrupt configuration */ + HAL_NVIC_SetPriority(DMA2_Channel3_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(DMA2_Channel3_IRQn); + +} + +/** + * @brief GPIO Initialization Function + * @param None + * @retval None + */ +static void MX_GPIO_Init(void) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + + /* GPIO Ports Clock Enable */ + __HAL_RCC_GPIOC_CLK_ENABLE(); + __HAL_RCC_GPIOA_CLK_ENABLE(); + __HAL_RCC_GPIOB_CLK_ENABLE(); + + /*Configure GPIO pin Output Level */ + HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_RESET); + + /*Configure GPIO pin Output Level */ + HAL_GPIO_WritePin(EN_GPIO_Port, EN_Pin, GPIO_PIN_RESET); + + /*Configure GPIO pin Output Level */ + HAL_GPIO_WritePin(GPIOB, CS1_Pin|CS2_Pin, GPIO_PIN_RESET); + + /*Configure GPIO pin : LED_Pin */ + GPIO_InitStruct.Pin = LED_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(LED_GPIO_Port, &GPIO_InitStruct); + + /*Configure GPIO pin : ADR3_Pin */ + GPIO_InitStruct.Pin = ADR3_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(ADR3_GPIO_Port, &GPIO_InitStruct); + + /*Configure GPIO pin : EN_Pin */ + GPIO_InitStruct.Pin = EN_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(EN_GPIO_Port, &GPIO_InitStruct); + + /*Configure GPIO pin : ADR0_Pin */ + GPIO_InitStruct.Pin = ADR0_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(ADR0_GPIO_Port, &GPIO_InitStruct); + + /*Configure GPIO pins : ADR1_Pin ADR2_Pin PG_Pin */ + GPIO_InitStruct.Pin = ADR1_Pin|ADR2_Pin|PG_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /*Configure GPIO pins : CS1_Pin CS2_Pin */ + GPIO_InitStruct.Pin = CS1_Pin|CS2_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + +} + +/* USER CODE BEGIN 4 */ + +/* USER CODE END 4 */ + +/* USER CODE BEGIN Header_vDefaultTask */ +/** + * @brief Function implementing the Default thread. + * @param argument: Not used + * @retval None + */ +/* USER CODE END Header_vDefaultTask */ +void vDefaultTask(void *argument) +{ + /* USER CODE BEGIN 5 */ + INIT_boCreateTask(); + osThreadSuspend( DefaultHandle ); + while(1); + /* USER CODE END 5 */ +} + +/** + * @brief This function is executed in case of error occurrence. + * @retval None + */ +void Error_Handler(void) +{ + /* USER CODE BEGIN Error_Handler_Debug */ + /* User can add his own implementation to report the HAL error return state */ + __disable_irq(); + while (1) + { + } + /* USER CODE END Error_Handler_Debug */ +} + +#ifdef USE_FULL_ASSERT +/** + * @brief Reports the name of the source file and the source line number + * where the assert_param error has occurred. + * @param file: pointer to the source file name + * @param line: assert_param error line source number + * @retval None + */ +void assert_failed(uint8_t *file, uint32_t line) +{ + /* USER CODE BEGIN 6 */ + /* User can add his own implementation to report the file name and line number, + ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ + /* USER CODE END 6 */ +} +#endif /* USE_FULL_ASSERT */ + diff --git a/Core/Src/stm32l4xx_hal_msp.c b/Core/Src/stm32l4xx_hal_msp.c index 18af7c2..739ee08 100644 --- a/Core/Src/stm32l4xx_hal_msp.c +++ b/Core/Src/stm32l4xx_hal_msp.c @@ -1,528 +1,528 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file stm32l4xx_hal_msp.c - * @brief This file provides code for the MSP Initialization - * and de-Initialization codes. - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2021 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** - */ -/* USER CODE END Header */ - -/* Includes ------------------------------------------------------------------*/ -#include "main.h" -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ -extern DMA_HandleTypeDef hdma_adc1; - -extern DMA_HandleTypeDef hdma_spi1_rx; - -extern DMA_HandleTypeDef hdma_spi1_tx; - -/* Private typedef -----------------------------------------------------------*/ -/* USER CODE BEGIN TD */ - -/* USER CODE END TD */ - -/* Private define ------------------------------------------------------------*/ -/* USER CODE BEGIN Define */ - -/* USER CODE END Define */ - -/* Private macro -------------------------------------------------------------*/ -/* USER CODE BEGIN Macro */ - -/* USER CODE END Macro */ - -/* Private variables ---------------------------------------------------------*/ -/* USER CODE BEGIN PV */ - -/* USER CODE END PV */ - -/* Private function prototypes -----------------------------------------------*/ -/* USER CODE BEGIN PFP */ - -/* USER CODE END PFP */ - -/* External functions --------------------------------------------------------*/ -/* USER CODE BEGIN ExternalFunctions */ - -/* USER CODE END ExternalFunctions */ - -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ -/** - * Initializes the Global MSP. - */ -void HAL_MspInit(void) -{ - /* USER CODE BEGIN MspInit 0 */ - - /* USER CODE END MspInit 0 */ - - __HAL_RCC_SYSCFG_CLK_ENABLE(); - __HAL_RCC_PWR_CLK_ENABLE(); - - /* System interrupt init*/ - /* PendSV_IRQn interrupt configuration */ - HAL_NVIC_SetPriority(PendSV_IRQn, 15, 0); - - /* USER CODE BEGIN MspInit 1 */ - - /* USER CODE END MspInit 1 */ -} - -/** -* @brief ADC MSP Initialization -* This function configures the hardware resources used in this example -* @param hadc: ADC handle pointer -* @retval None -*/ -void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) -{ - GPIO_InitTypeDef GPIO_InitStruct = {0}; - RCC_PeriphCLKInitTypeDef PeriphClkInit = {0}; - if(hadc->Instance==ADC1) - { - /* USER CODE BEGIN ADC1_MspInit 0 */ - - /* USER CODE END ADC1_MspInit 0 */ - /** Initializes the peripherals clock - */ - PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC; - PeriphClkInit.AdcClockSelection = RCC_ADCCLKSOURCE_SYSCLK; - if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) - { - Error_Handler(); - } - - /* Peripheral clock enable */ - __HAL_RCC_ADC_CLK_ENABLE(); - - __HAL_RCC_GPIOA_CLK_ENABLE(); - __HAL_RCC_GPIOB_CLK_ENABLE(); - /**ADC1 GPIO Configuration - PA1 ------> ADC1_IN6 - PA2 ------> ADC1_IN7 - PB0 ------> ADC1_IN15 - PB1 ------> ADC1_IN16 - */ - GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_2; - GPIO_InitStruct.Mode = GPIO_MODE_ANALOG_ADC_CONTROL; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1; - GPIO_InitStruct.Mode = GPIO_MODE_ANALOG_ADC_CONTROL; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - /* ADC1 DMA Init */ - /* ADC1 Init */ - hdma_adc1.Instance = DMA2_Channel3; - hdma_adc1.Init.Request = DMA_REQUEST_0; - hdma_adc1.Init.Direction = DMA_PERIPH_TO_MEMORY; - hdma_adc1.Init.PeriphInc = DMA_PINC_DISABLE; - hdma_adc1.Init.MemInc = DMA_MINC_ENABLE; - hdma_adc1.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD; - hdma_adc1.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD; - hdma_adc1.Init.Mode = DMA_CIRCULAR; - hdma_adc1.Init.Priority = DMA_PRIORITY_HIGH; - if (HAL_DMA_Init(&hdma_adc1) != HAL_OK) - { - Error_Handler(); - } - - __HAL_LINKDMA(hadc,DMA_Handle,hdma_adc1); - - /* ADC1 interrupt Init */ - HAL_NVIC_SetPriority(ADC1_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(ADC1_IRQn); - /* USER CODE BEGIN ADC1_MspInit 1 */ - - /* USER CODE END ADC1_MspInit 1 */ - } - -} - -/** -* @brief ADC MSP De-Initialization -* This function freeze the hardware resources used in this example -* @param hadc: ADC handle pointer -* @retval None -*/ -void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) -{ - if(hadc->Instance==ADC1) - { - /* USER CODE BEGIN ADC1_MspDeInit 0 */ - - /* USER CODE END ADC1_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_ADC_CLK_DISABLE(); - - /**ADC1 GPIO Configuration - PA1 ------> ADC1_IN6 - PA2 ------> ADC1_IN7 - PB0 ------> ADC1_IN15 - PB1 ------> ADC1_IN16 - */ - HAL_GPIO_DeInit(GPIOA, GPIO_PIN_1|GPIO_PIN_2); - - HAL_GPIO_DeInit(GPIOB, GPIO_PIN_0|GPIO_PIN_1); - - /* ADC1 DMA DeInit */ - HAL_DMA_DeInit(hadc->DMA_Handle); - - /* ADC1 interrupt DeInit */ - HAL_NVIC_DisableIRQ(ADC1_IRQn); - /* USER CODE BEGIN ADC1_MspDeInit 1 */ - - /* USER CODE END ADC1_MspDeInit 1 */ - } - -} - -/** -* @brief CAN MSP Initialization -* This function configures the hardware resources used in this example -* @param hcan: CAN handle pointer -* @retval None -*/ -void HAL_CAN_MspInit(CAN_HandleTypeDef* hcan) -{ - GPIO_InitTypeDef GPIO_InitStruct = {0}; - if(hcan->Instance==CAN1) - { - /* USER CODE BEGIN CAN1_MspInit 0 */ - - /* USER CODE END CAN1_MspInit 0 */ - /* Peripheral clock enable */ - __HAL_RCC_CAN1_CLK_ENABLE(); - - __HAL_RCC_GPIOA_CLK_ENABLE(); - /**CAN1 GPIO Configuration - PA11 ------> CAN1_RX - PA12 ------> CAN1_TX - */ - GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF9_CAN1; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /* CAN1 interrupt Init */ - HAL_NVIC_SetPriority(CAN1_TX_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(CAN1_TX_IRQn); - HAL_NVIC_SetPriority(CAN1_RX0_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(CAN1_RX0_IRQn); - HAL_NVIC_SetPriority(CAN1_RX1_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(CAN1_RX1_IRQn); - HAL_NVIC_SetPriority(CAN1_SCE_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(CAN1_SCE_IRQn); - /* USER CODE BEGIN CAN1_MspInit 1 */ - - /* USER CODE END CAN1_MspInit 1 */ - } - -} - -/** -* @brief CAN MSP De-Initialization -* This function freeze the hardware resources used in this example -* @param hcan: CAN handle pointer -* @retval None -*/ -void HAL_CAN_MspDeInit(CAN_HandleTypeDef* hcan) -{ - if(hcan->Instance==CAN1) - { - /* USER CODE BEGIN CAN1_MspDeInit 0 */ - - /* USER CODE END CAN1_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_CAN1_CLK_DISABLE(); - - /**CAN1 GPIO Configuration - PA11 ------> CAN1_RX - PA12 ------> CAN1_TX - */ - HAL_GPIO_DeInit(GPIOA, GPIO_PIN_11|GPIO_PIN_12); - - /* CAN1 interrupt DeInit */ - HAL_NVIC_DisableIRQ(CAN1_TX_IRQn); - HAL_NVIC_DisableIRQ(CAN1_RX0_IRQn); - HAL_NVIC_DisableIRQ(CAN1_RX1_IRQn); - HAL_NVIC_DisableIRQ(CAN1_SCE_IRQn); - /* USER CODE BEGIN CAN1_MspDeInit 1 */ - - /* USER CODE END CAN1_MspDeInit 1 */ - } - -} - -/** -* @brief DAC MSP Initialization -* This function configures the hardware resources used in this example -* @param hdac: DAC handle pointer -* @retval None -*/ -void HAL_DAC_MspInit(DAC_HandleTypeDef* hdac) -{ - GPIO_InitTypeDef GPIO_InitStruct = {0}; - if(hdac->Instance==DAC1) - { - /* USER CODE BEGIN DAC1_MspInit 0 */ - - /* USER CODE END DAC1_MspInit 0 */ - /* Peripheral clock enable */ - __HAL_RCC_DAC1_CLK_ENABLE(); - - __HAL_RCC_GPIOA_CLK_ENABLE(); - /**DAC1 GPIO Configuration - PA4 ------> DAC1_OUT1 - */ - GPIO_InitStruct.Pin = GPIO_PIN_4; - GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /* USER CODE BEGIN DAC1_MspInit 1 */ - - /* USER CODE END DAC1_MspInit 1 */ - } - -} - -/** -* @brief DAC MSP De-Initialization -* This function freeze the hardware resources used in this example -* @param hdac: DAC handle pointer -* @retval None -*/ -void HAL_DAC_MspDeInit(DAC_HandleTypeDef* hdac) -{ - if(hdac->Instance==DAC1) - { - /* USER CODE BEGIN DAC1_MspDeInit 0 */ - - /* USER CODE END DAC1_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_DAC1_CLK_DISABLE(); - - /**DAC1 GPIO Configuration - PA4 ------> DAC1_OUT1 - */ - HAL_GPIO_DeInit(GPIOA, GPIO_PIN_4); - - /* USER CODE BEGIN DAC1_MspDeInit 1 */ - - /* USER CODE END DAC1_MspDeInit 1 */ - } - -} - -/** -* @brief I2C MSP Initialization -* This function configures the hardware resources used in this example -* @param hi2c: I2C handle pointer -* @retval None -*/ -void HAL_I2C_MspInit(I2C_HandleTypeDef* hi2c) -{ - GPIO_InitTypeDef GPIO_InitStruct = {0}; - RCC_PeriphCLKInitTypeDef PeriphClkInit = {0}; - if(hi2c->Instance==I2C1) - { - /* USER CODE BEGIN I2C1_MspInit 0 */ - - /* USER CODE END I2C1_MspInit 0 */ - /** Initializes the peripherals clock - */ - PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_I2C1; - PeriphClkInit.I2c1ClockSelection = RCC_I2C1CLKSOURCE_PCLK1; - if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) - { - Error_Handler(); - } - - __HAL_RCC_GPIOA_CLK_ENABLE(); - /**I2C1 GPIO Configuration - PA9 ------> I2C1_SCL - PA10 ------> I2C1_SDA - */ - GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_10; - GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF4_I2C1; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /* Peripheral clock enable */ - __HAL_RCC_I2C1_CLK_ENABLE(); - /* USER CODE BEGIN I2C1_MspInit 1 */ - - /* USER CODE END I2C1_MspInit 1 */ - } - -} - -/** -* @brief I2C MSP De-Initialization -* This function freeze the hardware resources used in this example -* @param hi2c: I2C handle pointer -* @retval None -*/ -void HAL_I2C_MspDeInit(I2C_HandleTypeDef* hi2c) -{ - if(hi2c->Instance==I2C1) - { - /* USER CODE BEGIN I2C1_MspDeInit 0 */ - - /* USER CODE END I2C1_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_I2C1_CLK_DISABLE(); - - /**I2C1 GPIO Configuration - PA9 ------> I2C1_SCL - PA10 ------> I2C1_SDA - */ - HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9); - - HAL_GPIO_DeInit(GPIOA, GPIO_PIN_10); - - /* USER CODE BEGIN I2C1_MspDeInit 1 */ - - /* USER CODE END I2C1_MspDeInit 1 */ - } - -} - -/** -* @brief SPI MSP Initialization -* This function configures the hardware resources used in this example -* @param hspi: SPI handle pointer -* @retval None -*/ -void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) -{ - GPIO_InitTypeDef GPIO_InitStruct = {0}; - if(hspi->Instance==SPI1) - { - /* USER CODE BEGIN SPI1_MspInit 0 */ - - /* USER CODE END SPI1_MspInit 0 */ - /* Peripheral clock enable */ - __HAL_RCC_SPI1_CLK_ENABLE(); - - __HAL_RCC_GPIOA_CLK_ENABLE(); - /**SPI1 GPIO Configuration - PA5 ------> SPI1_SCK - PA6 ------> SPI1_MISO - PA7 ------> SPI1_MOSI - */ - GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF5_SPI1; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /* SPI1 DMA Init */ - /* SPI1_RX Init */ - hdma_spi1_rx.Instance = DMA1_Channel2; - hdma_spi1_rx.Init.Request = DMA_REQUEST_1; - hdma_spi1_rx.Init.Direction = DMA_PERIPH_TO_MEMORY; - hdma_spi1_rx.Init.PeriphInc = DMA_PINC_DISABLE; - hdma_spi1_rx.Init.MemInc = DMA_MINC_ENABLE; - hdma_spi1_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; - hdma_spi1_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; - hdma_spi1_rx.Init.Mode = DMA_NORMAL; - hdma_spi1_rx.Init.Priority = DMA_PRIORITY_LOW; - if (HAL_DMA_Init(&hdma_spi1_rx) != HAL_OK) - { - Error_Handler(); - } - - __HAL_LINKDMA(hspi,hdmarx,hdma_spi1_rx); - - /* SPI1_TX Init */ - hdma_spi1_tx.Instance = DMA1_Channel3; - hdma_spi1_tx.Init.Request = DMA_REQUEST_1; - hdma_spi1_tx.Init.Direction = DMA_MEMORY_TO_PERIPH; - hdma_spi1_tx.Init.PeriphInc = DMA_PINC_DISABLE; - hdma_spi1_tx.Init.MemInc = DMA_MINC_ENABLE; - hdma_spi1_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; - hdma_spi1_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; - hdma_spi1_tx.Init.Mode = DMA_NORMAL; - hdma_spi1_tx.Init.Priority = DMA_PRIORITY_LOW; - if (HAL_DMA_Init(&hdma_spi1_tx) != HAL_OK) - { - Error_Handler(); - } - - __HAL_LINKDMA(hspi,hdmatx,hdma_spi1_tx); - - /* SPI1 interrupt Init */ - HAL_NVIC_SetPriority(SPI1_IRQn, 5, 0); - HAL_NVIC_EnableIRQ(SPI1_IRQn); - /* USER CODE BEGIN SPI1_MspInit 1 */ - - /* USER CODE END SPI1_MspInit 1 */ - } - -} - -/** -* @brief SPI MSP De-Initialization -* This function freeze the hardware resources used in this example -* @param hspi: SPI handle pointer -* @retval None -*/ -void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) -{ - if(hspi->Instance==SPI1) - { - /* USER CODE BEGIN SPI1_MspDeInit 0 */ - - /* USER CODE END SPI1_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_SPI1_CLK_DISABLE(); - - /**SPI1 GPIO Configuration - PA5 ------> SPI1_SCK - PA6 ------> SPI1_MISO - PA7 ------> SPI1_MOSI - */ - HAL_GPIO_DeInit(GPIOA, GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7); - - /* SPI1 DMA DeInit */ - HAL_DMA_DeInit(hspi->hdmarx); - HAL_DMA_DeInit(hspi->hdmatx); - - /* SPI1 interrupt DeInit */ - HAL_NVIC_DisableIRQ(SPI1_IRQn); - /* USER CODE BEGIN SPI1_MspDeInit 1 */ - - /* USER CODE END SPI1_MspDeInit 1 */ - } - -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ - +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file stm32l4xx_hal_msp.c + * @brief This file provides code for the MSP Initialization + * and de-Initialization codes. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "main.h" +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ +extern DMA_HandleTypeDef hdma_adc1; + +extern DMA_HandleTypeDef hdma_spi1_rx; + +extern DMA_HandleTypeDef hdma_spi1_tx; + +/* Private typedef -----------------------------------------------------------*/ +/* USER CODE BEGIN TD */ + +/* USER CODE END TD */ + +/* Private define ------------------------------------------------------------*/ +/* USER CODE BEGIN Define */ + +/* USER CODE END Define */ + +/* Private macro -------------------------------------------------------------*/ +/* USER CODE BEGIN Macro */ + +/* USER CODE END Macro */ + +/* Private variables ---------------------------------------------------------*/ +/* USER CODE BEGIN PV */ + +/* USER CODE END PV */ + +/* Private function prototypes -----------------------------------------------*/ +/* USER CODE BEGIN PFP */ + +/* USER CODE END PFP */ + +/* External functions --------------------------------------------------------*/ +/* USER CODE BEGIN ExternalFunctions */ + +/* USER CODE END ExternalFunctions */ + +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ +/** + * Initializes the Global MSP. + */ +void HAL_MspInit(void) +{ + /* USER CODE BEGIN MspInit 0 */ + + /* USER CODE END MspInit 0 */ + + __HAL_RCC_SYSCFG_CLK_ENABLE(); + __HAL_RCC_PWR_CLK_ENABLE(); + + /* System interrupt init*/ + /* PendSV_IRQn interrupt configuration */ + HAL_NVIC_SetPriority(PendSV_IRQn, 15, 0); + + /* USER CODE BEGIN MspInit 1 */ + + /* USER CODE END MspInit 1 */ +} + +/** +* @brief ADC MSP Initialization +* This function configures the hardware resources used in this example +* @param hadc: ADC handle pointer +* @retval None +*/ +void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + RCC_PeriphCLKInitTypeDef PeriphClkInit = {0}; + if(hadc->Instance==ADC1) + { + /* USER CODE BEGIN ADC1_MspInit 0 */ + + /* USER CODE END ADC1_MspInit 0 */ + /** Initializes the peripherals clock + */ + PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC; + PeriphClkInit.AdcClockSelection = RCC_ADCCLKSOURCE_SYSCLK; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) + { + Error_Handler(); + } + + /* Peripheral clock enable */ + __HAL_RCC_ADC_CLK_ENABLE(); + + __HAL_RCC_GPIOA_CLK_ENABLE(); + __HAL_RCC_GPIOB_CLK_ENABLE(); + /**ADC1 GPIO Configuration + PA1 ------> ADC1_IN6 + PA2 ------> ADC1_IN7 + PB0 ------> ADC1_IN15 + PB1 ------> ADC1_IN16 + */ + GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_2; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG_ADC_CONTROL; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG_ADC_CONTROL; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /* ADC1 DMA Init */ + /* ADC1 Init */ + hdma_adc1.Instance = DMA2_Channel3; + hdma_adc1.Init.Request = DMA_REQUEST_0; + hdma_adc1.Init.Direction = DMA_PERIPH_TO_MEMORY; + hdma_adc1.Init.PeriphInc = DMA_PINC_DISABLE; + hdma_adc1.Init.MemInc = DMA_MINC_ENABLE; + hdma_adc1.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD; + hdma_adc1.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD; + hdma_adc1.Init.Mode = DMA_CIRCULAR; + hdma_adc1.Init.Priority = DMA_PRIORITY_HIGH; + if (HAL_DMA_Init(&hdma_adc1) != HAL_OK) + { + Error_Handler(); + } + + __HAL_LINKDMA(hadc,DMA_Handle,hdma_adc1); + + /* ADC1 interrupt Init */ + HAL_NVIC_SetPriority(ADC1_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(ADC1_IRQn); + /* USER CODE BEGIN ADC1_MspInit 1 */ + + /* USER CODE END ADC1_MspInit 1 */ + } + +} + +/** +* @brief ADC MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param hadc: ADC handle pointer +* @retval None +*/ +void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) +{ + if(hadc->Instance==ADC1) + { + /* USER CODE BEGIN ADC1_MspDeInit 0 */ + + /* USER CODE END ADC1_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_ADC_CLK_DISABLE(); + + /**ADC1 GPIO Configuration + PA1 ------> ADC1_IN6 + PA2 ------> ADC1_IN7 + PB0 ------> ADC1_IN15 + PB1 ------> ADC1_IN16 + */ + HAL_GPIO_DeInit(GPIOA, GPIO_PIN_1|GPIO_PIN_2); + + HAL_GPIO_DeInit(GPIOB, GPIO_PIN_0|GPIO_PIN_1); + + /* ADC1 DMA DeInit */ + HAL_DMA_DeInit(hadc->DMA_Handle); + + /* ADC1 interrupt DeInit */ + HAL_NVIC_DisableIRQ(ADC1_IRQn); + /* USER CODE BEGIN ADC1_MspDeInit 1 */ + + /* USER CODE END ADC1_MspDeInit 1 */ + } + +} + +/** +* @brief CAN MSP Initialization +* This function configures the hardware resources used in this example +* @param hcan: CAN handle pointer +* @retval None +*/ +void HAL_CAN_MspInit(CAN_HandleTypeDef* hcan) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + if(hcan->Instance==CAN1) + { + /* USER CODE BEGIN CAN1_MspInit 0 */ + + /* USER CODE END CAN1_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_CAN1_CLK_ENABLE(); + + __HAL_RCC_GPIOA_CLK_ENABLE(); + /**CAN1 GPIO Configuration + PA11 ------> CAN1_RX + PA12 ------> CAN1_TX + */ + GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF9_CAN1; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /* CAN1 interrupt Init */ + HAL_NVIC_SetPriority(CAN1_TX_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(CAN1_TX_IRQn); + HAL_NVIC_SetPriority(CAN1_RX0_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(CAN1_RX0_IRQn); + HAL_NVIC_SetPriority(CAN1_RX1_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(CAN1_RX1_IRQn); + HAL_NVIC_SetPriority(CAN1_SCE_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(CAN1_SCE_IRQn); + /* USER CODE BEGIN CAN1_MspInit 1 */ + + /* USER CODE END CAN1_MspInit 1 */ + } + +} + +/** +* @brief CAN MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param hcan: CAN handle pointer +* @retval None +*/ +void HAL_CAN_MspDeInit(CAN_HandleTypeDef* hcan) +{ + if(hcan->Instance==CAN1) + { + /* USER CODE BEGIN CAN1_MspDeInit 0 */ + + /* USER CODE END CAN1_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_CAN1_CLK_DISABLE(); + + /**CAN1 GPIO Configuration + PA11 ------> CAN1_RX + PA12 ------> CAN1_TX + */ + HAL_GPIO_DeInit(GPIOA, GPIO_PIN_11|GPIO_PIN_12); + + /* CAN1 interrupt DeInit */ + HAL_NVIC_DisableIRQ(CAN1_TX_IRQn); + HAL_NVIC_DisableIRQ(CAN1_RX0_IRQn); + HAL_NVIC_DisableIRQ(CAN1_RX1_IRQn); + HAL_NVIC_DisableIRQ(CAN1_SCE_IRQn); + /* USER CODE BEGIN CAN1_MspDeInit 1 */ + + /* USER CODE END CAN1_MspDeInit 1 */ + } + +} + +/** +* @brief DAC MSP Initialization +* This function configures the hardware resources used in this example +* @param hdac: DAC handle pointer +* @retval None +*/ +void HAL_DAC_MspInit(DAC_HandleTypeDef* hdac) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + if(hdac->Instance==DAC1) + { + /* USER CODE BEGIN DAC1_MspInit 0 */ + + /* USER CODE END DAC1_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_DAC1_CLK_ENABLE(); + + __HAL_RCC_GPIOA_CLK_ENABLE(); + /**DAC1 GPIO Configuration + PA4 ------> DAC1_OUT1 + */ + GPIO_InitStruct.Pin = GPIO_PIN_4; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /* USER CODE BEGIN DAC1_MspInit 1 */ + + /* USER CODE END DAC1_MspInit 1 */ + } + +} + +/** +* @brief DAC MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param hdac: DAC handle pointer +* @retval None +*/ +void HAL_DAC_MspDeInit(DAC_HandleTypeDef* hdac) +{ + if(hdac->Instance==DAC1) + { + /* USER CODE BEGIN DAC1_MspDeInit 0 */ + + /* USER CODE END DAC1_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_DAC1_CLK_DISABLE(); + + /**DAC1 GPIO Configuration + PA4 ------> DAC1_OUT1 + */ + HAL_GPIO_DeInit(GPIOA, GPIO_PIN_4); + + /* USER CODE BEGIN DAC1_MspDeInit 1 */ + + /* USER CODE END DAC1_MspDeInit 1 */ + } + +} + +/** +* @brief I2C MSP Initialization +* This function configures the hardware resources used in this example +* @param hi2c: I2C handle pointer +* @retval None +*/ +void HAL_I2C_MspInit(I2C_HandleTypeDef* hi2c) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + RCC_PeriphCLKInitTypeDef PeriphClkInit = {0}; + if(hi2c->Instance==I2C1) + { + /* USER CODE BEGIN I2C1_MspInit 0 */ + + /* USER CODE END I2C1_MspInit 0 */ + /** Initializes the peripherals clock + */ + PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_I2C1; + PeriphClkInit.I2c1ClockSelection = RCC_I2C1CLKSOURCE_PCLK1; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) + { + Error_Handler(); + } + + __HAL_RCC_GPIOA_CLK_ENABLE(); + /**I2C1 GPIO Configuration + PA9 ------> I2C1_SCL + PA10 ------> I2C1_SDA + */ + GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_10; + GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF4_I2C1; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /* Peripheral clock enable */ + __HAL_RCC_I2C1_CLK_ENABLE(); + /* USER CODE BEGIN I2C1_MspInit 1 */ + + /* USER CODE END I2C1_MspInit 1 */ + } + +} + +/** +* @brief I2C MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param hi2c: I2C handle pointer +* @retval None +*/ +void HAL_I2C_MspDeInit(I2C_HandleTypeDef* hi2c) +{ + if(hi2c->Instance==I2C1) + { + /* USER CODE BEGIN I2C1_MspDeInit 0 */ + + /* USER CODE END I2C1_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_I2C1_CLK_DISABLE(); + + /**I2C1 GPIO Configuration + PA9 ------> I2C1_SCL + PA10 ------> I2C1_SDA + */ + HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9); + + HAL_GPIO_DeInit(GPIOA, GPIO_PIN_10); + + /* USER CODE BEGIN I2C1_MspDeInit 1 */ + + /* USER CODE END I2C1_MspDeInit 1 */ + } + +} + +/** +* @brief SPI MSP Initialization +* This function configures the hardware resources used in this example +* @param hspi: SPI handle pointer +* @retval None +*/ +void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + if(hspi->Instance==SPI1) + { + /* USER CODE BEGIN SPI1_MspInit 0 */ + + /* USER CODE END SPI1_MspInit 0 */ + /* Peripheral clock enable */ + __HAL_RCC_SPI1_CLK_ENABLE(); + + __HAL_RCC_GPIOA_CLK_ENABLE(); + /**SPI1 GPIO Configuration + PA5 ------> SPI1_SCK + PA6 ------> SPI1_MISO + PA7 ------> SPI1_MOSI + */ + GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF5_SPI1; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /* SPI1 DMA Init */ + /* SPI1_RX Init */ + hdma_spi1_rx.Instance = DMA1_Channel2; + hdma_spi1_rx.Init.Request = DMA_REQUEST_1; + hdma_spi1_rx.Init.Direction = DMA_PERIPH_TO_MEMORY; + hdma_spi1_rx.Init.PeriphInc = DMA_PINC_DISABLE; + hdma_spi1_rx.Init.MemInc = DMA_MINC_ENABLE; + hdma_spi1_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; + hdma_spi1_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; + hdma_spi1_rx.Init.Mode = DMA_NORMAL; + hdma_spi1_rx.Init.Priority = DMA_PRIORITY_LOW; + if (HAL_DMA_Init(&hdma_spi1_rx) != HAL_OK) + { + Error_Handler(); + } + + __HAL_LINKDMA(hspi,hdmarx,hdma_spi1_rx); + + /* SPI1_TX Init */ + hdma_spi1_tx.Instance = DMA1_Channel3; + hdma_spi1_tx.Init.Request = DMA_REQUEST_1; + hdma_spi1_tx.Init.Direction = DMA_MEMORY_TO_PERIPH; + hdma_spi1_tx.Init.PeriphInc = DMA_PINC_DISABLE; + hdma_spi1_tx.Init.MemInc = DMA_MINC_ENABLE; + hdma_spi1_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; + hdma_spi1_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; + hdma_spi1_tx.Init.Mode = DMA_NORMAL; + hdma_spi1_tx.Init.Priority = DMA_PRIORITY_LOW; + if (HAL_DMA_Init(&hdma_spi1_tx) != HAL_OK) + { + Error_Handler(); + } + + __HAL_LINKDMA(hspi,hdmatx,hdma_spi1_tx); + + /* SPI1 interrupt Init */ + HAL_NVIC_SetPriority(SPI1_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(SPI1_IRQn); + /* USER CODE BEGIN SPI1_MspInit 1 */ + + /* USER CODE END SPI1_MspInit 1 */ + } + +} + +/** +* @brief SPI MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param hspi: SPI handle pointer +* @retval None +*/ +void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) +{ + if(hspi->Instance==SPI1) + { + /* USER CODE BEGIN SPI1_MspDeInit 0 */ + + /* USER CODE END SPI1_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_SPI1_CLK_DISABLE(); + + /**SPI1 GPIO Configuration + PA5 ------> SPI1_SCK + PA6 ------> SPI1_MISO + PA7 ------> SPI1_MOSI + */ + HAL_GPIO_DeInit(GPIOA, GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7); + + /* SPI1 DMA DeInit */ + HAL_DMA_DeInit(hspi->hdmarx); + HAL_DMA_DeInit(hspi->hdmatx); + + /* SPI1 interrupt DeInit */ + HAL_NVIC_DisableIRQ(SPI1_IRQn); + /* USER CODE BEGIN SPI1_MspDeInit 1 */ + + /* USER CODE END SPI1_MspDeInit 1 */ + } + +} + +/* USER CODE BEGIN 1 */ + +/* USER CODE END 1 */ + diff --git a/Core/Src/stm32l4xx_it.c b/Core/Src/stm32l4xx_it.c index 3db098c..b58941a 100644 --- a/Core/Src/stm32l4xx_it.c +++ b/Core/Src/stm32l4xx_it.c @@ -1,320 +1,320 @@ -/* USER CODE BEGIN Header */ -/** - ****************************************************************************** - * @file stm32l4xx_it.c - * @brief Interrupt Service Routines. - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2021 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** - */ -/* USER CODE END Header */ - -/* Includes ------------------------------------------------------------------*/ -#include "main.h" -#include "stm32l4xx_it.h" -#include "FreeRTOS.h" -#include "task.h" -/* Private includes ----------------------------------------------------------*/ -/* USER CODE BEGIN Includes */ -/* USER CODE END Includes */ - -/* Private typedef -----------------------------------------------------------*/ -/* USER CODE BEGIN TD */ - -/* USER CODE END TD */ - -/* Private define ------------------------------------------------------------*/ -/* USER CODE BEGIN PD */ - -/* USER CODE END PD */ - -/* Private macro -------------------------------------------------------------*/ -/* USER CODE BEGIN PM */ - -/* USER CODE END PM */ - -/* Private variables ---------------------------------------------------------*/ -/* USER CODE BEGIN PV */ - -/* USER CODE END PV */ - -/* Private function prototypes -----------------------------------------------*/ -/* USER CODE BEGIN PFP */ - -/* USER CODE END PFP */ - -/* Private user code ---------------------------------------------------------*/ -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -/* External variables --------------------------------------------------------*/ -extern DMA_HandleTypeDef hdma_adc1; -extern ADC_HandleTypeDef hadc1; -extern CAN_HandleTypeDef hcan1; -extern DMA_HandleTypeDef hdma_spi1_rx; -extern DMA_HandleTypeDef hdma_spi1_tx; -extern SPI_HandleTypeDef hspi1; -/* USER CODE BEGIN EV */ - -/* USER CODE END EV */ - -/******************************************************************************/ -/* Cortex-M4 Processor Interruption and Exception Handlers */ -/******************************************************************************/ -/** - * @brief This function handles Non maskable interrupt. - */ -void NMI_Handler(void) -{ - /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ - - /* USER CODE END NonMaskableInt_IRQn 0 */ - /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ - while (1) - { - } - /* USER CODE END NonMaskableInt_IRQn 1 */ -} - -/** - * @brief This function handles Hard fault interrupt. - */ -void HardFault_Handler(void) -{ - /* USER CODE BEGIN HardFault_IRQn 0 */ - - /* USER CODE END HardFault_IRQn 0 */ - while (1) - { - /* USER CODE BEGIN W1_HardFault_IRQn 0 */ - /* USER CODE END W1_HardFault_IRQn 0 */ - } -} - -/** - * @brief This function handles Memory management fault. - */ -void MemManage_Handler(void) -{ - /* USER CODE BEGIN MemoryManagement_IRQn 0 */ - - /* USER CODE END MemoryManagement_IRQn 0 */ - while (1) - { - /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */ - /* USER CODE END W1_MemoryManagement_IRQn 0 */ - } -} - -/** - * @brief This function handles Prefetch fault, memory access fault. - */ -void BusFault_Handler(void) -{ - /* USER CODE BEGIN BusFault_IRQn 0 */ - - /* USER CODE END BusFault_IRQn 0 */ - while (1) - { - /* USER CODE BEGIN W1_BusFault_IRQn 0 */ - /* USER CODE END W1_BusFault_IRQn 0 */ - } -} - -/** - * @brief This function handles Undefined instruction or illegal state. - */ -void UsageFault_Handler(void) -{ - /* USER CODE BEGIN UsageFault_IRQn 0 */ - - /* USER CODE END UsageFault_IRQn 0 */ - while (1) - { - /* USER CODE BEGIN W1_UsageFault_IRQn 0 */ - /* USER CODE END W1_UsageFault_IRQn 0 */ - } -} - -/** - * @brief This function handles Debug monitor. - */ -void DebugMon_Handler(void) -{ - /* USER CODE BEGIN DebugMonitor_IRQn 0 */ - - /* USER CODE END DebugMonitor_IRQn 0 */ - /* USER CODE BEGIN DebugMonitor_IRQn 1 */ - - /* USER CODE END DebugMonitor_IRQn 1 */ -} - -/** - * @brief This function handles System tick timer. - */ -void SysTick_Handler(void) -{ - /* USER CODE BEGIN SysTick_IRQn 0 */ - - /* USER CODE END SysTick_IRQn 0 */ - HAL_IncTick(); -#if (INCLUDE_xTaskGetSchedulerState == 1 ) - if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED) - { -#endif /* INCLUDE_xTaskGetSchedulerState */ - xPortSysTickHandler(); -#if (INCLUDE_xTaskGetSchedulerState == 1 ) - } -#endif /* INCLUDE_xTaskGetSchedulerState */ - /* USER CODE BEGIN SysTick_IRQn 1 */ - - /* USER CODE END SysTick_IRQn 1 */ -} - -/******************************************************************************/ -/* STM32L4xx Peripheral Interrupt Handlers */ -/* Add here the Interrupt Handlers for the used peripherals. */ -/* For the available peripheral interrupt handler names, */ -/* please refer to the startup file (startup_stm32l4xx.s). */ -/******************************************************************************/ - -/** - * @brief This function handles DMA1 channel2 global interrupt. - */ -void DMA1_Channel2_IRQHandler(void) -{ - /* USER CODE BEGIN DMA1_Channel2_IRQn 0 */ - - /* USER CODE END DMA1_Channel2_IRQn 0 */ - HAL_DMA_IRQHandler(&hdma_spi1_rx); - /* USER CODE BEGIN DMA1_Channel2_IRQn 1 */ - - /* USER CODE END DMA1_Channel2_IRQn 1 */ -} - -/** - * @brief This function handles DMA1 channel3 global interrupt. - */ -void DMA1_Channel3_IRQHandler(void) -{ - /* USER CODE BEGIN DMA1_Channel3_IRQn 0 */ - - /* USER CODE END DMA1_Channel3_IRQn 0 */ - HAL_DMA_IRQHandler(&hdma_spi1_tx); - /* USER CODE BEGIN DMA1_Channel3_IRQn 1 */ - - /* USER CODE END DMA1_Channel3_IRQn 1 */ -} - -/** - * @brief This function handles ADC1 global interrupt. - */ -void ADC1_IRQHandler(void) -{ - /* USER CODE BEGIN ADC1_IRQn 0 */ - - /* USER CODE END ADC1_IRQn 0 */ - HAL_ADC_IRQHandler(&hadc1); - /* USER CODE BEGIN ADC1_IRQn 1 */ - - /* USER CODE END ADC1_IRQn 1 */ -} - -/** - * @brief This function handles CAN1 TX interrupt. - */ -void CAN1_TX_IRQHandler(void) -{ - /* USER CODE BEGIN CAN1_TX_IRQn 0 */ - - /* USER CODE END CAN1_TX_IRQn 0 */ - HAL_CAN_IRQHandler(&hcan1); - /* USER CODE BEGIN CAN1_TX_IRQn 1 */ - - /* USER CODE END CAN1_TX_IRQn 1 */ -} - -/** - * @brief This function handles CAN1 RX0 interrupt. - */ -void CAN1_RX0_IRQHandler(void) -{ - /* USER CODE BEGIN CAN1_RX0_IRQn 0 */ - - /* USER CODE END CAN1_RX0_IRQn 0 */ - HAL_CAN_IRQHandler(&hcan1); - /* USER CODE BEGIN CAN1_RX0_IRQn 1 */ - - /* USER CODE END CAN1_RX0_IRQn 1 */ -} - -/** - * @brief This function handles CAN1 RX1 interrupt. - */ -void CAN1_RX1_IRQHandler(void) -{ - /* USER CODE BEGIN CAN1_RX1_IRQn 0 */ - - /* USER CODE END CAN1_RX1_IRQn 0 */ - HAL_CAN_IRQHandler(&hcan1); - /* USER CODE BEGIN CAN1_RX1_IRQn 1 */ - - /* USER CODE END CAN1_RX1_IRQn 1 */ -} - -/** - * @brief This function handles CAN1 SCE interrupt. - */ -void CAN1_SCE_IRQHandler(void) -{ - /* USER CODE BEGIN CAN1_SCE_IRQn 0 */ - - /* USER CODE END CAN1_SCE_IRQn 0 */ - HAL_CAN_IRQHandler(&hcan1); - /* USER CODE BEGIN CAN1_SCE_IRQn 1 */ - - /* USER CODE END CAN1_SCE_IRQn 1 */ -} - -/** - * @brief This function handles SPI1 global interrupt. - */ -void SPI1_IRQHandler(void) -{ - /* USER CODE BEGIN SPI1_IRQn 0 */ - - /* USER CODE END SPI1_IRQn 0 */ - HAL_SPI_IRQHandler(&hspi1); - /* USER CODE BEGIN SPI1_IRQn 1 */ - - /* USER CODE END SPI1_IRQn 1 */ -} - -/** - * @brief This function handles DMA2 channel3 global interrupt. - */ -void DMA2_Channel3_IRQHandler(void) -{ - /* USER CODE BEGIN DMA2_Channel3_IRQn 0 */ - - /* USER CODE END DMA2_Channel3_IRQn 0 */ - HAL_DMA_IRQHandler(&hdma_adc1); - /* USER CODE BEGIN DMA2_Channel3_IRQn 1 */ - - /* USER CODE END DMA2_Channel3_IRQn 1 */ -} - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ - +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file stm32l4xx_it.c + * @brief Interrupt Service Routines. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2021 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "main.h" +#include "stm32l4xx_it.h" +#include "FreeRTOS.h" +#include "task.h" +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ +/* USER CODE END Includes */ + +/* Private typedef -----------------------------------------------------------*/ +/* USER CODE BEGIN TD */ + +/* USER CODE END TD */ + +/* Private define ------------------------------------------------------------*/ +/* USER CODE BEGIN PD */ + +/* USER CODE END PD */ + +/* Private macro -------------------------------------------------------------*/ +/* USER CODE BEGIN PM */ + +/* USER CODE END PM */ + +/* Private variables ---------------------------------------------------------*/ +/* USER CODE BEGIN PV */ + +/* USER CODE END PV */ + +/* Private function prototypes -----------------------------------------------*/ +/* USER CODE BEGIN PFP */ + +/* USER CODE END PFP */ + +/* Private user code ---------------------------------------------------------*/ +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +/* External variables --------------------------------------------------------*/ +extern DMA_HandleTypeDef hdma_adc1; +extern ADC_HandleTypeDef hadc1; +extern CAN_HandleTypeDef hcan1; +extern DMA_HandleTypeDef hdma_spi1_rx; +extern DMA_HandleTypeDef hdma_spi1_tx; +extern SPI_HandleTypeDef hspi1; +/* USER CODE BEGIN EV */ + +/* USER CODE END EV */ + +/******************************************************************************/ +/* Cortex-M4 Processor Interruption and Exception Handlers */ +/******************************************************************************/ +/** + * @brief This function handles Non maskable interrupt. + */ +void NMI_Handler(void) +{ + /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ + + /* USER CODE END NonMaskableInt_IRQn 0 */ + /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ + while (1) + { + } + /* USER CODE END NonMaskableInt_IRQn 1 */ +} + +/** + * @brief This function handles Hard fault interrupt. + */ +void HardFault_Handler(void) +{ + /* USER CODE BEGIN HardFault_IRQn 0 */ + + /* USER CODE END HardFault_IRQn 0 */ + while (1) + { + /* USER CODE BEGIN W1_HardFault_IRQn 0 */ + /* USER CODE END W1_HardFault_IRQn 0 */ + } +} + +/** + * @brief This function handles Memory management fault. + */ +void MemManage_Handler(void) +{ + /* USER CODE BEGIN MemoryManagement_IRQn 0 */ + + /* USER CODE END MemoryManagement_IRQn 0 */ + while (1) + { + /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */ + /* USER CODE END W1_MemoryManagement_IRQn 0 */ + } +} + +/** + * @brief This function handles Prefetch fault, memory access fault. + */ +void BusFault_Handler(void) +{ + /* USER CODE BEGIN BusFault_IRQn 0 */ + + /* USER CODE END BusFault_IRQn 0 */ + while (1) + { + /* USER CODE BEGIN W1_BusFault_IRQn 0 */ + /* USER CODE END W1_BusFault_IRQn 0 */ + } +} + +/** + * @brief This function handles Undefined instruction or illegal state. + */ +void UsageFault_Handler(void) +{ + /* USER CODE BEGIN UsageFault_IRQn 0 */ + + /* USER CODE END UsageFault_IRQn 0 */ + while (1) + { + /* USER CODE BEGIN W1_UsageFault_IRQn 0 */ + /* USER CODE END W1_UsageFault_IRQn 0 */ + } +} + +/** + * @brief This function handles Debug monitor. + */ +void DebugMon_Handler(void) +{ + /* USER CODE BEGIN DebugMonitor_IRQn 0 */ + + /* USER CODE END DebugMonitor_IRQn 0 */ + /* USER CODE BEGIN DebugMonitor_IRQn 1 */ + + /* USER CODE END DebugMonitor_IRQn 1 */ +} + +/** + * @brief This function handles System tick timer. + */ +void SysTick_Handler(void) +{ + /* USER CODE BEGIN SysTick_IRQn 0 */ + + /* USER CODE END SysTick_IRQn 0 */ + HAL_IncTick(); +#if (INCLUDE_xTaskGetSchedulerState == 1 ) + if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED) + { +#endif /* INCLUDE_xTaskGetSchedulerState */ + xPortSysTickHandler(); +#if (INCLUDE_xTaskGetSchedulerState == 1 ) + } +#endif /* INCLUDE_xTaskGetSchedulerState */ + /* USER CODE BEGIN SysTick_IRQn 1 */ + + /* USER CODE END SysTick_IRQn 1 */ +} + +/******************************************************************************/ +/* STM32L4xx Peripheral Interrupt Handlers */ +/* Add here the Interrupt Handlers for the used peripherals. */ +/* For the available peripheral interrupt handler names, */ +/* please refer to the startup file (startup_stm32l4xx.s). */ +/******************************************************************************/ + +/** + * @brief This function handles DMA1 channel2 global interrupt. + */ +void DMA1_Channel2_IRQHandler(void) +{ + /* USER CODE BEGIN DMA1_Channel2_IRQn 0 */ + + /* USER CODE END DMA1_Channel2_IRQn 0 */ + HAL_DMA_IRQHandler(&hdma_spi1_rx); + /* USER CODE BEGIN DMA1_Channel2_IRQn 1 */ + + /* USER CODE END DMA1_Channel2_IRQn 1 */ +} + +/** + * @brief This function handles DMA1 channel3 global interrupt. + */ +void DMA1_Channel3_IRQHandler(void) +{ + /* USER CODE BEGIN DMA1_Channel3_IRQn 0 */ + + /* USER CODE END DMA1_Channel3_IRQn 0 */ + HAL_DMA_IRQHandler(&hdma_spi1_tx); + /* USER CODE BEGIN DMA1_Channel3_IRQn 1 */ + + /* USER CODE END DMA1_Channel3_IRQn 1 */ +} + +/** + * @brief This function handles ADC1 global interrupt. + */ +void ADC1_IRQHandler(void) +{ + /* USER CODE BEGIN ADC1_IRQn 0 */ + + /* USER CODE END ADC1_IRQn 0 */ + HAL_ADC_IRQHandler(&hadc1); + /* USER CODE BEGIN ADC1_IRQn 1 */ + + /* USER CODE END ADC1_IRQn 1 */ +} + +/** + * @brief This function handles CAN1 TX interrupt. + */ +void CAN1_TX_IRQHandler(void) +{ + /* USER CODE BEGIN CAN1_TX_IRQn 0 */ + + /* USER CODE END CAN1_TX_IRQn 0 */ + HAL_CAN_IRQHandler(&hcan1); + /* USER CODE BEGIN CAN1_TX_IRQn 1 */ + + /* USER CODE END CAN1_TX_IRQn 1 */ +} + +/** + * @brief This function handles CAN1 RX0 interrupt. + */ +void CAN1_RX0_IRQHandler(void) +{ + /* USER CODE BEGIN CAN1_RX0_IRQn 0 */ + + /* USER CODE END CAN1_RX0_IRQn 0 */ + HAL_CAN_IRQHandler(&hcan1); + /* USER CODE BEGIN CAN1_RX0_IRQn 1 */ + + /* USER CODE END CAN1_RX0_IRQn 1 */ +} + +/** + * @brief This function handles CAN1 RX1 interrupt. + */ +void CAN1_RX1_IRQHandler(void) +{ + /* USER CODE BEGIN CAN1_RX1_IRQn 0 */ + + /* USER CODE END CAN1_RX1_IRQn 0 */ + HAL_CAN_IRQHandler(&hcan1); + /* USER CODE BEGIN CAN1_RX1_IRQn 1 */ + + /* USER CODE END CAN1_RX1_IRQn 1 */ +} + +/** + * @brief This function handles CAN1 SCE interrupt. + */ +void CAN1_SCE_IRQHandler(void) +{ + /* USER CODE BEGIN CAN1_SCE_IRQn 0 */ + + /* USER CODE END CAN1_SCE_IRQn 0 */ + HAL_CAN_IRQHandler(&hcan1); + /* USER CODE BEGIN CAN1_SCE_IRQn 1 */ + + /* USER CODE END CAN1_SCE_IRQn 1 */ +} + +/** + * @brief This function handles SPI1 global interrupt. + */ +void SPI1_IRQHandler(void) +{ + /* USER CODE BEGIN SPI1_IRQn 0 */ + + /* USER CODE END SPI1_IRQn 0 */ + HAL_SPI_IRQHandler(&hspi1); + /* USER CODE BEGIN SPI1_IRQn 1 */ + + /* USER CODE END SPI1_IRQn 1 */ +} + +/** + * @brief This function handles DMA2 channel3 global interrupt. + */ +void DMA2_Channel3_IRQHandler(void) +{ + /* USER CODE BEGIN DMA2_Channel3_IRQn 0 */ + + /* USER CODE END DMA2_Channel3_IRQn 0 */ + HAL_DMA_IRQHandler(&hdma_adc1); + /* USER CODE BEGIN DMA2_Channel3_IRQn 1 */ + + /* USER CODE END DMA2_Channel3_IRQn 1 */ +} + +/* USER CODE BEGIN 1 */ + +/* USER CODE END 1 */ + diff --git a/Core/Toolbox/UTIL_Utility.c b/Core/Toolbox/UTIL_Utility.c index 11d75e3..dc27ead 100644 --- a/Core/Toolbox/UTIL_Utility.c +++ b/Core/Toolbox/UTIL_Utility.c @@ -1,432 +1,432 @@ -//================================================================================================= -// -// Company: Paul Scherrer Institut -// 5232 Villigen PSI -// Switzerland -// -//------------------------------------------------------------------------------------------------- -// -// Project: Peltier Controller V3 -// Author: Noah Piqué (noah.pique@psi.ch) -// -//------------------------------------------------------------------------------------------------- -// -// Module: Utility -// Filename: UTIL_Utility.c -// Date: Handled by Subversion (version control system) -// Revision: Handled by Subversion (version control system) -// History: Handled by Subversion (version control system) -// -//------------------------------------------------------------------------------------------------- -// -// Description: This source file contains a few utility functions -// -//================================================================================================= - - - -//================================================================================================= -// Section: INCLUDES -// Description: List of required include files. -//================================================================================================= - -#include "UTIL_Utility.h" - - -//================================================================================================= -// Section: DEFINITIONS -// Description: Definition of local constants (visible by this module only). -//================================================================================================= - -// defines the registers for the debug printf via trace -#define ITM_Port8(n) (*((volatile unsigned char *)(0xE0000000+4*n))) -#define ITM_Port16(n) (*((volatile unsigned short*)(0xE0000000+4*n))) -#define ITM_Port32(n) (*((volatile unsigned long *)(0xE0000000+4*n))) -#define DEMCR (*((volatile unsigned long *)(0xE000EDFC))) -#define TRCENA 0x01000000 - -#define DBGMCU_IDCOE 0xE0042000 - -//================================================================================================= -// Section: MACROS -// Description: Definition of local macros (visible by this module only). -//================================================================================================= - - - -//================================================================================================= -// Section: ENUMERATIONS -// Description: Definition of local enumerations (visible by this module only). -//================================================================================================= - - - - -//================================================================================================= -// Section: STRUCTURES -// Description: Definition of local Structures (visible by this module only). -//================================================================================================= - - - -//================================================================================================= -// Section: LOCAL VARIABLES -// Description: Definition of local variables (visible by this module only). -//================================================================================================= - - - -//================================================================================================= -// Section: LOCAL CONSTANTS -// Description: Definition of local constants (visible by this module only). -//================================================================================================= - -//================================================================================================= -// Section: LOCAL FUNCTIONS (PROTOTYPES) -// Description: Definition of local functions (visible by this module only). -//================================================================================================= - - -//================================================================================================= -// Section: EXTERNAL FUNCTIONS -// Description: Definition of external (global) functions. -//================================================================================================= - - - -//================================================================================================= -// Section: EXTERNAL VARIABLES -// Description: Definition of external (global) variables. -//================================================================================================= - - - -//================================================================================================= -// Section: GLOBAL FUNCTIONS -// Description: Definition (implementation) of global functions. -//================================================================================================= - -//------------------------------------------------------------------------------------------------- -// Function: UTIL_u16StringLength -// Description: Returns the length of the string without zero termination -// Parameters: PSZ pszString -// Returns: U16, string length -//------------------------------------------------------------------------------------------------- -U16 UTIL_u16StringLength( PSZ pszString ) -{ - U16 u16Cnt = 0; - - while( *pszString++ != '\0' ) - { - u16Cnt++; - } - return( u16Cnt ); -} - -//------------------------------------------------------------------------------------------------- -// Function: UTIL_u16CheckStringLength -// Description: Returns TRUE, if the string leght (withouth zero termination) is less or equal the u16MaxLength -// Parameters: PSZ pszString -// U16 u16MaxLength -// Returns: U16, string length -//------------------------------------------------------------------------------------------------- -BOOL UTIL_boCheckStringLength( PSZ pszString, U16 u16MaxLength ) -{ - while( *pszString++ != '\0' ) - { - if( u16MaxLength == 0 ) - { - return( FALSE ); - } - u16MaxLength--; - } - return( TRUE ); -} - -//------------------------------------------------------------------------------------------------- -// Function: UTIL_vPuts -// Description: Prints a string -// Parameters: PSZ pszString -// Returns: None -//------------------------------------------------------------------------------------------------- -VOID UTIL_vPuts( PSZ pszString ) -{ - while( *pszString != '\0' ) - { - putchar( *pszString++ ); - } -} - -//------------------------------------------------------------------------------------------------- -// Function: UTIL_u8FindMajority -// Description: Finds the majority element of a given data set -// Parameters: PU8 pu8Data -// U16 u16Length -// Returns: U8 -//------------------------------------------------------------------------------------------------- -U8 UTIL_u8FindMajority( PU8 pu8Data, U16 u16Length ) -{ - U32 u32MaxCount = 0; - S32 s32Index = -1; - - for( U32 i = 0; i < u16Length; i++) - { - U32 u32Count = 0; - for( int j = 0; j < u16Length; j++ ) - { - if(pu8Data[i] == pu8Data[j]) - u32Count++; - } - - // update maxCount if count of - // current element is greater - if( u32Count > u32MaxCount ) - { - u32MaxCount = u32Count; - s32Index = i; - } - } - - // if maxCount is greater than n/2 - // return the corresponding element - if( u32MaxCount > u16Length/2 && s32Index >= 0 ) - { - return( pu8Data[s32Index] ); - } - else - { - return( 0 ); - } - -} - -//------------------------------------------------------------------------------------------------- -// Function: UTIL_vMemCopy -// Description: Copies a set of data. -// Parameters: PVOID pvSource pointer to the source data -// VOID pvDest pointer destination data -// U16 u16Length number of bytes to copy -// Returns: None -//------------------------------------------------------------------------------------------------- -VOID UTIL_vMemCopy( PVOID pvSource, PVOID pvDest, U16 u16Length ) -{ - // use memcpy for better performance - memcpy( pvDest, pvSource, u16Length ); -} - -//------------------------------------------------------------------------------------------------- -// Function: UTIL_u32MemCopy -// Description: Copies a set of data. -// Parameters: PVOID pvSource pointer to the source data -// PVOID pvDest pointer destination data -// U16 u16Length number of bytes to copy -// SDEF_EnByteOrder enByteOrder byte order -// Returns: U32 Number of Bytes copied -//------------------------------------------------------------------------------------------------- -U32 UTIL_u32MemCopy( PVOID pvSource, PVOID pvDest, U16 u16Length, SDEF_EnByteOrder enByteOrder ) -{ - if( enByteOrder == SDEF_eNormalByteOrder ) - { - UTIL_vMemCopy( pvSource, pvDest, u16Length ); - } - else - { - // copy the bytes in reverse order - PU8 pu8Source = pvSource; - PU8 pu8Dest = pvDest; - for( U16 u16Cnt = 0; u16Cnt < (u16Length+1)/2; u16Cnt++ ) - { - pu8Dest[u16Cnt] = pu8Source[u16Length - 1 - u16Cnt]; - pu8Dest[u16Length - 1 - u16Cnt] = pu8Source[u16Cnt]; - } - } - - return( u16Length ); -} - -//------------------------------------------------------------------------------------------------- -// Function: UTIL_vMemCopyU32 -// Description: Copies a set of four byte data types. -// Parameters: PU32 pu32Source pointer to the source data -// PU32 pu32Dest pointer destination data -// U16 u16Length number of bytes to copy -// Returns: None -//------------------------------------------------------------------------------------------------- -VOID UTIL_vMemCopyU32( PU32 pu32Source, PU32 pu32Dest, U16 u16Length ) -{ - while( u16Length-- > 0 ) - { - *pu32Dest++ = *pu32Source++; - } -} - -//------------------------------------------------------------------------------------------------- -// Function: UTIL_boMemCompare -// Description: Compares a set of data to equality -// Parameters: PU8 pu8Data1 pointer to first data set -// PU8 pu8Data2 pointer to second data set -// U32 u32Length number of bytes to compare -// Returns: BOOL TRUE, if compared data is equal, otherwise FALSE -//------------------------------------------------------------------------------------------------- - -BOOL UTIL_boMemCompare( PU8 pu8Data1, PU8 pu8Data2, U32 u32Length ) -{ - while( u32Length-- > 0 ) - { - if( *pu8Data1++ != *pu8Data2++ ) - { - return( FALSE ); - } - } - return( TRUE ); -} - -//------------------------------------------------------------------------------------------------- -// Function: UTIL_boMemCompareVal -// Description: Compares if the all the data has the value specifed with u8Value. -// Parameters: PU8 pu8Data pointer to data set -// U8 u8Value value to compare -// U32 u32Length number of bytes to compare -// Returns: BOOL TRUE, if compared data is equal, otherwise FALSE -//------------------------------------------------------------------------------------------------- - -BOOL UTIL_boMemCompareVal( PU8 pu8Data, U8 u8Value, U32 u32Length ) -{ - while( u32Length-- > 0 ) - { - if( *pu8Data != u8Value) - { - return( FALSE ); - } - pu8Data++; - } - return( TRUE ); -} - -//------------------------------------------------------------------------------------------------- -// Function: UTIL_u8DecToBCD -// Description: Converts decimal encoded byte to bcd value -// Parameters: decimal value to convert to bcd -// Returns: None -//------------------------------------------------------------------------------------------------- -U8 UTIL_u8DecToBCD( U8 u8Value ) -{ - return ( (u8Value/10*16) + (u8Value%10) ); -} - -//------------------------------------------------------------------------------------------------- -// Function: UTIL_u8BCDToDec -// Description: Converts bcd to decimal -// Parameters: bcd value to convert to decimal -// Returns: None -//------------------------------------------------------------------------------------------------- -U8 UTIL_u8BCDToDec( U8 u8Value ) -{ - return ( (u8Value/16*10) + (u8Value%16) ); -} - -//------------------------------------------------------------------------------------------------- -// Function: UTIL_vReverseBytes -// Description: Reverses the byte order -// Parameters: PU8 pu8Data data -// U16 u16NumberOfBytes number of bytes -// Returns: None -//------------------------------------------------------------------------------------------------- -VOID UTIL_vReverseBytes( PU8 pu8Data, U16 u16NumberOfBytes ) -{ - U8 u8Tmp; - for( U16 u16Cnt = 0; u16Cnt < u16NumberOfBytes/2; u16Cnt++ ) - { - u8Tmp = pu8Data[u16Cnt]; - pu8Data[u16Cnt] = pu8Data[u16NumberOfBytes - 1 - u16Cnt]; - pu8Data[u16NumberOfBytes - 1 - u16Cnt] = u8Tmp; - } -} - -//------------------------------------------------------------------------------------------------- -// Function: UTIL_u32RevU32 -// Description: Reverses the bytes of an U32 -// Parameters: U32 u32Data -// Returns: U32 reversed data -//------------------------------------------------------------------------------------------------- -U32 UTIL_u32RevU32( U32 u32Data ) -{ - return( __REV(u32Data) ); -} - -//------------------------------------------------------------------------------------------------- -// Function: UTIL_u32RevFLOAT -// Description: Reverses the bytes of an FLOAT -// Parameters: FLOAT flData -// Returns: U32 reversed data -//------------------------------------------------------------------------------------------------- -U32 UTIL_u32RevFLOAT( FLOAT flData ) -{ - U32 u32Data = *(PU32)&flData; - return( __REV(u32Data) ); -} - -//------------------------------------------------------------------------------------------------- -// Function: UTIL_u16RevU16 -// Description: Reverses the bytes of an U16 -// Parameters: U16 u16Data -// Returns: U16 reversed data -//------------------------------------------------------------------------------------------------- -U16 UTIL_u16RevU16( U16 u16Data ) -{ - return( (U16)__REV16(u16Data) ); -} - -//------------------------------------------------------------------------------------------------- -// Function: UTIL_cGetDeviceRevision -// Description: Gets the silicon revision of the STM32F437 -// Parameters: None -// Returns: CHAR -//------------------------------------------------------------------------------------------------- -CHAR UTIL_cGetDeviceRevision( VOID ) -{ - U16 u16DeviceID = (*(PU32)DBGMCU_IDCOE) >> 16; - - switch( u16DeviceID ) - { - case 0x100: - return( 'A' ); - - case 0x1001: - return( 'Z' ); - - case 0x1003: - return( 'Y' ); - - case 0x1007: - return( '1' ); - - case 0x2001: - return( '3' ); - - default: - return( '0' ); - } -} - -//------------------------------------------------------------------------------------------------- -// Function: fputc -// Description: Prototype for printf -//------------------------------------------------------------------------------------------------- -int fputc( int ch, FILE *f ) -{ - UNUSED( f ); // file stream not used - - if( DEMCR & TRCENA ) - { - while( ITM_Port32(0) == 0 ); - ITM_Port8(0) = (U8)ch; - } - return( ch ); -} - -//================================================================================================= -// Section: LOCAL FUNCTIONS -// Description: Definition (implementation) of local functions. -//================================================================================================= - +//================================================================================================= +// +// Company: Paul Scherrer Institut +// 5232 Villigen PSI +// Switzerland +// +//------------------------------------------------------------------------------------------------- +// +// Project: Peltier Controller V3 +// Author: Noah Piqué (noah.pique@psi.ch) +// +//------------------------------------------------------------------------------------------------- +// +// Module: Utility +// Filename: UTIL_Utility.c +// Date: Handled by Subversion (version control system) +// Revision: Handled by Subversion (version control system) +// History: Handled by Subversion (version control system) +// +//------------------------------------------------------------------------------------------------- +// +// Description: This source file contains a few utility functions +// +//================================================================================================= + + + +//================================================================================================= +// Section: INCLUDES +// Description: List of required include files. +//================================================================================================= + +#include "UTIL_Utility.h" + + +//================================================================================================= +// Section: DEFINITIONS +// Description: Definition of local constants (visible by this module only). +//================================================================================================= + +// defines the registers for the debug printf via trace +#define ITM_Port8(n) (*((volatile unsigned char *)(0xE0000000+4*n))) +#define ITM_Port16(n) (*((volatile unsigned short*)(0xE0000000+4*n))) +#define ITM_Port32(n) (*((volatile unsigned long *)(0xE0000000+4*n))) +#define DEMCR (*((volatile unsigned long *)(0xE000EDFC))) +#define TRCENA 0x01000000 + +#define DBGMCU_IDCOE 0xE0042000 + +//================================================================================================= +// Section: MACROS +// Description: Definition of local macros (visible by this module only). +//================================================================================================= + + + +//================================================================================================= +// Section: ENUMERATIONS +// Description: Definition of local enumerations (visible by this module only). +//================================================================================================= + + + + +//================================================================================================= +// Section: STRUCTURES +// Description: Definition of local Structures (visible by this module only). +//================================================================================================= + + + +//================================================================================================= +// Section: LOCAL VARIABLES +// Description: Definition of local variables (visible by this module only). +//================================================================================================= + + + +//================================================================================================= +// Section: LOCAL CONSTANTS +// Description: Definition of local constants (visible by this module only). +//================================================================================================= + +//================================================================================================= +// Section: LOCAL FUNCTIONS (PROTOTYPES) +// Description: Definition of local functions (visible by this module only). +//================================================================================================= + + +//================================================================================================= +// Section: EXTERNAL FUNCTIONS +// Description: Definition of external (global) functions. +//================================================================================================= + + + +//================================================================================================= +// Section: EXTERNAL VARIABLES +// Description: Definition of external (global) variables. +//================================================================================================= + + + +//================================================================================================= +// Section: GLOBAL FUNCTIONS +// Description: Definition (implementation) of global functions. +//================================================================================================= + +//------------------------------------------------------------------------------------------------- +// Function: UTIL_u16StringLength +// Description: Returns the length of the string without zero termination +// Parameters: PSZ pszString +// Returns: U16, string length +//------------------------------------------------------------------------------------------------- +U16 UTIL_u16StringLength( PSZ pszString ) +{ + U16 u16Cnt = 0; + + while( *pszString++ != '\0' ) + { + u16Cnt++; + } + return( u16Cnt ); +} + +//------------------------------------------------------------------------------------------------- +// Function: UTIL_u16CheckStringLength +// Description: Returns TRUE, if the string leght (withouth zero termination) is less or equal the u16MaxLength +// Parameters: PSZ pszString +// U16 u16MaxLength +// Returns: U16, string length +//------------------------------------------------------------------------------------------------- +BOOL UTIL_boCheckStringLength( PSZ pszString, U16 u16MaxLength ) +{ + while( *pszString++ != '\0' ) + { + if( u16MaxLength == 0 ) + { + return( FALSE ); + } + u16MaxLength--; + } + return( TRUE ); +} + +//------------------------------------------------------------------------------------------------- +// Function: UTIL_vPuts +// Description: Prints a string +// Parameters: PSZ pszString +// Returns: None +//------------------------------------------------------------------------------------------------- +VOID UTIL_vPuts( PSZ pszString ) +{ + while( *pszString != '\0' ) + { + putchar( *pszString++ ); + } +} + +//------------------------------------------------------------------------------------------------- +// Function: UTIL_u8FindMajority +// Description: Finds the majority element of a given data set +// Parameters: PU8 pu8Data +// U16 u16Length +// Returns: U8 +//------------------------------------------------------------------------------------------------- +U8 UTIL_u8FindMajority( PU8 pu8Data, U16 u16Length ) +{ + U32 u32MaxCount = 0; + S32 s32Index = -1; + + for( U32 i = 0; i < u16Length; i++) + { + U32 u32Count = 0; + for( int j = 0; j < u16Length; j++ ) + { + if(pu8Data[i] == pu8Data[j]) + u32Count++; + } + + // update maxCount if count of + // current element is greater + if( u32Count > u32MaxCount ) + { + u32MaxCount = u32Count; + s32Index = i; + } + } + + // if maxCount is greater than n/2 + // return the corresponding element + if( u32MaxCount > u16Length/2 && s32Index >= 0 ) + { + return( pu8Data[s32Index] ); + } + else + { + return( 0 ); + } + +} + +//------------------------------------------------------------------------------------------------- +// Function: UTIL_vMemCopy +// Description: Copies a set of data. +// Parameters: PVOID pvSource pointer to the source data +// VOID pvDest pointer destination data +// U16 u16Length number of bytes to copy +// Returns: None +//------------------------------------------------------------------------------------------------- +VOID UTIL_vMemCopy( PVOID pvSource, PVOID pvDest, U16 u16Length ) +{ + // use memcpy for better performance + memcpy( pvDest, pvSource, u16Length ); +} + +//------------------------------------------------------------------------------------------------- +// Function: UTIL_u32MemCopy +// Description: Copies a set of data. +// Parameters: PVOID pvSource pointer to the source data +// PVOID pvDest pointer destination data +// U16 u16Length number of bytes to copy +// SDEF_EnByteOrder enByteOrder byte order +// Returns: U32 Number of Bytes copied +//------------------------------------------------------------------------------------------------- +U32 UTIL_u32MemCopy( PVOID pvSource, PVOID pvDest, U16 u16Length, SDEF_EnByteOrder enByteOrder ) +{ + if( enByteOrder == SDEF_eNormalByteOrder ) + { + UTIL_vMemCopy( pvSource, pvDest, u16Length ); + } + else + { + // copy the bytes in reverse order + PU8 pu8Source = pvSource; + PU8 pu8Dest = pvDest; + for( U16 u16Cnt = 0; u16Cnt < (u16Length+1)/2; u16Cnt++ ) + { + pu8Dest[u16Cnt] = pu8Source[u16Length - 1 - u16Cnt]; + pu8Dest[u16Length - 1 - u16Cnt] = pu8Source[u16Cnt]; + } + } + + return( u16Length ); +} + +//------------------------------------------------------------------------------------------------- +// Function: UTIL_vMemCopyU32 +// Description: Copies a set of four byte data types. +// Parameters: PU32 pu32Source pointer to the source data +// PU32 pu32Dest pointer destination data +// U16 u16Length number of bytes to copy +// Returns: None +//------------------------------------------------------------------------------------------------- +VOID UTIL_vMemCopyU32( PU32 pu32Source, PU32 pu32Dest, U16 u16Length ) +{ + while( u16Length-- > 0 ) + { + *pu32Dest++ = *pu32Source++; + } +} + +//------------------------------------------------------------------------------------------------- +// Function: UTIL_boMemCompare +// Description: Compares a set of data to equality +// Parameters: PU8 pu8Data1 pointer to first data set +// PU8 pu8Data2 pointer to second data set +// U32 u32Length number of bytes to compare +// Returns: BOOL TRUE, if compared data is equal, otherwise FALSE +//------------------------------------------------------------------------------------------------- + +BOOL UTIL_boMemCompare( PU8 pu8Data1, PU8 pu8Data2, U32 u32Length ) +{ + while( u32Length-- > 0 ) + { + if( *pu8Data1++ != *pu8Data2++ ) + { + return( FALSE ); + } + } + return( TRUE ); +} + +//------------------------------------------------------------------------------------------------- +// Function: UTIL_boMemCompareVal +// Description: Compares if the all the data has the value specifed with u8Value. +// Parameters: PU8 pu8Data pointer to data set +// U8 u8Value value to compare +// U32 u32Length number of bytes to compare +// Returns: BOOL TRUE, if compared data is equal, otherwise FALSE +//------------------------------------------------------------------------------------------------- + +BOOL UTIL_boMemCompareVal( PU8 pu8Data, U8 u8Value, U32 u32Length ) +{ + while( u32Length-- > 0 ) + { + if( *pu8Data != u8Value) + { + return( FALSE ); + } + pu8Data++; + } + return( TRUE ); +} + +//------------------------------------------------------------------------------------------------- +// Function: UTIL_u8DecToBCD +// Description: Converts decimal encoded byte to bcd value +// Parameters: decimal value to convert to bcd +// Returns: None +//------------------------------------------------------------------------------------------------- +U8 UTIL_u8DecToBCD( U8 u8Value ) +{ + return ( (u8Value/10*16) + (u8Value%10) ); +} + +//------------------------------------------------------------------------------------------------- +// Function: UTIL_u8BCDToDec +// Description: Converts bcd to decimal +// Parameters: bcd value to convert to decimal +// Returns: None +//------------------------------------------------------------------------------------------------- +U8 UTIL_u8BCDToDec( U8 u8Value ) +{ + return ( (u8Value/16*10) + (u8Value%16) ); +} + +//------------------------------------------------------------------------------------------------- +// Function: UTIL_vReverseBytes +// Description: Reverses the byte order +// Parameters: PU8 pu8Data data +// U16 u16NumberOfBytes number of bytes +// Returns: None +//------------------------------------------------------------------------------------------------- +VOID UTIL_vReverseBytes( PU8 pu8Data, U16 u16NumberOfBytes ) +{ + U8 u8Tmp; + for( U16 u16Cnt = 0; u16Cnt < u16NumberOfBytes/2; u16Cnt++ ) + { + u8Tmp = pu8Data[u16Cnt]; + pu8Data[u16Cnt] = pu8Data[u16NumberOfBytes - 1 - u16Cnt]; + pu8Data[u16NumberOfBytes - 1 - u16Cnt] = u8Tmp; + } +} + +//------------------------------------------------------------------------------------------------- +// Function: UTIL_u32RevU32 +// Description: Reverses the bytes of an U32 +// Parameters: U32 u32Data +// Returns: U32 reversed data +//------------------------------------------------------------------------------------------------- +U32 UTIL_u32RevU32( U32 u32Data ) +{ + return( __REV(u32Data) ); +} + +//------------------------------------------------------------------------------------------------- +// Function: UTIL_u32RevFLOAT +// Description: Reverses the bytes of an FLOAT +// Parameters: FLOAT flData +// Returns: U32 reversed data +//------------------------------------------------------------------------------------------------- +U32 UTIL_u32RevFLOAT( FLOAT flData ) +{ + U32 u32Data = *(PU32)&flData; + return( __REV(u32Data) ); +} + +//------------------------------------------------------------------------------------------------- +// Function: UTIL_u16RevU16 +// Description: Reverses the bytes of an U16 +// Parameters: U16 u16Data +// Returns: U16 reversed data +//------------------------------------------------------------------------------------------------- +U16 UTIL_u16RevU16( U16 u16Data ) +{ + return( (U16)__REV16(u16Data) ); +} + +//------------------------------------------------------------------------------------------------- +// Function: UTIL_cGetDeviceRevision +// Description: Gets the silicon revision of the STM32F437 +// Parameters: None +// Returns: CHAR +//------------------------------------------------------------------------------------------------- +CHAR UTIL_cGetDeviceRevision( VOID ) +{ + U16 u16DeviceID = (*(PU32)DBGMCU_IDCOE) >> 16; + + switch( u16DeviceID ) + { + case 0x100: + return( 'A' ); + + case 0x1001: + return( 'Z' ); + + case 0x1003: + return( 'Y' ); + + case 0x1007: + return( '1' ); + + case 0x2001: + return( '3' ); + + default: + return( '0' ); + } +} + +//------------------------------------------------------------------------------------------------- +// Function: fputc +// Description: Prototype for printf +//------------------------------------------------------------------------------------------------- +int fputc( int ch, FILE *f ) +{ + UNUSED( f ); // file stream not used + + if( DEMCR & TRCENA ) + { + while( ITM_Port32(0) == 0 ); + ITM_Port8(0) = (U8)ch; + } + return( ch ); +} + +//================================================================================================= +// Section: LOCAL FUNCTIONS +// Description: Definition (implementation) of local functions. +//================================================================================================= + diff --git a/Core/Toolbox/UTIL_Utility.h b/Core/Toolbox/UTIL_Utility.h index ac5b9f8..93fd2e9 100644 --- a/Core/Toolbox/UTIL_Utility.h +++ b/Core/Toolbox/UTIL_Utility.h @@ -1,202 +1,202 @@ -//================================================================================================= -// -// Company: Paul Scherrer Institut -// 5232 Villigen PSI -// Switzerland -// -//------------------------------------------------------------------------------------------------- -// -// Project: Peltier Controller V3 -// Author: Noah Piqué (noah.pique@psi.ch) -// -//------------------------------------------------------------------------------------------------- -// -// Module: Utility -// Filename: UTIL_Utility.h -// Date: Handled by Subversion (version control system) -// Revision: Handled by Subversion (version control system) -// History: Handled by Subversion (version control system) -// -//------------------------------------------------------------------------------------------------- - - -#ifndef UTIL_UTILITY_H -#define UTIL_UTILITY_H - -#ifdef __cplusplus -extern "C" { -#endif - - - -//================================================================================================= -// Section: INCLUDES -// Description: List of required include files (visible by all modules). -//================================================================================================= - -#include "string.h" -#include "stdio.h" -#include "../SDEF_StandardDefinitions.h" - -// include STM32 drivers -#include "stm32l4xx_hal.h" - -//================================================================================================= -// Section: DEFINITIONS -// Description: Definition of global constants (visible by all modules). -//================================================================================================= - - - -//================================================================================================= -// Section: MACROS -// Description: Definition of global macros (visible by all modules). -//================================================================================================= - -//macro for filename without path -/* #define _FILE_ ((PSZ)(strrchr(__FILE__, '/') ? (strrchr(__FILE__, '/') + 1) : \ - (strrchr(__FILE__, '\\') ? (strrchr(__FILE__, '\\') + 1) : __FILE__)))*/ - -#define _FILE_ __FILE__ - -#define _LINE_ __LINE__ - -//checks if a pointer is valid -#define UTIL_IS_FUNC( pfnFoo ) ( pfnFoo != NULL ) - -#define UTIL_32BitAlign( u32Address ) ((((U32)((u32Address)+4UL)/4UL))*4UL) - -#define UTIL_IS_POWER_OF_TWO( u32Numb ) ((u32Numb & (u32Numb - 1)) == 0) - -#define UTIL_u16ConcatenateBytes( u8UpperByte, u8LowerByte) ( (U16)((U16)u8UpperByte << 8) | (U16)u8LowerByte ) - -// approx delay of 1us -#define DELAY_US( u32Us ) do{\ - for( U32 u32Cnt = (SystemCoreClock >> 24U) * (u32Us); u32Cnt > 0U; u32Cnt-- ) \ - { \ - __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); \ - __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); \ - }\ - }while(0) - -#define DELAY_MS( u32Ms ) do{\ - for( U32 u32Cnt = (SystemCoreClock >> 14U) * (u32Ms); u32Cnt > 0U; u32Cnt-- ) \ - { \ - __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP();\ - __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP();\ - }\ - }while(0) - - -#ifndef UNUSED - #define UNUSED(x) ((void)(x)) -#endif - -#define UTIL_SET_BIT( u32Add, u32BitMask ) ( *(VOLATILE PU32)u32Add |= (u32BitMask) ) -#define UTIL_CLEAR_BIT( u32Add, u32BitMask ) ( *(VOLATILE PU32)u32Add &= ~(u32BitMask) ) - - #define UTIL_DEFINE_CRITICAL() U32 u32PRIMASK - -// Enter Critical: -// implements a memory barrier to ensure memory operations completed before -// stores the interrupt status register -// disables interrupts -#define UTIL_ENTER_CRITICAL() do{ \ - __DMB(); \ - u32PRIMASK = __get_PRIMASK(); \ - __disable_irq(); \ - }while(0) - -// Exit Critical: -// implements a memory barrier to ensure memory operations completed before -// restores the interrupt status register -#define UTIL_EXIT_CRITICAL() do{ \ - __DMB(); \ - __set_PRIMASK( u32PRIMASK ); \ - }while(0) - -// bit band definitions -#define UTIL_BB_SRAM( Address, BitNumber ) (*(VOLATILE PU32)(SRAM_BB_BASE + ((U32)Address - SRAM_BASE)*32 + BitNumber*4 ) ) -#define UTIL_BB_BKRAM( Address, BitNumber ) (*(VOLATILE PU32)(BKPSRAM_BB_BASE + ((U32)Address - BKPSRAM_BASE)*32 + BitNumber*4 ) ) -#define UTIL_BB_PERI( Address, BitNumber ) (*(VOLATILE PU32)(PERIPH_BB_BASE + ((U32)Address - PERIPH_BASE)*32 + BitNumber*4 ) ) - -// Basic bit band function definitions -#define UTIL_BB_SRAM_ClearBit( Address, BitNumber) (UTIL_BB_SRAM( Address, BitNumber ) = 0) -#define UTIL_BB_SRAM_SetBit( Address, BitNumber) (UTIL_BB_SRAM( Address, BitNumber ) = 1) -#define UTIL_BB_SRAM_GetBit( Address, BitNumber) UTIL_BB_SRAM( Address, BitNumber ) - -#define UTIL_BB_PERI_ClearBit( Address, BitNumber) (UTIL_BB_PERI( Address, BitNumber ) = 0) -#define UTIL_BB_PERI_SetBit( Address, BitNumber) (UTIL_BB_PERI( Address, BitNumber ) = 1) -#define UTIL_BB_PERI_GetBit( Address, BitNumber) UTIL_BB_PERI( Address, BitNumber ) - -#define UTIL_BB_BKRAM_ClearBit( Address, BitNumber) (UTIL_BB_BKRAM( Address, BitNumber ) = 0) -#define UTIL_BB_BKRAM_SetBit( Address, BitNumber) (UTIL_BB_BKRAM( Address, BitNumber ) = 1) -#define UTIL_BB_BKRMA_GetBit( Address, BitNumber) UTIL_BB_BKRAM( Address, BitNumber ) - -// Checks, if the core is in debug mode -#define UTIL_IS_DEBUGGER_ATTACHED() (CoreDebug_DHCSR_C_DEBUGEN_Msk & CoreDebug->DHCSR) - -//================================================================================================= -// Section: ENUMERATIONS -// Description: Definition of global enumerations (visible by all modules). -//================================================================================================= - - - -//================================================================================================= -// Section: STRUCTURES -// Description: Definition of global Structures (visible by all modules). -//================================================================================================= - - - -//================================================================================================= -// Section: GLOBAL VARIABLES -// Description: Definition of global variables (visible by all modules). -//================================================================================================= - - - -//================================================================================================= -// Section: GLOBAL CONSTANTS -// Description: Definition of global constants (visible by all modules). -//================================================================================================= - - - -//================================================================================================= -// Section: GLOBAL FUNCTIONS (PROTOTYPES) -// Description: Definition of global functions (visible by all modules). -//================================================================================================= - -U16 UTIL_u16StringLength( PSZ pszString ); -BOOL UTIL_boCheckStringLength( PSZ pszString, U16 u16MaxLength ); -VOID UTIL_vPuts( PSZ pszString ); - -VOID UTIL_vMemCopy( PVOID pvSource, PVOID pvDest, U16 u16Length ); -U32 UTIL_u32MemCopy( PVOID pvSource, PVOID pvDest, U16 u16Length, SDEF_EnByteOrder enByteOrder ); -VOID UTIL_vMemCopyU32( PU32 pu32Source, PU32 pu32Dest, U16 u16Length ); -BOOL UTIL_boMemCompare( PU8 pu8Data1, PU8 pu8Data2, U32 u32Length ); -BOOL UTIL_boMemCompareVal( PU8 pu8Data1, U8 u8Value, U32 u32Length ); - -U8 UTIL_u8GetPinSource( U16 u16GIPO_Pin ); -U8 UTIL_u8DecToBCD( U8 u8Value ); -U8 UTIL_u8BCDToDec( U8 u8Value ); -VOID UTIL_vReverseBytes( PU8 pu8Data, U16 u16NumberOfBytes ); -U32 UTIL_u32RevU32( U32 u32Data ); -U32 UTIL_u32RevFLOAT( FLOAT flData ); -U16 UTIL_u16RevU16( U16 u16Data ); -U8 UTIL_u8GetNumberOfClkCycles( DOUBLE dtime ); - -CHAR UTIL_cGetDeviceRevision( VOID ); - -U8 UTIL_u8FindMajority( PU8 pu8Data, U16 u16Length ); - -// printf prototype for debug printf -int fputc( int ch, FILE *f ); - -#ifdef __cplusplus -} -#endif - -#endif +//================================================================================================= +// +// Company: Paul Scherrer Institut +// 5232 Villigen PSI +// Switzerland +// +//------------------------------------------------------------------------------------------------- +// +// Project: Peltier Controller V3 +// Author: Noah Piqué (noah.pique@psi.ch) +// +//------------------------------------------------------------------------------------------------- +// +// Module: Utility +// Filename: UTIL_Utility.h +// Date: Handled by Subversion (version control system) +// Revision: Handled by Subversion (version control system) +// History: Handled by Subversion (version control system) +// +//------------------------------------------------------------------------------------------------- + + +#ifndef UTIL_UTILITY_H +#define UTIL_UTILITY_H + +#ifdef __cplusplus +extern "C" { +#endif + + + +//================================================================================================= +// Section: INCLUDES +// Description: List of required include files (visible by all modules). +//================================================================================================= + +#include "string.h" +#include "stdio.h" +#include "../SDEF_StandardDefinitions.h" + +// include STM32 drivers +#include "stm32l4xx_hal.h" + +//================================================================================================= +// Section: DEFINITIONS +// Description: Definition of global constants (visible by all modules). +//================================================================================================= + + + +//================================================================================================= +// Section: MACROS +// Description: Definition of global macros (visible by all modules). +//================================================================================================= + +//macro for filename without path +/* #define _FILE_ ((PSZ)(strrchr(__FILE__, '/') ? (strrchr(__FILE__, '/') + 1) : \ + (strrchr(__FILE__, '\\') ? (strrchr(__FILE__, '\\') + 1) : __FILE__)))*/ + +#define _FILE_ __FILE__ + +#define _LINE_ __LINE__ + +//checks if a pointer is valid +#define UTIL_IS_FUNC( pfnFoo ) ( pfnFoo != NULL ) + +#define UTIL_32BitAlign( u32Address ) ((((U32)((u32Address)+4UL)/4UL))*4UL) + +#define UTIL_IS_POWER_OF_TWO( u32Numb ) ((u32Numb & (u32Numb - 1)) == 0) + +#define UTIL_u16ConcatenateBytes( u8UpperByte, u8LowerByte) ( (U16)((U16)u8UpperByte << 8) | (U16)u8LowerByte ) + +// approx delay of 1us +#define DELAY_US( u32Us ) do{\ + for( U32 u32Cnt = (SystemCoreClock >> 24U) * (u32Us); u32Cnt > 0U; u32Cnt-- ) \ + { \ + __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); \ + __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); \ + }\ + }while(0) + +#define DELAY_MS( u32Ms ) do{\ + for( U32 u32Cnt = (SystemCoreClock >> 14U) * (u32Ms); u32Cnt > 0U; u32Cnt-- ) \ + { \ + __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP();\ + __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP();\ + }\ + }while(0) + + +#ifndef UNUSED + #define UNUSED(x) ((void)(x)) +#endif + +#define UTIL_SET_BIT( u32Add, u32BitMask ) ( *(VOLATILE PU32)u32Add |= (u32BitMask) ) +#define UTIL_CLEAR_BIT( u32Add, u32BitMask ) ( *(VOLATILE PU32)u32Add &= ~(u32BitMask) ) + + #define UTIL_DEFINE_CRITICAL() U32 u32PRIMASK + +// Enter Critical: +// implements a memory barrier to ensure memory operations completed before +// stores the interrupt status register +// disables interrupts +#define UTIL_ENTER_CRITICAL() do{ \ + __DMB(); \ + u32PRIMASK = __get_PRIMASK(); \ + __disable_irq(); \ + }while(0) + +// Exit Critical: +// implements a memory barrier to ensure memory operations completed before +// restores the interrupt status register +#define UTIL_EXIT_CRITICAL() do{ \ + __DMB(); \ + __set_PRIMASK( u32PRIMASK ); \ + }while(0) + +// bit band definitions +#define UTIL_BB_SRAM( Address, BitNumber ) (*(VOLATILE PU32)(SRAM_BB_BASE + ((U32)Address - SRAM_BASE)*32 + BitNumber*4 ) ) +#define UTIL_BB_BKRAM( Address, BitNumber ) (*(VOLATILE PU32)(BKPSRAM_BB_BASE + ((U32)Address - BKPSRAM_BASE)*32 + BitNumber*4 ) ) +#define UTIL_BB_PERI( Address, BitNumber ) (*(VOLATILE PU32)(PERIPH_BB_BASE + ((U32)Address - PERIPH_BASE)*32 + BitNumber*4 ) ) + +// Basic bit band function definitions +#define UTIL_BB_SRAM_ClearBit( Address, BitNumber) (UTIL_BB_SRAM( Address, BitNumber ) = 0) +#define UTIL_BB_SRAM_SetBit( Address, BitNumber) (UTIL_BB_SRAM( Address, BitNumber ) = 1) +#define UTIL_BB_SRAM_GetBit( Address, BitNumber) UTIL_BB_SRAM( Address, BitNumber ) + +#define UTIL_BB_PERI_ClearBit( Address, BitNumber) (UTIL_BB_PERI( Address, BitNumber ) = 0) +#define UTIL_BB_PERI_SetBit( Address, BitNumber) (UTIL_BB_PERI( Address, BitNumber ) = 1) +#define UTIL_BB_PERI_GetBit( Address, BitNumber) UTIL_BB_PERI( Address, BitNumber ) + +#define UTIL_BB_BKRAM_ClearBit( Address, BitNumber) (UTIL_BB_BKRAM( Address, BitNumber ) = 0) +#define UTIL_BB_BKRAM_SetBit( Address, BitNumber) (UTIL_BB_BKRAM( Address, BitNumber ) = 1) +#define UTIL_BB_BKRMA_GetBit( Address, BitNumber) UTIL_BB_BKRAM( Address, BitNumber ) + +// Checks, if the core is in debug mode +#define UTIL_IS_DEBUGGER_ATTACHED() (CoreDebug_DHCSR_C_DEBUGEN_Msk & CoreDebug->DHCSR) + +//================================================================================================= +// Section: ENUMERATIONS +// Description: Definition of global enumerations (visible by all modules). +//================================================================================================= + + + +//================================================================================================= +// Section: STRUCTURES +// Description: Definition of global Structures (visible by all modules). +//================================================================================================= + + + +//================================================================================================= +// Section: GLOBAL VARIABLES +// Description: Definition of global variables (visible by all modules). +//================================================================================================= + + + +//================================================================================================= +// Section: GLOBAL CONSTANTS +// Description: Definition of global constants (visible by all modules). +//================================================================================================= + + + +//================================================================================================= +// Section: GLOBAL FUNCTIONS (PROTOTYPES) +// Description: Definition of global functions (visible by all modules). +//================================================================================================= + +U16 UTIL_u16StringLength( PSZ pszString ); +BOOL UTIL_boCheckStringLength( PSZ pszString, U16 u16MaxLength ); +VOID UTIL_vPuts( PSZ pszString ); + +VOID UTIL_vMemCopy( PVOID pvSource, PVOID pvDest, U16 u16Length ); +U32 UTIL_u32MemCopy( PVOID pvSource, PVOID pvDest, U16 u16Length, SDEF_EnByteOrder enByteOrder ); +VOID UTIL_vMemCopyU32( PU32 pu32Source, PU32 pu32Dest, U16 u16Length ); +BOOL UTIL_boMemCompare( PU8 pu8Data1, PU8 pu8Data2, U32 u32Length ); +BOOL UTIL_boMemCompareVal( PU8 pu8Data1, U8 u8Value, U32 u32Length ); + +U8 UTIL_u8GetPinSource( U16 u16GIPO_Pin ); +U8 UTIL_u8DecToBCD( U8 u8Value ); +U8 UTIL_u8BCDToDec( U8 u8Value ); +VOID UTIL_vReverseBytes( PU8 pu8Data, U16 u16NumberOfBytes ); +U32 UTIL_u32RevU32( U32 u32Data ); +U32 UTIL_u32RevFLOAT( FLOAT flData ); +U16 UTIL_u16RevU16( U16 u16Data ); +U8 UTIL_u8GetNumberOfClkCycles( DOUBLE dtime ); + +CHAR UTIL_cGetDeviceRevision( VOID ); + +U8 UTIL_u8FindMajority( PU8 pu8Data, U16 u16Length ); + +// printf prototype for debug printf +int fputc( int ch, FILE *f ); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/Makefile b/Makefile index 52738e5..2974562 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ ########################################################################################################################## -# File automatically-generated by tool: [projectgenerator] version: [3.15.2] date: [Tue Sep 06 08:17:33 CEST 2022] +# File automatically-generated by tool: [projectgenerator] version: [3.17.1] date: [Tue Sep 27 08:33:11 CEST 2022] ########################################################################################################################## # ------------------------------------------------ diff --git a/PeltierControllerV3 Debug.launch b/PeltierControllerV3 Debug.launch index 69b54b6..136f62e 100644 --- a/PeltierControllerV3 Debug.launch +++ b/PeltierControllerV3 Debug.launch @@ -1,94 +1,94 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/PeltierControllerV3.ioc b/PeltierControllerV3.ioc index 3b7e531..9b86e0d 100644 --- a/PeltierControllerV3.ioc +++ b/PeltierControllerV3.ioc @@ -25,13 +25,14 @@ ADC1.SamplingTime-1\#ChannelRegularConversion=ADC_SAMPLETIME_640CYCLES_5 ADC1.SamplingTime-2\#ChannelRegularConversion=ADC_SAMPLETIME_640CYCLES_5 ADC1.SamplingTime-3\#ChannelRegularConversion=ADC_SAMPLETIME_640CYCLES_5 ADC1.master=1 -CAN1.BS1=CAN_BS1_3TQ +CAN1.BS1=CAN_BS1_13TQ +CAN1.BS2=CAN_BS2_6TQ CAN1.CalculateBaudRate=125000 CAN1.CalculateTimeBit=8000 -CAN1.CalculateTimeQuantum=1600.0 -CAN1.IPParameters=CalculateTimeQuantum,CalculateTimeBit,CalculateBaudRate,BS1,Prescaler,NART +CAN1.CalculateTimeQuantum=400.0 +CAN1.IPParameters=CalculateTimeQuantum,CalculateTimeBit,CalculateBaudRate,BS1,Prescaler,NART,BS2 CAN1.NART=ENABLE -CAN1.Prescaler=128 +CAN1.Prescaler=32 Dma.ADC1.2.Direction=DMA_PERIPH_TO_MEMORY Dma.ADC1.2.Instance=DMA2_Channel3 Dma.ADC1.2.MemDataAlignment=DMA_MDATAALIGN_HALFWORD @@ -77,6 +78,7 @@ IWDG.Prescaler=IWDG_PRESCALER_256 IWDG.Reload=150 IWDG.Window=4095 KeepUserPlacement=false +Mcu.CPN=STM32L432KBU6 Mcu.Family=STM32L4 Mcu.IP0=ADC1 Mcu.IP1=CAN1 @@ -125,29 +127,29 @@ Mcu.UserConstants= Mcu.UserName=STM32L432KBUx MxCube.Version=6.4.0 MxDb.Version=DB.6.0.40 -NVIC.ADC1_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true -NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.CAN1_RX0_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true -NVIC.CAN1_RX1_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true -NVIC.CAN1_SCE_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true -NVIC.CAN1_TX_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true -NVIC.DMA1_Channel2_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true -NVIC.DMA1_Channel3_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true -NVIC.DMA2_Channel3_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true -NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false +NVIC.ADC1_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true +NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false +NVIC.CAN1_RX0_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true +NVIC.CAN1_RX1_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true +NVIC.CAN1_SCE_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true +NVIC.CAN1_TX_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true +NVIC.DMA1_Channel2_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true\:true +NVIC.DMA1_Channel3_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true\:true +NVIC.DMA2_Channel3_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true\:true +NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false NVIC.ForceEnableDMAVector=true -NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:false\:false +NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false +NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false +NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false +NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:false\:false\:false NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 -NVIC.SPI1_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true -NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false +NVIC.SPI1_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true +NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false\:false NVIC.SavedPendsvIrqHandlerGenerated=false NVIC.SavedSvcallIrqHandlerGenerated=false NVIC.SavedSystickIrqHandlerGenerated=false -NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:true\:false\:true -NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false +NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:true\:false\:true\:false +NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false PA0.Mode=HSE-External-Clock-Source-for-LittleOrca PA0.Signal=RCC_CK_IN PA1.Locked=true diff --git a/STM32L432KBUx_FLASH.ld b/STM32L432KBUx_FLASH.ld new file mode 100644 index 0000000..19b3ff4 --- /dev/null +++ b/STM32L432KBUx_FLASH.ld @@ -0,0 +1,204 @@ +/* +****************************************************************************** +** + +** File : LinkerScript.ld +** +** Author : Auto-generated by System Workbench for STM32 +** +** Abstract : Linker script for STM32L432KBUx series +** 128Kbytes FLASH and 80Kbytes RAM +** +** Set heap size, stack size and stack location according +** to application requirements. +** +** Set memory bank area and size if external memory is used. +** +** Target : STMicroelectronics STM32 +** +** Distribution: The file is distributed “as is,” without any warranty +** of any kind. +** +***************************************************************************** +** @attention +** +**

© COPYRIGHT(c) 2019 STMicroelectronics

+** +** Redistribution and use in source and binary forms, with or without modification, +** are permitted provided that the following conditions are met: +** 1. Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** 3. Neither the name of STMicroelectronics nor the names of its contributors +** may be used to endorse or promote products derived from this software +** without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +***************************************************************************** +*/ + +/* Entry Point */ +ENTRY(Reset_Handler) + +/* Highest address of the user mode stack */ +_estack = 0x20010000; /* end of RAM */ +/* Generate a link error if heap and stack don't fit into RAM */ +_Min_Heap_Size = 0x200; /* required amount of heap */ +_Min_Stack_Size = 0x400; /* required amount of stack */ + +/* Specify the memory areas */ +MEMORY +{ +RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 64K +RAM2 (xrw) : ORIGIN = 0x10000000, LENGTH = 16K +FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 128K +} + +/* Define output sections */ +SECTIONS +{ + /* The startup code goes first into FLASH */ + .isr_vector : + { + . = ALIGN(8); + KEEP(*(.isr_vector)) /* Startup code */ + . = ALIGN(8); + } >FLASH + + /* The program code and other data goes into FLASH */ + .text : + { + . = ALIGN(8); + *(.text) /* .text sections (code) */ + *(.text*) /* .text* sections (code) */ + *(.glue_7) /* glue arm to thumb code */ + *(.glue_7t) /* glue thumb to arm code */ + *(.eh_frame) + + KEEP (*(.init)) + KEEP (*(.fini)) + + . = ALIGN(8); + _etext = .; /* define a global symbols at end of code */ + } >FLASH + + /* Constant data goes into FLASH */ + .rodata : + { + . = ALIGN(8); + *(.rodata) /* .rodata sections (constants, strings, etc.) */ + *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ + . = ALIGN(8); + } >FLASH + + .ARM.extab : + { + . = ALIGN(8); + *(.ARM.extab* .gnu.linkonce.armextab.*) + . = ALIGN(8); + } >FLASH + .ARM : { + . = ALIGN(8); + __exidx_start = .; + *(.ARM.exidx*) + __exidx_end = .; + . = ALIGN(8); + } >FLASH + + .preinit_array : + { + . = ALIGN(8); + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP (*(.preinit_array*)) + PROVIDE_HIDDEN (__preinit_array_end = .); + . = ALIGN(8); + } >FLASH + + .init_array : + { + . = ALIGN(8); + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array*)) + PROVIDE_HIDDEN (__init_array_end = .); + . = ALIGN(8); + } >FLASH + .fini_array : + { + . = ALIGN(8); + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array*)) + PROVIDE_HIDDEN (__fini_array_end = .); + . = ALIGN(8); + } >FLASH + + /* used by the startup to initialize data */ + _sidata = LOADADDR(.data); + + /* Initialized data sections goes into RAM, load LMA copy after code */ + .data : + { + . = ALIGN(8); + _sdata = .; /* create a global symbol at data start */ + *(.data) /* .data sections */ + *(.data*) /* .data* sections */ + + . = ALIGN(8); + _edata = .; /* define a global symbol at data end */ + } >RAM AT> FLASH + + + /* Uninitialized data section */ + . = ALIGN(4); + .bss : + { + /* This is used by the startup in order to initialize the .bss secion */ + _sbss = .; /* define a global symbol at bss start */ + __bss_start__ = _sbss; + *(.bss) + *(.bss*) + *(COMMON) + + . = ALIGN(4); + _ebss = .; /* define a global symbol at bss end */ + __bss_end__ = _ebss; + } >RAM + + /* User_heap_stack section, used to check that there is enough RAM left */ + ._user_heap_stack : + { + . = ALIGN(8); + PROVIDE ( end = . ); + PROVIDE ( _end = . ); + . = . + _Min_Heap_Size; + . = . + _Min_Stack_Size; + . = ALIGN(8); + } >RAM + + + + /* Remove information from the standard libraries */ + /DISCARD/ : + { + libc.a ( * ) + libm.a ( * ) + libgcc.a ( * ) + } + + .ARM.attributes 0 : { *(.ARM.attributes) } +} + + diff --git a/STM32Make.make b/STM32Make.make index 755049e..e8cb444 100644 --- a/STM32Make.make +++ b/STM32Make.make @@ -110,7 +110,7 @@ PREFIX = arm-none-eabi- POSTFIX = " # The gcc compiler bin path can be either defined in make command via GCC_PATH variable (> make GCC_PATH=xxx) # either it can be added to the PATH environment variable. -GCC_PATH="c:/Users/pique_n/AppData/Roaming/Code/User/globalStorage/bmd.stm32-for-vscode/@xpack-dev-tools/arm-none-eabi-gcc/10.3.1-2.3.1/.content/bin +GCC_PATH="c:/Users/pique_n/AppData/Roaming/Code/User/globalStorage/bmd.stm32-for-vscode/@xpack-dev-tools/arm-none-eabi-gcc/11.3.1-1.1.2/.content/bin ifdef GCC_PATH CXX = $(GCC_PATH)/$(PREFIX)g++$(POSTFIX) CC = $(GCC_PATH)/$(PREFIX)gcc$(POSTFIX) @@ -262,13 +262,13 @@ $(BUILD_DIR): # flash ####################################### flash: $(BUILD_DIR)/$(TARGET).elf - "C:/USERS/PIQUE_N/APPDATA/ROAMING/CODE/USER/GLOBALSTORAGE/BMD.STM32-FOR-VSCODE/@XPACK-DEV-TOOLS/OPENOCD/0.11.0-2.1/.CONTENT/BIN/OPENOCD.EXE" -f ./openocd.cfg -c "program $(BUILD_DIR)/$(TARGET).elf verify reset exit" + "C:/USERS/PIQUE_N/APPDATA/ROAMING/CODE/USER/GLOBALSTORAGE/BMD.STM32-FOR-VSCODE/@XPACK-DEV-TOOLS/OPENOCD/0.11.0-5.1/.CONTENT/BIN/OPENOCD.EXE" -f ./openocd.cfg -c "program $(BUILD_DIR)/$(TARGET).elf verify reset exit" ####################################### # erase ####################################### erase: $(BUILD_DIR)/$(TARGET).elf - "C:/USERS/PIQUE_N/APPDATA/ROAMING/CODE/USER/GLOBALSTORAGE/BMD.STM32-FOR-VSCODE/@XPACK-DEV-TOOLS/OPENOCD/0.11.0-2.1/.CONTENT/BIN/OPENOCD.EXE" -f ./openocd.cfg -c "init; reset halt; stm32l4x mass_erase 0; exit" + "C:/USERS/PIQUE_N/APPDATA/ROAMING/CODE/USER/GLOBALSTORAGE/BMD.STM32-FOR-VSCODE/@XPACK-DEV-TOOLS/OPENOCD/0.11.0-5.1/.CONTENT/BIN/OPENOCD.EXE" -f ./openocd.cfg -c "init; reset halt; stm32l4x mass_erase 0; exit" ####################################### # clean up