Command Hardware Control – Control GPIO on ESPrtk
Tip : This control command woks on UART configure mode , Main Action mode and WEB configure mode via UART0.
‘T’ | ‘G’ | PL2 | Control GPIO on ESPrtk |
|
| ‘0’ | G_SET_MODE_GPIO |
| |
‘1’ | G_WRITE_DIGITAL |
| ||
‘2’ | G_READ_DIGITAL |
|
HOST send Control G_SET_MODE_GPIO
Not support !
HOST send Control G_READ_DIGITAL
Not support !
HOST send Control G_WRITE_DIGITAL
<Header> + <Payload_length> | <Payload> | ||||||
PL0 | PL1 | PL2 | PL3 | PL4 | PL5 | … | |
$ESP_OK|xx| | ‘T’ | ‘G’ | ID Control | Infor 1 | Infor 2 | Infor 3 | ... |
Payload Index
| Type value | Min Value | Max Value | Min Length | Max Length | Describe | Unit | ||
PL2 | ‘1’ |
| ID Control : G_WRITE_DIGITAL |
| |||||
| PL3 | BIT | - | - | 19 | 19 | BIT control GPIO ESPrtk |
| |
0 | Set GPIO to LOW Level | ||||||||
1 | Set GPIO to HIGH Level |
PL0 | PL1 | PL2 | PL3 | GPIO ESPrtk | PL3 | GPIO ESPrtk |
‘T’ | ‘P’ | ‘0’ | BIT1 | BIT11 | 19 | |
|
|
| BIT2 | BIT12 | 21 | |
|
|
| BIT3 | BIT13 | 22 | |
|
|
| BIT4 | BIT14 | 23 | |
|
|
| BIT5 | BIT15 | 25 | |
|
|
| BIT6 | BIT16 | 26 | |
|
|
| BIT7 | BIT17 | 27 | |
|
|
| BIT8 | BIT18 | 32 | |
|
|
| BIT9 | BIT19 | 33 | |
|
|
| BIT10 |
|
|
ESPrtk Respond
Payload Index
| Type value | Min Value | Max Value | Min Length | Max Length | Describe | Unit | ||
PL2 | ‘1’ |
| ID Control : G_WRITE_DIGITAL |
| |||||
| PL3 | INTEGER | -1 | 1 | - | - | Status Control |
| |
-1 | NACK: BIT control GPIO invalid | ||||||||
0 | - | ||||||||
1 | OK | ||||||||
| PL4 | BIT | - | - | 19 | 19 | BIT control GPIO |
| |
0 | GPIO now is LOW Level | ||||||||
1 | GPIO now is HIGH Level | ||||||||
X | This GPIO was used by other task |
Example
Message : | |
HOST Send | $ESP_OK|26|T|G|1|1111111111111111111|*0A38 |
ACK Respond | $ESP_OK|28|T|G|1|1|1XXXX1XXX111111XX11|*2044
|
NACK Respond | $ESP_ER|40|T|G|1|-1|NACK: BIT control GPIO invalid|*2D5D |
Other NACK | $ESP_ER|… or $ESS_ER|… or $AES_ER|… |
Tip 1 : When BIT respond is ‘X’ , that mean the GPIO pin was used by other task (such as UART_1_2 , LoRa , IMU, Ethernet , SD_Card, NeoPixel, OLED, ERROR_LED , CONNECT_LED ….etc).
For example, if you use the pin map ESPrtk as default configure like this :
Configure | JSON Configure |
Default from factory | { "CWB_Button" : "13" , "RX_UART0" : "3" , "MOSI_SD_Card" : "23" , "MOSI_LoRa_Ethe" : "33" , "TX_UART0" : "1" , "MISO_SD_Card" : "39" , "MISO_LoRa_Ethe" : "35" , "RX_UART1" : "17" , "SCK_SD_Card" : "18" , "SCK_LoRa_Ethe" : "25" , "TX_UART1" : "5" , "CONNECT_LED" : "15" , "CS_SD_Card" : "19" , "RX_UART2" : "16" , "ERROR_LED" : "12" , "CS_LoRa" : "32" , "TX_UART2" : "4" , "NEOPIXEL_LED" : "14" , "CS_Ethernet" : "0" , "SCL_I2C" : "22" , "SCL_OLED" : "27" , "RST_LoRa_Ethe" : "2" , "SDA_I2C" : "21" , "SDA_OLED" : "26" , "DI0_LoRa" : "34" , "ESPrtk_IO" : "36" } |
To use GPIO for Hardware Control , you must release them before.
External deives | To Release | Release |
SD_Card | At Write Configure – ACTION_PLANNING (at configure Other Action) → Disable all BIT save data to SD_Card | 23 , 39 , 18 , 19 |
LoRa Ethernet | At Write Configure – RADIO_RTK → Select Type radio link is WIFI to release LoRa |
33 , 35 , 25 , 2 , 34 , 0 , 32 |
At Write Configure – INTNERNET → Select Type internet is WIFI only to release Ethernet | ||
Sensor/IMU | At Write Configure – ACTION_PLANNING ( at configure Other Action) → Disable BIT export IMU data | 22 , 21 |
CONNECT_LED | At Write Configure – DISPLAY_VIEWER → Disable use CONNECT_LED | 15 |
ERROR_LED | At Write Configure – DISPLAY_VIEWER → Disable use ERROR_LED | 12 |
NEOPIXEL_LED | At Write Configure – DISPLAY_VIEWER → Select Type Display is OLED | 14 |
Oled | At Write Configure – DISPLAY_VIEWER → Select Type Display is NEOPIXEL | 27 , 26 |
TX_UART12 | At Write Configure – ACTION_PLANNING → Select Map TX-UART-RTK to other TX UART port | 5 (or 4)
|
RX_UART12 | At Write Configure – ACTION_PLANNING → Select Map RX-UART-RTK to other RX UART port | 17 (or 16) |
Tip 2 : GPIO pins in the release state (idle / not use / free ) can be used for GPIO control . However, when users use other control functions such as Ethernet / IMU / SD Card, etc., IO pins will be taken back control for those functions !. (GPIO control will ignore those pins if they are used again.)