Mikroelektronika MIKROE-350 Fiche De Données

Page de 526
PORT EXPANDER LIBRARY
The mikroBasic PRO for AVR provides a library for communication with the
Microchip’s Port Expander MCP23S17 via SPI interface. Connections of the AVR
compliant MCU and MCP23S17 is given on the schematic at the bottom of this
page.
Note: Library uses the SPI module for communication. The user must initialize SPI
module before using the Port Expander Library.
Note: Prior to calling any of this library routines, Spi_Rd_Ptr needs to be initialized
with the appropriate SPI_Read routine.
Note: Library does not use Port Expander interrupts.
External dependencies of Port Expander Library
Library Routines
- Expander_Init 
- Expander_Read_Byte 
- Expander_Write_Byte 
- Expander_Read_PortA
- Expander_Read_PortB 
- Expander_Read_PortAB 
- Expander_Write_PortA
- Expander_Write_PortB 
289
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroBasic PRO for AVR
CHAPTER 6
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 
PORTB.B0
dim SPExpanderRST as
sbit at 
PORTB.B0
Chip Select line.
dim SPExpanderCS 
as
sbit at PORTB.B1
dim
SPExpanderRST_Directi
on 
as sbit sfr
external
Direction of the Reset pin.
dim
SPExpanderRST_Directi
on 
as sbit at DDRB.B0
dim
SPExpanderCS_Direction
as sbit sfr external
Direction of the Chip
Select pin.
dim
SPExpanderCS_Directio
ns 
as sbit at DDRB.B1