Table of Contents

x86 EApi Windows

EApi Installation

Open the Windows command prompt as administrator and navigate to the folder that is containing the installation files.
Execute the file install.batch from the command prompt.

TqDriver must be unistalled from the Device manager first, before reinstalling the software!


EApi Initialisation

The EApiLibInitialize function has to be called at the beginning of every application.
An error will be returned if TQ driver is not installed on the system.

The EApiLibUnInitialize function has to be called at the end of every application.

EApi Board Information

EApiBoardGetStringA <string id>

Example

EApiBoardGetValue <value id>

Example


Display Backlight

Backlight Functions are only available if a suitable display is connected.
Latest Intel(R) HD Graphics driver has be installed on the system.

EApiVgaBacklightEnable Enable Backlight
EApiVgaGetBacklightBrightness Get Backlight Brightness Value (0-255)
EApiVgaSetBacklightBrightness Set Backlight Brightness Value (0-255)


EEPROM

There are 2 available EEPROMs available on the TQ x86 Starterkits

EApiStorageCap
EApiStorageAreaRead
EApiStorageAreaRead ID Offset Bytecnt
Datatype dec hex dec

Example:

EApiStorageAreaWrite
EApiStorageAreaWrite ID Offset Data
Datatype dec hex hex …. hex

Example:

I2C

The current frequency is defined in Windows registry:

HKLM\SYSTEM\CurrentControlSet\Services\TqDrv\Parameters\I2cBusSpeed

Default Frequency is 100KHz, the following frequencies are available for the primary CPLD I2C Bus:

After changing I2C frequency in Windows registry, you need to reset Tq driver in Windows Device Manager:

EApiI2CWriteReadRawr
EApiI2CWriteReadRaw bus_id i2c_addr string_to_write bytes_to_read
Datatype dec hex hex … hex dec

To ignore write operation: <string_to_write> = “”
To ignore read operation: <bytes_to_read> = 0

Example:

EApiI2CReadTransfer | EApiI2CWriteTransfer
EApiI2CReadTransfer bus_id i2c_addr cmd type bytes_to_read
EApiI2CWriteTransfer bus_id i2c_addr cmd type bytes_to_write
Datatype dec hex hex hex dec

where 'type' = 0/1/2 (No Command/ Standard Command/ Extended Command)

Examples

Watchdog Functions

EApiWDogStart

Delay mode is not supported. Event mode and Reset mode are supported.

List of possible Watchdog timeout values

If timeout falls between these values, the closest top value will be used: For Example:
For 10 seconds - 16 secnds will be used.
For 683 seconds - 1024 seconds will be used.

Event Mode

Event timeout must be defined, other Timeout values must be 0.
2 interrupt lines are supported: 10 and 11.
Default line is 11.
Interrupt number must be defined in 2 places:

To change IRQ line you need to change it in 2 places. After that you need to reset Tq driver in Windows Device Manager:

Reset mode

Reset timeout must be defined, other Timeout values must be 0.
Following reset modes are supported:
1 = watchdog reset output triggers hard reset signal
0 = watchdog reset output triggers power-on button
Reset mode is definded in Windows Registry, default value is 1.

HKLM\SYSTEM\CurrentControlSet\Services\TqDrv\Parameters\WdtReset
Dual-Stage Mode

In dual-stage mode (Event + Reset) Event timeout will be used for both stages. Event timeout must be defined, reset timeout must not equal zero.
EApiWDogStart <Delay> <EventTimeout> <ResetTimeout>
Time must be specified in ms.
Example:

EApiWDogStart 0 15200 1000

GPIO

ON TQ Boards, 8 GPIO's are available, all of which can be input or output. The EApi library defines two different mechanisms to address GPIO: pin addressing and bank addressing. EAPI_GPIO_BANK_ID(GPIO_NUM) is used to define the GPIO bank.

EApiGPIOGetDirection

EApiGPIOGetDirection <bank> uses bank addressing, where <bank> is a group of 32 pins addressed simultaneously. Example:

> TqApp.exe EApiGPIOGetDirection 0
Bank 0: DIRECTION = 0xff
EApiGPIOSetDirection

EApiGPIOSetDirection <Pin> <Direction> uses pin addressing. <Direction> == 0 means Output, otherwise Input
Example:
Setting pin 2 to output

> TqApp.exe EApiGPIOSetDirection 2 0
EApiGPIOSetLevel

EApiGPIOSetLevel <bank> uses bank addressing, where <bank> is a group of 32 pins addressed simultaneously. Example:

> TqApp.exe EApiGPIOsetLevel 4 1
EApiGPIOGetLevel

EApiGPIOGetLevel <bank> uses bank addressing, where <bank> is a group of 32 pins addressed simultaneously. Example:

> TqApp.exe EApiGPIOGetLevel 0
Bank 0: LEVEL = 0xfb

TQ Library Functions

TqWdtWaitForInterrupt

This function detects Watchdog interrupts, there is a standalone application for TqWdtWaitForInterrupt because it’s not part of EAPI.

Examples



Linux version

Installation

First you have to unpack tqmx86-dist-0.1.tar.gz and deploy packages with dpkg, which is part of the dkms package.

$ sudo dpkg -i package-name.deb

Then install additional test and developer tools, drivers package and corresponding dependencies:

$ sudo apt-get i2c-tools lm-sensors
$ sudo apt-get install dkms linux-headers --> $(uname -r)
$ sudo dpkg -i tqmx86-drivers_0.1_amd64.deb

Now copy configs/sensors.tqmx to /etc/sensors.d/ and configs/tqmx86.conf to /lib/modules-load.d/ .
After that you have to edit the /etc/default/grub file by adding 'acpi_enforce_resources=lax' parameter to 'GRUB_CMDLINE_LINUX_DEFAULT', then reboot.
After the reboot check the output of “$ lsmod”, the following Kernel Modules/ Drivers must have loaded automatically.

$ lsmod

If any of these drivers have not been loaded automatically, load them manually with modprobe:

$ sudo modprobe <Driver_name>

Lastly check config: these Device special- and sysfs files and directories must be present:

config

Board and System Information

Board Manufacturer
 $ cat /sys/class/dmi/id/sys_vendor
 TQ-Group
Board Name
 $ cat /sys/devices/platform/tqmx86/board_id
 TQMxE38C
Board Hardware Revision
 $ cat /sys/devices/platform/tqmx86/board_version 
 1
Board BIOS Revision
 $ cat /sys/class/dmi/id/bios_version
 TQMxE38C.5.4.48.0025.02

Watchdog

Source code for watchdog test program ('wdtest') is provided in “examples” directory. To compile it, use the following command:

 $ gcc wdtest.c -o wdtest

Intended usage of this program is to run as daemon and periodically ping watchdog. The following command pings watchdog every 20 seconds, this is short enough for the default timeout period of 32 seconds.

$ sudo sh -c 
$ ./wdtest -p 20 &

The wdtest command can also print watchdog info and set timeout. The following sequence of commands will kill the running daemon, provide watchdog info and start a new daemon:

$ ps ax |grep wdtest
1686 pts/8    S      0:00 
$ ./wdtest -p 20
$ sudo kill -9 1686 ;sudo
$ ./wdtest -i
$ sudo sh -c 
$ ./wdtest -p 20 &
Options: 8080, Version: 0, Id: TQMx86 Watchdog
Status: 0
Timeout: 32

The process of changing the watchdog timeout is similar. Make sure the delay between 'kill' and 'start is short as to not allow the watchdog to reset the board.

$ ps ax |grep wdtest
1703 pts/8    S      0:00
$ ./wdtest -p 20
$ sudo kill -9 1703; 
$ sudo ./wdtest -t 800
Timeout set to 1024sec
$ sudo sh -c
$ ./wdtest -p 500 &

Once the watchdog is first accessed it is started and cannot be stopped by any means, it can only be restarted by 'wdtest' or a similar watchdog daemon program. Alternatively simply write a charecter into /dev/watchdog (dev/watchdog0) file

GPIO

GPIO functionality can be tested with the gpio-test.sh shell script provided in the “examples” directory.
The program requires root priviliges to export a pin and to change the output value.

Pins 0-3 are hardwired as output only and pins 4-7 as input only. Their direction cannot be changed.

With a single pin argument the program reports pin status (direction and value). When a second argument is provided it changes the state of the pin accordingly:

$ sudo ./gpio-test.sh 2
Direction: out
Value:     0
$ sudo ./gpio-test.sh 5
Direction: in
Value:     1
$ sudo ./gpio-test.sh 2 1
$ ./gpio-test.sh 2
Direction: out
Value:     1

I2C

Read module EEPROM

You can read “on-module” EEPROM at address 0x50 (* are variables in the file-path). You can also read/ write EEPROM as a regular file.

$ sudo hexdump -C /sys/devices/platform/tqmx86/i2c-machxo2/i2c-*/*-0050/eeprom
00000000  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00000010  54 51 4d 78 45 33 38 4d  0a ff ff ff ff ff ff ff  |TQMxE38M........|
00000020  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
*
000002a0  ff a1 ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
000002b0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
*
00001000
Accessing PCA9538 GPIO Chip using i2c-tools

You can also access the GPIO chip PCA9538 using i2c-tools:
First you have to determine the number of the i2c-machxo2 bus.

$ i2cdetect -1

Then read all 4 GPIO ports of PCA9538 located on this I2C bus:

i2cdump

Now configure pins 0 - 3 as outputs:

 $ sudo i2cset 8 0x70 3 0xf0
 $ sudo i2cdump -r 0-3 8 0x70
 00: 0f ff 00 f0

Lastly you have to change the output state for pins 0-1 (pins 4-7 are not affected as they are hardwired inputs).
Setting pin 0 to 0 output should turn on an LED.

$ sudo i2cset 8 0x70 1 0x06
$ sudo i2cdump -r 0-3 8 0x70
00: 06 06 00 f0
Accessing EEPROM on carrier using i2c-rw program

Source code for i2c-rw test program is provided in the “examples” directory. Use the following command to compile it:

$ gcc i2c-rw.c -o i2c-rw

Examples:

Read EEPROM at address 0x57 with offset 0 and size 64

Read EEPROM at address 0x57 with offset 0xa00 and size 512

Write "Hello!" to the same EEPROM at offset 0x30

HWMon Sensors

Standard linux '$ sensors' command can read NCT7802 and coretemp(MSR registers of CPU) hardware monitor data:

$ sensors
coretemp-isa-0000
Adapter: ISA adapter
Core 0:       +30.0°C  (high = +110.0°C, crit = +110.0°C)
Core 1:       +30.0°C  (high = +110.0°C, crit = +110.0°C)
Core 2:       +31.0°C  (high = +110.0°C, crit = +110.0°C)
Core 3:       +31.0°C  (high = +110.0°C, crit = +110.0°C)

soc_dts0-virtual-0
Adapter: Virtual device
temp1:        +29.0°C  

soc_dts1-virtual-0
Adapter: Virtual device
temp1:        +30.0°C  

nct7802-i2c-9-2c
Adapter: SMBus I801 adapter at 3000
3V3:          +3.37 V  (min =  +0.00 V, max =  +4.09 V)
RTC-bat:      +3.02 V  
5VSB:         +5.08 V  (min =  +0.00 V, max =  +6.24 V)
COMe-input:  +12.38 V  (min =  +0.00 V, max = +21.99 V)
CPU-fan:        0 RPM  (min =    0 RPM)
COMe-fan:    3936 RPM  (min =    0 RPM)
CPU-temp:     +30.2°C  (low  =  +0.0°C, high = +85.0°C)
                       (crit = +100.0°C)
SYS-temp:     +30.0°C  (low  =  +0.0°C, high = +85.0°C)
                       (crit = +100.0°C)

Known Issues

Windows

Linux