int in_main() { if ((!in_low_int()) && (!in_high_int())) { return (1); } else { return (0); } }
void SleepIfOkay() { // we won't sleep if the main isn't willing to block if (MQ_Main_Willing_to_block == 0) { return; } // check to see if we are handling a low priority interrupt // if so, we are not going to sleep if (in_low_int()) { return; } // we know that we are in a high priority interrupt handler // but we'll check to make sure and return if we are not if (!in_high_int()) { return; } // since we are the only thing executing that could be // putting something into a message queue destined for main() // we can safely check the message queues now // if they are empty, we'll go to sleep if (check_msg(&ToMainHigh_MQ)) { return; } if (check_msg(&ToMainLow_MQ)) { return; } enter_sleep_mode(); }
signed char FromMainLow_recvmsg(unsigned char maxlength, unsigned char *msgtype, void *data) { #ifdef DEBUG if (!in_low_int()) { return (MSG_NOT_IN_LOW); } #endif return (recv_msg(&FromMainLow_MQ, maxlength, msgtype, data)); }
signed char ToMainLow_sendmsg(unsigned char length, unsigned char msgtype, void *data) { #ifdef DEBUG if (!in_low_int()) { return (MSG_NOT_IN_LOW); } #endif return (send_msg(&ToMainLow_MQ, length, msgtype, data)); }