Appendix B F75111N DIO & Watchdog device¶
The Arrakis MK3 is available with optional DIO Ports, this chapter introduces programming.
Watchdog timer under DOS¶
You can download the Sources in the Driver Download Folder in Chapter 9 in the DIO folder.
Source file: F75111_Dos_Src.rar Binary file: F75111_Dos_Bin.rar USERNAME & PASSWORD: sf
How to use this Demo Application:
Boot Ms-Dos Operating System
Execute “75WDT.EXE” binary file
Input 1 to Enable WDT timer or input 0 to Disable it.
Input the numbers of second for chip countdown and Reset Computer
Introduction: How to use the Watchdog Time Demo in different ways:
WriteI2CByte(I2CADDR, CONFIG, 0x03);//Set Watch Dog Timer function
WriteI2CByte(I2CADDR, WDT_TIMER, timer);//Set Watch Dog Timer range from 0-255.
WriteI2CByte(I2CADDR, WDT_TIMER_CTL, 0x73);//Enable Watch Dog Timer in second and pulse mode
Or
WriteI2CByte(I2CADDR, WDT_TIMER_CTL, 0x00);
Or
void pause(int time) {
asm mov ah, 0h; // Ah = 00 Read System Time Counter
asm int 1ah; // read time from Time Counter and store it in DX register
asm add dx, time;
asm mov bx, dx;
label:
asm int 1ah;
asm cmp bx, dx;
asm jne label;
}
Watchdog Timer and DIO under Windows¶
You can download the Sources in the Driver Download Folder in Chapter 9 in the DIO folder.
Source file: F75111_DIOSrc.rar Binary file: F75111_DemoBin.rar USERNAME & PASSWORD: sf
How to use the Demo Application:
Press the “Start” button to test DIO function
Press the “Enable” button to test WDT function
Press the “Disable” button to disable WDT
Check the “Enable Loop” box and press “Enable” to do WDT loop test
Press “Install WDT” to set the system to autorun this application when booting,press again to remove this application when booting. The Icon will show when active.
F75111 will send “F75111_SetWDTEnable(BYTE byteTimer)” including a parameter “timer”, If there’s no disable signal (F75111_SetWDTDisable()) to stop it before timer countdown to 0, System will reboot. If there’s disable signal received, resent Enable WDT signal to prevent a reboot loop.
Introduction: Initial Internal F75111 port address (0x9c) Define GPIO1X, GPIO2X, GPIO3X to input or output and Enable WDT function pin
Set F75111 DI/DO (sample code as below Get Input value/Set output value) DO: InterDigitalOutput(BYTE byteValue) DI: InterDigitalInput()
Enable/Disable WDT: Enable: F75111_SetWDTEnable (BYTE byteTimer) Disable: F75111_SetWDTDisable ()
PULSE mode: Sample to setting GP33, 32, 31, 30 output 1mS low pulse signal.
{
this->Write_Byte(F75111_INTERNAL_ADDR, GPIO3X_PULSE_CONTROL, 0x00); // This is setting low pulse output
this->Write_Byte(F75111_INTERNAL_ADDR, GPIO3X_PULSE_WIDTH_CONTROL, 0x01); // This selects the pulse width to 1mS
this->Write_Byte(F75111_INTERNAL_ADDR, GPIO3X_CONTROL_MODE, 0x0F); // This is setting the GP33, 32, 31, 30 to output function.
this->Write_Byte(F75111_INTERNAL_ADDR, GPIO3X_Output_Data, 0x0F); // This is setting the GP33, 32, 31, 30 output data.
}
Sample to setting GP33, 32, 31, 30 output 1mS low pulse signal.
void F75111::InitInternalF75111() {
this->Write_Byte(F75111_INTERNAL_ADDR, GPIO1X_CONTROL_MODE, 0x00); // set GPIO1X to Input function
this->Write_Byte(F75111_INTERNAL_ADDR, GPIO3X_CONTROL_MODE, 0x00); // set GPIO3X to Input function
this->Write_Byte(F75111_INTERNAL_ADDR, GPIO2X_CONTROL_MODE, 0xFF); // set GPIO2X to Output function
this->Write_Byte(F75111_INTERNAL_ADDR, F75111_CONFIGURATION, 0x03); // Enable WDT OUT function
}
Set output value:
void F75111::InterDigitalOutput(BYTE byteValue) {
BYTE byteData = 0;
byteData = (byteData & 0x01) ? byteValue + 0x01 : byteValue;
byteData = (byteData & 0x02) ? byteValue + 0x02 : byteValue;
byteData = (byteData & 0x04) ? byteValue + 0x04 : byteValue;
byteData = (byteData & 0x80) ? byteValue + 0x08 : byteValue;
byteData = (byteData & 0x40) ? byteValue + 0x10 : byteValue;
byteData = (byteData & 0x20) ? byteValue + 0x20 : byteValue;
byteData = (byteData & 0x10) ? byteValue + 0x40 : byteValue;
byteData = (byteData & 0x08) ? byteValue + 0x80 : byteValue; // get value bit by bit
this->Write_Byte(F75111_INTERNAL_ADDR, GPIO2X_OUTPUT_DATA, byteData); // write byteData value via GPIO2X output pin
}
Get Input value:
BYTE F75111::InterDigitalInput() {
BYTE byteGPIO1X = 0;
BYTE byteGPIO3X = 0;
BYTE byteData = 0;
this->Read_Byte(F75111_INTERNAL_ADDR, GPIO1X_INPUT_DATA, &byteGPIO1X); // Get value from GPIO1X
this->Read_Byte(F75111_INTERNAL_ADDR, GPIO3X_INPUT_DATA, &byteGPIO3X); // Get value from GPIO3X
byteGPIO1X = byteGPIO1X & 0xF0; // Mask unuseful value
byteGPIO3X = byteGPIO3X & 0x0F; // Mask unuseful value
byteData = (byteGPIO1X & 0x10) ? byteData + 0x01 : byteData;
byteData = (byteGPIO1X & 0x80) ? byteData + 0x02 : byteData;
byteData = (byteGPIO1X & 0x40) ? byteData + 0x04 : byteData;
byteData = (byteGPIO3X & 0x01) ? byteData + 0x08 : byteData;
byteData = (byteGPIO3X & 0x02) ? byteData + 0x10 : byteData;
byteData = (byteGPIO3X & 0x04) ? byteData + 0x20 : byteData;
byteData = (byteGPIO3X & 0x08) ? byteData + 0x40 : byteData;
byteData = (byteGPIO1X & 0x20) ? byteData + 0x80 : byteData; // Get correct DI value from GPIO1X & GPIO3X
return byteData;
}
Enable WatchDog:
void F75111_SetWDTEnable(BYTE byteTimer) {
WriteByte(F75111_INTERNAL_ADDR, WDT_TIMER_RANGE, byteTimer); // set WatchDog range and timer
WriteByte(F75111_INTERNAL_ADDR, WDT_CONFIGURATION, WDT_TIMEOUT_FLAG | WDT_ENABLE | WDT_PULSE | WDT_PSWIDTH_100MS);
// Enable WatchDog, Setting WatchDog configure
}
Disable WatchDog:
void F75111_SetWDTDisable() {
WriteByte(F75111_INTERNAL_ADDR, WDT_CONFIGURATION, 0x00); // Disable WatchDog
}
IO Device: F75111 VB6 under Windows¶
You can download the Sources in the Driver Download Folder in Chapter 9 in the DIO folder.
Source file: 75111_VB_v10.rar Binary file: 75111_VB_Src.rar111_DemoBin.rar USERNAME & PASSWORD: sf
How to use this Demo Application:
A Function - Enable WDT timer, Key-in the value by seconds then system will reboot after value which you key-in in left text box! B Function - Disable WDT timer, Push down the button then WDT timer value will be clear !! C Function - Set DO Value, Key-in the DO value by hex then push the button !! D Function - Check DI Value, the right side two text box will display DI 1X & 2X Value when you push down the button!!
SDK Function Introduction¶
Function EnableWDT:
Function EnableWDT(timer As Integer)
Call WriteI2CByte(&H3, &H3)
Call WriteI2CByte(&H37, timer)
Call WriteI2CByte(&H36, &H73)
End Function
Function DisableWDT:
Function DisableWDT()
Call WriteI2CByte(&H36, &H0)
End Function
Function SetDOValue:
Function SetDOValue(dovalue As Integer)
Call WriteI2CByte(&H23, &H0)
Call WriteI2CByte(&H20, &HFF)
Call WriteI2CByte(&H2B, &HFF)
Call WriteI2CByte(&H21, dovalue)
End Function
Function SetDOValue:
Function SetDOValue(dovalue As Integer)
Call WriteI2CByte(&H23, &H0)
Call WriteI2CByte(&H20, &HFF)
Call WriteI2CByte(&H2B, &HFF)
Call WriteI2CByte(&H21, dovalue)
End Function
Function CheckDIValue:
Function CheckDIValue()
Dim GPIO1X As Integer
Dim GPIO3X As Integer
Dim DI1Xhex As String
Dim DI3Xhex As String
Call ReadI2CByte(&H12, GPIO1X)
Call ReadI2CByte(&H42, GPIO3X)
DI1Xhex = Hex(GPIO1X)
DI3Xhex = Hex(GPIO3X)
Text3.Text = "0x" + DI1Xhex
Text4.Text = "0x" + DI3Xhex
End Function
Watchdog Timer and DIO under Linux¶
You can download the Sources in the Driver Download Folder in Chapter 9 in the DIO folder.
Source file: F75111v2.0L.tar.gz Binary file: F75111v2.0LBin.tar.gz USERNAME & PASSWORD: sf
How to compile source code:
Compile source code with Code::Blocks download and install the Code::Block with command “apt-get install codeblocks” Open an exist project(F75111.cbp) in Code::Blocks, click the compile button ( add an option ‘pkg-confi g –libs gtk+-2.0 gthread-2.0’ in “Project->Build Option-> Linker Setting->Other linker option”)
Compile source code with “make”
cd F75111
make
src/f75111 // execute the binary file
How to use this Demo Application:
Press the “Start” button to test DIO function
Press the “Enable” button to test WDT function
Press the “Disable” button to disable WDT
Check the “Enable Loop” box and press “Enable” to do WDT loop test
Press “Install” to set the system to autorun this application when booting, press “Uninstall” to remove this application when booting.
If WDT enable, system icon will be blinking.
F75111 will send “F75111_SetWDTEnable(BYTE byteTimer)” including a parameter “timer”,if there’s no disable signal (F75111_SetWDTDisable()) to stop it before timer countdown to 0, System will reboot. If there’s disable signal received, resent Enable WDT signal to prevent a reboot loop.
Introduction:
IO function In the file SMBus.c:
void SMBusIoWrite(BYTE byteOffset, BYTE byteData) {
outb(byteData, m_SMBusMapIoAddr + byteOffset);
}
BYTE SMBusIoRead(BYTE byteOffset) {
DWORD dwAddrVal;
dwAddrVal = inb(m_SMBusMapIoAddr + byteOffset);
return (BYTE)(dwAddrVal & 0x0FF);
}
Init internal F75111:
void F75111::InitInternalF75111() {
this->Write_Byte(F75111_INTERNAL_ADDR, GPIO1X_CONTROL_MODE, 0x00); // set GPIO1X to Input function
this->Write_Byte(F75111_INTERNAL_ADDR, GPIO3X_CONTROL_MODE, 0x00); // set GPIO3X to Input function
this->Write_Byte(F75111_INTERNAL_ADDR, GPIO2X_CONTROL_MODE, 0xFF); // set GPIO2X to Output function
this->Write_Byte(F75111_INTERNAL_ADDR, F75111_CONFIGURATION, 0x03); // Enable WDT OUT function
}
Set output value:
void F75111::InterDigitalOutput(BYTE byteValue) {
BYTE byteData = 0;
byteData = (byteData & 0x01) ? byteValue + 0x01 : byteValue;
byteData = (byteData & 0x02) ? byteValue + 0x02 : byteValue;
byteData = (byteData & 0x04) ? byteValue + 0x04 : byteValue;
byteData = (byteData & 0x80) ? byteValue + 0x08 : byteValue;
byteData = (byteData & 0x40) ? byteValue + 0x10 : byteValue;
byteData = (byteData & 0x20) ? byteValue + 0x20 : byteValue;
byteData = (byteData & 0x10) ? byteValue + 0x40 : byteValue;
byteData = (byteData & 0x08) ? byteValue + 0x80 : byteValue; // get value bit by bit
this->Write_Byte(F75111_INTERNAL_ADDR, GPIO2X_OUTPUT_DATA, byteData); // write byteData value via GPIO2X output pin
}
Get Input value:
BYTE F75111::InterDigitalInput() {
BYTE byteGPIO1X = 0;
BYTE byteGPIO3X = 0;
BYTE byteData = 0;
this->Read_Byte(F75111_INTERNAL_ADDR, GPIO1X_INPUT_DATA, &byteGPIO1X); // Get value from GPIO1X
this->Read_Byte(F75111_INTERNAL_ADDR, GPIO3X_INPUT_DATA, &byteGPIO3X); // Get value from GPIO3X
byteGPIO1X = byteGPIO1X & 0xF0; // Mask unuseful value
byteGPIO3X = byteGPIO3X & 0x0F; // Mask unuseful value
byteData = (byteGPIO1X & 0x10) ? byteData + 0x01 : byteData;
byteData = (byteGPIO1X & 0x80) ? byteData + 0x02 : byteData;
byteData = (byteGPIO1X & 0x40) ? byteData + 0x04 : byteData;
byteData = (byteGPIO3X & 0x01) ? byteData + 0x08 : byteData;
byteData = (byteGPIO3X & 0x02) ? byteData + 0x10 : byteData;
byteData = (byteGPIO3X & 0x04) ? byteData + 0x20 : byteData;
byteData = (byteGPIO3X & 0x08) ? byteData + 0x40 : byteData;
byteData = (byteGPIO1X & 0x20) ? byteData + 0x80 : byteData; // Get correct DI value from GPIO1X & GPIO3X
return byteData;
}
Enable WatchDog:
void F75111_SetWDTEnable(BYTE byteTimer) {
WriteByte(F75111_INTERNAL_ADDR, WDT_TIMER_RANGE, byteTimer); // set WatchDog range and timer
WriteByte(F75111_INTERNAL_ADDR, WDT_CONFIGURATION, WDT_TIMEOUT_FLAG | WDT_ENABLE | WDT_PULSE | WDT_PSWIDTH_100MS);
// Enable WatchDog, Setting WatchDog configure
}
Disable WatchDog:
void F75111_SetWDTDisable() {
WriteByte(F75111_INTERNAL_ADDR, WDT_CONFIGURATION, 0x00); // Disable WatchDog
}