Mikroelektronika MIKROE-742 데이터 시트

다운로드
페이지 532
Port Expander Library
The mikroPascal 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 
- Expander_Write_PortAB 
302
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroPASCAL PRO for AVR
CHAPTER 6
The following variables
must be defined in all
projects using Port
Expander Library:
Description: 
Example : 
var SPExpanderRST :
sbit; sfr; external;
Reset line.
var SPExpanderRST :
sbit at PORTB.B0;
var SPExpanderCS :
sbit; sfr; external;
Chip Select line.
var SPExpanderCS :
sbit at PORTB.B1;
var
SPExpanderCS_Directio
n : 
sbit; sfr;
external;
Direction of the Reset pin.
var
SPExpanderRST_Directi
on : 
sbit at DDRB.B0;
var
SPExpanderCS_Directio
n : 
sbit; sfr;
external;
Direction of the Chip
Select pin.
var
SPExpanderCS_Directio
n : 
sbit at DDRB.B1;