int main () { v2x_board_init(); //configure pins and initial safe condition while (1){ sleepmgr_enter_sleep(); //go to sleep until interrupt charge_pump_toggle(); //charge pump pin needs toggled to create boost voltage for LEDs reset_processor(); //look for pending resets button_service(); //SCAN and report the button charge_pump_toggle(); //charge pump pin needs toggled to create boost voltage for LEDs job_coordinator(); //schedule new jobs if needed GSM_process_buffer(); //handle any pending jobs for GSM CAN_process_buffer(); //handle any pending jobs for CAN charge_pump_toggle(); //charge pump pin needs toggled to create boost voltage for LEDs if (usb_cdc_is_active(USB_ACL)) //if host listening, {report_accel_data();} //create and send accel data charge_pump_toggle(); //charge pump pin needs toggled to create boost voltage for LEDs } }
static int es705_sensor_hub_handle_data(struct es705_priv *es705) { static u32 buffer[ES705_SENSOR_HUB_BLOCK_MAX/sizeof(u32)]; u32 cmd; u32 resp; int ret; unsigned size; unsigned rdcnt; struct sensor_sample *pSensData[3]; struct spi_data *spiData = es705->sensData; static u32 counter; /* Note: mutex_lock is done by calling function (IRQ worker) */ /* Read sensor hub data block request. */ cmd = cpu_to_le32(SENS_HUB_RDB); ret = es705->dev_write(es705, (char *)&cmd, 4); if (ret < 0) { dev_err(es705->dev, "[SPI]: error sending write request = %d\n", ret); goto OUT; } usleep_range(3000, 4000); /* Wait for response */ ret = es705->dev_read(es705, (char *)&resp, 4); if (ret < 0) { dev_err(es705->dev, "[SPI]: error sending read request = %d\n", ret); goto OUT; } le32_to_cpus(resp); size = resp & 0xffff; /* pr_info("[SPI]: 2.Resp: %08X\n", resp); */ if ((resp & 0xffff0000) != 0x802E0000) { dev_dbg(es705->dev, "[SPI]: invalid read sensor data block response = 0x%08x\n", resp); goto OUT; } BUG_ON(size == 0); BUG_ON(size > ES705_SENSOR_HUB_BLOCK_MAX); BUG_ON(size % 4 != 0); /* This assumes we need to transfer the block in 4 byte * increments. This is true on slimbus, but may not hold true * for other buses. */ for (rdcnt = 0; rdcnt < size; rdcnt += 4) { ret = es705->dev_read(es705, (char *)&resp, 4); if (ret < 0) { dev_dbg(es705->dev, "[SPI]: error reading data block at %d bytes\n", rdcnt); goto OUT; } buffer[rdcnt/4] = resp; } /* Parse Sensor Data and publish to respective device nodes */ pSensData[0] = (struct sensor_sample *)buffer; report_accel_data(spiData, pSensData[0]); if ((counter % 50) == 0) { pr_debug("[SPI]: Sensor Data: %d:\t%d\t%d\t%d\t%d", pSensData[0]->id, pSensData[0]->x, pSensData[0]->y, pSensData[0]->z, pSensData[0]->timeStamp); } pSensData[1] = (struct sensor_sample *)&buffer[ sizeof(struct sensor_sample)/sizeof(u32)]; report_gyro_data(spiData, pSensData[1]); if ((counter % 50) == 0) { pr_debug("[SPI]: Sensor Data: %d:\t%d\t%d\t%d\t%d", pSensData[1]->id, pSensData[1]->x, pSensData[1]->y, pSensData[1]->z, pSensData[1]->timeStamp); } pSensData[2] = (struct sensor_sample *)&buffer[ 2*sizeof(struct sensor_sample)/sizeof(u32)]; report_mag_data(spiData, pSensData[2]); if ((counter % 50) == 0) { pr_debug("[SPI]: Sensor Data: %d:\t%d\t%d\t%d\t%d", pSensData[2]->id, pSensData[2]->x, pSensData[2]->y, pSensData[2]->z, pSensData[2]->timeStamp); } counter++; OUT: /* Note: mutex_unlock is done by calling function (IRQ worker) */ if (ret) dev_err(es705->dev, "sens read data block failure=%d\n", ret); return ret; }