STM32F10x library
serialq.h
1 // ------------------------------------------------------------------
2 // --- serialq.c - basic routines for sending data over USART ---
3 // --- ---
4 // --- 03.dec.2013, Matej Kogovsek (matej@hamradio.si) ---
5 // ------------------------------------------------------------------
6 
7 #ifndef MAT_SERIALQ_H
8 #define MAT_SERIALQ_H
9 
10 #include <inttypes.h>
11 
12 void ser_init(const uint8_t devnum, const uint32_t br, uint8_t* txb, uint16_t txs, uint8_t* rxb, uint16_t rxs);
13 void ser_shutdown(const uint8_t devnum);
14 
15 void ser_flush_rxbuf(const uint8_t devnum);
16 void ser_wait_txe(const uint8_t devnum);
17 uint8_t ser_getc(const uint8_t devnum, uint8_t* const d);
18 
19 void ser_putc(const uint8_t devnum, const char a);
20 void ser_puts(const uint8_t devnum, const char* s);
21 void ser_putsn(const uint8_t devnum, const char* s, uint8_t n);
22 void ser_puti_lc(const uint8_t devnum, const int32_t a, const uint8_t r, uint8_t w, char c);
23 void ser_putf(const uint8_t devnum, float f, uint8_t prec);
24 #define ser_puti(a, b, c) ser_puti_lc(a, b, c, 0, 'x')
25 #define ser_puti_lz(a, b, c, d) ser_puti_lc(a, b, c, d, '0')
26 
27 extern uint8_t ser_printf_devnum;
28 int ser_printf(const char* s, ...);
29 
30 #endif
void ser_putc(const uint8_t devnum, const char a)
Enqueue a byte to the serial queue for transmission.
Definition: serialq.c:157
void ser_shutdown(const uint8_t devnum)
Deinit USART.
Definition: serialq.c:115
uint8_t ser_printf_devnum
Definition: serialq.c:240
void ser_putsn(const uint8_t devnum, const char *s, uint8_t n)
Send n chars of string.
Definition: serialq.c:192
void ser_putf(const uint8_t devnum, float f, uint8_t prec)
Send float with specified precision.
Definition: serialq.c:229
uint8_t ser_getc(const uint8_t devnum, uint8_t *const d)
Get a byte from the serial queue.
Definition: serialq.c:146
void ser_puti_lc(const uint8_t devnum, const int32_t a, const uint8_t r, uint8_t w, char c)
Send int in the specified radix r of minlen w prepended by char c.
Definition: serialq.c:212
void ser_init(const uint8_t devnum, const uint32_t br, uint8_t *txb, uint16_t txs, uint8_t *rxb, uint16_t rxs)
Init USART.
Definition: serialq.c:69
int ser_printf(const char *s,...)
Simplified implementation of printf (without dynamic malloc).
Definition: serialq.c:248
void ser_flush_rxbuf(const uint8_t devnum)
Flush rx buffer.
Definition: serialq.c:124
void ser_wait_txe(const uint8_t devnum)
Wait for output queue to be transmitted.
Definition: serialq.c:133
void ser_puts(const uint8_t devnum, const char *s)
Send a string.
Definition: serialq.c:178