2007-10-16 19:20:11 -04:00
|
|
|
#ifndef UART_H
|
|
|
|
#define UART_H
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
/* Init */
|
2007-11-01 19:36:31 -04:00
|
|
|
void uart_init(int uart, int32_t rate);
|
2007-10-16 19:20:11 -04:00
|
|
|
|
|
|
|
/* Blocking sends */
|
|
|
|
void uart_put(int uart, uint8_t x);
|
|
|
|
void uart_put_string(int uart, const char *s);
|
|
|
|
void uart_crlf(int uart);
|
|
|
|
void uart_put_hex(int uart, uint8_t x);
|
|
|
|
void uart_put_hex16(int uart, uint16_t x);
|
|
|
|
void uart_put_hex32(int uart, uint32_t x);
|
|
|
|
void uart_put_bin(int uart, uint8_t x);
|
2007-11-05 19:57:07 -05:00
|
|
|
void uart_put_dec(int uart, int32_t x);
|
2009-07-21 16:31:09 -04:00
|
|
|
void uart_put_float(int uart, float x);
|
2007-10-16 19:20:11 -04:00
|
|
|
|
|
|
|
/* Blocking receives */
|
|
|
|
uint8_t uart_get(int uart);
|
|
|
|
|
|
|
|
/* Return true if get/put would not block */
|
|
|
|
int uart_can_get(int uart);
|
|
|
|
int uart_can_put(int uart);
|
|
|
|
|
|
|
|
/* Helpers to work with a specific uart */
|
2007-11-01 19:36:31 -04:00
|
|
|
#define uart1_init(x) uart_init(1, x)
|
2008-01-22 22:33:10 -05:00
|
|
|
#define uart1_can_get() uart_can_get(1)
|
2007-11-05 19:57:07 -05:00
|
|
|
#define uart1_get() uart_get(1)
|
2007-10-16 19:20:11 -04:00
|
|
|
#define uart1_put(x) uart_put(1,x)
|
|
|
|
#define uart1_put_string(x) uart_put_string(1,x)
|
|
|
|
#define uart1_crlf() uart_crlf(1)
|
|
|
|
#define uart1_put_hex(x) uart_put_hex(1,x)
|
|
|
|
#define uart1_put_hex16(x) uart_put_hex16(1,x)
|
|
|
|
#define uart1_put_hex32(x) uart_put_hex32(1,x)
|
|
|
|
#define uart1_put_bin(x) uart_put_bin(1,x)
|
|
|
|
#define uart1_put_dec(x) uart_put_dec(1,x)
|
2009-07-21 16:31:09 -04:00
|
|
|
#define uart1_put_float(x) uart_put_float(1,x)
|
2007-10-16 19:20:11 -04:00
|
|
|
|
2007-11-01 19:36:31 -04:00
|
|
|
#define uart2_init(x) uart_init(2, x)
|
2008-01-22 22:33:10 -05:00
|
|
|
#define uart2_can_get() uart_can_get(2)
|
2007-11-05 19:57:07 -05:00
|
|
|
#define uart2_get() uart_get(2)
|
2007-10-16 19:20:11 -04:00
|
|
|
#define uart2_put(x) uart_put(2,x)
|
|
|
|
#define uart2_put_string(x) uart_put_string(2,x)
|
|
|
|
#define uart2_crlf() uart_crlf(2)
|
|
|
|
#define uart2_put_hex(x) uart_put_hex(2,x)
|
|
|
|
#define uart2_put_hex16(x) uart_put_hex16(2,x)
|
|
|
|
#define uart2_put_hex32(x) uart_put_hex32(2,x)
|
|
|
|
#define uart2_put_bin(x) uart_put_bin(2,x)
|
|
|
|
#define uart2_put_dec(x) uart_put_dec(2,x)
|
2009-07-21 16:31:09 -04:00
|
|
|
#define uart2_put_float(x) uart_put_float(2,x)
|
2007-10-16 19:20:11 -04:00
|
|
|
|
|
|
|
#endif
|