28 char *data,
size_t dataLen,
void *register_pointers_state_vp) {
29 if (!register_pointers_state_vp) {
31 command, data, dataLen,
32 ASC_ERROR_REG_BLOCK_NULL);
37 if (command !=
'r' && command !=
'w') {
39 command, data, dataLen,
40 ASC_ERROR_UNEXPECTED_COMMAND);
45 command, data, dataLen,
46 ASC_ERROR_DATA_TOO_SHORT);
50 if (reg_num >= register_pointers_state->
n_regs) {
52 command, data, dataLen,
53 ASC_ERROR_REGNUM_OOB);
56 volatile REGTYPE *pointer = register_pointers_state->
pointers[reg_num];
63 put_val_into_bytes(reg_val, data + 5);
64 dataLen = 5 + REGWIDTHBYTES * 2;
66 if (dataLen < 5 + REGWIDTHBYTES) {
68 command, data, dataLen,
69 ASC_ERROR_REGVAL_LEN);
73 REGTYPE new_reg_val = get_val_from_bytes(data + 5);
74 REGTYPE mask = register_pointers_state->
write_masks[reg_num];
75 *pointer = (new_reg_val & mask) | (*pointer & ~mask);
80 command, data, dataLen);
void ascii_serial_com_put_message_in_output_buffer(ascii_serial_com *asc, char ascVersion, char appVersion, char command, const char *data, size_t dataLen)
ASCII Serial Com Pack and put message in output buffer.
void ascii_serial_com_put_error_in_output_buffer(ascii_serial_com *asc, char ascVersion, char appVersion, char command, char *data, size_t dataLen, enum asc_exception errorCode)
ASCII Serial Com put error message in out buffer.
void ascii_serial_com_register_pointers_handle_message(ascii_serial_com *asc, char ascVersion, char appVersion, char command, char *data, size_t dataLen, void *register_pointers_state_vp)
ASCII Serial Com Register Pointers handle message.
void ascii_serial_com_register_pointers_init(ascii_serial_com_register_pointers *register_pointers_state, volatile REGTYPE **pointers, REGTYPE *write_masks, uint16_t n_regs)
ASCII Serial Com Register Pointers init.