projects
/
bertos.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge contributed patch to extend support of atxmega.
[bertos.git]
/
bertos
/
cpu
/
avr
/
drv
/
kdebug_xmega.c
diff --git
a/bertos/cpu/avr/drv/kdebug_xmega.c
b/bertos/cpu/avr/drv/kdebug_xmega.c
index 8f9cf87f9cebf8b32f45f128f3ba87f16bfedcfe..34ed9ee1b27f541b4b90166edaff0766aeb04903 100644
(file)
--- a/
bertos/cpu/avr/drv/kdebug_xmega.c
+++ b/
bertos/cpu/avr/drv/kdebug_xmega.c
@@
-39,6
+39,7
@@
* ports, by using the USART_t structs.
*
* \author Onno <developer@gorgoz.org>
* ports, by using the USART_t structs.
*
* \author Onno <developer@gorgoz.org>
+ * notest:all
*/
#include <hw/hw_cpufreq.h> /* for CPU_FREQ */
*/
#include <hw/hw_cpufreq.h> /* for CPU_FREQ */
@@
-54,7
+55,8
@@
/* Set KDBG_USART, KDBG_USART_PORT and KDBG_USART_TX_PIN_bm
* according to the CONFIG_KDEBUG_PORT setting
/* Set KDBG_USART, KDBG_USART_PORT and KDBG_USART_TX_PIN_bm
* according to the CONFIG_KDEBUG_PORT setting
- * The Xmega A and D families support at least 2 UARTS
+ * All Xmega families support at least 2 UARTS
+ * Some Xmega families suport more (D3->3, A4->5, A3->7, A1->8)
*/
#if CONFIG_KDEBUG_PORT == 0
#define KDBG_USART USARTC0
*/
#if CONFIG_KDEBUG_PORT == 0
#define KDBG_USART USARTC0
@@
-65,31
+67,57
@@
#define KDBG_USART_PORT PORTD
#define KDBG_USART_TX_PIN_bm PIN3_bm
#endif
#define KDBG_USART_PORT PORTD
#define KDBG_USART_TX_PIN_bm PIN3_bm
#endif
-/* Allow the configuration of the extra 3 UARTS for the
- * Xmega A family
- */
-#ifdef CPU_AVR_XMEGA_A
+#if CPU_AVR_XMEGA_D3 || CPU_AVR_XMEGA_A4 || CPU_AVR_XMEGA_A3 || CPU_AVR_XMEGA_A1
#if CONFIG_KDEBUG_PORT == 2
#if CONFIG_KDEBUG_PORT == 2
+ #define KDBG_USART USARTE0
+ #define KDBG_USART_PORT PORTE
+ #define KDBG_USART_TX_PIN_bm PIN3_bm
+ #endif
+#endif
+#if CPU_AVR_XMEGA_A4 || CPU_AVR_XMEGA_A3 || CPU_AVR_XMEGA_A1
+ #if CONFIG_KDEBUG_PORT == 3
#define KDBG_USART USARTC1
#define KDBG_USART_PORT PORTC
#define KDBG_USART_TX_PIN_bm PIN7_bm
#define KDBG_USART USARTC1
#define KDBG_USART_PORT PORTC
#define KDBG_USART_TX_PIN_bm PIN7_bm
- #elif CONFIG_KDEBUG_PORT ==
3
+ #elif CONFIG_KDEBUG_PORT ==
4
#define KDBG_USART USARTD1
#define KDBG_USART_PORT PORTD
#define KDBG_USART_TX_PIN_bm PIN7_bm
#define KDBG_USART USARTD1
#define KDBG_USART_PORT PORTD
#define KDBG_USART_TX_PIN_bm PIN7_bm
- #elif CONFIG_KDEBUG_PORT == 4
- #define KDBG_USART USARTE0
+ #endif
+#endif
+#if CPU_AVR_XMEGA_A3 || CPU_AVR_XMEGA_A1
+ #if CONFIG_KDEBUG_PORT == 5
+ #define KDBG_USART USARTE1
#define KDBG_USART_PORT PORTE
#define KDBG_USART_PORT PORTE
+ #define KDBG_USART_TX_PIN_bm PIN7_bm
+ #elif CONFIG_KDEBUG_PORT == 6
+ #define KDBG_USART USARTF0
+ #define KDBG_USART_PORT PORTF
#define KDBG_USART_TX_PIN_bm PIN3_bm
#endif
#endif
#define KDBG_USART_TX_PIN_bm PIN3_bm
#endif
#endif
+#if CPU_AVR_XMEGA_A1
+ #if CONFIG_KDEBUG_PORT == 7
+ #define KDBG_USART USARTF1
+ #define KDBG_USART_PORT PORTF
+ #define KDBG_USART_TX_PIN_bm PIN7_bm
+ #endif
+#endif
+
+
/* Check if all required KDBG_ macros are defined
*/
#ifndef KDBG_USART
/* Check if all required KDBG_ macros are defined
*/
#ifndef KDBG_USART
- #if CPU_AVR_XMEGA_D
+ #if CPU_AVR_XMEGA_D
4
#error CONFIG_KDEBUG_PORT should be either 0 or 1
#error CONFIG_KDEBUG_PORT should be either 0 or 1
- #elif CPU_AVR_XMEGA_A
+ #elif CPU_AVR_XMEGA_D3
+ #error CONFIG_KDEBUG_PORT should be either 0, 1 or 2
+ #elif CPU_AVR_XMEGA_A4
#error CONFIG_KDEBUG_PORT should be either 0, 1, 2, 3 or 4
#error CONFIG_KDEBUG_PORT should be either 0, 1, 2, 3 or 4
+ #elif CPU_AVR_XMEGA_A3
+ #error CONFIG_KDEBUG_PORT should be either 0, 1, 2, 3, 4, 5 or 6
+ #elif CPU_AVR_XMEGA_A1
+ #error CONFIG_KDEBUG_PORT should be either 0, 1, 2, 3, 4, 5, 6 or 7
#endif
#endif
#endif
#endif
@@
-108,7
+136,7
@@
/*
* \name KDBG macros
/*
* \name KDBG macros
- *
+ *
* Used to set or alter the KDB_USART operation,
* enable the usart or send a byte.
* Some of these methods are called/included from kdbg_hw_init()
* Used to set or alter the KDB_USART operation,
* enable the usart or send a byte.
* Some of these methods are called/included from kdbg_hw_init()
@@
-144,7
+172,7
@@
/*
* To restore the USART state, to registers need to be restored
/*
* To restore the USART state, to registers need to be restored
- * These registers (CTRLA and CTRLB) can be saved to the
+ * These registers (CTRLA and CTRLB) can be saved to the
* kdbg_avr_xmaga_irqsave structure
*/
struct kdbg_avr_xmega_irqsave
* kdbg_avr_xmaga_irqsave structure
*/
struct kdbg_avr_xmega_irqsave
@@
-194,7
+222,8
@@
typedef struct kdbg_avr_xmega_irqsave kdbg_irqsave_t;
INLINE void kdbg_hw_init(void)
{
//set transmit pin as output
INLINE void kdbg_hw_init(void)
{
//set transmit pin as output
- KDBG_USART_PORT.OUT = KDBG_USART_PORT.OUT & ~KDBG_USART_TX_PIN_bm;
+ //KDBG_USART_PORT.OUTCLR = KDBG_USART_TX_PIN_bm;
+ KDBG_USART_PORT.OUTSET = KDBG_USART_TX_PIN_bm;
KDBG_USART_PORT.DIRSET = KDBG_USART_TX_PIN_bm;
//set 8 bits, no parity, 1 stop bit
KDBG_SET_FORMAT(USART_CHSIZE_8BIT_gc, USART_PMODE_DISABLED_gc, false);
KDBG_USART_PORT.DIRSET = KDBG_USART_TX_PIN_bm;
//set 8 bits, no parity, 1 stop bit
KDBG_SET_FORMAT(USART_CHSIZE_8BIT_gc, USART_PMODE_DISABLED_gc, false);