Как выключить светодиод через определенный промежуток времени с помощью модуля nrf51822 - PullRequest
0 голосов
/ 25 января 2019

Существует 12 светодиодов, которые подключены с помощью сдвигового регистра HC595, используется модуль nrf51822 (модуль Bluetooth).Я хочу, чтобы светодиоды погасли через 3 секунды.Мой код выглядит следующим образом:

#include "main.h"
#include "uart.h"
#include "nrf_delay.h"
#include "rc522.h"
#include "hc595.h"
#include "tsm12m.h"
#include "iic.h"
#include "app_timer.h"
#define APP_TIMER_PRESCALER              0                                          /**< Value of the RTC1 PRESCALER register. */
#define APP_TIMER_OP_QUEUE_SIZE          6    

APP_TIMER_DEF(LEDOps);
static void timer_a_handler(void * p_context)
{
    lightAllLEDs();
}
static void create_timers()
{  
    uint32_t err_code;

    // Create timers
    err_code = app_timer_create(&LEDOps,
                                APP_TIMER_MODE_SINGLE_SHOT,
                                timer_a_handler);
    APP_ERROR_CHECK(err_code);
}
void timers_init(){
    uint32_t err_code;
// Initialize the application timer module.
        APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false);
        create_timers();
}
void timer_a_start(){
    uint32_t err_code;
    err_code = app_timer_start(LEDOps, APP_TIMER_TICKS(3,APP_TIMER_PRESCALER), NULL);
  APP_ERROR_CHECK(err_code);
}

int main(void)
{
        uartInit();
      TSM12_Init(); 
      HC595_Init();
        timers_init();
        timer_a_start();
      UartSendstring("123456789");   
    printf("timer stopped!!");  
      app_timer_stop(LEDOps);
    while(1)
    {
             TSM12_Handle();
             nrf_delay_ms(1);
    }
}

Код выше, похоже, не работает.Я новичок в модуле.Пожалуйста, помогите, предоставив решение.

...