void rf_process() { struct rf_cmd cmd; UINT32 val32; UINT8 devId, hostId; INT8 ret; if(32 != rcvCmd(&cmd)){ return; } switch(cmd.cmd){ case KFISH_CMD_DISCOVER: if(rf_mode_get() != SLAVE_MODE_WAIT_DISCOVER) break; memcpy(&val32, cmd.data, sizeof(UINT32)); if(val32 == 0xffffffff){ DBG_PRINT("devId full\n"); rf_mode_set(SLAVE_MODE_WAIT_DISCOVER); return; } for(devId = 0; devId < 0x20; devId++){ if(((val32 >> devId) & 1) == 0) break; } /* printk("rcv discover from 0x%x->%x \n", cmd.srcId, cmd.destId); */ /* printk("try devid 0x%x plane %d mode %d\n", devId, cmd.rfPlane, rf_mode_get()); */ /* printk("list 0x%lx\n", val32); */ rf_config(cmd.srcId, devId); cmd.cmd = KFISH_CMD_DISCOVER_ACK; val32 = val32 | (1 << devId); memcpy(cmd.data, &val32, sizeof(UINT32)); sndCmd(&cmd); rf_mode_set(SLAVE_MODE_DISCOVER_GET); break; case KFISH_CMD_DEVCONFIRM: /* 4Byte dev status, 1B controlNum */ if(rf_mode_get() != SLAVE_MODE_DISCOVER_GET) break; hostId = cmd.srcId; devId = cmd.destId; memcpy(&val32, cmd.data, sizeof(UINT32)); val32 |= (1 << devId); memcpy(cmd.data, &val32, sizeof(UINT32)); cmd.data[4] = __local_ctrl_num; /* control number */ cmd.cmd = KFISH_CMD_DEVCONFIRM_ACK; rf_mode_set(SLAVE_MODE_NORMAL); sndCmd(&cmd); printk("confirmed, use devId 0x%x\n", devId); if(hostId != EEPROM_get(EEPROM_OFS_HOSTID)){ EEPROM_put(EEPROM_OFS_HOSTID, hostId); } if(devId != EEPROM_get(EEPROM_OFS_DEVID)){ EEPROM_put(EEPROM_OFS_RFPLANE, devId); } if(0xa9 != EEPROM_get(EEPROM_OFS_RFAVAIL)){ EEPROM_put(EEPROM_OFS_RFAVAIL, 0xa9); } break; default: ret = uartCmdLocalProcess(&cmd); if(CMD_PROCESS_ACK == ret){ DBG_PRINT("<cmd 0x%x ctrl:%d data:%x %x %x\n", cmd.cmd, cmd.ctrlId, cmd.data[0], cmd.data[1], cmd.data[2] ); sndCmd(&cmd); /* 合法命令,发送应答 */ DBG_PRINT(">cmd 0x%x ctrl %d %x %x %x\n", cmd.cmd, cmd.ctrlId, cmd.data[0], cmd.data[1], cmd.data[2] ); }else if(CMD_PROCESS_NO_ACK == ret){ /* 合法命令,但是不用应答 */ }else{ /* 不合法的命令 */ DBG_PRINT("illegal command\n"); DBG_PRINT("\tcmd 0x%x ctrlId %d", cmd.cmd, cmd.ctrlId); } break; } }
void cam_rh2v2_cordlg::on_pbCmd_clicked(bool checked) { emit sndCmd(0xF111); }