請先看『使用說明』
IO Device:F81801 DIO under Linux
From LEXWiKi
(Difference between revisions)
(New page: == The Sample code source you can download from == Source file: [ftp://ftp.lex.com.tw/Engineer/SoftSupport/AP_Module/F81801_DIO/linux/F81801_DIO_v0.2_Src_L.tar.gz F81801_DIO_v0.2_Src_L.ta...) |
(→F81801 OPEN) |
||
Line 22: | Line 22: | ||
return FALSE; | return FALSE; | ||
} | } | ||
+ | |||
=== F81801 CLOSE === | === F81801 CLOSE === | ||
void F81801U_Close() | void F81801U_Close() |
Revision as of 09:01, 15 February 2022
Contents |
The Sample code source you can download from
Source file: F81801_DIO_v0.2_Src_L.tar.gz
Binary file: F81801_DIO_v0.2_x32_Bin_L.tar.gz
F81801_DIO_v0.2_x64_Bin_L.tar.gz
Google Drive: F81801 DIO under Linux
How to use this Demo Application
Introduction
F81801 OPEN
BOOL F81801U_Open() { outb(0x87, 0x2e); outb(0x87, 0x2e); if (F81801U_Read(CHIP_ID_REGISTER1) == CHIP_ID_DEFAULT_VALUE1 && F81801U_Read(CHIP_ID_REGISTER2) == CHIP_ID_DEFAULT_VALUE2) return TRUE; return FALSE; }
F81801 CLOSE
void F81801U_Close() { outb(0xaa,0x2e); }
Initial internal F81801
void F81801U_Init() { F81801U_Write(Logic_Device_Number_Register, GPIO_Device_Configuration_Registers);// GPIO Device Configuration Registers (LDN CR06) F81801U_Write(GPIO3_Output_Enable_Register, 0xf0);//GPIO34~GPIO37 OUTPUT SET / GPIO30~GPIO33 INPUT SET F81801U_Write(GPIO3_Drive_Enable_Register, 0xf0);//GPIO34~GPIO37 DRIVE SET
}
F81801U READ
DWORD F81801U_Read(DWORD dwAddrVal) { DWORD dwPortVal; outb(dwAddrVal, 0x2e ); dwPortVal=inb( 0x2f ); return (dwPortVal & 0x00FF); }
F81801U WRITE
void F81801U_Write(DWORD dwAddrVal, DWORD dwPortVal) { outb(dwAddrVal, 0x2e ); outb(dwPortVal, 0x2f ); }
F81801U GetDigitalInput
BYTE F81801U_GetDigitalInput() { CString tmp; BYTE byteGPIO3X = 0; BYTE byteData = 0; byteGPIO3X = F81801U_Read(GPIO3_Pin_Status_Register); byteData = byteGPIO3X & 0x0F; return byteData; }
F81801U SetDigitalOutput
void F81801U_SetDigitalOutput(BYTE byteValue) { BYTE byteData = 0; byteData = (byteValue & 0x01) ? byteData + 0x10 : byteData; byteData = (byteValue & 0x02) ? byteData + 0x20 : byteData; byteData = (byteValue & 0x04) ? byteData + 0x40 : byteData; byteData = (byteValue & 0x08) ? byteData + 0x80 : byteData; F81801U_Write(GPIO3_Output_Data_Register, byteData); }