From 62c4883af719f5bacd197257387a0071c625e469 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Sun, 11 Oct 2015 14:13:02 +0200 Subject: Replace usart initialization parameters with configuration Baudrate and other configurations are now defined in compile time by preprocessor flags. This simplifies output code. --- usart.h | 51 +++------------------------------------------------ 1 file changed, 3 insertions(+), 48 deletions(-) (limited to 'usart.h') diff --git a/usart.h b/usart.h index 04ed963..8ff0773 100644 --- a/usart.h +++ b/usart.h @@ -13,52 +13,12 @@ #error "No USART interface is known on your mcu." #endif -enum usartBaudrate { - USART_BAUDRATE_2400, - USART_BAUDRATE_4800, - USART_BAUDRATE_9600, - USART_BAUDRATE_19200, - USART_BAUDRATE_38400, - USART_BAUDRATE_57600, - USART_BAUDRATE_115200 -}; - -enum usartParity { - USART_PARITY_NONE, - USART_PARITY_ODD, - USART_PARITY_EVEN -}; - -enum usartStopBit { - USART_STOPBIT_SINGLE = 1, - USART_STOPBIT_DOUBLE = 2 -}; - -enum usartDataBits { - USART_DATABITS_5 = 5, - USART_DATABITS_6 = 6, - USART_DATABITS_7 = 7, - USART_DATABITS_8 = 8, - // USART_DATABITS_9 = 9 // Not supported yet -}; - -// Not supported yet. This is for synchronous mode only -//enum usartClockPolarity { - //USART_CLOCKPOLARITY_FALLING, - //USART_CLOCKPOLARITY_RISING -//}; +// TODO clock polarity and synchronous mode #define USART_FRAMEERROR _BV(FE0) #define USART_DATAOVERRUN _BV(DOR0) #define USART_PARITYERROR _BV(UPE0) -#if (defined CONFIG_IOE_USART_INFILE) && (CONFIG_IOE_USART_INBUFFER_SIZE <= 0) -#error "USART Input file can't be enabled without input buffer" -#endif -#if (defined CONFIG_IOE_USART_OUTFILE) && (CONFIG_IOE_USART_OUTBUFFER_SIZE <= 0) -#error "USART Input file can't be enabled without output buffer" -#endif - #if CONFIG_IOE_USART_INBUFFER_SIZE > 0 #define _IOE_USART_INBUFFER volatile IOEBUFFER(_ioe_usart_inbuffer, CONFIG_IOE_USART_INBUFFER_SIZE); @@ -70,14 +30,9 @@ volatile IOEBUFFER(_ioe_usart_outbuffer, CONFIG_IOE_USART_OUTBUFFER_SIZE); /* - * Initialize USART device with 115200 baud rate, no parity, single stop bit, - * and 8 data bits. - * This function serves as fast default initialization. + * Initialize USART device. */ -void usart_init_uart(void); -void usart_init_async(enum usartBaudrate, - enum usartParity, enum usartStopBit, - enum usartDataBits); +void usart_init_async(void); void usart_send(uint8_t data); #ifdef _IOE_USART_OUTBUFFER void usart_send_str(char *str); -- cgit v1.2.3