void analyze_ttydata() { static char cmdbuf[33]; static uint8_t cmdlen; uint8_t idx, ucCommand; while(USB_Rx_Buffer->nbytes) { ucCommand = rb_get(USB_Rx_Buffer); //DC(ucCommand); // echo if(ucCommand == '\n' || ucCommand == '\r') { if(!cmdlen) // empty return continue; cmdbuf[cmdlen] = 0; if(!callfn(cmdbuf)) { DC('?'); for(idx = 0; fntab[idx].name; idx++) { DC(' '); DC(fntab[idx].name); } DNL(); } cmdlen = 0; } else { if(cmdlen < sizeof(cmdbuf)-1) cmdbuf[cmdlen++] = ucCommand; } } }
int psci_cpu_on(unsigned long cpu, unsigned long entry, unsigned long context_id) { psci_callfn_t callfn; phandle_t node; uint32_t fnid; if (psci_softc == NULL) { node = ofw_bus_find_compatible(OF_peer(0), "arm,psci-0.2"); if (node == 0) /* TODO: Handle psci 0.1 */ return (PSCI_RETVAL_INTERNAL_FAILURE); fnid = PSCI_FNID_CPU_ON; callfn = psci_get_callfn(node); if (callfn == NULL) return (PSCI_RETVAL_INTERNAL_FAILURE); } else { callfn = psci_softc->psci_call; fnid = psci_softc->psci_fnids[PSCI_FN_CPU_ON]; } /* PSCI v0.1 and v0.2 both support cpu_on. */ return (callfn(fnid, cpu, entry, context_id)); }
void analyze_ttydata(uint8_t channel) { static int cmdlen; /* we need int because TTY_BUFSIZE may be >255 */ uint8_t ucCommand; uint8_t odc = display_channel; display_channel = channel; while(TTY_Rx_Buffer.nbytes) { ucCommand = rb_get(&TTY_Rx_Buffer); #ifdef RPI_TTY_FIX // eat RPi rubbish if (ucCommand == 0xff) continue; #endif if(ucCommand == '\n' || ucCommand == '\r') { if(!cmdlen) // empty return continue; cmdbuf[cmdlen] = 0; if(!callfn(cmdbuf)) { DS_P(PSTR("? (")); display_string(cmdbuf); DS_P(PSTR(" is unknown) Use one of")); callfn(0); DNL(); } cmdlen = 0; } else { if(cmdlen < sizeof(cmdbuf)-1) cmdbuf[cmdlen++] = ucCommand; } } display_channel = odc; }
void menu_handle_joystick(uint8_t key) { uint8_t menu_line[MLINESIZE+1]; //////////////////////////////////////// // Scrolling up/down. if(key == KEY_DOWN || key == KEY_UP) { menu_setbg(menu_curitem); lcd_putchar(menu_curitem-menu_topitem+1, ' '); uint8_t insert_line = 0; if(key == KEY_DOWN) { if(menu_curitem == menu_nitems-1) menu_curitem = 0; else menu_curitem++; if(menu_curitem - menu_topitem >= BODY_LINES) { menu_topitem++; insert_line = 9; } } if(key == KEY_UP) { if(menu_curitem == 0) menu_curitem = menu_nitems-1; else menu_curitem--; if(menu_topitem > menu_curitem) { menu_topitem--; insert_line = 10; } } menu_setbg(menu_curitem); if(insert_line) { uint8_t dpybuf[17]; menu_get_line(menu_item_offset[menu_curitem], menu_line, sizeof(menu_line)); menu_getlineword(1, menu_line, dpybuf+1, sizeof(dpybuf)-1); dpybuf[0] = ' '; lcd_putline(insert_line, (char *)dpybuf); } lcd_putchar(menu_curitem-menu_topitem+1, '>'); } //////////////////////////////////////// // Exec current command if(key == KEY_RIGHT) { // Save the current position menu_lastsel[menu_stack[menu_stackidx-1]] = menu_curitem; menu_get_line(menu_item_offset[menu_curitem], menu_line, sizeof(menu_line)); uint8_t arg[MLINESIZE]; menu_getlineword(2, menu_line, arg, sizeof(arg)); if(menu_line[0] == 'S') { // submenu uint8_t sm; fromhex((char *)arg, &sm, 1); menu_push(sm); } if(menu_line[0] == 'C') { // Command lcd_invon(); callfn((char *)arg); lcd_invoff(); } if(menu_line[0] == 'm') { // Macro uint8_t idx; uint16_t off; lcd_invon(); fromhex((char *)arg, &idx, 1); off = menu_get_line(menu_offset[idx], menu_line, sizeof(menu_line)); while(off && menu_line[0]) { off = menu_get_line(off, menu_line, sizeof(menu_line)); if(off == 0 || !menu_line[0]) break; callfn((char *)menu_line); } lcd_invoff(); } } if(key == KEY_LEFT) { // pop menu stack // Save the current position menu_lastsel[menu_stack[menu_stackidx-1]] = menu_curitem; menu_pop(); } //////////////////////////////////////// // Switch display on / off if(key == KEY_ENTER) { if(lcd_on) { if(lcd_on == 0xff) { lcd_switch(1); lcd_cls(); lcd_contrast(0xfc); menu_stackidx = 0; menu_push(0); } else { dosleep(); } } else { lcd_switch(1); } bat_drawstate(); } }
////////////////////////////////////////////////// // Display routines void display_char(char data) { #ifdef HAS_USB if(USB_IsConnected && (output_enabled & OUTPUT_USB)) { if(USB_Tx_Buffer->nbytes >= USB_Tx_Buffer->size) CDC_Task(); rb_put(USB_Tx_Buffer, data); if(data == '\n') CDC_Task(); } #endif #ifdef HAS_LCD if(output_enabled & OUTPUT_LCD) { static uint8_t buf[TITLE_LINECHARS+1]; static uint8_t off = 0, cmdmode = 0; if(data == '\r') return; if(data == '\n') { buf[off] = 0; off = 0; if(cmdmode) { callfn((char *)buf); } else lcd_putline(0, (char*)buf); cmdmode = 0; } else { // if(off < TITLE_LINECHARS) // or cmd: up to 12Byte: F12346448616c6c6f buf[off++] = data; if(cmdmode && cmdmode++ == 2) { off -= 2; fromhex((char *)buf+off, buf+off, 1); // replace the hexnumber off++; cmdmode = 1; } } // Check if its a message for us: F<HC>..., and set cmdmode if(!cmdmode && off == 5 && buf[0] == 'F') { uint8_t hb[2]; fromhex((char*)buf+1, hb, 2); if(hb[0] == fht_hc[0] && hb[1] == fht_hc[1]) { cmdmode = 1; off = 0; } } } #endif #ifdef HAS_FS if(output_enabled & OUTPUT_LOG) { static uint8_t buf[LOG_NETTOLINELEN+1]; static uint8_t off = 0; if(data == '\r') return; if(data == '\n') { buf[off] = 0; off = 0; Log((char*)buf); } else { if(off < LOG_NETTOLINELEN) buf[off++] = data; } } #endif }
void newdyndata(Modlink *ml) { callfn(ml->m, "init"); }
void freedyndata(Modlink *ml) { callfn(ml->m, "end"); }