User manual
442
mikoC PRO for dsPIC
MikroElektronika
Expander_Init
Prototype
void Expander_Init(char ModuleAddress);
Description Initializes Port Expander using SPI communication.
Port Expander module settings :
- hardware addressing enabled
- automatic address pointer incrementing disabled (byte mode)
- BANK_0 register adressing
- slew rate enabled
Parameters - ModuleAddress: Port Expander hardware address, see schematic at the bottom of this page
Returns Nothing.
Requires Global variables :
- SPExpanderCS: Chip Select line
- SPExpanderRST: Reset line
- SPExpanderCS_Direction: Direction of the Chip Select pin
- SPExpanderRST_Direction: Direction of the Reset pin
must be dened before using this function.
SPI module needs to be initialized. See SPIx_Init and SPIx_Init_Advanced routines.
Example
// Port Expander module connections
sbit SPExpanderRST at RF0_bit;
sbit SPExpanderCS at RF1_bit;
sbit SPExpanderRST_Direction at TRISF0_bit;
sbit SPExpanderCS_Direction at TRISF1_bit;
// End Port Expander module connections
...
// If Port Expander Library uses SPI module
SPI1_Init(); // Initialize SPI module used with PortExpander
Expander_Init(0); // Initialize Port Expander
Notes None.