kdebug_at91.c
Go to the documentation of this file.00001
00039 #include "kdebug_at91.h"
00040 #include <cfg/macros.h>
00041 #include <appconfig.h>
00042 #include <hw_cpu.h>
00043 #include <hw_ser.h>
00044
00045 #include <io/arm.h>
00046
00047 #if CONFIG_KDEBUG_PORT == KDEBUG_PORT_DBGU
00048 #define KDBG_WAIT_READY() while (!(DBGU_SR & BV(US_TXRDY))) {}
00049 #define KDBG_WAIT_TXDONE() while (!(DBGU_SR & BV(US_TXEMPTY))) {}
00050
00051 #define KDBG_WRITE_CHAR(c) do { DBGU_THR = (c); } while(0)
00052
00053
00054 #define KDBG_MASK_IRQ(old) do { (void)old; } while(0)
00055
00056
00057 #define KDBG_RESTORE_IRQ(old) do { (void)old; } while(0)
00058
00059 typedef uint32_t kdbg_irqsave_t;
00060
00061 #else
00062 #error CONFIG_KDEBUG_PORT should be KDEBUG_PORT_DBGU
00063 #endif
00064
00065
00066 INLINE void kdbg_hw_init(void)
00067 {
00068 #if CONFIG_KDEBUG_PORT == KDEBUG_PORT_DBGU
00069
00070 DBGU_IDR = 0xFFFFFFFF;
00071
00072 DBGU_CR = BV(US_RSTRX) | BV(US_RSTTX) | BV(US_RXDIS) | BV(US_TXDIS);
00073
00074 DBGU_BRGR = DIV_ROUND(CLOCK_FREQ, 16 * CONFIG_KDEBUG_BAUDRATE);
00075
00076 DBGU_MR = US_CHMODE_NORMAL | US_CHRL_8 | US_PAR_NO | US_NBSTOP_1;
00077
00078 DBGU_CR = BV(US_TXEN);
00079
00080 PIOA_PDR = BV(DTXD);
00081 PIOA_ASR = BV(DTXD);
00082
00083 #if 0
00084
00085 DBGU_CR = BV(US_RXEN);
00086
00087 PIOA_PDR = BV(DRXD);
00088 PIOA_ASR = BV(DRXD);
00089 #endif
00090 #else
00091 #error CONFIG_KDEBUG_PORT should be KDEBUG_PORT_DBGU
00092 #endif
00093 }