Merge pull request #2666 from dhalbert/assert_pin-and-mp_const_none-cleanup
validate various displayio args; new pin validation routines; don't use mp_const_none if NULL will do
This commit is contained in:
commit
df88939128
@ -49,7 +49,7 @@ uint8_t display_init_sequence[] = {
|
|||||||
|
|
||||||
void board_init(void) {
|
void board_init(void) {
|
||||||
busio_spi_obj_t* spi = &displays[0].fourwire_bus.inline_bus;
|
busio_spi_obj_t* spi = &displays[0].fourwire_bus.inline_bus;
|
||||||
common_hal_busio_spi_construct(spi, &pin_PA01, &pin_PA00, mp_const_none);
|
common_hal_busio_spi_construct(spi, &pin_PA01, &pin_PA00, NULL);
|
||||||
common_hal_busio_spi_never_reset(spi);
|
common_hal_busio_spi_never_reset(spi);
|
||||||
|
|
||||||
displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus;
|
displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus;
|
||||||
|
@ -50,7 +50,7 @@ uint8_t display_init_sequence[] = {
|
|||||||
|
|
||||||
void board_init(void) {
|
void board_init(void) {
|
||||||
busio_spi_obj_t* spi = &displays[0].fourwire_bus.inline_bus;
|
busio_spi_obj_t* spi = &displays[0].fourwire_bus.inline_bus;
|
||||||
common_hal_busio_spi_construct(spi, &pin_PA13, &pin_PA12, mp_const_none);
|
common_hal_busio_spi_construct(spi, &pin_PA13, &pin_PA12, NULL);
|
||||||
common_hal_busio_spi_never_reset(spi);
|
common_hal_busio_spi_never_reset(spi);
|
||||||
|
|
||||||
displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus;
|
displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus;
|
||||||
|
@ -55,7 +55,7 @@ uint8_t stop_sequence[] = {
|
|||||||
|
|
||||||
void board_init(void) {
|
void board_init(void) {
|
||||||
busio_spi_obj_t* spi = &displays[0].fourwire_bus.inline_bus;
|
busio_spi_obj_t* spi = &displays[0].fourwire_bus.inline_bus;
|
||||||
common_hal_busio_spi_construct(spi, &pin_PB13, &pin_PB15, mp_const_none);
|
common_hal_busio_spi_construct(spi, &pin_PB13, &pin_PB15, NULL);
|
||||||
common_hal_busio_spi_never_reset(spi);
|
common_hal_busio_spi_never_reset(spi);
|
||||||
|
|
||||||
displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus;
|
displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus;
|
||||||
|
@ -97,7 +97,7 @@ uint8_t display_init_sequence[] = {
|
|||||||
|
|
||||||
void board_init(void) {
|
void board_init(void) {
|
||||||
busio_spi_obj_t* spi = &displays[0].fourwire_bus.inline_bus;
|
busio_spi_obj_t* spi = &displays[0].fourwire_bus.inline_bus;
|
||||||
common_hal_busio_spi_construct(spi, &pin_PA13, &pin_PA15, mp_const_none);
|
common_hal_busio_spi_construct(spi, &pin_PA13, &pin_PA15, NULL);
|
||||||
common_hal_busio_spi_never_reset(spi);
|
common_hal_busio_spi_never_reset(spi);
|
||||||
|
|
||||||
displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus;
|
displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus;
|
||||||
|
@ -72,7 +72,7 @@ uint8_t display_init_sequence[] = {
|
|||||||
|
|
||||||
void board_init(void) {
|
void board_init(void) {
|
||||||
busio_spi_obj_t* spi = &displays[0].fourwire_bus.inline_bus;
|
busio_spi_obj_t* spi = &displays[0].fourwire_bus.inline_bus;
|
||||||
common_hal_busio_spi_construct(spi, &pin_PB13, &pin_PB15, mp_const_none);
|
common_hal_busio_spi_construct(spi, &pin_PB13, &pin_PB15, NULL);
|
||||||
common_hal_busio_spi_never_reset(spi);
|
common_hal_busio_spi_never_reset(spi);
|
||||||
|
|
||||||
displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus;
|
displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus;
|
||||||
|
@ -50,7 +50,7 @@ uint8_t display_init_sequence[] = {
|
|||||||
|
|
||||||
void board_init(void) {
|
void board_init(void) {
|
||||||
busio_spi_obj_t* spi = &displays[0].fourwire_bus.inline_bus;
|
busio_spi_obj_t* spi = &displays[0].fourwire_bus.inline_bus;
|
||||||
common_hal_busio_spi_construct(spi, &pin_PB13, &pin_PB15, mp_const_none);
|
common_hal_busio_spi_construct(spi, &pin_PB13, &pin_PB15, NULL);
|
||||||
common_hal_busio_spi_never_reset(spi);
|
common_hal_busio_spi_never_reset(spi);
|
||||||
|
|
||||||
displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus;
|
displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus;
|
||||||
|
@ -72,7 +72,7 @@ uint8_t display_init_sequence[] = {
|
|||||||
|
|
||||||
void board_init(void) {
|
void board_init(void) {
|
||||||
busio_spi_obj_t* spi = &displays[0].fourwire_bus.inline_bus;
|
busio_spi_obj_t* spi = &displays[0].fourwire_bus.inline_bus;
|
||||||
common_hal_busio_spi_construct(spi, &pin_PB13, &pin_PB15, mp_const_none);
|
common_hal_busio_spi_construct(spi, &pin_PB13, &pin_PB15, NULL);
|
||||||
common_hal_busio_spi_never_reset(spi);
|
common_hal_busio_spi_never_reset(spi);
|
||||||
|
|
||||||
displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus;
|
displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus;
|
||||||
|
@ -50,7 +50,7 @@ uint8_t display_init_sequence[] = {
|
|||||||
|
|
||||||
void board_init(void) {
|
void board_init(void) {
|
||||||
busio_spi_obj_t* spi = &displays[0].fourwire_bus.inline_bus;
|
busio_spi_obj_t* spi = &displays[0].fourwire_bus.inline_bus;
|
||||||
common_hal_busio_spi_construct(spi, &pin_PB13, &pin_PB12, mp_const_none);
|
common_hal_busio_spi_construct(spi, &pin_PB13, &pin_PB12, NULL);
|
||||||
common_hal_busio_spi_never_reset(spi);
|
common_hal_busio_spi_never_reset(spi);
|
||||||
|
|
||||||
displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus;
|
displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus;
|
||||||
|
@ -73,7 +73,7 @@ void common_hal_analogio_analogin_construct(analogio_analogin_obj_t* self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool common_hal_analogio_analogin_deinited(analogio_analogin_obj_t *self) {
|
bool common_hal_analogio_analogin_deinited(analogio_analogin_obj_t *self) {
|
||||||
return self->pin == mp_const_none;
|
return self->pin == NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void common_hal_analogio_analogin_deinit(analogio_analogin_obj_t *self) {
|
void common_hal_analogio_analogin_deinit(analogio_analogin_obj_t *self) {
|
||||||
@ -81,7 +81,7 @@ void common_hal_analogio_analogin_deinit(analogio_analogin_obj_t *self) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
reset_pin_number(self->pin->number);
|
reset_pin_number(self->pin->number);
|
||||||
self->pin = mp_const_none;
|
self->pin = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void analogin_reset() {
|
void analogin_reset() {
|
||||||
|
@ -89,6 +89,7 @@ void i2sout_reset(void) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Caller validates that pins are free.
|
||||||
void common_hal_audiobusio_i2sout_construct(audiobusio_i2sout_obj_t* self,
|
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* bit_clock, const mcu_pin_obj_t* word_select,
|
||||||
const mcu_pin_obj_t* data, bool left_justified) {
|
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
|
#ifdef SAMD21
|
||||||
#define GPIO_I2S_FUNCTION GPIO_PIN_FUNCTION_G
|
#define GPIO_I2S_FUNCTION GPIO_PIN_FUNCTION_G
|
||||||
#endif
|
#endif
|
||||||
assert_pin_free(bit_clock);
|
|
||||||
assert_pin_free(word_select);
|
|
||||||
assert_pin_free(data);
|
|
||||||
|
|
||||||
self->bit_clock = bit_clock;
|
self->bit_clock = bit_clock;
|
||||||
self->word_select = word_select;
|
self->word_select = word_select;
|
||||||
@ -204,7 +202,7 @@ void common_hal_audiobusio_i2sout_construct(audiobusio_i2sout_obj_t* self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool common_hal_audiobusio_i2sout_deinited(audiobusio_i2sout_obj_t* self) {
|
bool common_hal_audiobusio_i2sout_deinited(audiobusio_i2sout_obj_t* self) {
|
||||||
return self->bit_clock == mp_const_none;
|
return self->bit_clock == NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void common_hal_audiobusio_i2sout_deinit(audiobusio_i2sout_obj_t* self) {
|
void common_hal_audiobusio_i2sout_deinit(audiobusio_i2sout_obj_t* self) {
|
||||||
@ -213,11 +211,11 @@ void common_hal_audiobusio_i2sout_deinit(audiobusio_i2sout_obj_t* self) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
reset_pin_number(self->bit_clock->number);
|
reset_pin_number(self->bit_clock->number);
|
||||||
self->bit_clock = mp_const_none;
|
self->bit_clock = NULL;
|
||||||
reset_pin_number(self->word_select->number);
|
reset_pin_number(self->word_select->number);
|
||||||
self->word_select = mp_const_none;
|
self->word_select = NULL;
|
||||||
reset_pin_number(self->data->number);
|
reset_pin_number(self->data->number);
|
||||||
self->data = mp_const_none;
|
self->data = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void common_hal_audiobusio_i2sout_play(audiobusio_i2sout_obj_t* self,
|
void common_hal_audiobusio_i2sout_play(audiobusio_i2sout_obj_t* self,
|
||||||
|
@ -74,6 +74,7 @@ void pdmin_reset(void) {
|
|||||||
I2S->CTRLA.reg = I2S_CTRLA_SWRST;
|
I2S->CTRLA.reg = I2S_CTRLA_SWRST;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Caller validates that pins are free.
|
||||||
void common_hal_audiobusio_pdmin_construct(audiobusio_pdmin_obj_t* self,
|
void common_hal_audiobusio_pdmin_construct(audiobusio_pdmin_obj_t* self,
|
||||||
const mcu_pin_obj_t* clock_pin,
|
const mcu_pin_obj_t* clock_pin,
|
||||||
const mcu_pin_obj_t* data_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
|
#ifdef SAMD21
|
||||||
#define GPIO_I2S_FUNCTION GPIO_PIN_FUNCTION_G
|
#define GPIO_I2S_FUNCTION GPIO_PIN_FUNCTION_G
|
||||||
#endif
|
#endif
|
||||||
assert_pin_free(clock_pin);
|
|
||||||
assert_pin_free(data_pin);
|
|
||||||
|
|
||||||
uint32_t clock_divisor = (uint32_t) roundf( 48000000.0f / sample_rate / oversample);
|
uint32_t clock_divisor = (uint32_t) roundf( 48000000.0f / sample_rate / oversample);
|
||||||
float mic_clock_freq = 48000000.0f / clock_divisor;
|
float mic_clock_freq = 48000000.0f / clock_divisor;
|
||||||
@ -219,7 +218,7 @@ void common_hal_audiobusio_pdmin_construct(audiobusio_pdmin_obj_t* self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool common_hal_audiobusio_pdmin_deinited(audiobusio_pdmin_obj_t* self) {
|
bool common_hal_audiobusio_pdmin_deinited(audiobusio_pdmin_obj_t* self) {
|
||||||
return self->clock_pin == mp_const_none;
|
return self->clock_pin == NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void common_hal_audiobusio_pdmin_deinit(audiobusio_pdmin_obj_t* self) {
|
void common_hal_audiobusio_pdmin_deinit(audiobusio_pdmin_obj_t* self) {
|
||||||
@ -237,8 +236,8 @@ void common_hal_audiobusio_pdmin_deinit(audiobusio_pdmin_obj_t* self) {
|
|||||||
|
|
||||||
reset_pin_number(self->clock_pin->number);
|
reset_pin_number(self->clock_pin->number);
|
||||||
reset_pin_number(self->data_pin->number);
|
reset_pin_number(self->data_pin->number);
|
||||||
self->clock_pin = mp_const_none;
|
self->clock_pin = NULL;
|
||||||
self->data_pin = mp_const_none;
|
self->data_pin = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t common_hal_audiobusio_pdmin_get_bit_depth(audiobusio_pdmin_obj_t* self) {
|
uint8_t common_hal_audiobusio_pdmin_get_bit_depth(audiobusio_pdmin_obj_t* self) {
|
||||||
|
@ -115,6 +115,7 @@ void audioout_reset(void) {
|
|||||||
// TODO(tannewt): Turn off the DAC clocks to save power.
|
// 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,
|
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) {
|
const mcu_pin_obj_t* left_channel, const mcu_pin_obj_t* right_channel, uint16_t quiescent_value) {
|
||||||
#ifdef SAMD51
|
#ifdef SAMD51
|
||||||
@ -135,7 +136,6 @@ void common_hal_audioio_audioout_construct(audioio_audioout_obj_t* self,
|
|||||||
if (left_channel != &pin_PA02) {
|
if (left_channel != &pin_PA02) {
|
||||||
mp_raise_ValueError(translate("Invalid pin"));
|
mp_raise_ValueError(translate("Invalid pin"));
|
||||||
}
|
}
|
||||||
assert_pin_free(left_channel);
|
|
||||||
claim_pin(left_channel);
|
claim_pin(left_channel);
|
||||||
#endif
|
#endif
|
||||||
#ifdef SAMD51
|
#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) {
|
if (left_channel != &pin_PA02 && left_channel != &pin_PA05) {
|
||||||
mp_raise_ValueError(translate("Invalid pin for left channel"));
|
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) {
|
if (right_channel != NULL && right_channel != &pin_PA02 && right_channel != &pin_PA05) {
|
||||||
mp_raise_ValueError(translate("Invalid pin for right channel"));
|
mp_raise_ValueError(translate("Invalid pin for right channel"));
|
||||||
}
|
}
|
||||||
@ -304,7 +303,7 @@ void common_hal_audioio_audioout_construct(audioio_audioout_obj_t* self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool common_hal_audioio_audioout_deinited(audioio_audioout_obj_t* self) {
|
bool common_hal_audioio_audioout_deinited(audioio_audioout_obj_t* self) {
|
||||||
return self->left_channel == mp_const_none;
|
return self->left_channel == NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void common_hal_audioio_audioout_deinit(audioio_audioout_obj_t* self) {
|
void common_hal_audioio_audioout_deinit(audioio_audioout_obj_t* self) {
|
||||||
@ -332,10 +331,10 @@ void common_hal_audioio_audioout_deinit(audioio_audioout_obj_t* self) {
|
|||||||
tc_set_enable(tc_insts[self->tc_index], false);
|
tc_set_enable(tc_insts[self->tc_index], false);
|
||||||
|
|
||||||
reset_pin_number(self->left_channel->number);
|
reset_pin_number(self->left_channel->number);
|
||||||
self->left_channel = mp_const_none;
|
self->left_channel = NULL;
|
||||||
#ifdef SAMD51
|
#ifdef SAMD51
|
||||||
reset_pin_number(self->right_channel->number);
|
reset_pin_number(self->right_channel->number);
|
||||||
self->right_channel = mp_const_none;
|
self->right_channel = NULL;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,8 +89,8 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
|
|||||||
Sercom* sercom = NULL;
|
Sercom* sercom = NULL;
|
||||||
uint8_t sercom_index;
|
uint8_t sercom_index;
|
||||||
uint32_t clock_pinmux = 0;
|
uint32_t clock_pinmux = 0;
|
||||||
bool mosi_none = mosi == mp_const_none || mosi == NULL;
|
bool mosi_none = mosi == NULL;
|
||||||
bool miso_none = miso == mp_const_none || miso == NULL;
|
bool miso_none = miso == NULL;
|
||||||
uint32_t mosi_pinmux = 0;
|
uint32_t mosi_pinmux = 0;
|
||||||
uint32_t miso_pinmux = 0;
|
uint32_t miso_pinmux = 0;
|
||||||
uint8_t clock_pad = 0;
|
uint8_t clock_pad = 0;
|
||||||
|
@ -65,7 +65,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||||||
uint32_t tx_pinmux = 0;
|
uint32_t tx_pinmux = 0;
|
||||||
uint8_t tx_pad = 255; // Unset pad
|
uint8_t tx_pad = 255; // Unset pad
|
||||||
|
|
||||||
if ((rts != mp_const_none) || (cts != mp_const_none) || (rs485_dir != mp_const_none) || (rs485_invert)) {
|
if ((rts != NULL) || (cts != NULL) || (rs485_dir != NULL) || (rs485_invert)) {
|
||||||
mp_raise_ValueError(translate("RTS/CTS/RS485 Not yet supported on this device"));
|
mp_raise_ValueError(translate("RTS/CTS/RS485 Not yet supported on this device"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,8 +73,8 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||||||
mp_raise_NotImplementedError(translate("bytes > 8 bits not supported"));
|
mp_raise_NotImplementedError(translate("bytes > 8 bits not supported"));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool have_tx = tx != mp_const_none;
|
bool have_tx = tx != NULL;
|
||||||
bool have_rx = rx != mp_const_none;
|
bool have_rx = rx != NULL;
|
||||||
if (!have_tx && !have_rx) {
|
if (!have_tx && !have_rx) {
|
||||||
mp_raise_ValueError(translate("tx and rx cannot both be None"));
|
mp_raise_ValueError(translate("tx and rx cannot both be None"));
|
||||||
}
|
}
|
||||||
@ -109,7 +109,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||||||
#endif
|
#endif
|
||||||
tx_pinmux = PINMUX(tx->number, (i == 0) ? MUX_C : MUX_D);
|
tx_pinmux = PINMUX(tx->number, (i == 0) ? MUX_C : MUX_D);
|
||||||
tx_pad = tx->sercom[i].pad;
|
tx_pad = tx->sercom[i].pad;
|
||||||
if (rx == mp_const_none) {
|
if (rx == NULL) {
|
||||||
sercom = potential_sercom;
|
sercom = potential_sercom;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ void common_hal_digitalio_digitalinout_never_reset(
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool common_hal_digitalio_digitalinout_deinited(digitalio_digitalinout_obj_t* self) {
|
bool common_hal_digitalio_digitalinout_deinited(digitalio_digitalinout_obj_t* self) {
|
||||||
return self->pin == mp_const_none;
|
return self->pin == NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void common_hal_digitalio_digitalinout_deinit(digitalio_digitalinout_obj_t* self) {
|
void common_hal_digitalio_digitalinout_deinit(digitalio_digitalinout_obj_t* self) {
|
||||||
@ -63,7 +63,7 @@ void common_hal_digitalio_digitalinout_deinit(digitalio_digitalinout_obj_t* self
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
reset_pin_number(self->pin->number);
|
reset_pin_number(self->pin->number);
|
||||||
self->pin = mp_const_none;
|
self->pin = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void common_hal_digitalio_digitalinout_switch_to_input(
|
void common_hal_digitalio_digitalinout_switch_to_input(
|
||||||
|
@ -292,7 +292,7 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool common_hal_pulseio_pwmout_deinited(pulseio_pwmout_obj_t* self) {
|
bool common_hal_pulseio_pwmout_deinited(pulseio_pwmout_obj_t* self) {
|
||||||
return self->pin == mp_const_none;
|
return self->pin == NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t* self) {
|
void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t* self) {
|
||||||
@ -319,7 +319,7 @@ void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t* self) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
reset_pin_number(self->pin->number);
|
reset_pin_number(self->pin->number);
|
||||||
self->pin = mp_const_none;
|
self->pin = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern void common_hal_pulseio_pwmout_set_duty_cycle(pulseio_pwmout_obj_t* self, uint16_t duty) {
|
extern void common_hal_pulseio_pwmout_set_duty_cycle(pulseio_pwmout_obj_t* self, uint16_t duty) {
|
||||||
|
@ -97,7 +97,7 @@ void common_hal_analogio_analogin_deinit(analogio_analogin_obj_t *self) {
|
|||||||
close(analogin_dev[self->number].fd);
|
close(analogin_dev[self->number].fd);
|
||||||
analogin_dev[self->number].fd = -1;
|
analogin_dev[self->number].fd = -1;
|
||||||
|
|
||||||
self->pin = mp_const_none;
|
self->pin = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool common_hal_analogio_analogin_deinited(analogio_analogin_obj_t *self) {
|
bool common_hal_analogio_analogin_deinited(analogio_analogin_obj_t *self) {
|
||||||
|
@ -60,7 +60,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||||||
mp_float_t timeout, uint16_t receiver_buffer_size) {
|
mp_float_t timeout, uint16_t receiver_buffer_size) {
|
||||||
struct termios tio;
|
struct termios tio;
|
||||||
|
|
||||||
if ((rts != mp_const_none) || (cts != mp_const_none) || (rs485_dir != mp_const_none) || (rs485_invert)) {
|
if ((rts != NULL) || (cts != NULL) || (rs485_dir != NULL) || (rs485_invert)) {
|
||||||
mp_raise_ValueError(translate("RTS/CTS/RS485 Not yet supported on this device"));
|
mp_raise_ValueError(translate("RTS/CTS/RS485 Not yet supported on this device"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,11 +56,11 @@ void common_hal_digitalio_digitalinout_deinit(digitalio_digitalinout_obj_t *self
|
|||||||
board_gpio_config(self->pin->number, 0, false, true, PIN_FLOAT);
|
board_gpio_config(self->pin->number, 0, false, true, PIN_FLOAT);
|
||||||
|
|
||||||
reset_pin_number(self->pin->number);
|
reset_pin_number(self->pin->number);
|
||||||
self->pin = mp_const_none;
|
self->pin = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool common_hal_digitalio_digitalinout_deinited(digitalio_digitalinout_obj_t *self) {
|
bool common_hal_digitalio_digitalinout_deinited(digitalio_digitalinout_obj_t *self) {
|
||||||
return self->pin == mp_const_none;
|
return self->pin == NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void common_hal_digitalio_digitalinout_switch_to_input(digitalio_digitalinout_obj_t *self, digitalio_pull_t pull) {
|
void common_hal_digitalio_digitalinout_switch_to_input(digitalio_digitalinout_obj_t *self, digitalio_pull_t pull) {
|
||||||
|
@ -95,7 +95,7 @@ void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t *self) {
|
|||||||
pwmout_dev[self->number].fd = -1;
|
pwmout_dev[self->number].fd = -1;
|
||||||
|
|
||||||
reset_pin_number(self->pin->number);
|
reset_pin_number(self->pin->number);
|
||||||
self->pin = mp_const_none;
|
self->pin = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool common_hal_pulseio_pwmout_deinited(pulseio_pwmout_obj_t *self) {
|
bool common_hal_pulseio_pwmout_deinited(pulseio_pwmout_obj_t *self) {
|
||||||
|
@ -116,11 +116,11 @@ void common_hal_pulseio_pulsein_deinit(pulseio_pulsein_obj_t *self) {
|
|||||||
board_gpio_intconfig(self->pin->number, 0, false, NULL);
|
board_gpio_intconfig(self->pin->number, 0, false, NULL);
|
||||||
|
|
||||||
reset_pin_number(self->pin->number);
|
reset_pin_number(self->pin->number);
|
||||||
self->pin = mp_const_none;
|
self->pin = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool common_hal_pulseio_pulsein_deinited(pulseio_pulsein_obj_t *self) {
|
bool common_hal_pulseio_pulsein_deinited(pulseio_pulsein_obj_t *self) {
|
||||||
return self->pin == mp_const_none;
|
return self->pin == NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void common_hal_pulseio_pulsein_pause(pulseio_pulsein_obj_t *self) {
|
void common_hal_pulseio_pulsein_pause(pulseio_pulsein_obj_t *self) {
|
||||||
@ -193,4 +193,3 @@ uint16_t common_hal_pulseio_pulsein_get_item(pulseio_pulsein_obj_t *self, int16_
|
|||||||
common_hal_mcu_enable_interrupts();
|
common_hal_mcu_enable_interrupts();
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
@ -58,7 +58,7 @@ void common_hal_analogio_analogin_construct(analogio_analogin_obj_t* self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool common_hal_analogio_analogin_deinited(analogio_analogin_obj_t *self) {
|
bool common_hal_analogio_analogin_deinited(analogio_analogin_obj_t *self) {
|
||||||
return self->pin == mp_const_none;
|
return self->pin == NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void common_hal_analogio_analogin_deinit(analogio_analogin_obj_t *self) {
|
void common_hal_analogio_analogin_deinit(analogio_analogin_obj_t *self) {
|
||||||
@ -66,7 +66,7 @@ void common_hal_analogio_analogin_deinit(analogio_analogin_obj_t *self) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
reset_pin_number(self->pin->number);
|
reset_pin_number(self->pin->number);
|
||||||
self->pin = mp_const_none;
|
self->pin = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t common_hal_analogio_analogin_get_value(analogio_analogin_obj_t *self) {
|
uint16_t common_hal_analogio_analogin_get_value(analogio_analogin_obj_t *self) {
|
||||||
|
@ -80,8 +80,8 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||||||
|
|
||||||
// TODO: Allow none rx or tx
|
// TODO: Allow none rx or tx
|
||||||
|
|
||||||
bool have_tx = tx != mp_const_none;
|
bool have_tx = tx != NULL;
|
||||||
bool have_rx = rx != mp_const_none;
|
bool have_rx = rx != NULL;
|
||||||
if (!have_tx && !have_rx) {
|
if (!have_tx && !have_rx) {
|
||||||
mp_raise_ValueError(translate("tx and rx cannot both be None"));
|
mp_raise_ValueError(translate("tx and rx cannot both be None"));
|
||||||
}
|
}
|
||||||
@ -116,8 +116,8 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Filter for sane settings for RS485
|
// Filter for sane settings for RS485
|
||||||
if (rs485_dir != mp_const_none) {
|
if (rs485_dir != NULL) {
|
||||||
if ((rts != mp_const_none) || (cts != mp_const_none)) {
|
if ((rts != NULL) || (cts != NULL)) {
|
||||||
mp_raise_ValueError(translate("Cannot specify RTS or CTS in RS485 mode"));
|
mp_raise_ValueError(translate("Cannot specify RTS or CTS in RS485 mode"));
|
||||||
}
|
}
|
||||||
// For IMXRT the RTS pin is used for RS485 direction
|
// For IMXRT the RTS pin is used for RS485 direction
|
||||||
@ -133,7 +133,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||||||
const uint32_t rts_count = sizeof(mcu_uart_rts_list) / sizeof(mcu_periph_obj_t);
|
const uint32_t rts_count = sizeof(mcu_uart_rts_list) / sizeof(mcu_periph_obj_t);
|
||||||
const uint32_t cts_count = sizeof(mcu_uart_cts_list) / sizeof(mcu_periph_obj_t);
|
const uint32_t cts_count = sizeof(mcu_uart_cts_list) / sizeof(mcu_periph_obj_t);
|
||||||
|
|
||||||
if (rts != mp_const_none) {
|
if (rts != NULL) {
|
||||||
for (uint32_t i=0; i < rts_count; ++i) {
|
for (uint32_t i=0; i < rts_count; ++i) {
|
||||||
if (mcu_uart_rts_list[i].bank_idx == self->rx_pin->bank_idx) {
|
if (mcu_uart_rts_list[i].bank_idx == self->rx_pin->bank_idx) {
|
||||||
if (mcu_uart_rts_list[i].pin == rts) {
|
if (mcu_uart_rts_list[i].pin == rts) {
|
||||||
@ -146,7 +146,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||||||
mp_raise_ValueError(translate("Selected RTS pin not valid"));
|
mp_raise_ValueError(translate("Selected RTS pin not valid"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cts != mp_const_none) {
|
if (cts != NULL) {
|
||||||
for (uint32_t i=0; i < cts_count; ++i) {
|
for (uint32_t i=0; i < cts_count; ++i) {
|
||||||
if (mcu_uart_cts_list[i].bank_idx == self->rx_pin->bank_idx) {
|
if (mcu_uart_cts_list[i].bank_idx == self->rx_pin->bank_idx) {
|
||||||
if (mcu_uart_cts_list[i].pin == cts) {
|
if (mcu_uart_cts_list[i].pin == cts) {
|
||||||
@ -187,7 +187,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||||||
// Before we init, setup RS485 direction pin
|
// Before we init, setup RS485 direction pin
|
||||||
// ..unfortunately this isn't done by the driver library
|
// ..unfortunately this isn't done by the driver library
|
||||||
uint32_t modir = (self->uart->MODIR) & ~(LPUART_MODIR_TXRTSPOL_MASK | LPUART_MODIR_TXRTSE_MASK);
|
uint32_t modir = (self->uart->MODIR) & ~(LPUART_MODIR_TXRTSPOL_MASK | LPUART_MODIR_TXRTSE_MASK);
|
||||||
if (rs485_dir != mp_const_none) {
|
if (rs485_dir != NULL) {
|
||||||
modir |= LPUART_MODIR_TXRTSE_MASK;
|
modir |= LPUART_MODIR_TXRTSE_MASK;
|
||||||
if (rs485_invert)
|
if (rs485_invert)
|
||||||
modir |= LPUART_MODIR_TXRTSPOL_MASK;
|
modir |= LPUART_MODIR_TXRTSPOL_MASK;
|
||||||
|
@ -78,7 +78,7 @@ void common_hal_digitalio_digitalinout_never_reset(
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool common_hal_digitalio_digitalinout_deinited(digitalio_digitalinout_obj_t* self) {
|
bool common_hal_digitalio_digitalinout_deinited(digitalio_digitalinout_obj_t* self) {
|
||||||
return self->pin == mp_const_none;
|
return self->pin == NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void common_hal_digitalio_digitalinout_deinit(digitalio_digitalinout_obj_t* self) {
|
void common_hal_digitalio_digitalinout_deinit(digitalio_digitalinout_obj_t* self) {
|
||||||
@ -86,7 +86,7 @@ void common_hal_digitalio_digitalinout_deinit(digitalio_digitalinout_obj_t* self
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
reset_pin_number(self->pin->number);
|
reset_pin_number(self->pin->number);
|
||||||
self->pin = mp_const_none;
|
self->pin = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void common_hal_digitalio_digitalinout_switch_to_input(
|
void common_hal_digitalio_digitalinout_switch_to_input(
|
||||||
|
@ -49,7 +49,7 @@ uint8_t display_init_sequence[] = {
|
|||||||
|
|
||||||
void board_init(void) {
|
void board_init(void) {
|
||||||
busio_spi_obj_t* spi = &displays[0].fourwire_bus.inline_bus;
|
busio_spi_obj_t* spi = &displays[0].fourwire_bus.inline_bus;
|
||||||
common_hal_busio_spi_construct(spi, &pin_P0_14, &pin_P0_15, mp_const_none);
|
common_hal_busio_spi_construct(spi, &pin_P0_14, &pin_P0_15, NULL);
|
||||||
common_hal_busio_spi_never_reset(spi);
|
common_hal_busio_spi_never_reset(spi);
|
||||||
|
|
||||||
displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus;
|
displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus;
|
||||||
|
@ -49,7 +49,7 @@ uint8_t display_init_sequence[] = {
|
|||||||
|
|
||||||
void board_init(void) {
|
void board_init(void) {
|
||||||
busio_spi_obj_t* spi = &displays[0].fourwire_bus.inline_bus;
|
busio_spi_obj_t* spi = &displays[0].fourwire_bus.inline_bus;
|
||||||
common_hal_busio_spi_construct(spi, &pin_P0_11, &pin_P0_12, mp_const_none);
|
common_hal_busio_spi_construct(spi, &pin_P0_11, &pin_P0_12, NULL);
|
||||||
common_hal_busio_spi_never_reset(spi);
|
common_hal_busio_spi_never_reset(spi);
|
||||||
|
|
||||||
displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus;
|
displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus;
|
||||||
|
@ -55,7 +55,7 @@ void common_hal_analogio_analogin_construct(analogio_analogin_obj_t *self, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool common_hal_analogio_analogin_deinited(analogio_analogin_obj_t *self) {
|
bool common_hal_analogio_analogin_deinited(analogio_analogin_obj_t *self) {
|
||||||
return self->pin == mp_const_none;
|
return self->pin == NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void common_hal_analogio_analogin_deinit(analogio_analogin_obj_t *self) {
|
void common_hal_analogio_analogin_deinit(analogio_analogin_obj_t *self) {
|
||||||
@ -65,7 +65,7 @@ void common_hal_analogio_analogin_deinit(analogio_analogin_obj_t *self) {
|
|||||||
nrf_gpio_cfg_default(self->pin->number);
|
nrf_gpio_cfg_default(self->pin->number);
|
||||||
|
|
||||||
reset_pin_number(self->pin->number);
|
reset_pin_number(self->pin->number);
|
||||||
self->pin = mp_const_none;
|
self->pin = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t common_hal_analogio_analogin_get_value(analogio_analogin_obj_t *self) {
|
uint16_t common_hal_analogio_analogin_get_value(analogio_analogin_obj_t *self) {
|
||||||
|
@ -34,6 +34,7 @@ NRF_PDM_Type *nrf_pdm = NRF_PDM;
|
|||||||
|
|
||||||
static uint32_t dummy_buffer[4];
|
static uint32_t dummy_buffer[4];
|
||||||
|
|
||||||
|
// Caller validates that pins are free.
|
||||||
void common_hal_audiobusio_pdmin_construct(audiobusio_pdmin_obj_t* self,
|
void common_hal_audiobusio_pdmin_construct(audiobusio_pdmin_obj_t* self,
|
||||||
const mcu_pin_obj_t* clock_pin,
|
const mcu_pin_obj_t* clock_pin,
|
||||||
const mcu_pin_obj_t* data_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,
|
uint8_t bit_depth,
|
||||||
bool mono,
|
bool mono,
|
||||||
uint8_t oversample) {
|
uint8_t oversample) {
|
||||||
assert_pin_free(clock_pin);
|
|
||||||
assert_pin_free(data_pin);
|
|
||||||
claim_pin(clock_pin);
|
claim_pin(clock_pin);
|
||||||
claim_pin(data_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,
|
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) {
|
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);
|
self->pwm = pwmout_allocate(256, PWM_PRESCALER_PRESCALER_DIV_1, true, NULL, NULL);
|
||||||
if (!self->pwm) {
|
if (!self->pwm) {
|
||||||
mp_raise_RuntimeError(translate("All timers in use"));
|
mp_raise_RuntimeError(translate("All timers in use"));
|
||||||
|
@ -155,7 +155,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, const mcu_pin_obj_t *
|
|||||||
self->clock_pin_number = clock->number;
|
self->clock_pin_number = clock->number;
|
||||||
claim_pin(clock);
|
claim_pin(clock);
|
||||||
|
|
||||||
if (mosi != mp_const_none) {
|
if (mosi != NULL) {
|
||||||
config.mosi_pin = mosi->number;
|
config.mosi_pin = mosi->number;
|
||||||
self->MOSI_pin_number = mosi->number;
|
self->MOSI_pin_number = mosi->number;
|
||||||
claim_pin(mosi);
|
claim_pin(mosi);
|
||||||
@ -163,7 +163,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, const mcu_pin_obj_t *
|
|||||||
self->MOSI_pin_number = NO_PIN;
|
self->MOSI_pin_number = NO_PIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (miso != mp_const_none) {
|
if (miso != NULL) {
|
||||||
config.miso_pin = miso->number;
|
config.miso_pin = miso->number;
|
||||||
self->MISO_pin_number = mosi->number;
|
self->MISO_pin_number = mosi->number;
|
||||||
claim_pin(miso);
|
claim_pin(miso);
|
||||||
|
@ -135,7 +135,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||||||
uint32_t baudrate, uint8_t bits, uart_parity_t parity, uint8_t stop,
|
uint32_t baudrate, uint8_t bits, uart_parity_t parity, uint8_t stop,
|
||||||
mp_float_t timeout, uint16_t receiver_buffer_size) {
|
mp_float_t timeout, uint16_t receiver_buffer_size) {
|
||||||
|
|
||||||
if ((rts != mp_const_none) || (cts != mp_const_none) || (rs485_dir != mp_const_none) || (rs485_invert)) {
|
if ((rts != NULL) || (cts != NULL) || (rs485_dir != NULL) || (rs485_invert)) {
|
||||||
mp_raise_ValueError(translate("RTS/CTS/RS485 Not yet supported on this device"));
|
mp_raise_ValueError(translate("RTS/CTS/RS485 Not yet supported on this device"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||||||
mp_raise_ValueError(translate("All UART peripherals are in use"));
|
mp_raise_ValueError(translate("All UART peripherals are in use"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (tx == mp_const_none) && (rx == mp_const_none) ) {
|
if ( (tx == NULL) && (rx == NULL) ) {
|
||||||
mp_raise_ValueError(translate("tx and rx cannot both be None"));
|
mp_raise_ValueError(translate("tx and rx cannot both be None"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,8 +165,8 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
nrfx_uarte_config_t config = {
|
nrfx_uarte_config_t config = {
|
||||||
.pseltxd = (tx == mp_const_none) ? NRF_UARTE_PSEL_DISCONNECTED : tx->number,
|
.pseltxd = (tx == NULL) ? NRF_UARTE_PSEL_DISCONNECTED : tx->number,
|
||||||
.pselrxd = (rx == mp_const_none) ? NRF_UARTE_PSEL_DISCONNECTED : rx->number,
|
.pselrxd = (rx == NULL) ? NRF_UARTE_PSEL_DISCONNECTED : rx->number,
|
||||||
.pselcts = NRF_UARTE_PSEL_DISCONNECTED,
|
.pselcts = NRF_UARTE_PSEL_DISCONNECTED,
|
||||||
.pselrts = NRF_UARTE_PSEL_DISCONNECTED,
|
.pselrts = NRF_UARTE_PSEL_DISCONNECTED,
|
||||||
.p_context = self,
|
.p_context = self,
|
||||||
@ -181,7 +181,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||||||
_VERIFY_ERR(nrfx_uarte_init(self->uarte, &config, uart_callback_irq));
|
_VERIFY_ERR(nrfx_uarte_init(self->uarte, &config, uart_callback_irq));
|
||||||
|
|
||||||
// Init buffer for rx
|
// Init buffer for rx
|
||||||
if ( rx != mp_const_none ) {
|
if ( rx != NULL ) {
|
||||||
// Initially allocate the UART's buffer in the long-lived part of the
|
// Initially allocate the UART's buffer in the long-lived part of the
|
||||||
// heap. UARTs are generally long-lived objects, but the "make long-
|
// heap. UARTs are generally long-lived objects, but the "make long-
|
||||||
// lived" machinery is incapable of moving internal pointers like
|
// lived" machinery is incapable of moving internal pointers like
|
||||||
@ -200,7 +200,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||||||
claim_pin(rx);
|
claim_pin(rx);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( tx != mp_const_none ) {
|
if ( tx != NULL ) {
|
||||||
self->tx_pin_number = tx->number;
|
self->tx_pin_number = tx->number;
|
||||||
claim_pin(tx);
|
claim_pin(tx);
|
||||||
} else {
|
} else {
|
||||||
|
@ -46,7 +46,7 @@ digitalinout_result_t common_hal_digitalio_digitalinout_construct(
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool common_hal_digitalio_digitalinout_deinited(digitalio_digitalinout_obj_t *self) {
|
bool common_hal_digitalio_digitalinout_deinited(digitalio_digitalinout_obj_t *self) {
|
||||||
return self->pin == mp_const_none;
|
return self->pin == NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void common_hal_digitalio_digitalinout_deinit(digitalio_digitalinout_obj_t *self) {
|
void common_hal_digitalio_digitalinout_deinit(digitalio_digitalinout_obj_t *self) {
|
||||||
@ -56,7 +56,7 @@ void common_hal_digitalio_digitalinout_deinit(digitalio_digitalinout_obj_t *self
|
|||||||
nrf_gpio_cfg_default(self->pin->number);
|
nrf_gpio_cfg_default(self->pin->number);
|
||||||
|
|
||||||
reset_pin_number(self->pin->number);
|
reset_pin_number(self->pin->number);
|
||||||
self->pin = mp_const_none;
|
self->pin = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void common_hal_digitalio_digitalinout_switch_to_input(
|
void common_hal_digitalio_digitalinout_switch_to_input(
|
||||||
|
@ -62,7 +62,7 @@ void common_hal_analogio_analogin_construct(analogio_analogin_obj_t* self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool common_hal_analogio_analogin_deinited(analogio_analogin_obj_t *self) {
|
bool common_hal_analogio_analogin_deinited(analogio_analogin_obj_t *self) {
|
||||||
return self->pin == mp_const_none;
|
return self->pin == NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void common_hal_analogio_analogin_deinit(analogio_analogin_obj_t *self) {
|
void common_hal_analogio_analogin_deinit(analogio_analogin_obj_t *self) {
|
||||||
@ -70,7 +70,7 @@ void common_hal_analogio_analogin_deinit(analogio_analogin_obj_t *self) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
reset_pin_number(self->pin->port,self->pin->number);
|
reset_pin_number(self->pin->port,self->pin->number);
|
||||||
self->pin = mp_const_none;
|
self->pin = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t common_hal_analogio_analogin_get_value(analogio_analogin_obj_t *self) {
|
uint16_t common_hal_analogio_analogin_get_value(analogio_analogin_obj_t *self) {
|
||||||
|
@ -97,7 +97,7 @@ bool common_hal_analogio_analogout_deinited(analogio_analogout_obj_t *self) {
|
|||||||
void common_hal_analogio_analogout_deinit(analogio_analogout_obj_t *self) {
|
void common_hal_analogio_analogout_deinit(analogio_analogout_obj_t *self) {
|
||||||
#if HAS_DAC
|
#if HAS_DAC
|
||||||
reset_pin_number(self->pin->port,self->pin->number);
|
reset_pin_number(self->pin->port,self->pin->number);
|
||||||
self->pin = mp_const_none;
|
self->pin = NULL;
|
||||||
dac_on[self->dac_index] = false;
|
dac_on[self->dac_index] = false;
|
||||||
|
|
||||||
//turn off the DAC if both channels are off
|
//turn off the DAC if both channels are off
|
||||||
|
@ -144,7 +144,7 @@ void common_hal_busio_i2c_never_reset(busio_i2c_obj_t *self) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool common_hal_busio_i2c_deinited(busio_i2c_obj_t *self) {
|
bool common_hal_busio_i2c_deinited(busio_i2c_obj_t *self) {
|
||||||
return self->sda->pin == mp_const_none;
|
return self->sda == NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void common_hal_busio_i2c_deinit(busio_i2c_obj_t *self) {
|
void common_hal_busio_i2c_deinit(busio_i2c_obj_t *self) {
|
||||||
@ -158,8 +158,8 @@ void common_hal_busio_i2c_deinit(busio_i2c_obj_t *self) {
|
|||||||
|
|
||||||
reset_pin_number(self->sda->pin->port,self->sda->pin->number);
|
reset_pin_number(self->sda->pin->port,self->sda->pin->number);
|
||||||
reset_pin_number(self->scl->pin->port,self->scl->pin->number);
|
reset_pin_number(self->scl->pin->port,self->scl->pin->number);
|
||||||
self->sda = mp_const_none;
|
self->sda = NULL;
|
||||||
self->scl = mp_const_none;
|
self->scl = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool common_hal_busio_i2c_probe(busio_i2c_obj_t *self, uint8_t addr) {
|
bool common_hal_busio_i2c_probe(busio_i2c_obj_t *self, uint8_t addr) {
|
||||||
|
@ -113,7 +113,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
|
|||||||
for (uint i = 0; i < sck_len; i++) {
|
for (uint i = 0; i < sck_len; i++) {
|
||||||
if (mcu_spi_sck_list[i].pin == sck) {
|
if (mcu_spi_sck_list[i].pin == sck) {
|
||||||
//if both MOSI and MISO exist, loop search normally
|
//if both MOSI and MISO exist, loop search normally
|
||||||
if ((mosi != mp_const_none) && (miso != mp_const_none)) {
|
if ((mosi != NULL) && (miso != NULL)) {
|
||||||
//MOSI
|
//MOSI
|
||||||
for (uint j = 0; j < mosi_len; j++) {
|
for (uint j = 0; j < mosi_len; j++) {
|
||||||
if (mcu_spi_mosi_list[j].pin == mosi) {
|
if (mcu_spi_mosi_list[j].pin == mosi) {
|
||||||
@ -137,7 +137,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// if just MISO, reduce search
|
// if just MISO, reduce search
|
||||||
} else if (miso != mp_const_none) {
|
} else if (miso != NULL) {
|
||||||
for (uint j = 0; j < miso_len; j++) {
|
for (uint j = 0; j < miso_len; j++) {
|
||||||
if ((mcu_spi_miso_list[j].pin == miso) //only SCK and MISO need the same index
|
if ((mcu_spi_miso_list[j].pin == miso) //only SCK and MISO need the same index
|
||||||
&& (mcu_spi_sck_list[i].spi_index == mcu_spi_miso_list[j].spi_index)) {
|
&& (mcu_spi_sck_list[i].spi_index == mcu_spi_miso_list[j].spi_index)) {
|
||||||
@ -154,7 +154,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// if just MOSI, reduce search
|
// if just MOSI, reduce search
|
||||||
} else if (mosi != mp_const_none) {
|
} else if (mosi != NULL) {
|
||||||
for (uint j = 0; j < mosi_len; j++) {
|
for (uint j = 0; j < mosi_len; j++) {
|
||||||
if ((mcu_spi_mosi_list[j].pin == mosi) //only SCK and MOSI need the same index
|
if ((mcu_spi_mosi_list[j].pin == mosi) //only SCK and MOSI need the same index
|
||||||
&& (mcu_spi_sck_list[i].spi_index == mcu_spi_mosi_list[j].spi_index)) {
|
&& (mcu_spi_sck_list[i].spi_index == mcu_spi_mosi_list[j].spi_index)) {
|
||||||
@ -179,8 +179,8 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
|
|||||||
|
|
||||||
//handle typedef selection, errors
|
//handle typedef selection, errors
|
||||||
if ( (self->sck != NULL && self->mosi != NULL && self->miso != NULL) ||
|
if ( (self->sck != NULL && self->mosi != NULL && self->miso != NULL) ||
|
||||||
(self->sck != NULL && self->mosi != NULL && miso == mp_const_none) ||
|
(self->sck != NULL && self->mosi != NULL && miso == NULL) ||
|
||||||
(self->sck != NULL && self->miso != NULL && mosi == mp_const_none)) {
|
(self->sck != NULL && self->miso != NULL && mosi == NULL)) {
|
||||||
SPIx = mcu_spi_banks[self->sck->spi_index - 1];
|
SPIx = mcu_spi_banks[self->sck->spi_index - 1];
|
||||||
} else {
|
} else {
|
||||||
if (spi_taken) {
|
if (spi_taken) {
|
||||||
@ -269,7 +269,7 @@ void common_hal_busio_spi_never_reset(busio_spi_obj_t *self) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool common_hal_busio_spi_deinited(busio_spi_obj_t *self) {
|
bool common_hal_busio_spi_deinited(busio_spi_obj_t *self) {
|
||||||
return self->sck->pin == mp_const_none;
|
return self->sck->pin == NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void common_hal_busio_spi_deinit(busio_spi_obj_t *self) {
|
void common_hal_busio_spi_deinit(busio_spi_obj_t *self) {
|
||||||
@ -287,9 +287,9 @@ void common_hal_busio_spi_deinit(busio_spi_obj_t *self) {
|
|||||||
if (self->miso != NULL) {
|
if (self->miso != NULL) {
|
||||||
reset_pin_number(self->miso->pin->port,self->miso->pin->number);
|
reset_pin_number(self->miso->pin->port,self->miso->pin->number);
|
||||||
}
|
}
|
||||||
self->sck = mp_const_none;
|
self->sck = NULL;
|
||||||
self->mosi = mp_const_none;
|
self->mosi = NULL;
|
||||||
self->miso = mp_const_none;
|
self->miso = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool common_hal_busio_spi_configure(busio_spi_obj_t *self,
|
bool common_hal_busio_spi_configure(busio_spi_obj_t *self,
|
||||||
|
@ -86,12 +86,12 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||||||
bool uart_taken = false;
|
bool uart_taken = false;
|
||||||
uint8_t uart_index = 0; //origin 0 corrected
|
uint8_t uart_index = 0; //origin 0 corrected
|
||||||
|
|
||||||
if ((rts != mp_const_none) || (cts != mp_const_none) || (rs485_dir != mp_const_none) || (rs485_invert == true)) {
|
if ((rts != NULL) || (cts != NULL) || (rs485_dir != NULL) || (rs485_invert == true)) {
|
||||||
mp_raise_ValueError(translate("RTS/CTS/RS485 Not yet supported on this device"));
|
mp_raise_ValueError(translate("RTS/CTS/RS485 Not yet supported on this device"));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Can have both pins, or either
|
//Can have both pins, or either
|
||||||
if ((tx != mp_const_none) && (rx != mp_const_none)) {
|
if ((tx != NULL) && (rx != NULL)) {
|
||||||
//normal find loop if both pins exist
|
//normal find loop if both pins exist
|
||||||
for (uint i = 0; i < tx_len; i++) {
|
for (uint i = 0; i < tx_len; i++) {
|
||||||
if (mcu_uart_tx_list[i].pin == tx) {
|
if (mcu_uart_tx_list[i].pin == tx) {
|
||||||
@ -115,7 +115,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||||||
uart_index = self->tx->uart_index - 1;
|
uart_index = self->tx->uart_index - 1;
|
||||||
USARTx = assign_uart_or_throw(self, (self->tx != NULL && self->rx != NULL),
|
USARTx = assign_uart_or_throw(self, (self->tx != NULL && self->rx != NULL),
|
||||||
uart_index, uart_taken);
|
uart_index, uart_taken);
|
||||||
} else if (tx == mp_const_none) {
|
} else if (tx == NULL) {
|
||||||
//If there is no tx, run only rx
|
//If there is no tx, run only rx
|
||||||
for (uint i = 0; i < rx_len; i++) {
|
for (uint i = 0; i < rx_len; i++) {
|
||||||
if (mcu_uart_rx_list[i].pin == rx) {
|
if (mcu_uart_rx_list[i].pin == rx) {
|
||||||
@ -132,7 +132,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||||||
uart_index = self->rx->uart_index - 1;
|
uart_index = self->rx->uart_index - 1;
|
||||||
USARTx = assign_uart_or_throw(self, (self->rx != NULL),
|
USARTx = assign_uart_or_throw(self, (self->rx != NULL),
|
||||||
uart_index, uart_taken);
|
uart_index, uart_taken);
|
||||||
} else if (rx == mp_const_none) {
|
} else if (rx == NULL) {
|
||||||
//If there is no rx, run only tx
|
//If there is no rx, run only tx
|
||||||
for (uint i = 0; i < tx_len; i++) {
|
for (uint i = 0; i < tx_len; i++) {
|
||||||
if (mcu_uart_tx_list[i].pin == tx) {
|
if (mcu_uart_tx_list[i].pin == tx) {
|
||||||
@ -236,7 +236,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool common_hal_busio_uart_deinited(busio_uart_obj_t *self) {
|
bool common_hal_busio_uart_deinited(busio_uart_obj_t *self) {
|
||||||
return self->tx->pin == mp_const_none;
|
return self->tx->pin == NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void common_hal_busio_uart_deinit(busio_uart_obj_t *self) {
|
void common_hal_busio_uart_deinit(busio_uart_obj_t *self) {
|
||||||
@ -244,8 +244,8 @@ void common_hal_busio_uart_deinit(busio_uart_obj_t *self) {
|
|||||||
|
|
||||||
reset_pin_number(self->tx->pin->port,self->tx->pin->number);
|
reset_pin_number(self->tx->pin->port,self->tx->pin->number);
|
||||||
reset_pin_number(self->rx->pin->port,self->rx->pin->number);
|
reset_pin_number(self->rx->pin->port,self->rx->pin->number);
|
||||||
self->tx = mp_const_none;
|
self->tx = NULL;
|
||||||
self->rx = mp_const_none;
|
self->rx = NULL;
|
||||||
gc_free(self->rbuf.buf);
|
gc_free(self->rbuf.buf);
|
||||||
self->rbuf.size = 0;
|
self->rbuf.size = 0;
|
||||||
self->rbuf.iput = self->rbuf.iget = 0;
|
self->rbuf.iput = self->rbuf.iget = 0;
|
||||||
|
@ -54,7 +54,7 @@ digitalinout_result_t common_hal_digitalio_digitalinout_construct(
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool common_hal_digitalio_digitalinout_deinited(digitalio_digitalinout_obj_t *self) {
|
bool common_hal_digitalio_digitalinout_deinited(digitalio_digitalinout_obj_t *self) {
|
||||||
return self->pin == mp_const_none;
|
return self->pin == NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void common_hal_digitalio_digitalinout_deinit(digitalio_digitalinout_obj_t *self) {
|
void common_hal_digitalio_digitalinout_deinit(digitalio_digitalinout_obj_t *self) {
|
||||||
@ -63,7 +63,7 @@ void common_hal_digitalio_digitalinout_deinit(digitalio_digitalinout_obj_t *self
|
|||||||
}
|
}
|
||||||
|
|
||||||
reset_pin_number(self->pin->port, self->pin->number);
|
reset_pin_number(self->pin->port, self->pin->number);
|
||||||
self->pin = mp_const_none;
|
self->pin = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void common_hal_digitalio_digitalinout_switch_to_input(
|
void common_hal_digitalio_digitalinout_switch_to_input(
|
||||||
|
@ -240,7 +240,7 @@ void common_hal_pulseio_pwmout_reset_ok(pulseio_pwmout_obj_t *self) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool common_hal_pulseio_pwmout_deinited(pulseio_pwmout_obj_t* self) {
|
bool common_hal_pulseio_pwmout_deinited(pulseio_pwmout_obj_t* self) {
|
||||||
return self->tim == mp_const_none;
|
return self->tim == NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t* self) {
|
void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t* self) {
|
||||||
@ -255,7 +255,7 @@ void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t* self) {
|
|||||||
HAL_TIM_PWM_Stop(&self->handle, self->channel);
|
HAL_TIM_PWM_Stop(&self->handle, self->channel);
|
||||||
}
|
}
|
||||||
reset_pin_number(self->tim->pin->port,self->tim->pin->number);
|
reset_pin_number(self->tim->pin->port,self->tim->pin->number);
|
||||||
self->tim = mp_const_none;
|
self->tim = NULL;
|
||||||
|
|
||||||
//if reserved timer has no active channels, we can disable it
|
//if reserved timer has no active channels, we can disable it
|
||||||
if (!reserved_tim[self->tim->tim_index - 1]) {
|
if (!reserved_tim[self->tim->tim_index - 1]) {
|
||||||
|
@ -63,16 +63,13 @@ STATIC mp_obj_t analogio_analogin_make_new(const mp_obj_type_t *type,
|
|||||||
mp_arg_check_num(n_args, kw_args, 1, 1, false);
|
mp_arg_check_num(n_args, kw_args, 1, 1, false);
|
||||||
|
|
||||||
// 1st argument is the pin
|
// 1st argument is the pin
|
||||||
mp_obj_t pin_obj = args[0];
|
const mcu_pin_obj_t *pin = validate_obj_is_free_pin(args[0]);
|
||||||
assert_pin(pin_obj, false);
|
|
||||||
|
|
||||||
analogio_analogin_obj_t *self = m_new_obj(analogio_analogin_obj_t);
|
analogio_analogin_obj_t *self = m_new_obj(analogio_analogin_obj_t);
|
||||||
self->base.type = &analogio_analogin_type;
|
self->base.type = &analogio_analogin_type;
|
||||||
const mcu_pin_obj_t *pin = MP_OBJ_TO_PTR(pin_obj);
|
|
||||||
assert_pin_free(pin);
|
|
||||||
common_hal_analogio_analogin_construct(self, pin);
|
common_hal_analogio_analogin_construct(self, pin);
|
||||||
|
|
||||||
return (mp_obj_t) self;
|
return MP_OBJ_FROM_PTR(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
//| .. method:: deinit()
|
//| .. method:: deinit()
|
||||||
|
@ -62,15 +62,13 @@ STATIC mp_obj_t analogio_analogout_make_new(const mp_obj_type_t *type, mp_uint_t
|
|||||||
// check arguments
|
// check arguments
|
||||||
mp_arg_check_num(n_args, kw_args, 1, 1, false);
|
mp_arg_check_num(n_args, kw_args, 1, 1, false);
|
||||||
|
|
||||||
assert_pin(args[0], false);
|
const mcu_pin_obj_t *pin = validate_obj_is_free_pin(args[0]);
|
||||||
const mcu_pin_obj_t *pin = MP_OBJ_TO_PTR(args[0]);
|
|
||||||
|
|
||||||
analogio_analogout_obj_t *self = m_new_obj(analogio_analogout_obj_t);
|
analogio_analogout_obj_t *self = m_new_obj(analogio_analogout_obj_t);
|
||||||
self->base.type = &analogio_analogout_type;
|
self->base.type = &analogio_analogout_type;
|
||||||
assert_pin_free(pin);
|
|
||||||
common_hal_analogio_analogout_construct(self, pin);
|
common_hal_analogio_analogout_construct(self, pin);
|
||||||
|
|
||||||
return self;
|
return MP_OBJ_FROM_PTR(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
//| .. method:: deinit()
|
//| .. method:: deinit()
|
||||||
|
@ -105,17 +105,9 @@ STATIC mp_obj_t audiobusio_i2sout_make_new(const mp_obj_type_t *type, size_t n_a
|
|||||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
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_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||||
|
|
||||||
mp_obj_t bit_clock_obj = args[ARG_bit_clock].u_obj;
|
const mcu_pin_obj_t *bit_clock = validate_obj_is_free_pin(args[ARG_bit_clock].u_obj);
|
||||||
assert_pin(bit_clock_obj, false);
|
const mcu_pin_obj_t *word_select = validate_obj_is_free_pin(args[ARG_word_select].u_obj);
|
||||||
const mcu_pin_obj_t *bit_clock = MP_OBJ_TO_PTR(bit_clock_obj);
|
const mcu_pin_obj_t *data = validate_obj_is_free_pin(args[ARG_data].u_obj);
|
||||||
|
|
||||||
mp_obj_t word_select_obj = args[ARG_word_select].u_obj;
|
|
||||||
assert_pin(word_select_obj, false);
|
|
||||||
const mcu_pin_obj_t *word_select = MP_OBJ_TO_PTR(word_select_obj);
|
|
||||||
|
|
||||||
mp_obj_t data_obj = args[ARG_data].u_obj;
|
|
||||||
assert_pin(data_obj, false);
|
|
||||||
const mcu_pin_obj_t *data = MP_OBJ_TO_PTR(data_obj);
|
|
||||||
|
|
||||||
audiobusio_i2sout_obj_t *self = m_new_obj_with_finaliser(audiobusio_i2sout_obj_t);
|
audiobusio_i2sout_obj_t *self = m_new_obj_with_finaliser(audiobusio_i2sout_obj_t);
|
||||||
self->base.type = &audiobusio_i2sout_type;
|
self->base.type = &audiobusio_i2sout_type;
|
||||||
|
@ -104,15 +104,8 @@ STATIC mp_obj_t audiobusio_pdmin_make_new(const mp_obj_type_t *type, size_t n_ar
|
|||||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
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_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||||
|
|
||||||
mp_obj_t clock_pin_obj = args[ARG_clock_pin].u_obj;
|
const mcu_pin_obj_t *clock_pin = validate_obj_is_free_pin(args[ARG_clock_pin].u_obj);
|
||||||
assert_pin(clock_pin_obj, false);
|
const mcu_pin_obj_t *data_pin = validate_obj_is_free_pin(args[ARG_data_pin].u_obj);
|
||||||
const mcu_pin_obj_t *clock_pin = MP_OBJ_TO_PTR(clock_pin_obj);
|
|
||||||
assert_pin_free(clock_pin);
|
|
||||||
|
|
||||||
mp_obj_t data_pin_obj = args[ARG_data_pin].u_obj;
|
|
||||||
assert_pin(data_pin_obj, false);
|
|
||||||
const mcu_pin_obj_t *data_pin = MP_OBJ_TO_PTR(data_pin_obj);
|
|
||||||
assert_pin_free(data_pin);
|
|
||||||
|
|
||||||
// create PDMIn object from the given pin
|
// create PDMIn object from the given pin
|
||||||
audiobusio_pdmin_obj_t *self = m_new_obj(audiobusio_pdmin_obj_t);
|
audiobusio_pdmin_obj_t *self = m_new_obj(audiobusio_pdmin_obj_t);
|
||||||
|
@ -104,16 +104,8 @@ STATIC mp_obj_t audioio_audioout_make_new(const mp_obj_type_t *type, size_t n_ar
|
|||||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
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_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||||
|
|
||||||
mp_obj_t left_channel_obj = args[ARG_left_channel].u_obj;
|
const mcu_pin_obj_t *left_channel_pin = validate_obj_is_free_pin(args[ARG_left_channel].u_obj);
|
||||||
assert_pin(left_channel_obj, false);
|
const mcu_pin_obj_t *right_channel_pin = validate_obj_is_free_pin_or_none(args[ARG_right_channel].u_obj);
|
||||||
const mcu_pin_obj_t *left_channel_pin = MP_OBJ_TO_PTR(left_channel_obj);
|
|
||||||
|
|
||||||
mp_obj_t right_channel_obj = args[ARG_right_channel].u_obj;
|
|
||||||
const mcu_pin_obj_t *right_channel_pin = NULL;
|
|
||||||
if (right_channel_obj != mp_const_none) {
|
|
||||||
assert_pin(right_channel_obj, false);
|
|
||||||
right_channel_pin = MP_OBJ_TO_PTR(right_channel_obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
// create AudioOut object from the given pin
|
// create AudioOut object from the given pin
|
||||||
audioio_audioout_obj_t *self = m_new_obj(audioio_audioout_obj_t);
|
audioio_audioout_obj_t *self = m_new_obj(audioio_audioout_obj_t);
|
||||||
|
@ -107,16 +107,8 @@ STATIC mp_obj_t audiopwmio_pwmaudioout_make_new(const mp_obj_type_t *type, size_
|
|||||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
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_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||||
|
|
||||||
mp_obj_t left_channel_obj = args[ARG_left_channel].u_obj;
|
const mcu_pin_obj_t *left_channel_pin = validate_obj_is_free_pin(args[ARG_left_channel].u_obj);
|
||||||
assert_pin(left_channel_obj, false);
|
const mcu_pin_obj_t *right_channel_pin = validate_obj_is_free_pin_or_none(args[ARG_right_channel].u_obj);
|
||||||
const mcu_pin_obj_t *left_channel_pin = MP_OBJ_TO_PTR(left_channel_obj);
|
|
||||||
|
|
||||||
mp_obj_t right_channel_obj = args[ARG_right_channel].u_obj;
|
|
||||||
const mcu_pin_obj_t *right_channel_pin = NULL;
|
|
||||||
if (right_channel_obj != mp_const_none) {
|
|
||||||
assert_pin(right_channel_obj, false);
|
|
||||||
right_channel_pin = MP_OBJ_TO_PTR(right_channel_obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
// create AudioOut object from the given pin
|
// create AudioOut object from the given pin
|
||||||
audiopwmio_pwmaudioout_obj_t *self = m_new_obj(audiopwmio_pwmaudioout_obj_t);
|
audiopwmio_pwmaudioout_obj_t *self = m_new_obj(audiopwmio_pwmaudioout_obj_t);
|
||||||
|
@ -63,10 +63,9 @@ STATIC mp_obj_t bitbangio_i2c_make_new(const mp_obj_type_t *type, size_t n_args,
|
|||||||
};
|
};
|
||||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
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_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||||
assert_pin(args[ARG_scl].u_obj, false);
|
|
||||||
assert_pin(args[ARG_sda].u_obj, false);
|
const mcu_pin_obj_t* scl = validate_obj_is_free_pin(args[ARG_scl].u_obj);
|
||||||
const mcu_pin_obj_t* scl = MP_OBJ_TO_PTR(args[ARG_scl].u_obj);
|
const mcu_pin_obj_t* sda = validate_obj_is_free_pin(args[ARG_sda].u_obj);
|
||||||
const mcu_pin_obj_t* sda = MP_OBJ_TO_PTR(args[ARG_sda].u_obj);
|
|
||||||
|
|
||||||
bitbangio_i2c_obj_t *self = m_new_obj(bitbangio_i2c_obj_t);
|
bitbangio_i2c_obj_t *self = m_new_obj(bitbangio_i2c_obj_t);
|
||||||
self->base.type = &bitbangio_i2c_type;
|
self->base.type = &bitbangio_i2c_type;
|
||||||
|
@ -69,9 +69,8 @@ STATIC mp_obj_t bitbangio_onewire_make_new(const mp_obj_type_t *type, size_t n_a
|
|||||||
};
|
};
|
||||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
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_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||||
assert_pin(args[ARG_pin].u_obj, false);
|
|
||||||
const mcu_pin_obj_t* pin = MP_OBJ_TO_PTR(args[ARG_pin].u_obj);
|
const mcu_pin_obj_t* pin = validate_obj_is_free_pin(args[ARG_pin].u_obj);
|
||||||
assert_pin_free(pin);
|
|
||||||
|
|
||||||
bitbangio_onewire_obj_t *self = m_new_obj(bitbangio_onewire_obj_t);
|
bitbangio_onewire_obj_t *self = m_new_obj(bitbangio_onewire_obj_t);
|
||||||
self->base.type = &bitbangio_onewire_type;
|
self->base.type = &bitbangio_onewire_type;
|
||||||
|
@ -71,12 +71,10 @@ STATIC mp_obj_t bitbangio_spi_make_new(const mp_obj_type_t *type, size_t n_args,
|
|||||||
};
|
};
|
||||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
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_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||||
assert_pin(args[ARG_clock].u_obj, false);
|
|
||||||
assert_pin(args[ARG_MOSI].u_obj, true);
|
const mcu_pin_obj_t* clock = validate_obj_is_free_pin(args[ARG_clock].u_obj);
|
||||||
assert_pin(args[ARG_MISO].u_obj, true);
|
const mcu_pin_obj_t* mosi = validate_obj_is_free_pin_or_none(args[ARG_MOSI].u_obj);
|
||||||
const mcu_pin_obj_t* clock = MP_OBJ_TO_PTR(args[ARG_clock].u_obj);
|
const mcu_pin_obj_t* miso = validate_obj_is_free_pin_or_none(args[ARG_MISO].u_obj);
|
||||||
const mcu_pin_obj_t* mosi = MP_OBJ_TO_PTR(args[ARG_MOSI].u_obj);
|
|
||||||
const mcu_pin_obj_t* miso = MP_OBJ_TO_PTR(args[ARG_MISO].u_obj);
|
|
||||||
|
|
||||||
bitbangio_spi_obj_t *self = m_new_obj(bitbangio_spi_obj_t);
|
bitbangio_spi_obj_t *self = m_new_obj(bitbangio_spi_obj_t);
|
||||||
self->base.type = &bitbangio_spi_type;
|
self->base.type = &bitbangio_spi_type;
|
||||||
|
@ -76,12 +76,10 @@ STATIC mp_obj_t busio_i2c_make_new(const mp_obj_type_t *type, size_t n_args, con
|
|||||||
};
|
};
|
||||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
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_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||||
assert_pin(args[ARG_scl].u_obj, false);
|
|
||||||
assert_pin(args[ARG_sda].u_obj, false);
|
const mcu_pin_obj_t* scl = validate_obj_is_free_pin(args[ARG_scl].u_obj);
|
||||||
const mcu_pin_obj_t* scl = MP_OBJ_TO_PTR(args[ARG_scl].u_obj);
|
const mcu_pin_obj_t* sda = validate_obj_is_free_pin(args[ARG_sda].u_obj);
|
||||||
assert_pin_free(scl);
|
|
||||||
const mcu_pin_obj_t* sda = MP_OBJ_TO_PTR(args[ARG_sda].u_obj);
|
|
||||||
assert_pin_free(sda);
|
|
||||||
common_hal_busio_i2c_construct(self, scl, sda, args[ARG_frequency].u_int, args[ARG_timeout].u_int);
|
common_hal_busio_i2c_construct(self, scl, sda, args[ARG_frequency].u_int, args[ARG_timeout].u_int);
|
||||||
return (mp_obj_t)self;
|
return (mp_obj_t)self;
|
||||||
}
|
}
|
||||||
|
@ -69,9 +69,7 @@ STATIC mp_obj_t busio_onewire_make_new(const mp_obj_type_t *type, size_t n_args,
|
|||||||
};
|
};
|
||||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
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_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||||
assert_pin(args[ARG_pin].u_obj, false);
|
const mcu_pin_obj_t* pin = validate_obj_is_free_pin(args[ARG_pin].u_obj);
|
||||||
const mcu_pin_obj_t* pin = MP_OBJ_TO_PTR(args[ARG_pin].u_obj);
|
|
||||||
assert_pin_free(pin);
|
|
||||||
|
|
||||||
busio_onewire_obj_t *self = m_new_obj(busio_onewire_obj_t);
|
busio_onewire_obj_t *self = m_new_obj(busio_onewire_obj_t);
|
||||||
self->base.type = &busio_onewire_type;
|
self->base.type = &busio_onewire_type;
|
||||||
|
@ -89,17 +89,13 @@ STATIC mp_obj_t busio_spi_make_new(const mp_obj_type_t *type, size_t n_args, con
|
|||||||
};
|
};
|
||||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
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_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||||
assert_pin(args[ARG_clock].u_obj, false);
|
|
||||||
assert_pin(args[ARG_MOSI].u_obj, true);
|
const mcu_pin_obj_t* clock = validate_obj_is_free_pin(args[ARG_clock].u_obj);
|
||||||
assert_pin(args[ARG_MISO].u_obj, true);
|
const mcu_pin_obj_t* mosi = validate_obj_is_free_pin_or_none(args[ARG_MOSI].u_obj);
|
||||||
const mcu_pin_obj_t* clock = MP_OBJ_TO_PTR(args[ARG_clock].u_obj);
|
const mcu_pin_obj_t* miso = validate_obj_is_free_pin_or_none(args[ARG_MISO].u_obj);
|
||||||
assert_pin_free(clock);
|
|
||||||
const mcu_pin_obj_t* mosi = MP_OBJ_TO_PTR(args[ARG_MOSI].u_obj);
|
|
||||||
assert_pin_free(mosi);
|
|
||||||
const mcu_pin_obj_t* miso = MP_OBJ_TO_PTR(args[ARG_MISO].u_obj);
|
|
||||||
assert_pin_free(miso);
|
|
||||||
common_hal_busio_spi_construct(self, clock, mosi, miso);
|
common_hal_busio_spi_construct(self, clock, mosi, miso);
|
||||||
return (mp_obj_t)self;
|
return MP_OBJ_FROM_PTR(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
//| .. method:: deinit()
|
//| .. method:: deinit()
|
||||||
|
@ -105,13 +105,12 @@ STATIC mp_obj_t busio_uart_make_new(const mp_obj_type_t *type, size_t n_args, co
|
|||||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
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_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||||
|
|
||||||
assert_pin(args[ARG_rx].u_obj, true);
|
const mcu_pin_obj_t* rx = validate_obj_is_free_pin_or_none(args[ARG_rx].u_obj);
|
||||||
const mcu_pin_obj_t* rx = MP_OBJ_TO_PTR(args[ARG_rx].u_obj);
|
const mcu_pin_obj_t* tx = validate_obj_is_free_pin_or_none(args[ARG_tx].u_obj);
|
||||||
assert_pin_free(rx);
|
|
||||||
|
|
||||||
assert_pin(args[ARG_tx].u_obj, true);
|
if ( (tx == NULL) && (rx == NULL) ) {
|
||||||
const mcu_pin_obj_t* tx = MP_OBJ_TO_PTR(args[ARG_tx].u_obj);
|
mp_raise_ValueError(translate("tx and rx cannot both be None"));
|
||||||
assert_pin_free(tx);
|
}
|
||||||
|
|
||||||
uint8_t bits = args[ARG_bits].u_int;
|
uint8_t bits = args[ARG_bits].u_int;
|
||||||
if (bits < 7 || bits > 9) {
|
if (bits < 7 || bits > 9) {
|
||||||
@ -133,12 +132,11 @@ STATIC mp_obj_t busio_uart_make_new(const mp_obj_type_t *type, size_t n_args, co
|
|||||||
mp_float_t timeout = mp_obj_get_float(args[ARG_timeout].u_obj);
|
mp_float_t timeout = mp_obj_get_float(args[ARG_timeout].u_obj);
|
||||||
validate_timeout(timeout);
|
validate_timeout(timeout);
|
||||||
|
|
||||||
const mcu_pin_obj_t* rts = MP_OBJ_TO_PTR(args[ARG_rts].u_obj);
|
const mcu_pin_obj_t* rts = validate_obj_is_free_pin_or_none(args[ARG_rts].u_obj);
|
||||||
|
const mcu_pin_obj_t* cts = validate_obj_is_free_pin_or_none(args[ARG_cts].u_obj);
|
||||||
|
const mcu_pin_obj_t* rs485_dir = validate_obj_is_free_pin_or_none(args[ARG_rs485_dir].u_obj);
|
||||||
|
|
||||||
const mcu_pin_obj_t* cts = MP_OBJ_TO_PTR(args[ARG_cts].u_obj);
|
const bool rs485_invert = args[ARG_rs485_invert].u_bool;
|
||||||
|
|
||||||
const mcu_pin_obj_t* rs485_dir = args[ARG_rs485_dir].u_obj;
|
|
||||||
bool rs485_invert = args[ARG_rs485_invert].u_bool;
|
|
||||||
|
|
||||||
common_hal_busio_uart_construct(self, tx, rx, rts, cts, rs485_dir, rs485_invert,
|
common_hal_busio_uart_construct(self, tx, rx, rts, cts, rs485_dir, rs485_invert,
|
||||||
args[ARG_baudrate].u_int, bits, parity, stop, timeout,
|
args[ARG_baudrate].u_int, bits, parity, stop, timeout,
|
||||||
|
@ -68,12 +68,10 @@ STATIC mp_obj_t digitalio_digitalinout_make_new(const mp_obj_type_t *type,
|
|||||||
digitalio_digitalinout_obj_t *self = m_new_obj(digitalio_digitalinout_obj_t);
|
digitalio_digitalinout_obj_t *self = m_new_obj(digitalio_digitalinout_obj_t);
|
||||||
self->base.type = &digitalio_digitalinout_type;
|
self->base.type = &digitalio_digitalinout_type;
|
||||||
|
|
||||||
assert_pin(args[0], false);
|
mcu_pin_obj_t *pin = validate_obj_is_free_pin(args[0]);
|
||||||
mcu_pin_obj_t *pin = MP_OBJ_TO_PTR(args[0]);
|
|
||||||
assert_pin_free(pin);
|
|
||||||
common_hal_digitalio_digitalinout_construct(self, pin);
|
common_hal_digitalio_digitalinout_construct(self, pin);
|
||||||
|
|
||||||
return (mp_obj_t)self;
|
return MP_OBJ_FROM_PTR(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
//| .. method:: deinit()
|
//| .. method:: deinit()
|
||||||
|
@ -141,13 +141,7 @@ STATIC mp_obj_t displayio_display_make_new(const mp_obj_type_t *type, size_t n_a
|
|||||||
mp_buffer_info_t bufinfo;
|
mp_buffer_info_t bufinfo;
|
||||||
mp_get_buffer_raise(args[ARG_init_sequence].u_obj, &bufinfo, MP_BUFFER_READ);
|
mp_get_buffer_raise(args[ARG_init_sequence].u_obj, &bufinfo, MP_BUFFER_READ);
|
||||||
|
|
||||||
mp_obj_t backlight_pin_obj = args[ARG_backlight_pin].u_obj;
|
const mcu_pin_obj_t* backlight_pin = validate_obj_is_free_pin_or_none(args[ARG_backlight_pin].u_obj);
|
||||||
assert_pin(backlight_pin_obj, true);
|
|
||||||
const mcu_pin_obj_t* backlight_pin = NULL;
|
|
||||||
if (backlight_pin_obj != NULL && backlight_pin_obj != mp_const_none) {
|
|
||||||
backlight_pin = MP_OBJ_TO_PTR(backlight_pin_obj);
|
|
||||||
assert_pin_free(backlight_pin);
|
|
||||||
}
|
|
||||||
|
|
||||||
mp_float_t brightness = mp_obj_get_float(args[ARG_brightness].u_obj);
|
mp_float_t brightness = mp_obj_get_float(args[ARG_brightness].u_obj);
|
||||||
|
|
||||||
|
@ -129,13 +129,7 @@ STATIC mp_obj_t displayio_epaperdisplay_make_new(const mp_obj_type_t *type, size
|
|||||||
mp_get_buffer_raise(args[ARG_stop_sequence].u_obj, &stop_bufinfo, MP_BUFFER_READ);
|
mp_get_buffer_raise(args[ARG_stop_sequence].u_obj, &stop_bufinfo, MP_BUFFER_READ);
|
||||||
|
|
||||||
|
|
||||||
mp_obj_t busy_pin_obj = args[ARG_busy_pin].u_obj;
|
const mcu_pin_obj_t* busy_pin = validate_obj_is_free_pin_or_none(args[ARG_busy_pin].u_obj);
|
||||||
assert_pin(busy_pin_obj, true);
|
|
||||||
const mcu_pin_obj_t* busy_pin = NULL;
|
|
||||||
if (busy_pin_obj != NULL && busy_pin_obj != mp_const_none) {
|
|
||||||
busy_pin = MP_OBJ_TO_PTR(busy_pin_obj);
|
|
||||||
assert_pin_free(busy_pin);
|
|
||||||
}
|
|
||||||
|
|
||||||
mp_int_t rotation = args[ARG_rotation].u_int;
|
mp_int_t rotation = args[ARG_rotation].u_int;
|
||||||
if (rotation % 90 != 0) {
|
if (rotation % 90 != 0) {
|
||||||
|
@ -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_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_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;
|
mcu_pin_obj_t *command = validate_obj_is_free_pin(args[ARG_command].u_obj);
|
||||||
mp_obj_t chip_select = args[ARG_chip_select].u_obj;
|
mcu_pin_obj_t *chip_select = validate_obj_is_free_pin(args[ARG_chip_select].u_obj);
|
||||||
assert_pin_free(command);
|
mcu_pin_obj_t *reset = validate_obj_is_free_pin_or_none(args[ARG_reset].u_obj);
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
displayio_fourwire_obj_t* self = NULL;
|
displayio_fourwire_obj_t* self = NULL;
|
||||||
mp_obj_t spi = args[ARG_spi_bus].u_obj;
|
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_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_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;
|
mcu_pin_obj_t *reset = validate_obj_is_free_pin_or_none(args[ARG_reset].u_obj);
|
||||||
if (reset != mp_const_none) {
|
|
||||||
assert_pin_free(reset);
|
|
||||||
} else {
|
|
||||||
reset = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
displayio_i2cdisplay_obj_t* self = NULL;
|
displayio_i2cdisplay_obj_t* self = NULL;
|
||||||
mp_obj_t i2c = args[ARG_i2c_bus].u_obj;
|
mp_obj_t i2c = args[ARG_i2c_bus].u_obj;
|
||||||
|
@ -71,23 +71,17 @@ STATIC mp_obj_t displayio_parallelbus_make_new(const mp_obj_type_t *type, size_t
|
|||||||
{ MP_QSTR_chip_select, MP_ARG_OBJ | MP_ARG_KW_ONLY | MP_ARG_REQUIRED },
|
{ MP_QSTR_chip_select, MP_ARG_OBJ | MP_ARG_KW_ONLY | MP_ARG_REQUIRED },
|
||||||
{ MP_QSTR_write, MP_ARG_OBJ | MP_ARG_KW_ONLY | MP_ARG_REQUIRED },
|
{ MP_QSTR_write, MP_ARG_OBJ | MP_ARG_KW_ONLY | MP_ARG_REQUIRED },
|
||||||
{ MP_QSTR_read, MP_ARG_OBJ | MP_ARG_KW_ONLY | MP_ARG_REQUIRED },
|
{ MP_QSTR_read, MP_ARG_OBJ | MP_ARG_KW_ONLY | MP_ARG_REQUIRED },
|
||||||
{ MP_QSTR_reset, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = mp_const_none} },
|
{ MP_QSTR_reset, MP_ARG_OBJ | MP_ARG_KW_ONLY | MP_ARG_REQUIRED },
|
||||||
};
|
};
|
||||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
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_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;
|
mcu_pin_obj_t *data0 = validate_obj_is_free_pin(args[ARG_data0].u_obj);
|
||||||
mp_obj_t command = args[ARG_command].u_obj;
|
mcu_pin_obj_t *command = validate_obj_is_free_pin(args[ARG_command].u_obj);
|
||||||
mp_obj_t chip_select = args[ARG_chip_select].u_obj;
|
mcu_pin_obj_t *chip_select = validate_obj_is_free_pin(args[ARG_chip_select].u_obj);
|
||||||
mp_obj_t write = args[ARG_write].u_obj;
|
mcu_pin_obj_t *write = validate_obj_is_free_pin(args[ARG_write].u_obj);
|
||||||
mp_obj_t read = args[ARG_read].u_obj;
|
mcu_pin_obj_t *read = validate_obj_is_free_pin(args[ARG_read].u_obj);
|
||||||
mp_obj_t reset = args[ARG_reset].u_obj;
|
mcu_pin_obj_t *reset = validate_obj_is_free_pin(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);
|
|
||||||
|
|
||||||
displayio_parallelbus_obj_t* self = NULL;
|
displayio_parallelbus_obj_t* self = NULL;
|
||||||
for (uint8_t i = 0; i < CIRCUITPY_DISPLAY_LIMIT; i++) {
|
for (uint8_t i = 0; i < CIRCUITPY_DISPLAY_LIMIT; i++) {
|
||||||
|
@ -87,9 +87,7 @@ STATIC mp_obj_t frequencyio_frequencyin_make_new(const mp_obj_type_t *type, size
|
|||||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
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_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||||
|
|
||||||
assert_pin(args[ARG_pin].u_obj, false);
|
mcu_pin_obj_t* pin = validate_obj_is_free_pin(args[ARG_pin].u_obj);
|
||||||
mcu_pin_obj_t* pin = MP_OBJ_TO_PTR(args[ARG_pin].u_obj);
|
|
||||||
assert_pin_free(pin);
|
|
||||||
|
|
||||||
const uint16_t capture_period = args[ARG_capture_period].u_int;
|
const uint16_t capture_period = args[ARG_capture_period].u_int;
|
||||||
|
|
||||||
|
@ -77,12 +77,8 @@ STATIC mp_obj_t i2cslave_i2c_slave_make_new(const mp_obj_type_t *type, size_t n_
|
|||||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
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_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||||
|
|
||||||
assert_pin(args[ARG_scl].u_obj, false);
|
const mcu_pin_obj_t* scl = validate_obj_is_free_pin(args[ARG_scl].u_obj);
|
||||||
assert_pin(args[ARG_sda].u_obj, false);
|
const mcu_pin_obj_t* sda = validate_obj_is_free_pin(args[ARG_sda].u_obj);
|
||||||
const mcu_pin_obj_t* scl = MP_OBJ_TO_PTR(args[ARG_scl].u_obj);
|
|
||||||
assert_pin_free(scl);
|
|
||||||
const mcu_pin_obj_t* sda = MP_OBJ_TO_PTR(args[ARG_sda].u_obj);
|
|
||||||
assert_pin_free(sda);
|
|
||||||
|
|
||||||
mp_obj_iter_buf_t iter_buf;
|
mp_obj_iter_buf_t iter_buf;
|
||||||
mp_obj_t iterable = mp_getiter(args[ARG_addresses].u_obj, &iter_buf);
|
mp_obj_t iterable = mp_getiter(args[ARG_addresses].u_obj, &iter_buf);
|
||||||
|
@ -84,10 +84,35 @@ const mp_obj_type_t mcu_pin_type = {
|
|||||||
.print = mcu_pin_print
|
.print = mcu_pin_print
|
||||||
};
|
};
|
||||||
|
|
||||||
void assert_pin(mp_obj_t obj, bool none_ok) {
|
mcu_pin_obj_t *validate_obj_is_pin(mp_obj_t obj) {
|
||||||
if ((obj != mp_const_none || !none_ok) && !MP_OBJ_IS_TYPE(obj, &mcu_pin_type)) {
|
if (!MP_OBJ_IS_TYPE(obj, &mcu_pin_type)) {
|
||||||
mp_raise_TypeError_varg(translate("Expected a %q"), mcu_pin_type.name);
|
mp_raise_TypeError_varg(translate("Expected a %q"), mcu_pin_type.name);
|
||||||
}
|
}
|
||||||
|
return MP_OBJ_TO_PTR(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate that the obj is a pin or None. Return an mcu_pin_obj_t* or NULL, correspondingly.
|
||||||
|
mcu_pin_obj_t *validate_obj_is_pin_or_none(mp_obj_t obj) {
|
||||||
|
if (obj == mp_const_none) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return validate_obj_is_pin(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
mcu_pin_obj_t *validate_obj_is_free_pin(mp_obj_t obj) {
|
||||||
|
mcu_pin_obj_t *pin = validate_obj_is_pin(obj);
|
||||||
|
assert_pin_free(pin);
|
||||||
|
return pin;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate that the obj is a free pin or None. Return an mcu_pin_obj_t* or NULL, correspondingly.
|
||||||
|
mcu_pin_obj_t *validate_obj_is_free_pin_or_none(mp_obj_t obj) {
|
||||||
|
if (obj == mp_const_none) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
mcu_pin_obj_t *pin = validate_obj_is_pin(obj);
|
||||||
|
assert_pin_free(pin);
|
||||||
|
return pin;
|
||||||
}
|
}
|
||||||
|
|
||||||
void assert_pin_free(const mcu_pin_obj_t* pin) {
|
void assert_pin_free(const mcu_pin_obj_t* pin) {
|
||||||
|
@ -33,7 +33,11 @@
|
|||||||
// Type object used in Python. Should be shared between ports.
|
// Type object used in Python. Should be shared between ports.
|
||||||
extern const mp_obj_type_t mcu_pin_type;
|
extern const mp_obj_type_t mcu_pin_type;
|
||||||
|
|
||||||
void assert_pin(mp_obj_t obj, bool none_ok);
|
mcu_pin_obj_t *validate_obj_is_pin(mp_obj_t obj);
|
||||||
|
mcu_pin_obj_t *validate_obj_is_pin_or_none(mp_obj_t obj);
|
||||||
|
mcu_pin_obj_t *validate_obj_is_free_pin(mp_obj_t obj);
|
||||||
|
mcu_pin_obj_t *validate_obj_is_free_pin_or_none(mp_obj_t obj);
|
||||||
|
|
||||||
void assert_pin_free(const mcu_pin_obj_t* pin);
|
void assert_pin_free(const mcu_pin_obj_t* pin);
|
||||||
|
|
||||||
bool common_hal_mcu_pin_is_free(const mcu_pin_obj_t* pin);
|
bool common_hal_mcu_pin_is_free(const mcu_pin_obj_t* pin);
|
||||||
|
@ -77,12 +77,9 @@ STATIC mp_obj_t ps2io_ps2_make_new(const mp_obj_type_t *type, size_t n_args, con
|
|||||||
};
|
};
|
||||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
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_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||||
assert_pin(args[ARG_clkpin].u_obj, false);
|
|
||||||
assert_pin(args[ARG_datapin].u_obj, false);
|
const mcu_pin_obj_t* clkpin = validate_obj_is_free_pin(args[ARG_clkpin].u_obj);
|
||||||
const mcu_pin_obj_t* clkpin = MP_OBJ_TO_PTR(args[ARG_clkpin].u_obj);
|
const mcu_pin_obj_t* datapin = validate_obj_is_free_pin(args[ARG_datapin].u_obj);
|
||||||
assert_pin_free(clkpin);
|
|
||||||
const mcu_pin_obj_t* datapin = MP_OBJ_TO_PTR(args[ARG_datapin].u_obj);
|
|
||||||
assert_pin_free(datapin);
|
|
||||||
|
|
||||||
ps2io_ps2_obj_t *self = m_new_obj(ps2io_ps2_obj_t);
|
ps2io_ps2_obj_t *self = m_new_obj(ps2io_ps2_obj_t);
|
||||||
self->base.type = &ps2io_ps2_type;
|
self->base.type = &ps2io_ps2_type;
|
||||||
|
@ -96,10 +96,7 @@ STATIC mp_obj_t pulseio_pwmout_make_new(const mp_obj_type_t *type, size_t n_args
|
|||||||
mp_arg_val_t parsed_args[MP_ARRAY_SIZE(allowed_args)];
|
mp_arg_val_t parsed_args[MP_ARRAY_SIZE(allowed_args)];
|
||||||
mp_arg_parse_all(n_args, args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, parsed_args);
|
mp_arg_parse_all(n_args, args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, parsed_args);
|
||||||
|
|
||||||
mp_obj_t pin_obj = parsed_args[ARG_pin].u_obj;
|
const mcu_pin_obj_t *pin = validate_obj_is_free_pin(parsed_args[ARG_pin].u_obj);
|
||||||
assert_pin(pin_obj, false);
|
|
||||||
const mcu_pin_obj_t *pin = MP_OBJ_TO_PTR(pin_obj);
|
|
||||||
assert_pin_free(pin);
|
|
||||||
|
|
||||||
uint16_t duty_cycle = parsed_args[ARG_duty_cycle].u_int;
|
uint16_t duty_cycle = parsed_args[ARG_duty_cycle].u_int;
|
||||||
uint32_t frequency = parsed_args[ARG_frequency].u_int;
|
uint32_t frequency = parsed_args[ARG_frequency].u_int;
|
||||||
|
@ -90,9 +90,7 @@ STATIC mp_obj_t pulseio_pulsein_make_new(const mp_obj_type_t *type, size_t n_arg
|
|||||||
};
|
};
|
||||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
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_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||||
assert_pin(args[ARG_pin].u_obj, false);
|
const mcu_pin_obj_t* pin = validate_obj_is_free_pin(args[ARG_pin].u_obj);
|
||||||
const mcu_pin_obj_t* pin = MP_OBJ_TO_PTR(args[ARG_pin].u_obj);
|
|
||||||
assert_pin_free(pin);
|
|
||||||
|
|
||||||
pulseio_pulsein_obj_t *self = m_new_obj(pulseio_pulsein_obj_t);
|
pulseio_pulsein_obj_t *self = m_new_obj(pulseio_pulsein_obj_t);
|
||||||
self->base.type = &pulseio_pulsein_type;
|
self->base.type = &pulseio_pulsein_type;
|
||||||
|
@ -73,13 +73,8 @@ STATIC mp_obj_t rotaryio_incrementalencoder_make_new(const mp_obj_type_t *type,
|
|||||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
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_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||||
|
|
||||||
assert_pin(args[ARG_pin_a].u_obj, false);
|
const mcu_pin_obj_t* pin_a = validate_obj_is_free_pin(args[ARG_pin_a].u_obj);
|
||||||
const mcu_pin_obj_t* pin_a = MP_OBJ_TO_PTR(args[ARG_pin_a].u_obj);
|
const mcu_pin_obj_t* pin_b = validate_obj_is_free_pin(args[ARG_pin_b].u_obj);
|
||||||
assert_pin_free(pin_a);
|
|
||||||
|
|
||||||
assert_pin(args[ARG_pin_b].u_obj, false);
|
|
||||||
const mcu_pin_obj_t* pin_b = MP_OBJ_TO_PTR(args[ARG_pin_b].u_obj);
|
|
||||||
assert_pin_free(pin_b);
|
|
||||||
|
|
||||||
rotaryio_incrementalencoder_obj_t *self = m_new_obj(rotaryio_incrementalencoder_obj_t);
|
rotaryio_incrementalencoder_obj_t *self = m_new_obj(rotaryio_incrementalencoder_obj_t);
|
||||||
self->base.type = &rotaryio_incrementalencoder_type;
|
self->base.type = &rotaryio_incrementalencoder_type;
|
||||||
|
@ -66,10 +66,7 @@ STATIC mp_obj_t touchio_touchin_make_new(const mp_obj_type_t *type,
|
|||||||
mp_arg_check_num(n_args, kw_args, 1, 1, false);
|
mp_arg_check_num(n_args, kw_args, 1, 1, false);
|
||||||
|
|
||||||
// 1st argument is the pin
|
// 1st argument is the pin
|
||||||
mp_obj_t pin_obj = args[0];
|
const mcu_pin_obj_t *pin = validate_obj_is_free_pin(args[0]);
|
||||||
assert_pin(pin_obj, false);
|
|
||||||
const mcu_pin_obj_t *pin = MP_OBJ_TO_PTR(pin_obj);
|
|
||||||
assert_pin_free(pin);
|
|
||||||
|
|
||||||
touchio_touchin_obj_t *self = m_new_obj(touchio_touchin_obj_t);
|
touchio_touchin_obj_t *self = m_new_obj(touchio_touchin_obj_t);
|
||||||
self->base.type = &touchio_touchin_type;
|
self->base.type = &touchio_touchin_type;
|
||||||
|
@ -78,10 +78,10 @@ STATIC mp_obj_t wiznet5k_make_new(const mp_obj_type_t *type, size_t n_args, cons
|
|||||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
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_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||||
// TODO check type of ARG_spi?
|
// TODO check type of ARG_spi?
|
||||||
assert_pin(args[ARG_cs].u_obj, false);
|
const mcu_pin_obj_t *cs = validate_obj_is_free_pin(args[ARG_cs].u_obj);
|
||||||
assert_pin(args[ARG_rst].u_obj, true); // may be NULL
|
const mcu_pin_obj_t *rst = validate_obj_is_free_pin_or_none(args[ARG_rst].u_obj);
|
||||||
|
|
||||||
mp_obj_t ret = wiznet5k_create(args[ARG_spi].u_obj, args[ARG_cs].u_obj, args[ARG_rst].u_obj);
|
mp_obj_t ret = wiznet5k_create(args[ARG_spi].u_obj, cs, rst);
|
||||||
if (args[ARG_dhcp].u_bool) wiznet5k_start_dhcp();
|
if (args[ARG_dhcp].u_bool) wiznet5k_start_dhcp();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ void shared_module_bitbangio_spi_construct(bitbangio_spi_obj_t *self,
|
|||||||
}
|
}
|
||||||
common_hal_digitalio_digitalinout_switch_to_output(&self->clock, self->polarity == 1, DRIVE_MODE_PUSH_PULL);
|
common_hal_digitalio_digitalinout_switch_to_output(&self->clock, self->polarity == 1, DRIVE_MODE_PUSH_PULL);
|
||||||
|
|
||||||
if (mosi != mp_const_none) {
|
if (mosi != NULL) {
|
||||||
result = common_hal_digitalio_digitalinout_construct(&self->mosi, mosi);
|
result = common_hal_digitalio_digitalinout_construct(&self->mosi, mosi);
|
||||||
if (result != DIGITALINOUT_OK) {
|
if (result != DIGITALINOUT_OK) {
|
||||||
common_hal_digitalio_digitalinout_deinit(&self->clock);
|
common_hal_digitalio_digitalinout_deinit(&self->clock);
|
||||||
@ -55,12 +55,12 @@ void shared_module_bitbangio_spi_construct(bitbangio_spi_obj_t *self,
|
|||||||
common_hal_digitalio_digitalinout_switch_to_output(&self->mosi, false, DRIVE_MODE_PUSH_PULL);
|
common_hal_digitalio_digitalinout_switch_to_output(&self->mosi, false, DRIVE_MODE_PUSH_PULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (miso != mp_const_none) {
|
if (miso != NULL) {
|
||||||
// Starts out as input by default, no need to change.
|
// Starts out as input by default, no need to change.
|
||||||
result = common_hal_digitalio_digitalinout_construct(&self->miso, miso);
|
result = common_hal_digitalio_digitalinout_construct(&self->miso, miso);
|
||||||
if (result != DIGITALINOUT_OK) {
|
if (result != DIGITALINOUT_OK) {
|
||||||
common_hal_digitalio_digitalinout_deinit(&self->clock);
|
common_hal_digitalio_digitalinout_deinit(&self->clock);
|
||||||
if (mosi != mp_const_none) {
|
if (mosi != NULL) {
|
||||||
common_hal_digitalio_digitalinout_deinit(&self->mosi);
|
common_hal_digitalio_digitalinout_deinit(&self->mosi);
|
||||||
}
|
}
|
||||||
mp_raise_ValueError(translate("MISO pin init failed."));
|
mp_raise_ValueError(translate("MISO pin init failed."));
|
||||||
|
@ -103,12 +103,12 @@ mp_obj_t common_hal_board_create_uart(void) {
|
|||||||
#ifdef DEFAULT_UART_BUS_RTS
|
#ifdef DEFAULT_UART_BUS_RTS
|
||||||
const mcu_pin_obj_t* rts = MP_OBJ_TO_PTR(DEFAULT_UART_BUS_RTS);
|
const mcu_pin_obj_t* rts = MP_OBJ_TO_PTR(DEFAULT_UART_BUS_RTS);
|
||||||
#else
|
#else
|
||||||
const mcu_pin_obj_t* rts = mp_const_none;
|
const mcu_pin_obj_t* rts = NULL;
|
||||||
#endif
|
#endif
|
||||||
#ifdef DEFAULT_UART_BUS_CTS
|
#ifdef DEFAULT_UART_BUS_CTS
|
||||||
const mcu_pin_obj_t* cts = MP_OBJ_TO_PTR(DEFAULT_UART_BUS_CTS);
|
const mcu_pin_obj_t* cts = MP_OBJ_TO_PTR(DEFAULT_UART_BUS_CTS);
|
||||||
#else
|
#else
|
||||||
const mcu_pin_obj_t* cts = mp_const_none;
|
const mcu_pin_obj_t* cts = NULL;
|
||||||
#endif
|
#endif
|
||||||
#ifdef DEFAULT_UART_IS_RS485
|
#ifdef DEFAULT_UART_IS_RS485
|
||||||
const mcu_pin_obj_t* rs485_dir = MP_OBJ_TO_PTR(DEFAULT_UART_BUS_RS485DIR);
|
const mcu_pin_obj_t* rs485_dir = MP_OBJ_TO_PTR(DEFAULT_UART_BUS_RS485DIR);
|
||||||
@ -118,7 +118,7 @@ mp_obj_t common_hal_board_create_uart(void) {
|
|||||||
const bool rs485_invert = false;
|
const bool rs485_invert = false;
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
const mcu_pin_obj_t* rs485_dir = mp_const_none;
|
const mcu_pin_obj_t* rs485_dir = NULL;
|
||||||
const bool rs485_invert = false;
|
const bool rs485_invert = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -379,12 +379,12 @@ void wiznet5k_socket_deinit(mod_network_socket_obj_t *socket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Create and return a WIZNET5K object.
|
/// Create and return a WIZNET5K object.
|
||||||
mp_obj_t wiznet5k_create(mp_obj_t spi_in, mp_obj_t cs_in, mp_obj_t rst_in) {
|
mp_obj_t wiznet5k_create(busio_spi_obj_t *spi_in, const mcu_pin_obj_t *cs_in, const mcu_pin_obj_t *rst_in) {
|
||||||
|
|
||||||
// init the wiznet5k object
|
// init the wiznet5k object
|
||||||
wiznet5k_obj.base.type = (mp_obj_type_t*)&mod_network_nic_type_wiznet5k;
|
wiznet5k_obj.base.type = (mp_obj_type_t*)&mod_network_nic_type_wiznet5k;
|
||||||
wiznet5k_obj.cris_state = 0;
|
wiznet5k_obj.cris_state = 0;
|
||||||
wiznet5k_obj.spi = MP_OBJ_TO_PTR(spi_in);
|
wiznet5k_obj.spi = spi_in;
|
||||||
wiznet5k_obj.socket_used = 0;
|
wiznet5k_obj.socket_used = 0;
|
||||||
wiznet5k_obj.dhcp_socket = -1;
|
wiznet5k_obj.dhcp_socket = -1;
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ int wiznet5k_socket_ioctl(mod_network_socket_obj_t *socket, mp_uint_t request, m
|
|||||||
void wiznet5k_socket_timer_tick(mod_network_socket_obj_t *socket);
|
void wiznet5k_socket_timer_tick(mod_network_socket_obj_t *socket);
|
||||||
void wiznet5k_socket_deinit(mod_network_socket_obj_t *socket);
|
void wiznet5k_socket_deinit(mod_network_socket_obj_t *socket);
|
||||||
mp_obj_t wiznet5k_socket_disconnect(mp_obj_t self_in);
|
mp_obj_t wiznet5k_socket_disconnect(mp_obj_t self_in);
|
||||||
mp_obj_t wiznet5k_create(mp_obj_t spi_in, mp_obj_t cs_in, mp_obj_t rst_in);
|
mp_obj_t wiznet5k_create(busio_spi_obj_t *spi_in, const mcu_pin_obj_t *cs_in, const mcu_pin_obj_t *rst_in);
|
||||||
|
|
||||||
int wiznet5k_start_dhcp(void);
|
int wiznet5k_start_dhcp(void);
|
||||||
int wiznet5k_stop_dhcp(void);
|
int wiznet5k_stop_dhcp(void);
|
||||||
|
Loading…
Reference in New Issue
Block a user