Merge branch 'refactor/common_rom_gpio_apis' into 'master'

esp_rom: extract common GPIO apis into esp_rom_gpio.h

See merge request espressif/esp-idf!9248
This commit is contained in:
Ivan Grokhotkov
2020-07-07 17:28:39 +08:00
89 changed files with 440 additions and 595 deletions

View File

@@ -10,6 +10,7 @@
#include "soc/gpio_reg.h"
#include "soc/gpio_sig_map.h"
#include "gpio_pcm_config.h"
#include "esp_rom_gpio.h"
#define GPIO_OUTPUT_PCM_FSYNC (25)
#define GPIO_OUTPUT_PCM_CLK_OUT (5)
@@ -25,7 +26,7 @@ void app_gpio_pcm_io_cfg(void)
gpio_config_t io_conf;
/// configure the PCM output pins
//disable interrupt
io_conf.intr_type = GPIO_PIN_INTR_DISABLE;
io_conf.intr_type = GPIO_INTR_DISABLE;
//set as output mode
io_conf.mode = GPIO_MODE_OUTPUT;
//bit mask of the pins that you want to set,e.g.GPIO18/19
@@ -39,7 +40,7 @@ void app_gpio_pcm_io_cfg(void)
/// configure the PCM input pin
//interrupt of rising edge
io_conf.intr_type = GPIO_PIN_INTR_DISABLE;
io_conf.intr_type = GPIO_INTR_DISABLE;
//bit mask of the pins, use GPIO4/5 here
io_conf.pin_bit_mask = GPIO_INPUT_PCM_PIN_SEL;
//set as input mode
@@ -51,10 +52,10 @@ void app_gpio_pcm_io_cfg(void)
gpio_config(&io_conf);
/// matrix out | in the internal PCM signals to the GPIOs
gpio_matrix_out(GPIO_OUTPUT_PCM_FSYNC, PCMFSYNC_OUT_IDX, false, false);
gpio_matrix_out(GPIO_OUTPUT_PCM_CLK_OUT, PCMCLK_OUT_IDX, false, false);
gpio_matrix_out(GPIO_OUTPUT_PCM_DOUT, PCMDOUT_IDX, false, false);
gpio_matrix_in(GPIO_INPUT_PCM_DIN, PCMDIN_IDX, false);
esp_rom_gpio_connect_out_signal(GPIO_OUTPUT_PCM_FSYNC, PCMFSYNC_OUT_IDX, false, false);
esp_rom_gpio_connect_out_signal(GPIO_OUTPUT_PCM_CLK_OUT, PCMCLK_OUT_IDX, false, false);
esp_rom_gpio_connect_out_signal(GPIO_OUTPUT_PCM_DOUT, PCMDOUT_IDX, false, false);
esp_rom_gpio_connect_in_signal(GPIO_INPUT_PCM_DIN, PCMDIN_IDX, false);
}
#if ACOUSTIC_ECHO_CANCELLATION_ENABLE
@@ -68,7 +69,7 @@ void app_gpio_aec_io_cfg(void)
{
gpio_config_t io_conf;
//disable interrupt
io_conf.intr_type = GPIO_PIN_INTR_DISABLE;
io_conf.intr_type = GPIO_INTR_DISABLE;
//set as output mode
io_conf.mode = GPIO_MODE_OUTPUT;
//bit mask of the pins that you want to set,e.g.GPIO18/19

View File

@@ -10,6 +10,7 @@
#include "soc/gpio_reg.h"
#include "soc/gpio_sig_map.h"
#include "gpio_pcm_config.h"
#include "esp_rom_gpio.h"
#define GPIO_OUTPUT_PCM_FSYNC (25)
#define GPIO_OUTPUT_PCM_CLK_OUT (5)
@@ -25,7 +26,7 @@ void app_gpio_pcm_io_cfg(void)
gpio_config_t io_conf;
/// configure the PCM output pins
//disable interrupt
io_conf.intr_type = GPIO_PIN_INTR_DISABLE;
io_conf.intr_type = GPIO_INTR_DISABLE;
//set as output mode
io_conf.mode = GPIO_MODE_OUTPUT;
//bit mask of the pins that you want to set,e.g.GPIO18/19
@@ -39,7 +40,7 @@ void app_gpio_pcm_io_cfg(void)
/// configure the PCM input pin
//interrupt of rising edge
io_conf.intr_type = GPIO_PIN_INTR_DISABLE;
io_conf.intr_type = GPIO_INTR_DISABLE;
//bit mask of the pins, use GPIO4/5 here
io_conf.pin_bit_mask = GPIO_INPUT_PCM_PIN_SEL;
//set as input mode
@@ -51,10 +52,10 @@ void app_gpio_pcm_io_cfg(void)
gpio_config(&io_conf);
/// matrix out | in the internal PCM signals to the GPIOs
gpio_matrix_out(GPIO_OUTPUT_PCM_FSYNC, PCMFSYNC_OUT_IDX, false, false);
gpio_matrix_out(GPIO_OUTPUT_PCM_CLK_OUT, PCMCLK_OUT_IDX, false, false);
gpio_matrix_out(GPIO_OUTPUT_PCM_DOUT, PCMDOUT_IDX, false, false);
gpio_matrix_in(GPIO_INPUT_PCM_DIN, PCMDIN_IDX, false);
esp_rom_gpio_connect_out_signal(GPIO_OUTPUT_PCM_FSYNC, PCMFSYNC_OUT_IDX, false, false);
esp_rom_gpio_connect_out_signal(GPIO_OUTPUT_PCM_CLK_OUT, PCMCLK_OUT_IDX, false, false);
esp_rom_gpio_connect_out_signal(GPIO_OUTPUT_PCM_DOUT, PCMDOUT_IDX, false, false);
esp_rom_gpio_connect_in_signal(GPIO_INPUT_PCM_DIN, PCMDIN_IDX, false);
}
#if ACOUSTIC_ECHO_CANCELLATION_ENABLE
@@ -68,7 +69,7 @@ void app_gpio_aec_io_cfg(void)
{
gpio_config_t io_conf;
//disable interrupt
io_conf.intr_type = GPIO_PIN_INTR_DISABLE;
io_conf.intr_type = GPIO_INTR_DISABLE;
//set as output mode
io_conf.mode = GPIO_MODE_OUTPUT;
//bit mask of the pins that you want to set,e.g.GPIO18/19

View File

@@ -58,7 +58,7 @@ void board_led_operation(uint8_t pin, uint8_t onoff)
static void board_led_init(void)
{
for (int i = 0; i < 3; i++) {
gpio_pad_select_gpio(led_state[i].pin);
gpio_reset_pin(led_state[i].pin);
gpio_set_direction(led_state[i].pin, GPIO_MODE_OUTPUT);
gpio_set_level(led_state[i].pin, LED_OFF);
led_state[i].previous = LED_OFF;

View File

@@ -10,6 +10,7 @@
#include <stdio.h>
#include "driver/uart.h"
#include "driver/gpio.h"
#include "esp_log.h"
#include "iot_button.h"
@@ -49,7 +50,7 @@ void board_led_operation(uint8_t pin, uint8_t onoff)
static void board_led_init(void)
{
for (int i = 0; i < ARRAY_SIZE(led_state); i++) {
gpio_pad_select_gpio(led_state[i].pin);
gpio_reset_pin(led_state[i].pin);
gpio_set_direction(led_state[i].pin, GPIO_MODE_OUTPUT);
gpio_set_level(led_state[i].pin, LED_OFF);
led_state[i].previous = LED_OFF;

View File

@@ -43,7 +43,7 @@ void board_led_operation(uint8_t pin, uint8_t onoff)
static void board_led_init(void)
{
for (int i = 0; i < 3; i++) {
gpio_pad_select_gpio(led_state[i].pin);
gpio_reset_pin(led_state[i].pin);
gpio_set_direction(led_state[i].pin, GPIO_MODE_OUTPUT);
gpio_set_level(led_state[i].pin, LED_OFF);
led_state[i].previous = LED_OFF;

View File

@@ -42,7 +42,7 @@ void board_led_operation(uint8_t pin, uint8_t onoff)
static void board_led_init(void)
{
for (int i = 0; i < 3; i++) {
gpio_pad_select_gpio(led_state[i].pin);
gpio_reset_pin(led_state[i].pin);
gpio_set_direction(led_state[i].pin, GPIO_MODE_OUTPUT);
gpio_set_level(led_state[i].pin, LED_OFF);
led_state[i].previous = LED_OFF;

View File

@@ -42,7 +42,7 @@ void board_led_operation(uint8_t pin, uint8_t onoff)
static void board_led_init(void)
{
for (int i = 0; i < 3; i++) {
gpio_pad_select_gpio(led_state[i].pin);
gpio_reset_pin(led_state[i].pin);
gpio_set_direction(led_state[i].pin, GPIO_MODE_OUTPUT);
gpio_set_level(led_state[i].pin, LED_OFF);
led_state[i].previous = LED_OFF;

View File

@@ -58,7 +58,7 @@ void board_led_operation(uint8_t pin, uint8_t onoff)
static void board_led_init(void)
{
for (int i = 0; i < 3; i++) {
gpio_pad_select_gpio(led_state[i].pin);
gpio_reset_pin(led_state[i].pin);
gpio_set_direction(led_state[i].pin, GPIO_MODE_OUTPUT);
gpio_set_level(led_state[i].pin, LED_OFF);
led_state[i].previous = LED_OFF;

View File

@@ -102,7 +102,7 @@ This demo calls the `board_init` function to:
```c
for (int i = 0; i < 3; i++) {
gpio_pad_select_gpio(led_state[i].pin);
esp_rom_gpio_pad_select_gpio(led_state[i].pin);
gpio_set_direction(led_state[i].pin, GPIO_MODE_OUTPUT);
gpio_set_level(led_state[i].pin, LED_OFF);
led_state[i].previous = LED_OFF;

View File

@@ -838,7 +838,7 @@ static esp_err_t emac_enc28j60_init(esp_eth_mac_t *mac)
esp_eth_mediator_t *eth = emac->eth;
/* init gpio used for reporting enc28j60 interrupt */
gpio_pad_select_gpio(emac->int_gpio_num);
gpio_reset_pin(emac->int_gpio_num);
gpio_set_direction(emac->int_gpio_num, GPIO_MODE_INPUT);
gpio_set_pull_mode(emac->int_gpio_num, GPIO_PULLUP_ONLY);
gpio_set_intr_type(emac->int_gpio_num, GPIO_INTR_NEGEDGE);

View File

@@ -163,7 +163,7 @@ static esp_err_t enc28j60_reset_hw(esp_eth_phy_t *phy)
phy_enc28j60_t *enc28j60 = __containerof(phy, phy_enc28j60_t, parent);
// set reset_gpio_num minus zero can skip hardware reset phy chip
if (enc28j60->reset_gpio_num >= 0) {
gpio_pad_select_gpio(enc28j60->reset_gpio_num);
gpio_reset_pin(enc28j60->reset_gpio_num);
gpio_set_direction(enc28j60->reset_gpio_num, GPIO_MODE_OUTPUT);
gpio_set_level(enc28j60->reset_gpio_num, 0);
gpio_set_level(enc28j60->reset_gpio_num, 1);

View File

@@ -25,7 +25,7 @@ void app_main(void)
Technical Reference for a list of pads and their default
functions.)
*/
gpio_pad_select_gpio(BLINK_GPIO);
gpio_reset_pin(BLINK_GPIO);
/* Set the GPIO as a push/pull output */
gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT);
while(1) {

View File

@@ -61,7 +61,7 @@ void mqtt_app_publish(char* topic, char *publish_string);
static void initialise_button(void)
{
gpio_config_t io_conf = {0};
io_conf.intr_type = GPIO_PIN_INTR_DISABLE;
io_conf.intr_type = GPIO_INTR_DISABLE;
io_conf.pin_bit_mask = BIT64(EXAMPLE_BUTTON_GPIO);
io_conf.mode = GPIO_MODE_INPUT;
io_conf.pull_up_en = 1;

View File

@@ -61,7 +61,7 @@ void app_main(void)
{
gpio_config_t io_conf;
//disable interrupt
io_conf.intr_type = GPIO_PIN_INTR_DISABLE;
io_conf.intr_type = GPIO_INTR_DISABLE;
//set as output mode
io_conf.mode = GPIO_MODE_OUTPUT;
//bit mask of the pins that you want to set,e.g.GPIO18/19
@@ -74,7 +74,7 @@ void app_main(void)
gpio_config(&io_conf);
//interrupt of rising edge
io_conf.intr_type = GPIO_PIN_INTR_POSEDGE;
io_conf.intr_type = GPIO_INTR_POSEDGE;
//bit mask of the pins, use GPIO4/5 here
io_conf.pin_bit_mask = GPIO_INPUT_PIN_SEL;
//set as input mode

View File

@@ -58,11 +58,11 @@ Immediately after that the LED should start brightening and dimming.
If you are using [ESP-WROVER-KIT](https://www.espressif.com/en/products/hardware/esp-wrover-kit/overview) then this board has an RGB LED already installed. GPIO4 is driving blue color of the LED. The brightening and dimming effect of the blue LED may not be distinctly visible because red and green LEDs are not actively driven by this example and will slightly lit. To resolve this issue you can switch both diodes off by adding the following code at the end of `sigmadelta_example_init()` function:
```c
gpio_pad_select_gpio(GPIO_NUM_0);
esp_rom_gpio_pad_select_gpio(GPIO_NUM_0);
gpio_set_direction(GPIO_NUM_0, GPIO_MODE_OUTPUT);
gpio_set_level(GPIO_NUM_0, 0);
gpio_pad_select_gpio(GPIO_NUM_2);
esp_rom_gpio_pad_select_gpio(GPIO_NUM_2);
gpio_set_direction(GPIO_NUM_2, GPIO_MODE_OUTPUT);
gpio_set_level(GPIO_NUM_2, 0);
```

View File

@@ -119,7 +119,7 @@ void app_main(void)
//GPIO config for the handshake line.
gpio_config_t io_conf={
.intr_type=GPIO_PIN_INTR_POSEDGE,
.intr_type=GPIO_INTR_POSEDGE,
.mode=GPIO_MODE_INPUT,
.pull_up_en=1,
.pin_bit_mask=(1<<GPIO_HANDSHAKE)
@@ -137,7 +137,7 @@ void app_main(void)
//Set up handshake line interrupt.
gpio_config(&io_conf);
gpio_install_isr_service(0);
gpio_set_intr_type(GPIO_HANDSHAKE, GPIO_PIN_INTR_POSEDGE);
gpio_set_intr_type(GPIO_HANDSHAKE, GPIO_INTR_POSEDGE);
gpio_isr_handler_add(GPIO_HANDSHAKE, gpio_handshake_isr_handler, NULL);
//Initialize the SPI bus and add the device we want to send stuff to.

View File

@@ -27,6 +27,7 @@
#include "esp_log.h"
#include "driver/gpio.h"
#include "driver/twai.h"
#include "esp_rom_gpio.h"
/* --------------------- Definitions and static variables ------------------ */
//Example Configuration
@@ -53,10 +54,10 @@ static void invert_tx_bits(bool enable)
{
if (enable) {
//Inverts output of TX to trigger errors
gpio_matrix_out(TX_GPIO_NUM, TWAI_TX_IDX, true, false);
esp_rom_gpio_connect_out_signal(TX_GPIO_NUM, TWAI_TX_IDX, true, false);
} else {
//Returns TX to default settings
gpio_matrix_out(TX_GPIO_NUM, TWAI_TX_IDX, false, false);
esp_rom_gpio_connect_out_signal(TX_GPIO_NUM, TWAI_TX_IDX, false, false);
}
}

View File

@@ -139,7 +139,7 @@ static void query_mdns_host(const char * host_name)
static void initialise_button(void)
{
gpio_config_t io_conf = {0};
io_conf.intr_type = GPIO_PIN_INTR_DISABLE;
io_conf.intr_type = GPIO_INTR_DISABLE;
io_conf.pin_bit_mask = BIT64(EXAMPLE_BUTTON_GPIO);
io_conf.mode = GPIO_MODE_INPUT;
io_conf.pull_up_en = 1;

View File

@@ -167,7 +167,7 @@ void app_main(void)
err = save_restart_counter();
if (err != ESP_OK) printf("Error (%s) saving restart counter to NVS!\n", esp_err_to_name(err));
gpio_pad_select_gpio(GPIO_NUM_0);
gpio_reset_pin(GPIO_NUM_0);
gpio_set_direction(GPIO_NUM_0, GPIO_MODE_DEF_INPUT);
/* Read the status of GPIO0. If GPIO0 is LOW for longer than 1000 ms,

View File

@@ -32,7 +32,7 @@ static void blink_task(void *pvParameter)
Technical Reference for a list of pads and their default
functions.)
*/
gpio_pad_select_gpio(BLINK_GPIO);
gpio_reset_pin(BLINK_GPIO);
/* Set the GPIO as a push/pull output */
gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT);

View File

@@ -249,7 +249,7 @@ static void ota_example_task(void *pvParameter)
static bool diagnostic(void)
{
gpio_config_t io_conf;
io_conf.intr_type = GPIO_PIN_INTR_DISABLE;
io_conf.intr_type = GPIO_INTR_DISABLE;
io_conf.mode = GPIO_MODE_INPUT;
io_conf.pin_bit_mask = (1ULL << CONFIG_EXAMPLE_GPIO_DIAGNOSTIC);
io_conf.pull_down_en = GPIO_PULLDOWN_DISABLE;