示例#1
0
文件: main.c 项目: lyncxy119/Sentry
/**
 * @brief Function for application main entry.
 */
int main(void)
{
    uint8_t new_duty_cycle;
    uint32_t err_code;

    lfclk_init();

    // Start APP_TIMER to generate timeouts.
    APP_TIMER_INIT(APP_TIMER_PRESCALER, OP_QUEUES_SIZE, NULL);

    /*Initialize low power PWM for all 3  channels of RGB or 3 channels of leds on pca10028*/
    pwm_init();

    while (true)
    {
        /* Duty cycle can also be changed from main context. */
        new_duty_cycle = low_power_pwm_2.period - low_power_pwm_2.duty_cycle;
        err_code = low_power_pwm_duty_set(&low_power_pwm_2, new_duty_cycle);
        APP_ERROR_CHECK(err_code);
        nrf_delay_ms(500);

        new_duty_cycle = low_power_pwm_2.period - low_power_pwm_2.duty_cycle;
        err_code = low_power_pwm_duty_set(&low_power_pwm_2, new_duty_cycle);
        APP_ERROR_CHECK(err_code);
        nrf_delay_ms(500);
    }
}
/**
 * @brief Function for application main entry.
 */
int main(void)
{
	lfclk_init();
    timers_init();
    timers_start();
    //Arduino initialization, LFCLK and timers must have been initialized before
    application_setup();

    // Enter main loop
    for (;;)
    {
        //application loop
        application_loop();
    }
}
示例#3
0
/**
 * @brief Function for application main entry.
 */
int main(void)
{
    ret_code_t err_code;

    lfclk_init();

    // Start APP_TIMER to generate timeouts.
    APP_TIMER_INIT(APP_TIMER_PRESCALER, OP_QUEUES_SIZE, NULL);

    led_sb_init_params_t led_sb_init_param = LED_SB_INIT_DEFAULT_PARAMS(LEDS_MASK);
    
    err_code = led_softblink_init(&led_sb_init_param);
    APP_ERROR_CHECK(err_code);
    
    err_code = led_softblink_start(LEDS_MASK);
    APP_ERROR_CHECK(err_code);     

    while (true)
    {
        __WFE();
    }
}
示例#4
0
/**@todo Take care of values of ticks passed which are greater than 2^24, now it is suppressed to 2^24 when greater
 * @warning Works only for input less than 512000 milli-seconds, or 8.5 min without when @ref RTC_PRESCALER is 0 */
void start_ms_timer(timer_num id, timer_mode mode, uint32_t ticks, void (*handler)(void)){

	/* make sure the number of ticks to interrupt is less than 2^24 */
	ticks &= 0xFFFFFF;

	ms_timer_t[id].timer_handler = handler;
	if(mode == SINGLE_CALL){
		ms_timer_t[id].timer_mode_t  = SINGLE_CALL;
	}else{
		ms_timer_t[id].timer_mode_t  = ticks;
	}

	NRF_RTC1->CC[id]	= NRF_RTC1->COUNTER + ticks;

	NRF_RTC1->EVENTS_COMPARE[id] = 0;
	NRF_RTC1->EVTENSET 		= 1 << (RTC_INTENSET_COMPARE0_Pos + id);
	NRF_RTC1->INTENSET 		= 1 << (RTC_INTENSET_COMPARE0_Pos + id);

	if(ms_timers_status == 0){
		lfclk_init();
		NRF_RTC1->TASKS_START = 1;
	}
	ms_timers_status |= 1 << id;
}