49 #include "hal_clocks.h" 50 #include "hal_nop_delay.h" 52 #include "common_util.h" 53 #include "tinyprintf.h" 54 #include "uart_printf.h" 58 #define SS_TIME_MS 5052 63 OFF_STATE, RED_STATE, GREEN_STATE
85 tfp_printf(
"RED to OFF\n");
93 tfp_printf(
"GREEN to RED\n");
110 uint32_t curr_state = hal_gpio_pin_read(
BUTTON_1);
117 falling_edge =
false;
119 prev_state = curr_state;
144 tfp_printf(
"OFF to RED\n");
159 tfp_printf(
"RED to GREEN\n");
164 static void rgb_led_init(
void)
172 static void rgb_led_cycle(
void)
177 hal_nop_delay_ms(250);
181 hal_nop_delay_ms(250);
185 hal_nop_delay_ms(250);
200 tfp_printf(
"Hello World %d!\n", 1);
216 hal_nop_delay_ms(50);
void repeat_handler(void)
5s timeout handler used to go from green to red state or red to off state.
sm_states
The three states of the state machine.
void red_process(void)
Red state process checks if there is a button press to go to green state.
#define LEDS_ACTIVE_STATE
void green_process(void)
Green state process checks if there is a button press to reset the timer.
void lfclk_init(lfclk_src_t lfclk_src)
Function to initialize the LF clock.
#define MS_TIMER_TICKS_MS(ms)
void ms_timer_init(uint32_t irq_priority)
void uart_printf_init(uart_printf_baud_t baud_rate)
Function to initialize the parameters of UART based on the configurations in boards....
void ms_timer_start(ms_timer_num id, ms_timer_mode mode, uint64_t ticks, void(*handler)(void))
bool button_check(void)
Function that returns if the button was released from the previous time it was called.
void hfclk_xtal_init_blocking(void)
Function to start the crystal oscillator to be used for HF clock. This function blocks until the crys...
int main(void)
Function for application main entry.
void off_process(void)
Off state process checks if there is a button press to go to red state.
void(* state_process)(void)
The type of function pointer that'll be used by the processing functions of the three states.
#define BUTTONS_ACTIVE_STATE
One shot call of the timer.