void dccthread_yield(void) { if(is_it_manager_running) return; is_it_manager_running=1; blockInterrupts(); int old_index = send_to_the_end(); #ifdef DEBUG printf("Swapping %d -> Manager\n", thread_ready_queue[old_index]->id); #endif swapcontext(&(thread_ready_queue[old_index]->context), &manager); }
/// @details /// This call provides direct access to the RFM12B registers. If you're careful /// to avoid configuring the wireless module in a way which stops the driver /// from functioning, this can be used to adjust some settings. /// See the RFM12B wireless module documentation. static uint16_t rf12_xfer (uint16_t cmd) { blockInterrupts(); // writing can take place at full speed, even 8 MHz works bitClear(SS_PORT, cs_pin); uint16_t res = rf12_byte(cmd >> 8) << 8; res |= rf12_byte(cmd); bitSet(SS_PORT, cs_pin); allowInterrupts(); return res; }
/// @details /// Requests RFM12 state from RF module and reads back a waiting data byte if there is /// any. /// One of two commands accessing SPI, so interrupts disabled in here /// @param *data Pointer to byte where to write the received data to (if any) static uint16_t rf12_xferState (uint8_t *data) { blockInterrupts(); // writing can take place at full speed, even 8 MHz works bitClear(SS_PORT, cs_pin); uint16_t res = rf12_byte(0x00) << 8; res |= rf12_byte(0x00); if (res & RF_FIFO_BIT && rxstate == TXRECV) { // slow down to under 2.5 MHz #if F_CPU > 10000000 bitSet(SPCR, SPR0); #endif *data = rf12_byte(0x00); #if F_CPU > 10000000 bitClear(SPCR, SPR0); #endif } bitSet(SS_PORT, cs_pin); allowInterrupts(); return res; }