This command sets the direction of the individual IO pins of the individual ports. Additionally, the same command can be used to set up weak pull-ups at the pins where available. See datasheet of the PIC MCU for a description of IO ports.
Request
NADR |
PNUM |
PCMD |
HWPID |
0 |
1 |
2 |
… |
n × 3 |
n × 3 + 1 |
n × 3 + 2 |
NADR |
0x09 |
0x00 |
? |
Port0 |
Mask0 |
Value0 |
… |
Portn |
Maskn |
Valuen |
n ∈ [0,17] Number of settings minus 1.
Port a. Specifies port to setup a direction to. 0x00=TRISA, 0x01=TRISB, …(predefined symbols PNUM_IO_TRISx) or
b. Specifies port to setup a pull-up. 0x11=WPUB (predefined symbols PNUM_IO_WPUx)
Mask Masks pins of the port.
Value a. Actual direction bits for the masked pins. 0=output, 1=input., … or
b. Pull-up state. 0=disabled, 1=enabled.
Error codes
ERROR_DATA Invalid Port value.
Response
The general response to writing request with STATUS_NO_ERROR Error code.