int svc_send_calibration_cmd_to_core(ss_sensor_calibration_req_t *req) { struct ia_cmd *cmd = NULL; uint8_t sensor_type = GET_SENSOR_TYPE(req->sensor); uint8_t sensor_id = GET_SENSOR_ID(req->sensor); uint16_t length = sizeof(struct ia_cmd)+sizeof(struct calibration)+req->data_length; cmd = (struct ia_cmd*)balloc(length,NULL); struct calibration *ia_param = (struct calibration*)cmd->param; ia_param->sensor.sensor_type = sensor_type; ia_param->sensor.dev_id = sensor_id; ia_param->calibration_type= req->calibration_type; ia_param->clb_cmd= req->clb_cmd; cmd->cmd_id = CMD_CALIBRATION; if((req->clb_cmd) == SET_CALIBRATION_CMD || (req->clb_cmd == REBOOT_AUTO_CALIBRATION_CMD)){ ia_param->data_length = req->data_length; memcpy(ia_param->calib_params, req->value, ia_param->data_length); /*write the clb data to falsh*/ if(ia_param->clb_cmd == SET_CALIBRATION_CMD) sensor_clb_write_flash(sensor_type, sensor_id, ia_param->calib_params, ia_param->data_length); }else{ ia_param->data_length = 0; } return ipc_2core_send(cmd); }
int SendCmd2OpenCore(int cmd_id) { int length = sizeof(struct ia_cmd); struct ia_cmd *cmd = (struct ia_cmd *)balloc(length, NULL); if (cmd == NULL) return -1; memset(cmd, 0, length); cmd->cmd_id = cmd_id; ipc_2core_send(cmd); return 0; }
int send_request_cmd_to_core(uint8_t tran_id, uint8_t sensor_id, uint32_t param1, uint32_t param2, uint8_t* addr, uint8_t cmd_id) { struct ia_cmd *cmd = NULL; uint16_t length; switch( cmd_id ){ case CMD_GET_SENSOR_LIST:{ length = sizeof(struct ia_cmd)+sizeof(struct sensor_type_bit_map); cmd = (struct ia_cmd*)balloc(length,NULL); struct sensor_type_bit_map *bitmap= (struct sensor_type_bit_map *)cmd->param; bitmap->bit_map = param1; SS_PRINT_LOG("CMD_GET_SENSOR_LIST:bit_map=%d",param1); break; }case CMD_START_SENSOR: case CMD_STOP_SENSOR:{ length = sizeof(struct ia_cmd)+sizeof(struct sensor_id); cmd = (struct ia_cmd*)balloc(length,NULL); struct sensor_id *sensor = (struct sensor_id*)cmd->param; sensor->sensor_type = tran_id; sensor->dev_id = sensor_id; break; }case CMD_SUBSCRIBE_SENSOR_DATA:{ length = sizeof(struct ia_cmd)+sizeof(struct subscription); cmd = (struct ia_cmd*)balloc(length,NULL); struct subscription *ia_param = (struct subscription*)cmd->param; ia_param->sensor.sensor_type = tran_id; ia_param->sensor.dev_id = sensor_id; ia_param->sampling_interval = param1; ia_param->reporting_interval= param2; break; }case CMD_UNSUBSCRIBE_SENSOR_DATA:{ length = sizeof(struct ia_cmd)+sizeof(struct unsubscription); cmd = (struct ia_cmd*)balloc(length,NULL); struct unsubscription *ia_param = (struct unsubscription*)cmd->param; ia_param->sensor.sensor_type = tran_id; ia_param->sensor.dev_id = sensor_id; break; }case CMD_GET_PROPERTY:{ length = sizeof(struct ia_cmd)+sizeof(struct get_property); cmd = (struct ia_cmd*)balloc(length,NULL); struct get_property *ia_param = (struct get_property*)cmd->param; ia_param->sensor.sensor_type = tran_id; ia_param->sensor.dev_id = sensor_id; break; }case CMD_SET_PROPERTY:{ length = sizeof(struct ia_cmd)+sizeof(struct set_property)+param2; cmd = (struct ia_cmd*)balloc(length,NULL); struct set_property *ia_param = (struct set_property *)cmd->param; ia_param->sensor.sensor_type = tran_id; ia_param->sensor.dev_id = sensor_id; ia_param->length= param2; memcpy(ia_param->property_params, addr, param2); break; }case CMD_DEBUG:{ SS_PRINT_LOG("Returning as command debug sent\n"); return IPC_STS_ERR_EMPTY; }default:{ length = sizeof(struct ia_cmd); cmd = (struct ia_cmd*)balloc(length,NULL); } } cmd->length = length; cmd->cmd_id = cmd_id; return ipc_2core_send(cmd); }