9#include <avr/interrupt.h>
11#include <util/atomic.h>
13#define F_CPU 16000000L
15#define MYUBRR (F_CPU / 16 / BAUD - 1)
18char dataBuffer[MAXDATALEN];
20volatile REGTYPE *regPtrs[nRegs] = {&PORTB, &PORTC, &PORTD};
22REGTYPE masks[nRegs] = {
31void handle_nf_messages(
ascii_serial_com *asc,
char ascVersion,
char appVersion,
32 char command,
char *data,
size_t dataLen,
41 .state_rw = ®_pointers_state,
42 .func_nf = handle_nf_messages,
43 .state_nf = &stream_state};
47#define extraInputBuffer_size 64
48uint8_t extraInputBuffer_raw[extraInputBuffer_size];
55char counter_buffer[2];
73 extraInputBuffer_raw);
75 Catch(e) {
return e; }
89 ATOMIC_BLOCK(ATOMIC_FORCEON) {
100 &ascd,
'0',
'0', counter_buffer, 2);
105 Catch(e) { nExceptions++; }
114 __attribute__((unused))
char ascVersion,
115 __attribute__((unused))
char appVersion,
char command,
116 __attribute__((unused))
char *data,
117 __attribute__((unused))
size_t dataLen,
120 if (command ==
'n') {
122 }
else if (command ==
'f') {
#define uart_rx_to_circ_buf(uart_no, circ_buf_ptr)
Receive a byte from UART into circular buffer.
#define uart_tx_from_circ_buf(uart_no, circ_buf_ptr)
Transmit a byte from the circular buffer.
void convert_uint8_to_hex(uint8_t num, char *outstr, bool caps)
convert uint8 to hex string
circular_buffer_uint8 * ascii_serial_com_device_get_output_buffer(ascii_serial_com_device *ascd)
ASCII Serial Com Device get output buffer.
void ascii_serial_com_device_receive(ascii_serial_com_device *ascd)
ASCII Serial Com Device receive messages.
void ascii_serial_com_device_put_s_message_in_output_buffer(ascii_serial_com_device *ascd, char ascVersion, char appVersion, char *data, size_t dataLen)
ASCII Serial Com Device put a 's' message in output buffer.
circular_buffer_uint8 * ascii_serial_com_device_get_input_buffer(ascii_serial_com_device *ascd)
ASCII Serial Com Device get input buffer.
void ascii_serial_com_device_init(ascii_serial_com_device *ascd, ascii_serial_com_device_config *config)
ASCII Serial Com Device init.
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.
ASCII Serial Com Register Pointers.
#define UART_Init(uart_no, ubrr, rxIntEnable)
Initialize USART.
size_t circular_buffer_get_size_uint8(const circular_buffer_uint8 *circ_buf)
circular buffer get number of elements
void circular_buffer_init_uint8(circular_buffer_uint8 *circ_buf, const size_t capacity, uint8_t *buffer)
circular buffer init method
uint8_t circular_buffer_pop_front_uint8(circular_buffer_uint8 *circ_buf)
circular buffer pop front
bool circular_buffer_is_empty_uint8(const circular_buffer_uint8 *circ_buf)
circular buffer get if empty
void circular_buffer_push_back_uint8(circular_buffer_uint8 *circ_buf, const uint8_t element)
circular buffer push back
ASCII Serial Com Device Config Struct.
void(* func_rw)(ascii_serial_com *, char, char, char, char *data, size_t, void *)
ASCII Serial Com Device State struct.
ASCII Serial Com Interface State struct.
ASCII Serial Com Register Pointers State struct.