This is an automated email from the ASF dual-hosted git repository. janc pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit bcd372f03d97cb9b995dbc20a6d69edd8c03c027 Author: Miguel Azevedo <[email protected]> AuthorDate: Fri Nov 22 17:12:06 2019 +0000 hw/drivers/pwm: Update nrf52_pwm for nrfx 2.0.0 --- hw/drivers/pwm/pwm_nrf52/src/pwm_nrf52.c | 99 +++++++++++++++++++------------- 1 file changed, 58 insertions(+), 41 deletions(-) diff --git a/hw/drivers/pwm/pwm_nrf52/src/pwm_nrf52.c b/hw/drivers/pwm/pwm_nrf52/src/pwm_nrf52.c index f240788..cdb4c5a 100644 --- a/hw/drivers/pwm/pwm_nrf52/src/pwm_nrf52.c +++ b/hw/drivers/pwm/pwm_nrf52/src/pwm_nrf52.c @@ -58,7 +58,10 @@ static struct nrf52_pwm_dev_global instances[] = [0].in_use = false, [0].playing = false, [0].drv_instance = NRFX_PWM_INSTANCE(0), - [0].config = NRFX_PWM_DEFAULT_CONFIG, + [0].config = NRFX_PWM_DEFAULT_CONFIG(NRFX_PWM_PIN_NOT_USED, + NRFX_PWM_PIN_NOT_USED, + NRFX_PWM_PIN_NOT_USED, + NRFX_PWM_PIN_NOT_USED), [0].flags = NRFX_PWM_FLAG_LOOP, [0].duty_cycles = {0}, [0].n_cycles = 1, @@ -72,7 +75,10 @@ static struct nrf52_pwm_dev_global instances[] = [1].in_use = false, [1].playing = false, [1].drv_instance = NRFX_PWM_INSTANCE(1), - [1].config = NRFX_PWM_DEFAULT_CONFIG, + [1].config = NRFX_PWM_DEFAULT_CONFIG(NRFX_PWM_PIN_NOT_USED, + NRFX_PWM_PIN_NOT_USED, + NRFX_PWM_PIN_NOT_USED, + NRFX_PWM_PIN_NOT_USED), [1].flags = NRFX_PWM_FLAG_LOOP, [1].duty_cycles = {0}, [1].n_cycles = 1, @@ -86,7 +92,10 @@ static struct nrf52_pwm_dev_global instances[] = [2].in_use = false, [2].playing = false, [2].drv_instance = NRFX_PWM_INSTANCE(2), - [2].config = NRFX_PWM_DEFAULT_CONFIG, + [2].config = NRFX_PWM_DEFAULT_CONFIG(NRFX_PWM_PIN_NOT_USED, + NRFX_PWM_PIN_NOT_USED, + NRFX_PWM_PIN_NOT_USED, + NRFX_PWM_PIN_NOT_USED), [2].flags = NRFX_PWM_FLAG_LOOP, [2].duty_cycles = {0}, [2].n_cycles = 1, @@ -100,7 +109,10 @@ static struct nrf52_pwm_dev_global instances[] = [3].in_use = false, [3].playing = false, [3].drv_instance = NRFX_PWM_INSTANCE(3), - [3].config = NRFX_PWM_DEFAULT_CONFIG, + [3].config = NRFX_PWM_DEFAULT_CONFIG(NRFX_PWM_PIN_NOT_USED, + NRFX_PWM_PIN_NOT_USED, + NRFX_PWM_PIN_NOT_USED, + NRFX_PWM_PIN_NOT_USED), [3].flags = NRFX_PWM_FLAG_LOOP, [3].duty_cycles = {0}, [3].n_cycles = 1, @@ -113,20 +125,20 @@ static struct nrf52_pwm_dev_global instances[] = }; #if MYNEWT_VAL(PWM_0) -static void handler_0(nrfx_pwm_evt_type_t event_type) +static void +handler_0(nrfx_pwm_evt_type_t event_type, void *unused) { - switch (event_type) - { - case NRFX_PWM_EVT_END_SEQ0 : - case NRFX_PWM_EVT_END_SEQ1 : + switch (event_type) { + case NRFX_PWM_EVT_END_SEQ0: + case NRFX_PWM_EVT_END_SEQ1: instances[0].cycle_handler(instances[0].cycle_data); break; - case NRFX_PWM_EVT_FINISHED : + case NRFX_PWM_EVT_FINISHED: instances[0].seq_end_handler(instances[0].seq_end_data); break; - case NRFX_PWM_EVT_STOPPED : + case NRFX_PWM_EVT_STOPPED: break; default: @@ -136,20 +148,20 @@ static void handler_0(nrfx_pwm_evt_type_t event_type) #endif #if MYNEWT_VAL(PWM_1) -static void handler_1(nrfx_pwm_evt_type_t event_type) +static void +handler_1(nrfx_pwm_evt_type_t event_type, void *unused) { - switch (event_type) - { - case NRFX_PWM_EVT_END_SEQ0 : - case NRFX_PWM_EVT_END_SEQ1 : + switch (event_type) { + case NRFX_PWM_EVT_END_SEQ0: + case NRFX_PWM_EVT_END_SEQ1: instances[1].cycle_handler(instances[1].cycle_data); break; - case NRFX_PWM_EVT_FINISHED : + case NRFX_PWM_EVT_FINISHED: instances[1].seq_end_handler(instances[1].seq_end_data); break; - case NRFX_PWM_EVT_STOPPED : + case NRFX_PWM_EVT_STOPPED: break; default: @@ -159,20 +171,20 @@ static void handler_1(nrfx_pwm_evt_type_t event_type) #endif #if MYNEWT_VAL(PWM_2) -static void handler_2(nrfx_pwm_evt_type_t event_type) +static void +handler_2(nrfx_pwm_evt_type_t event_type, void *unused) { - switch (event_type) - { - case NRFX_PWM_EVT_END_SEQ0 : - case NRFX_PWM_EVT_END_SEQ1 : + switch (event_type) { + case NRFX_PWM_EVT_END_SEQ0: + case NRFX_PWM_EVT_END_SEQ1: instances[2].cycle_handler(instances[2].cycle_data); break; - case NRFX_PWM_EVT_FINISHED : + case NRFX_PWM_EVT_FINISHED: instances[2].seq_end_handler(instances[2].seq_end_data); break; - case NRFX_PWM_EVT_STOPPED : + case NRFX_PWM_EVT_STOPPED: break; default: @@ -183,20 +195,20 @@ static void handler_2(nrfx_pwm_evt_type_t event_type) #endif #if MYNEWT_VAL(PWM_3) -static void handler_3(nrfx_pwm_evt_type_t event_type) +static void +handler_3(nrfx_pwm_evt_type_t event_type, void *unused) { - switch (event_type) - { - case NRFX_PWM_EVT_END_SEQ0 : - case NRFX_PWM_EVT_END_SEQ1 : + switch (event_type) { + case NRFX_PWM_EVT_END_SEQ0: + case NRFX_PWM_EVT_END_SEQ1: instances[3].cycle_handler(instances[3].cycle_data); break; - case NRFX_PWM_EVT_FINISHED : + case NRFX_PWM_EVT_FINISHED: instances[3].seq_end_handler(instances[3].seq_end_data); break; - case NRFX_PWM_EVT_STOPPED : + case NRFX_PWM_EVT_STOPPED: break; default: @@ -243,11 +255,12 @@ init_instance(int inst_id, nrfx_pwm_config_t* init_conf) config->output_pins[2] = NRFX_PWM_PIN_NOT_USED; config->output_pins[3] = NRFX_PWM_PIN_NOT_USED; config->irq_priority = 3; /* APP_IRQ_PRIORITY_LOW */ - config->base_clock = NRF_PWM_CLK_1MHz; - config->count_mode = NRF_PWM_MODE_UP; - config->top_value = 10000; - config->load_mode = NRF_PWM_LOAD_INDIVIDUAL; - config->step_mode = NRF_PWM_STEP_AUTO; + config->base_clock = NRF_PWM_CLK_1MHz; + config->count_mode = NRF_PWM_MODE_UP; + config->top_value = 10000; + config->load_mode = NRF_PWM_LOAD_INDIVIDUAL; + config->step_mode = NRF_PWM_STEP_AUTO; + config->skip_gpio_cfg = false; } else { memcpy(config, init_conf, sizeof(nrfx_pwm_config_t)); } @@ -422,7 +435,8 @@ nrf52_pwm_configure_device(struct pwm_dev *dev, struct pwm_dev_cfg *cfg) nrfx_pwm_uninit(&instance->drv_instance); nrfx_pwm_init(&instance->drv_instance, &instance->config, - instance->internal_handler); + instance->internal_handler, + NULL); play_current_config(instance); } @@ -459,7 +473,8 @@ nrf52_pwm_configure_channel(struct pwm_dev *dev, nrfx_pwm_uninit(&instance->drv_instance); nrfx_pwm_init(&instance->drv_instance, &instance->config, - instance->internal_handler); + instance->internal_handler, + NULL); play_current_config(instance); } @@ -519,7 +534,8 @@ nrf52_pwm_enable(struct pwm_dev *dev) nrfx_pwm_init(&instance->drv_instance, &instance->config, - instance->internal_handler); + instance->internal_handler, + NULL); play_current_config(instance); instance->playing = true; @@ -623,7 +639,8 @@ nrf52_pwm_set_frequency(struct pwm_dev *dev, uint32_t freq_hz) nrfx_pwm_uninit(&instances[inst_id].drv_instance); nrfx_pwm_init(&instances[inst_id].drv_instance, &instances[inst_id].config, - instances[inst_id].internal_handler); + instances[inst_id].internal_handler, + NULL); play_current_config(&instances[inst_id]); }
