Firmware SDK
|
Driver for RS-485 Module. More...
Enumerations | |
enum | twr_module_rs485_event_t { TWR_MODULE_RS485_EVENT_ERROR = 0 , TWR_MODULE_RS485_EVENT_VOLTAGE = 1 , TWR_MODULE_RS485_EVENT_ASYNC_WRITE_DONE = 2 , TWR_MODULE_RS485_EVENT_ASYNC_READ_DATA = 2 , TWR_MODULE_RS485_EVENT_ASYNC_READ_TIMEOUT = 3 } |
Callback events. More... | |
enum | twr_module_rs485_baudrate_t { TWR_MODULE_RS485_BAUDRATE_9600 = TWR_SC16IS740_BAUDRATE_9600 , TWR_MODULE_RS485_BAUDRATE_19200 = TWR_SC16IS740_BAUDRATE_19200 , TWR_MODULE_RS485_BAUDRATE_38400 = TWR_SC16IS740_BAUDRATE_38400 , TWR_MODULE_RS485_BAUDRATE_57600 = TWR_SC16IS740_BAUDRATE_57600 , TWR_MODULE_RS485_BAUDRATE_115200 = TWR_SC16IS740_BAUDRATE_115200 } |
Baudrates. | |
Functions | |
bool | twr_module_rs485_init (void) |
Initialize RS-485 Module. More... | |
bool | twr_module_rs485_deinit (void) |
Deinitialize RS-485 Module. More... | |
bool | twr_module_rs485_measure (void) |
Start single voltage measurement. More... | |
bool | twr_module_rs485_get_voltage (float *volt) |
Get measured voltage. More... | |
void | twr_module_rs485_set_event_handler (void(*event_handler)(twr_module_rs485_event_t, void *), void *event_param) |
Set callback function. More... | |
void | twr_module_rs485_set_update_interval (twr_tick_t interval) |
Set measurement interval. More... | |
size_t | twr_module_rs485_write (uint8_t *buffer, size_t length) |
Write data to RS-485 bus. More... | |
bool | twr_module_rs485_available (size_t *available) |
Get number of received bytes. More... | |
size_t | twr_module_rs485_read (uint8_t *buffer, size_t length, twr_tick_t timeout) |
Read the received data. More... | |
bool | twr_module_rs485_set_baudrate (twr_module_rs485_baudrate_t baudrate) |
Set baudrate. More... | |
void | twr_module_rs485_set_async_fifo (twr_fifo_t *write_fifo, twr_fifo_t *read_fifo) |
Set FIFO. More... | |
size_t | twr_module_rs485_async_write (uint8_t *buffer, size_t length) |
Add data to be transmited in async mode. More... | |
bool | twr_module_rs485_async_read_start (twr_tick_t timeout) |
Start async reading. More... | |
bool | twr_module_rs485_async_read_stop (void) |
Stop async reading. More... | |
size_t | twr_module_rs485_async_read (void *buffer, size_t length) |
Get data that has been received in async mode. More... | |
Driver for RS-485 Module.
Callback events.
Definition at line 15 of file twr_module_rs485.h.
size_t twr_module_rs485_async_read | ( | void * | buffer, |
size_t | length | ||
) |
Get data that has been received in async mode.
[in] | buffer | Pointer to buffer |
[in] | length | Maximum length of received data |
Definition at line 406 of file twr_module_rs485.c.
bool twr_module_rs485_async_read_start | ( | twr_tick_t | timeout | ) |
Start async reading.
[in] | timeout | Maximum timeout in ms |
Definition at line 379 of file twr_module_rs485.c.
bool twr_module_rs485_async_read_stop | ( | void | ) |
Stop async reading.
Definition at line 393 of file twr_module_rs485.c.
size_t twr_module_rs485_async_write | ( | uint8_t * | buffer, |
size_t | length | ||
) |
Add data to be transmited in async mode.
[in] | buffer | Pointer to buffer |
[in] | length | Length of data to be added |
Definition at line 358 of file twr_module_rs485.c.
bool twr_module_rs485_available | ( | size_t * | available | ) |
Get number of received bytes.
[out] | available | Number of received bytes |
Definition at line 427 of file twr_module_rs485.c.
bool twr_module_rs485_deinit | ( | void | ) |
Deinitialize RS-485 Module.
Definition at line 110 of file twr_module_rs485.c.
bool twr_module_rs485_get_voltage | ( | float * | volt | ) |
Get measured voltage.
[out] | volt | Measured voltage in volts |
Definition at line 146 of file twr_module_rs485.c.
bool twr_module_rs485_init | ( | void | ) |
Initialize RS-485 Module.
Definition at line 63 of file twr_module_rs485.c.
bool twr_module_rs485_measure | ( | void | ) |
Start single voltage measurement.
Definition at line 167 of file twr_module_rs485.c.
Referenced by twr_module_rs485_set_update_interval().
size_t twr_module_rs485_read | ( | uint8_t * | buffer, |
size_t | length, | ||
twr_tick_t | timeout | ||
) |
Read the received data.
[out] | buffer | Pointer to the buffer where the data will be copied |
[in] | length | Size of the buffer |
[in] | timeout | Receive timeout. Write 0 for no timeout |
Definition at line 432 of file twr_module_rs485.c.
void twr_module_rs485_set_async_fifo | ( | twr_fifo_t * | write_fifo, |
twr_fifo_t * | read_fifo | ||
) |
Set FIFO.
[in] | write_fifo | Pointer to the created and initialized write FIFO |
[in] | read_fifo | Pointer to the created and initialized read FIFO |
Definition at line 352 of file twr_module_rs485.c.
bool twr_module_rs485_set_baudrate | ( | twr_module_rs485_baudrate_t | baudrate | ) |
Set baudrate.
[in] | self | Instance |
[in] | baudrate |
Definition at line 437 of file twr_module_rs485.c.
void twr_module_rs485_set_event_handler | ( | void(*)(twr_module_rs485_event_t, void *) | event_handler, |
void * | event_param | ||
) |
Set callback function.
[in] | event_handler | Function address |
[in] | event_param | Optional event parameter (can be NULL) |
Definition at line 416 of file twr_module_rs485.c.
void twr_module_rs485_set_update_interval | ( | twr_tick_t | interval | ) |
Set measurement interval.
[in] | interval | Measurement interval |
Definition at line 130 of file twr_module_rs485.c.
size_t twr_module_rs485_write | ( | uint8_t * | buffer, |
size_t | length | ||
) |
Write data to RS-485 bus.
[in] | buffer | Data to send |
[in] | interval | Number of bytes to send |
Definition at line 422 of file twr_module_rs485.c.