The GPIO_SET_FR_CNT_CFG command allows to switch on/off frequency counter mode on specified pin and to set the conditions of the event generation.
| Byte 0 | GPIO_SET_FR_CNT_CFG | Command ID (0x16). | |
| Byte 1 | ECHO | Echo to associate a command with the response. | |
| Byte 2 | Bit 7..4 | ON | Frequency counter state. |
| Bit 3..0 | FR_CNT_NUMBER | ID number of the counter to measure frequency. | |
| Byte 3 | REPEAT | Repeat interval value in units of 100 ms. | |
| Byte 4 | COMP_VAL[2] | Threshold frequency (least significant byte). | |
| Byte 5 | COMP_VAL[1] | Threshold frequency (middle byte). | |
| Byte 6 | COMP_VAL[0] | Threshold frequency (most significant byte). | |
| Byte 7 | EVENT_COND | Condition of comparison. | |
Command is an 8-byte array of the following format:
This byte contains command ID (command type). It should be set to 0x16.
This byte is used to associate a response received from GPIO-24 adapter with a specific command. Response will contain exactly the same value in its echo byte.
| Bits 7..4 | Bits 3..0 |
|---|---|
| ON | FR_CNT_NUMBER |
The frequency counter state (on/off):
1 – the pin will be switched to the frequency counter mode. GPIO_GET_CFG and GPIO_GET_PIN_CFG commands will return GPIO_CFG_FR_CNT (0x6) value for the pin. The pin can be used only by the frequency counter module;
0 – the frequency counter mode will be switched off on the pin. GPIO_GET_CFG and GPIO_GET_PIN_CFG commands will return GPIO_CFG_NOT_CONFIGURED (0xf) value for the pin. The pin can be used by any module.
The ID number of the frequency counter:
0 – frequency counter on A.3 pin;
1 – frequency counter on A.4 pin.
This byte defines the repeat interval in units of 100 ms for the event GPIO_EV_FR_CNT generation. If this byte is non-zero, GPIO-24 adapter sends events each REPEAT*100 ms. For more detailed information see Section 10.1, “Frequency Counter Event”.
The threshold frequency to be compared with. The counter calculates frequency and constantly compares it with the threshold frequency specified in Bytes 4..6: COMP_VAL.
Byte 4: COMP_VAL[2] – least significant byte (low byte) of threshold frequency.
Byte 5: COMP_VAL[1] – middle byte of threshold frequency.
Byte 6: COMP_VAL[0] – most significant byte (high byte) of threshold frequency.
Frequency is specified in Hz in the range from 0 to 5,000,000 Hz (5 MHz).
The condition of the comparison:
GPIO_FR_CNT_EV_NONE (0x00) – No events are sent by current frequency counter.
GPIO_FR_CNT_EV_BELOW (0x01) – Events are sent when the frequency is lower than the threshold value specified in Bytes 4..6: COMP_VAL.
GPIO_FR_CNT_EV_NOT_EQ (0x02) – Events are sent when the frequency is lower or higher than the threshold value specified in Bytes 4..6: COMP_VAL.
GPIO_FR_CNT_EV_EQ (0x03) – Events are sent when the frequency is equal to the threshold value specified in Bytes 4..6: COMP_VAL.
GPIO_FR_CNT_EV_ABOVE (0x04) – Events are sent when the frequency is higher than the threshold value specified in Bytes 4..6: COMP_VAL.
GPIO_FR_CNT_EV_ALWAYS (0x05) – Events are sent periodically with predefined interval specified in Byte 3: REPEAT.
For convenience GPIO_SET_FR_CNT_CFG_CMD structure is declared in reports.h file:
GPIO-24 adapter sends GPIO_SET_FR_CNT_CFG response after command execution.
| Byte 0 | GPIO_SET_FR_CNT_CFG | Response ID (0x16). |
| Byte 1 | ECHO | Echo to associate a command with the response. |
| Byte 2 | ST | Status of the command execution. |
| Byte 3..7 | Reserved | Reserved |
Response is an 8-byte array of the following format:
Response ID (response type). This byte will contain 0x16.
Echo byte copied from the corresponding command. It is used to associate the response with the specific command.
Status of the command execution:
GPIO_ST_SUCCESS (0x00) – Frequency counter was succesfully configured;
GPIO_ST_INVALID_FR_CNT_NUMBER (0x0A) – Invalid frequency counter ID has been specified (only 1 and 0 are valid);
GPIO_ST_UNKNOWN_EVENT_TYPE (0x0B) – Unsupported comparison condition has been specified.
These bytes are reserved for future usage.