Datasheet

PORT EXPANDER LIBRARY
The mikroC 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: 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
- Expander_Set_DirectionPortA
- Expander_Set_DirectionPortB
- Expander_Set_DirectionPortAB
- Expander_Set_PullUpsPortA
- Expander_Set_PullUpsPortB
- Expander_Set_PullUpsPortAB
353
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroC PRO for AVR
CHAPTER 6
The following variables must be
defined in all projects using
Manchester Code Library:
Description: Example:
extern sfr sbit
SPExpanderRST;
Reset line.
sbit SPExpanderRST
at PORTB.B0;
extern sfr sbit
SPExpanderCS;
Chip Select line.
sbit SPExpanderCS
at PORTB.B1;
extern sfr sbit
SPExpanderRST_Direction;
Direction of the
Reset pin.
sbit
SPExpanderRST_Dire
ction at DDRB.B0;
extern sfr sbit
SPExpanderCS_Direction;
Direction of the Chip
Select pin.
sbit
SPExpanderCS_Direc
tion at DDRB.B1;