int main( void ) { halInit(); moduleInit(); HAL_DISABLE_INTERRUPTS(); printf("\r\n****************************************************\r\n"); printf("Simple Application Example - END DEVICE\r\n"); uint16_t vlo = calibrateVlo(); printf("VLO = %u Hz\r\n", vlo); timerIsr = &handleTimer; clearLeds(); HAL_ENABLE_INTERRUPTS(); /* Most of the of infoMessage are the same, so we can create most of the message ahead of time. */ hdr.sequence = 0; //this will be incremented each message hdr.version = INFO_MESSAGE_VERSION; hdr.flags = INFO_MESSAGE_FLAGS_NONE; initializeSensors(); delayMs(100); stateMachine(); }
int main( void ) { halInit(); HAL_DISABLE_INTERRUPTS(); printf("\r\n****************************************************\r\n"); printf("Simple Application Example - END DEVICE - using AFZDO\r\n"); #ifdef SEND_MESSAGE_ON_TIMER unsigned int vlo = calibrateVlo(); printf("VLO = %u Hz\r\n", vlo); timerIsr = &handleTimer; printf("Send message on timer enabled.\r\n"); #endif #ifdef SEND_MESSAGE_ON_MOTION printf("Send message on motion enabled.\r\n"); halSpiInitAccelerometer(); //note: this puts the SPI port in a non-ZNP configuration; must init it for ZNP afterwards writeAccelerometerRegister(ACCEL_CTRL, G_RANGE_2 | I2C_DIS | MODE_MD_10 | MDET_NO_EXIT); // Configure Accelerometer delayUs(ACCELEROMETER_DELAY_BETWEEN_OPERATIONS_US); // 11 bit-time delay required when using SPI readAccelerometerRegister(ACCEL_INT_STATUS); // clear the interrupt accelerometerIsr = &handleAccelerometer; halEnableAccelerometerInterrupt(WAKEUP_AFTER_ACCELEROMETER); #endif HAL_ENABLE_INTERRUPTS(); //create the infoMessage. Most of these fields are the same, so we can create most of the message ahead of time. hdr.sequence = 0; //this will be incremented each message hdr.version = INFO_MESSAGE_VERSION; hdr.flags = INFO_MESSAGE_FLAGS_NONE; im.header = &hdr; //Note, if you have multiple similar message types then you can use the same header for all im.deviceType = DEVICETYPE_SMITH_ELECTRONCS_ROUTER_DEMO; im.deviceSubType = DEVICESUBTYPE_SMITH_ELECTRONCS_ROUTER_DEMO; im.numParameters = 3; //run the state machine stateMachine(); }