Mikroelektronika MIKROE-742 데이터 시트
- Expander_Set_DirectionPortA
- Expander_Set_DirectionPortB
- Expander_Set_DirectionPortAB
- Expander_Set_PullUpsPortA
- Expander_Set_PullUpsPortB
- Expander_Set_PullUpsPortAB
- Expander_Set_DirectionPortB
- Expander_Set_DirectionPortAB
- Expander_Set_PullUpsPortA
- Expander_Set_PullUpsPortB
- Expander_Set_PullUpsPortAB
Expander_Init
303
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroPASCAL PRO for AVR
CHAPTER 6
Prototype
procedure Expander_Init(ModuleAddress : 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
- 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 module connections
var SPExpanderCS : sbit at PORTB.B1;
var SPExpanderCS : sbit at PORTB.B1;
SPExpanderRST :
sbit at PORTB.B0;
SPExpanderCS_Direction :
sbit at DDRB.B1;
SPExpanderRST_Direction :
sbit at DDRB.B0;
// End of Port Expander module connections
...
SPI1_Init(); // initialize SPI module
Spi_Rd_Ptr := @SPI1_Read; // Pass pointer to SPI Read function
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