/*
File Name    : system.h
Author       : Yichip
Version      : V1.0
Date         : 2019/11/13
Description  : none.
*/

#ifndef __SYSTEM_H__
#define __SYSTEM_H__

#include <string.h>
#include "yc11xx_uart.h"
#include "yc11xx_gpio.h"
#include "ycdef.h"
#include "yc_timer.h"

//#define ENABLE_LOG	//Debug switch
//#define DEBUG_ADC
//#define DEBUG_OTP
//#define DEBUG_QSPI
//#define DEBUG_SYS
//#define DEBUG_DRV_BT

#define NEC_ENABLE 1
#if (NEC_ENABLE==1)
#define NEC_GPIO 31
#endif

#define DEBUG_USART 1
#define DEBUG_BLE_PRINTF 0
#if (DEBUG_USART==1)
#define PRINTPORT  UARTB
#define PRINTRXIO  6
#define PRINTTXIO  25
#else   
#define PRINTPORT  UARTB
#define PRINTRXIO  6
#define PRINTTXIO  7
#endif



#define BLE_SEND_HANDLE 0x001e 

#define ADC_GET_GPIOx 23


#define BIT_SET(a,b) ((a) |= (1<<(b)))
#define BIT_CLEAR(a,b) ((a) &= ~(1<<(b)))
#define BIT_FLIP(a,b) ((a) ^= (1<<(b)))				//bit Negation
#define BIT_GET(a,b) (((a) & (1<<(b)))>>(b))

extern uint8_t Bt_CONNECTED_State;

typedef struct printportStruct
{
    USART_TypeDef print_port;
    uint8_t       print_rxio;
    uint8_t       print_txio;
}printport_CB;

/**
 * @brief Print format string to serial port 0.You need to initialize the serial port 0 before you use MyPrintf.
 *
 * @param format : format string
 * @param ...: format parameter
 */
void printport_init(void);

void setprintport(USART_TypeDef UARTx);

void getprintportcb(printport_CB *printportx);

void MyPrintf(char *format, ...);

void open_log_print(uint8_t isopen);

void log_print(char *format, ...);
void log2_print(char *format, ...);
void printfsend(uint8_t* buf, int len);
void delay_us(uint32_t num);

#endif /*__SYSTEM_H__*/