Kta55/pitx software guide – Kontron KTA55-pITX User Manual
Page 19
KTD-S0043-A
Page 16
GPIO Interface
KTA55/pITX Software Guide
void WriteDigitalIO (u8 port, u8 value)
{
u8 content, *ptr = (u8 *) GPIO_BASE_ADDR;
ptr += port;
content = *ptr;
content &= ~(1 << OUT_SHIFT);
*ptr = content | ((value & 1) << OUT_SHIFT);
}
u8 ReadDigitalIO (u8 port)
{
u8 value, *ptr = (u8 *) GPIO_BASE_ADDR;
ptr += port;
value = *ptr;
return ((value >> IN_SHIFT) & 1);
}
// Variable 'dir':
// 0 = Output
// 1 = Input
void SetDirectionIO (u8 port, u8 dir)
{
u8 content, *ptr = (u8 *) GPIO_BASE_ADDR;
ptr += port;
content = *ptr;
content &= ~(1 << DIR_SHIFT);
*ptr = content | ((dir & 1) << DIR_SHIFT);
}
// Variable 'pu':
// 0 = Pullup enable
// 1 = Pullup disable
void SetPullupIO (u8 port, u8 pu)
{
u8 content, *ptr = (u8 *) GPIO_BASE_ADDR;
ptr += port;
content = *ptr;
content &= ~(1 << PU_SHIFT);
*ptr = content | ((pu & 1) << PU_SHIFT);
}
// Variable 'pd':
// 0 = Pulldown disable
// 1 = Pulldown enable
void SetPulldownIO (u8 port, u8 pd)
{
u8 content, *ptr = (u8 *) GPIO_BASE_ADDR;
ptr += port;
content = *ptr;
content &= ~(1 << PD_SHIFT);
*ptr = content | ((pd & 1) << PD_SHIFT);
}