From ea43fa104e811418417d4f41c2569de47d35c982 Mon Sep 17 00:00:00 2001 From: danicampora Date: Mon, 16 Mar 2015 13:18:29 +0100 Subject: [PATCH] cc3200: Remove unneeded functions and add pybsleep_remove() calls. --- cc3200/mods/pybadc.c | 9 +++++---- cc3200/mods/pybi2c.c | 3 ++- cc3200/mods/pybuart.c | 15 --------------- 3 files changed, 7 insertions(+), 20 deletions(-) diff --git a/cc3200/mods/pybadc.c b/cc3200/mods/pybadc.c index 2494648b46..a619362601 100644 --- a/cc3200/mods/pybadc.c +++ b/cc3200/mods/pybadc.c @@ -72,8 +72,8 @@ typedef struct _pyb_obj_adc_t { STATIC void pybadc_init (pyb_obj_adc_t *self) { - // enable the ADC channel - MAP_ADCChannelEnable(ADC_BASE, self->channel); + // enable the ADC channel + MAP_ADCChannelEnable(ADC_BASE, self->channel); // enable and configure the timer MAP_ADCTimerConfig(ADC_BASE, (1 << 17) - 1); MAP_ADCTimerEnable(ADC_BASE); @@ -161,7 +161,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(adc_read_obj, adc_read); STATIC mp_obj_t adc_enable(mp_obj_t self_in) { pyb_obj_adc_t *self = self_in; - MAP_ADCChannelEnable(ADC_BASE, self->channel); + pybadc_init(self); return mp_const_none; } 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) { pyb_obj_adc_t *self = self_in; MAP_ADCChannelDisable(ADC_BASE, self->channel); + // unregister it with the sleep module + pybsleep_remove ((const mp_obj_t)self); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(adc_disable_obj, adc_disable); STATIC const mp_map_elem_t adc_locals_dict_table[] = { - { MP_OBJ_NEW_QSTR(MP_QSTR___del__), (mp_obj_t)&adc_disable_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_read), (mp_obj_t)&adc_read_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_enable), (mp_obj_t)&adc_enable_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_disable), (mp_obj_t)&adc_disable_obj }, diff --git a/cc3200/mods/pybi2c.c b/cc3200/mods/pybi2c.c index 5a2e548207..aa4401ee18 100644 --- a/cc3200/mods/pybi2c.c +++ b/cc3200/mods/pybi2c.c @@ -351,6 +351,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pyb_i2c_init_obj, 1, pyb_i2c_init); /// Turn off the I2C bus. STATIC mp_obj_t pyb_i2c_deinit(mp_obj_t self_in) { i2c_deinit(); + // unregister it with the sleep module + pybsleep_remove ((const mp_obj_t)self_in); return mp_const_none; } 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); STATIC const mp_map_elem_t pyb_i2c_locals_dict_table[] = { // instance methods - { MP_OBJ_NEW_QSTR(MP_QSTR___del__), (mp_obj_t)&pyb_i2c_deinit_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_init), (mp_obj_t)&pyb_i2c_init_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_deinit), (mp_obj_t)&pyb_i2c_deinit_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_is_ready), (mp_obj_t)&pyb_i2c_is_ready_obj }, diff --git a/cc3200/mods/pybuart.c b/cc3200/mods/pybuart.c index ccaf3a31e0..0387f68e42 100644 --- a/cc3200/mods/pybuart.c +++ b/cc3200/mods/pybuart.c @@ -523,20 +523,6 @@ STATIC mp_obj_t pyb_uart_deinit(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_uart_deinit_obj, pyb_uart_deinit); -/// \method delete() -/// Deinits the UART and removes its references so that it can be cleaned by the gc -STATIC mp_obj_t pyb_uart_delete(mp_obj_t self_in) { - pyb_uart_obj_t *self = self_in; - - // deinit the peripheral - pyb_uart_deinit(self); - // remove it from the list - mp_obj_list_remove(&MP_STATE_PORT(pyb_uart_list), self); - - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_uart_delete_obj, pyb_uart_delete); - /// \method any() /// Return `True` if any characters waiting, else `False`. 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); STATIC const mp_map_elem_t pyb_uart_locals_dict_table[] = { // instance methods - { MP_OBJ_NEW_QSTR(MP_QSTR___del__), (mp_obj_t)&pyb_uart_delete_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_init), (mp_obj_t)&pyb_uart_init_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_deinit), (mp_obj_t)&pyb_uart_deinit_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_any), (mp_obj_t)&pyb_uart_any_obj },