// Number of signals to be transmitted from the embedded system to the computer.
#define N_TX_SIGNALS 12
//Number of signals to be transmitted from the computer to the embedded system.
#define N_RX_SIGNALS 2
//Maximum buffer size in bytes to be allocated for your communication interface.
#define MAX_COMM_BUFFER_DIM 256
// Frequency of the process which sends out the buffered data in Hz, e.g. a timer-based interrupt routine.
#define PROCESS_FREQUENCY 1000
//Transmission speed in baud/s of your communication interfac
#define COMM_DEV_BAUDRATE 115200
//e.g. UART adds per byte a start and a stop bit (8 bit + 2 bit = 10 bit)
#define ES_DEV_PAYLOAD_PER_BYTE 10
weak void es_start_data_transfer(uint32_t buffer_size, uint8_t *tx_data_buff, uint8_t *rx_data_buff) {};
weak uint8_t es_get_transfer_status()
Initialize your es_prot struct
void es_prot_init_struct(volatile es_prot* cp)
Prepare the info/ handshake buffer and initialize the data transfer via DMA.
void es_prot_init_comm(volatile es_prot* cp)
uint8_t es_prot_set_tx_data_info(
volatile es_prot *cp,
uint8_t idx,
uint8_t scaling_factor_applied,
uint8_t type,
const char *desc,
uint16_t representation,
float scaling_factor,
uint8_t line_width,
uint8_t alpha,
uint8_t r,
uint8_t g,
uint8_t b
)
| Argument | Type | Description |
|---|---|---|
| *cp | es_prot | Pointer to the ‘es_prot’ variable. |
| idx | uint8_t | Index of the signal (starts from zero). |
| scaling_factor_applied | uint8_t | Defines if scaling with the scaling factor should be enabled. Possible values:‘SCALING_FACTOR_NOT_APPLIED’ = 0,‘SCALING_FACTOR_APPLIED’ = 1. |
| type | uint8_t | Type of the variable. Possible values: ‘TYPE_INT8’, ‘TYPE_UINT8’, ‘TYPE_INT16’, ‘TYPE_UINT16’, ‘TYPE_INT32’, ‘TYPE_UINT32’, ‘TYPE_FLOAT’. |
| *desc | char | Name of the signal (Characters must be ASCII-compatible). |
| representation | uint16_t | Here you can assign the signal to one of the signal plots (‘PLOT_NR_1’ ... ‘PLOT_NR_x’) or no plot (‘PLOT_NONE’). Assigning a signal to several plots is possible as well as assigning several signals to one plot. |
| scaling_factor | float | Factor to scale the signal on the computer side. |
| line_width | uint8_t | Line width of the signal in the specified plot. |
| r, g, b, alpha | uint8_t | Color of the signal in the specified plot. |
uint8_t es_prot_set_rx_data_info(
volatile es_prot *cp,
uint8_t idx,
const char *desc
)
| Argument | Type | Description |
|---|---|---|
| *cp | es_prot | Pointer to the ‘es_prot’ variable. |
| idx | uint8_t | Index of the signal (starts from zero). |
| *desc | char | Name of the signal (Characters must be ASCII-compatible). |
Transmit the bufffers
uint8_t es_prot_manager(volatile es_prot* cp)
Writes a signal value to the buffer at index idx.
void es_prot_write_tx_value(volatile es_prot *ep, uint8_t idx, float value)
| Argument | Type | Description |
|---|---|---|
| *cp | es_prot | Pointer to the ‘es_prot’ variable. |
| idx | uint8_t | Index of the signal (starts from zero). |
| value | float | Value of the signal |
Example usage:
es_prot_write_tx_value(&USB_COMM, 0, get_i_d());
Get a parameter from the buffer at index idx.
int es_prot_get_rx_value(volatile es_prot* cp, uint8_t idx)
| Argument | Type | Description |
|---|---|---|
| *cp | es_prot | Pointer to the ‘es_prot’ variable. |
| idx | uint8_t | Index of the parameter (starts from zero). |
void es_prot_set_cmd(volatile es_prot* cp, uint8_t cmd)
| Argument | Type | Description |
|---|---|---|
| *cp | es_prot | Pointer to the ‘es_prot’ variable. |
| cmd | uint8_t | 'RECORD_CMD' or 'NO_CMD'. |
With the terminal on the left side of the commands tab you can send a command string to the embedded system which can be accessed by means of the char array terminal_cmd in the es_prot struct. The buffer has a size of char[16];
es_prot.terminal_cmd