cc3200: Remove unneeded functions and add pybsleep_remove() calls.

This commit is contained in:
danicampora 2015-03-16 13:18:29 +01:00
parent 1954d8021f
commit ea43fa104e
3 changed files with 7 additions and 20 deletions

View File

@ -72,8 +72,8 @@ typedef struct _pyb_obj_adc_t {
STATIC void pybadc_init (pyb_obj_adc_t *self) { STATIC void pybadc_init (pyb_obj_adc_t *self) {
// enable the ADC channel // enable the ADC channel
MAP_ADCChannelEnable(ADC_BASE, self->channel); MAP_ADCChannelEnable(ADC_BASE, self->channel);
// enable and configure the timer // enable and configure the timer
MAP_ADCTimerConfig(ADC_BASE, (1 << 17) - 1); MAP_ADCTimerConfig(ADC_BASE, (1 << 17) - 1);
MAP_ADCTimerEnable(ADC_BASE); 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) { STATIC mp_obj_t adc_enable(mp_obj_t self_in) {
pyb_obj_adc_t *self = self_in; pyb_obj_adc_t *self = self_in;
MAP_ADCChannelEnable(ADC_BASE, self->channel); pybadc_init(self);
return mp_const_none; return mp_const_none;
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_1(adc_enable_obj, adc_enable); 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; pyb_obj_adc_t *self = self_in;
MAP_ADCChannelDisable(ADC_BASE, self->channel); MAP_ADCChannelDisable(ADC_BASE, self->channel);
// unregister it with the sleep module
pybsleep_remove ((const mp_obj_t)self);
return mp_const_none; return mp_const_none;
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_1(adc_disable_obj, adc_disable); STATIC MP_DEFINE_CONST_FUN_OBJ_1(adc_disable_obj, adc_disable);
STATIC const mp_map_elem_t adc_locals_dict_table[] = { 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_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_enable), (mp_obj_t)&adc_enable_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_disable), (mp_obj_t)&adc_disable_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_disable), (mp_obj_t)&adc_disable_obj },

View File

@ -351,6 +351,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pyb_i2c_init_obj, 1, pyb_i2c_init);
/// Turn off the I2C bus. /// Turn off the I2C bus.
STATIC mp_obj_t pyb_i2c_deinit(mp_obj_t self_in) { STATIC mp_obj_t pyb_i2c_deinit(mp_obj_t self_in) {
i2c_deinit(); i2c_deinit();
// unregister it with the sleep module
pybsleep_remove ((const mp_obj_t)self_in);
return mp_const_none; return mp_const_none;
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_i2c_deinit_obj, pyb_i2c_deinit); 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[] = { STATIC const mp_map_elem_t pyb_i2c_locals_dict_table[] = {
// instance methods // 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_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_deinit), (mp_obj_t)&pyb_i2c_deinit_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_is_ready), (mp_obj_t)&pyb_i2c_is_ready_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_is_ready), (mp_obj_t)&pyb_i2c_is_ready_obj },

View File

@ -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); 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() /// \method any()
/// Return `True` if any characters waiting, else `False`. /// Return `True` if any characters waiting, else `False`.
STATIC mp_obj_t pyb_uart_any(mp_obj_t self_in) { 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[] = { STATIC const mp_map_elem_t pyb_uart_locals_dict_table[] = {
// instance methods // 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_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_deinit), (mp_obj_t)&pyb_uart_deinit_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_any), (mp_obj_t)&pyb_uart_any_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_any), (mp_obj_t)&pyb_uart_any_obj },