void SimpleShell::on_gcode_received(void *argument) { Gcode *gcode = static_cast<Gcode *>(argument); string args = get_arguments(gcode->get_command()); if (gcode->has_m) { if (gcode->m == 20) { // list sd card gcode->stream->printf("Begin file list\r\n"); ls_command("/sd", gcode->stream); gcode->stream->printf("End file list\r\n"); } else if (gcode->m == 30) { // remove file rm_command("/sd/" + args, gcode->stream); } else if(gcode->m == 501) { // load config override if(args.empty()) { load_command("/sd/config-override", gcode->stream); } else { load_command("/sd/config-override." + args, gcode->stream); } } else if(gcode->m == 504) { // save to specific config override file if(args.empty()) { save_command("/sd/config-override", gcode->stream); } else { save_command("/sd/config-override." + args, gcode->stream); } } } }
void write_fuse(uint8_t efuse, uint16_t fuse_word) { load_command(appc_write_fuse_bits); load_data_low_byte(fuse_word & 0xFF); set_byte_low(); reset_bs2(); wrb_pulse(); while (poll_busy()) ; load_data_low_byte(fuse_word >> 8); set_byte_high(); reset_bs2(); wrb_pulse(); while (poll_busy()) ; set_byte_low(); load_data_low_byte(efuse); set_byte_low(); set_bs2(); wrb_pulse(); while (poll_busy()) ; reset_bs2(); }
void erase_chip(void) { load_command(appc_chip_erase); wrb_pulse(); while (poll_busy()) ; }
//----------------------------------------------------------------------- // write_ADNS2051() //----------------------------------------------------------------------- // void write_ADNS2051(int address, int data) { // Load register address load_command(WRITE | address); load_data(data); }
void read_lock(uint8_t *lock) { load_command(appc_read_fuse_n_lock_bits); output_enable(); reset_bs2(); set_byte_high(); *lock = data_in(); output_disable(); }
void write_lock(uint8_t lock) { load_command(appc_write_lock_bits); load_data_low_byte(lock); set_byte_low(); reset_bs2(); wrb_pulse(); while (poll_busy()) ; }
void read_cali(uint8_t *cali) { load_command(appc_read_sig_bytes_n_cali_byte); load_address_low_byte(0); output_enable(); set_byte_high(); *cali = data_in(); output_disable(); }
//----------------------------------------------------------------------- // read_ADNS2051() //----------------------------------------------------------------------- // int read_ADNS2051(int address) { int data; // Load register address load_command(address); data = read_data(); return data; }
uint8_t read_eeprom(uint16_t addr) { uint8_t data; load_command(appc_read_eeprom); load_address_high_byte(addr >> 8); load_address_low_byte(addr & 0xFF); output_enable(); set_byte_low(); data = data_in(); output_disable(); return data; }
int main(int argc,char **argv) { FILE *fp; char ch; enum request request; request = REQ_VIEW_MAIN; fp = fopen("config","r+"); if(fp == NULL) T_ERR("cannot read the file config!\nplease checkout the file is exist\n"); argvs = argv; load_command(fp); fclose(fp); convert_command(); command_type = parser_option(argc, argv); if(command_type == -1) exit(1); g_current = 0; g_change = 0; #if CURSES_MOD == 1 Init_Screen(); mvwaddstr(stdscr,LINES/2,COLS/2,"Loading......"); #endif #if CURSES_MOD == 1 while(view_control(request)) { ch = wgetch(status_win); request = get_request(ch); } #endif #if CURSES_MOD == 1 getch(); #endif #if CURSES_MOD == 1 quit(0); #endif return 0; }
void read_fuse(uint8_t *efuse, uint8_t *hfuse, uint8_t *lfuse) { load_command(appc_read_fuse_n_lock_bits); output_enable(); reset_bs2(); set_byte_low(); *lfuse = data_in(); set_bs2(); set_byte_high(); *hfuse = data_in(); set_bs2(); set_byte_low(); *efuse = data_in(); output_disable(); }
void exec_command(regcontext_t *REGS, int run, int fd, char *cmd_name, u_short *param) { char *arg; char *env; char *argv[2]; char *envs[100]; env = (char *)MAKEPTR(param[0], 0); arg = (char *)MAKEPTR(param[2], param[1]); if (arg) { int nbytes = *arg++; arg[nbytes] = 0; if (!*arg) arg = NULL; } argv[0] = arg; argv[1] = NULL; debug (D_EXEC, "exec_command: cmd_name = %s\n" "env = 0x0%x, arg = %04x:%04x(%s)\n", cmd_name, param[0], param[2], param[1], arg); if (env) { int i; for ( i=0; i < 99 && *env; ++i ) { envs[i] = env; env += strlen(env)+1; } envs[i] = NULL; load_command(REGS, run, fd, cmd_name, param, argv, envs); } else load_command(REGS, run, fd, cmd_name, param, argv, NULL); }
uint16_t read_pgm_mem_word(uint16_t waddr) { uint16_t word; load_command(appc_read_flash); load_address_high_byte(waddr >> 8); load_address_low_byte(waddr & 0xFF); output_enable(); set_byte_low(); word = data_in(); set_byte_high(); word |= data_in() << 8; output_disable(); return word; }
void read_sign(uint8_t *msb, uint8_t *csb, uint8_t *lsb) { load_command(appc_read_sig_bytes_n_cali_byte); //load_address_high_byte(0); // TODO load_address_low_byte(0); output_enable(); set_byte_low(); *msb = data_in(); output_disable(); load_address_low_byte(1); output_enable(); set_byte_low(); *csb = data_in(); output_disable(); load_address_low_byte(2); output_enable(); set_byte_low(); *lsb = data_in(); output_disable(); }
void initiate_eep_mem_write(void) { load_command(appc_write_eeprom); }
static int __devinit touch_tool_probe( struct platform_device *pdev ) { struct synaptics_rmi4_data *rmi_data = ( struct synaptics_rmi4_data* )pdev->dev.platform_data; struct touch_tool_data *tool_data; if( !rmi_data ) { printk( "TTUCH : The pointer of RMI data is NULL\n" ); return -ENOMEM; } if( !( tool_data = allocate_memory() ) ) { printk( "TTUCH : allocate Memory failed\n" ); return -ENOMEM; } if( !create_command_string_list( &tool_data->string ) ) { printk( "TTUCH : Create command failed\n" ); release_memory( tool_data ); return -EINVAL; } tool_data->rmi_data = rmi_data; if( load_command( &tool_data->command, get_load_command_pointer(), get_load_command_counter() ) ) { struct control_node_load file_node; // Create file node in sys/class/touch/rmi4 file_node.class_name = "touch", file_node.device_name = "rmi4"; file_node.file_node_data = tool_data, file_node.control_read = tool_command, file_node.control_write = tool_control, file_node.info_read = tool_info; tool_data->file_node_class = control_file_node_register( &file_node ); dev_set_drvdata( &pdev->dev, tool_data ); info_print( INFO_BUFFER_INIT, NULL, tool_data->info_buffer, INFO_BUFFER_SIZE ); INIT_LIST_HEAD( &tool_data->descriptor_list ); get_page_description( tool_data ); get_touch_ic_info( tool_data, log_print ); printk( "TTUCH : Touch tool driver is ready\n" ); return 0; } release_memory( tool_data ); return -EINVAL; }