diff options
| author | Daniel Campora | 2015-09-04 14:36:52 +0200 |
|---|---|---|
| committer | Daniel Campora | 2015-09-10 07:59:41 +0200 |
| commit | 36821d095a2657ab370a8f413f471f4c9ad9a8b5 (patch) | |
| tree | 59ca23ec96e63dd46d486e7e7289733ab2b55a27 /cc3200/mods | |
| parent | d5e256486eafab543c3e24850fe87136c2f0575d (diff) | |
cc3200: Add alternate functions list to Pin object.
Also remove pin.high() and pin.low() methods.
Diffstat (limited to 'cc3200/mods')
| -rw-r--r-- | cc3200/mods/pybpin.c | 2 | ||||
| -rw-r--r-- | cc3200/mods/pybpin.h | 83 | ||||
| -rw-r--r-- | cc3200/mods/pybsleep.c | 2 |
3 files changed, 75 insertions, 12 deletions
diff --git a/cc3200/mods/pybpin.c b/cc3200/mods/pybpin.c index 81385afd8..01fd52292 100644 --- a/cc3200/mods/pybpin.c +++ b/cc3200/mods/pybpin.c @@ -779,8 +779,6 @@ STATIC const mp_map_elem_t pin_locals_dict_table[] = { // instance methods { MP_OBJ_NEW_QSTR(MP_QSTR_init), (mp_obj_t)&pin_init_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_value), (mp_obj_t)&pin_value_obj }, - { MP_OBJ_NEW_QSTR(MP_QSTR_low), (mp_obj_t)&pin_low_obj }, - { MP_OBJ_NEW_QSTR(MP_QSTR_high), (mp_obj_t)&pin_high_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_toggle), (mp_obj_t)&pin_toggle_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_id), (mp_obj_t)&pin_id_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_mode), (mp_obj_t)&pin_mode_obj }, diff --git a/cc3200/mods/pybpin.h b/cc3200/mods/pybpin.h index cefc6e03b..04b80825d 100644 --- a/cc3200/mods/pybpin.h +++ b/cc3200/mods/pybpin.h @@ -29,24 +29,90 @@ #define PYBPIN_H_ enum { - PORT_A0 = GPIOA0_BASE, - PORT_A1 = GPIOA1_BASE, - PORT_A2 = GPIOA2_BASE, - PORT_A3 = GPIOA3_BASE + PORT_A0 = GPIOA0_BASE, + PORT_A1 = GPIOA1_BASE, + PORT_A2 = GPIOA2_BASE, + PORT_A3 = GPIOA3_BASE, }; +enum { + PIN_FN_UART = 0, + PIN_FN_SPI, + PIN_FN_I2S, + PIN_FN_I2C, + PIN_FN_TIM, + PIN_FN_SD, + PIN_FN_ADC, +}; + +enum { + PIN_TYPE_UART_TX = 0, + PIN_TYPE_UART_RX, + PIN_TYPE_UART_RTS, + PIN_TYPE_UART_CTS, +}; + +enum { + PIN_TYPE_SPI_CLK = 0, + PIN_TYPE_SPI_MOSI, + PIN_TYPE_SPI_MISO, + PIN_TYPE_SPI_CS0, +}; + +enum { + PIN_TYPE_I2S_CLK = 0, + PIN_TYPE_I2S_FS, + PIN_TYPE_I2S_DAT0, + PIN_TYPE_I2S_DAT1, +}; + +enum { + PIN_TYPE_I2C_SDA = 0, + PIN_TYPE_I2C_SCL, +}; + +enum { + PIN_TYPE_TIM_PWM0 = 0, + PIN_TYPE_TIM_PWM1, + PIN_TYPE_TIM_CC0, + PIN_TYPE_TIM_CC1, +}; + +enum { + PIN_TYPE_SD_CLK = 0, + PIN_TYPE_SD_CMD, + PIN_TYPE_SD_DAT0, +}; + +enum { + PIN_TYPE_ADC_CH0 = -1, + PIN_TYPE_ADC_CH1 = -1, + PIN_TYPE_ADC_CH2 = -1, + PIN_TYPE_ADC_CH3 = -1, +}; + +typedef struct { + qstr name; + uint8_t idx; + uint8_t fn; + uint8_t unit; + uint8_t type; +} pin_af_t; + typedef struct { const mp_obj_base_t base; const qstr name; const uint32_t port; + const pin_af_t *af_list; uint16_t pull; const uint8_t bit; const uint8_t pin_num; int8_t af; uint8_t strength; - uint8_t mode; // this is now a combination of type and mode - int8_t value; // -1 means no defined value - bool isused; + uint8_t mode; // this is now a combination of type and mode + uint8_t num_afs: 6; // up to 63 AFs + uint8_t value : 1; + uint8_t used : 1; } pin_obj_t; extern const mp_obj_type_t pin_type; @@ -68,7 +134,6 @@ extern const mp_obj_dict_t pin_board_pins_locals_dict; void pin_init0(void); void pin_config(pin_obj_t *self, int af, uint mode, uint type, int value, uint strength); pin_obj_t *pin_find(mp_obj_t user_obj); -pin_obj_t *pin_find_named_pin(const mp_obj_dict_t *named_pins, mp_obj_t name); -pin_obj_t *pin_find_pin_by_port_bit (const mp_obj_dict_t *named_pins, uint port, uint bit); +int8_t pin_find_af_index(const pin_obj_t* pin, uint8_t fn, uint8_t unit, uint8_t type); #endif // PYBPIN_H_ diff --git a/cc3200/mods/pybsleep.c b/cc3200/mods/pybsleep.c index c04b49797..0b6a29b3f 100644 --- a/cc3200/mods/pybsleep.c +++ b/cc3200/mods/pybsleep.c @@ -474,7 +474,7 @@ STATIC void pybsleep_iopark (bool hibernate) { #endif default: // enable a weak pull-down if the pin is unused - if (!pin->isused) { + if (!pin->used) { MAP_PinConfigSet(pin->pin_num, pin->strength, PIN_TYPE_STD_PD); } if (hibernate) { |
