Mikroelektronika MIKROE-738 Datenbogen

Seite von 682
mikroC PRO for PIC32
MikroElektronika
385
Port Expander Library
The mikroC PRO for PIC32 provides a library for communication with the Microchip’s Port Expander MCP23S17 via 
SPI interface. Connections of the PIC32 MCU and MCP23S17 is given on the schematic at the bottom of this page.
Important: 
- The library uses the SPI module for communication. User must initialize the appropriate SPI module before using 
  the Port Expander Library. 
- For MCUs with multiple SPI modules it is possible to initialize all of them and then switch by using the 
SPI_Set_
Active() 
function. See the SPI Library functions. 
- Library does not use Port Expander interrupts. 
Library Dependency Tree
The following variables must be defined 
in  all  projects  using  Port  Expander 
Library:
Description:
Example:
extern sfr sbit 
SPExpanderRST;
Reset line.
sbit SPExpanderRST at RF0_bit;
extern sfr sbit
SPExpanderCS;
Chip Select line.
sbit SPExpanderCS at RF1_bit;
extern sfr sbit 
SPExpanderRST_Direction;
Direction of the Reset pin.
sbit 
SPExpanderRST_Direction 
at 
TRISF0_bit;
extern sfr sbit 
SPExpanderCS_Direction;
Direction of the Chip Select pin.
sbit 
SPExpanderCS_Direction 
at 
TRISF1_bit;
External dependencies of Port Expander Library
Library Routines
 
- Expander_Init 
 
- Expander_Init_Advanced 
 
- Expander_Read_Byte 
 
- Expander_Write_Byte 
 
- Expander_Read_PortA 
 
- Expander_Read_PortB 
 
- Expander_Read_PortAB 
 
- Expander_Write_PortA 
 
- Expander_Write_PortB 
 
- Expander_Write_PortAB 
 
- Expander_Set_DirectionPortA 
 
- Expander_Set_DirectionPortB 
 
- Expander_Set_DirectionPortAB 
 
- Expander_Set_PullUpsPortA 
 
- Expander_Set_PullUpsPortB 
 
- Expander_Set_PullUpsPortAB