/**
******************************************************************************************************************************************************************************************
*@file                       user_mic_gpadc.h
*@author         
*@data                       
*@version                    v1.0
*@par Copyright(c):
*
*@par History:
*     version:author,date,desc
*     v1.0   :create this file
*
*******************************************************************************************************************************************************************************************
*/
#ifndef USER_MIC_GPADC_H_
#define USER_MIC_GPADC_H_

#include <stdbool.h>
#include "cpu.h"

/* Defined Register field range */
#define REG_RANGE(high_bit, low_bit)	low_bit, high_bit

/* Field range mask */
#define REG_RANGE_MASK(low_bit, high_bit)	((1 << ((high_bit) - (low_bit) + 1)) - 1)

typedef enum
{
    STATE_CLOSE,
	STATE_OPEN,
	
	STATE_OTP,

}mic_adc_state_t;

typedef struct {
	unsigned char *buf1;
	unsigned char *buf2;
	unsigned int  buf_size;
	unsigned int  sampling_rate;
	
	void (*on_mic_data)(void *user, unsigned char *data, unsigned int data_size);
	void *user;
} gpadc_mic_init_paramter_t;

static void (*on_mic_data_handler)(void *user, unsigned char *data, unsigned int data_size);
static void *on_mic_data_user;

/* Initialize GPADC Mic */
void mic_send_back(void);

static void on_mic_data(void *user, unsigned char *data, unsigned int data_size);

void gpadc_mic_init(void);

void user_mic_gpadc_init(void);

void paramter_init(const gpadc_mic_init_paramter_t *paramter);

void mic_config(const gpadc_mic_init_paramter_t *paramter);

void gpadc_gpio(void);

void user_mic_gpadc_cmd(functional_state_t new_state);

bool mic_send_data(void);


void mic_notify_data(void);
void gpadc_ctrl_upper_lower(functional_state_t new_state);
void mic_notify_finished(void);
void mic_tx_view(void);
void mic_state_set(mic_adc_state_t state);


#endif

