#ifndef __MUX_H
#define __MUX_H

#include <stdbool.h>

//
#define LED_NUMBER      4

#define LINE_0_SET      GPIOE->scr = GPIO_PINS_3
#define LINE_0_RESET    GPIOE->clr = GPIO_PINS_3

#define LINE_1_SET      GPIOE->scr = GPIO_PINS_2
#define LINE_1_RESET    GPIOE->clr = GPIO_PINS_2

#define LINE_2_SET      GPIOB->scr = GPIO_PINS_9
#define LINE_2_RESET    GPIOB->clr = GPIO_PINS_9

#define COL_1_SET      GPIOD->scr = GPIO_PINS_6
#define COL_1_RESET    GPIOD->clr = GPIO_PINS_6

#define COL_2_SET      GPIOD->scr = GPIO_PINS_7
#define COL_2_RESET    GPIOD->clr = GPIO_PINS_7

#define COL_3_SET      GPIOB->scr = GPIO_PINS_6
#define COL_3_RESET    GPIOB->clr = GPIO_PINS_6

#define COL_4_SET      GPIOB->scr = GPIO_PINS_7
#define COL_4_RESET    GPIOB->clr = GPIO_PINS_7


typedef enum
{
    STATUS_G = 0,
    STATUS_R,
    RX_G,
    TX_R,
      
} led_t;


typedef enum
{
    LED_OFF = 0, 
    LED_ON,
    LED_BLINK,
    
} led_state_t;


typedef struct 
{
    led_t           name;
    uint8_t         line[3];    // [line_0, line_1, line_2]
    led_state_t     state;
    uint32_t        cnt;
    
} mux_channel_t;


//
void mux_led_init(mux_channel_t *ch);

//
void mux_gpio_init(void);

//
void mux_led_proc(void);

//
void mux_led_blink(void);

//
void mux_led_test_init(void);

//
void mux_led_test_toggle(void);

//
void mux_led_status(bool state);


extern mux_channel_t leds[];

#endif  // __MUX_H

