#ifndef __MCULIB_COMMON_H
#define __MCULIB_COMMON_H

#include "string.h"
#include "stdio.h"

#include "BoardConfig.h"
// #include "hc32f46x.h"
// #include "hc32_ddl.h"
// #include "hc32f46x_usart.h"
// #include "hc32f46x_timer0.h"

//#include "ms_typedef.h"
//#include "mculib_i2c.h"
// #include "mculib_peripheral.h"
// #include "mculib_gpio.h"
// #include "mculib_uart.h"
// #include "mculib_timer.h"
// #include "mculib_key.h"
// #include "mculib_ir.h"
// #include "mculib_flash.h"
// #include "mculib_systick.h"
#include "TaskProcessCom.h" //g_u16_timer_out

#define _MS1826_LOG_ENABLE_  (1)


#define HD_RX_LED3(x)     (x == TRUE) ?   GPIO_WriteBit(GPIOA, HDMI1_LED, Bit_RESET) : GPIO_WriteBit(GPIOA, HDMI1_LED, Bit_SET)
#define HD_RX_LED2(x)     (x == TRUE) ?   GPIO_WriteBit(GPIOC, HDMI2_LED, Bit_RESET) : GPIO_WriteBit(GPIOC, HDMI2_LED, Bit_SET)
#define HD_RX_LED1(x)     (x == TRUE) ?   GPIO_WriteBit(GPIOC, HDMI3_LED, Bit_RESET) : GPIO_WriteBit(GPIOC, HDMI3_LED, Bit_SET)
#define HD_RX_LED4(x)     //	(x == TRUE) ? PORT_ResetBits(LED_IN4_PORT, LED_IN4_PIN) : PORT_SetBits(LED_IN4_PORT, LED_IN4_PIN)
#define HD_TX_LED1(x)     //(x == TRUE) ?   GPIO_WriteBit(GPIOA, HDMI1_LED, Bit_SET) : GPIO_WriteBit(GPIOA, HDMI1_LED, Bit_RESET)
#define HD_TX_LED2(x)     //	(x == TRUE) ? PORT_ResetBits(LED_OUT2_PORT, LED_OUT2_PIN)  : PORT_SetBits(LED_OUT2_PORT, LED_OUT2_PIN)
#define HD_TX_LED3(x)     //	(x == TRUE) ? PORT_ResetBits(LED_OUT3_PORT, LED_OUT3_PIN)  : PORT_SetBits(LED_OUT3_PORT, LED_OUT3_PIN)
#define HD_TX_LED4(x)     //	(x == TRUE) ? PORT_ResetBits(LED_OUT4_PORT, LED_OUT4_PIN)  : PORT_SetBits(LED_OUT4_PORT, LED_OUT4_PIN)

#define HD_POWERON_LED(x)  //(x == TRUE) ? PORT_ResetBits(LED_POWER_ON_PORT, LED_POWER_ON_PIN)  : PORT_SetBits(LED_POWER_ON_PORT, LED_POWER_ON_PIN)
#define HD_POWEROFF_LED(x) //(x == TRUE) ? PORT_ResetBits(LED_POWER_OFF_PORT, LED_POWER_OFF_PIN)  : PORT_SetBits(LED_POWER_OFF_PORT, LED_POWER_OFF_PIN)

#define I2S1_SW_OUTPUT     //	PORT_SetBits(I2S1_SW_PORT, I2S1_SW_PIN)
#define I2S2_SW_OUTPUT     //	PORT_SetBits(I2S2_SW_PORT, I2S2_SW_PIN)
#define I2S3_SW_OUTPUT     //	PORT_SetBits(I2S3_SW_PORT, I2S3_SW_PIN)
#define I2S4_SW_OUTPUT     //	PORT_SetBits(I2S4_SW_PORT, I2S4_SW_PIN)
#define I2S1_SW_INPUT     //	PORT_ResetBits(I2S1_SW_PORT, I2S1_SW_PIN)
#define I2S2_SW_INPUT     //	PORT_ResetBits(I2S2_SW_PORT, I2S2_SW_PIN)
#define I2S3_SW_INPUT     //	PORT_ResetBits(I2S3_SW_PORT, I2S3_SW_PIN)
#define I2S4_SW_INPUT     //	PORT_ResetBits(I2S4_SW_PORT, I2S4_SW_PIN)

#define SPDIF1_SW_OUTPUT    // 	PORT_SetBits(SPDIF1_SW_PORT, SPDIF1_SW_PIN)
#define SPDIF2_SW_OUTPUT    // 	PORT_SetBits(SPDIF2_SW_PORT, SPDIF2_SW_PIN)
#define SPDIF3_SW_OUTPUT    // 	PORT_SetBits(SPDIF3_SW_PORT, SPDIF3_SW_PIN)
#define SPDIF4_SW_OUTPUT    // 	PORT_SetBits(SPDIF4_SW_PORT, SPDIF4_SW_PIN)
#define SPDIF1_SW_INPUT     //	PORT_ResetBits(SPDIF1_SW_PORT, SPDIF1_SW_PIN)
#define SPDIF2_SW_INPUT     //	PORT_ResetBits(SPDIF2_SW_PORT, SPDIF2_SW_PIN)
#define SPDIF3_SW_INPUT     //	PORT_ResetBits(SPDIF3_SW_PORT, SPDIF3_SW_PIN)
#define SPDIF4_SW_INPUT     //	PORT_ResetBits(SPDIF4_SW_PORT, SPDIF4_SW_PIN)

#define TRUE 1
#define FALSE 0

#define _ENABLE_  1
#define _DISABLE_ 0




#ifndef LOG
#if _MS1826_LOG_ENABLE_
#define LOG(X) printf("%s\n", X)
#else
#define LOG(X)
#endif
#endif

#ifndef LOG1
#if _MS1826_LOG_ENABLE_
#define LOG1(X, Y) printf("%s %x\n", X, Y)
#else
#define LOG1(X, Y)
#endif
#endif

#ifndef LOG2
#if _MS1826_LOG_ENABLE_
#define LOG2(X, Y) printf("%s %d\n", X, Y)
#else
#define LOG2(X, Y)
#endif
#endif

void mculib_chip_reset(void);



#define KEY_NUM_1			0x00
#define KEY_NUM_2			0x01
#define KEY_NUM_3			0x02
#define KEY_NUM_4			0x03
#define KEY_FUNCTION		0x04
#define KEY_MODE			0x05
#define KEY_AUDIO			0x06
#define KEY_RESOLU			0x07
#define KEY_POWER			0x08
#define KEY_UP				0x09
#define KEY_DOWN			0x0A
#define KEY_LEFT			0x0B
#define KEY_RIGHT			0x0C
#define KEY_OK				0x0D
#define KEY_RETURN			0x0E
#define KEY_RX_VIDEO_SEL 	0x0F

#define KEY_AUDIO_MUTE		0x10
#define KEY_NUM_5			0x11
#define KEY_NUM_6			0x12
#define KEY_NUM_7			0x13
#define KEY_NUM_8			0x14
#define KEY_NUM_9			0x15
#define KEY_AUDIO_ADD		0x16
#define KEY_AUDIO_SUB		0x17
#define KEY_DEFAULT			0x18
#define KEY_MENU			0x19





#endif

