static void EnterShippingMode(void) { /* Turn off the watchdog timer */ WDTCTL = WDTPW + WDTHOLD; #ifdef DIGITAL ClearLcd(); #endif ConfigResetPin(RST_PIN_ENABLED); __delay_cycles(100000); __disable_interrupt(); __no_operation(); DisableRtosTick(); /* * the radio draws more current in reset than it does after * the patch is loaded */ DISABLE_DISPLAY_POWER(); DISABLE_LCD_ENABLE(); BATTERY_CHARGE_DISABLE(); LIGHT_SENSOR_SHUTDOWN(); BATTERY_SENSE_DISABLE(); HARDWARE_CFG_SENSE_DISABLE(); APPLE_POWER_DISABLE(); ACCELEROMETER_INT_DISABLE(); DISABLE_BUTTONS(); #ifdef DIGITAL /* SHIPPING */ ENABLE_SHIPPING_WAKEUP(); #endif SELECT_ACLK(SELA__REFOCLK); SELECT_FLLREF(SELREF__REFOCLK); UCSCTL8 &= ~SMCLKREQEN; UCSCTL6 |= SMCLKOFF; /* disable aclk */ P11SEL &= ~BIT0; XT1_Stop(); /* turn off the regulator */ PMMCTL0_H = PMMPW_H; PMMCTL0_L = PMMREGOFF; __low_power_mode_4(); __no_operation(); __no_operation(); /* should not get here without a power event */ SoftwareReset(); }
/* * The interrupt can either send a message to the host or * it can send data (send a message that causes the task to read data from * part and then send it to the host). */ void AccelerometerPinIsr(void) { #if 0 /* disabling the interrupt is the easiest way to make sure that * the stack does not get blasted with * data when it is in sleep mode */ ACCELEROMETER_INT_DISABLE(); #endif /* can't allocate buffer here so we must go to task to send interrupt * occurred message */ tMessage Msg; SetupMessage(&Msg, AccelMsg, MSG_OPT_ACCEL_DATA); SendMessageToQueueFromIsr(DISPLAY_QINDEX, &Msg); }
static void EnterShippingMode(void) { /* Turn off the watchdog timer */ WDTCTL = WDTPW | WDTHOLD; EnableRstPin(); __delay_cycles(100000); __disable_interrupt(); __no_operation(); /* * the radio draws more current in reset than it does after * the patch is loaded */ DISABLE_DISPLAY_POWER(); DISABLE_LCD_ENABLE(); BATTERY_CHARGE_DISABLE(); LIGHT_SENSOR_SHUTDOWN(); BATTERY_SENSE_DISABLE(); HARDWARE_CFG_SENSE_DISABLE(); APPLE_POWER_DISABLE(); ACCELEROMETER_INT_DISABLE(); DISABLE_BUTTONS(); SELECT_ACLK(SELA__REFOCLK); SELECT_FLLREF(SELREF__REFOCLK); UCSCTL8 &= ~SMCLKREQEN; UCSCTL6 |= SMCLKOFF; /* disable aclk */ P11SEL &= ~BIT0; XT1_Stop(); /* turn off the regulator */ unsigned char temp = PMMCTL0_L; PMMCTL0_H = PMMPW_H; PMMCTL0_L = PMMREGOFF | temp; LPM4; __no_operation(); __no_operation(); /* should not get here without a power event */ SoftwareReset(); }
static void DisableAccelerometer(void) { /* put into low power mode */ ACCELEROMETER_INT_DISABLE(); ENTER_STANDBY_MODE(); }
void HandleAccelerometer(tMessage *pMsg) { if (Control == INIT_MODE) InitAccelerometer(); switch (pMsg->Options) { case MSG_OPT_ACCEL_DATA: if (Connected(CONN_TYPE_SPP) && QuerySniffState() == Active #if SUPPORT_BLE || Connected(CONN_TYPE_BLE) && CurrentInterval(INTERVAL_STATE) == SHORT #endif ) AccelerometerSendDataHandler(); break; case MSG_OPT_ACCEL_ENABLE: if (Connected(CONN_TYPE_BLE)) SendMessage(UpdConnParamMsg, SHORT); else if (Connected(CONN_TYPE_SPP)) SendMessage(SniffControlMsg, MSG_OPT_EXIT_SNIFF); if (pMsg->Length) { ENTER_STANDBY_MODE(); Control &= ~ACCEL_RANGE_MASK; Control |= (*pMsg->pBuffer & 0x03) << ACCEL_RANGE_SHFT; AccelerometerWrite(KIONIX_CTRL_REG1, &Control, ONE_BYTE); } /* enable accelerometer */ ENTER_OPERATING_MODE(); ACCELEROMETER_INT_ENABLE(); break; case MSG_OPT_ACCEL_DISABLE: /* put into low power mode */ ACCELEROMETER_INT_DISABLE(); ENTER_STANDBY_MODE(); if (Connected(CONN_TYPE_BLE)) SendMessage(UpdConnParamMsg, LONG); break; case MSG_OPT_ACCEL_STREAMING: ENTER_STANDBY_MODE(); Control &= ~WUF_ENABLE; Control |= DRDYE_DATA_AVAILABLE; AccelerometerWrite(KIONIX_CTRL_REG1, &Control, ONE_BYTE); ENTER_OPERATING_MODE(); break; case MSG_OPT_ACCEL_WUF: ENTER_STANDBY_MODE(); if (pMsg->Length) AccelerometerWrite(KIONIX_WUF_THRESH, pMsg->pBuffer, ONE_BYTE); Control &= ~DRDYE_DATA_AVAILABLE; Control |= WUF_ENABLE; AccelerometerWrite(KIONIX_CTRL_REG1, &Control, ONE_BYTE); ENTER_OPERATING_MODE(); break; default: break; } }