File tree Expand file tree Collapse file tree 7 files changed +69
-2
lines changed
include/flex-stacker/firmware Expand file tree Collapse file tree 7 files changed +69
-2
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ add_STM32G4_freertos(${TARGET_MODULE_NAME})
7
7
add_STM32G4_usb (${TARGET_MODULE_NAME} )
8
8
9
9
set (SYSTEM_DIR "${CMAKE_CURRENT_SOURCE_DIR} /system" )
10
+ set (UI_DIR "${CMAKE_CURRENT_SOURCE_DIR} /ui" )
10
11
set (COMMS_DIR "${CMAKE_CURRENT_SOURCE_DIR} /host_comms_task" )
11
12
set (MOTOR_CONTROL_DIR "${CMAKE_CURRENT_SOURCE_DIR} /motor_control" )
12
13
set (COMMON_MCU_DIR "${CMAKE_CURRENT_SOURCE_DIR} /../../common/STM32G491" )
@@ -17,6 +18,7 @@ set(GDBINIT_PATH "${CMAKE_CURRENT_BINARY_DIR}/../../common/STM32G491/gdbinit")
17
18
set (${TARGET_MODULE_NAME} _FW_LINTABLE_SRCS
18
19
${CMAKE_CURRENT_SOURCE_DIR} /main.cpp
19
20
${SYSTEM_DIR} /freertos_idle_timer_task.cpp
21
+ ${UI_DIR} /freertos_ui_task.cpp
20
22
${MOTOR_CONTROL_DIR} /freertos_motor_task.cpp
21
23
${MOTOR_CONTROL_DIR} /freertos_motor_driver_task.cpp
22
24
${MOTOR_CONTROL_DIR} /motor_driver_policy.cpp
@@ -27,6 +29,8 @@ set(${TARGET_MODULE_NAME}_FW_NONLINTABLE_SRCS
27
29
${SYSTEM_DIR} /stm32g4xx_hal_msp.c
28
30
${SYSTEM_DIR} /stm32g4xx_it.c
29
31
${SYSTEM_DIR} /system_stm32g4xx.c
32
+ ${SYSTEM_DIR} /hal_tick.c
33
+ ${UI_DIR} /ui_hardware.c
30
34
${COMMS_DIR} /usbd_conf.c
31
35
${COMMS_DIR} /usbd_desc.c
32
36
${COMMS_DIR} /usb_hardware.c
Original file line number Diff line number Diff line change @@ -11,7 +11,8 @@ using EntryPoint = std::function<void(tasks::FirmwareTasks::QueueAggregator *)>;
11
11
static auto motor_driver_task_entry = EntryPoint(motor_driver_task::run);
12
12
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
13
13
static auto motor_task_entry = EntryPoint(motor_control_task::run);
14
-
14
+ // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
15
+ static auto ui_task_entry = EntryPoint(ui_control_task::run);
15
16
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
16
17
static auto aggregator = tasks::FirmwareTasks::QueueAggregator();
17
18
@@ -23,13 +24,18 @@ static auto driver_task =
23
24
static auto motor_task =
24
25
ot_utils::freertos_task::FreeRTOSTask<tasks::MOTOR_STACK_SIZE, EntryPoint>(
25
26
motor_task_entry);
26
-
27
+ // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
28
+ static auto ui_task =
29
+ ot_utils::freertos_task::FreeRTOSTask<tasks::UI_STACK_SIZE, EntryPoint>(
30
+ ui_task_entry);
27
31
auto main () -> int {
28
32
HardwareInit ();
33
+
29
34
driver_task.start (tasks::MOTOR_DRIVER_TASK_PRIORITY, " Motor Driver" ,
30
35
&aggregator);
31
36
motor_task.start (tasks::MOTOR_TASK_PRIORITY, " Motor" , &aggregator);
32
37
38
+ ui_task.start (tasks::UI_TASK_PRIORITY, " UI" , &aggregator);
33
39
vTaskStartScheduler ();
34
40
return 0 ;
35
41
}
Original file line number Diff line number Diff line change
1
+ #include " firmware/freertos_tasks.hpp"
2
+
3
+ #include " firmware/ui_hardware.h"
4
+
5
+ namespace ui_control_task {
6
+
7
+ auto run (tasks::FirmwareTasks::QueueAggregator* aggregator) -> void {
8
+ while (true ) {
9
+ ui_hardware_set_heartbeat_led (true );
10
+ vTaskDelay (500 );
11
+ ui_hardware_set_heartbeat_led (false );
12
+ vTaskDelay (500 );
13
+ }
14
+ }
15
+
16
+ }; // namespace ui_control_task
Original file line number Diff line number Diff line change
1
+ #include "main.h"
2
+
3
+ #include <stdbool.h>
4
+
5
+ #include "stm32g4xx_hal.h"
6
+
7
+
8
+ #define nSTATUS_LED_Pin GPIO_PIN_10
9
+ #define nSTATUS_LED_GPIO_Port GPIOC
10
+
11
+ void ui_hardware_set_heartbeat_led (bool setting ) {
12
+ //NOLINTNEXTLINE(performance-no-int-to-ptr)
13
+ HAL_GPIO_WritePin (nSTATUS_LED_GPIO_Port , nSTATUS_LED_Pin ,
14
+ setting ? GPIO_PIN_SET : GPIO_PIN_RESET );
15
+ }
Original file line number Diff line number Diff line change @@ -24,4 +24,7 @@ constexpr uint8_t MOTOR_TASK_PRIORITY = 1;
24
24
constexpr size_t MOTOR_DRIVER_STACK_SIZE = 256 ;
25
25
constexpr uint8_t MOTOR_DRIVER_TASK_PRIORITY = 1 ;
26
26
27
+ constexpr size_t UI_STACK_SIZE = 256 ;
28
+ constexpr uint8_t UI_TASK_PRIORITY = 1 ;
29
+
27
30
}; // namespace tasks
Original file line number Diff line number Diff line change @@ -18,3 +18,9 @@ namespace motor_control_task {
18
18
auto run (tasks::FirmwareTasks::QueueAggregator* aggregator) -> void;
19
19
20
20
} // namespace motor_control_task
21
+
22
+ namespace ui_control_task {
23
+
24
+ // Actual function that runs in the task
25
+ auto run (tasks::FirmwareTasks::QueueAggregator* aggregator) -> void;
26
+ } // namespace ui_control_task
Original file line number Diff line number Diff line change
1
+ #ifndef UI_HARDWARE_H__
2
+ #define UI_HARDWARE_H__
3
+ #ifdef __cplusplus
4
+ extern "C" {
5
+ #endif // __cplusplus
6
+
7
+ #include <stdbool.h>
8
+
9
+ /**
10
+ * @brief Enter the bootloader. This function never returns.
11
+ */
12
+ void ui_hardware_set_heartbeat_led (bool setting );
13
+
14
+ #ifdef __cplusplus
15
+ } // extern "C"
16
+ #endif // __cplusplus
17
+ #endif // _UI_HARDWARE_H__
You can’t perform that action at this time.
0 commit comments