diff options
author | Karel Kočí <cynerd@email.cz> | 2015-10-11 14:13:02 +0200 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2015-10-11 14:16:52 +0200 |
commit | 62c4883af719f5bacd197257387a0071c625e469 (patch) | |
tree | c8f37c013c8263f818375d5b45606c10584a7646 /usart.h | |
parent | 861ed124caf5a403748c948b88afa4ef89cc1787 (diff) | |
download | avr-ioe-62c4883af719f5bacd197257387a0071c625e469.tar.gz avr-ioe-62c4883af719f5bacd197257387a0071c625e469.tar.bz2 avr-ioe-62c4883af719f5bacd197257387a0071c625e469.zip |
Replace usart initialization parameters with configuration
Baudrate and other configurations are now defined in compile time by
preprocessor flags. This simplifies output code.
Diffstat (limited to 'usart.h')
-rw-r--r-- | usart.h | 51 |
1 files changed, 3 insertions, 48 deletions
@@ -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); |