firmware-nucleo/App/Inc/task_leds_attribute.h (7039B)
1 /* 2 * Copyright (c) 2026 Martin Javier Klöckner <mklockner@fi.uba.ar> 3 * 4 * See file `LICENSE` for full details 5 */ 6 7 #ifndef TASK_INC_TASK_LEDS_ATTRIBUTE_H_ 8 #define TASK_INC_TASK_LEDS_ATTRIBUTE_H_ 9 10 #ifdef __cplusplus 11 extern "C" { 12 #endif 13 14 /* Led Statechart - State Transition Table */ 15 /* +-----------------------+-----------------------+-------------+-----------------------+-----------------------+ 16 * | Current | Event | | Next | | 17 * | State | (Parameters) | [Guard] | State | Actions | 18 * |=======================+=======================+=============+=======================+=======================| 19 * | INICIAL | | | ST_LED_XX_OFF | led = LED_OFF | 20 * | | | | | op_led(led) | 21 * |-----------------------+-----------------------+-------------+-----------------------+-----------------------| 22 * | ST_LED_XX_OFF | EV_LED_XX_ON | | ST_LED_XX_ON | led = LED_ON | 23 * | | | | | op_led(led) | 24 * | |-----------------------+-------------+-----------------------+-----------------------| 25 * | | EV_LED_XX_BLINK | | ST_LED_XX_BLINK_ON | tick = tick_max | 26 * | | | | | led = LED_ON | 27 * | | | | | op_led(led) | 28 * | |-----------------------+-------------+-----------------------+-----------------------| 29 * | | EV_LED_XX_PULSE | | ST_LED_XX_PULSE | tick = tick_max | 30 * | | | | | led = LED_ON | 31 * | | | | | op_led(led) | 32 * |-----------------------+-----------------------+-------------+-----------------------+-----------------------| 33 * | ST_LED_XX_ON | EV_LED_XX_OFF | | ST_LED_XX_OFF | led = LED_OFF | 34 * | | | | | op_led(led) | 35 * |-----------------------+-----------------------+-------------+-----------------------+-----------------------| 36 * | ST_LED_XX_BLINK_ON | EV_LED_XX_OFF | | ST_LED_XX_OFF | led = LED_OFF | 37 * | | | | | op_led(led) | 38 * | +-----------------------+-------------+-----------------------+-----------------------| 39 * | | EV_LED_XX_ON | | ST_LED_XX_ON | led = LED_ON | 40 * | | | | | op_led(led) | 41 * | +-----------------------+-------------+-----------------------+-----------------------| 42 * | | | [tick == 0] | ST_LED_XX_BLINK_OFF | tick = tick_max | 43 * | | | | | led = LED_OFF | 44 * | | | | | op_led(led) | 45 * | +-----------------------+-------------+-----------------------+-----------------------| 46 * | | | [tick > 0] | ST_LED_XX_BLINK_ON | tick-- | 47 * |-----------------------+-----------------------+-------------+-----------------------+-----------------------| 48 * | ST_LED_XX_BLINK_OFF | EV_LED_XX_OFF | | ST_LED_XX_OFF | led = LED_OFF | 49 * | | | | | op_led(led) | 50 * | +-----------------------+-------------+-----------------------+-----------------------| 51 * | | EV_LED_XX_ON | | ST_LED_XX_ON | led = LED_ON | 52 * | | | | | op_led(led) | 53 * | +-----------------------+-------------+-----------------------+-----------------------| 54 * | | | [tick > 0] | ST_LED_XX_BLINK_OFF | tick-- | 55 * | +-----------------------+-------------+-----------------------+-----------------------| 56 * | | | [tick == 0] | ST_LED_XX_BLINK_ON | tick = tick_max | 57 * | | | | | led = LED_ON | 58 * | | | | | op_led(led) | 59 * |-----------------------+-----------------------+-------------+-----------------------+-----------------------| 60 * | ST_LED_XX_PULSE | | [tick == 0] | ST_LED_XX_OFF | tick = tick_max | 61 * | | | | | led = LED_OFF | 62 * | | | | | op_led(led) | 63 * |-----------------------+-----------------------+-------------+-----------------------+-----------------------| 64 * | | | [tick > 0] | ST_LED_XX_PULSE | tick-- | 65 * +-----------------------+-----------------------+-------------+-----------------------+-----------------------+ */ 66 67 /* Events to excite Task Led */ 68 typedef enum { 69 EV_LED_XX_OFF, 70 EV_LED_XX_ON, 71 EV_LED_XX_NOT_BLINK, 72 EV_LED_XX_BLINK, 73 EV_LED_XX_PULSE 74 } task_leds_ev_t; 75 76 /* States of Task Led */ 77 typedef enum { 78 ST_LED_XX_OFF, 79 ST_LED_XX_ON, 80 ST_LED_XX_BLINK_ON, 81 ST_LED_XX_BLINK_OFF, 82 ST_LED_XX_PULSE 83 } task_leds_st_t; 84 85 /* Identifier of Task Led */ 86 typedef enum { 87 ID_LED_A, 88 ID_LED_B 89 } task_leds_id_t; 90 91 typedef struct 92 { 93 task_leds_id_t identifier; 94 GPIO_TypeDef *gpio_port; 95 uint16_t pin; 96 GPIO_PinState led_on; 97 GPIO_PinState led_off; 98 uint32_t tick_blink; 99 uint32_t tick_pulse; 100 } task_leds_cfg_t; 101 102 typedef struct 103 { 104 uint32_t tick; 105 task_leds_st_t state; 106 task_leds_ev_t event; 107 bool flag; 108 } task_leds_dta_t; 109 110 extern task_leds_dta_t task_leds_dta_list[]; 111 112 #ifdef __cplusplus 113 } 114 #endif 115 116 #endif /* TASK_INC_TASK_LEDS_ATTRIBUTE_H_ */
