Read analog voltage value, Read digital io value – Linx Technologies HUM-xxx-DT User Manual

Page 19

Advertising
background image

– –

– –

32

33

Read Analog Voltage Value - Command Code = 26
This command reads the analog voltage on a specific GPIO line.

Parameter 1 is set to 0x00. Parameter 2 is the GPIO number to be queried,
where 0 corresponds to GPIO_0 and 7 is GPIO_7 and so forth.

The response returns four parameter bytes. Parameter 1 is set to 0x00
and Parameter 2 returns the GPIO number that is being read. Param 3
and Param 4 return the voltage value on the pin. The voltage on the pin is
calculated using the formula below.

Voltage (V) = [(Param 3) * 16 + (Param 4)] / 2047 * V

CC

For example, if a Read ADC Value command returns the following response
and V

CC

is 3.0V,

0x3C 0x26 0x00 0x07 0x21 0x0E 0x00 0x3E

This means that the voltage on GPIO_7 can be calculated as

[(0x21) * 16 + (0x0E)] / 2047 * 3.0 = 0.794V

The GPIO line being read must be configured as an analog input before the
ADC value can be read.

Parameter 5 indicates if the command was successful (00) or if there was
an error (01).

Read Analog Voltage Value Command and Response

Command

Start

Command Param 1 Param 2

End

3C

26

00

GPIO

3E

Response

Start

Response Param 1 Param 2 Param 3 Param 4 Param 5

End

3C

26

00

GPIO

ADC1

ADC2

Status

3E

Figure 29: Read Analog Voltage Value Command and Response

Read Digital IO Value - Command Code = 27
This command reads the digital input value on a specific GPIO line.

This command returns four Parameter bytes. Parameter 1 is set to 0x00
and Parameter 2 returns the GPIO number that is being read.

Parameter 3 is the state of the GPIO line that is being read. If it is high,
Parameter 3 is 0x01. If it is low, Parameter 3 is 0x00.

Parameter 4 indicates if the command was successful (00) or if there was
an error (01).

The GPIO line being read must be configured as a digital input or output
before the value can be read.

Read Digital Input Value Command and Response

Command

Start

Command

Param 1

Param 2

End

3C

27

00

GPIO

3E

Response

Start

Response

Param 1

Param 2

Param 3

Param 4

End

3C

27

00

GPIO

DIVal

Status

3E

Figure 30: Read Digital Input Value Command and Response

Advertising