Generation

generate functionSat, 06 May 2023

fsm_t* fsm_retina_new(fsm_t *p_fsm_button, uint32_t button_press_time, fsm_t *p_fsm_tx, fsm_t *p_fsm_rx, uint8_t rgb_id) Create a new RETINA FSM. This FSM is the main state machine of the Retina system that governs the interaction between the other state machines of the system: button, transmitter and receiver FSM. The FSM starts in the WAIT RX state and checks if the button has been pressed for more than button_press_time_ms ms. If so, it goes to the WAIT TX state to wait to transmit. When in the WAIT RX state, it checks if the button has been pressed for more than button_press_time_ms ms. If so, it goes to the WAIT RX state to wait to receive. Being in WAIT RX or WAIT TX, if no machine has any activity (neither the button's FSM, nor the transmitter's, nor the receiver's), it goes to low power mode SLEEP RX or SLEEP TX, respectively. While in SLEEP RX or SLEEP TX, it checks that no machine has activity, and, by means of an autotransition, it goes to sleep. These autotransitions are used to avoid staying awake by any interruption from other elements than ours, or the debugger. When waking up by one of our system elements, being in SLEEP RX or SLEEP TX, it will always switch (check_true()) to WAIT RX or WAIT TX, respectively. Returns: A pointer to the Retina FSM

fsm_retina_new(fsm_button_new(GPIO1, BUTTON_ACTIVE_LOW, BUTTON_NO_PULL, button_time_ms), BUTTON_TIME_MS, fsm_tx_new(GPIO2, RGB_ID), fsm_rx_new(GPIO3, RGB_ID), RGB_ID)

Questions about programming?Chat with your personal AI assistant