Commit 00787878 authored by Daniel Campora's avatar Daniel Campora
Browse files

cc3200: Rename pins from GPIO to just GP.

This is how the names will be printed on the sticker that goes on top
of the EMI shield. The shorter names also help saving a few bytes of
RAM and ROM.
parent cfc4c338
......@@ -38,8 +38,8 @@
#define MICROPY_STDIO_UART 1
#define MICROPY_STDIO_UART_BAUD 115200
#define MICROPY_STDIO_UART_RX_BUF_SIZE 128
#define MICROPY_STDIO_UART_TX_PIN (pin_GPIO1)
#define MICROPY_STDIO_UART_RX_PIN (pin_GPIO2)
#define MICROPY_STDIO_UART_TX_PIN (pin_GP1)
#define MICROPY_STDIO_UART_RX_PIN (pin_GP2)
#define MICROPY_STDIO_UART_TX_PIN_AF PIN_MODE_3
#define MICROPY_STDIO_UART_RX_PIN_AF PIN_MODE_3
......@@ -47,9 +47,9 @@
#define MICROPY_SAFE_BOOT_PRCM PRCM_GPIOA2
#define MICROPY_SYS_LED_PORT GPIOA1_BASE
#define MICROPY_SAFE_BOOT_PORT GPIOA2_BASE
#define MICROPY_SYS_LED_GPIO pin_GPIO9
#define MICROPY_SYS_LED_PIN_NUM PIN_64 // GPIO9
#define MICROPY_SAFE_BOOT_PIN_NUM PIN_15 // GPIO22
#define MICROPY_SYS_LED_GPIO pin_GP9
#define MICROPY_SYS_LED_PIN_NUM PIN_64 // GP9
#define MICROPY_SAFE_BOOT_PIN_NUM PIN_15 // GP22
#define MICROPY_SYS_LED_PORT_PIN GPIO_PIN_1
#define MICROPY_SAFE_BOOT_PORT_PIN GPIO_PIN_6
......
......@@ -39,9 +39,9 @@
#define MICROPY_SAFE_BOOT_PRCM PRCM_GPIOA3
#define MICROPY_SYS_LED_PORT GPIOA3_BASE
#define MICROPY_SAFE_BOOT_PORT GPIOA3_BASE
#define MICROPY_SYS_LED_GPIO pin_GPIO25
#define MICROPY_SYS_LED_PIN_NUM PIN_21 // GPIO25 (SOP2)
#define MICROPY_SAFE_BOOT_PIN_NUM PIN_18 // GPIO28
#define MICROPY_SYS_LED_GPIO pin_GP25
#define MICROPY_SYS_LED_PIN_NUM PIN_21 // GP25 (SOP2)
#define MICROPY_SAFE_BOOT_PIN_NUM PIN_18 // GP28
#define MICROPY_SYS_LED_PORT_PIN GPIO_PIN_1
#define MICROPY_SAFE_BOOT_PORT_PIN GPIO_PIN_4
......
L2,GPIO2
L3,GPIO1
L4,GPIO23
L5,GPIO24
L6,GPIO11
L7,GPIO12
L8,GPIO13
L9,GPIO14
L10,GPIO15
L11,GPIO16
L12,GPIO17
L13,GPIO22
L14,GPIO28
R4,GPIO10
R5,GPIO9
R6,GPIO8
R7,GPIO7
R8,GPIO6
R9,GPIO30
R10,GPIO31
R11,GPIO3
R12,GPIO0
R13,GPIO4
R14,GPIO5
HBL,GPIO25
L2,GP2
L3,GP1
L4,GP23
L5,GP24
L6,GP11
L7,GP12
L8,GP13
L9,GP14
L10,GP15
L11,GP16
L12,GP17
L13,GP22
L14,GP28
R4,GP10
R5,GP9
R6,GP8
R7,GP7
R8,GP6
R9,GP30
R10,GP31
R11,GP3
R12,GP0
R13,GP4
R14,GP5
HBL,GP25
Pin,Name,Default,AF0,AF1,AF2,AF3,AF4,AF5,AF6,AF7,AF8,AF9,AF10,AF11,AF12,AF13,AF14,AF15,ADC
1,GPIO10,GPIO10,GPIO10,I2C_SCL,,GT_PWM06,,,SDCARD_CLK,UART1_TX,,,,,GT_CCP01,,,,
2,GPIO11,GPIO11,GPIO11,I2C_SDA,,GT_PWM07,pXCLK(XVCLK),,SDCARD_CMD,UART1_RX,,,,,GT_CCP02,McAFSX,,,
3,GPIO12,GPIO12,GPIO12,,,McACLK,pVS(VSYNC),I2C_SCL,,UART0_TX,,,,,GT_CCP03,,,,
4,GPIO13,GPIO13,GPIO13,,,,pHS(HSYNC),I2C_SDA,,UART0_RX,,,,,GT_CCP04,,,,
5,GPIO14,GPIO14,GPIO14,,,,pDATA8(CAM_D4),2C_SCL,,GSPI_CLK,,,,,GT_CCP05,,,,
6,GPIO15,GPIO15,GPIO15,,,,pDATA9(CAM_D5),I2C_SDA,,GSPI_MISO,,,,,,GT_CCP06,,,
7,GPIO16,GPIO16,GPIO16,,,,pDATA10(CAM_D6),UART1_TX,,GSPI_MOSI,,,,,,GT_CCP07,,,
8,GPIO17,GPIO17,GPIO17,,,,pDATA11(CAM_D7),UART1_RX,,GSPI_CS,,,,,,,,,
1,GP10,GP10,GP10,I2C_SCL,,GT_PWM06,,,SDCARD_CLK,UART1_TX,,,,,GT_CCP01,,,,
2,GP11,GP11,GP11,I2C_SDA,,GT_PWM07,pXCLK(XVCLK),,SDCARD_CMD,UART1_RX,,,,,GT_CCP02,McAFSX,,,
3,GP12,GP12,GP12,,,McACLK,pVS(VSYNC),I2C_SCL,,UART0_TX,,,,,GT_CCP03,,,,
4,GP13,GP13,GP13,,,,pHS(HSYNC),I2C_SDA,,UART0_RX,,,,,GT_CCP04,,,,
5,GP14,GP14,GP14,,,,pDATA8(CAM_D4),2C_SCL,,GSPI_CLK,,,,,GT_CCP05,,,,
6,GP15,GP15,GP15,,,,pDATA9(CAM_D5),I2C_SDA,,GSPI_MISO,,,,,,GT_CCP06,,,
7,GP16,GP16,GP16,,,,pDATA10(CAM_D6),UART1_TX,,GSPI_MOSI,,,,,,GT_CCP07,,,
8,GP17,GP17,GP17,,,,pDATA11(CAM_D7),UART1_RX,,GSPI_CS,,,,,,,,,
9,VDD_DIG1,VDD_DIG1,VDD_DIG1,,,,,,,,,,,,,,,,
10,VIN_IO1,VIN_IO1,VIN_IO1,,,,,,,,,,,,,,,,
11,FLASH_SPI_CLK,FLASH_SPI_CLK,FLASH_SPI_CLK,,,,,,,,,,,,,,,,
12,FLASH_SPI_DOUT,FLASH_SPI_DOUT,FLASH_SPI_DOUT,,,,,,,,,,,,,,,,
13,FLASH_SPI_DIN,FLASH_SPI_DIN,FLASH_SPI_DIN,,,,,,,,,,,,,,,,
14,FLASH_SPI_CS,FLASH_SPI_CS,FLASH_SPI_CS,,,,,,,,,,,,,,,,
15,GPIO22,GPIO22,GPIO22,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C_CH0
58,GPIO3,GPIO3,GPIO3,,,,pDATA7(CAM_D3),,UART1_TX,,,,,,,,,,ADC_CH1
59,GPIO4,GPIO4,GPIO4,,,,pDATA6(CAM_D2),,UART1_RX,,,,,,,,,,ADC_CH2
60,GPIO5,GPIO5,GPIO5,,,,pDATA5(CAM_D1),,McAXR1,GT_CCP05,,,,,,,,,ADC_CH3
61,GPIO6,GPIO6,GPIO6,,,UART1_CTS,pDATA4(CAM_D0),UART0_RTS,UART0_CTS,GT_CCP06,,,,,,,,,
62,GPIO7,GPIO7,GPIO7,,,UART1_RTS,,,,,,,UART0_RTS,UART0_TX,,McACLKX,,,
63,GPIO8,GPIO8,GPIO8,,,,,,SDCARD_IRQ,McAFSX,,,,,GT_CCP06,,,,
64,GPIO9,GPIO9,GPIO9,,,GT_PWM05,,,SDCARD_DATA,McAXR0,,,,,GT_CCP00,,,,
57,GP2,GP2,GP2,,,UART0_RX,,,UART1_RX,GT_CCP02,,,,,,,,,ADC_CH0
58,GP3,GP3,GP3,,,,pDATA7(CAM_D3),,UART1_TX,,,,,,,,,,ADC_CH1
59,GP4,GP4,GP4,,,,pDATA6(CAM_D2),,UART1_RX,,,,,,,,,,ADC_CH2
60,GP5,GP5,GP5,,,,pDATA5(CAM_D1),,McAXR1,GT_CCP05,,,,,,,,,ADC_CH3
61,GP6,GP6,GP6,,,UART1_CTS,pDATA4(CAM_D0),UART0_RTS,UART0_CTS,GT_CCP06,,,,,,,,,
62,GP7,GP7,GP7,,,UART1_RTS,,,,,,,UART0_RTS,UART0_TX,,McACLKX,,,
63,GP8,GP8,GP8,,,,,,SDCARD_IRQ,McAFSX,,,,,GT_CCP06,,,,
64,GP9,GP9,GP9,,,GT_PWM05,,,SDCARD_DATA,McAXR0,,,,,GT_CCP00,,,,
65,GND_TAB,GND_TAB,GND_TAB,,,,,,,,,,,,,,,,
......@@ -10,14 +10,14 @@ import csv
def parse_port_pin(name_str):
"""Parses a string and returns a (port, gpio_bit) tuple."""
if len(name_str) < 5:
raise ValueError("Expecting pin name to be at least 5 characters")
if name_str[:4] != 'GPIO':
raise ValueError("Expecting pin name to start with GPIO")
if not name_str[4:].isdigit():
if len(name_str) < 3:
raise ValueError("Expecting pin name to be at least 3 characters")
if name_str[:2] != 'GP':
raise ValueError("Expecting pin name to start with GP")
if not name_str[2:].isdigit():
raise ValueError("Expecting numeric GPIO number")
port = int(int(name_str[4:]) / 8)
gpio_bit = 1 << int(int(name_str[4:]) % 8)
port = int(int(name_str[2:]) / 8)
gpio_bit = 1 << int(int(name_str[2:]) % 8)
return (port, gpio_bit)
......
......@@ -119,19 +119,19 @@ STATIC mp_obj_t adc_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw,
switch (idx) {
case 0:
channel = ADC_CH_0;
pin = &pin_GPIO2;
pin = &pin_GP2;
break;
case 1:
channel = ADC_CH_1;
pin = &pin_GPIO3;
pin = &pin_GP3;
break;
case 2:
channel = ADC_CH_2;
pin = &pin_GPIO4;
pin = &pin_GP4;
break;
case 3:
channel = ADC_CH_3;
pin = &pin_GPIO5;
pin = &pin_GP5;
break;
default:
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
......
......@@ -135,11 +135,11 @@ STATIC pybpin_wake_pin_t pybpin_wake_pin[PYBPIN_NUM_WAKE_PINS] =
DEFINE PUBLIC FUNCTIONS
******************************************************************************/
void pin_init0(void) {
// assign GPIO10 and GPIO11 to the GPIO peripheral (the default is I2C), so that the I2C bus can
// assign GP10 and GP11 to the GPIO peripheral (the default is I2C), so that the I2C bus can
// be assigned safely to any other pins (as recomended by the SDK release notes). Make them
// inputs with pull-downs enabled to ensure they are not floating during LDPS and hibernate.
pin_config ((pin_obj_t *)&pin_GPIO10, PIN_MODE_0, GPIO_DIR_MODE_IN, PIN_TYPE_STD_PD, PIN_STRENGTH_2MA);
pin_config ((pin_obj_t *)&pin_GPIO11, PIN_MODE_0, GPIO_DIR_MODE_IN, PIN_TYPE_STD_PD, PIN_STRENGTH_2MA);
pin_config ((pin_obj_t *)&pin_GP10, PIN_MODE_0, GPIO_DIR_MODE_IN, PIN_TYPE_STD_PD, PIN_STRENGTH_2MA);
pin_config ((pin_obj_t *)&pin_GP11, PIN_MODE_0, GPIO_DIR_MODE_IN, PIN_TYPE_STD_PD, PIN_STRENGTH_2MA);
}
// C API used to convert a user-supplied pin name into an ordinal pin number.
......@@ -210,27 +210,27 @@ STATIC void pin_obj_configure (const pin_obj_t *self) {
STATIC void pin_get_hibernate_pin_and_idx (const pin_obj_t *self, uint *hib_pin, uint *idx) {
// pin_num is actually : (package_pin - 1)
switch (self->pin_num) {
case 56: // GPIO2
case 56: // GP2
*hib_pin = PRCM_HIB_GPIO2;
*idx = 0;
break;
case 58: // GPIO4
case 58: // GP4
*hib_pin = PRCM_HIB_GPIO4;
*idx = 1;
break;
case 3: // GPIO13
case 3: // GP13
*hib_pin = PRCM_HIB_GPIO13;
*idx = 2;
break;
case 7: // GPIO17
case 7: // GP17
*hib_pin = PRCM_HIB_GPIO17;
*idx = 3;
break;
case 1: // GPIO11
case 1: // GP11
*hib_pin = PRCM_HIB_GPIO11;
*idx = 4;
break;
case 16: // GPIO24
case 16: // GP24
*hib_pin = PRCM_HIB_GPIO24;
*idx = 5;
break;
......
......@@ -49,7 +49,7 @@ Constructors
.. warning::
ADC pin input range is 0-1.4V (being 1.8V the absolute maximum that it
can withstand). When GPIO2, GPIO3, GPIO4 or GPIO5 are remapped to the
can withstand). When GP2, GP3, GP4 or GP5 are remapped to the
ADC block, 1.8 V is the maximum. If these pins are used in digital mode,
then the maximum allowed input is 3.6V.
......
......@@ -5,8 +5,8 @@ class HeartBeat -- heart beat LED
The HeartBeat class controls the heart beat led which by default
flashes once every 5s. The user can disable the HeartBeat and then
is free to control this LED manually through GPIO25 using the Pin
class. The GPIO25 can also be remapped as a PWM output, an this
is free to control this LED manually through GP25 using the Pin
class. The GP25 can also be remapped as a PWM output, an this
can be used to control the light intesity of the heart beat LED.
Example usage::
......@@ -39,8 +39,8 @@ Methods
# disable the heart beat
pyb.HeartBeat().disable()
# get the GPIO25 pin object
hbl = pyb.Pin('GPIO25')
# get the GP25 pin object
hbl = pyb.Pin('GP25')
# toggle the led
hbl.toggle()
...
......@@ -67,14 +67,14 @@ Usage Model:
Board pins are identified by their string name::
g = pyb.Pin('GPIO9', af=0, mode=pyb.Pin.IN, type=pyb.Pin.STD, strength=pyb.Pin.S2MA)
g = pyb.Pin('GP9', af=0, mode=pyb.Pin.IN, type=pyb.Pin.STD, strength=pyb.Pin.S2MA)
You can also configure the Pin to generate interrupts. For instance::
def pincb(pin):
print(pin.name())
pin_int = pyb.Pin('GPIO10', af=0, mode=Pin.IN, type=pyb.Pin.STD_PD, strength=pyb.Pin.S2MA)
pin_int = pyb.Pin('GP10', af=0, mode=Pin.IN, type=pyb.Pin.STD_PD, strength=pyb.Pin.S2MA)
pin_int.callback (mode=pyb.Pin.INT_RISING, handler=pincb)
# the callback can be triggered manually
pin_int.callback()()
......@@ -288,12 +288,12 @@ Methods
board. Please note:
- If ``wakes=pyb.Sleep.ACTIVE`` any pin can wake the board.
- If ``wakes=pyb.Sleep.SUSPENDED`` pins ``GPIO2``, ``GPIO4``, ``GPIO10``,
``GPIO11``, GPIO17`` or ``GPIO24`` can wake the board. Note that only 1
- If ``wakes=pyb.Sleep.SUSPENDED`` pins ``GP2``, ``GP4``, ``GP10``,
``GP11``, GP17`` or ``GP24`` can wake the board. Note that only 1
of this pins can be enabled as a wake source at the same time, so, only
the last enabled pin as a ``pyb.Sleep.SUSPENDED`` wake source will have effect.
- If ``wakes=pyb.Sleep.SUSPENDED`` pins ``GPIO2``, ``GPIO4``, ``GPIO10``,
``GPIO11``, ``GPIO17`` and ``GPIO24`` can wake the board. In this case all of the
- If ``wakes=pyb.Sleep.SUSPENDED`` pins ``GP2``, ``GP4``, ``GP10``,
``GP11``, ``GP17`` and ``GP24`` can wake the board. In this case all of the
6 pins can be enabled as a ``pyb.Sleep.HIBERNATE`` wake source at the same time.
- Values can be ORed to make a pin generate interrupts in more than one power
mode.
......
......@@ -15,7 +15,7 @@ Example usage::
# data, clk and cmd pins must be passed along with
# their respective alternate functions
sd = pyb.SD('GPIO15', 8, 'GPIO10', 6, 'GPIO11', 6)
sd = pyb.SD('GP15', 8, 'GP10', 6, 'GP11', 6)
sd.enable() # enable and mount the SD card
sd.disable() # disable and unmount it
......
......@@ -35,21 +35,21 @@ If you power up normally, or press the reset button, the WiPy will boot
into standard mode; the ``boot.py`` file will be executed first, then
``main.py`` will run.
You can override this boot sequence by pulling ``GPIO28`` **up** (connect
You can override this boot sequence by pulling ``GP28`` **up** (connect
it to the 3v3 output pin) during reset. This procedure also allows going
back in time to old firmware versions. The WiPy can hold up to 3 different
firmware versions, which are: the factory firmware plus 2 user updates.
After reset, if ``GPIO28`` is held high, the heart beat LED will start flashing
After reset, if ``GP28`` is held high, the heart beat LED will start flashing
slowly, if after 3 seconds the pin is still being held high, the LED will start
blinking a bit faster and the WiPy will select the previous user update to boot.
If the previous user update is the desired firmware image, ``GPIO28`` must be
If the previous user update is the desired firmware image, ``GP28`` must be
released before 3 more seconds elapse. If 3 seconds later the pin is still high,
the factory firmware will be selected, the LED will flash quickly for 1.5 seconds
and the WiPy will proceed to boot. The firmware selection mechanism is as follows:
**Safe Boot Pin** ``GPIO28`` **released during:**
**Safe Boot Pin** ``GP28`` **released during:**
+-------------------------+-------------------------+----------------------------+
| 1st 3 secs window | 2nd 3 secs window | Final 1.5 secs window |
......
......@@ -27,14 +27,14 @@ See :ref:`pyb.Pin <pyb.Pin>`. ::
from pyb import Pin
# initialize GPIO2 in gpio mode (af=0) and make it an output
p_out = Pin('GPIO2', af=0, mode=Pin.OUT)
# initialize GP2 in gpio mode (af=0) and make it an output
p_out = Pin('GP2', af=0, mode=Pin.OUT)
p_out.high()
p_out.low()
p_out.toggle()
# make GPIO1 an input with the pull-up enabled
p_in = Pin('GPIO1', af = 0, mode=Pin.IN, type = Pin.STD_PU)
# make GP1 an input with the pull-up enabled
p_in = Pin('GP1', af = 0, mode=Pin.IN, type = Pin.STD_PU)
p_in.value() # get value, 0 or 1
Timers
......@@ -50,7 +50,7 @@ See :ref:`pyb.Timer <pyb.Timer>` and :ref:`pyb.Pin <pyb.Pin>`. ::
tim_a.time() # get the value in microseconds
tim_a.freq(1) # 1 Hz
p_out = Pin('GPIO2', af=0, mode=Pin.OUT)
p_out = Pin('GP2', af=0, mode=Pin.OUT)
tim_a.callback(handler=lambda t: p_out.toggle())
PWM (pulse width modulation)
......@@ -61,8 +61,8 @@ See :ref:`pyb.Pin <pyb.Pin>` and :ref:`pyb.Timer <pyb.Timer>`. ::
from pyb import Timer
from pyb import Pin
# assign GPIO25 to alternate function 5 (PWM)
p_out = Pin('GPIO25', af=9, type=Pin.STD)
# assign GP25 to alternate function 5 (PWM)
p_out = Pin('GP25', af=9, type=Pin.STD)
# timer 2 in PWM mode and width must be 16 buts
tim = Timer(2, mode=Timer.PWM, width=16)
......@@ -88,8 +88,8 @@ See :ref:`pyb.Pin <pyb.Pin>` and :ref:`pyb.UART <pyb.UART>`. ::
from pyb import Pin, UART
# first assign TX and RX to the correct pins
Pin('GPIO1', af=3, mode=Pin.STD_PU) # TX
Pin('GPIO2', af=3, mode=Pin.STD_PU) # RX
Pin('GP1', af=3, mode=Pin.STD_PU) # TX
Pin('GP2', af=3, mode=Pin.STD_PU) # RX
uart = UART(1, 9600)
uart.write('hello')
......@@ -103,10 +103,10 @@ See :ref:`pyb.Pin <pyb.Pin>` and :ref:`pyb.SPI <pyb.SPI>`. ::
from pyb import Pin, SPI
# first assign CLK, MISO, MOSI, CS to the correct pins
Pin('GPIO14', af=7, mode=Pin.STD) # CLK
Pin('GPIO15', af=7, mode=Pin.STD) # MISO
Pin('GPIO16', af=7, mode=Pin.STD) # MOSI
Pin('GPIO17', af=7, mode=Pin.STD) # NSS/CS
Pin('GP14', af=7, mode=Pin.STD) # CLK
Pin('GP15', af=7, mode=Pin.STD) # MISO
Pin('GP16', af=7, mode=Pin.STD) # MOSI
Pin('GP17', af=7, mode=Pin.STD) # NSS/CS
# configure the SPI master @ 2MHz
spi = SPI(1, SPI.MASTER, baudrate=200000, polarity=0, phase=0)
......@@ -122,8 +122,8 @@ See :ref:`pyb.Pin <pyb.Pin>` and :ref:`pyb.I2C <pyb.I2C>`. ::
from pyb import Pin, I2C
# first assign SCL and SDA to the correct pins
Pin('GPIO23', af=9, mode=Pin.STD_PU) # SCL
Pin('GPIO24', af=9, mode=Pin.STD_PU) # SDA
Pin('GP23', af=9, mode=Pin.STD_PU) # SCL
Pin('GP24', af=9, mode=Pin.STD_PU) # SDA
# configure the I2C bus
i2c = I2C(1, I2C.MASTER, baudrate=100000)
......@@ -174,7 +174,7 @@ See :ref:`pyb.SD <pyb.SD>`. ::
# SD card pins need special configuration so we pass 'em to the constructor
# data pin, data af, clock pin, clock af, cmd pin, cmd af
sd = pyb.SD('GPIO15', 8, 'GPIO10', 6, 'GPIO11', 6)
sd = pyb.SD('GP15', 8, 'GP10', 6, 'GP11', 6)
sd.enable()
WLAN (WiFi)
......@@ -220,7 +220,7 @@ See :ref:`pyb.HeartBeat <pyb.HeartBeat>`. ::
from pyb import HeartBeat
# disable the heart beat indication (you are free to use this LED connected to GPIO25)
# disable the heart beat indication (you are free to use this LED connected to GP25)
HeartBeat().disable()
# enable the heart beat again
HeartBeat().enable()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment