I2C Bus and SPI Interface - SC12 @CHIP-RTOS V1.10
IPC@CHIP Documentation Index
I2C Bus / SPI API News
I2C Bus / SPI API
Here are the interface definitions for access to the IPC@CHIP's I2C bus and
Software SPI.
Philips was the inventor of the Inter-IC or I²C-bus, and it is now firmly
established as the worldwide de-facto solution for embedded applications.
It is used extensively in a variety of microcontroller-based professional,
consumer and telecommunications applications as a control, diagnostic and
power management bus. As a two-wire serial bus, its inherently simple
operation was crucial to its emergence as the worldwide de-facto standard.
SPI is a serial bus standard established by Motorola. The Serial Peripheral
Interface (SPI) is a synchronous serial interface useful for communicating
with other peripheral or microcontroller devices. These peripheral devices
may be Serial EEPROMs, shift registers, display drivers, A/D converters, etc.
API Functions
The I2C Bus / SPI API provides interrupt 0xAA with a service number in the high
order byte of the AX register (AH).
This interface provides access to the I2C Bus and Software SPI of the IPC@CHIP
for application programs.
Interrupt 0xAA service 0x80: Initialize the I2C Bus
- This function initializes the I2C bus. It enables the two defined PIO
pins for I2C usage (see also function 8eh and 8fh).
Parameters
- AH
- 0x80
Comments
- The user can specify which two PIO are used for I2C
clock and data.
After calling this initialization function, these two pins will no longer be available
as PIO pins unless the PFE Enable function
is called for these pins following this function call.
Related Topics
-
- Select I2C Clock Pin
-
- Select I2C Data Pin
-
- PFE: Enable Programmable I/O Pins
Top of list Index page
Interrupt 0xAA service 0x81: Scan I2C Devices
- Report addresses of slave devices, one at a time.
Parameters
- AH
- 0x81
- AL
- First slave address (even address, LSB=0)
- CL
- Last slave address (even address, LSB=0)
Return Value
- AL: 0 no slave found
AL: -1 Timeout
AL: address of the first found slave
Comments
- This is an iterator function which is called repetitively to determine
all connected slaves. Specify on each successive call a new restricted
slave address range until no further address is returned by this function.
Top of list Index page
Interrupt 0xAA service 0x82: Transmit / Receive Character
- Send or receive a single character.
Parameters
- AH
- 0x82
- AL
- Slave address, LSB:0 => Transmit, LSB:1 => Receive
- CL
- If Transmit: CL = Byte to transmit
If Receive: CL = 0 for last char to be received
Return Value
- Success: Carry flag cleared and CH contains received byte (if receiving)
Failure: Carry flag set and AL contains I2C error
code
Comments
- The IPC@CHIP is the I2C bus master.
The least significant bit of the slave address determines the direction
of the communication.
Even address: Master sending to slave
Odd address: Master receiving from slave
If the direction or the slave address changes, this functions executes the I2C
restart function automatically. This will insert a I2C start condition on the
bus. After this, the I2C address is send again.
I2C error codes:
8: Timeout
9: Slave faulty or not available
Related Topics
-
- I2C Transmit/Receive Block
Top of list Index page
Interrupt 0xAA service 0x83: Transmit/ Receive Block
Parameters
- AH
- 0x83
- AL
- Slave address, LSB:0 => Transmit, LSB:1 => Receive
- CX
- Number of bytes to transmit or receive
- ES:BX
- Buffer address
Return Value
- Success: Carry flag cleared
Failure: Carry flag set and AL contains I2C error
code
Comments
- If an odd slave address is specified in AL then this function will dwell
here until either CX bytes are received and stored in user buffer at [ES:BX], or
until an error occurs. For an even slave address this function will
dwell here until CX bytes from user buffer at [ES:BX] are transmit or until an
error occurs.
If the direction or the slave address changes, this functions executes the I2C
restart function automatically. This will insert a I2C start condition on the
bus. After this, the I2C address is send again.
Related Topics
-
- I2C Transmit/Receive Character
Top of list Index page
Interrupt 0xAA service 0x84: Release I2C Bus
Parameters
- AH
- 0x84
Comments
- This function generates an I2C stop condition. (The Bus will be
released). At next call of transmit or receive functions, the address
will be send again.
Top of list Index page
Interrupt 0xAA service 0x8b: Restart the I2C Bus
Parameters
- AH
- 0x8b
Return Value
- CF: 0
Comments
- This function generates an I2C start condition. (The Bus will be
reserved)
Top of list Index page
Interrupt 0xAA service 0x8E: Select I2C Clock Pin
- Select IPC@CHIP I/O pin to be used for I2CCLK signal.
Parameters
- AH
- 0x8E
- AL
- PIO pin number, [0..13]
Return Value
- none
Comments
- The default I2C clock pin is PIO 0
To change the I2CCLK pin this function must be called before
the I2C initialize
function (0x80) is called.
Related Topics
-
- Initialize I2C Bus Function
-
- Select I2C Data Pin
Top of list Index page
Interrupt 0xAA service 0x8F: Select I2C Data Pin
- Select IPC@CHIP I/O pin to be used for I2CDAT signal.
Parameters
- AH
- 0x8F
- AL
- PIO pin number, [0..13]
Return Value
- none
Comments
- The default I2C data pin is PIO 1
To change the I2CDAT pin this function must be called before
the I2C initialize
function (0x80) is called.
Related Topics
-
- Initialize I2C Bus Function
-
- Select I2C Clock Pin
Top of list Index page
Interrupt 0xAA service 0x90: SPI Init
- Init the SPI Interface.
SPI specifies four signals: clock (SCLK); master data output,
slave data input (MOSI); master data input, slave data output (MISO);
and slave select (CSS). The slave select signal pin is not specified with the
SPI init function and not activated with the SPI read and write functions.
The user has to enable any other PIO pin for that purpose and should serve this
pin manually.
Parameters
- AH
- Must be 0x90
- BX
- Mode, must be 0
- CL
- Pio number for SPI Clock Pin (SCLK)
- CH
- Pio number for SPI Input Pin (MISO)
- DL
- Pio number for SPI Output Pin (MOSI)
Return Value
- none
Comments
- none
Related Topics
-
- Read SPI Block
-
- Write SPI Block
Top of list Index page
Interrupt 0xAA service 0x95: SPI Write Block
- Write n bytes out to the SPI Output pin
Parameters
- AH
- Must be 0x95.
- ES:SI
- Pointer to write buffer
- CX
- Number of bytes in buffer to write
Return Value
- none
Comments
- None
Related Topics
-
- Init SPI
-
- Read Block SPI
Top of list Index page
Interrupt 0xAA service 0x96: SPI Read Block
- Reads n bytes from the SPI Input pin
Parameters
- AH
- Must be 0x96
- ES:DI
- Pointer to buffer for storing read data
- CX
- Number of bytes to read
Return Value
- none
Comments
- None
Related Topics
-
- Init SPI
-
- Write SPI Block
Top of list Index page
Interrupt 0xAA service 0x97: SPI Read and Write Block
- Reads n bytes from the SPI Input pin and
write n bytes out to the SPI Output pin simultaneously.
Parameters
- AH
- Must be 0x97
- DS:DI
- Pointer to buffer for storing read data
- ES:SI
- Pointer to buffer which stores write data
- CX
- Number of bytes to read and write
Return Value
- none
Comments
- None
Related Topics
-
- Init SPI
-
- Write SPI Block
-
- Read SPI Block
Top of list Index page
End of document
|