Skip to content

Commit

Permalink
Add GPIO1 (UART tx) and GPIO3 (UART rx) finally.
Browse files Browse the repository at this point in the history
This means all supported GPIO's can be used now.

Be careful with GPIO1 and GPIO3, they share the pins
with the UART. If GPIO1 and/or GPIO3 is enabled, you
can't use the UART.

The UART can still be used for programming, though.
  • Loading branch information
Erik Slagter committed Jul 19, 2015
1 parent ecd51a9 commit 52b21ef
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion config.h
Expand Up @@ -11,7 +11,7 @@ enum
{
config_magic = 0x4afc0001,
config_major_version = 1,
config_minor_version = 1
config_minor_version = 2
};

typedef enum __attribute__ ((__packed__))
Expand Down
23 changes: 22 additions & 1 deletion gpios.c
Expand Up @@ -97,6 +97,16 @@ static gpio_trait_t gpio_traits[gpio_size] =
.io_mux = PERIPHS_IO_MUX_GPIO0_U,
.io_func = FUNC_GPIO0,
},
{
.id = gpio_1,
.name = "gpio1",
.index = 1,
.flags = {
.rtc_gpio = 0,
},
.io_mux = PERIPHS_IO_MUX_U0TXD_U,
.io_func = FUNC_GPIO1
},
{
.id = gpio_2,
.name = "gpio2",
Expand All @@ -107,6 +117,16 @@ static gpio_trait_t gpio_traits[gpio_size] =
.io_mux = PERIPHS_IO_MUX_GPIO2_U,
.io_func = FUNC_GPIO2,
},
{
.id = gpio_3,
.name = "gpio3",
.index = 3,
.flags = {
.rtc_gpio = 0,
},
.io_mux = PERIPHS_IO_MUX_U0RXD_U,
.io_func = FUNC_GPIO3,
},
{
.id = gpio_4,
.name = "gpio4",
Expand Down Expand Up @@ -234,7 +254,8 @@ irom void gpios_init(void)
gpio = &gpio_traits[current];
cfg = get_config(gpio);

select_pin_function(gpio);
if(cfg->mode != gpio_disabled)
select_pin_function(gpio);

if(cfg->mode == gpio_counter)
state_change_mask |= (1 << gpio->index);
Expand Down
8 changes: 8 additions & 0 deletions gpios.h
Expand Up @@ -10,9 +10,17 @@
typedef enum __attribute__ ((__packed__))
{
gpio_0 = 0,
gpio_1, // UART TX use with care
gpio_2,
gpio_3, // UART RX use with care
gpio_4,
gpio_5,
// gpio_6, // cannot use, used by flash memory
// gpio_7, // cannot use, used by flash memory
// gpio_8, // cannot use, used by flash memory
// gpio_9, // cannot use, used by flash memory
// gpio_10, // cannot use, used by flash memory
// gpio_11, // cannot use, used by flash memory
gpio_12,
gpio_13,
gpio_14,
Expand Down

0 comments on commit 52b21ef

Please sign in to comment.