fix OTA blinky pattern
This commit is contained in:
parent
8b30c417f8
commit
633885aa51
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
29
src/boards.c
29
src/boards.c
@ -81,7 +81,7 @@ void board_init(void)
|
|||||||
led_off(LED_BLUE);
|
led_off(LED_BLUE);
|
||||||
|
|
||||||
// use PMW0 for LED RED
|
// use PMW0 for LED RED
|
||||||
led_pwm_init(NRF_PWM0, LED_RED);
|
led_pwm_init(LED_RED);
|
||||||
|
|
||||||
// Init scheduler
|
// Init scheduler
|
||||||
APP_SCHED_INIT(SCHED_MAX_EVENT_DATA_SIZE, SCHED_QUEUE_SIZE);
|
APP_SCHED_INIT(SCHED_MAX_EVENT_DATA_SIZE, SCHED_QUEUE_SIZE);
|
||||||
@ -93,7 +93,7 @@ void board_init(void)
|
|||||||
void board_teardown(void)
|
void board_teardown(void)
|
||||||
{
|
{
|
||||||
// Disable and reset PWM for LED
|
// Disable and reset PWM for LED
|
||||||
led_pwm_teardown(NRF_PWM0);
|
led_pwm_teardown(LED_RED);
|
||||||
|
|
||||||
led_off(LED_BLUE);
|
led_off(LED_BLUE);
|
||||||
led_off(LED_RED);
|
led_off(LED_RED);
|
||||||
@ -115,8 +115,10 @@ uint32_t tusb_hal_millis(void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void led_pwm_init(NRF_PWM_Type* pwm, uint32_t led_pin)
|
void led_pwm_init(uint32_t led_pin)
|
||||||
{
|
{
|
||||||
|
NRF_PWM_Type* pwm = (led_pin == LED_RED) ? NRF_PWM0 : NRF_PWM1;
|
||||||
|
|
||||||
pwm->MODE = PWM_MODE_UPDOWN_UpAndDown;
|
pwm->MODE = PWM_MODE_UPDOWN_UpAndDown;
|
||||||
pwm->COUNTERTOP = PWM_MAXCOUNT;
|
pwm->COUNTERTOP = PWM_MAXCOUNT;
|
||||||
pwm->PRESCALER = PWM_PRESCALER_PRESCALER_DIV_128;
|
pwm->PRESCALER = PWM_PRESCALER_PRESCALER_DIV_128;
|
||||||
@ -134,8 +136,10 @@ void led_pwm_init(NRF_PWM_Type* pwm, uint32_t led_pin)
|
|||||||
pwm->TASKS_SEQSTART[0] = 1;
|
pwm->TASKS_SEQSTART[0] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void led_pwm_teardown(NRF_PWM_Type* pwm)
|
void led_pwm_teardown(uint32_t led_pin)
|
||||||
{
|
{
|
||||||
|
NRF_PWM_Type* pwm = (led_pin == LED_RED) ? NRF_PWM0 : NRF_PWM1;
|
||||||
|
|
||||||
pwm->TASKS_SEQSTART[0] = 0;
|
pwm->TASKS_SEQSTART[0] = 0;
|
||||||
pwm->ENABLE = 0;
|
pwm->ENABLE = 0;
|
||||||
|
|
||||||
@ -150,12 +154,23 @@ void led_pwm_teardown(NRF_PWM_Type* pwm)
|
|||||||
pwm->SEQ[0].CNT = 0;
|
pwm->SEQ[0].CNT = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void led_pwm_solid(uint32_t led_pin, bool solid)
|
void led_pwm_disable(uint32_t led_pin)
|
||||||
{
|
{
|
||||||
uint16_t* seq = ((led_pin == LED_RED) ? _pwm_red_seq : _pwm_blue_seq);
|
NRF_PWM_Type* pwm = (led_pin == LED_RED) ? NRF_PWM0 : NRF_PWM1;
|
||||||
seq[0] = (solid ? PWM_MAXCOUNT : PWM_MAXCOUNT/2);
|
|
||||||
|
pwm->TASKS_SEQSTART[0] = 0;
|
||||||
|
pwm->ENABLE = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void led_pwm_enable(uint32_t led_pin)
|
||||||
|
{
|
||||||
|
NRF_PWM_Type* pwm = (led_pin == LED_RED) ? NRF_PWM0 : NRF_PWM1;
|
||||||
|
|
||||||
|
pwm->ENABLE = 1;
|
||||||
|
pwm->TASKS_SEQSTART[0] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void led_blink_fast(bool enable)
|
void led_blink_fast(bool enable)
|
||||||
{
|
{
|
||||||
if ( enable )
|
if ( enable )
|
||||||
|
@ -64,9 +64,10 @@ static inline void led_off(uint32_t pin)
|
|||||||
led_control(pin, false);
|
led_control(pin, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void led_pwm_init(NRF_PWM_Type* pwm, uint32_t led_pin);
|
void led_pwm_init(uint32_t led_pin);
|
||||||
void led_pwm_teardown(NRF_PWM_Type* pwm);
|
void led_pwm_teardown(uint32_t led_pin);
|
||||||
void led_pwm_solid(uint32_t led_pin, bool solid);
|
void led_pwm_disable(uint32_t led_pin);
|
||||||
|
void led_pwm_enable(uint32_t led_pin);
|
||||||
|
|
||||||
void led_blink_fast(bool enable);
|
void led_blink_fast(bool enable);
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ int main(void)
|
|||||||
if ( _ota_dfu )
|
if ( _ota_dfu )
|
||||||
{
|
{
|
||||||
// Enable BLE if in OTA
|
// Enable BLE if in OTA
|
||||||
led_pwm_init(NRF_PWM1, LED_BLUE);
|
led_pwm_init(LED_BLUE);
|
||||||
|
|
||||||
softdev_init(!sd_inited);
|
softdev_init(!sd_inited);
|
||||||
sd_inited = true;
|
sd_inited = true;
|
||||||
@ -195,7 +195,7 @@ int main(void)
|
|||||||
|
|
||||||
if ( _ota_dfu )
|
if ( _ota_dfu )
|
||||||
{
|
{
|
||||||
led_pwm_teardown(NRF_PWM1);
|
led_pwm_teardown(LED_BLUE);
|
||||||
led_off(LED_BLUE);
|
led_off(LED_BLUE);
|
||||||
|
|
||||||
sd_softdevice_disable();
|
sd_softdevice_disable();
|
||||||
@ -375,12 +375,13 @@ uint32_t proc_ble(void)
|
|||||||
{
|
{
|
||||||
case BLE_GAP_EVT_CONNECTED:
|
case BLE_GAP_EVT_CONNECTED:
|
||||||
_ota_connected = true;
|
_ota_connected = true;
|
||||||
led_pwm_solid(LED_BLUE, true); // LED on
|
led_pwm_disable(LED_BLUE);
|
||||||
|
led_on(LED_BLUE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BLE_GAP_EVT_DISCONNECTED:
|
case BLE_GAP_EVT_DISCONNECTED:
|
||||||
_ota_connected = false;
|
_ota_connected = false;
|
||||||
led_pwm_solid(LED_BLUE, false); // LED Blink
|
led_pwm_enable(LED_BLUE); // LED Blink
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: break;
|
default: break;
|
||||||
|
Loading…
Reference in New Issue
Block a user