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