finished testing led pattern

This commit is contained in:
hathach 2018-12-19 18:29:24 +07:00
parent 5c6bbaca47
commit c69ae13423
3 changed files with 10 additions and 15 deletions

View File

@ -154,6 +154,8 @@ void led_pwm_init(uint32_t led_index, uint32_t led_pin)
pwm->ENABLE = 0;
nrf_gpio_cfg_output(led_pin);
nrf_gpio_pin_write(led_pin, 1 - LED_STATE_ON);
pwm->PSEL.OUT[led_index] = led_pin;
pwm->MODE = PWM_MODE_UPDOWN_Up;
@ -170,7 +172,7 @@ void led_pwm_init(uint32_t led_index, uint32_t led_pin)
pwm->ENABLE = 1;
pwm->EVENTS_SEQEND[0] = 0;
pwm->TASKS_SEQSTART[0] = 1;
// pwm->TASKS_SEQSTART[0] = 1;
}
void led_pwm_teardown(void)
@ -221,32 +223,28 @@ static uint32_t rgb_color;
static bool temp_color_active = false;
void led_state(uint32_t state)
{
enum {
CYCLE_NORMAL = 4000,
CYCLE_WRITING = 100
};
uint32_t new_rgb_color = rgb_color;
uint32_t temp_color = 0;
switch (state) {
case STATE_USB_MOUNTED:
new_rgb_color = 0x00ff00;
primary_cycle_length = CYCLE_NORMAL;
primary_cycle_length = 3000;
break;
case STATE_BOOTLOADER_STARTED:
case STATE_USB_UNMOUNTED:
new_rgb_color = 0xff0000;
primary_cycle_length = CYCLE_NORMAL;
primary_cycle_length = 300;
break;
case STATE_WRITING_STARTED:
temp_color = 0xff0000;
primary_cycle_length = CYCLE_WRITING;
primary_cycle_length = 100;
break;
case STATE_WRITING_FINISHED:
// Empty means to unset any temp colors.
primary_cycle_length = CYCLE_NORMAL;
primary_cycle_length = 3000;
break;
case STATE_BLE_CONNECTED:

View File

@ -108,8 +108,6 @@ static inline bool button_pressed(uint32_t pin)
return (nrf_gpio_pin_read(pin) == 0) ? true : false;
}
bool is_ota(void);
#endif

View File

@ -71,7 +71,7 @@ void usb_teardown(void);
#else
#define usb_init(x)
#define usb_init(x) led_state(STATE_USB_MOUNTED) // mark nrf52832 as mounted
#define usb_teardown()
#endif
@ -167,6 +167,8 @@ int main(void)
board_init();
bootloader_init();
led_state(STATE_BOOTLOADER_STARTED);
// When updating SoftDevice, bootloader will reset before swapping SD
if (bootloader_dfu_sd_in_progress())
{
@ -209,8 +211,6 @@ int main(void)
(*dbl_reset_mem) = 0;
led_state(STATE_BOOTLOADER_STARTED);
if ( dfu_start || !valid_app )
{
if ( _ota_dfu )
@ -222,7 +222,6 @@ int main(void)
else
{
led_state(STATE_USB_UNMOUNTED);
// otherwise USB for Serial & UF2
usb_init(serial_only_dfu);
}