/*
 * Copyright (c) 2026 Martin Javier Klöckner <mklockner@fi.uba.ar>
 *
 * See file `LICENSE` for full details
 */

#ifndef TASK_INC_TASK_BUZZER_ATTRIBUTE_H_
#define TASK_INC_TASK_BUZZER_ATTRIBUTE_H_

#ifdef __cplusplus
extern "C" {
#endif

/* Buzzer Statechart - State Transition Table
 *
 * +---------+--------------+---------+-------+---------+
 * | Current | Event        |         | Next  |         |
 * | State   | (Parameters) | [Guard] | State | Actions |
 * |=========+==============+=========+=======+=========|
 * | INICIAL |              |         |       |         |
 * +---------+--------------+---------+-------+---------+
 *
 */

typedef enum {
    EV_BUZ_XX_OFF,
    EV_BUZ_XX_SHORT_BEEP,
    EV_BUZ_XX_LONG_BEEP
} task_buzzer_ev_t;

typedef enum {
    ST_BUZ_XX_OFF,
    ST_BUZ_XX_ON
} task_buzzer_st_t;

typedef enum {
    ID_BUZ_A
} task_buzzer_id_t;

typedef struct {
    task_buzzer_id_t identifier;
    TIM_HandleTypeDef *htim;
    uint32_t tim_channel;
    uint16_t freq;
    uint32_t short_beep_ms;
    uint32_t long_beep_ms;
} task_buzzer_cfg_t;

typedef struct {
    uint32_t tick;
    task_buzzer_st_t state;
    task_buzzer_ev_t event;
    bool event_flag;
} task_buzzer_dta_t;

extern task_buzzer_dta_t task_buzzer_dta_list[];

#ifdef __cplusplus
}
#endif

#endif /* TASK_INC_TASK_BUZZER_ATTRIBUTE_H_ */
