/******************************************************************************
;  *   	@MCU				 : MC51F003A4
;  *   	@Create Date         : 2021.10.11
;  *   	@Author/Corporation  : Martin/SinoMCU
;  *   	@晟矽微技术支持QQ 	 : 2048615934
;  *    @晟矽微官网		     : http://www.sinomcu.com/
;  *   	@Copyright           : 2020 SINOMCU Corporation,All Rights Reserved.
;  *----------------------Abstract Description---------------------------------
;  *			          定义                              		
******************************************************************************/
#ifndef GPIO_H__
#define GPIO_H__
#include "User_Def.h"

#define LED1 P00D
#define LED2 P01D

//------------------- Define Port as Input Hi-Z mode ----------------
#define P00_INPUTHIZ_MODE				P0MOD0&=~DEF_SET_BIT0;P0MOD0|=DEF_SET_BIT1
#define P01_INPUTHIZ_MODE				P0MOD0&=~DEF_SET_BIT2;P0MOD0|=DEF_SET_BIT3

#define P10_INPUTHIZ_MODE				P1MOD0&=~DEF_SET_BIT0;P1MOD0|=DEF_SET_BIT1
#define P11_INPUTHIZ_MODE				P1MOD0&=~DEF_SET_BIT2;P1MOD0|=DEF_SET_BIT3
#define P12_INPUTHIZ_MODE				P1MOD0&=~DEF_SET_BIT4;P1MOD0|=DEF_SET_BIT5
#define P13_INPUTHIZ_MODE				P1MOD0&=~DEF_SET_BIT6;P1MOD0|=DEF_SET_BIT7
#define P14_INPUTHIZ_MODE				P1MOD1&=~DEF_SET_BIT0;P1MOD1|=DEF_SET_BIT1
#define P15_INPUTHIZ_MODE				P1MOD1&=~DEF_SET_BIT2;P1MOD1|=DEF_SET_BIT3
#define P16_INPUTHIZ_MODE				P1MOD1&=~DEF_SET_BIT4;P1MOD1|=DEF_SET_BIT5
#define P17_INPUTHIZ_MODE				P1MOD1&=~DEF_SET_BIT6;P1MOD1|=DEF_SET_BIT7

#define P20_INPUTHIZ_MODE				P2MOD0&=~DEF_SET_BIT0;P2MOD0|=DEF_SET_BIT1
#define P21_INPUTHIZ_MODE				P2MOD0&=~DEF_SET_BIT2;P2MOD0|=DEF_SET_BIT3
#define P22_INPUTHIZ_MODE				P2MOD0&=~DEF_SET_BIT4;P2MOD0|=DEF_SET_BIT5
#define P23_INPUTHIZ_MODE				P2MOD0&=~DEF_SET_BIT6;P2MOD0|=DEF_SET_BIT7
#define P24_INPUTHIZ_MODE				P2MOD1&=~DEF_SET_BIT0;P2MOD1|=DEF_SET_BIT1
#define P25_INPUTHIZ_MODE				P2MOD1&=~DEF_SET_BIT2;P2MOD1|=DEF_SET_BIT3
#define P26_INPUTHIZ_MODE				P2MOD1&=~DEF_SET_BIT4;P2MOD1|=DEF_SET_BIT5
#define P27_INPUTHIZ_MODE				P2MOD1&=~DEF_SET_BIT6;P2MOD1|=DEF_SET_BIT7

#define SET_ALL_GPIO_INPUTHIZ_MODE		P0MOD0=0x0a;P1MOD0=0xAA;P1MOD1=0xAA;P2MOD0=0xAA;P2MOD1=0xAA

//------------------- Define Port as Push Pull mode -----------------
#define P00_PUSHPULL_MODE				P0MOD0&=~DEF_SET_BIT1;P0MOD0|=DEF_SET_BIT0
#define P01_PUSHPULL_MODE				P0MOD0&=~DEF_SET_BIT3;P0MOD0|=DEF_SET_BIT2

#define P10_PUSHPULL_MODE				P1MOD0&=~DEF_SET_BIT1;P1MOD0|=DEF_SET_BIT0
#define P11_PUSHPULL_MODE				P1MOD0&=~DEF_SET_BIT3;P1MOD0|=DEF_SET_BIT2
#define P12_PUSHPULL_MODE				P1MOD0&=~DEF_SET_BIT5;P1MOD0|=DEF_SET_BIT4
#define P13_PUSHPULL_MODE				P1MOD0&=~DEF_SET_BIT7;P1MOD0|=DEF_SET_BIT6
#define P14_PUSHPULL_MODE				P1MOD1&=~DEF_SET_BIT1;P1MOD1|=DEF_SET_BIT0
#define P15_PUSHPULL_MODE				P1MOD1&=~DEF_SET_BIT3;P1MOD1|=DEF_SET_BIT2
#define P16_PUSHPULL_MODE				P1MOD1&=~DEF_SET_BIT5;P1MOD1|=DEF_SET_BIT4
#define P17_PUSHPULL_MODE				P1MOD1&=~DEF_SET_BIT7;P1MOD1|=DEF_SET_BIT6

#define P20_PUSHPULL_MODE				P2MOD0&=~DEF_SET_BIT1;P2MOD0|=DEF_SET_BIT0
#define P21_PUSHPULL_MODE				P2MOD0&=~DEF_SET_BIT3;P2MOD0|=DEF_SET_BIT2
#define P22_PUSHPULL_MODE				P2MOD0&=~DEF_SET_BIT5;P2MOD0|=DEF_SET_BIT4
#define P23_PUSHPULL_MODE				P2MOD0&=~DEF_SET_BIT7;P2MOD0|=DEF_SET_BIT6
#define P24_PUSHPULL_MODE				P2MOD1&=~DEF_SET_BIT1;P2MOD1|=DEF_SET_BIT0
#define P25_PUSHPULL_MODE				P2MOD1&=~DEF_SET_BIT3;P2MOD1|=DEF_SET_BIT2
#define P26_PUSHPULL_MODE				P2MOD1&=~DEF_SET_BIT5;P2MOD1|=DEF_SET_BIT4
#define P27_PUSHPULL_MODE				P2MOD1&=~DEF_SET_BIT7;P2MOD1|=DEF_SET_BIT6

#define SET_ALL_GPIO_PUSHPULL_MODE		P0MOD0=0x05;P1MOD0=0x55;P1MOD1=0x55;P2MOD0=0x55;P2MOD1=0x55

//------------------- Define Port as Input with Pullup Z ------------
#define P00_INPUT_PULLUPZ				P0PU|=DEF_SET_BIT0
#define P01_INPUT_PULLUPZ				P0PU|=DEF_SET_BIT1

#define P10_INPUT_PULLUPZ				P1PU|=DEF_SET_BIT0
#define P11_INPUT_PULLUPZ				P1PU|=DEF_SET_BIT1
#define P12_INPUT_PULLUPZ				P1PU|=DEF_SET_BIT2
#define P13_INPUT_PULLUPZ				P1PU|=DEF_SET_BIT3
#define P14_INPUT_PULLUPZ				P1PU|=DEF_SET_BIT4
#define P15_INPUT_PULLUPZ				P1PU|=DEF_SET_BIT5
#define P16_INPUT_PULLUPZ				P1PU|=DEF_SET_BIT6
#define P17_INPUT_PULLUPZ				P1PU|=DEF_SET_BIT7

#define P20_INPUT_PULLUPZ				P2PU|=DEF_SET_BIT0
#define P21_INPUT_PULLUPZ				P2PU|=DEF_SET_BIT1
#define P22_INPUT_PULLUPZ				P2PU|=DEF_SET_BIT2
#define P23_INPUT_PULLUPZ				P2PU|=DEF_SET_BIT3
#define P24_INPUT_PULLUPZ				P2PU|=DEF_SET_BIT4
#define P25_INPUT_PULLUPZ				P2PU|=DEF_SET_BIT5
#define P26_INPUT_PULLUPZ				P2PU|=DEF_SET_BIT6
#define P27_INPUT_PULLUPZ				P2PU|=DEF_SET_BIT7

#define SET_ALL_GPIO_INPUT_PULLUPZ		P0PU=0x03;P1PU=0xff;P2PU=0xff
#define CLR_ALL_GPIO_INPUT_PULLUPZ		P0PU=0x0;P1PU=0x0;P2PU=0x0


void GPIO_Init(void);


#endif

/**************************** end of file *********************************************/

