Skip to content

Commit 9ea809b

Browse files
committed
add pin claiming to devices
1 parent 585597a commit 9ea809b

File tree

36 files changed

+140
-100
lines changed

36 files changed

+140
-100
lines changed

main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ void NORETURN __fatal_error(const char *msg) {
451451

452452
#ifndef NDEBUG
453453
void MP_WEAK __assert_func(const char *file, int line, const char *func, const char *expr) {
454-
printf("Assertion '%s' failed, at file %s:%d\n", expr, file, line);
454+
mp_printf(&mp_plat_print, "Assertion '%s' failed, at file %s:%d\n", expr, file, line);
455455
__fatal_error("Assertion failed");
456456
}
457457
#endif

ports/atmel-samd/boards/circuitplayground_express/board.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ bool board_requests_safe_mode(void) {
4848
gpio_set_pin_pull_mode(PIN_PA28, GPIO_PULL_DOWN);
4949
bool safe_mode = gpio_get_pin_level(PIN_PA14) &&
5050
gpio_get_pin_level(PIN_PA28);
51-
reset_pin(PIN_PA14);
52-
reset_pin(PIN_PA28);
51+
reset_pin_number(PIN_PA14);
52+
reset_pin_number(PIN_PA28);
5353
return safe_mode;
5454
}
5555

ports/atmel-samd/boards/circuitplayground_express_crickit/board.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ bool board_requests_safe_mode(void) {
4848
gpio_set_pin_pull_mode(PIN_PA28, GPIO_PULL_DOWN);
4949
bool safe_mode = gpio_get_pin_level(PIN_PA14) &&
5050
gpio_get_pin_level(PIN_PA28);
51-
reset_pin(PIN_PA14);
52-
reset_pin(PIN_PA28);
51+
reset_pin_number(PIN_PA14);
52+
reset_pin_number(PIN_PA28);
5353
return safe_mode;
5454
}
5555

ports/atmel-samd/common-hal/analogio/AnalogIn.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ void common_hal_analogio_analogin_deinit(analogio_analogin_obj_t *self) {
8080
if (common_hal_analogio_analogin_deinited(self)) {
8181
return;
8282
}
83-
reset_pin(self->pin->number);
83+
reset_pin_number(self->pin->number);
8484
self->pin = mp_const_none;
8585
}
8686

ports/atmel-samd/common-hal/analogio/AnalogOut.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ void common_hal_analogio_analogout_deinit(analogio_analogout_obj_t *self) {
113113
return;
114114
}
115115
dac_sync_disable_channel(&self->descriptor, self->channel);
116-
reset_pin(PIN_PA02);
116+
reset_pin_number(PIN_PA02);
117117
// Only deinit the DAC on the SAMD51 if both outputs are free.
118118
#ifdef SAMD51
119119
if (common_hal_mcu_pin_is_free(&pin_PA02) && common_hal_mcu_pin_is_free(&pin_PA05)) {

ports/atmel-samd/common-hal/audiobusio/I2SOut.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,11 @@ void common_hal_audiobusio_i2sout_deinit(audiobusio_i2sout_obj_t* self) {
212212
return;
213213
}
214214

215-
reset_pin(self->bit_clock->number);
215+
reset_pin_number(self->bit_clock->number);
216216
self->bit_clock = mp_const_none;
217-
reset_pin(self->word_select->number);
217+
reset_pin_number(self->word_select->number);
218218
self->word_select = mp_const_none;
219-
reset_pin(self->data->number);
219+
reset_pin_number(self->data->number);
220220
self->data = mp_const_none;
221221
}
222222

ports/atmel-samd/common-hal/audiobusio/PDMIn.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,8 @@ void common_hal_audiobusio_pdmin_deinit(audiobusio_pdmin_obj_t* self) {
235235
disconnect_gclk_from_peripheral(self->gclk, I2S_GCLK_ID_0 + self->clock_unit);
236236
disable_clock_generator(self->gclk);
237237

238-
reset_pin(self->clock_pin->number);
239-
reset_pin(self->data_pin->number);
238+
reset_pin_number(self->clock_pin->number);
239+
reset_pin_number(self->data_pin->number);
240240
self->clock_pin = mp_const_none;
241241
self->data_pin = mp_const_none;
242242
}

ports/atmel-samd/common-hal/audioio/AudioOut.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,10 @@ void common_hal_audioio_audioout_deinit(audioio_audioout_obj_t* self) {
248248

249249
tc_set_enable(tc_insts[self->tc_index], false);
250250

251-
reset_pin(self->left_channel->number);
251+
reset_pin_number(self->left_channel->number);
252252
self->left_channel = mp_const_none;
253253
#ifdef SAMD51
254-
reset_pin(self->right_channel->number);
254+
reset_pin_number(self->right_channel->number);
255255
self->right_channel = mp_const_none;
256256
#endif
257257
}

ports/atmel-samd/common-hal/busio/I2C.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self,
9696
common_hal_mcu_delay_us(3);
9797

9898
if (!gpio_get_pin_level(sda->number) || !gpio_get_pin_level(scl->number)) {
99-
reset_pin(sda->number);
100-
reset_pin(scl->number);
99+
reset_pin_number(sda->number);
100+
reset_pin_number(scl->number);
101101
mp_raise_RuntimeError(translate("SDA or SCL needs a pull up"));
102102
}
103103
gpio_set_pin_function(sda->number, sda_pinmux);
@@ -107,17 +107,17 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self,
107107
samd_peripherals_sercom_clock_init(sercom, sercom_index);
108108

109109
if (i2c_m_sync_init(&self->i2c_desc, sercom) != ERR_NONE) {
110-
reset_pin(sda->number);
111-
reset_pin(scl->number);
110+
reset_pin_number(sda->number);
111+
reset_pin_number(scl->number);
112112
mp_raise_OSError(MP_EIO);
113113
}
114114

115115
// clkrate is always 0. baud_rate is in kHz.
116116

117117
// Frequency must be set before the I2C device is enabled.
118118
if (i2c_m_sync_set_baudrate(&self->i2c_desc, 0, frequency / 1000) != ERR_NONE) {
119-
reset_pin(sda->number);
120-
reset_pin(scl->number);
119+
reset_pin_number(sda->number);
120+
reset_pin_number(scl->number);
121121
mp_raise_ValueError(translate("Unsupported baudrate"));
122122
}
123123

@@ -144,8 +144,8 @@ void common_hal_busio_i2c_deinit(busio_i2c_obj_t *self) {
144144
i2c_m_sync_disable(&self->i2c_desc);
145145
i2c_m_sync_deinit(&self->i2c_desc);
146146

147-
reset_pin(self->sda_pin);
148-
reset_pin(self->scl_pin);
147+
reset_pin_number(self->sda_pin);
148+
reset_pin_number(self->scl_pin);
149149
self->sda_pin = NO_PIN;
150150
self->scl_pin = NO_PIN;
151151
}

ports/atmel-samd/common-hal/busio/I2C.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
typedef struct {
3737
mp_obj_base_t base;
3838
struct i2c_m_sync_desc i2c_desc;
39-
volatile bool has_lock;
39+
bool has_lock;
4040
uint8_t scl_pin;
4141
uint8_t sda_pin;
4242
} busio_i2c_obj_t;

0 commit comments

Comments
 (0)