X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fcpu%2Favr%2Fdrv%2Fser_xmega.h;h=3dc58fc8293bc6c976af9f6f8bcececd886d7d07;hb=57fa5e371a8b40afc99b922731b77d17c55330a4;hp=cad8b1e95b97b816523278d4525f102019ca1e0a;hpb=5f79b6719488747126625b6aae6ef684961f3d52;p=bertos.git diff --git a/bertos/cpu/avr/drv/ser_xmega.h b/bertos/cpu/avr/drv/ser_xmega.h index cad8b1e9..3dc58fc8 100644 --- a/bertos/cpu/avr/drv/ser_xmega.h +++ b/bertos/cpu/avr/drv/ser_xmega.h @@ -46,6 +46,7 @@ #include /* BV() */ #include /* uint8_t */ +#include "cfg/cfg_ser.h" /* Serialport configuration settings */ typedef uint8_t serstatus_t; @@ -64,21 +65,100 @@ typedef uint8_t serstatus_t; #define SERRF_NOISEERROR 0 /**< Unsupported */ /* + * XMEGA_D4 has 2 serial ports + * XMEGA_D3 has 3 serial ports + * XMEGA_A4 has 5 serial ports + * XMEGA_A3 has 7 serial ports + * XMEGA_A1 has 8 serial ports + * + * These serial ports can be enabled or disabled in the cfg_ser.h file + * Generate definitions whether a serial port needs to be implementend by + * the driver, depending on the type of XMega and the settings in cfg_ser.h + */ +#if CONFIG_UART0_ENABLED + #define IMPLEMENT_SER_UART0 1 +#else + #define IMPLEMENT_SER_UART0 0 +#endif +#if CONFIG_UART1_ENABLED + #define IMPLEMENT_SER_UART1 1 +#else + #define IMPLEMENT_SER_UART1 0 +#endif +#if (CPU_AVR_XMEGA_D3 || CPU_AVR_XMEGA_A4 || CPU_AVR_XMEGA_A3 || CPU_AVR_XMEGA_A1) && CONFIG_UART2_ENABLED + #define IMPLEMENT_SER_UART2 1 +#else + #define IMPLEMENT_SER_UART2 0 +#endif +#if CPU_AVR_XMEGA_A4 || CPU_AVR_XMEGA_A3 || CPU_AVR_XMEGA_A1 + #if CONFIG_UART3_ENABLED + #define IMPLEMENT_SER_UART3 1 + #else + #define IMPLEMENT_SER_UART3 0 + #endif + #if CONFIG_UART4_ENABLED + #define IMPLEMENT_SER_UART4 1 + #else + #define IMPLEMENT_SER_UART4 0 + #endif +#else + #define IMPLEMENT_SER_UART3 0 + #define IMPLEMENT_SER_UART4 0 +#endif +#if CPU_AVR_XMEGA_A3 || CPU_AVR_XMEGA_A1 + #if CONFIG_UART5_ENABLED + #define IMPLEMENT_SER_UART5 1 + #else + #define IMPLEMENT_SER_UART5 0 + #endif + #if CONFIG_UART6_ENABLED + #define IMPLEMENT_SER_UART6 1 + #else + #define IMPLEMENT_SER_UART6 0 + #endif +#else + #define IMPLEMENT_SER_UART5 0 + #define IMPLEMENT_SER_UART6 0 +#endif +#if CPU_AVR_XMEGA_A1 && CONFIG_UART7_ENABLED + #define IMPLEMENT_SER_UART7 1 +#else + #define IMPLEMENT_SER_UART7 0 +#endif + +/* + * * \name Serial hw numbers * * \{ */ enum { +#if IMPLEMENT_SER_UART0 SER_UART0, +#endif +#if IMPLEMENT_SER_UART1 SER_UART1, -#ifdef CPU_AVR_XMEGA_A - //the XMEGA A Family have 5 USART ports +#endif +#if IMPLEMENT_SER_UART2 SER_UART2, +#endif +#if IMPLEMENT_SER_UART3 SER_UART3, +#endif +#if IMPLEMENT_SER_UART4 SER_UART4, #endif - SER_CNT /**< Number of serial ports */ +#if IMPLEMENT_SER_UART5 + SER_UART5, +#endif +#if IMPLEMENT_SER_UART6 + SER_UART6, +#endif +#if IMPLEMENT_SER_UART7 + SER_UART7, +#endif + SER_CNT /**< Number of serial ports implemented*/ }; /*\}*/