AVR library
serque.h
1 #ifndef MAT_SERIALQ_H
2 #define MAT_SERIALQ_H
3 
4 #if F_CPU == 1000000
5  #define BAUD_4800 12
6 #endif
7 
8 #if F_CPU == 3686400
9  #define BAUD_9600 23
10  #define BAUD_19200 11
11  #define BAUD_115200 1
12 #endif
13 
14 #if F_CPU == 7372800
15  #define BAUD_9600 47
16  #define BAUD_19200 23
17  #define BAUD_115200 3
18 #endif
19 
20 #if F_CPU == 8000000
21  #define BAUD_4800 103
22  #define BAUD_9600 51
23  #define BAUD_19200 25
24  #define BAUD_38400 12
25 #endif
26 
27 #if F_CPU == 11059200
28  #define BAUD_9600 71
29  #define BAUD_19200 35
30  #define BAUD_115200 5
31 #endif
32 
33 #if F_CPU == 16000000
34  #define BAUD_9600 103
35  #define BAUD_19200 51
36  #define BAUD_38400 25
37 #endif
38 
39 #include <inttypes.h>
40 #include <avr/pgmspace.h>
41 
42 #define ser_puti(par1,par2,par3) ser_puti_lc(par1,par2,par3,0,0)
43 
44 void ser_init(const uint8_t n, const uint16_t br, uint8_t* txb, uint8_t txs, uint8_t* rxb, uint8_t rxs);
45 void ser_shutdown(const uint8_t n);
46 void ser_flush_rxbuf(const uint8_t n);
47 uint8_t ser_putc(const uint8_t n, const char a);
48 uint8_t ser_getc(const uint8_t n, uint8_t* const d);
49 void ser_puts_P(const uint8_t n, const PGM_P s);
50 void ser_puts_esc(const uint8_t n, const char* s);
51 void ser_puts(const uint8_t n, const char* s);
52 void ser_puti_lc(const uint8_t n, const uint32_t a, const uint8_t r, uint8_t l, char c);
53 void ser_putf(const uint8_t n, float f, uint8_t prec);
54 uint8_t ser_txdone(const uint8_t n);
55 
56 #endif
void ser_init(const uint8_t n, const uint16_t br, uint8_t *txb, uint8_t txs, uint8_t *rxb, uint8_t rxs)
Init USART.
Definition: serque.c:69
void ser_shutdown(const uint8_t n)
Deinit USART.
Definition: serque.c:95
void ser_flush_rxbuf(const uint8_t n)
Flush rx buffer.
Definition: serque.c:110
uint8_t ser_getc(const uint8_t n, uint8_t *const d)
Get a byte from the serial queue.
Definition: serque.c:143
uint8_t ser_putc(const uint8_t n, const char a)
Enqueue a byte to the serial queue for transmission.
Definition: serque.c:120