int ee_do_command( u8 *Tx, int Tx_len, u8 *Rx, int Rx_len, int Send_skip ){ /* Execute this command string, including giving reset and setting to idle after command if Rx_len is set, we read out data from EEPROM */ int i; E_DEBUG("Command, Tx_len %d, Rx_len %d\n", Tx_len, Rx_len ); if(do_reset()){ /* Failed! */ return(-EIO); } if(Send_skip) /* Always send SKIP_ROM first to tell chip we are sending a command, except when we read out rom data for chip */ write_byte(SKIP_ROM); /* Always have Tx data */ for(i=0;i<Tx_len;i++){ write_byte(Tx[i]); } if(Rx_len){ for(i=0;i<Rx_len;i++){ Rx[i]=read_byte(); } } set_idle(); E_DEBUG("Command done\n"); return(0); }
static int usb_kbd_setup(struct usbdevice_s *usbdev , struct usb_endpoint_descriptor *epdesc) { if (! CONFIG_USB_KEYBOARD) return -1; if (keyboard_pipe) // XXX - this enables the first found keyboard (could be random) return -1; if (epdesc->wMaxPacketSize != 8) return -1; // Enable "boot" protocol. int ret = set_protocol(usbdev->defpipe, 0); if (ret) return -1; // Periodically send reports to enable key repeat. ret = set_idle(usbdev->defpipe, KEYREPEATMS); if (ret) return -1; keyboard_pipe = usb_alloc_pipe(usbdev, epdesc); if (!keyboard_pipe) return -1; dprintf(1, "USB keyboard initialized\n"); return 0; }
//--------- Begin of function UnitB::stop_move ---------// // void UnitB::stop_move() { switch( cur_action ) { //----- if the unit is moving right now, ask it to stop as soon as possible -----// case SPRITE_READY_TO_MOVE: set_idle(); break; case SPRITE_TURN: case SPRITE_WAIT: go_x = next_x; go_y = next_y; final_dir = cur_dir; turn_delay = 0; wait_state = 0; set_idle(); break; case SPRITE_MOVE: go_x = next_x; go_y = next_y; if(cur_x==next_x && cur_y==next_y) set_idle(); break; //--- if its current action is SPRITE_ATTACK, stop immediately ---// case SPRITE_ATTACK: set_next(cur_x, cur_y, 0, 1); go_x = next_x; go_y = next_y; set_idle(); cur_frame = 1; break; } //-------- reset parameters --------// cur_path_result_id = 0; // reset it so that if the mode is SPRITE_MOVE, it won't use the old path }
void do_command(u_char cmd) { if(cmd == C_READ_PIO) { DBG_P(":I"); do_read_pio(); } else { DBG_P("?CI"); DBG_X(cmd); set_idle(); } }
void inf_loop_cmd(int argc, char **args, int call_type) { switch (call_type) { case CALL_TYPE_HELP: puts("RUN AN INFINITE LOOP\n"); return; case CALL_TYPE_DESC: putc('\n'); return; } set_idle(); while (1); }
/** idle_loop(): Loop the child processes while waiting for work. Created 081405; last modified 122208 **/ void idle_loop(int id) { char buf[2]; while (TRUE) { while (smp_block[id].input == 0) ; SMP_DEBUG(print("cpu %i got input %i\n", id, smp_block[id].input)); switch (smp_block[id].input) { case SMP_INIT: /* Nothing here at the moment... */ smp_block[id].input = 0; smp_block[id].output = SMP_DONE; break; case SMP_SEARCH: /* Jump into the search() function, where we actively wait for nodes to search, and then search them... (duh) */ smp_copy_root(&board, &smp_data->root_board); smp_block[id].input = 0; smp_block[id].output = SMP_DONE; root_entry = board.game_entry; set_idle(); board.search_stack[0].search_state = SEARCH_CHILD_RETURN; board.search_stack[1].search_state = SEARCH_WAIT; search(&board.search_stack[1]); break; case SMP_UPDATE_HASH: /* Resize the hash tables. */ initialize_hash(); smp_block[id].input = 0; smp_block[id].output = SMP_DONE; break; case SMP_IDLE: /* After we are done searching, do a blocked read on our pipe. This is so that we don't consume CPU time. */ smp_block[id].input = 0; smp_block[id].output = SMP_DONE; read(smp_block[id].wait_pipe[0], buf, 1); break; default: /* Just send back the message if we're idle. */ smp_block[id].data = -1; smp_block[id].input = 0; smp_block[id].output = SMP_DONE; break; } } }
int ee_init_data(void){ int i; u8 Tx[10]; int tmp; volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR; while(0){ tmp = 1-tmp; if(tmp) immap->im_ioport.iop_padat &= ~PA_FRONT_LED; else immap->im_ioport.iop_padat |= PA_FRONT_LED; udelay(1); } /* Set port to open drain to be able to read data from port without setting it to input */ PORT_B_PAR &= ~PB_EEPROM; PORT_B_ODR |= PB_EEPROM; SET_PORT_B_OUTPUT(PB_EEPROM); /* Set idle mode */ set_idle(); /* Copy all User EEPROM data to scratchpad */ for(i=0;i<USER_PAGES;i++){ Tx[0]=RECALL_MEMORY; Tx[1]=EE_USER_PAGE_0+i; if(ee_do_command(Tx,2,NULL,0,TRUE)) return(-EIO); } /* Make sure chip doesnt store measurements in NVRAM */ Tx[0]=WRITE_SCRATCHPAD; Tx[1]=0; /* Page */ Tx[2]=9; if(ee_do_command(Tx,3,NULL,0,TRUE)) return(-EIO); Tx[0]=COPY_SCRATCHPAD; if(ee_do_command(Tx,2,NULL,0,TRUE)) return(-EIO); /* FIXME check status bit instead Could take 10 ms to store in EEPROM */ for(i=0;i<10;i++){ udelay(1000); } return(0); }
//--------- Begin of function UnitB::next_move ---------// // // If there is unprocessed node(s) in the result_node_array, // then next unprocessed node will be set to be the next location // to move to. (i.e. go_? = location of the unprocessed node) // void UnitB::next_move() { if( cur_path == NULL || !cur_path_result_id ) return; //------------ all nodes are visited --------------// err_when(cur_x!=next_x || cur_y!=next_y); set_idle(); //---- order the unit to move to the next checkpoint following the path ----// PathResult* pathResult = cur_path + cur_path_result_id - 1; cur_path_result_id--; err_when( pathResult->loc_x == cur_x_loc() && pathResult->loc_y == cur_y_loc() ); sprite_move( pathResult->loc_x * LOCATE_WIDTH, pathResult->loc_y * LOCATE_HEIGHT ); err_when(cur_x==go_x && cur_y==go_y && (cur_x!=next_x || cur_y!=next_y)); }
static int do_reset(void){ /* Release reset and verify that chip responds with presence pulse */ int Retries = 0; while(Retries<5){ udelay(RESET_LOW_TIME); /* Send reset */ WRITE_PORT(0); udelay(RESET_LOW_TIME); /* Release reset */ WRITE_PORT(1); /* Wait for EEPROM to drive output */ udelay(PRESENCE_TIMEOUT); if(!READ_PORT){ /* Ok, EEPROM is driving a 0 */ E_DEBUG("Presence detected\n"); if(Retries){ E_DEBUG("Retries %d\n",Retries); } /* Make sure chip releases pin */ udelay(PRESENCE_LOW_TIME); return 0; } Retries++; } printk(KERN_ERR"EEPROM did not respond when releasing reset\n"); /* Make sure chip releases pin */ udelay(PRESENCE_LOW_TIME); /* Set to idle again */ set_idle(); return(-EIO); }
void main(TCommandLine cmd) { fshutdown=-1; agent_state = 3; vccID = cmd.argv(0); agentID = cmd.argv(1); passwd = cmd.argv(2); var TInteger FSM; FSM = getfsmid(); CorrelationKey = sprintf('%04d', FSM); print(sprintf('***The SL %s starts ,vccID:%s agentID:%s passwd:%s ***\n', CorrelationKey,vccID,agentID,passwd)); initialize_packet(); initial(); while(fshutdown==-1) { print(sprintf('***The SL %s is alive', CorrelationKey)); sleep(2); } on(serviceEvent, TCommandLine backevent) { print(sprintf('***The SL %s got message is %s***\n', CorrelationKey, backevent.argv())); var TString xmlstr = strstr(backevent.argv(),'<acp'); var TXMLTree root = hxmlparse(xmlstr); var TString type, name; type = hxmlgetattr(root, 'acpMessage/body/type' , 'null'); if(type!='null') { name = hxmlgetattr(root, 'acpMessage/body/name', 'null'); switch(type) { case 'response': if(name == 'Initial') { var TString ip = hxmlgetattr(root,'acpMessage/body/parameter/ip', 'null'); var TInteger port = atoi(hxmlgetattr(root,'acpMessage/body/parameter/port','0')); sign_in(ip, port); } else if(name == 'SignIn') { agent_state=2; timeStamp = hxml(root,'acpMessage/header/timeStamp', 'null'); send_state_msg(); set_idle(); } else if(name == 'SetIdle') { agent_state=0; var TString temp = hxmlgetattr(root, 'acpMessage/header/timeStamp', 'null'); if(timeStamp == '') { if(temp != 'null') timeStamp = temp; } send_state_msg(); } break; case 'event': if(name == 'OnAnswerRequest') answer_request(); else if(name == 'OnForceOut') { agent_state=3; send_state_msg(); force_out(); } else if(name == 'OnAnswerSuccess') answer_success(); break; default: print(sprintf('***The SL %s got unknown cmd***\n', CorrelationKey)); }