static void rtc_handler(nrf_drv_rtc_int_type_t int_type)
{
    uint32_t err_code;
	
    if (int_type == NRF_DRV_RTC_INT_COMPARE0)
    {
        nrf_drv_saadc_sample();                                        //Trigger the SAADC SAMPLE task
			
        LEDS_INVERT(BSP_LED_0_MASK);                                   //Toggle LED1 to indicate SAADC sampling start
			
        err_code = nrf_drv_rtc_cc_set(&rtc,0,RTC_CC_VALUE,true);       //Set RTC compare value. This needs to be done every time as the nrf_drv_rtc clears the compare register on every compare match
        APP_ERROR_CHECK(err_code);
        nrf_drv_rtc_counter_clear(&rtc);                               //Clear the RTC counter to start count from zero
    }
}
Example #2
0
static void rtc1_handler(nrf_drv_rtc_int_type_t int_type) {
//    uint32_t err_code;

    if (int_type == NRF_DRV_RTC_INT_COMPARE0) {   // Interrupt from COMPARE0 event.
        nrf_gpio_pin_set(led_pin1);
        nrf_drv_rtc_int_enable(&rtc1, RTC_CHANNEL_INT_MASK(0));
    } else if (int_type == NRF_DRV_RTC_INT_COMPARE1) {   // Interrupt from COMPARE1 event.
        nrf_gpio_pin_clear(led_pin1);
        nrf_drv_rtc_int_enable(&rtc1, RTC_CHANNEL_INT_MASK(1));
    } else if (int_type == NRF_DRV_RTC_INT_COMPARE2) {   // Interrupt from COMPARE2 event.
        nrf_drv_rtc_counter_clear(&rtc1);
        nrf_drv_rtc_int_enable(&rtc1, RTC_CHANNEL_INT_MASK(2));
    } else if (int_type == NRF_DRV_RTC_INT_TICK) {       // Tick off
        nrf_gpio_pin_toggle(led_pin1);
    }
}
Example #3
0
static void rtc1_handler(nrf_drv_rtc_int_type_t int_type) {
//    uint32_t err_code;

    NRF_LOG_DEBUG("rtc1_handler %d %u\n\r",int_type,pos);
    if (int_type == NRF_DRV_RTC_INT_COMPARE0) {   // Interrupt from COMPARE0 event.
    	uint16_t temp;
        nrf_gpio_pin_toggle(led_pin1);
        if (pos%2==0) {
        	max6675_prepare(&max6675_config);
        } else {
        	temp=max6675_readcelsius(&max6675_config);
            NRF_LOG_INFO("rtc1_handler temp \x1B[1;32m%u\x1B[0m,\x1B[1;31m%d\x1B[0m    \r",temp>>2,(temp&0x0003)*25);
        }
        nrf_drv_rtc_int_enable(&rtc1, RTC_CHANNEL_INT_MASK(0));
        nrf_drv_rtc_counter_clear(&rtc1);


    }