6 * This tools should help to parse some input.
15 int getnextwordn(char *s, int n){ /* words are seperated by spaces */
17 while ((c=uart_getc()) == ' ')
20 while (n && (*s++=uart_getc())!=' ')
27 void readhex2buffer(void* buffer, int n){
31 // DEBUG_S("\r\nDBG: n="); DEBUG_B(n&0xff); DEBUG_S("\r\n");
34 if ('0'<= c && '9'>=c){
35 ((uint8_t*)buffer)[i] = c - '0';
37 c &= ~('A' ^ 'a'); /* make all uppercase */
38 if ('A'<= c && 'F'>=c){
39 ((uint8_t*)buffer)[i] = c - 'A' + 10;
41 /* oh shit, wrong char */
45 ((uint8_t*)buffer)[i] <<= 4;
48 if ('0'<= c && '9'>=c){
49 ((uint8_t*)buffer)[i] |= c - '0';
51 c &= ~('A' ^ 'a'); /* make all uppercase */
52 if ('A'<= c && 'F'>=c){
53 ((uint8_t*)buffer)[i] |= c - 'A' + 10;
55 /* oh shit, wrong char */
61 void uart_putptr(void* p){
62 uart_hexdump((void*) &p,2);