CPC314
C P C 3 1 4 U s e r M a n u a l
52
© 2 0 2 1 F a s t w e l V e r . 0 0 1
outpd( 0xCFC, pci_reg );
// write register
}
enable();
// enable interrupts
If the “SB Clock” parameter in BIOS Setup is set to “100 MHz” (Advanced → South Bridge
Configuration → ISA Configuration), then this function will set the reference frequency not to 24
MHz, but to 48 MHz. When the “SB Clock” parameter is set in BIOS Setup by default (100 MHz),
the Set_Base24MHz_UART1 () function will set the reference frequency to 48 MHz.
Attention!
Changing the value of the “SB Clock" parameter influences over the frequency of ISA bus.
4.9 Working with I2C devices
As an example of working with i2c devices, you can use the vortex86_i2c library (library files
“vortex86_i2c.c”, “vortex86_i2c.h” and sample files are available on the manufacturer's and
distributor's ftp servers.
The library is collected within a free Open Watcom C/C ++ package.
The library implements the following functions:
●
uint16_t I2C_GetBase() – returns the base address in the I/O space used for i2c buses
●
void I2C_SetBase( uint16_t ba ) – sets a base address in the I/O space that is used for i2c buses
●
void I2C_PowerOff( uint8_t channel ) – disables the specified i2c bus
●
void I2C_PowerOn( uint8_t channel ) – enables the specified i2c bus
●
uint16_t I2C_Init( uint8_t channel ) – configures the specified bus and returns the base address
●
uint16_t I2C_Start( uint8_t channel, uint8_t addr, uint8_t gen_stop, uint16_t timeout ) – generates the start on the
bus and sets the device address. The function will return the remainder of the timeout parameter
●
uint16_t I2C_ReadByte( uint8_t channel, uint8_t * dat, uint8_t lastbyte, uint16_t timeout ) – reads one byte. For the
last byte, the lastbyte parameter must not be equal to 0. The function returns the remainder of the timeout
parameter
●
uint16_t I2C_WriteByte( uint8_t channel, uint8_t dat, uint8_t lastbyte, uint16_t timeout ) – writes one byte. For the
last byte, the lastbyte parameter must not be equal to 0. The function returns the remainder of the timeout
parameter
●
uint16_t I2C_ReadByteReg( uint8_t channel, uint8_t addr, uint8_t reg, uint8_t * dat, uint16_t timeout ) reads a byte
from the i2c device with the addr address from register reg. The function will return the remainder of the timeout
parameter
●
uint16_t I2C_ReadWordReg( uint8_t channel, uint8_t addr, uint8_t reg, uint16_t * dat, uint16_t timeout ) reads a
word from i2c device with the addr address from register reg. The function will return the remainder of the timeout
parameter
●
uint16_t I2C_WriteByteReg( uint8_t channel, uint8_t addr, uint8_t reg, uint8_t dat, uint16_t timeout ) writes a byte
to the i2c device with the addr address to register reg. The function will return the remainder of the timeout
parameter
●
uint16_t I2C_WriteWordReg( uint8_t channel, uint8_t addr, uint8_t reg, uint16_t dat, uint16_t timeout ) writes a
word to i2c device with the addr address to register reg. The function will return the remainder of the timeout
parameter