Firmware SDK
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
bc_module_rs485

Driver for RS-485 Module. More...

Enumerations

enum  bc_module_rs485_event_t {
  BC_MODULE_RS485_EVENT_ERROR = 0,
  BC_MODULE_RS485_EVENT_VOLTAGE = 1,
  BC_MODULE_RS485_EVENT_ASYNC_WRITE_DONE = 2,
  BC_MODULE_RS485_EVENT_ASYNC_READ_DATA = 2,
  BC_MODULE_RS485_EVENT_ASYNC_READ_TIMEOUT = 3
}
 Callback events. More...
 
enum  bc_module_rs485_baudrate_t {
  BC_MODULE_RS485_BAUDRATE_9600 = BC_SC16IS740_BAUDRATE_9600,
  BC_MODULE_RS485_BAUDRATE_19200 = BC_SC16IS740_BAUDRATE_19200,
  BC_MODULE_RS485_BAUDRATE_38400 = BC_SC16IS740_BAUDRATE_38400,
  BC_MODULE_RS485_BAUDRATE_57600 = BC_SC16IS740_BAUDRATE_57600,
  BC_MODULE_RS485_BAUDRATE_115200 = BC_SC16IS740_BAUDRATE_115200
}
 Baudrates.
 

Functions

bool bc_module_rs485_init (void)
 Initialize RS-485 Module. More...
 
bool bc_module_rs485_measure (void)
 Start single voltage measurement. More...
 
bool bc_module_rs485_get_voltage (float *volt)
 Get measured voltage. More...
 
void bc_module_rs485_set_event_handler (void(*event_handler)(bc_module_rs485_event_t, void *), void *event_param)
 Set callback function. More...
 
void bc_module_rs485_set_update_interval (bc_tick_t interval)
 Set measurement interval. More...
 
size_t bc_module_rs485_write (uint8_t *buffer, size_t length)
 Write data to RS-485 bus. More...
 
bool bc_module_rs485_available (size_t *available)
 Get number of received bytes. More...
 
size_t bc_module_rs485_read (uint8_t *buffer, size_t length, bc_tick_t timeout)
 Read the received data. More...
 
bool bc_module_rs485_set_baudrate (bc_module_rs485_baudrate_t baudrate)
 Set baudrate. More...
 
void bc_module_rs485_set_async_fifo (bc_fifo_t *write_fifo, bc_fifo_t *read_fifo)
 Set FIFO. More...
 
size_t bc_module_rs485_async_write (uint8_t *buffer, size_t length)
 Add data to be transmited in async mode. More...
 
bool bc_module_rs485_async_read_start (bc_tick_t timeout)
 Start async reading. More...
 
bool bc_module_rs485_async_read_stop (void)
 Stop async reading. More...
 
size_t bc_module_rs485_async_read (void *buffer, size_t length)
 Get data that has been received in async mode. More...
 

Detailed Description

Driver for RS-485 Module.

Enumeration Type Documentation

Callback events.

Enumerator
BC_MODULE_RS485_EVENT_ERROR 

Error event.

BC_MODULE_RS485_EVENT_VOLTAGE 

Update event.

BC_MODULE_RS485_EVENT_ASYNC_WRITE_DONE 

Async write done.

BC_MODULE_RS485_EVENT_ASYNC_READ_DATA 

Reading done event.

BC_MODULE_RS485_EVENT_ASYNC_READ_TIMEOUT 

Timeout event.

Definition at line 15 of file bc_module_rs485.h.

Function Documentation

size_t bc_module_rs485_async_read ( void *  buffer,
size_t  length 
)

Get data that has been received in async mode.

Parameters
[in]bufferPointer to buffer
[in]lengthMaximum length of received data
Returns
Number of received bytes

Definition at line 370 of file bc_module_rs485.c.

Here is the call graph for this function:

bool bc_module_rs485_async_read_start ( bc_tick_t  timeout)

Start async reading.

Parameters
[in]timeoutMaximum timeout in ms
Returns
true On success
false On failure

Definition at line 343 of file bc_module_rs485.c.

Here is the call graph for this function:

bool bc_module_rs485_async_read_stop ( void  )

Stop async reading.

Returns
true On success
false On failure

Definition at line 357 of file bc_module_rs485.c.

Here is the call graph for this function:

size_t bc_module_rs485_async_write ( uint8_t *  buffer,
size_t  length 
)

Add data to be transmited in async mode.

Parameters
[in]bufferPointer to buffer
[in]lengthLength of data to be added
Returns
Number of bytes added

Definition at line 322 of file bc_module_rs485.c.

Here is the call graph for this function:

bool bc_module_rs485_available ( size_t *  available)

Get number of received bytes.

Parameters
[out]availableNumber of received bytes

Definition at line 391 of file bc_module_rs485.c.

Here is the call graph for this function:

bool bc_module_rs485_get_voltage ( float *  volt)

Get measured voltage.

Parameters
[out]voltMeasured voltage in volts

Definition at line 110 of file bc_module_rs485.c.

bool bc_module_rs485_init ( void  )

Initialize RS-485 Module.

Returns
true On success
false When module is not detected

Definition at line 63 of file bc_module_rs485.c.

Here is the call graph for this function:

bool bc_module_rs485_measure ( void  )

Start single voltage measurement.

Returns
true On success
false When other measurement is in progress

Definition at line 131 of file bc_module_rs485.c.

Referenced by bc_module_rs485_set_update_interval().

Here is the call graph for this function:

Here is the caller graph for this function:

size_t bc_module_rs485_read ( uint8_t *  buffer,
size_t  length,
bc_tick_t  timeout 
)

Read the received data.

Parameters
[out]bufferPointer to the buffer where the data will be copied
[in]lengthSize of the buffer
[in]timeoutReceive timeout. Write 0 for no timeout

Definition at line 396 of file bc_module_rs485.c.

Here is the call graph for this function:

void bc_module_rs485_set_async_fifo ( bc_fifo_t write_fifo,
bc_fifo_t read_fifo 
)

Set FIFO.

Parameters
[in]write_fifoPointer to the created and initialized write FIFO
[in]read_fifoPointer to the created and initialized read FIFO

Definition at line 316 of file bc_module_rs485.c.

bool bc_module_rs485_set_baudrate ( bc_module_rs485_baudrate_t  baudrate)

Set baudrate.

Parameters
[in]selfInstance
[in]baudrate
Returns
true On success
false On failure

Definition at line 401 of file bc_module_rs485.c.

Here is the call graph for this function:

void bc_module_rs485_set_event_handler ( void(*)(bc_module_rs485_event_t, void *)  event_handler,
void *  event_param 
)

Set callback function.

Parameters
[in]event_handlerFunction address
[in]event_paramOptional event parameter (can be NULL)

Definition at line 380 of file bc_module_rs485.c.

void bc_module_rs485_set_update_interval ( bc_tick_t  interval)

Set measurement interval.

Parameters
[in]intervalMeasurement interval

Definition at line 94 of file bc_module_rs485.c.

Here is the call graph for this function:

size_t bc_module_rs485_write ( uint8_t *  buffer,
size_t  length 
)

Write data to RS-485 bus.

Parameters
[in]bufferData to send
[in]intervalNumber of bytes to send

Definition at line 386 of file bc_module_rs485.c.

Here is the call graph for this function: