tdse-tp2_02-model_integration

Index Commits Files Refs README
app/inc/task_actuator_attribute.h (10175B)
   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 task_actuator_ev {EV_LED_XX_OFF,
 106                                EV_LED_XX_ON,
 107                                EV_LED_XX_NOT_BLINK,
 108                                EV_LED_XX_BLINK,
 109                                EV_LED_XX_PULSE} task_actuator_ev_t;
 110 
 111 /* States of Task Actuator */
 112 typedef enum task_actuator_st {ST_LED_XX_OFF,
 113                                ST_LED_XX_ON,
 114                                ST_LED_XX_BLINK_ON,
 115                                ST_LED_XX_BLINK_OFF,
 116                                ST_LED_XX_PULSE} task_actuator_st_t;
 117 
 118 /* Identifier of Task Actuator */
 119 typedef enum task_actuator_id {ID_LED_A} task_actuator_id_t;
 120 
 121 typedef struct
 122 {
 123     task_actuator_id_t    identifier;
 124     GPIO_TypeDef *        gpio_port;
 125     uint16_t            pin;
 126     GPIO_PinState        led_on;
 127     GPIO_PinState        led_off;
 128     uint32_t            tick_blink;
 129     uint32_t            tick_pulse;
 130 } task_actuator_cfg_t;
 131 
 132 typedef struct
 133 {
 134     uint32_t            tick;
 135     task_actuator_st_t    state;
 136     task_actuator_ev_t    event;
 137     bool                flag;
 138 } task_actuator_dta_t;
 139 
 140 /********************** external data declaration ****************************/
 141 extern task_actuator_dta_t task_actuator_dta_list[];
 142 
 143 /********************** external functions declaration ***********************/
 144 
 145 /********************** End of CPP guard *************************************/
 146 #ifdef __cplusplus
 147 }
 148 #endif
 149 
 150 #endif /* TASK_INC_TASK_ACTUATOR_ATTRIBUTE_H_ */
 151 
 152 /********************** end of file ******************************************/