Pitx-sp software guide – Kontron pITX-SP User Manual

Page 26

Advertising
background image

KTD-S0003-C

Page 22

CPLD Interface


p

ITX-SP Software Guide

//*********************************************************
//* Sets clock line low
//*********************************************************
void SCL_Low (void)
{

i2c_bits &= ~I2C_CLOCK;

outp (CPLD_BASE_ADDR+1, i2c_bits);

}

//*********************************************************
//* Sets data line high
//*********************************************************
void SDA_High (void)
{

i2c_bits |= I2C_DATA;

outp (CPLD_BASE_ADDR+1, i2c_bits);

}

//*********************************************************
//* Sets data line low
//*********************************************************
void SDA_Low (void)
{

i2c_bits &= ~I2C_DATA;

outp (CPLD_BASE_ADDR+1, i2c_bits);

}

//*********************************************************
//* Reads data line
//*********************************************************
int SDA_Read (void)
{
int

i2c_val;

outp (CPLD_BASE_ADDR, GPIO_INPUT);

i2c_val = inp (CPLD_BASE_ADDR+1);

i2c_val &= I2C_DATA;

outp (CPLD_BASE_ADDR, GPIO_OUTPUT);

return

i2c_val;

}

//*********************************************************
//* Delay routine
//*********************************************************
void I2C_Delay (void)
{

_asm push cx

_asm xor ah, ah

_asm mov cx, I2C_DELAY_VAL

_Loop:

_asm in al, 61h

_asm and al, 0010000b

_asm cmp al, ah

_asm je _Loop

Advertising