Ran clang-format
This commit is contained in:
parent
470eb06345
commit
c03196493a
45
uart.h
45
uart.h
@ -46,33 +46,30 @@ LICENSE:
|
|||||||
* @copyright (C) 2015 Peter Fleury, GNU General Public License Version 3
|
* @copyright (C) 2015 Peter Fleury, GNU General Public License Version 3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <avr/pgmspace.h>
|
#include <avr/pgmspace.h>
|
||||||
|
|
||||||
#if (__GNUC__ * 100 + __GNUC_MINOR__) < 405
|
#if (__GNUC__ * 100 + __GNUC_MINOR__) < 405
|
||||||
#error "This library requires AVR-GCC 4.5 or later, update to newer AVR-GCC compiler !"
|
#error "This library requires AVR-GCC 4.5 or later, update to newer AVR-GCC compiler !"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/**@{*/
|
/**@{*/
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** constants and macros
|
** constants and macros
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/** @brief UART Baudrate Expression
|
/** @brief UART Baudrate Expression
|
||||||
* @param xtalCpu system clock in Mhz, e.g. 4000000UL for 4Mhz
|
* @param xtalCpu system clock in Mhz, e.g. 4000000UL for 4Mhz
|
||||||
* @param baudRate baudrate in bps, e.g. 1200, 2400, 9600
|
* @param baudRate baudrate in bps, e.g. 1200, 2400, 9600
|
||||||
*/
|
*/
|
||||||
#define UART_BAUD_SELECT(baudRate,xtalCpu) (((xtalCpu) + 8UL * (baudRate)) / (16UL * (baudRate)) -1UL)
|
#define UART_BAUD_SELECT(baudRate, xtalCpu) (((xtalCpu) + 8UL * (baudRate)) / (16UL * (baudRate)) - 1UL)
|
||||||
|
|
||||||
/** @brief UART Baudrate Expression for ATmega double speed mode
|
/** @brief UART Baudrate Expression for ATmega double speed mode
|
||||||
* @param xtalCpu system clock in Mhz, e.g. 4000000UL for 4Mhz
|
* @param xtalCpu system clock in Mhz, e.g. 4000000UL for 4Mhz
|
||||||
* @param baudRate baudrate in bps, e.g. 1200, 2400, 9600
|
* @param baudRate baudrate in bps, e.g. 1200, 2400, 9600
|
||||||
*/
|
*/
|
||||||
#define UART_BAUD_SELECT_DOUBLE_SPEED(baudRate,xtalCpu) ( ((((xtalCpu) + 4UL * (baudRate)) / (8UL * (baudRate)) -1UL)) | 0x8000)
|
#define UART_BAUD_SELECT_DOUBLE_SPEED(baudRate, xtalCpu) \
|
||||||
|
(((((xtalCpu) + 4UL * (baudRate)) / (8UL * (baudRate)) - 1UL)) | 0x8000)
|
||||||
|
|
||||||
/** @brief Size of the circular receive buffer, must be power of 2
|
/** @brief Size of the circular receive buffer, must be power of 2
|
||||||
*
|
*
|
||||||
@ -93,19 +90,18 @@ LICENSE:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* test if the size of the circular buffers fits into SRAM */
|
/* test if the size of the circular buffers fits into SRAM */
|
||||||
#if ( (UART_RX_BUFFER_SIZE+UART_TX_BUFFER_SIZE) >= (RAMEND-0x60 ) )
|
#if ((UART_RX_BUFFER_SIZE + UART_TX_BUFFER_SIZE) >= (RAMEND - 0x60))
|
||||||
#error "size of UART_RX_BUFFER_SIZE + UART_TX_BUFFER_SIZE larger than size of SRAM"
|
#error "size of UART_RX_BUFFER_SIZE + UART_TX_BUFFER_SIZE larger than size of SRAM"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** high byte error return code of uart_getc()
|
** high byte error return code of uart_getc()
|
||||||
*/
|
*/
|
||||||
#define UART_FRAME_ERROR 0x1000 /**< @brief Framing Error by UART */
|
#define UART_FRAME_ERROR 0x1000 /**< @brief Framing Error by UART */
|
||||||
#define UART_OVERRUN_ERROR 0x0800 /**< @brief Overrun condition by UART */
|
#define UART_OVERRUN_ERROR 0x0800 /**< @brief Overrun condition by UART */
|
||||||
#define UART_PARITY_ERROR 0x0400 /**< @brief Parity Error by UART */
|
#define UART_PARITY_ERROR 0x0400 /**< @brief Parity Error by UART */
|
||||||
#define UART_BUFFER_OVERFLOW 0x0200 /**< @brief receive ringbuffer overflow */
|
#define UART_BUFFER_OVERFLOW 0x0200 /**< @brief receive ringbuffer overflow */
|
||||||
#define UART_NO_DATA 0x0100 /**< @brief no receive data available */
|
#define UART_NO_DATA 0x0100 /**< @brief no receive data available */
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** function prototypes
|
** function prototypes
|
||||||
@ -118,7 +114,6 @@ LICENSE:
|
|||||||
*/
|
*/
|
||||||
extern void uart_init(unsigned int baudrate);
|
extern void uart_init(unsigned int baudrate);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get received byte from ringbuffer
|
* @brief Get received byte from ringbuffer
|
||||||
*
|
*
|
||||||
@ -145,7 +140,6 @@ extern void uart_init(unsigned int baudrate);
|
|||||||
*/
|
*/
|
||||||
extern unsigned int uart_getc(void);
|
extern unsigned int uart_getc(void);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Put byte to ringbuffer for transmitting via UART
|
* @brief Put byte to ringbuffer for transmitting via UART
|
||||||
* @param data byte to be transmitted
|
* @param data byte to be transmitted
|
||||||
@ -153,7 +147,6 @@ extern unsigned int uart_getc(void);
|
|||||||
*/
|
*/
|
||||||
extern void uart_putc(unsigned char data);
|
extern void uart_putc(unsigned char data);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Put string to ringbuffer for transmitting via UART
|
* @brief Put string to ringbuffer for transmitting via UART
|
||||||
*
|
*
|
||||||
@ -164,8 +157,7 @@ extern void uart_putc(unsigned char data);
|
|||||||
* @param s string to be transmitted
|
* @param s string to be transmitted
|
||||||
* @return none
|
* @return none
|
||||||
*/
|
*/
|
||||||
extern void uart_puts(const char *s );
|
extern void uart_puts(const char *s);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Put string from program memory to ringbuffer for transmitting via UART.
|
* @brief Put string from program memory to ringbuffer for transmitting via UART.
|
||||||
@ -178,14 +170,12 @@ extern void uart_puts(const char *s );
|
|||||||
* @return none
|
* @return none
|
||||||
* @see uart_puts_P
|
* @see uart_puts_P
|
||||||
*/
|
*/
|
||||||
extern void uart_puts_p(const char *s );
|
extern void uart_puts_p(const char *s);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Macro to automatically put a string constant into program memory
|
* @brief Macro to automatically put a string constant into program memory
|
||||||
*/
|
*/
|
||||||
#define uart_puts_P(__s) uart_puts_p(PSTR(__s))
|
#define uart_puts_P(__s) uart_puts_p(PSTR(__s))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */
|
/** @brief Initialize USART1 (only available on selected ATmegas) @see uart_init */
|
||||||
extern void uart1_init(unsigned int baudrate);
|
extern void uart1_init(unsigned int baudrate);
|
||||||
@ -194,14 +184,13 @@ extern unsigned int uart1_getc(void);
|
|||||||
/** @brief Put byte to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_putc */
|
/** @brief Put byte to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_putc */
|
||||||
extern void uart1_putc(unsigned char data);
|
extern void uart1_putc(unsigned char data);
|
||||||
/** @brief Put string to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts */
|
/** @brief Put string to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts */
|
||||||
extern void uart1_puts(const char *s );
|
extern void uart1_puts(const char *s);
|
||||||
/** @brief Put string from program memory to ringbuffer for transmitting via USART1 (only available on selected ATmega) @see uart_puts_p */
|
/** @brief Put string from program memory to ringbuffer for transmitting via USART1 (only available on selected ATmega)
|
||||||
extern void uart1_puts_p(const char *s );
|
* @see uart_puts_p */
|
||||||
|
extern void uart1_puts_p(const char *s);
|
||||||
/** @brief Macro to automatically put a string constant into program memory */
|
/** @brief Macro to automatically put a string constant into program memory */
|
||||||
#define uart1_puts_P(__s) uart1_puts_p(PSTR(__s))
|
#define uart1_puts_P(__s) uart1_puts_p(PSTR(__s))
|
||||||
|
|
||||||
/**@}*/
|
/**@}*/
|
||||||
|
|
||||||
|
|
||||||
#endif // UART_H
|
#endif // UART_H
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user