void *malloc( size_t xSize ) { /* There should not be a heap defined, so trap any attempts to call malloc. */ Interrupt_disableMaster(); for( ;; ); }
bool PCM_gotoLPM3InterruptSafe(void) { bool lpmHappenedCorrect; /* Disabling master interrupts. In Cortex M, if an interrupt is enabled but master interrupts are disabled and a WFI happens the WFI will immediately exit. */ Interrupt_disableMaster(); lpmHappenedCorrect = PCM_gotoLPM3(); /* Enabling and Disabling Interrupts very quickly so that the processor catches any pending interrupts */ Interrupt_enableMaster(); Interrupt_disableMaster(); return lpmHappenedCorrect; }
//------------------------------------------------------------------------------ // Send colors to the strip and show them. Disables interrupts while processing. void showStrip() { // __bic_SR_register(GIE); // disable interrupts Interrupt_disableMaster(); // send RGB color for every LED int i, j; for (i = 0; i < NUM_LEDS; i++){ u_char rgb[4] = {leds[i].green, leds[i].red, leds[i].blue, leds[i].white}; // get RGB color for this LED // send green, then red, then blue, then white for (j = 0; j < 4; j++){ u_char mask = 0x80; // b1000000 // check each of the 8 bits while(mask != 0){ while ((UCB1IFG&0x0002)==0x0000); // wait until empty to transmit if (rgb[j] & mask) { // most significant bit first // SPI_transmitData(EUSCI_B1_MODULE, HIGH_CODE); UCB1TXBUF = HIGH_CODE; // send 1 } else { // SPI_transmitData(EUSCI_B1_MODULE, LOW_CODE); UCB1TXBUF = LOW_CODE; // send 0 } mask >>= 1; // check next bit } } } // send RES code for at least 50 us _delay_cycles(800); // __bis_SR_register(GIE); // enable interrupts Interrupt_enableMaster(); }