1 #include <AT91RM9200.h>
2 #include <lib_AT91RM9200.h>
5 static char erase_seq
[] = "\b \b"; /* erase sequence */
6 static char tab_seq
[] = " "; /* used to expand TABs */
8 int at91_dbgu_putc(int ch
)
10 while (!AT91F_US_TxReady((AT91PS_USART
)AT91C_BASE_DBGU
));
11 AT91F_US_PutChar((AT91PS_USART
)AT91C_BASE_DBGU
, (char)ch
);
17 while(!AT91F_US_RxReady((AT91PS_USART
)AT91C_BASE_DBGU
));
18 return((int)AT91F_US_GetChar((AT91PS_USART
)AT91C_BASE_DBGU
));
22 //*-----------------------------------------------------------------------------
23 //* Function Name : AT91F_ClrScr()
24 //* Object : Send a clear screen on the USART
25 //* Input Parameters :
27 //*-----------------------------------------------------------------------------
28 void AT91F_ClrScr(void)
34 //*-----------------------------------------------------------------------------
35 //* Function Name : AT91F_DeleteChar()
37 //* Input Parameters :
39 //*-----------------------------------------------------------------------------
40 char *AT91F_DeleteChar(char *buffer
, char *p
, int *colp
, int *np
, int plen
)
48 if (*(--p
) == '\t') { /* will retype the whole line */
49 while (*colp
> plen
) {
53 for (s
=buffer
; s
<p
; ++s
) {
55 puts(tab_seq
+((*colp
) & 07));
56 *colp
+= 8 - ((*colp
) & 07);
72 //*-----------------------------------------------------------------------------
73 //* Function Name : AT91F_ReadLine()
75 //* Input Parameters :
77 //*-----------------------------------------------------------------------------
78 int AT91F_ReadLine (const char *const prompt
, char *console_buffer
)
80 char *p
= console_buffer
;
81 int n
= 0; /* buffer index */
82 int plen
= strlen (prompt
); /* prompt length */
83 int col
; /* output column cnt */
97 case '\r': /* Enter */
101 return (p
- console_buffer
);
103 case 0x03: /* ^C - break */
104 console_buffer
[0] = '\0'; /* discard input */
107 case 0x15: /* ^U - erase line */
117 case 0x17: /* ^W - erase word */
118 p
= (char *)AT91F_DeleteChar(console_buffer
, p
, &col
, &n
, plen
);
119 while ((n
> 0) && (*p
!= ' '))
120 p
= (char *)AT91F_DeleteChar(console_buffer
, p
, &col
, &n
, plen
);
123 case 0x08: /* ^H - backspace */
124 case 0x7F: /* DEL - backspace */
125 p
=(char *)AT91F_DeleteChar(console_buffer
, p
, &col
, &n
, plen
);
130 * Must be a normal character then
132 if (n
< (AT91C_CB_SIZE
-2))
134 ++col
; /* echo input */
139 else /* Buffer full */
146 //*-----------------------------------------------------------------------------
147 //* Function Name : AT91F_WaitKeyPressed()
149 //* Input Parameters :
151 //*-----------------------------------------------------------------------------
152 void AT91F_WaitKeyPressed(void)