Mikroelektronika MIKROE-724 データシート

ページ / 726
mikroBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
417
Port Expander Library
mikroBasic PRO for dsPIC30/33 and PIC24 provides a library for communication with the Microchip’s Port Expander 
MCP23S17 via SPI interface. Connections of the dsPIC30/33 and PIC24 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:
dim  SPExpanderRST  as  sbit  sfr 
external
Reset line.
dim  SPExpanderRST  as  sbit  at  LATF0_
bit
dim  SPExpanderCS  as  sbit  sfr 
external
Chip Select line.
dim SPExpanderCS as sbit at LATF1_bit
dim  SPExpanderRST_Direction  as 
sbit sfr external
Direction of the Reset pin.
dim SPExpanderRST_Direction as sbit at 
TRISF0_bit
dim  SPExpanderCS_Direction  as 
sbit sfr external
Direction of the Chip Select pin.
dim SPExpanderCS_Directions as sbit 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