代码不难,希望有高手帮帮忙。感谢!
忙
#include <stdint.h>
#include "nrf_delay.h"
#include "nrf_gpio.h"
#include "app_timer.h"
//#include "app_scheduler.h"
APP_TIMER_DEF(testapp_timer_id);
static void leds_init(void)
{
nrf_gpio_cfg_output(17);//ÅäÖÃP0.17ΪÊä³ö
nrf_gpio_pin_clear(17); //ָʾµÆ17³õʼ״̬ΪϨÃð1
nrf_gpio_cfg_output(18);//ÅäÖÃP0.17ΪÊä³ö
nrf_gpio_pin_set(18);
nrf_gpio_cfg_output(19);//ÅäÖÃP0.17ΪÊä³ö
nrf_gpio_pin_set(19);
}
static void k_timeout_handler(void * p_context)
{
UNUSED_PARAMETER(p_context);
// battery_level_update();
nrf_gpio_pin_toggle(17);
}
static void timers_init(void)
{
// Initialize timer module, making it use the scheduler
APP_TIMER_INIT(0, 0, false); //Ò»¸öÈí¼þ¶¨Ê±
uint32_t err_code; //н¨¶¨Ê±ÈÎÎñ Ñ»·Ä£Ê½
err_code=app_timer_create(&testapp_timer_id,APP_TIMER_MODE_SINGLE_SHOT,k_timeout_handler);
APP_ERROR_CHECK(err_code);
app_timer_start(testapp_timer_id, APP_TIMER_TICKS(1000,0), NULL);
}
int main(void)
{
leds_init(); //
timers_init();
while (true)
{
}
}
|