|
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
Go to the source code of this file.
Data Structures | |
struct | acc_reg_protocol_t |
Register access mode and functions struct. More... | |
Macros | |
#define | ACC_REG_PROTOCOL_ADDRESS_LENGTH (2U) |
#define | ACC_REG_PROTOCOL_REGDATA_LENGTH (4U) |
#define | ACC_REG_ERROR_FLAG_PROTOCOL_STATE_ERROR (1U << 0U) |
#define | ACC_REG_ERROR_FLAG_PACKET_LENGTH_ERROR (1U << 1U) |
#define | ACC_REG_ERROR_FLAG_ADDRESS_ERROR (1U << 2U) |
#define | ACC_REG_ERROR_FLAG_WRITE_FAILED (1U << 3U) |
#define | ACC_REG_ERROR_FLAG_WRITE_TO_READ_ONLY (1U << 4U) |
Typedefs | |
typedef void() | acc_reg_read_func_t(uint32_t *data) |
Function to read a register. More... | |
typedef bool() | acc_reg_write_func_t(const uint32_t data) |
Function to writes a register. More... | |
Functions | |
void | acc_reg_protocol_setup (const acc_reg_protocol_t *protocol_struct, uint16_t register_count) |
Setup register protocol. More... | |
void | acc_reg_protocol_reset (void) |
Reset register protocol. More... | |
bool | acc_reg_protocol_data_nack (void) |
Should protocol NACK the next data. More... | |
void | acc_reg_protocol_data_in (uint8_t *buffer, size_t data_in_length) |
Handle data input to the register protocol. More... | |
void | acc_reg_protocol_data_out (uint8_t *buffer, size_t data_out_length) |
Handle data input from the register protocol. More... | |
uint32_t | acc_reg_protocol_get_error_flags (void) |
Get the error flags for the register protocol. More... | |
int32_t | acc_reg_protocol_float_to_int32_milli (float value) |
Convert 1000 * float to int32. More... | |
uint32_t | acc_reg_protocol_float_to_uint32_milli (float value) |
Convert 1000 * float to uint32. More... | |
float | acc_reg_protocol_int32_milli_to_float (int32_t value) |
Convert int32 / 1000 to float. More... | |
float | acc_reg_protocol_uint32_milli_to_float (uint32_t value) |
Convert uint32 / 1000 to float. More... | |
#define ACC_REG_ERROR_FLAG_ADDRESS_ERROR (1U << 2U) |
Definition at line 16 of file acc_reg_protocol.h.
#define ACC_REG_ERROR_FLAG_PACKET_LENGTH_ERROR (1U << 1U) |
Definition at line 15 of file acc_reg_protocol.h.
#define ACC_REG_ERROR_FLAG_PROTOCOL_STATE_ERROR (1U << 0U) |
Definition at line 14 of file acc_reg_protocol.h.
#define ACC_REG_ERROR_FLAG_WRITE_FAILED (1U << 3U) |
Definition at line 17 of file acc_reg_protocol.h.
#define ACC_REG_ERROR_FLAG_WRITE_TO_READ_ONLY (1U << 4U) |
Definition at line 18 of file acc_reg_protocol.h.
#define ACC_REG_PROTOCOL_ADDRESS_LENGTH (2U) |
Definition at line 11 of file acc_reg_protocol.h.
#define ACC_REG_PROTOCOL_REGDATA_LENGTH (4U) |
Definition at line 12 of file acc_reg_protocol.h.
typedef void() acc_reg_read_func_t(uint32_t *data) |
Function to read a register.
[out] | data | The data to be read |
Definition at line 25 of file acc_reg_protocol.h.
typedef bool() acc_reg_write_func_t(const uint32_t data) |
Function to writes a register.
[in] | data | The data to be written |
Definition at line 33 of file acc_reg_protocol.h.
void acc_reg_protocol_data_in | ( | uint8_t * | buffer, |
size_t | data_in_length | ||
) |
Handle data input to the register protocol.
[in] | buffer | The data to be processed by the protocol |
[in] | data_in_length | The byte length of the data to be processed |
Definition at line 230 of file acc_reg_protocol.c.
bool acc_reg_protocol_data_nack | ( | void | ) |
Should protocol NACK the next data.
Return true if protocol should nack the next data write
Definition at line 218 of file acc_reg_protocol.c.
void acc_reg_protocol_data_out | ( | uint8_t * | buffer, |
size_t | data_out_length | ||
) |
Handle data input from the register protocol.
[in] | buffer | The data buffer to be filled with data |
[in] | data_out_length | The byte length of the data to be read |
Definition at line 294 of file acc_reg_protocol.c.
int32_t acc_reg_protocol_float_to_int32_milli | ( | float | value | ) |
Convert 1000 * float to int32.
[in] | value | A float value |
Definition at line 330 of file acc_reg_protocol.c.
uint32_t acc_reg_protocol_float_to_uint32_milli | ( | float | value | ) |
Convert 1000 * float to uint32.
[in] | value | A float value |
Definition at line 336 of file acc_reg_protocol.c.
uint32_t acc_reg_protocol_get_error_flags | ( | void | ) |
Get the error flags for the register protocol.
The error flags will be cleared by this call
ACC_REG_ERROR_FLAG_PROTOCOL_STATE_ERROR The flag will be set if for example the protocol got unexpected data
ACC_REG_ERROR_FLAG_PACKET_LENGTH_ERROR The flag will be set if for example the protocol got data with unexpected length
ACC_REG_ERROR_FLAG_ADDRESS_ERROR The flag will be set if a register address outside the address space is used
ACC_REG_ERROR_FLAG_WRITE_FAILED The flag will be set if a register write failed
ACC_REG_ERROR_FLAG_WRITE_TO_READ_ONLY The flag will be set if a read only register is written
Return The protocol error flags
Definition at line 319 of file acc_reg_protocol.c.
float acc_reg_protocol_int32_milli_to_float | ( | int32_t | value | ) |
Convert int32 / 1000 to float.
[in] | value | An int32 value |
Definition at line 342 of file acc_reg_protocol.c.
void acc_reg_protocol_reset | ( | void | ) |
Reset register protocol.
This function should be called when a new transaction start.
Definition at line 211 of file acc_reg_protocol.c.
void acc_reg_protocol_setup | ( | const acc_reg_protocol_t * | protocol_struct, |
uint16_t | register_count | ||
) |
Setup register protocol.
[in] | protocol_struct | The protocol struct with read/write functions |
[in] | register_count | The number of registers in the struct |
Definition at line 202 of file acc_reg_protocol.c.
float acc_reg_protocol_uint32_milli_to_float | ( | uint32_t | value | ) |
Convert uint32 / 1000 to float.
[in] | value | An uint32 value |
Definition at line 351 of file acc_reg_protocol.c.