update uses of assert_pin_free; remove redundant checks

crypto-aes
Dan Halbert 3 years ago
parent b6206406de
commit 8435935429
  1. 4
      ports/atmel-samd/common-hal/audiobusio/I2SOut.c
  2. 3
      ports/atmel-samd/common-hal/audiobusio/PDMIn.c
  3. 3
      ports/atmel-samd/common-hal/audioio/AudioOut.c
  4. 3
      ports/nrf/common-hal/audiobusio/PDMIn.c
  5. 3
      ports/nrf/common-hal/audiopwmio/PWMAudioOut.c
  6. 13
      shared-bindings/displayio/FourWire.c
  7. 7
      shared-bindings/displayio/I2CDisplay.c
  8. 18
      shared-bindings/displayio/ParallelBus.c

@ -89,6 +89,7 @@ void i2sout_reset(void) {
#endif
}
// Caller validates that pins are free.
void common_hal_audiobusio_i2sout_construct(audiobusio_i2sout_obj_t* self,
const mcu_pin_obj_t* bit_clock, const mcu_pin_obj_t* word_select,
const mcu_pin_obj_t* data, bool left_justified) {
@ -182,9 +183,6 @@ void common_hal_audiobusio_i2sout_construct(audiobusio_i2sout_obj_t* self,
#ifdef SAMD21
#define GPIO_I2S_FUNCTION GPIO_PIN_FUNCTION_G
#endif
assert_pin_free(bit_clock);
assert_pin_free(word_select);
assert_pin_free(data);
self->bit_clock = bit_clock;
self->word_select = word_select;

@ -74,6 +74,7 @@ void pdmin_reset(void) {
I2S->CTRLA.reg = I2S_CTRLA_SWRST;
}
// Caller validates that pins are free.
void common_hal_audiobusio_pdmin_construct(audiobusio_pdmin_obj_t* self,
const mcu_pin_obj_t* clock_pin,
const mcu_pin_obj_t* data_pin,
@ -157,8 +158,6 @@ void common_hal_audiobusio_pdmin_construct(audiobusio_pdmin_obj_t* self,
#ifdef SAMD21
#define GPIO_I2S_FUNCTION GPIO_PIN_FUNCTION_G
#endif
assert_pin_free(clock_pin);
assert_pin_free(data_pin);
uint32_t clock_divisor = (uint32_t) roundf( 48000000.0f / sample_rate / oversample);
float mic_clock_freq = 48000000.0f / clock_divisor;

@ -115,6 +115,7 @@ void audioout_reset(void) {
// TODO(tannewt): Turn off the DAC clocks to save power.
}
// Caller validates that pins are free.
void common_hal_audioio_audioout_construct(audioio_audioout_obj_t* self,
const mcu_pin_obj_t* left_channel, const mcu_pin_obj_t* right_channel, uint16_t quiescent_value) {
#ifdef SAMD51
@ -135,7 +136,6 @@ void common_hal_audioio_audioout_construct(audioio_audioout_obj_t* self,
if (left_channel != &pin_PA02) {
mp_raise_ValueError(translate("Invalid pin"));
}
assert_pin_free(left_channel);
claim_pin(left_channel);
#endif
#ifdef SAMD51
@ -143,7 +143,6 @@ void common_hal_audioio_audioout_construct(audioio_audioout_obj_t* self,
if (left_channel != &pin_PA02 && left_channel != &pin_PA05) {
mp_raise_ValueError(translate("Invalid pin for left channel"));
}
assert_pin_free(left_channel);
if (right_channel != NULL && right_channel != &pin_PA02 && right_channel != &pin_PA05) {
mp_raise_ValueError(translate("Invalid pin for right channel"));
}

@ -34,6 +34,7 @@ NRF_PDM_Type *nrf_pdm = NRF_PDM;
static uint32_t dummy_buffer[4];
// Caller validates that pins are free.
void common_hal_audiobusio_pdmin_construct(audiobusio_pdmin_obj_t* self,
const mcu_pin_obj_t* clock_pin,
const mcu_pin_obj_t* data_pin,
@ -41,8 +42,6 @@ void common_hal_audiobusio_pdmin_construct(audiobusio_pdmin_obj_t* self,
uint8_t bit_depth,
bool mono,
uint8_t oversample) {
assert_pin_free(clock_pin);
assert_pin_free(data_pin);
claim_pin(clock_pin);
claim_pin(data_pin);

@ -155,10 +155,9 @@ void audiopwmout_background() {
}
}
// Caller validates that pins are free.
void common_hal_audiopwmio_pwmaudioout_construct(audiopwmio_pwmaudioout_obj_t* self,
const mcu_pin_obj_t* left_channel, const mcu_pin_obj_t* right_channel, uint16_t quiescent_value) {
assert_pin_free(left_channel);
assert_pin_free(right_channel);
self->pwm = pwmout_allocate(256, PWM_PRESCALER_PRESCALER_DIV_1, true, NULL, NULL);
if (!self->pwm) {
mp_raise_RuntimeError(translate("All timers in use"));

@ -73,16 +73,9 @@ STATIC mp_obj_t displayio_fourwire_make_new(const mp_obj_type_t *type, size_t n_
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
mp_obj_t command = args[ARG_command].u_obj;
mp_obj_t chip_select = args[ARG_chip_select].u_obj;
assert_pin_free(command);
assert_pin_free(chip_select);
mp_obj_t reset = args[ARG_reset].u_obj;
if (reset != mp_const_none) {
assert_pin_free(reset);
} else {
reset = NULL;
}
mcu_pin_obj_t *command = validate_is_free_pin(args[ARG_command].u_obj);
mcu_pin_obj_t *chip_select = validate_is_free_pin(args[ARG_chip_select].u_obj);
mcu_pin_obj_t *reset = validate_is_free_pin_or_none(args[ARG_reset].u_obj);
displayio_fourwire_obj_t* self = NULL;
mp_obj_t spi = args[ARG_spi_bus].u_obj;

@ -69,12 +69,7 @@ STATIC mp_obj_t displayio_i2cdisplay_make_new(const mp_obj_type_t *type, size_t
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
mp_obj_t reset = args[ARG_reset].u_obj;
if (reset != mp_const_none) {
assert_pin_free(reset);
} else {
reset = NULL;
}
mcu_pin_obj_t *reset = validate_is_free_pin_or_none(args[ARG_reset].u_obj);
displayio_i2cdisplay_obj_t* self = NULL;
mp_obj_t i2c = args[ARG_i2c_bus].u_obj;

@ -76,18 +76,12 @@ STATIC mp_obj_t displayio_parallelbus_make_new(const mp_obj_type_t *type, size_t
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
mp_obj_t data0 = args[ARG_data0].u_obj;
mp_obj_t command = args[ARG_command].u_obj;
mp_obj_t chip_select = args[ARG_chip_select].u_obj;
mp_obj_t write = args[ARG_write].u_obj;
mp_obj_t read = args[ARG_read].u_obj;
mp_obj_t reset = args[ARG_reset].u_obj;
assert_pin_free(data0);
assert_pin_free(command);
assert_pin_free(chip_select);
assert_pin_free(write);
assert_pin_free(read);
assert_pin_free(reset);
mcu_pin_obj_t *data0 = validate_is_free_pin(args[ARG_data0].u_obj);
mcu_pin_obj_t *command = validate_is_free_pin(args[ARG_command].u_obj);
mcu_pin_obj_t *chip_select = validate_is_free_pin(args[ARG_chip_select].u_obj);
mcu_pin_obj_t *write = validate_is_free_pin(args[ARG_write].u_obj);
mcu_pin_obj_t *read = validate_is_free_pin(args[ARG_read].u_obj);
mcu_pin_obj_t *reset = validate_is_free_pin(args[ARG_reset].u_obj);
displayio_parallelbus_obj_t* self = NULL;
for (uint8_t i = 0; i < CIRCUITPY_DISPLAY_LIMIT; i++) {

Loading…
Cancel
Save