Appendix
- 38 -
CPC-1814CLD5NA-N
(2)
Input/output program:
//I/O program
write_gpio(1, input[OUTPUT1]) //set OUTPUT1 to high level
write_gpio(0, input[OUTPUT1]) //set OUTPUT1 to low level
read_gpio(input[INPUT1]) //read INPUT1, return 1 is high level while return 0 is
low level
Required user-defined functions
/*************************************************************
Function Name: GPIO initialization function initializ_gpio(int pin_NO)
Input Parameters: (PIN number)
Functions: initialize GPIO according to DATASHEET specification
*************************************************************/
void initializ_gpio(int pin_NO)
{
unsigned int ioadd=(BAR+0x00);
unsigned
char
mask;
int
offset=pin_NO/8;
unsigned char tempv;
//*********************
if(pin_NO>=32)
{
ioadd=(BAR+0x30);
offset=(pin_NO-32)/8;
}
//*********************
while(offset!=0)
{