Mikroelektronika MIKROE-350 Fiche De Données

Page de 526
- Expander_Write_PortAB 
- Expander_Set_DirectionPortA
- Expander_Set_DirectionPortB 
- Expander_Set_DirectionPortAB 
- Expander_Set_PullUpsPortA
- Expander_Set_PullUpsPortB 
- Expander_Set_PullUpsPortAB 
Expander_Init
290
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroBasic PRO for AVR
CHAPTER 6
Prototype
sub procedure Expander_Init(dim ModuleAddress as byte)
Returns
Nothing.
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 bot-
tom of this page 
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 defined before using this function. 
SPI module needs to be initialized. See SPI1_Init and SPI1_Init_Advanced routines.
Example
' port expander pinout definition
dim SPExpanderCS as sbit at PORTB.B1
SPExpanderRST 
as sbit at PORTB.B0
SPExpanderCS_Direction 
as sbit at DDRB.B1
SPExpanderRST_Direction 
as sbit at DDRB.B0   
...
SPI1_Init()                ' initialize SPI module
Spi_Rd_Ptr  = @SPI1_Read   ' Pass pointer to SPI Read function
of used SPI module
Expander_Init(0)           ' initialize port expander