Пример #1
0
static void ble_evt_setup(void)
{
	/*set radio*/
	periph_radio_setup();
	
	periph_radio_shorts_set(	RADIO_SHORTS_END_DISABLE_Msk  
														| RADIO_SHORTS_READY_START_Msk
														| RADIO_SHORTS_DISABLED_RXEN_Msk
														);//
	//ppi
	//periph_ppi_set(1, &(NRF_TIMER0->TASKS_CAPTURE[0]), &(NRF_RADIO->EVENTS_DISABLED));
	periph_ppi_set(26, &(NRF_TIMER0->TASKS_CAPTURE[1]), &(NRF_RADIO->EVENTS_ADDRESS));
	periph_ppi_set(2, &(NRF_RADIO->TASKS_START), &(NRF_TIMER0->EVENTS_COMPARE[0]));
	//periph_ppi_set(3, &(NRF_RADIO->TASKS_DISABLE), &(NRF_TIMER0->EVENTS_COMPARE[1]));
	///timer0
	NRF_TIMER0->TASKS_CLEAR = 1;
	NRF_TIMER0->EVENTS_COMPARE[0] = 0;
	NRF_TIMER0->EVENTS_COMPARE[1] = 0;
	NRF_TIMER0->EVENTS_COMPARE[2] = 0;
	NRF_TIMER0->EVENTS_COMPARE[3] = 0;
	NRF_TIMER0->INTENSET = (1 << (TIMER_INTENSET_COMPARE0_Pos + 2));
	NRF_TIMER0->INTENSET = (1 << (TIMER_INTENSET_COMPARE0_Pos + 3));
	NVIC_EnableIRQ(TIMER0_IRQn);
	NRF_TIMER0->TASKS_START = 1;
	//| RADIO_SHORTS_DISABLED_TXEN_Msk
	/*set disable irq*/
	periph_radio_intenset(RADIO_INTENSET_DISABLED_Msk);
	periph_radio_intenset(RADIO_INTENSET_READY_Msk);
	periph_radio_intenset(RADIO_INTENSET_ADDRESS_Msk);
	periph_radio_intenset(RADIO_INTENSET_PAYLOAD_Msk);
	periph_radio_intenset(RADIO_INTENSET_END_Msk);
	
}	
/**
* Doing the setup actions before the first adv_send state actions
*/
static __INLINE void adv_evt_setup(void)
{
	periph_radio_setup();
	
	/* set channel to first in sequence */
	channel = 36; /* will be iterated by channel_iterate() */
	channel_iterate();
}