1 /* 2 * Copyright (c) 2023 Juan Manuel Cruz <jcruz@fi.uba.ar> <jcruz@frba.utn.edu.ar>. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * 3. Neither the name of the copyright holder nor the names of its 16 * contributors may be used to endorse or promote products derived from 17 * this software without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 22 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 23 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 * POSSIBILITY OF SUCH DAMAGE. 31 * 32 * @file : task_actuator_attribute.h 33 * @date : Set 26, 2023 34 * @author : Juan Manuel Cruz <jcruz@fi.uba.ar> <jcruz@frba.utn.edu.ar> 35 * @version v1.0.0 36 */ 37 38 #ifndef TASK_INC_TASK_ACTUATOR_ATTRIBUTE_H_ 39 #define TASK_INC_TASK_ACTUATOR_ATTRIBUTE_H_ 40 41 /********************** CPP guard ********************************************/ 42 #ifdef __cplusplus 43 extern "C" { 44 #endif 45 46 /********************** inclusions *******************************************/ 47 48 /********************** macros ***********************************************/ 49 50 /********************** typedef **********************************************/ 51 /* Actuator Statechart - State Transition Table */ 52 /* +-----------------------+-----------------------+-------------+-----------------------+-----------------------+ 53 * | Current | Event | | Next | | 54 * | State | (Parameters) | [Guard] | State | Actions | 55 * |=======================+=======================+=============+=======================+=======================| 56 * | INICIAL | | | ST_LED_XX_OFF | led = LED_OFF | 57 * | | | | | op_led(led) | 58 * |-----------------------+-----------------------+-------------+-----------------------+-----------------------| 59 * | ST_LED_XX_OFF | EV_LED_XX_ON | | ST_LED_XX_ON | led = LED_ON | 60 * | | | | | op_led(led) | 61 * | |-----------------------+-------------+-----------------------+-----------------------| 62 * | | EV_LED_XX_BLINK | | ST_LED_XX_BLINK_ON | tick = tick_max | 63 * | | | | | led = LED_ON | 64 * | | | | | op_led(led) | 65 * | |-----------------------+-------------+-----------------------+-----------------------| 66 * | | EV_LED_XX_PULSE | | ST_LED_XX_PULSE | tick = tick_max | 67 * | | | | | led = LED_ON | 68 * | | | | | op_led(led) | 69 * |-----------------------+-----------------------+-------------+-----------------------+-----------------------| 70 * | ST_LED_XX_ON | EV_LED_XX_OFF | | ST_LED_XX_OFF | led = LED_OFF | 71 * | | | | | op_led(led) | 72 * |-----------------------+-----------------------+-------------+-----------------------+-----------------------| 73 * | ST_LED_XX_BLINK_ON | EV_LED_XX_OFF | | ST_LED_XX_OFF | led = LED_OFF | 74 * | | | | | op_led(led) | 75 * | +-----------------------+-------------+-----------------------+-----------------------| 76 * | | EV_LED_XX_ON | | ST_LED_XX_ON | led = LED_ON | 77 * | | | | | op_led(led) | 78 * | +-----------------------+-------------+-----------------------+-----------------------| 79 * | | | [tick == 0] | ST_LED_XX_BLINK_OFF | tick = tick_max | 80 * | | | | | led = LED_OFF | 81 * | | | | | op_led(led) | 82 * | +-----------------------+-------------+-----------------------+-----------------------| 83 * | | | [tick > 0] | ST_LED_XX_BLINK_ON | tick-- | 84 * |-----------------------+-----------------------+-------------+-----------------------+-----------------------| 85 * | ST_LED_XX_BLINK_OFF | EV_LED_XX_OFF | | ST_LED_XX_OFF | led = LED_OFF | 86 * | | | | | op_led(led) | 87 * | +-----------------------+-------------+-----------------------+-----------------------| 88 * | | EV_LED_XX_ON | | ST_LED_XX_ON | led = LED_ON | 89 * | | | | | op_led(led) | 90 * | +-----------------------+-------------+-----------------------+-----------------------| 91 * | | | [tick > 0] | ST_LED_XX_BLINK_OFF | tick-- | 92 * | +-----------------------+-------------+-----------------------+-----------------------| 93 * | | | [tick == 0] | ST_LED_XX_BLINK_ON | tick = tick_max | 94 * | | | | | led = LED_ON | 95 * | | | | | op_led(led) | 96 * |-----------------------+-----------------------+-------------+-----------------------+-----------------------| 97 * | ST_LED_XX_PULSE | | [tick == 0] | ST_LED_XX_OFF | tick = tick_max | 98 * | | | | | led = LED_OFF | 99 * | | | | | op_led(led) | 100 * |-----------------------+-----------------------+-------------+-----------------------+-----------------------| 101 * | | | [tick > 0] | ST_LED_XX_PULSE | tick-- | 102 * +-----------------------+-----------------------+-------------+-----------------------+-----------------------+ */ 103 104 /* Events to excite Task Actuator */ 105 typedef enum { 106 EV_LED_XX_OFF, 107 EV_LED_XX_ON, 108 EV_LED_XX_NOT_BLINK, 109 EV_LED_XX_BLINK, 110 EV_LED_XX_PULSE 111 } task_actuator_ev_t; 112 113 /* States of Task Actuator */ 114 typedef enum { 115 ST_LED_XX_OFF, 116 ST_LED_XX_ON, 117 ST_LED_XX_BLINK_ON, 118 ST_LED_XX_BLINK_OFF, 119 ST_LED_XX_PULSE 120 } task_actuator_st_t; 121 122 /* Identifier of Task Actuator */ 123 typedef enum { 124 ID_LED_A 125 } task_actuator_id_t; 126 127 typedef struct 128 { 129 task_actuator_id_t identifier; 130 GPIO_TypeDef *gpio_port; 131 uint16_t pin; 132 GPIO_PinState led_on; 133 GPIO_PinState led_off; 134 uint32_t tick_blink; 135 uint32_t tick_pulse; 136 } task_actuator_cfg_t; 137 138 typedef struct 139 { 140 uint32_t tick; 141 task_actuator_st_t state; 142 task_actuator_ev_t event; 143 bool flag; 144 } task_actuator_dta_t; 145 146 /********************** external data declaration ****************************/ 147 extern task_actuator_dta_t task_actuator_dta_list[]; 148 149 /********************** external functions declaration ***********************/ 150 151 /********************** End of CPP guard *************************************/ 152 #ifdef __cplusplus 153 } 154 #endif 155 156 #endif /* TASK_INC_TASK_ACTUATOR_ATTRIBUTE_H_ */ 157 158 /********************** end of file ******************************************/
