Esempio n. 1
0
extern "C" void EINT3_IRQHandler(void)
{
    uint8_t flags;
	
		//LPC_GPIO1->FIOPIN ^= 1<<31;

    
    LPC_GPIOINT->IO2IntClr |= (1 << 4);     // Clear mbed interrupt flag
    
    flags = mrf_read_short(INTSTAT);        // Read radio interrupt flags
	
		if(flags & 0x01) {
        tx_status_ready = 1;
    }
    if(flags & 0x08) {
			
				//nrk_led_toggle(GREEN_LED);
        rf_parse_rx_packet();
        rfSettings.pRxInfo = rf_rx_callback(rfSettings.pRxInfo);
    }
}
Esempio n. 2
0
uint8_t polling_TBR( uint16_t time_to_wait, uint8_t condition)
{
	//Check if the waiting time is not extended too much by interrupts 
	if (time_to_wait > tools_TBR_vote())
	{
		if ( (time_to_wait - tools_TBR_vote()) > 500)
		{
			return TOO_LATE;
		}
	}
	else
	{
		if ((time_to_wait + (TBCCR0 - tools_TBR_vote()) ) > 500)
		{
			return TOO_LATE;
		}
	}
	
	switch(condition)
	{
		case PULL_24_RX_BUF:
		case NO_CONDITION:	  
			// if TBR and time_to_wait are not on the same slope of the timer, TBR has to count till TBCCR0.
			if (tools_TBR_vote() > time_to_wait)
			{  
				while (tools_TBR_vote() > time_to_wait)
				{
					if((tools_TBR_vote() > time_to_wait) && (tools_TBR_vote() - time_to_wait > 500))
					{clock_pause_us(10);}
					else // An interrupt has occured during polling. Transmission time has passed! 
					{
						if ((tools_TBR_vote() > time_to_wait) && ( tools_TBR_vote() - time_to_wait < 7))
						{/* it is almost on the date time */ return DELAYED_TX;} 
						else
						{return TOO_LATE;}   
					}  
				}
				if (condition == PULL_24_RX_BUF) {if(rf_rx_callback(0)==pdTRUE){/* debug("msg\r\n"); */};}
			}  
			while (tools_TBR_vote() < time_to_wait)
			{
				if (tools_TBR_vote() < time_to_wait )
				{ 
					if (time_to_wait - tools_TBR_vote() < 500)
					{clock_pause_us(10);}
					else  // An interrupt has passed TBR from TBCCR0 
					{return TOO_LATE;}  
				}
				else  // An interrupt has occured during the polling. Transmission time has passed! 
				{  
					if ( tools_TBR_vote() - time_to_wait < 7)
					{return DELAYED_TX;} 
					else 
					{return TOO_LATE;} 
				}
				if (condition == PULL_24_RX_BUF) {if(rf_rx_callback(0)==pdTRUE){/* debug("msg\r\n"); */};}
			}	
		break;

		default:
		  break;
	  
	}
	return POLL_OK;
}