#ifndef _GW3323_SARADC_H
#define _GW3323_SARADC_H

#include "include.h"

//--------------- SADC Flag Definition ---------------//
#define SADC_FLAG_PENDING            ((uint32_t)0x00010000)

//SARADC CLK enumeration
typedef enum {
    SADC_CLK_2M         = 0x00,
    SADC_CLK_6M         = 0x01,
} SADC_CLK_TYPEDEF;

//SARADC setup timing enumeration
typedef enum {
    SADC_ST_0_CLK       = 0x00,
    SADC_ST_2_CLK       = 0x01,
    SADC_ST_4_CLK       = 0x10,
    SADC_ST_8_CLK       = 0x11,
} SADC_ST_TYPEDEF;

//SARADC init structure
typedef struct{
    SADC_CLK_TYPEDEF    clk;
    uint16_t            baud;
} sadc_init_typedef;

typedef struct {
    volatile u8 adc_i;
    volatile u16 shock_wave_each_val[12];//12, according Oscillation frequency
} adc_cb_t;
extern adc_cb_t adc_cb;



void sadc_init(sadc_init_typedef* sadc_init_struct);
void sadc_channel_config(uint8_t adc_chx, SADC_ST_TYPEDEF setup_timing);
void sadc_cmd(FUNCTIONAL_STATE state);
void sadc_it_cmd(FUNCTIONAL_STATE state);
void sadc_set_baud(uint16_t div);
void sadc_kick_start(uint16_t adc_ch, uint8_t auto_anl_en);
FLAG_STATE sadc_get_flag(uint32_t sadc_flag);
void sadc_clear_flag(uint32_t sadc_flag);
uint32_t sadc_get_data(u8 adc_chx);

#endif  // _GW3323_SARADC_H
