int main(void) { system_init(); //! [run_initialize_i2c] /* Configure device and enable. */ //! [config] configure_i2c(); //! [config] /* Configure callbacks and enable. */ //! [config_callback] configure_i2c_callbacks(); //! [config_callback] //! [run_initialize_i2c] /* Init i2c packet. */ //! [packet] packet.address = SLAVE_ADDRESS; packet.data_length = DATA_LENGTH; packet.data = buffer; //! [packet] /* Initiate first packet to be sent to slave. */ //! [write_packet] i2c_master_write_packet_job(&i2c_master_instance, &packet); //! [write_packet] //! [while] while (true) { /* Infinite loop */ } //! [while] }
int main (void) { system_init(); system_interrupt_enable_global(); /* Configure various sensors and their associated peripherals */ configure_i2c(); configure_mag_sw_int(extint_callback); configure_S70FL01(S70FL01_CS1, false); configure_SP1ML(); configure_ADXL375(); configure_sleepmode(); configure_rtc(); port_pin_set_output_level(SP1ML_EN_PIN,true); configure_ADT7420(); configure_databuffers(); // Assume that we are in active mode during stationary period ucActiveInactive_Mode = ACTIVE_MODE; ucMotion_State = STATIONARY_MODE; // Per Dr. Buck, 30C is the pivot point -- These don't necessarily have to be the same, they can build in some hysteresis depending upon the subject ucActivityTemperatureThreshold = 30; ucInactivityTemperatureThreshold = 30; while(true) { if((uiAccelerometerMatrixPtr > (300 - 32)) || (ucTemperatureArrayPtr > 71)){ // Accelerometer total buffer size minus the ADXL375 internal FIFO size // If either buffer is full enough that another set of samples cannot be stored, trigger an offload offload_data(); uiAccelerometerMatrixPtr = 0; ucTemperatureArrayPtr = 0; } // If we are at the end of the die, then switch die and reset the address pointer // If we hit the end of the second die, then we restart at the beginning of the first die (ring buffer) if(S70FL01_address >= S70FL01_MAX_ADDR){ S70FL01_active_die++; S70FL01_active_die %= 2; S70FL01_address = 0; } ADT7420_read_temp(); // Housekeeping done -- go back to sleep sleep(); } }