Skip to content

Commit ea43fa1

Browse files
committed
cc3200: Remove unneeded functions and add pybsleep_remove() calls.
1 parent 1954d80 commit ea43fa1

3 files changed

Lines changed: 7 additions & 20 deletions

File tree

cc3200/mods/pybadc.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ typedef struct _pyb_obj_adc_t {
7272

7373

7474
STATIC void pybadc_init (pyb_obj_adc_t *self) {
75-
// enable the ADC channel
76-
MAP_ADCChannelEnable(ADC_BASE, self->channel);
75+
// enable the ADC channel
76+
MAP_ADCChannelEnable(ADC_BASE, self->channel);
7777
// enable and configure the timer
7878
MAP_ADCTimerConfig(ADC_BASE, (1 << 17) - 1);
7979
MAP_ADCTimerEnable(ADC_BASE);
@@ -161,7 +161,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(adc_read_obj, adc_read);
161161
STATIC mp_obj_t adc_enable(mp_obj_t self_in) {
162162
pyb_obj_adc_t *self = self_in;
163163

164-
MAP_ADCChannelEnable(ADC_BASE, self->channel);
164+
pybadc_init(self);
165165
return mp_const_none;
166166
}
167167
STATIC MP_DEFINE_CONST_FUN_OBJ_1(adc_enable_obj, adc_enable);
@@ -172,12 +172,13 @@ STATIC mp_obj_t adc_disable(mp_obj_t self_in) {
172172
pyb_obj_adc_t *self = self_in;
173173

174174
MAP_ADCChannelDisable(ADC_BASE, self->channel);
175+
// unregister it with the sleep module
176+
pybsleep_remove ((const mp_obj_t)self);
175177
return mp_const_none;
176178
}
177179
STATIC MP_DEFINE_CONST_FUN_OBJ_1(adc_disable_obj, adc_disable);
178180

179181
STATIC const mp_map_elem_t adc_locals_dict_table[] = {
180-
{ MP_OBJ_NEW_QSTR(MP_QSTR___del__), (mp_obj_t)&adc_disable_obj },
181182
{ MP_OBJ_NEW_QSTR(MP_QSTR_read), (mp_obj_t)&adc_read_obj },
182183
{ MP_OBJ_NEW_QSTR(MP_QSTR_enable), (mp_obj_t)&adc_enable_obj },
183184
{ MP_OBJ_NEW_QSTR(MP_QSTR_disable), (mp_obj_t)&adc_disable_obj },

cc3200/mods/pybi2c.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pyb_i2c_init_obj, 1, pyb_i2c_init);
351351
/// Turn off the I2C bus.
352352
STATIC mp_obj_t pyb_i2c_deinit(mp_obj_t self_in) {
353353
i2c_deinit();
354+
// unregister it with the sleep module
355+
pybsleep_remove ((const mp_obj_t)self_in);
354356
return mp_const_none;
355357
}
356358
STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_i2c_deinit_obj, pyb_i2c_deinit);
@@ -602,7 +604,6 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pyb_i2c_mem_write_obj, 1, pyb_i2c_mem_write);
602604

603605
STATIC const mp_map_elem_t pyb_i2c_locals_dict_table[] = {
604606
// instance methods
605-
{ MP_OBJ_NEW_QSTR(MP_QSTR___del__), (mp_obj_t)&pyb_i2c_deinit_obj },
606607
{ MP_OBJ_NEW_QSTR(MP_QSTR_init), (mp_obj_t)&pyb_i2c_init_obj },
607608
{ MP_OBJ_NEW_QSTR(MP_QSTR_deinit), (mp_obj_t)&pyb_i2c_deinit_obj },
608609
{ MP_OBJ_NEW_QSTR(MP_QSTR_is_ready), (mp_obj_t)&pyb_i2c_is_ready_obj },

cc3200/mods/pybuart.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -523,20 +523,6 @@ STATIC mp_obj_t pyb_uart_deinit(mp_obj_t self_in) {
523523
}
524524
STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_uart_deinit_obj, pyb_uart_deinit);
525525

526-
/// \method delete()
527-
/// Deinits the UART and removes its references so that it can be cleaned by the gc
528-
STATIC mp_obj_t pyb_uart_delete(mp_obj_t self_in) {
529-
pyb_uart_obj_t *self = self_in;
530-
531-
// deinit the peripheral
532-
pyb_uart_deinit(self);
533-
// remove it from the list
534-
mp_obj_list_remove(&MP_STATE_PORT(pyb_uart_list), self);
535-
536-
return mp_const_none;
537-
}
538-
STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_uart_delete_obj, pyb_uart_delete);
539-
540526
/// \method any()
541527
/// Return `True` if any characters waiting, else `False`.
542528
STATIC mp_obj_t pyb_uart_any(mp_obj_t self_in) {
@@ -583,7 +569,6 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_uart_readchar_obj, pyb_uart_readchar);
583569

584570
STATIC const mp_map_elem_t pyb_uart_locals_dict_table[] = {
585571
// instance methods
586-
{ MP_OBJ_NEW_QSTR(MP_QSTR___del__), (mp_obj_t)&pyb_uart_delete_obj },
587572
{ MP_OBJ_NEW_QSTR(MP_QSTR_init), (mp_obj_t)&pyb_uart_init_obj },
588573
{ MP_OBJ_NEW_QSTR(MP_QSTR_deinit), (mp_obj_t)&pyb_uart_deinit_obj },
589574
{ MP_OBJ_NEW_QSTR(MP_QSTR_any), (mp_obj_t)&pyb_uart_any_obj },

0 commit comments

Comments
 (0)