diff --git a/README.md b/README.md index 645dfc367..db770f0d2 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,8 @@ Please add your name to the list below in your first Pull Request! * Kale F. * Marko V. * Vaibhav K. -* Muhammad Ali. +* Muhammad Ali +* Saksham P. * Alex O. * Fardin M. diff --git a/docs/Non-Critical_Notes/Configuration_Variables.md b/docs/Non-Critical_Notes/Configuration_Variables.md index 2d595bef0..adcee3874 100644 --- a/docs/Non-Critical_Notes/Configuration_Variables.md +++ b/docs/Non-Critical_Notes/Configuration_Variables.md @@ -18,10 +18,11 @@ **3) `CONFIG_int_config_variables_count`**: The number of integer configuration variables in the `CONFIG_int_config_variables[]` array. -**4) `CONFIG_str_config_variables_count`**: +**4) `CONFIG_str_config_variables_count`**: The number of string configuration variables in the `CONFIG_str_config_variables[]` array. ---- +**5) `TCMD_require_unique_tssent`**: +A boolean value set to either 0 or 1. A value of 1 indicates that timestamps (usage of `@tssent`) are required, and a value of 0 indicates that timestamps are not required. ## Configuration Variable Arrays diff --git a/firmware/.mxproject b/firmware/.mxproject index 4072764d6..3b995b8c5 100644 --- a/firmware/.mxproject +++ b/firmware/.mxproject @@ -1,5 +1,5 @@ [PreviousLibFiles] -LibFiles=Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_crc.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_crc_ex.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_crc.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_rcc.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_rcc_ex.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_bus.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_rcc.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_crs.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_system.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_utils.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_ll_gpio.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_dma.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_dma_ex.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_dma.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_dmamux.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_ll_pwr.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_cortex.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_cortex.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_exti.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_exti.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_i2c.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_uart.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_usart.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_lpuart.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_uart_ex.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_spi.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_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;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_tim.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_crc.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_crc_ex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.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_i2c.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c_ex.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_uart.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart_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/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_crc.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_crc_ex.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_crc.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_rcc.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_rcc_ex.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_bus.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_rcc.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_crs.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_system.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_utils.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_ll_gpio.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_dma.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_dma_ex.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_dma.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_dmamux.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_ll_pwr.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_cortex.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_cortex.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_exti.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_exti.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_i2c.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_uart.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_usart.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_lpuart.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_uart_ex.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_spi.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_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;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_tim.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/stm32l4r5xx.h;Drivers/CMSIS/Device/ST/STM32L4xx/Include/stm32l4xx.h;Drivers/CMSIS/Device/ST/STM32L4xx/Include/system_stm32l4xx.h;Drivers/CMSIS/Device/ST/STM32L4xx/Include/system_stm32l4xx.h;Drivers/CMSIS/Device/ST/STM32L4xx/Source/Templates/system_stm32l4xx.c;Drivers/CMSIS/Include/core_cm1.h;Drivers/CMSIS/Include/tz_context.h;Drivers/CMSIS/Include/core_armv81mml.h;Drivers/CMSIS/Include/cmsis_version.h;Drivers/CMSIS/Include/core_armv8mbl.h;Drivers/CMSIS/Include/cmsis_armclang_ltm.h;Drivers/CMSIS/Include/core_cm35p.h;Drivers/CMSIS/Include/core_cm7.h;Drivers/CMSIS/Include/core_cm0.h;Drivers/CMSIS/Include/mpu_armv8.h;Drivers/CMSIS/Include/mpu_armv7.h;Drivers/CMSIS/Include/core_cm0plus.h;Drivers/CMSIS/Include/core_cm23.h;Drivers/CMSIS/Include/cmsis_iccarm.h;Drivers/CMSIS/Include/cmsis_armclang.h;Drivers/CMSIS/Include/core_cm33.h;Drivers/CMSIS/Include/core_cm4.h;Drivers/CMSIS/Include/cmsis_gcc.h;Drivers/CMSIS/Include/core_sc300.h;Drivers/CMSIS/Include/core_armv8mml.h;Drivers/CMSIS/Include/cmsis_armcc.h;Drivers/CMSIS/Include/core_sc000.h;Drivers/CMSIS/Include/core_cm3.h;Drivers/CMSIS/Include/cmsis_compiler.h; +LibFiles=Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_tim.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_tim_ex.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_crc.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_crc_ex.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_crc.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_rcc.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_rcc_ex.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_bus.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_rcc.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_crs.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_system.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_utils.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_ll_gpio.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_dma.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_dma_ex.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_dma.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_dmamux.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_ll_pwr.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_cortex.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_cortex.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_exti.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_exti.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_i2c.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_uart.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_usart.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_lpuart.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_uart_ex.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_spi.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_spi.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_spi_ex.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_tim.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_tim.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim_ex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_crc.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_crc_ex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.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_i2c.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c_ex.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_uart.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart_ex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_spi.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_spi_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_tim.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_tim_ex.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_crc.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_crc_ex.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_crc.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_rcc.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_rcc_ex.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_bus.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_rcc.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_crs.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_system.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_utils.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_ll_gpio.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_dma.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_dma_ex.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_dma.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_dmamux.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_ll_pwr.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_cortex.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_cortex.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_exti.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_exti.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_i2c.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_uart.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_usart.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_lpuart.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_uart_ex.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_spi.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_spi.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_spi_ex.h;Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_tim.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/stm32l4r5xx.h;Drivers/CMSIS/Device/ST/STM32L4xx/Include/stm32l4xx.h;Drivers/CMSIS/Device/ST/STM32L4xx/Include/system_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;Core/Src/stm32l4xx_hal_timebase_tim.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.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_i2c.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c_ex.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_uart.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart_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.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_i2c.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c_ex.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_uart.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart_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; @@ -7,7 +7,7 @@ HeaderPath=Drivers/STM32L4xx_HAL_Driver/Inc;Drivers/STM32L4xx_HAL_Driver/Inc/Leg CDefines=USE_HAL_DRIVER;STM32L4R5xx;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;Core/Src/stm32l4xx_hal_timebase_tim.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_crc.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_crc_ex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.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_i2c.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c_ex.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_uart.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart_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_crc.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_crc_ex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.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_i2c.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c_ex.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_uart.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart_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; +SourceFiles=Core/Src/main.c;Core/Src/freertos.c;Core/Src/stm32l4xx_it.c;Core/Src/stm32l4xx_hal_msp.c;Core/Src/stm32l4xx_hal_timebase_tim.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim_ex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_crc.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_crc_ex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.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_i2c.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c_ex.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_uart.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart_ex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_spi.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_spi_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_tim.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim_ex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_crc.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_crc_ex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.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_i2c.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c_ex.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_uart.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart_ex.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_spi.c;Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_spi_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;STM32L4R5xx;USE_HAL_DRIVER;USE_HAL_DRIVER; diff --git a/firmware/CTS-SAT-1_FW.ioc b/firmware/CTS-SAT-1_FW.ioc index 49b77f221..ac99d6cb9 100644 --- a/firmware/CTS-SAT-1_FW.ioc +++ b/firmware/CTS-SAT-1_FW.ioc @@ -155,6 +155,7 @@ NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false NVIC.DMA1_Channel1_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true\:true NVIC.DMA1_Channel2_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.EXTI9_5_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true NVIC.ForceEnableDMAVector=true NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false NVIC.LPUART1_IRQn=true\:4\:0\:true\:false\:true\:false\:true\:true\:true @@ -214,7 +215,7 @@ PA4.Signal=GPIO_Input PA6.GPIOParameters=GPIO_Label PA6.GPIO_Label=PIN_GPS_PPS_IN PA6.Locked=true -PA6.Signal=GPIO_Input +PA6.Signal=GPXTI6 PA9.GPIOParameters=GPIO_Label PA9.GPIO_Label=PIN_MPI_MOSI_USART1_TX PA9.Locked=true @@ -502,6 +503,8 @@ RCC.VCOInputFreq_Value=16000000 RCC.VCOOutputFreq_Value=192000000 RCC.VCOSAI1OutputFreq_Value=128000000 RCC.VCOSAI2OutputFreq_Value=128000000 +SH.GPXTI6.0=GPIO_EXTI6 +SH.GPXTI6.ConfNb=1 SPI1.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_8 SPI1.CalculateBaudRate=2.0 MBits/s SPI1.DataSize=SPI_DATASIZE_8BIT diff --git a/firmware/Core/Inc/config/configuration.h b/firmware/Core/Inc/config/configuration.h index 92704fd27..88e1adcb6 100644 --- a/firmware/Core/Inc/config/configuration.h +++ b/firmware/Core/Inc/config/configuration.h @@ -35,6 +35,9 @@ extern CONFIG_string_config_entry_t CONFIG_str_config_variables[]; // extern extern const uint8_t CONFIG_str_config_variables_count; +// extern +extern uint32_t TCMD_require_unique_tssent; + int16_t CONFIG_get_int_var_index(const char *search_name); int16_t CONFIG_get_str_var_index(const char *search_name); diff --git a/firmware/Core/Inc/config/static_config.h b/firmware/Core/Inc/config/static_config.h index 73365c9da..96c51f1b0 100644 --- a/firmware/Core/Inc/config/static_config.h +++ b/firmware/Core/Inc/config/static_config.h @@ -8,8 +8,4 @@ /// Default: 0 (disabled) static const uint8_t FLASH_enable_hot_path_debug_logs = 0; -/// Whether to enable hot-path debug success logging in the LittleFS drivers. -/// Default: 0 (disabled) -static const uint8_t LFS_enable_hot_path_debug_logs = 0; - -#endif /* INCLUDE_GUARD__STATIC_CONFIG_H__ */ +#endif /* __INCLUDE_GUARD__STATIC_CONFIG_H__ */ diff --git a/firmware/Core/Inc/gpio_handler/gpio_handler.h b/firmware/Core/Inc/gpio_handler/gpio_handler.h new file mode 100644 index 000000000..ed70c5bb7 --- /dev/null +++ b/firmware/Core/Inc/gpio_handler/gpio_handler.h @@ -0,0 +1,11 @@ + +#ifndef __INCLUDE_GUARD__GPIO_HANDLER_H +#define __INCLUDE_GUARD__GPIO_HANDLER_H + +#include "stm32l4xx_hal.h" +#include "main.h" + +extern uint32_t GPS_pps_counter; + +void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin); +#endif diff --git a/firmware/Core/Inc/gps/gps_internal_drivers.h b/firmware/Core/Inc/gps/gps_internal_drivers.h new file mode 100644 index 000000000..f23e009b4 --- /dev/null +++ b/firmware/Core/Inc/gps/gps_internal_drivers.h @@ -0,0 +1,11 @@ + +#ifndef INCLUDE_GUARD__GPS_INTERNAL_DRIVERS_H__ +#define INCLUDE_GUARD__GPS_INTERNAL_DRIVERS_H__ + +#include + +uint8_t GPS_send_cmd_get_response(const char *cmd_buf, uint8_t cmd_buf_len, uint8_t rx_buf[], + uint16_t rx_buf_len, const uint16_t rx_buf_max_size); + + +#endif /* INCLUDE_GUARD__GPS_INTERNAL_DRIVERS_H__ */ \ No newline at end of file diff --git a/firmware/Core/Inc/gps/gps_pps_interrupt.h b/firmware/Core/Inc/gps/gps_pps_interrupt.h new file mode 100644 index 000000000..2b50dab3c --- /dev/null +++ b/firmware/Core/Inc/gps/gps_pps_interrupt.h @@ -0,0 +1,12 @@ + +#ifndef __INCLUDE_GUARD__GPS_PPS_INTERRUPT_H +#define __INCLUDE_GUARD__GPS_PPS_INTERRUPT_H + +#include "stm32l4xx_hal.h" +#include "gpio_handler/gpio_handler.h" + +void GPIO_EXTI_Init(void); + +void Disable_GPIO_EXTI(void); + +#endif // __INCLUDE_GUARD__GPS_PPS_INTERRUPT_H \ No newline at end of file diff --git a/firmware/Core/Inc/littlefs/littlefs_helper.h b/firmware/Core/Inc/littlefs/littlefs_helper.h index 8a824cfd2..a753f9f93 100644 --- a/firmware/Core/Inc/littlefs/littlefs_helper.h +++ b/firmware/Core/Inc/littlefs/littlefs_helper.h @@ -20,13 +20,17 @@ extern struct lfs_config LFS_cfg; extern struct lfs_file_config LFS_file_cfg; extern uint8_t LFS_is_lfs_mounted; +/// @brief The maximum path length supported by CTS-SAT-1, including the null terminator. +/// @note LittleFS supports up to 255 bytes by default, but we'll restrict a bit under. +static const uint16_t LFS_MAX_PATH_LENGTH = 250; + /*---------------------------FUNCTIONS---------------------------*/ int8_t LFS_format(); int8_t LFS_mount(); int8_t LFS_unmount(); -int8_t LFS_list_directory(const char root_directory[]); -int8_t LFS_delete_file(const char file_name[]); +int8_t LFS_list_directory(const char root_directory[], uint16_t offset, int16_t count); int8_t LFS_make_directory(const char dir_name[]); +int8_t LFS_delete_file(const char file_name[]); int8_t LFS_write_file(const char file_name[], uint8_t *write_buffer, uint32_t write_buffer_len); int8_t LFS_append_file(const char file_name[], uint8_t *write_buffer, uint32_t write_buffer_len); lfs_ssize_t LFS_read_file(const char file_name[], lfs_soff_t offset, uint8_t *read_buffer, uint32_t read_buffer_len); diff --git a/firmware/Core/Inc/main.h b/firmware/Core/Inc/main.h index f88c667bd..e765fb682 100644 --- a/firmware/Core/Inc/main.h +++ b/firmware/Core/Inc/main.h @@ -109,6 +109,7 @@ void Error_Handler(void); #define PIN_BOOM_PGOOD_IN_GPIO_Port GPIOA #define PIN_GPS_PPS_IN_Pin GPIO_PIN_6 #define PIN_GPS_PPS_IN_GPIO_Port GPIOA +#define PIN_GPS_PPS_IN_EXTI_IRQn EXTI9_5_IRQn #define PIN_GPS_MOSI_USART3_TX_Pin GPIO_PIN_4 #define PIN_GPS_MOSI_USART3_TX_GPIO_Port GPIOC #define PIN_GPS_MISO_USART3_RX_Pin GPIO_PIN_5 diff --git a/firmware/Core/Inc/stm32l4xx_it.h b/firmware/Core/Inc/stm32l4xx_it.h index 5ba834d51..2723464d0 100644 --- a/firmware/Core/Inc/stm32l4xx_it.h +++ b/firmware/Core/Inc/stm32l4xx_it.h @@ -54,6 +54,7 @@ void UsageFault_Handler(void); void DebugMon_Handler(void); void DMA1_Channel1_IRQHandler(void); void DMA1_Channel2_IRQHandler(void); +void EXTI9_5_IRQHandler(void); void TIM1_UP_TIM16_IRQHandler(void); void USART2_IRQHandler(void); void USART3_IRQHandler(void); diff --git a/firmware/Core/Inc/telecommands/gps_telecommand_defs.h b/firmware/Core/Inc/telecommands/gps_telecommand_defs.h new file mode 100644 index 000000000..4f2943346 --- /dev/null +++ b/firmware/Core/Inc/telecommands/gps_telecommand_defs.h @@ -0,0 +1,14 @@ +#ifndef __INCLUDE_GUARD__GPS_TELECOMMAND_DEFS_H +#define __INCLUDE_GUARD__GPS_TELECOMMAND_DEFS_H + +#include "telecommands/telecommand_types.h" + +#include + +uint8_t TCMDEXEC_gps_send_cmd_ascii(const char *args_str, TCMD_TelecommandChannel_enum_t tcmd_channel, + char *response_output_buf, uint16_t response_output_buf_len); + +uint8_t TCMDEXEC_gps_set_enabled_pps_tracking(const char *args_str, TCMD_TelecommandChannel_enum_t tcmd_channel, + char *response_output_buf, uint16_t response_output_buf_len); + +#endif // __INCLUDE_GUARD__GPS_TELECOMMAND_DEFINITIONS_H diff --git a/firmware/Core/Inc/telecommands/lfs_telecommand_defs.h b/firmware/Core/Inc/telecommands/lfs_telecommand_defs.h index 75fd28760..43a54e79f 100644 --- a/firmware/Core/Inc/telecommands/lfs_telecommand_defs.h +++ b/firmware/Core/Inc/telecommands/lfs_telecommand_defs.h @@ -14,7 +14,13 @@ uint8_t TCMDEXEC_fs_mount(const char *args_str, TCMD_TelecommandChannel_enum_t t uint8_t TCMDEXEC_fs_unmount(const char *args_str, TCMD_TelecommandChannel_enum_t tcmd_channel, char *response_output_buf, uint16_t response_output_buf_len); -uint8_t TCMDEXEC_fs_write_file(const char *args_str, TCMD_TelecommandChannel_enum_t tcmd_channel, +uint8_t TCMDEXEC_fs_list_directory(const char *args_str, TCMD_TelecommandChannel_enum_t tcmd_channel, + char *response_output_buf, uint16_t response_output_buf_len); + +uint8_t TCMDEXEC_fs_make_directory(const char *args_str, TCMD_TelecommandChannel_enum_t tcmd_channel, + char *response_output_buf, uint16_t response_output_buf_len); + +uint8_t TCMDEXEC_fs_write_file_str(const char *args_str, TCMD_TelecommandChannel_enum_t tcmd_channel, char *response_output_buf, uint16_t response_output_buf_len); uint8_t TCMDEXEC_fs_read_file_hex(const char *args_str, TCMD_TelecommandChannel_enum_t tcmd_channel, diff --git a/firmware/Core/Inc/uart_handler/uart_handler.h b/firmware/Core/Inc/uart_handler/uart_handler.h index baadfef4a..a3625eae7 100644 --- a/firmware/Core/Inc/uart_handler/uart_handler.h +++ b/firmware/Core/Inc/uart_handler/uart_handler.h @@ -21,7 +21,15 @@ extern volatile uint8_t UART_mpi_rx_last_byte; // Last received byte from the MP extern volatile uint32_t UART_mpi_rx_last_byte_write_time_ms; // Last write time in milliseconds for MPI response extern volatile uint16_t UART_mpi_rx_buffer_write_idx; // Write index for MPI response buffer +extern const uint16_t UART_gps_buffer_len; +extern volatile uint8_t UART_gps_buffer[]; +extern volatile uint16_t UART_gps_buffer_write_idx; +extern volatile uint32_t UART_gps_last_write_time_ms; +extern volatile uint8_t UART_gps_buffer_last_rx_byte; +extern volatile uint8_t UART_gps_uart_interrupt_enabled; // Flag to enable or disable the UART GPS ISR + void UART_init_uart_handlers(void); +void GPS_set_uart_interrupt_state(uint8_t new_enabled) ; #endif // INCLUDE_GUARD__UART_HANDLER_H__ diff --git a/firmware/Core/Src/config/configuration.c b/firmware/Core/Src/config/configuration.c index 91af6e709..0fdd4f771 100644 --- a/firmware/Core/Src/config/configuration.c +++ b/firmware/Core/Src/config/configuration.c @@ -11,6 +11,8 @@ uint32_t CONFIG_int_demo_var_1 = 13345; uint32_t CONFIG_int_demo_var_2 = 242344; // extern +// 1 = require, 0 = don't require +uint32_t TCMD_require_unique_tssent = 0; /// @brief The percentage of the stack space that should remain free. If the free space falls /// below this percentage, a warning will be logged. @@ -35,6 +37,10 @@ CONFIG_integer_config_entry_t CONFIG_int_config_variables[] = { .variable_name = "TCMD_require_valid_sha256", .num_config_var = &TCMD_require_valid_sha256, }, + { + .variable_name = "TCMD_require_unique_tssent", + .num_config_var = &TCMD_require_unique_tssent, + }, }; // extern diff --git a/firmware/Core/Src/gpio_handler/gpio_handler.c b/firmware/Core/Src/gpio_handler/gpio_handler.c new file mode 100644 index 000000000..2cda6a570 --- /dev/null +++ b/firmware/Core/Src/gpio_handler/gpio_handler.c @@ -0,0 +1,19 @@ + +#include "gpio_handler/gpio_handler.h" +#include "log/log.h" +#include "timekeeping/timekeeping.h" +#include +#include +#include +uint32_t GPS_pps_counter = 0; +uint64_t GPS_last_pps_time = 0; + +void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) { + if (GPIO_Pin != PIN_GPS_PPS_IN_Pin) { + return; + } + if (TIM_get_current_unix_epoch_time_ms() - GPS_last_pps_time > 800 && HAL_GPIO_ReadPin(PIN_GPS_PPS_IN_GPIO_Port, PIN_GPS_PPS_IN_Pin) == GPIO_PIN_SET) { + GPS_last_pps_time = TIM_get_current_unix_epoch_time_ms(); + GPS_pps_counter++; + } +} \ No newline at end of file diff --git a/firmware/Core/Src/gps/gps_internal_drivers.c b/firmware/Core/Src/gps/gps_internal_drivers.c new file mode 100644 index 000000000..b45fac78f --- /dev/null +++ b/firmware/Core/Src/gps/gps_internal_drivers.c @@ -0,0 +1,135 @@ +#include "main.h" + +#include "debug_tools/debug_uart.h" +#include "debug_tools/debug_i2c.h" +#include "gps/gps_internal_drivers.h" +#include "uart_handler/uart_handler.h" +#include "stm_drivers/timing_helpers.h" +#include "uart_handler/uart_handler.h" +#include "log/log.h" + +#include +#include + +extern UART_HandleTypeDef *UART_gps_port_handle; + +const uint32_t GPS_RX_TIMEOUT_BEFORE_FIRST_BYTE_MS = 800; +const uint32_t GPS_RX_TIMEOUT_BETWEEN_BYTES_MS = 800; + +/// @brief Sends a log command to the GPS, and receives the response. +/// @param cmd_buf log command string to send to the GPS. +/// @param cmd_buf_len Exact length of the log command string. +/// @param rx_buf Buffer to store the response. +/// @param rx_buf_len Length of the response buffer. +/// @param rx_buf_max_size Maximum length of the response buffer. +/// @return 0 on success, >0 if error. +/// @note This function is intended for "once" log commands +uint8_t GPS_send_cmd_get_response(const char *cmd_buf, uint8_t cmd_buf_len, uint8_t rx_buf[], uint16_t rx_buf_len, const uint16_t rx_buf_max_size) +{ + + // Reset the GPS UART interrupt variables + GPS_set_uart_interrupt_state(0); // Lock writing to the UART_gps_buffer while we memset it + for (uint16_t i = 0; i < UART_gps_buffer_len; i++) + { + // Clear the buffer + // Can't use memset because UART_gps_buffer is volatile + UART_gps_buffer[i] = 0; + } + UART_gps_buffer_write_idx = 0; // Make it start writing from the start + + // TX TO GPS + const HAL_StatusTypeDef tx_status = HAL_UART_Transmit( + UART_gps_port_handle, + (uint8_t *)cmd_buf, + cmd_buf_len, + 100); + + if (tx_status != HAL_OK) + { + LOG_message( + LOG_SYSTEM_GPS, LOG_SEVERITY_WARNING, LOG_SINK_ALL, + "GPS ERROR: tx_status != HAL_OK (%d)\n", + tx_status); + + return 1; + } + + GPS_set_uart_interrupt_state(1); // We are now expecting a response + + // FIXME: Update the timeouts with the actual times, it currently works with 800 ms and 500ms does not work + // GPS takes time to respond, first section of log response ie GPS_RX_TIMEOUT_BEFORE_FIRST_BYTE_MS) { + LOG_message( + LOG_SYSTEM_GPS, LOG_SEVERITY_WARNING, LOG_SINK_ALL, + "GPS ERROR: Timeout before receiving any data" + ); + + // Disable the UART gps channel + GPS_set_uart_interrupt_state(0); + + // fatal error; return + return 2; + } + } + else { // thus, UART_eps_buffer_write_idx > 0 + // Check if we've timed out (between bytes) + const uint32_t cur_time = HAL_GetTick(); + // Note: Sometimes, because ISRs and C are fun, the UART_eps_last_write_time_ms is + // greater than `cur_time`. Thus, we must do a safety check that the time difference + // is positive. + if ( + (cur_time > UART_gps_last_write_time_ms) // Important seemingly-obvious safety check. + && ((cur_time - UART_gps_last_write_time_ms) > GPS_RX_TIMEOUT_BETWEEN_BYTES_MS) + ) { + LOG_message( + LOG_SYSTEM_GPS, LOG_SEVERITY_WARNING, LOG_SINK_ALL, + "GPS WARNING: Timeout during receiving of response. UART_gps_last_write_time_ms=%lu, cur_time=%lu", + UART_gps_last_write_time_ms, + cur_time + ); + // Non-fatal error; try to parse what we received + break; + } + } + } + + // End Receiving + GPS_set_uart_interrupt_state(0); // We are no longer expecting a response + + // Logging the received response + LOG_message( + LOG_SYSTEM_GPS, LOG_SEVERITY_NORMAL, LOG_SINK_ALL, + "GPS Buffer Data: %s", + UART_gps_buffer + ); + + // Check that we've received what we're expecting + // TODO: If the following cases happen ever during testing, consider allowing them and treating them as WARNINGs + if (UART_gps_buffer_write_idx > rx_buf_max_size) + { + LOG_message( + LOG_SYSTEM_GPS, LOG_SEVERITY_WARNING, LOG_SINK_ALL, + "GPS ERROR: UART_gps_buffer overflow"); + return 3; + } + + // Copy the log response from the UART gps buffer to the rx_buf[] and clear the buffer + for (uint16_t i = 0; i < UART_gps_buffer_write_idx; i++) { + rx_buf[i] = UART_gps_buffer[i]; + } + + LOG_message( + LOG_SYSTEM_GPS, LOG_SEVERITY_NORMAL, LOG_SINK_ALL, + "rx_buf: %s", + rx_buf + ); + + return 0; +} diff --git a/firmware/Core/Src/gps/gps_pps_interrupt.c b/firmware/Core/Src/gps/gps_pps_interrupt.c new file mode 100644 index 000000000..cd4e518ce --- /dev/null +++ b/firmware/Core/Src/gps/gps_pps_interrupt.c @@ -0,0 +1,14 @@ +#include "stm32l4xx_hal.h" +#include "gps/gps_pps_interrupt.h" + +#include "main.h" + +void GPIO_EXTI_Init(void) { + HAL_NVIC_SetPriority(EXTI9_5_IRQn, 0, 0); + HAL_NVIC_EnableIRQ(EXTI9_5_IRQn); +} + +void Disable_GPIO_EXTI(void) { + GPS_pps_counter = 0; + HAL_NVIC_DisableIRQ(EXTI9_5_IRQn); +} diff --git a/firmware/Core/Src/littlefs/flash_driver.c b/firmware/Core/Src/littlefs/flash_driver.c index 71e5b017a..8d59be1fb 100644 --- a/firmware/Core/Src/littlefs/flash_driver.c +++ b/firmware/Core/Src/littlefs/flash_driver.c @@ -87,16 +87,15 @@ void FLASH_deactivate_chip_select() HAL_GPIO_WritePin(PIN_MEM_NCS_FRAM_1_GPIO_Port, PIN_MEM_NCS_FRAM_1_Pin, GPIO_PIN_SET); } -/** - * @brief Unblocks all blocked blocks of memory on the NAND flash memory module - * - * @param hspi - Pointer to the SPI HAL handle - * @param chip_number - the chip select number to activate - * @param buf - Pointer to a buffer to store the new Block Lock Register value. Length: 1 byte. - * @return FLASH_ERR_OK on success, < 0 on failure - * - * @note unblocking blocks of memory is necessary to write to memory - */ +/// @brief Unblocks all blocked blocks of memory on the NAND flash memory module +/// +/// @param hspi - Pointer to the SPI HAL handle +/// @param chip_number - the chip select number to activate +/// @param buf - Pointer to a buffer to store the new Block Lock Register value. Length: 1 byte. +/// @return FLASH_ERR_OK on success, < 0 on failure +/// +/// @note unblocking blocks of memory is necessary to write to memory + FLASH_error_enum_t FLASH_unblock_block_lock(SPI_HandleTypeDef *hspi, uint8_t chip_number, uint8_t *buf) { static const uint8_t data_bytes = 0x00; @@ -160,13 +159,12 @@ FLASH_error_enum_t FLASH_unblock_block_lock(SPI_HandleTypeDef *hspi, uint8_t chi return FLASH_ERR_OK; } -/** - * @brief Read Status Register and store the values in given buffer - * @param hspi - Pointer to the SPI HAL handle - * @param chip_number - the chip select number to activate - * @param buf - Pointer to a buffer to store SR1 value. Length: 1 byte. - * @retval FLASH_ERR_OK on success, < 0 on failure - */ +/// @brief Read Status Register and store the values in given buffer +/// @param hspi - Pointer to the SPI HAL handle +/// @param chip_number - the chip select number to activate +/// @param buf - Pointer to a buffer to store SR1 value. Length: 1 byte. +/// @retval FLASH_ERR_OK on success, < 0 on failure + FLASH_error_enum_t FLASH_read_status_register(SPI_HandleTypeDef *hspi, uint8_t chip_number, uint8_t *buf) { // Send GET FEATURES command @@ -216,13 +214,12 @@ FLASH_error_enum_t FLASH_read_status_register(SPI_HandleTypeDef *hspi, uint8_t c return FLASH_ERR_OK; } -/** - * @brief Read Block Lock Register and store the values in given buffer - * @param hspi - Pointer to the SPI HAL handle - * @param chip_number - the chip select number to activate - * @param buf - Pointer to a buffer to store Block Lock Register value. Length: 1 byte. - * @retval FLASH_ERR_OK on success, < 0 on failure - */ +/// @brief Read Block Lock Register and store the values in given buffer +/// @param hspi - Pointer to the SPI HAL handle +/// @param chip_number - the chip select number to activate +/// @param buf - Pointer to a buffer to store Block Lock Register value. Length: 1 byte. +/// @retval FLASH_ERR_OK on success, < 0 on failure + FLASH_error_enum_t FLASH_read_block_lock_register(SPI_HandleTypeDef *hspi, uint8_t chip_number, uint8_t *buf) { // Send GET FEATURES command @@ -272,12 +269,11 @@ FLASH_error_enum_t FLASH_read_block_lock_register(SPI_HandleTypeDef *hspi, uint8 return FLASH_ERR_OK; } -/** - * @brief Sends Write Enable Command - * @param hspi - Pointer to the SPI HAL handle - * @param chip_number - the chip select number to activate - * @retval FLASH_ERR_OK on success, < 0 on failure - */ +/// @brief Sends Write Enable Command +/// @param hspi - Pointer to the SPI HAL handle +/// @param chip_number - the chip select number to activate +/// @retval FLASH_ERR_OK on success, < 0 on failure + FLASH_error_enum_t FLASH_write_enable(SPI_HandleTypeDef *hspi, uint8_t chip_number) { // Buffer to store status register value @@ -331,12 +327,11 @@ FLASH_error_enum_t FLASH_write_enable(SPI_HandleTypeDef *hspi, uint8_t chip_numb return FLASH_ERR_UNKNOWN; } -/** - * @brief Sends Write Disable Command - * @param hspi - Pointer to the SPI HAL handle - * @param chip_number - the chip select number to activate - * @retval FLASH_ERR_OK on success, < 0 on failure - */ +/// @brief Sends Write Disable Command +/// @param hspi - Pointer to the SPI HAL handle +/// @param chip_number - the chip select number to activate +/// @retval FLASH_ERR_OK on success, < 0 on failure + FLASH_error_enum_t FLASH_write_disable(SPI_HandleTypeDef *hspi, uint8_t chip_number) { // Buffer to store status register value @@ -390,13 +385,12 @@ FLASH_error_enum_t FLASH_write_disable(SPI_HandleTypeDef *hspi, uint8_t chip_num return FLASH_ERR_UNKNOWN; } -/** - * @brief Sends Block Erase Command - * @param hspi - Pointer to the SPI HAL handle - * @param chip_number - the chip select number to activate - * @param page - page number to erase the block the page is contained in - * @retval FLASH_ERR_OK on success, < 0 on failure - */ +/// @brief Sends Block Erase Command +/// @param hspi - Pointer to the SPI HAL handle +/// @param chip_number - the chip select number to activate +/// @param page - page number to erase the block the page is contained in +/// @retval FLASH_ERR_OK on success, < 0 on failure + FLASH_error_enum_t FLASH_erase(SPI_HandleTypeDef *hspi, uint8_t chip_number, lfs_block_t page) { // Split address into its 3 bytes @@ -489,15 +483,14 @@ FLASH_error_enum_t FLASH_erase(SPI_HandleTypeDef *hspi, uint8_t chip_number, lfs return FLASH_ERR_UNKNOWN; } -/** - * @brief Sends Page Program Command - * @param hspi - Pointer to the SPI HAL handle - * @param chip_number - the chip select number to activate - * @param page - page number the data is to be written to - * @param packet_buffer - Pointer to buffer containing data to write - * @param packet_buffer_len - integer that indicates the size of the data to write - * @retval FLASH_ERR_OK on success, < 0 on failure - */ +/// @brief Sends Page Program Command +/// @param hspi - Pointer to the SPI HAL handle +/// @param chip_number - the chip select number to activate +/// @param page - page number the data is to be written to +/// @param packet_buffer - Pointer to buffer containing data to write +/// @param packet_buffer_len - integer that indicates the size of the data to write +/// @retval FLASH_ERR_OK on success, < 0 on failure + FLASH_error_enum_t FLASH_write_data(SPI_HandleTypeDef *hspi, uint8_t chip_number, lfs_block_t page, uint8_t *packet_buffer, lfs_size_t packet_buffer_len) { // Split main address into its 3 bytes @@ -642,15 +635,14 @@ FLASH_error_enum_t FLASH_write_data(SPI_HandleTypeDef *hspi, uint8_t chip_number return FLASH_ERR_UNKNOWN; } -/** - * @brief Sends Page Read Command - * @param hspi - Pointer to the SPI HAL handle - * @param chip_number - The chip select number to activate - * @param page - page number to be read - * @param rx_buffer - A buffer where the read data will be stored - * @param rx_buffer_len - Integer that indicates the capacity of `rx_buffer` - * @retval FLASH_ERR_OK on success, < 0 on failure - */ +/// @brief Sends Page Read Command +/// @param hspi - Pointer to the SPI HAL handle +/// @param chip_number - The chip select number to activate +/// @param page - page number to be read +/// @param rx_buffer - A buffer where the read data will be stored +/// @param rx_buffer_len - Integer that indicates the capacity of `rx_buffer` +/// @retval FLASH_ERR_OK on success, < 0 on failure + FLASH_error_enum_t FLASH_read_data(SPI_HandleTypeDef *hspi, uint8_t chip_number, lfs_block_t page, uint8_t *rx_buffer, lfs_size_t rx_buffer_len) { uint8_t read_addr_bytes[3] = {(page >> 16) & 0xFF, (page >> 8) & 0xFF, page & 0xFF}; @@ -788,12 +780,11 @@ FLASH_error_enum_t FLASH_read_data(SPI_HandleTypeDef *hspi, uint8_t chip_number, return FLASH_ERR_OK; } -/** - * @brief Resets the NAND flash memory module - * @param hspi - Pointer to the SPI HAL handle - * @param chip_number - The chip select number to activate - * @retval FLASH_ERR_OK on success, <0 on failure - */ +/// @brief Resets the NAND flash memory module +/// @param hspi - Pointer to the SPI HAL handle +/// @param chip_number - The chip select number to activate +/// @retval FLASH_ERR_OK on success, <0 on failure + FLASH_error_enum_t FLASH_reset(SPI_HandleTypeDef *hspi, uint8_t chip_number) { FLASH_activate_chip_select(chip_number); @@ -815,12 +806,11 @@ FLASH_error_enum_t FLASH_reset(SPI_HandleTypeDef *hspi, uint8_t chip_number) return FLASH_ERR_OK; } -/** - * @brief Checks if the FLASH chip is reachable by checking it's ID - * @param hspi - Pointer to the SPI HAL handle - * @param chip_number - The chip select number to activate - * @retval FLASH_ERR_OK on success, < 0 on failure - */ +/// @brief Checks if the FLASH chip is reachable by checking it's ID +/// @param hspi - Pointer to the SPI HAL handle +/// @param chip_number - The chip select number to activate +/// @retval FLASH_ERR_OK on success, < 0 on failure + FLASH_error_enum_t FLASH_is_reachable(SPI_HandleTypeDef *hspi, uint8_t chip_number) { // TODO: confirm if this works with the CS2 logical chip on each physical FLASH chip; diff --git a/firmware/Core/Src/littlefs/littlefs_driver.c b/firmware/Core/Src/littlefs/littlefs_driver.c index acca87460..638f67418 100644 --- a/firmware/Core/Src/littlefs/littlefs_driver.c +++ b/firmware/Core/Src/littlefs/littlefs_driver.c @@ -11,11 +11,10 @@ uint8_t LFS_get_chip_number(lfs_block_t block_num) { return 0; } -/** - * @brief LittleFS read function - * @param LittleFS Configurations, Block to write, offset, buffer, buffer size - * @retval int - any error codes that happened in littlefs - */ +/// @brief LittleFS read function +/// @param LittleFS Configurations, Block to write, offset, buffer, buffer size +/// @retval int - any error codes that happened in littlefs + int LFS_block_device_read(const struct lfs_config *c, lfs_block_t block, lfs_off_t off, void *buffer, lfs_size_t size) { return FLASH_read_data( @@ -27,11 +26,10 @@ int LFS_block_device_read(const struct lfs_config *c, lfs_block_t block, lfs_off ); } -/** - * @brief LittleFS write function - * @param LittleFS Configurations, Block to read, offset, buffer, buffer size - * @retval int - any error codes that happened in littlefs - */ +/// @brief LittleFS write function +/// @param LittleFS Configurations, Block to read, offset, buffer, buffer size +/// @retval int - any error codes that happened in littlefs + int LFS_block_device_prog(const struct lfs_config *c, lfs_block_t block, lfs_off_t off, const void *buffer, lfs_size_t size) { return FLASH_write_data( @@ -43,11 +41,10 @@ int LFS_block_device_prog(const struct lfs_config *c, lfs_block_t block, lfs_off ); } -/** - * @brief LittleFS erase function - * @param LittleFS Configurations, Block to erase - * @retval int - any error codes that happened in littlefs - */ +/// @brief LittleFS erase function +/// @param LittleFS Configurations, Block to erase +/// @retval int - any error codes that happened in littlefs + int LFS_block_device_erase(const struct lfs_config *c, lfs_block_t block) { return FLASH_erase( @@ -57,11 +54,10 @@ int LFS_block_device_erase(const struct lfs_config *c, lfs_block_t block) ); } -/** - * @brief LittleFS sync function - * @param c - LittleFS Configuration - * @retval int - 0 since we are not caching reads or writes - */ +/// @brief LittleFS sync function +/// @param c - LittleFS Configuration +/// @retval int - 0 since we are not caching reads or writes + int LFS_block_device_sync(const struct lfs_config *c) { // Per the README: diff --git a/firmware/Core/Src/littlefs/littlefs_helper.c b/firmware/Core/Src/littlefs/littlefs_helper.c index cca4483aa..b2c993650 100644 --- a/firmware/Core/Src/littlefs/littlefs_helper.c +++ b/firmware/Core/Src/littlefs/littlefs_helper.c @@ -1,13 +1,9 @@ - - /*-----------------------------INCLUDES-----------------------------*/ #include #include "littlefs/littlefs_helper.h" #include "littlefs/lfs.h" #include "littlefs/littlefs_driver.h" -#include "debug_tools/debug_uart.h" -#include "config/static_config.h" #include "log/log.h" /*-----------------------------VARIABLES-----------------------------*/ @@ -39,7 +35,7 @@ struct lfs_config LFS_cfg = { // block device configuration .read_size = FLASH_CHIP_PAGE_SIZE_BYTES, .prog_size = FLASH_CHIP_PAGE_SIZE_BYTES, - .block_size = FLASH_CHIP_BLOCK_SIZE_BYTES, // FIXME: Clarify block Size 256KiB or 1KiB + .block_size = FLASH_CHIP_BLOCK_SIZE_BYTES, .block_count = (FLASH_CHIP_SIZE_BYTES / FLASH_CHIP_BLOCK_SIZE_BYTES), .block_cycles = 100, // TODO: ASK ABOUT THIS (HOW FREQUENT ARE WE USING THE MODULE), .cache_size = FLASH_CHIP_PAGE_SIZE_BYTES, @@ -57,60 +53,54 @@ struct lfs_file_config LFS_file_cfg = { // -----------------------------LITTLEFS FUNCTIONS----------------------------- - -/** - * @brief Formats Memory Module so it can successfully mount LittleFS - * @param None - * @retval 0 on success, negative LFS error codes on failure - */ +/// @brief Formats Memory Module so it can successfully mount LittleFS +/// @param None +/// @retval 0 on success, negative LFS error codes on failure + int8_t LFS_format() { - int8_t result = lfs_format(&LFS_filesystem, &LFS_cfg); - if (result < 0) - { - DEBUG_uart_print_str("Error formatting!\n"); - return result; - } - - DEBUG_uart_print_str("Formatting successful!\n"); - return 0; + int8_t format_result = lfs_format(&LFS_filesystem, &LFS_cfg); + if (format_result < 0) { + LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_CRITICAL, LOG_all_sinks_except(LOG_SINK_FILE), "Error formatting FLASH memory!"); + return format_result; + } + + LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_NORMAL, LOG_all_sinks_except(LOG_SINK_FILE), "LittleFS Memory formatting successful!"); + return 0; } -/** - * @brief Mounts LittleFS to the Memory Module - * @param None - * @retval 0 on success, 1 if LFS is already mounted, negative LFS error codes on failure - */ +/// @brief Mounts LittleFS to the Memory Module +/// @param None +/// @retval 0 on success, 1 if LFS is already mounted, negative LFS error codes on failure + int8_t LFS_mount() { - if (LFS_is_lfs_mounted) { - DEBUG_uart_print_str("LittleFS already mounted!\n"); - return 1; - } + if (LFS_is_lfs_mounted) { + LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_WARNING, LOG_all_sinks_except(LOG_SINK_FILE), "LittleFS already mounted!"); + return 1; + } // Variable to store status of LittleFS mounting int8_t mount_result = lfs_mount(&LFS_filesystem, &LFS_cfg); - if (mount_result < 0) - { - DEBUG_uart_print_str("Mounting unsuccessful\n"); + if (mount_result < 0) { + LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_CRITICAL, LOG_all_sinks_except(LOG_SINK_FILE), "Error mounting LittleFS!"); return mount_result; } - DEBUG_uart_print_str("Mounting successful\n"); + LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_NORMAL, LOG_all_sinks_except(LOG_SINK_FILE), "LittleFS mounting successful!"); + LFS_is_lfs_mounted = 1; return 0; } -/** - * @brief Unmounts LittleFS to the Memory Module - * @param None - * @retval 0 on success, 1 if LFS is already unmounted, negative LFS error codes on failure - */ +/// @brief Unmounts LittleFS to the Memory Module +/// @param None +/// @retval 0 on success, 1 if LFS is already unmounted, negative LFS error codes on failure + int8_t LFS_unmount() { - if (!LFS_is_lfs_mounted) - { - DEBUG_uart_print_str("LittleFS not mounted.\n"); + if (!LFS_is_lfs_mounted) { + LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_CRITICAL, LOG_all_sinks_except(LOG_SINK_FILE), "LittleFS not mounted!"); return 1; } @@ -118,131 +108,170 @@ int8_t LFS_unmount() const int8_t unmount_result = lfs_unmount(&LFS_filesystem); if (unmount_result < 0) { - DEBUG_uart_print_str("Error un-mounting.\n"); + LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_CRITICAL, LOG_all_sinks_except(LOG_SINK_FILE), "Error un-mounting LittleFS!"); return unmount_result; } - DEBUG_uart_print_str("Successfully un-mounted LittleFS.\n"); + LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_NORMAL, LOG_all_sinks_except(LOG_SINK_FILE), "LittleFS un-mounting successful!"); LFS_is_lfs_mounted = 0; return 0; } -/** - * @brief Lists contents of LittleFS Directory - * @param root_directory Pointer to cstring holding the root directory to open and read - * @retval 0 on success, 1 if LFS is unmounted, negative LFS error codes on failure - */ -int8_t LFS_list_directory(const char root_directory[]) +/// @brief Lists contents of LittleFS Directory +/// @param root_directory cstring holding the root directory to open and read +/// @param offset Number of entries to skip before listing directory +/// @param count Number of entries to list in total (if 0, prints all entries) +/// @retval 0 on success, 1 if LFS is unmounted, negative LFS error codes on failure + +int8_t LFS_list_directory(const char root_directory[], uint16_t offset, int16_t count) { - if (!LFS_is_lfs_mounted) - { - DEBUG_uart_print_str("LittleFS not mounted.\n"); + // Check if LFS is mounted + if (!LFS_is_lfs_mounted) { + LOG_message( + LOG_SYSTEM_LFS, LOG_SEVERITY_WARNING, LOG_all_sinks_except(LOG_SINK_FILE), + "LittleFS not mounted." + ); return 1; } + // Try to open the directory lfs_dir_t dir; int8_t open_dir_result = lfs_dir_open(&LFS_filesystem, &dir, root_directory); if (open_dir_result < 0) { - DEBUG_uart_print_str("Error opening a directory.\n"); + LOG_message( + LOG_SYSTEM_LFS, LOG_SEVERITY_CRITICAL, LOG_all_sinks_except(LOG_SINK_FILE), + "Error opening directory: %s", root_directory + ); return open_dir_result; } - // result is positive on success, 0 at the end of directory, or negative on failure. + if (count == 0) { + count = -1; + } + + // Result is positive on success, 0 at the end of directory, or negative on failure. int8_t read_dir_result = 1; - while (read_dir_result >= 0) + struct lfs_info info; + LOG_message( + LOG_SYSTEM_LFS, LOG_SEVERITY_NORMAL, LOG_all_sinks_except(LOG_SINK_FILE), "Name (Bytes)" + ); + while (read_dir_result > 0) { - struct lfs_info info; read_dir_result = lfs_dir_read(&LFS_filesystem, &dir, &info); - DEBUG_uart_print_str(info.name); - DEBUG_uart_print_str(", "); - // TODO: The info struct contains information about directory contents + if (read_dir_result < 0) + { + LOG_message( + LOG_SYSTEM_LFS, LOG_SEVERITY_CRITICAL, LOG_all_sinks_except(LOG_SINK_FILE), + "Error reading content from directory: %s", root_directory + ); + break; + } + + if (offset > 0) { + offset--; + continue; + } + + if (count == 0) { + break; + } else { + count--; + } + + if (info.type == LFS_TYPE_REG) + { + LOG_message( + LOG_SYSTEM_LFS, LOG_SEVERITY_NORMAL, LOG_all_sinks_except(LOG_SINK_FILE), + "%s (%ld B)", info.name, info.size + ); + } else if (info.type == LFS_TYPE_DIR){ + LOG_message( + LOG_SYSTEM_LFS, LOG_SEVERITY_NORMAL, LOG_all_sinks_except(LOG_SINK_FILE), + "%s/", info.name + ); + } } - DEBUG_uart_print_str("\n"); - - if (read_dir_result < 0) - { - DEBUG_uart_print_str("Error reading directory contents.\n"); - return read_dir_result; - } - - DEBUG_uart_print_str("Successfully Listed Directory Contents.\n"); int8_t close_dir_result = lfs_dir_close(&LFS_filesystem, &dir); if (close_dir_result < 0) { - DEBUG_uart_print_str("Error closing directory.\n"); + LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_CRITICAL, LOG_all_sinks_except(LOG_SINK_FILE), "Error closing directory: %s", root_directory); return close_dir_result; } - return 0; + if (read_dir_result < 0) { + return read_dir_result; + } else { + LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_NORMAL, LOG_all_sinks_except(LOG_SINK_FILE), "Successfully listed contents from directory: %s", root_directory); + return 0; + } } -/** - * @brief Removes / deletes the file specified - * @param file_name Pointer to cstring holding the file name to remove - * @retval 0 on success, 1 if LFS is unmounted, negative LFS error codes on failure - */ -int8_t LFS_delete_file(const char file_name[]) +/// @brief Creates directory +/// @param dir_name Pointer to cstring holding the name of the directory +/// @retval 0 on success, 1 if LFS is unmounted, negative LFS error codes on failure + +int8_t LFS_make_directory(const char dir_name[]) { if (!LFS_is_lfs_mounted) { - DEBUG_uart_print_str("LittleFS not mounted.\n"); + LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_WARNING, LOG_all_sinks_except(LOG_SINK_FILE), "LittleFS not mounted!"); return 1; } - int8_t remove_result = lfs_remove(&LFS_filesystem, file_name); - if (remove_result < 0) + const int8_t make_dir_result = lfs_mkdir(&LFS_filesystem, dir_name); + if (make_dir_result < 0) { - DEBUG_uart_print_str("Error removing file/directory.\n"); - return remove_result; + if (make_dir_result == LFS_ERR_EXIST) { + LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_WARNING, LOG_all_sinks_except(LOG_SINK_FILE), + "Directory %s already exists.", dir_name); + } else { + LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_WARNING, LOG_all_sinks_except(LOG_SINK_FILE), + "Recieved error: %d while creating directory: %s.", make_dir_result, dir_name); + } + return make_dir_result; } - DEBUG_uart_print_str("Successfully removed file/directory.\n"); + LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_NORMAL, LOG_all_sinks_except(LOG_SINK_FILE), "Successfully created directory: %s", dir_name); return 0; } -/** - * @brief Creates directory - * @param dir_name Pointer to cstring holding the name of the directory - * @retval 0 on success, 1 if LFS is unmounted, negative LFS error codes on failure - */ -int8_t LFS_make_directory(const char dir_name[]) +/// @brief Removes / deletes the file specified +/// @param file_name Pointer to cstring holding the file name to remove +/// @retval 0 on success, 1 if LFS is unmounted, negative LFS error codes on failure + +int8_t LFS_delete_file(const char file_name[]) { if (!LFS_is_lfs_mounted) { - DEBUG_uart_print_str("LittleFS not mounted.\n"); + LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_WARNING, LOG_all_sinks_except(LOG_SINK_FILE), "LittleFS not mounted."); return 1; } - const int8_t make_dir_result = lfs_mkdir(&LFS_filesystem, dir_name); - if (make_dir_result < 0) + int8_t remove_result = lfs_remove(&LFS_filesystem, file_name); + if (remove_result < 0) { - LOG_message( - LOG_SYSTEM_LFS, LOG_SEVERITY_WARNING, LOG_SINK_ALL, - "Error %d creating directory.", - make_dir_result - ); - return make_dir_result; + LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_WARNING, LOG_all_sinks_except(LOG_SINK_FILE), "Error removing file / directory: %s", file_name); + return remove_result; } - DEBUG_uart_print_str("Successfully created directory.\n"); + LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_NORMAL, LOG_all_sinks_except(LOG_SINK_FILE), "Successfully removed file / directory: %s", file_name); return 0; } -/** - * @brief Creates / Opens LittleFS File to write to the Memory Module - * @param file_name - Pointer to cstring holding the file name to create or open - * @param write_buffer - Pointer to buffer holding the data to write - * @param write_buffer_len - Size of the data to write - * @retval 0 on success, 1 if LFS is unmounted, negative LFS error codes on failure - */ +/// @brief Creates / Opens LittleFS File to write to the Memory Module +/// @param file_name - Pointer to cstring holding the file name to create or open +/// @param write_buffer - Pointer to buffer holding the data to write +/// @param write_buffer_len - Size of the data to write +/// @retval 0 on success, 1 if LFS is unmounted, negative LFS error codes on failure + int8_t LFS_write_file(const char file_name[], uint8_t *write_buffer, uint32_t write_buffer_len) { if (!LFS_is_lfs_mounted) { - DEBUG_uart_print_str("LittleFS not mounted.\n"); + LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_WARNING, LOG_all_sinks_except(LOG_SINK_FILE), "LittleFS not mounted."); return 1; } @@ -250,52 +279,42 @@ int8_t LFS_write_file(const char file_name[], uint8_t *write_buffer, uint32_t wr lfs_file_t file; const int8_t open_result = lfs_file_opencfg(&LFS_filesystem, &file, file_name, LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC, &LFS_file_cfg); - if (open_result < 0) - { - DEBUG_uart_print_str("Error opening/creating file.\n"); - return open_result; - } - - if (LFS_enable_hot_path_debug_logs) { - DEBUG_uart_print_str("Opened/created a file named: '"); - DEBUG_uart_print_str(file_name); - DEBUG_uart_print_str("'\n"); - } - - // Write data to file - const int8_t write_result = lfs_file_write(&LFS_filesystem, &file, write_buffer, write_buffer_len); - if (write_result < 0) - { - DEBUG_uart_print_str("Error writing to file!\n"); - return write_result; - } - - if (LFS_enable_hot_path_debug_logs) { - DEBUG_uart_print_str("Successfully wrote data to file!\n"); - } - - // Close the File, the storage is not updated until the file is closed successfully - const int8_t close_result = lfs_file_close(&LFS_filesystem, &file); - if (close_result < 0) - { - DEBUG_uart_print_str("Error closing the file!\n"); - return close_result; - } - - if (LFS_enable_hot_path_debug_logs) { - DEBUG_uart_print_str("Successfully closed the file!\n"); - } - - return 0; + if (open_result < 0) + { + LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_WARNING, LOG_all_sinks_except(LOG_SINK_FILE), "Error opening / creating file: %s", file_name); + return open_result; + } + + LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_NORMAL, LOG_all_sinks_except(LOG_SINK_FILE), "Opened/created file: %s", file_name); + + // Write data to file + const int8_t write_result = lfs_file_write(&LFS_filesystem, &file, write_buffer, write_buffer_len); + if (write_result < 0) + { + LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_WARNING, LOG_all_sinks_except(LOG_SINK_FILE), "Error writing to file: %s", file_name); + return write_result; + } + + // Close the File, the storage is not updated until the file is closed successfully + const int8_t close_result = lfs_file_close(&LFS_filesystem, &file); + if (close_result < 0) + { + LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_WARNING, LOG_all_sinks_except(LOG_SINK_FILE), "Error closing file: %s", file_name); + return close_result; + } + + LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_WARNING, LOG_all_sinks_except(LOG_SINK_FILE), "Successfully closed file: %s", file_name); + LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_WARNING, LOG_all_sinks_except(LOG_SINK_FILE), "Successfully wrote data to file: %s", file_name); + + return 0; } -/** - * @brief Creates / Opens LittleFS File to append contents - * @param file_name - Pointer to cstring holding the file name to create or open - * @param write_buffer - Pointer to buffer holding the data to write - * @param write_buffer_len - Size of the data to write - * @retval 0 on success, 1 if LFS is unmounted, negative LFS error codes on failure - */ +/// @brief Creates / Opens LittleFS File to append contents +/// @param file_name - Pointer to cstring holding the file name to create or open +/// @param write_buffer - Pointer to buffer holding the data to write +/// @param write_buffer_len - Size of the data to write +/// @retval 0 on success, 1 if LFS is unmounted, negative LFS error codes on failure + int8_t LFS_append_file(const char file_name[], uint8_t *write_buffer, uint32_t write_buffer_len) { if (!LFS_is_lfs_mounted) @@ -307,114 +326,114 @@ int8_t LFS_append_file(const char file_name[], uint8_t *write_buffer, uint32_t w lfs_file_t file; const int8_t open_result = lfs_file_opencfg(&LFS_filesystem, &file, file_name, LFS_O_WRONLY | LFS_O_CREAT | LFS_O_APPEND, &LFS_file_cfg); - if (open_result < 0) - { - LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_CRITICAL, LOG_all_sinks_except(LOG_SINK_FILE), "Error opening file"); - return open_result; - } - + if (open_result < 0) + { + LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_CRITICAL, LOG_all_sinks_except(LOG_SINK_FILE), "Error opening file: %s", file_name); + return open_result; + } + const int8_t seek_result = lfs_file_seek(&LFS_filesystem, &file, 0, LFS_SEEK_END); if (seek_result < 0) { - LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_CRITICAL, LOG_all_sinks_except(LOG_SINK_FILE), "Error seeking within file"); + LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_CRITICAL, LOG_all_sinks_except(LOG_SINK_FILE), "Error seeking within file: %s", file_name); return seek_result; } - const int8_t write_result = lfs_file_write(&LFS_filesystem, &file, write_buffer, write_buffer_len); - if (write_result < 0) - { - LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_CRITICAL, LOG_all_sinks_except(LOG_SINK_FILE), "Error writing to file"); - return write_result; - } - - // Close the File, the storage is not updated until the file is closed successfully - const int8_t close_result = lfs_file_close(&LFS_filesystem, &file); - if (close_result < 0) - { - LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_CRITICAL, LOG_all_sinks_except(LOG_SINK_FILE), "Error closing file"); - return close_result; - } - - return 0; + const int8_t write_result = lfs_file_write(&LFS_filesystem, &file, write_buffer, write_buffer_len); + if (write_result < 0) { + LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_CRITICAL, LOG_all_sinks_except(LOG_SINK_FILE), "Error writing to file %s", file_name); + return write_result; + } + + // Close the File, the storage is not updated until the file is closed successfully + const int8_t close_result = lfs_file_close(&LFS_filesystem, &file); + if (close_result < 0) { + LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_CRITICAL, LOG_all_sinks_except(LOG_SINK_FILE), "Error closing file: %s", file_name); + return close_result; + } + + return 0; } -/** - * @brief Opens LittleFS File to read from the Memory Module - * @param file_name - Pointer to buffer holding the file name to open - * @param offset - position within the file to read from - * @param read_buffer - Pointer to buffer where the read data will be stored - * @param read_buffer_len - Size of the data to read - * @retval Returns negative values if read or file open failed, else the - * number of bytes read - */ +/// @brief Opens LittleFS File to read from the Memory Module +/// @param file_name - Pointer to buffer holding the file name to open +/// @param offset - position within the file to read from +/// @param read_buffer - Pointer to buffer where the read data will be stored +/// @param read_buffer_len - Size of the data to read +/// @retval Returns negative values if read or file open failed, else the +/// number of bytes read + lfs_ssize_t LFS_read_file(const char file_name[], lfs_soff_t offset, uint8_t *read_buffer, uint32_t read_buffer_len) { - lfs_file_t file; - const int8_t open_result = lfs_file_opencfg(&LFS_filesystem, &file, file_name, LFS_O_RDONLY, &LFS_file_cfg); - if (open_result < 0) - { + if (!LFS_is_lfs_mounted) + { + LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_CRITICAL, LOG_all_sinks_except(LOG_SINK_FILE), "LittleFS not mounted"); + return 1; + } + + lfs_file_t file; + const int8_t open_result = lfs_file_opencfg(&LFS_filesystem, &file, file_name, LFS_O_RDONLY, &LFS_file_cfg); + if (open_result < 0) + { // TODO: confirm behaviour is desired: this assumes filesystem as a // whole as an issue, so does not send log message to file - LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_CRITICAL, LOG_all_sinks_except(LOG_SINK_FILE), "Error opening file to read"); - return open_result; - } - - if (LFS_enable_hot_path_debug_logs) { - LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_CRITICAL, LOG_SINK_ALL, "Opened file to read: %s", file_name); + LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_CRITICAL, LOG_all_sinks_except(LOG_SINK_FILE), "Error opening file to read: %s", file_name); + return open_result; } + LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_NORMAL, LOG_all_sinks_except(LOG_SINK_FILE), "Opened file to read: %s", file_name); const lfs_soff_t seek_result = lfs_file_seek(&LFS_filesystem, &file, offset, LFS_SEEK_SET); - if (seek_result < 0) - { - LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_CRITICAL, LOG_all_sinks_except(LOG_SINK_FILE), "Error seeking within file"); - return seek_result; - } - - const lfs_ssize_t read_result = lfs_file_read(&LFS_filesystem, &file, read_buffer, read_buffer_len); - if (read_result < 0) - { - LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_CRITICAL, LOG_all_sinks_except(LOG_SINK_FILE), "Error reading file"); - return read_result; - } - - if (LFS_enable_hot_path_debug_logs) { - LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_CRITICAL, LOG_SINK_ALL, "Successfully read file"); - } - - // Close the File, the storage is not updated until the file is closed successfully - const int8_t close_result = lfs_file_close(&LFS_filesystem, &file); - if (close_result < 0) - { - LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_CRITICAL, LOG_all_sinks_except(LOG_SINK_FILE), "Error closing file"); - return close_result; - } - - if (LFS_enable_hot_path_debug_logs) { - LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_CRITICAL, LOG_all_sinks_except(LOG_SINK_FILE), "Successfully close file"); - } - - return read_result; + if (seek_result < 0) + { + LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_CRITICAL, LOG_all_sinks_except(LOG_SINK_FILE), "Error seeking within file: %s", file_name); + return seek_result; + } + + const lfs_ssize_t read_result = lfs_file_read(&LFS_filesystem, &file, read_buffer, read_buffer_len); + if (read_result < 0) + { + LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_CRITICAL, LOG_all_sinks_except(LOG_SINK_FILE), "Error reading file: %s", file_name); + return read_result; + } + LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_NORMAL, LOG_all_sinks_except(LOG_SINK_FILE), "Successfully read file: %s", file_name); + + // Close the File, the storage is not updated until the file is closed successfully + const int8_t close_result = lfs_file_close(&LFS_filesystem, &file); + if (close_result < 0) { + LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_CRITICAL, LOG_all_sinks_except(LOG_SINK_FILE), "Error closing file: %s", file_name); + return close_result; + } + LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_NORMAL, LOG_all_sinks_except(LOG_SINK_FILE), "Successfully closed file: %s", file_name); + + return read_result; } -/** - * @brief Returns the file size - * @param file_name - Pointer to buffer holding the file name to open - * @retval Returns negative values if read or file open failed, else the - * number of bytes in the file - */ +/// @brief Returns the file size +/// @param file_name - Pointer to buffer holding the file name to open +/// @retval Returns negative values if read or file open failed, else the +/// number of bytes in the file + lfs_ssize_t LFS_file_size(const char file_name[]) { - lfs_file_t file; - const int8_t open_result = lfs_file_opencfg(&LFS_filesystem, &file, file_name, LFS_O_RDONLY, &LFS_file_cfg); + if (!LFS_is_lfs_mounted) { + LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_CRITICAL, LOG_all_sinks_except(LOG_SINK_FILE), "LittleFS not mounted"); + return 1; + } + + lfs_file_t file; + const int8_t open_result = lfs_file_opencfg(&LFS_filesystem, &file, file_name, LFS_O_RDONLY, &LFS_file_cfg); if (open_result < 0) { - LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_CRITICAL, LOG_all_sinks_except(LOG_SINK_FILE), "Error opening file"); + LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_CRITICAL, LOG_all_sinks_except(LOG_SINK_FILE), "Error opening file: %s", file_name); return open_result; } + LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_NORMAL, LOG_all_sinks_except(LOG_SINK_FILE), "Successfully opened file: %s", file_name); + const lfs_ssize_t size = lfs_file_size(&LFS_filesystem, &file); + const int8_t close_result = lfs_file_close(&LFS_filesystem, &file); - if (close_result < 0) { - LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_CRITICAL, LOG_all_sinks_except(LOG_SINK_FILE), "Error closing file"); - return close_result; - } + if (close_result < 0) { + LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_CRITICAL, LOG_all_sinks_except(LOG_SINK_FILE), "Error closing file: %s", file_name); + return close_result; + } + LOG_message(LOG_SYSTEM_LFS, LOG_SEVERITY_NORMAL, LOG_all_sinks_except(LOG_SINK_FILE), "Successfully closed file: %s", file_name); return size; -} - +} \ No newline at end of file diff --git a/firmware/Core/Src/log/log.c b/firmware/Core/Src/log/log.c index 6382a4526..7cd68b040 100644 --- a/firmware/Core/Src/log/log.c +++ b/firmware/Core/Src/log/log.c @@ -17,8 +17,8 @@ #define LOG_TIMESTAMP_MAX_LENGTH 30 #define LOG_SINK_NAME_MAX_LENGTH 20 #define LOG_SYSTEM_NAME_MAX_LENGTH 20 -// Messages up to 256 characters -#define LOG_FORMATTED_MESSAGE_MAX_LENGTH 256 +// Messages up to 512 characters +#define LOG_FORMATTED_MESSAGE_MAX_LENGTH 512 // Includes prefix, with cushion for delimiters, newline, and null terminator #define LOG_FULL_MESSAGE_MAX_LENGTH ( LOG_FORMATTED_MESSAGE_MAX_LENGTH + LOG_TIMESTAMP_MAX_LENGTH + LOG_SINK_NAME_MAX_LENGTH + LOG_SYSTEM_NAME_MAX_LENGTH + 1 ) diff --git a/firmware/Core/Src/main.c b/firmware/Core/Src/main.c index e8692eb45..abc5faa8f 100644 --- a/firmware/Core/Src/main.c +++ b/firmware/Core/Src/main.c @@ -1022,11 +1022,17 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - /*Configure GPIO pins : PIN_BOOM_PGOOD_IN_Pin PIN_GPS_PPS_IN_Pin */ - GPIO_InitStruct.Pin = PIN_BOOM_PGOOD_IN_Pin|PIN_GPS_PPS_IN_Pin; + /*Configure GPIO pin : PIN_BOOM_PGOOD_IN_Pin */ + GPIO_InitStruct.Pin = PIN_BOOM_PGOOD_IN_Pin; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + HAL_GPIO_Init(PIN_BOOM_PGOOD_IN_GPIO_Port, &GPIO_InitStruct); + + /*Configure GPIO pin : PIN_GPS_PPS_IN_Pin */ + GPIO_InitStruct.Pin = PIN_GPS_PPS_IN_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(PIN_GPS_PPS_IN_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pins : PIN_MEM_NCS_FLASH_7_Pin PIN_MEM_NCS_FLASH_6_Pin PIN_MEM_NCS_FLASH_5_Pin PIN_MEM_NCS_FLASH_4_Pin PIN_MEM_NCS_FLASH_3_Pin */ @@ -1072,7 +1078,12 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(PIN_BOOT0_GPIO_Port, &GPIO_InitStruct); + /* EXTI interrupt init*/ + HAL_NVIC_SetPriority(EXTI9_5_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(EXTI9_5_IRQn); + /* USER CODE BEGIN MX_GPIO_Init_2 */ + HAL_NVIC_DisableIRQ(EXTI9_5_IRQn); /* USER CODE END MX_GPIO_Init_2 */ } diff --git a/firmware/Core/Src/stm32l4xx_it.c b/firmware/Core/Src/stm32l4xx_it.c index c1f509ce8..2da5a0dad 100644 --- a/firmware/Core/Src/stm32l4xx_it.c +++ b/firmware/Core/Src/stm32l4xx_it.c @@ -213,6 +213,20 @@ void DMA1_Channel2_IRQHandler(void) /* USER CODE END DMA1_Channel2_IRQn 1 */ } +/** + * @brief This function handles EXTI line[9:5] interrupts. + */ +void EXTI9_5_IRQHandler(void) +{ + /* USER CODE BEGIN EXTI9_5_IRQn 0 */ + + /* USER CODE END EXTI9_5_IRQn 0 */ + HAL_GPIO_EXTI_IRQHandler(PIN_GPS_PPS_IN_Pin); + /* USER CODE BEGIN EXTI9_5_IRQn 1 */ + + /* USER CODE END EXTI9_5_IRQn 1 */ +} + /** * @brief This function handles TIM1 update interrupt and TIM16 global interrupt. */ @@ -221,8 +235,14 @@ void TIM1_UP_TIM16_IRQHandler(void) /* USER CODE BEGIN TIM1_UP_TIM16_IRQn 0 */ /* USER CODE END TIM1_UP_TIM16_IRQn 0 */ - HAL_TIM_IRQHandler(&htim1); - HAL_TIM_IRQHandler(&htim16); + if (htim1.Instance != NULL) + { + HAL_TIM_IRQHandler(&htim1); + } + if (htim16.Instance != NULL) + { + HAL_TIM_IRQHandler(&htim16); + } /* USER CODE BEGIN TIM1_UP_TIM16_IRQn 1 */ ulHighFrequencyTimerTicks++; diff --git a/firmware/Core/Src/telecommands/gps_telecommand_defs.c b/firmware/Core/Src/telecommands/gps_telecommand_defs.c new file mode 100644 index 000000000..876a649e8 --- /dev/null +++ b/firmware/Core/Src/telecommands/gps_telecommand_defs.c @@ -0,0 +1,106 @@ +#include "telecommands/telecommand_definitions.h" +#include "uart_handler/uart_handler.h" +#include "telecommands/eps_telecommands.h" +#include "gps/gps_internal_drivers.h" +#include "log/log.h" +#include "main.h" +#include "telecommands/telecommand_args_helpers.h" +#include "telecommands/telecommand_executor.h" +#include "debug_tools/debug_uart.h" +#include "telecommands/gps_telecommand_defs.h" +#include "gps/gps_pps_interrupt.h" + +#include "stm32l4xx_hal.h" + +#include +#include +#include +#include + +/// @brief Telecommand: Transmit a log command to the GPS receiver through UART +/// @param args_str +/// - Arg 0: Log command to be sent to GPS eg "log bestxyza once" (string) +/// @param tcmd_channel The channel on which the telecommand was received, and on which the response should be sent +/// @param response_output_buf The buffer to write the response to +/// @param response_output_buf_len The maximum length of the response_output_buf (its size) +/// @return 0 on success, > 0 error +uint8_t TCMDEXEC_gps_send_cmd_ascii(const char *args_str, TCMD_TelecommandChannel_enum_t tcmd_channel, + char *response_output_buf, uint16_t response_output_buf_len) +{ + + if (args_str == NULL) + { + snprintf(response_output_buf, response_output_buf_len, "Error: Empty args_str"); + return 1; + } + + // TODO : Determine if we need to perform extra error checks on arg_str ie log command format etc + + // Adding a new line character to the log command + char gps_log_cmd[128]; + snprintf(gps_log_cmd, sizeof(gps_log_cmd), "%s\n", args_str); + const uint16_t gps_log_cmd_len = strlen(gps_log_cmd); + + // Allocate space to receive incoming GPS response. + const uint16_t GPS_rx_buffer_max_size = 512; + uint16_t GPS_rx_buffer_len = 0; + uint8_t GPS_rx_buffer[GPS_rx_buffer_max_size]; + memset(GPS_rx_buffer, 0, GPS_rx_buffer_max_size); // Initialize all elements to 0 + + // Send log command to GPS and receive response + const uint8_t gps_cmd_response = GPS_send_cmd_get_response( + gps_log_cmd, gps_log_cmd_len, GPS_rx_buffer, GPS_rx_buffer_len, GPS_rx_buffer_max_size + ); + + // Handle the gps_cmd_response: Perform the error checks + // TODO: Potentially add GPS_validate_log_response function in here to validate response from the gps receiver + + if(gps_cmd_response != 0){ + LOG_message( + LOG_SYSTEM_GPS, + LOG_SEVERITY_NORMAL, + LOG_SINK_ALL, + "GPS Response Code: %d", + gps_cmd_response + ); + + } + + snprintf(response_output_buf, response_output_buf_len, "GPS Command: '%s' successfully transmitted", args_str); + + return 0; +} + +/// @brief Telecommand: Delete all agendas +/// @param args_str No arguments needed +/// @param tcmd_channel The channel on which the telecommand was received, and on which the response should be sent +/// @param response_output_buf The buffer to write the response to +/// @param response_output_buf_len The maximum length of the response_output_buf (its size) +/// @return 0 on success, 1 gps is off. +uint8_t TCMDEXEC_gps_set_enabled_pps_tracking(const char *args_str, TCMD_TelecommandChannel_enum_t tcmd_channel, + char *response_output_buf, uint16_t response_output_buf_len) { + + static uint8_t GPS_pps_interrupt_enabled = 0; + + // Check if EXTI is active + if (GPS_pps_interrupt_enabled) { + // Disable EXTI tracking + Disable_GPIO_EXTI(); + GPS_pps_interrupt_enabled = 0; + snprintf( + response_output_buf, response_output_buf_len, + "PPS tracking disabled"); + return 0; + } + // Check if EXTI is inactive + else if (!GPS_pps_interrupt_enabled) { + // Enable EXTI tracking + GPIO_EXTI_Init(); + GPS_pps_interrupt_enabled = 1; + snprintf( + response_output_buf, response_output_buf_len, + "PPS tracking enabled"); + return 0; + } + return 1; +} \ No newline at end of file diff --git a/firmware/Core/Src/telecommands/lfs_telecommand_defs.c b/firmware/Core/Src/telecommands/lfs_telecommand_defs.c index ae1699cd4..f01f4ac37 100644 --- a/firmware/Core/Src/telecommands/lfs_telecommand_defs.c +++ b/firmware/Core/Src/telecommands/lfs_telecommand_defs.c @@ -11,51 +11,139 @@ #include "telecommands/telecommand_definitions.h" #include "telecommands/telecommand_args_helpers.h" - uint8_t TCMDEXEC_fs_format_storage(const char *args_str, TCMD_TelecommandChannel_enum_t tcmd_channel, char *response_output_buf, uint16_t response_output_buf_len) { - int8_t result = LFS_format(); + const int8_t result = LFS_format(); if (result < 0) { - snprintf(response_output_buf, response_output_buf_len, "LittleFS Formatting Error: %d\n", result); + snprintf(response_output_buf, response_output_buf_len, "LittleFS Formatting Error: %d", result); return 1; } - snprintf(response_output_buf, response_output_buf_len, "LittleFS Successfully Formatted!\n"); + snprintf(response_output_buf, response_output_buf_len, "LittleFS Successfully Formatted!"); return 0; } uint8_t TCMDEXEC_fs_mount(const char *args_str, TCMD_TelecommandChannel_enum_t tcmd_channel, char *response_output_buf, uint16_t response_output_buf_len) { - int8_t result = LFS_mount(); + const int8_t result = LFS_mount(); if (result < 0) { - snprintf(response_output_buf, response_output_buf_len, "LittleFS Mounting Error: %d\n", result); + snprintf(response_output_buf, response_output_buf_len, "LittleFS Mounting Error: %d", result); return 1; } - snprintf(response_output_buf, response_output_buf_len, "LittleFS Successfully Mounted!\n"); + snprintf(response_output_buf, response_output_buf_len, "LittleFS Successfully Mounted!"); return 0; } uint8_t TCMDEXEC_fs_unmount(const char *args_str, TCMD_TelecommandChannel_enum_t tcmd_channel, char *response_output_buf, uint16_t response_output_buf_len) { - int8_t result = LFS_unmount(); + const int8_t result = LFS_unmount(); if (result < 0) { - snprintf(response_output_buf, response_output_buf_len, "LittleFS Unmounting Error: %d\n", result); + snprintf(response_output_buf, response_output_buf_len, "LittleFS Unmounting Error: %d", result); + return 1; + } + + snprintf(response_output_buf, response_output_buf_len, "LittleFS Successfully Unounted!"); + return 0; +} + +/// @brief Telecommand: List all the files and directories within a given directory +/// @param args_str +/// - Arg 0: Root Directory path as string +/// - Arg 1: (Offset) Number of entries to skip at the beginning +/// - Arg 2: (Count) Number entries to display +uint8_t TCMDEXEC_fs_list_directory(const char *args_str, TCMD_TelecommandChannel_enum_t tcmd_channel, + char *response_output_buf, uint16_t response_output_buf_len) { + + char arg_root_directory_path[LFS_MAX_PATH_LENGTH]; + const uint8_t parse_directory_path_result = TCMD_extract_string_arg( + args_str, 0, arg_root_directory_path, sizeof(arg_root_directory_path) + ); + if (parse_directory_path_result != 0) { + // error parsing + snprintf( + response_output_buf, + response_output_buf_len, + "Error parsing directory path arg: Error %d", parse_directory_path_result); + return 1; + } + + uint64_t arg_listing_offset = 0; + const uint8_t parse_listing_offset_result = TCMD_extract_uint64_arg( + args_str, strlen(args_str), 1, &arg_listing_offset + ); + if (parse_listing_offset_result != 0) { + // error parsing + snprintf( + response_output_buf, + response_output_buf_len, + "Error parsing offset arg: Error %d", parse_listing_offset_result); + return 1; + } + + uint64_t arg_listing_count = 0; + const uint8_t parse_listing_count_result = TCMD_extract_uint64_arg( + args_str, strlen(args_str), 2, &arg_listing_count + ); + if (parse_listing_count_result != 0) { + // error parsing + snprintf( + response_output_buf, + response_output_buf_len, + "Error parsing count arg: Error %d", parse_listing_count_result); + return 1; + } + + const int8_t list_directory_result = LFS_list_directory( + arg_root_directory_path, (uint16_t) arg_listing_offset, (int16_t) arg_listing_count + ); + if (list_directory_result < 0) { + snprintf( + response_output_buf, response_output_buf_len, + "LittleFS List Directory Error: %d", list_directory_result + ); + return 1; + } + + return 0; +} + +/// @brief Telecommand: Create a directory +/// @param args_str +/// - Arg 0: Directory Name as string (e.g., "/dir1", "/dir1/subdir1") +uint8_t TCMDEXEC_fs_make_directory(const char *args_str, TCMD_TelecommandChannel_enum_t tcmd_channel, + char *response_output_buf, uint16_t response_output_buf_len +) { + char arg_root_directory_path[LFS_MAX_PATH_LENGTH]; + const uint8_t parse_directory_path_result = TCMD_extract_string_arg( + args_str, 0, arg_root_directory_path, sizeof(arg_root_directory_path) + ); + if (parse_directory_path_result != 0) { + // Error parsing + snprintf( + response_output_buf, + response_output_buf_len, + "Error parsing directory path arg: Error %d", parse_directory_path_result); + return 1; + } + + const int8_t make_directory_result = LFS_make_directory(arg_root_directory_path); + if (make_directory_result < 0) { + snprintf(response_output_buf, response_output_buf_len, "LittleFS Make Directory Error: %d", make_directory_result); return 1; } - snprintf(response_output_buf, response_output_buf_len, "LittleFS Successfully Unounted!\n"); return 0; } /// @brief Telecommand: Write data to a file in LittleFS /// @param args_str /// - Arg 0: File path as string -/// - Arg 1: String to write to file -uint8_t TCMDEXEC_fs_write_file(const char *args_str, TCMD_TelecommandChannel_enum_t tcmd_channel, +/// - Arg 1: String to write to file (up to 512 bytes) +uint8_t TCMDEXEC_fs_write_file_str(const char *args_str, TCMD_TelecommandChannel_enum_t tcmd_channel, char *response_output_buf, uint16_t response_output_buf_len) { - char arg_file_name[64] = {0}; + char arg_file_name[LFS_MAX_PATH_LENGTH]; const uint8_t parse_file_name_result = TCMD_extract_string_arg(args_str, 0, arg_file_name, sizeof(arg_file_name)); if (parse_file_name_result != 0) { // error parsing @@ -77,9 +165,9 @@ uint8_t TCMDEXEC_fs_write_file(const char *args_str, TCMD_TelecommandChannel_enu return 2; } - int8_t result = LFS_write_file(arg_file_name, (uint8_t*) arg_file_content, strlen(arg_file_content)); + const int8_t result = LFS_write_file(arg_file_name, (uint8_t*) arg_file_content, strlen(arg_file_content)); if (result < 0) { - snprintf(response_output_buf, response_output_buf_len, "LittleFS Writing Error: %d\n", result); + snprintf(response_output_buf, response_output_buf_len, "LittleFS Writing Error: %d", result); return 1; } @@ -87,6 +175,8 @@ uint8_t TCMDEXEC_fs_write_file(const char *args_str, TCMD_TelecommandChannel_enu return 0; } +// TODO: Add a `fs_write_file_hex` telecommand, which supports offsets within the file. (Issue #266) + /// @brief Reads a file from LittleFS, and responds with its contents as 2-digit hex bytes. /// @param args_str /// - Arg 0: File path as string @@ -95,7 +185,7 @@ uint8_t TCMDEXEC_fs_read_file_hex(const char *args_str, TCMD_TelecommandChannel_ char *response_output_buf, uint16_t response_output_buf_len) { uint8_t rx_buffer[512] = {0}; - char arg_file_name[64] = {0}; + char arg_file_name[LFS_MAX_PATH_LENGTH]; const uint8_t parse_file_name_result = TCMD_extract_string_arg(args_str, 0, arg_file_name, sizeof(arg_file_name)); if (parse_file_name_result != 0) { // error parsing @@ -123,7 +213,7 @@ uint8_t TCMDEXEC_fs_read_file_hex(const char *args_str, TCMD_TelecommandChannel_ // print to uart and radio DEBUG_uart_print_array_hex(rx_buffer, bytes_read); // TODO send to radio - DEBUG_uart_print_str("TODO: send data to radio from TCMD_fs_read_file_hex()\n"); + DEBUG_uart_print_str("TODO: send data to radio from TCMD_fs_read_file_hex()"); } @@ -139,8 +229,10 @@ uint8_t TCMDEXEC_fs_read_text_file(const char *args_str, TCMD_TelecommandChannel char *response_output_buf, uint16_t response_output_buf_len) { uint8_t rx_buffer[512] = {0}; - char arg_file_name[64] = {0}; - const uint8_t parse_file_name_result = TCMD_extract_string_arg(args_str, 0, arg_file_name, sizeof(arg_file_name)); + char arg_file_name[LFS_MAX_PATH_LENGTH]; + const uint8_t parse_file_name_result = TCMD_extract_string_arg( + args_str, 0, arg_file_name, sizeof(arg_file_name) + ); if (parse_file_name_result != 0) { // error parsing snprintf( @@ -168,7 +260,7 @@ uint8_t TCMDEXEC_fs_read_text_file(const char *args_str, TCMD_TelecommandChannel // print to uart and radio DEBUG_uart_print_str((char*)rx_buffer); // TODO send to radio - DEBUG_uart_print_str("TODO: send data to radio from TCMD_fs_read_text_file()\n"); + DEBUG_uart_print_str("TODO: send data to radio from TCMD_fs_read_text_file()"); } @@ -187,20 +279,20 @@ uint8_t TCMDEXEC_fs_demo_write_then_read(const char *args_str, TCMD_TelecommandC const int8_t mount_result = LFS_mount(); if (mount_result < 0) { - snprintf(response_output_buf, response_output_buf_len, "LittleFS mounting error: %d\n", mount_result); + snprintf(response_output_buf, response_output_buf_len, "LittleFS mounting error: %d", mount_result); return 1; } const int8_t write_result = LFS_write_file(file_name, (uint8_t*) file_content, strlen(file_content)); if (write_result < 0) { - snprintf(response_output_buf, response_output_buf_len, "LittleFS writing error: %d\n", write_result); + snprintf(response_output_buf, response_output_buf_len, "LittleFS writing error: %d", write_result); return 2; } uint8_t read_buffer[200] = {0}; const int8_t read_result = LFS_read_file(file_name, 0, read_buffer, sizeof(read_buffer)); if (read_result < 0) { - snprintf(response_output_buf, response_output_buf_len, "LittleFS reading error: %d\n", read_result); + snprintf(response_output_buf, response_output_buf_len, "LittleFS reading error: %d", read_result); return 3; } diff --git a/firmware/Core/Src/telecommands/telecommand_definitions.c b/firmware/Core/Src/telecommands/telecommand_definitions.c index defb87dbe..7e9a983cb 100644 --- a/firmware/Core/Src/telecommands/telecommand_definitions.c +++ b/firmware/Core/Src/telecommands/telecommand_definitions.c @@ -24,7 +24,8 @@ #include "telecommands/eps_telecommands.h" #include "telecommands/stm32_internal_flash_telecommand_defs.h" #include "telecommands/comms_telecommand_defs.h" - +#include "telecommands/gps_telecommand_defs.h" +#include "telecommands/comms_telecommand_defs.h" #include "timekeeping/timekeeping.h" #include "littlefs/littlefs_helper.h" @@ -252,8 +253,20 @@ const TCMD_TelecommandDefinition_t TCMD_telecommand_definitions[] = { .readiness_level = TCMD_READINESS_LEVEL_FOR_OPERATION, }, { - .tcmd_name = "fs_write_file", - .tcmd_func = TCMDEXEC_fs_write_file, + .tcmd_name = "fs_list_directory", + .tcmd_func = TCMDEXEC_fs_list_directory, + .number_of_args = 3, + .readiness_level = TCMD_READINESS_LEVEL_FOR_OPERATION, + }, + { + .tcmd_name = "fs_make_directory", + .tcmd_func = TCMDEXEC_fs_make_directory, + .number_of_args = 1, + .readiness_level = TCMD_READINESS_LEVEL_FOR_OPERATION, + }, + { + .tcmd_name = "fs_write_file_str", + .tcmd_func = TCMDEXEC_fs_write_file_str, .number_of_args = 2, .readiness_level = TCMD_READINESS_LEVEL_FOR_OPERATION, }, @@ -1071,6 +1084,20 @@ const TCMD_TelecommandDefinition_t TCMD_telecommand_definitions[] = { .readiness_level = TCMD_READINESS_LEVEL_FLIGHT_TESTING, }, // ****************** END SECTION: comms_telecommand_defs ****************** + // ****************** SECTION: gps_telecommand_defs ****************** + { + .tcmd_name = "gps_send_cmd_ascii", + .tcmd_func = TCMDEXEC_gps_send_cmd_ascii, + .number_of_args = 1, + .readiness_level = TCMD_READINESS_LEVEL_FOR_OPERATION, + }, + { + .tcmd_name = "gps_set_enabled_pps_tracking", + .tcmd_func = TCMDEXEC_gps_set_enabled_pps_tracking, + .number_of_args = 0, + .readiness_level = TCMD_READINESS_LEVEL_FOR_OPERATION, + }, + // ****************** END SECTION: gps_telecommand_defs ****************** }; // extern diff --git a/firmware/Core/Src/telecommands/telecommand_executor.c b/firmware/Core/Src/telecommands/telecommand_executor.c index ae8bfd0d5..6ed3b428c 100644 --- a/firmware/Core/Src/telecommands/telecommand_executor.c +++ b/firmware/Core/Src/telecommands/telecommand_executor.c @@ -7,6 +7,7 @@ #include "timekeeping/timekeeping.h" #include "log/log.h" #include "transforms/arrays.h" +#include "config/configuration.h" #include #include @@ -56,22 +57,29 @@ uint8_t TCMD_add_tcmd_to_agenda(const TCMD_parsed_tcmd_to_execute_t *parsed_tcmd continue; } - // check to see if timestamp is in the circular buffer - for (uint32_t i = 0; i < TCMD_timestamp_sent_head; i++) { - if(parsed_tcmd->timestamp_sent == TCMD_timestamp_sent_store[i]) { - // Skip this telecommand - LOG_message( - LOG_SYSTEM_TELECOMMAND, - LOG_SEVERITY_WARNING, - LOG_SINK_ALL, - "Telecommand skipped due to timestamp collision" - ); - return 1; + // Skip if timstamps are not needed. + if(TCMD_require_unique_tssent) { + // Check to see if timestamp is in the circular buffer. + for (uint32_t i = 0; i < TCMD_timestamp_sent_head; i++) { + if(parsed_tcmd->timestamp_sent == TCMD_timestamp_sent_store[i]) { + // Skip this telecommand. + LOG_message( + LOG_SYSTEM_TELECOMMAND, + LOG_SEVERITY_WARNING, + LOG_SINK_ALL, + "Telecommand skipped due to repeated tssent." + ); + return 1; + } } } - // Add the timestamp to the circular buffer - TCMD_timestamp_sent_store[TCMD_timestamp_sent_head] = parsed_tcmd->timestamp_sent; - TCMD_timestamp_sent_head = (TCMD_timestamp_sent_head + 1) % TCMD_TIMESTAMP_RECORD_SIZE; + + // Add the timestamp to the circular buffer. + // This mechanism prevents command replays (executing the same command twice inadvertently). + if (parsed_tcmd->timestamp_sent > 0) { + TCMD_timestamp_sent_store[TCMD_timestamp_sent_head] = parsed_tcmd->timestamp_sent; + TCMD_timestamp_sent_head = (TCMD_timestamp_sent_head + 1) % TCMD_TIMESTAMP_RECORD_SIZE; + } // Copy the parsed telecommand into the agenda. TCMD_agenda[slot_num].tcmd_idx = parsed_tcmd->tcmd_idx; diff --git a/firmware/Core/Src/uart_handler/uart_handler.c b/firmware/Core/Src/uart_handler/uart_handler.c index fb9c740eb..bf22438cd 100644 --- a/firmware/Core/Src/uart_handler/uart_handler.c +++ b/firmware/Core/Src/uart_handler/uart_handler.c @@ -7,6 +7,7 @@ UART_HandleTypeDef *UART_telecommand_port_handle = &hlpuart1; UART_HandleTypeDef *UART_eps_port_handle = &huart5; // TODO: update this UART_HandleTypeDef *UART_mpi_port_handle = &huart1; +UART_HandleTypeDef *UART_gps_port_handle = &huart3; // UART telecommand buffer const uint16_t UART_telecommand_buffer_len = 256; // extern @@ -30,6 +31,14 @@ volatile uint8_t UART_mpi_rx_last_byte = 0; // extern volatile uint32_t UART_mpi_rx_last_byte_write_time_ms = 0; // extern volatile uint16_t UART_mpi_rx_buffer_write_idx = 0; // extern +// UART GPS buffer +const uint16_t UART_gps_buffer_len = 512; // extern +volatile uint8_t UART_gps_buffer[512]; // extern +volatile uint16_t UART_gps_buffer_write_idx = 0; // extern +volatile uint32_t UART_gps_last_write_time_ms = 0; // extern +volatile uint8_t UART_gps_buffer_last_rx_byte = 0; // extern +volatile uint8_t UART_gps_uart_interrupt_enabled = 0; //extern + // UART MPI science data buffer (WILL NEED IN THE FUTURE) // const uint16_t UART_mpi_data_rx_buffer_len = 8192; // extern // volatile uint8_t UART_mpi_data_rx_buffer[8192]; // extern @@ -104,6 +113,29 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) { DEBUG_uart_print_str("Unhandled MPI Mode\n"); // TODO: HANDLE other MPI MODES } } + + else if (huart->Instance == UART_gps_port_handle->Instance) { + if (UART_gps_uart_interrupt_enabled == 1) { + + // Add the byte to the buffer + if (UART_gps_buffer_write_idx >= UART_gps_buffer_len) { + DEBUG_uart_print_str("HAL_UART_RxCpltCallback() -> UART gps buffer is full\n"); + + // Shift all bytes left by 1 + for (uint16_t i = 1; i < UART_gps_buffer_len; i++) { + UART_gps_buffer[i - 1] = UART_gps_buffer[i]; + } + + // Reset to a valid index + UART_gps_buffer_write_idx = UART_gps_buffer_len - 1; + } + UART_gps_buffer[UART_gps_buffer_write_idx++] = UART_gps_buffer_last_rx_byte; + UART_gps_last_write_time_ms = HAL_GetTick(); + + HAL_UART_Receive_IT(UART_gps_port_handle, (uint8_t*) &UART_gps_buffer_last_rx_byte, 1); + } + + } else { // FIXME: add the rest (camera, MPI, maybe others) @@ -117,4 +149,18 @@ void UART_init_uart_handlers(void) { HAL_UART_Receive_IT(UART_eps_port_handle, (uint8_t*) &UART_eps_buffer_last_rx_byte, 1); // TODO: add the rest +} + + +/// @brief Sets the UART interrupt state (enabled/disabled) +/// @param new_enabled 1: enable interrupt; 0: disable interrupt +void GPS_set_uart_interrupt_state(uint8_t new_enabled) { + if (new_enabled == 1) + { + UART_gps_uart_interrupt_enabled = 1; + HAL_UART_Receive_IT(UART_gps_port_handle, (uint8_t*) &UART_gps_buffer_last_rx_byte, 1); + } + else { + UART_gps_uart_interrupt_enabled = 0; + } } \ No newline at end of file diff --git a/firmware/Core/Src/unit_tests/test_telecommand_parser.c b/firmware/Core/Src/unit_tests/test_telecommand_parser.c index 078f156e6..ed565de8a 100644 --- a/firmware/Core/Src/unit_tests/test_telecommand_parser.c +++ b/firmware/Core/Src/unit_tests/test_telecommand_parser.c @@ -132,9 +132,9 @@ uint8_t TEST_EXEC_TCMD_parse_full_telecommand() { TEST_ASSERT_TRUE(strcmp(TCMD_telecommand_definitions[parsed_tcmd.tcmd_idx].tcmd_name, "hello_world") == 0); // Tesing incorrect usage of 0 argument telecommand - TEST_ASSERT_TRUE(TCMD_parse_full_telecommand("CTS1+hello_world(a)!", TCMD_TelecommandChannel_DEBUG_UART, &parsed_tcmd) == 100); - TEST_ASSERT_TRUE(TCMD_parse_full_telecommand("CTS1+hello_world(a,1)!", TCMD_TelecommandChannel_DEBUG_UART, &parsed_tcmd) == 100); - TEST_ASSERT_TRUE(TCMD_parse_full_telecommand("CTS1+hello_world(,)!", TCMD_TelecommandChannel_DEBUG_UART, &parsed_tcmd) == 100); + TEST_ASSERT_TRUE(TCMD_parse_full_telecommand("CTS1+hello_world(a)!", TCMD_TelecommandChannel_DEBUG_UART, &parsed_tcmd) == 130); + TEST_ASSERT_TRUE(TCMD_parse_full_telecommand("CTS1+hello_world(a,1)!", TCMD_TelecommandChannel_DEBUG_UART, &parsed_tcmd) == 130); + TEST_ASSERT_TRUE(TCMD_parse_full_telecommand("CTS1+hello_world(,)!", TCMD_TelecommandChannel_DEBUG_UART, &parsed_tcmd) == 130); // Testing correct usage of 1 argument telecommand TEST_ASSERT_TRUE(TCMD_parse_full_telecommand("CTS1+set_system_time(10)!", TCMD_TelecommandChannel_DEBUG_UART, &parsed_tcmd) == 0); @@ -144,18 +144,18 @@ uint8_t TEST_EXEC_TCMD_parse_full_telecommand() { // Tesing incorrect usage of 1 argument telecommand - TEST_ASSERT_TRUE(TCMD_parse_full_telecommand("CTS1+set_system_time()!", TCMD_TelecommandChannel_DEBUG_UART, &parsed_tcmd) == 100); - TEST_ASSERT_TRUE(TCMD_parse_full_telecommand("CTS1+set_system_time(10,1)!", TCMD_TelecommandChannel_DEBUG_UART, &parsed_tcmd) == 100); - TEST_ASSERT_TRUE(TCMD_parse_full_telecommand("CTS1+set_system_time(10,)!", TCMD_TelecommandChannel_DEBUG_UART, &parsed_tcmd) == 100); - TEST_ASSERT_TRUE(TCMD_parse_full_telecommand("CTS1+set_system_time(,10)!", TCMD_TelecommandChannel_DEBUG_UART, &parsed_tcmd) == 100); - TEST_ASSERT_TRUE(TCMD_parse_full_telecommand("CTS1+set_system_time(,)!", TCMD_TelecommandChannel_DEBUG_UART, &parsed_tcmd) == 100); + TEST_ASSERT_TRUE(TCMD_parse_full_telecommand("CTS1+set_system_time()!", TCMD_TelecommandChannel_DEBUG_UART, &parsed_tcmd) == 130); + TEST_ASSERT_TRUE(TCMD_parse_full_telecommand("CTS1+set_system_time(10,1)!", TCMD_TelecommandChannel_DEBUG_UART, &parsed_tcmd) == 130); + TEST_ASSERT_TRUE(TCMD_parse_full_telecommand("CTS1+set_system_time(10,)!", TCMD_TelecommandChannel_DEBUG_UART, &parsed_tcmd) == 130); + TEST_ASSERT_TRUE(TCMD_parse_full_telecommand("CTS1+set_system_time(,10)!", TCMD_TelecommandChannel_DEBUG_UART, &parsed_tcmd) == 130); + TEST_ASSERT_TRUE(TCMD_parse_full_telecommand("CTS1+set_system_time(,)!", TCMD_TelecommandChannel_DEBUG_UART, &parsed_tcmd) == 130); // Testing correct usage of 3 3 argument telecommand TEST_ASSERT_TRUE(TCMD_parse_full_telecommand("CTS1+flash_read_hex(0,0,0)!", TCMD_TelecommandChannel_DEBUG_UART, &parsed_tcmd) == 0); - TEST_ASSERT_TRUE(TCMD_parse_full_telecommand("CTS1+flash_read_hex(0,0,0,)!", TCMD_TelecommandChannel_DEBUG_UART, &parsed_tcmd) == 100); - TEST_ASSERT_TRUE(TCMD_parse_full_telecommand("CTS1+flash_read_hex(,0,0,0)!", TCMD_TelecommandChannel_DEBUG_UART, &parsed_tcmd) == 100); - TEST_ASSERT_TRUE(TCMD_parse_full_telecommand("CTS1+flash_read_hex(,0,0,0)!", TCMD_TelecommandChannel_DEBUG_UART, &parsed_tcmd) == 100); - TEST_ASSERT_TRUE(TCMD_parse_full_telecommand("CTS1+flash_read_hex(0,0)!", TCMD_TelecommandChannel_DEBUG_UART, &parsed_tcmd) == 100); + TEST_ASSERT_TRUE(TCMD_parse_full_telecommand("CTS1+flash_read_hex(0,0,0,)!", TCMD_TelecommandChannel_DEBUG_UART, &parsed_tcmd) == 130); + TEST_ASSERT_TRUE(TCMD_parse_full_telecommand("CTS1+flash_read_hex(,0,0,0)!", TCMD_TelecommandChannel_DEBUG_UART, &parsed_tcmd) == 130); + TEST_ASSERT_TRUE(TCMD_parse_full_telecommand("CTS1+flash_read_hex(,0,0,0)!", TCMD_TelecommandChannel_DEBUG_UART, &parsed_tcmd) == 130); + TEST_ASSERT_TRUE(TCMD_parse_full_telecommand("CTS1+flash_read_hex(0,0)!", TCMD_TelecommandChannel_DEBUG_UART, &parsed_tcmd) == 130); return 0; } \ No newline at end of file