Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00045 #include <cfg/uart.h>
00046 #include <arch/arm/atmel/debug_at91.h>
00047
00048 #if defined(USART0_BASE)
00049
00054
00055 #ifndef NUT_DEV_DEBUG_SPEED
00056 #ifdef UART0_INIT_BAUDRATE
00057 #define NUT_DEV_DEBUG_SPEED UART0_INIT_BAUDRATE
00058 #else
00059 #define NUT_DEV_DEBUG_SPEED 115200
00060 #endif
00061 #endif
00062
00068 static int Debug0Init(NUTDEVICE * dev)
00069 {
00070
00071 #if defined (PS_PCER)
00072 outr(PS_PCER, _BV(US0_ID));
00073 #elif defined (PMC_PCER)
00074 outr(PMC_PCER, _BV(US0_ID));
00075 #endif
00076
00077 #if defined (P15_RXD0) && defined (P14_TXD0)
00078 outr(PIO_PDR, _BV(P15_RXD0) | _BV(P14_TXD0));
00079 #elif defined (PA0_RXD0_A) && defined (PA1_TXD0_A)
00080 outr(PIOA_PDR, _BV(PA0_RXD0_A) | _BV(PA1_TXD0_A));
00081 #elif defined (PA5_RXD0_A) && defined (PA6_TXD0_A)
00082 outr(PIOA_PDR, _BV(PA5_RXD0_A) | _BV(PA6_TXD0_A));
00083 #endif
00084
00085 outr(US0_CR, US_RSTRX | US_RSTTX | US_RXDIS | US_TXDIS);
00086
00087 outr(US0_IDR, 0xFFFFFFFF);
00088 #if defined (US0_RCR) && defined(US0_TCR)
00089
00090 outr(US0_RCR, 0);
00091 outr(US0_TCR, 0);
00092 #endif
00093 #if NUT_DEV_DEBUG_SPEED
00094
00095 outr(US0_BRGR, At91BaudRateDiv(NUT_DEV_DEBUG_SPEED));
00096 #endif
00097
00098 outr(US0_MR, US_CHMODE_NORMAL | US_CHRL_8 | US_PAR_NO | US_NBSTOP_1);
00099
00100 outr(US0_CR, US_RXEN | US_TXEN);
00101
00102 return 0;
00103 }
00104
00105 static NUTFILE dbgfile0;
00106
00110 NUTDEVICE devDebug0 = {
00111 0,
00112 {'u', 'a', 'r', 't', '0', 0, 0, 0, 0}
00113 ,
00114 0,
00115 USART0_BASE,
00116 0,
00117 0,
00118 &dbgfile0,
00119 Debug0Init,
00120 At91DevDebugIOCtl,
00121 0,
00122 At91DevDebugWrite,
00123 At91DevDebugOpen,
00124 At91DevDebugClose,
00125 0
00126 };
00127
00128 #endif
00129