Configure and control the FlexSense serial interface.
More...
Configure and control the FlexSense serial interface.
The FlexSense Serial interface supports RS-485 and RS-232. The RS-232 is configurable to support a wide range of interface requirements.
- Warning
- To maximise the battery life of your FlexSense, we recommend initialising and de-initialising the Serial interface each time the job using it is called. This will reduce the idle power usage of your FlexSense.
◆ FLEX_SerialProtocol
Serial Interface - Protocol Options.
Enumerator |
---|
FLEX_SERIAL_PROTOCOL_RS485 | use RS-485 as the Serial Protocol
|
FLEX_SERIAL_PROTOCOL_RS232 | use RS-232 as the Serial Protocol
|
◆ FLEX_SerialParity
Serial Interface - Parity Options.
Enumerator |
---|
FLEX_SERIAL_PARITY_NONE | No parity for serial device.
|
FLEX_SERIAL_PARITY_EVEN | Even parity for serial device.
|
FLEX_SERIAL_PARITY_ODD | Odd parity for serial device.
|
◆ FLEX_SerialDatabits
Serial Interface - Databits Options.
Enumerator |
---|
FLEX_SERIAL_DATABITS_EIGHT | Eight databits for serial device.
|
FLEX_SERIAL_DATABITS_NINE | Nine databits for serial device.
|
◆ FLEX_SerialStopbits
Serial Interface - Stopbits Options.
Enumerator |
---|
FLEX_SERIAL_STOPBITS_ONE | 1 stopbits for serial device
|
FLEX_SERIAL_STOPBITS_HALF | 0.5 stopbits for serial device
|
FLEX_SERIAL_STOPBITS_ONEANDHALF | 1.5 stopbits for serial device
|
FLEX_SERIAL_STOPBITS_TWO | 2 stopbits for serial device
|
◆ FLEX_SerialInit()
Initialise the selected serial interface (RS-485 or RS-232).
- Note
- RS-485 and RS-232 cannot be initialised at the same time
-
De-initialise the Serial Interface before a job is completed to preserve device power.
- Parameters
-
[in] | Protocol | required protocol for serial communication. |
[in] | BaudRate | required baudrate. |
- Returns
- FLEX_SUCCESS (0) if succeeded and < 0 if failed.
- Return values
-
-FLEX_ERROR_EALREADY | device already initialised |
-FLEX_ERROR_IO_EXPANDER | failed to initialise or configure expander device |
-FLEX_ERROR_SERIAL | failed to initialise serial device |
-FLEX_ERROR_POWER_OUT | failed to enable power to serial interface |
◆ FLEX_SerialInitEx()
Initialise the selected serial interface (RS-485 or RS-232).
- Note
- RS-485 and RS-232 cannot be initialised at the same time
-
De-initialise the Serial Interface before a job is completed to preserve device power.
- Parameters
-
[in] | Options | extended configuration options for serial protocol. |
- Returns
- FLEX_SUCCESS (0) if succeeded and < 0 if failed.
- Return values
-
-FLEX_ERROR_EALREADY | device already initialised |
-FLEX_ERROR_IO_EXPANDER | failed to initialise or configure expander device |
-FLEX_ERROR_SERIAL | failed to initialise serial device |
-FLEX_ERROR_POWER_OUT | failed to enable power to serial interface |
◆ FLEX_SerialWrite()
int FLEX_SerialWrite |
( |
const uint8_t * | Tx, |
|
|
size_t | Length ) |
Write to the serial interface synchronously.
- Parameters
-
[in] | Tx | pointer to the transmit buffer to be sent. |
[in] | Length | length of data to be sent. |
- Returns
- FLEX_SUCCESS (0) if succeeded and < 0 if failed.
- Return values
-
-FLEX_ERROR_NOT_INIT | device not initialised |
◆ FLEX_SerialRead()
int FLEX_SerialRead |
( |
uint8_t * | Rx, |
|
|
size_t | Length ) |
Read from the input buffer of the serial interface. The buffer size is 50 bytes.
- Parameters
-
[out] | Rx | pointer to the receive buffer. |
[in] | Length | length of the receive buffer. |
- Returns
- number of bytes read back or < 0 if read failed.
- Return values
-
-FLEX_ERROR_NOT_INIT | device not initialised |
◆ FLEX_SerialDeinit()
int FLEX_SerialDeinit |
( |
void | | ) |
|
De-initialise the serial interface.
- Note
- De-initialise the Serial Interface before a job is completed to preserve device power.
- Returns
- FLEX_SUCCESS (0) if succeeded and < 0 if failed.
- Return values
-
-FLEX_ERROR_POWER_OUT | failed to disable power to serial interface |