Gpio Sample Code - MSI MS-98H3 Manual

Industrial computer board
Table of Contents

Advertisement

GPIO Sample Code

1. General Purposed IO – GPIO/DIO 
The GPIO port configuration addresses are listed in the following table: 
Name 
IO Port 
N_GPI0 
N_GPI1 
N_GPI2 
N_GPI3 
N_GPI4 
N_GPI5 
N_GPI6 
N_GPI7 
Note: GPIO should be accessed through controller device 0x6E on SMBus. The associated access method in 
examples (SMBus_ReadByte, SMBus_WriteByte) are provided in part 4. 
 
1.1 Set output value of GPO 
1.
Read the value from GPO port. 
2.
Set the value of GPO address. 
3.
Write the value back to GPO port. 
 
Example: Set N_GPO0 output "high" 
val =SMBus_ReadByte (0x6E, 0x41); 
val = val | (1<<0);   
SMBus_WriteByte (0x6E, 0x41, val); 
 
Example: Set N_GPO1 output "low" 
val = SMBus_ReadByte (0x6E, 0x11); 
val = val & (~(1<<3)); 
SMBus_WriteByte (0x6E, 0x11, val); 
 
1.2 Read input value from GPI: 
1. Read the value from GPI port. 
2. Get the value of GPI address. 
 
Example: Get N_GPI2 input value. 
val = SMBus_ReadByte (0x6E, 0x42); 
val = val & (1<<3);   
if (val)     
printf ("Input of    N_GPI2    is High"); 
printf ("Input of    N_GPI2    is Low"); 
else     
 
Example: Get N_GPI6 input value. 
val = SMBus_ReadByte (0x6E, 0x22); 
val = val & (1<<6);   
if (val)     
printf ("Input of    N_GPI6    is High"); 
else     
printf ("Input of    N_GPI6    is Low"); 
IO address 
0x42 
Bit 1 
0x42 
Bit 2 
0x42 
Bit 3 
0x22 
Bit 3 
0x22 
Bit 4 
0x22 
Bit 5 
0x22 
Bit 6 
0x22 
Bit 7 
// Read value from N_GPO0 port through SMBus. 
 
 
// Set N_GPO0address (bit 0) to 1 (output "high"). 
// Write back to N_GPO0 port through SMBus. 
// Read value from N_GPO1 port through SMBus.. 
 
 
// Set N_GPO1 address (bit 3) to 0 (output "low"). 
// Write back to N_GPO1 port through SMBus. 
// Read value from N_GPI2 port through SMBus. 
 
 
// Read N_GPI2 address (bit 3). 
// Read value from N_GPI6 port through SMBus. 
 
 
// Read N_GPI6 address (bit 6). 
Name 
IO Port 
N_GPO0 
0x41 
N_GPO1 
0x11 
N_GPO2 
0x11 
N_GPO3 
0x11 
N_GPO4 
0x21 
N_GPO5 
0x21 
N_GPO6 
0x21 
N_GPO7 
0x11 
MS-98H3
IO address 
Bit 0 
Bit 3 
Bit 6 
Bit 7 
Bit 0 
Bit 1 
Bit 2 
Bit 4 
A-3

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents