[sync] This command sets the output state of the IO pins. It also allows inserting an active waiting delay between IO pins settings. This feature can be used to generate arbitrary time-defined signals on the IO pins of the MCU. During the active waiting, the device is blocked and any network traffic will not be processed.
This command is executed after the DPA Request is sent back to the device that sent the original DPA IO Set request. The correctness of the embedded triplet is not checked before but during their execution. Therefore, if an invalid port is specified an error code is not returned inside DPA Request but the rest of the request execution is skipped. Also when the length of the very last tripletn is not 3 bytes, the preceding commands are executed and the error is not returned.
Request
NADR |
PNUM |
PCMD |
HWPID |
0 |
1 |
2 |
… |
n × 3 |
n × 3 + 1 |
n × 3 + 2 |
NADR |
0x09 |
0x01 |
? |
triplet0 |
… |
tripletn |
n ∈ [0,17] Number of triplets minus 1.
triplet There are 2 types of 3-byte triplets (subcommands) allowed:
a. Setting an output value
port Specifies the port to set up an output state. 0=PORTA, 1=PORTB, … (predefined symbols PNUM_IO_PORTx)
mask Masks pins of the port to setup.
value Actual output bit value for the masked pins.
b. Delay
0xFF Specifies a delay command (predefined symbol PNUM_IO_DELAY).
delayL Lower byte of the 2-byte delay value, unit is 1 ms.
delayH Higher byte of the 2-byte delay value, unit is 1 ms.
Response
The general response to writing request with STATUS_NO_ERROR Error code.
Example 1
The setting of PORTA.0 and PORTC.2 as output, PORTC.3 as input.
• Request
NADR=0x0001, PNUM=0x09, PCMD=0x00, HWPID=0xFFFF, PData={0x00(PORTA), 0x01(bit0=1), 0x00(bit0=output)} {0x02(PORTC), 0x0C(bit2=1, bit3=1), 0x08(bit2=output, bit3=input)}
• Response
NADR=0x0001, PNUM=0x09, PCMD=0x80, HWPID=0xABCD, PData={00}(No error), {0x07}(DPA Value)
Example 2
Set PORTA.0=1, PORTC.2=1, then wait for 300 ms, set PORTA.0=0.
• Request
NADR=0x0001, PNUM=0x09, PCMD=0x01, HWPID=0xFFFF, PData={0x00(PORTA), 0x01(bit0=1), 0x01(bit0=1)} {0x02(PORTC), 0x04(bit2=1), 0x04(bit2=1)} {0xFF(delay), 0x2C (low byte of 300), 0x01(high byte of 300)} {0x00(PORTA), 0x01(bit0=1), 0x00(bit0=0)}
• Response
NADR=0x0001, PNUM=0x09, PCMD=0x81, HWPID=0xABCD, PData={00}(No error), {0x07}(DPA Value)