nrf/modules/machine: Enable code formatting.

It destroys a few manual alignments, but these seem minor compared to
the benefit of automated code style consistency.

Signed-off-by: Christian Walther <cwalther@gmx.ch>
pull/13497/head
Christian Walther 2024-01-05 15:52:09 +01:00 zatwierdzone przez Damien George
rodzic d1a3e7d292
commit be89d4376b
14 zmienionych plików z 175 dodań i 179 usunięć

Wyświetl plik

@ -211,8 +211,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(mp_machine_adc_value_obj, machine_adc_value);
#define BATTERY_MILLIVOLT(VALUE) \
((((VALUE)*ADC_REF_VOLTAGE_IN_MILLIVOLT) / 255) * ADC_PRE_SCALING_MULTIPLIER)
static uint8_t battery_level_in_percent(const uint16_t mvolts)
{
static uint8_t battery_level_in_percent(const uint16_t mvolts) {
uint8_t battery_level;
if (mvolts >= 3000) {

Wyświetl plik

@ -159,8 +159,7 @@ int machine_hard_i2c_transfer_single(mp_obj_base_t *self_in, uint16_t addr, size
if (err_code != NRFX_SUCCESS) {
if (err_code == NRFX_ERROR_DRV_TWI_ERR_ANACK) {
return -MP_ENODEV;
}
else if (err_code == NRFX_ERROR_DRV_TWI_ERR_DNACK) {
} else if (err_code == NRFX_ERROR_DRV_TWI_ERR_DNACK) {
return -MP_EIO;
}
return -MP_ETIMEDOUT;

Wyświetl plik

@ -102,7 +102,7 @@ static mp_obj_t mp_machine_pwm_make_new(const mp_obj_type_t *type, size_t n_args
mp_raise_ValueError(MP_ERROR_TEXT("Pin number >31"));
}
machine_pwm_obj_t *self = mp_obj_malloc(machine_pwm_obj_t, &machine_pwm_type);;
machine_pwm_obj_t *self = mp_obj_malloc(machine_pwm_obj_t, &machine_pwm_type);
self->defer_start = false;
self->pwm_pin = pwm_pin;
self->duty_mode = DUTY_NOT_SET;
@ -197,7 +197,7 @@ static void machine_soft_pwm_start(machine_pwm_obj_t *self) {
duty_width = self->duty * DUTY_FULL_SCALE / 100;
} else if (self->duty_mode == DUTY_U16) {
duty_width = self->duty * DUTY_FULL_SCALE / 65536;
}if (self->duty_mode == DUTY_NS) {
} else if (self->duty_mode == DUTY_NS) {
duty_width = (uint64_t)self->duty * self->freq * DUTY_FULL_SCALE / 1000000000ULL;
}
pwm_set_duty_cycle(self->pwm_pin, duty_width);

Wyświetl plik

@ -270,8 +270,8 @@ static void machine_hard_spi_init_helper(const machine_hard_spi_obj_t *self, mp_
self->p_config->frequency = NRF_SPI_FREQ_1M;
}
// Active high
if (args[ARG_INIT_polarity].u_int == 0) {
// Active high
if (args[ARG_INIT_phase].u_int == 0) {
// First clock edge
self->p_config->mode = NRF_SPI_MODE_0;
@ -279,8 +279,8 @@ static void machine_hard_spi_init_helper(const machine_hard_spi_obj_t *self, mp_
// Second clock edge
self->p_config->mode = NRF_SPI_MODE_1;
}
// Active low
} else {
// Active low
if (args[ARG_INIT_phase].u_int == 0) {
// First clock edge
self->p_config->mode = NRF_SPI_MODE_2;

Wyświetl plik

@ -59,11 +59,9 @@ EXCLUSIONS = [
"ports/nrf/drivers/*.[ch]",
"ports/nrf/modules/ble/*.[ch]",
"ports/nrf/modules/board/*.[ch]",
"ports/nrf/modules/machine/*.[ch]",
"ports/nrf/modules/music/*.[ch]",
"ports/nrf/modules/ubluepy/*.[ch]",
"ports/nrf/modules/os/*.[ch]",
"ports/nrf/modules/time/*.[ch]",
# STM32 USB dev/host code is mostly 3rd party.
"ports/stm32/usbdev/**/*.[ch]",
"ports/stm32/usbhost/**/*.[ch]",