/*---------------------------------------------------------------------------*/ int putchar (int c) { int bl = '\r' ; if (tx_init == YES) { /* Get a spot on the tx buffer */ if (sem_get (tx_buf_sem, WAIT_FOREVER) != GOOD) return EOF ; /* First take the buffer semaphore */ if (sem_get (putchar_sem, WAIT_FOREVER) != GOOD) return EOF ; /* Copy character into buffer */ tx_buf [tx_p++ % BUF_SIZE] = (u8) c ; /* Give back the buffer semaphore */ sem_give (putchar_sem) ; /* Now wake up the stdout task */ sem_give (tx_task_sem) ; } else { /* The stdout is still not inited. Used the Debug out */ dbg_putchar (c) ; /* Follow a new line char with a begin line char */ if (c == '\n') dbg_putchar (bl) ; } return c ; } /* End of function putchar() */
/** * \internal * \brief Report a failure and jump out of current test case function * * \param test Current test case. * \param result Result value of failure. \note Should not be \ref TEST_PASS. * \param file Name of file in which function resides. * \param line Line number at which failure occurred. * \param fmt Failure message, as printf-formatted string. * \param ... Values to insert into failure message. */ void test_case_fail(const struct test_case *test, int result, const char *file, unsigned int line, const char *fmt, ...) { va_list ap; dbg_error("Test '%s' failed at %s:%u:\r\n\t", test->name, file, line); va_start(ap, fmt); dbg_vprintf_pgm(fmt, ap); va_end(ap); dbg_putchar('\r'); dbg_putchar('\n'); /* * This will cause the setjmp() call in test_call() to return * TEST_FAIL. */ longjmp(test_failure_jmpbuf, result); }
void LCDsetCursor(uint8_t x, uint8_t y) { dbg_putchar(CMD_ID); if (x == 0) dbg_putchar(CMD_LINE_0); if (x == 1) dbg_putchar(CMD_LINE_1); if (x == 2) dbg_putchar(CMD_LINE_2); if (x == 3) dbg_putchar(CMD_LINE_3); dbg_putchar(y); }
/*---------------------------------------------------------------------------*/ void dbg_putchar (int c) { volatile u32 *addr ; addr = (volatile u32 *) 0xFFFFF214 ; /* Poll for Tx Ready Bit */ while ((*addr & 0x2) != 0x2) ; addr = (volatile u32 *) 0xFFFFF21c ; *addr = (char) c ; if (((char) c) == '\n') dbg_putchar ('\r') ; } /* End of function dbg_putchar() */
/** * Wait for input * \param keys pointer to buffer to store inputs * \param nb_keys max number of keys * \param ctrl_flags flags to control inputs (DBGIN_ECHO_ON, DBGIN_NUM_ONLY, * DBGIN_WANT_ESC and DBGIN_WANT_CR can be used) * \return -1 if ESC, else number of input chars */ static int _app_dbg_input(uint8_t *keys, int nb_keys, uint32_t ctrl_flags) { uint8_t key; int i; for (i = 0; i < nb_keys;) { if (!dbg_rx_ready()) { continue; } key = dbg_getchar(); if (key == CR) { if (DBGIN_WANT_CR & ctrl_flags) { keys[i++] = 0; break; } /* Ignore */ continue; } else if (key == ESC) { if (DBGIN_WANT_ESC & ctrl_flags) { keys[0] = 0; return -1; } } else { if (DBGIN_NUM_ONLY & ctrl_flags) { if (key < '0' || key > '9') { /* Not accepted */ continue; } } if (key <= ' ' || key >= 'z') { /* Not accepted */ continue; } } if (ctrl_flags & DBGIN_ECHO_ON) { dbg_putchar(key); } keys[i++] = key; } return i; }
static void panic_dump_stack(void) { uint32_t *current_sp = (uint32_t *) read_msp(); int word = 0; dbg_puts("\n\nStack dump:\n"); #ifdef LOADER while (current_sp < &stack_end) { #else while (current_sp < &kernel_stack_end) { #endif dbg_printf(DL_EMERG, "%p ", *(++current_sp)); if (++word % 8 == 0) dbg_putchar('\n'); } } #endif /* CONFIG_PANIC_DUMP_STACK */ void panic_impl(char *fmt, ...) { va_list va; va_start(va, fmt); dbg_start_panic(); irq_disable(); dbg_vprintf(DL_EMERG, fmt, va); #ifndef LOADER #ifdef CONFIG_KDB kdb_dump_error(); #endif #endif #ifdef CONFIG_PANIC_DUMP_STACK panic_dump_stack(); #endif va_end(va); while (1) /* */ ; }
void LCDcontrast(uint8_t level) { dbg_putchar(CMD_CONTRAST); dbg_putchar(level); }
void LCDbacklight(uint8_t level) { dbg_putchar(CMD_BACKLIGHT); dbg_putchar(level); }
void LCDclr() { dbg_putchar(CMD_ID); dbg_putchar(CMD_CLR_SCRN); dbg_putchar(0); }
void spilcd_init() { SETBIT(DDRD, 7); //output LCDclr(); dbg_putchar(CMD_ID); dbg_putchar(CMD_NB_LINE); dbg_putchar(4); _delay_ms(5); dbg_putchar(CMD_ID); dbg_putchar(CMD_NB_COLUMN); dbg_putchar(20); _delay_ms(5); dbg_putchar(CMD_ID); dbg_putchar(CMD_CONTRAST); dbg_putchar(255); _delay_ms(5); dbg_putchar(CMD_ID); dbg_putchar(CMD_BACKLIGHT); dbg_putchar(255); _delay_ms(5); }
/** * Boot information edit * \param info Pointer to region information block */ static void _app_info_edit(struct regions_info *info) { uint32_t i, input_size = 1, input_flags = DBGIN_ECHO_ON; uint8_t menu = 0; bool wait_input = false; int rc; ioport_set_pin_dir(DBG_INFO_EDIT_TRIGGER_PIN, IOPORT_DIR_INPUT); if (!DBG_INFO_EDIT_TRIGGER_PIN_ACTIVE == ioport_get_pin_level(DBG_INFO_EDIT_TRIGGER_PIN)) { return; } while (1) { if (wait_input) { rc = _app_dbg_input(input_buf, input_size, input_flags); switch (menu) { case 1: /* Select boot mode */ if (input_buf[0] >= '0' && input_buf[0] < ('0' + TRIGGER_NUM_MAX)) { int new_trig = input_buf[0] - '0'; dbg_print("\r\n"); dbg_print( "- Trigger: %d, %s -> %d, %s\r\n", (int)info->trigger, trigger_get_mode_str(( enum trigger_modes) info ->trigger), new_trig, trigger_get_mode_str(( enum trigger_modes) new_trig)); info->trigger = input_buf[0] - '0'; /* Return to default menu */ menu = 0; wait_input = false; } else { /* Invalid input, wait another */ dbg_putchar(BS); } break; case 2: /* Change boot file */ dbg_print("\r\n"); if (-1 != rc) { dbg_print("- Set file: %s\r\n", input_buf); strcpy(info->boot_file_name, (char *)input_buf); } /* Return to default menu */ menu = 0; wait_input = false; break; default: /* Main menu */ switch (input_buf[0]) { /* Switch to menu */ case '1': case '2': dbg_print("\r\n"); menu = input_buf[0] - '0'; wait_input = false; break; /* Show regions info */ case 'i': case 'I': dbg_print("\r\n"); _app_show_regions_info(info); wait_input = false; break; /* Load regions info */ case 'l': case 'L': region_info_read((void *)INFO_ADDR( true), info); dbg_print("\r\n- Info loaded\r\n"); _app_show_regions_info(info); wait_input = false; break; /* Save regions info */ case 's': case 'S': _app_save_regions_info(info, true); dbg_print("\r\n- Info saved\r\n"); _app_show_regions_info(info); wait_input = false; break; /* Quit edit */ case 'q': case 'Q': dbg_print("\r\n"); return; default: /* Invalid input, wait another */ dbg_putchar(BS); } } } switch (menu) { case 1: /* Select trigger mode */ for (i = 0; i < TRIGGER_NUM_MAX; i++) { dbg_print("= %u: %s\r\n", (unsigned)i, trigger_get_mode_str((enum trigger_modes)i)); } dbg_print("= Current boot mode: %d, %s\r\n", (int)info->trigger, trigger_get_mode_str((enum trigger_modes) info->trigger)); dbg_print("> New mode:"); input_size = 1; input_flags = DBGIN_ECHO_ON | DBGIN_NUM_ONLY; break; case 2: /* Change boot file */ dbg_print("==== Available List ====\r\n"); for (i = 0; i < MEDIA_NUM_MAX; i++) { dbg_print(" - In #%u, %s\r\n", (unsigned)i, media_get_type_str((enum media_types)i)); media_select((enum media_types)i); media_scan_files(false); } dbg_print("= Current file: %s\r\n", info->boot_file_name); dbg_print("> New file:"); input_size = 13; input_flags = DBGIN_ECHO_ON | DBGIN_WANT_ESC | DBGIN_WANT_CR; break; default: dbg_print("\r\n==== Info Edit ====\r\n"); dbg_print(" - 1: Change boot mode\r\n"); dbg_print(" - 2: Change boot file\r\n"); dbg_print(" - i: Show regions information\r\n"); dbg_print(" - l: Load/restore boot information\r\n"); dbg_print(" - s: Save boot information\r\n"); dbg_print(" - q: quit edit\r\n"); input_size = 1; input_flags = DBGIN_ECHO_ON; } wait_input = true; } }
int putchar(int c) { dbg_putchar(c); return c; }
int __sp(struct _reent *_ptr, int c, FILE *_p) { dbg_putchar(c); return c; }
int putc(int c, FILE *f) { dbg_putchar(c); return c; }