Skip to content

Commit 53716fc

Browse files
committed
cc3200: Rename GPIO module to Pin.
This change helps making the cc3200 port API a bit closer to stmhal. The ramaining differences are due to the specific hardware details of each chip. One feature that has been deliberately disabled is the possibility to add custom names and custom pin mappings. Those features are nice and convenient, but in this port, code size is a major concern.
1 parent d0df10b commit 53716fc

15 files changed

Lines changed: 154 additions & 260 deletions

cc3200/application.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ APP_HAL_SRC_C = $(addprefix hal/,\
7474

7575
APP_MISC_SRC_C = $(addprefix misc/,\
7676
FreeRTOSHooks.c \
77-
gpio_named_pins.c \
77+
pin_named_pins.c \
7878
help.c \
7979
mperror.c \
8080
mpexception.c \
@@ -89,7 +89,7 @@ APP_MODS_SRC_C = $(addprefix mods/,\
8989
modutime.c \
9090
modwlan.c \
9191
pybextint.c \
92-
pybgpio.c \
92+
pybpin.c \
9393
pybrtc.c \
9494
pybstdio.c \
9595
pybsystick.c \

cc3200/boards/cc3200_prefix.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@
3636
#include "obj.h"
3737
#include "inc/hw_types.h"
3838
#include "inc/hw_memmap.h"
39-
#include "pybgpio.h"
39+
#include "pybpin.h"
4040

4141

42-
#define GPIO(p_gpio_name, p_port, p_bit, p_pin_num) \
42+
#define PIN(p_pin_name, p_port, p_bit, p_pin_num) \
4343
{ \
44-
{ &gpio_type }, \
45-
.name = MP_QSTR_ ## p_gpio_name, \
44+
{ &pin_type }, \
45+
.name = MP_QSTR_ ## p_pin_name, \
4646
.port = PORT_A ## p_port, \
4747
.bit = (p_bit), \
4848
.pin_num = (p_pin_num) \

cc3200/boards/make-pins.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python
2-
"""Creates the pin file for the CC3200."""
2+
"""Generates the pins files for the CC3200."""
33

44
from __future__ import print_function
55

@@ -40,11 +40,11 @@ def set_is_board_pin(self):
4040
self.board_pin = True
4141

4242
def print(self):
43-
print('const gpio_obj_t pin_{:6s} = GPIO({:6s}, {:1d}, {:3d}, {:2d});'.format(
43+
print('const pin_obj_t pin_{:6s} = PIN({:6s}, {:1d}, {:3d}, {:2d});'.format(
4444
self.name, self.name, self.port, self.gpio_bit, self.pin_num))
4545

4646
def print_header(self, hdr_file):
47-
hdr_file.write('extern const gpio_obj_t pin_{:s};\n'.
47+
hdr_file.write('extern const pin_obj_t pin_{:s};\n'.
4848
format(self.name))
4949

5050

@@ -89,12 +89,12 @@ def parse_board_file(self, filename, cpu_pin_num_col):
8989

9090
def print_named(self, label, pins):
9191
print('')
92-
print('STATIC const mp_map_elem_t gpio_{:s}_pins_locals_dict_table[] = {{'.format(label))
92+
print('STATIC const mp_map_elem_t pin_{:s}_pins_locals_dict_table[] = {{'.format(label))
9393
for pin in pins:
9494
if pin.is_board_pin():
9595
print(' {{ MP_OBJ_NEW_QSTR(MP_QSTR_{:6s}), (mp_obj_t)&pin_{:6s} }},'.format(pin.cpu_pin_name(), pin.cpu_pin_name()))
9696
print('};')
97-
print('MP_DEFINE_CONST_DICT(gpio_{:s}_pins_locals_dict, gpio_{:s}_pins_locals_dict_table);'.format(label, label));
97+
print('MP_DEFINE_CONST_DICT(pin_{:s}_pins_locals_dict, pin_{:s}_pins_locals_dict_table);'.format(label, label));
9898

9999
def print(self):
100100
for pin in self.cpu_pins:

cc3200/bootmgr/bootmgr.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
*
44
* The MIT License (MIT)
55
*
6-
* Copyright (c) 2013, 2014 Damien P. George
76
* Copyright (c) 2015 Daniel Campora
87
*
98
* Permission is hereby granted, free of charge, to any person obtaining a copy

cc3200/bootmgr/flc.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
*
44
* The MIT License (MIT)
55
*
6-
* Copyright (c) 2013, 2014 Damien P. George
76
* Copyright (c) 2015 Daniel Campora
87
*
98
* Permission is hereby granted, free of charge, to any person obtaining a copy

cc3200/misc/pin_defs_cc3200.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,18 @@
3737
#include "rom_map.h"
3838
#include "gpio.h"
3939
#include "pin.h"
40-
#include "pybgpio.h"
40+
#include "pybpin.h"
4141
#include "runtime.h"
4242
#include MICROPY_HAL_H
4343

4444

4545
// Returns the pin mode. This value returned by this macro should be one of:
4646
// GPIO_DIR_MODE_IN or GPIO_DIR_MODE_OUT
47-
uint32_t gpio_get_mode(const gpio_obj_t *self) {
47+
uint32_t pin_get_mode(const pin_obj_t *self) {
4848
return MAP_GPIODirModeGet(self->port, self->bit);
4949
}
5050

51-
uint32_t gpio_get_type(const gpio_obj_t *self) {
51+
uint32_t pin_get_type(const pin_obj_t *self) {
5252

5353
uint32_t strenght;
5454
uint32_t type;
@@ -58,7 +58,7 @@ uint32_t gpio_get_type(const gpio_obj_t *self) {
5858
return type;
5959
}
6060

61-
uint32_t gpio_get_strenght (const gpio_obj_t *self) {
61+
uint32_t pin_get_strenght (const pin_obj_t *self) {
6262

6363
uint32_t strenght;
6464
uint32_t type;
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,23 @@
3636
#include "inc/hw_types.h"
3737
#include "inc/hw_ints.h"
3838
#include "inc/hw_memmap.h"
39-
#include "pybgpio.h"
39+
#include "pybpin.h"
4040
#include "runtime.h"
4141
#include MICROPY_HAL_H
4242

43-
STATIC void gpio_named_pins_obj_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
44-
gpio_named_pins_obj_t *self = self_in;
43+
STATIC void pin_named_pins_obj_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
44+
pin_named_pins_obj_t *self = self_in;
4545
print(env, "<Pin.%s>", qstr_str(self->name));
4646
}
4747

48-
const mp_obj_type_t gpio_cpu_pins_obj_type = {
48+
const mp_obj_type_t pin_cpu_pins_obj_type = {
4949
{ &mp_type_type },
5050
.name = MP_QSTR_cpu,
51-
.print = gpio_named_pins_obj_print,
52-
.locals_dict = (mp_obj_t)&gpio_cpu_pins_locals_dict,
51+
.print = pin_named_pins_obj_print,
52+
.locals_dict = (mp_obj_t)&pin_cpu_pins_locals_dict,
5353
};
5454

55-
const gpio_obj_t *gpio_find_named_pin(const mp_obj_dict_t *named_pins, mp_obj_t name) {
55+
const pin_obj_t *pin_find_named_pin(const mp_obj_dict_t *named_pins, mp_obj_t name) {
5656
mp_map_t *named_map = mp_obj_dict_get_map((mp_obj_t)named_pins);
5757
mp_map_elem_t *named_elem = mp_map_lookup(named_map, name, MP_MAP_LOOKUP);
5858
if (named_elem != NULL && named_elem->value != NULL) {

cc3200/mods/modpyb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
#include "prcm.h"
4848
#include "pyexec.h"
4949
#include "pybuart.h"
50-
#include "pybgpio.h"
50+
#include "pybpin.h"
5151
#include "pybstdio.h"
5252
#include "pybrtc.h"
5353
#include "pybsystick.h"
@@ -303,7 +303,7 @@ STATIC const mp_map_elem_t pyb_module_globals_table[] = {
303303
{ MP_OBJ_NEW_QSTR(MP_QSTR_RTC), (mp_obj_t)&pyb_rtc_type },
304304
#endif
305305

306-
{ MP_OBJ_NEW_QSTR(MP_QSTR_GPIO), (mp_obj_t)&gpio_type },
306+
{ MP_OBJ_NEW_QSTR(MP_QSTR_Pin), (mp_obj_t)&pin_type },
307307
{ MP_OBJ_NEW_QSTR(MP_QSTR_ExtInt), (mp_obj_t)&extint_type },
308308

309309
{ MP_OBJ_NEW_QSTR(MP_QSTR_UART), (mp_obj_t)&pyb_uart_type },

cc3200/mods/pybextint.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
#include "rom_map.h"
4646
#include "pin.h"
4747
#include "gpio.h"
48-
#include "pybgpio.h"
48+
#include "pybpin.h"
4949
#include "pybextint.h"
5050
#include "mpexception.h"
5151
#include "interrupt.h"
@@ -55,7 +55,7 @@
5555
/// \moduleref pyb
5656
/// \class ExtInt - configure I/O pins to interrupt on external events
5757
///
58-
/// There are a maximum of 25 GPIO interrupt lines.
58+
/// There are a maximum of 25 gpio interrupt lines.
5959
///
6060
/// Example callback:
6161
///
@@ -72,10 +72,10 @@
7272
/// See: http://www.eng.utah.edu/~cs5780/debouncing.pdf for a detailed
7373
/// explanation, along with various techniques for debouncing.
7474
///
75-
/// All gpio objects go through the gpio mapper to come up with one of the
75+
/// All pin objects go through the pin mapper to come up with one of the
7676
/// gpio pins.
7777
///
78-
/// extint = pyb.ExtInt(gpio, mode, pull, callback)
78+
/// extint = pyb.ExtInt(pin, mode, pull, callback)
7979
///
8080
/// There is also a C API, so that drivers which require EXTI interrupt lines
8181
/// can also use this code. See pybextint.h for the available functions.
@@ -149,7 +149,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(extint_obj_swint_obj, extint_obj_swint);
149149
/// \classmethod \constructor(pin, mode, pull, callback)
150150
/// Create an ExtInt object:
151151
///
152-
/// - `gpio` is the gpio on which to enable the interrupt (can be a gpio object or any valid gpio name).
152+
/// - `pin` is the pin on which to enable the interrupt (can be a pin object or any valid pin name).
153153
/// - `mode` can be one of:
154154
/// - `ExtInt.IRQ_RISING` - trigger on a rising edge;
155155
/// - `ExtInt.IRQ_FALLING` - trigger on a falling edge;
@@ -162,7 +162,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(extint_obj_swint_obj, extint_obj_swint);
162162
/// callback function must accept exactly 1 argument, which is the line that
163163
/// triggered the interrupt.
164164
STATIC const mp_arg_t pyb_extint_make_new_args[] = {
165-
{ MP_QSTR_gpio, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
165+
{ MP_QSTR_pin, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
166166
{ MP_QSTR_mode, MP_ARG_REQUIRED | MP_ARG_INT, {.u_int = 0} },
167167
{ MP_QSTR_pull, MP_ARG_REQUIRED | MP_ARG_INT, {.u_int = 0} },
168168
{ MP_QSTR_callback, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
@@ -271,12 +271,12 @@ void extint_init0(void) {
271271
}
272272

273273
extint_obj_t* extint_register(mp_obj_t pin_obj, uint32_t intmode, uint32_t pull, mp_obj_t callback) {
274-
const gpio_obj_t *gpio = NULL;
274+
const pin_obj_t *pin = NULL;
275275
extint_obj_t* self;
276276
void *handler;
277277
uint32_t intnum;
278278

279-
gpio = gpio_find(pin_obj);
279+
pin = pin_find(pin_obj);
280280

281281
if (intmode != GPIO_FALLING_EDGE &&
282282
intmode != GPIO_RISING_EDGE &&
@@ -294,8 +294,8 @@ extint_obj_t* extint_register(mp_obj_t pin_obj, uint32_t intmode, uint32_t pull,
294294
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_value_invalid_arguments));
295295
}
296296

297-
if (NULL == (self = extint_find(gpio->port, gpio->bit))) {
298-
self = extint_add(gpio->pin_num, gpio->port, gpio->bit);
297+
if (NULL == (self = extint_find(pin->port, pin->bit))) {
298+
self = extint_add(pin->pin_num, pin->port, pin->bit);
299299
}
300300
else {
301301
// we need to update the callback atomically, so we disable the line
@@ -307,10 +307,10 @@ extint_obj_t* extint_register(mp_obj_t pin_obj, uint32_t intmode, uint32_t pull,
307307
self->callback = NULL;
308308

309309
// before enabling the interrupt, configure the gpio pin
310-
gpio_config(gpio, PIN_MODE_0, GPIO_DIR_MODE_IN, pull, PIN_STRENGTH_4MA);
310+
pin_config(pin, PIN_MODE_0, GPIO_DIR_MODE_IN, pull, PIN_STRENGTH_4MA);
311311

312-
MAP_GPIOIntTypeSet(gpio->port, gpio->bit, intmode);
313-
switch (gpio->port) {
312+
MAP_GPIOIntTypeSet(pin->port, pin->bit, intmode);
313+
switch (pin->port) {
314314
case GPIOA0_BASE:
315315
handler = GPIOA0IntHandler;
316316
intnum = INT_GPIOA0;
@@ -330,7 +330,7 @@ extint_obj_t* extint_register(mp_obj_t pin_obj, uint32_t intmode, uint32_t pull,
330330
break;
331331
}
332332

333-
MAP_GPIOIntRegister(gpio->port, handler);
333+
MAP_GPIOIntRegister(pin->port, handler);
334334
// set the interrupt to the lowest priority, to make sure that no ther
335335
// isr will be preemted by this one
336336
MAP_IntPrioritySet(intnum, INT_PRIORITY_LVL_7);

0 commit comments

Comments
 (0)