Programing/ Nordic(BLE)
LED 인티케이터 동작시 다른 LED가 꺼지는 현상
흰군
2016. 1. 9. 17:39
제목 그대로 BLE Advertising 중에 LED 1번에 깜밖이는데
문제는 LED 1번이 켜질때는 문제 없지만 꺼질때는 다른 LED들도 같이 꺼지는 것을 확인했습니다.
이를 수정하기 위해서는
Board Support의 bsp.c 파일을 열어
static uint32_t bsp_led_indication(bsp_indication_t indicate) 함수를 찾습니다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | static uint32_t bsp_led_indication(bsp_indication_t indicate) { uint32_t err_code = NRF_SUCCESS; uint32_t next_delay = 0; switch (indicate) { case BSP_INDICATE_IDLE: LEDS_OFF(LEDS_MASK & ~m_alert_mask); m_stable_state = indicate; break; case BSP_INDICATE_SCANNING: case BSP_INDICATE_ADVERTISING: LEDS_OFF(LEDS_MASK & ~BSP_LED_0_MASK & ~m_alert_mask); // in advertising blink LED_0 if (LED_IS_ON(BSP_LED_0_MASK)) { LEDS_OFF(BSP_LED_0_MASK); next_delay = indicate == BSP_INDICATE_ADVERTISING ? ADVERTISING_LED_OFF_INTERVAL : ADVERTISING_SLOW_LED_OFF_INTERVAL; } else { LEDS_ON(BSP_LED_0_MASK); next_delay = indicate == BSP_INDICATE_ADVERTISING ? ADVERTISING_LED_ON_INTERVAL : ADVERTISING_SLOW_LED_ON_INTERVAL; } m_stable_state = indicate; err_code = app_timer_start(m_leds_timer_id, BSP_MS_TO_TICK(next_delay), NULL); break; | cs |
BSP_INDICATE_ADVERTISING:
아래에 있는 LEDS_OFF(LEDS_MASK & ~BSP_LED_0_MASK & ~m_alert_mask); 부분을 아래와 같이 주석 처리하면 됩니다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | static uint32_t bsp_led_indication(bsp_indication_t indicate) { uint32_t err_code = NRF_SUCCESS; uint32_t next_delay = 0; switch (indicate) { case BSP_INDICATE_IDLE: LEDS_OFF(LEDS_MASK & ~m_alert_mask); m_stable_state = indicate; break; case BSP_INDICATE_SCANNING: case BSP_INDICATE_ADVERTISING: // LEDS_OFF(LEDS_MASK & ~BSP_LED_0_MASK & ~m_alert_mask); // in advertising blink LED_0 if (LED_IS_ON(BSP_LED_0_MASK)) { LEDS_OFF(BSP_LED_0_MASK); next_delay = indicate == BSP_INDICATE_ADVERTISING ? ADVERTISING_LED_OFF_INTERVAL : ADVERTISING_SLOW_LED_OFF_INTERVAL; } else { LEDS_ON(BSP_LED_0_MASK); next_delay = indicate == BSP_INDICATE_ADVERTISING ? ADVERTISING_LED_ON_INTERVAL : ADVERTISING_SLOW_LED_ON_INTERVAL; } m_stable_state = indicate; err_code = app_timer_start(m_leds_timer_id, BSP_MS_TO_TICK(next_delay), NULL); break; | cs |
왜 이렇식으로 짜놓았는지 모르겠습니다.
블루투스를 연결하지 않았더라도 다른 LED들을 다른 용도로 사용할 일이 많을 텐데요.