Mikroelektronika MIKROE-742 데이터 시트

다운로드
페이지 532
Expander_Read_PortAB
Expander_Write_PortA
306
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroPASCAL PRO for AVR
CHAPTER 6
Prototype
function Expander_Read_PortAB(ModuleAddress: byte): word;
Returns
Word read.
Description
The function reads word from Port Expander's ports. PortA readings are in the
higher byte of the result. PortB readings are in the lower byte of the result.
Parameters : 
ModuleAddress
: Port Expander hardware address, see schematic at the bot-
tom of this page 
Requires
Port Expander must be initialized. See Expander_Init.
Port Expander's PortA and PortB should be configured as inputs. See
Expander_Set_DirectionPortA, Expander_Set_DirectionPortB and
Expander_Set_DirectionPortAB routines.
Example
// Read a byte from Port Expander's PORTA and PORTB
var read_data : word;
...
Expander_Set_DirectionPortAB(0,0xFFFF);        // set expander's
porta and portb to be input
...
read_data := Expander_Read_PortAB(0);
Prototype
procedure Expander_Write_PortA(ModuleAddress: byte; Data_: byte);
Returns
Nothing.
Description
The function writes byte to Port Expander's PortA.
Parameters : 
ModuleAddress
: Port Expander hardware address, see schematic at the bot-
tom of this page 
Data_
: data to be written 
Requires
Port Expander must be initialized. See Expander_Init.
Port Expander's PortA should be configured as output. See
Expander_Set_DirectionPortA and Expander_Set_DirectionPortAB routines.
Example
// Write a byte to Port Expander's PORTA
...
Expander_Set_DirectionPortA(0,0x00);        // set expander's
porta to be output
...
Expander_Write_PortA(0, 0xAA);