driver(gpio) : Fixed the gpio related bug for release v3.1.

This commit is contained in:
hou wen xiang 2018-06-04 10:34:23 +08:00 committed by XiongYu
parent 01efe9a300
commit 5402ace528
3 changed files with 26 additions and 5 deletions

View File

@ -91,9 +91,19 @@ esp_err_t gpio_set_intr_type(gpio_num_t gpio_num, gpio_int_type_t intr_type)
return ESP_OK;
}
static void gpio_intr_status_clr(gpio_num_t gpio_num)
{
if (gpio_num < 32) {
GPIO.status_w1tc = BIT(gpio_num);
} else {
GPIO.status1_w1tc.intr_st = BIT(gpio_num - 32);
}
}
static esp_err_t gpio_intr_enable_on_core (gpio_num_t gpio_num, uint32_t core_id)
{
GPIO_CHECK(GPIO_IS_VALID_GPIO(gpio_num), "GPIO number error", ESP_ERR_INVALID_ARG);
gpio_intr_status_clr(gpio_num);
if (core_id == 0) {
GPIO.pin[gpio_num].int_ena = GPIO_PRO_CPU_INTR_ENA; //enable pro cpu intr
} else {
@ -111,6 +121,7 @@ esp_err_t gpio_intr_disable(gpio_num_t gpio_num)
{
GPIO_CHECK(GPIO_IS_VALID_GPIO(gpio_num), "GPIO number error", ESP_ERR_INVALID_ARG);
GPIO.pin[gpio_num].int_ena = 0; //disable GPIO intr
gpio_intr_status_clr(gpio_num);
return ESP_OK;
}
@ -249,7 +260,11 @@ esp_err_t gpio_config(const gpio_config_t *pGPIOConfig)
}
do {
io_reg = GPIO_PIN_MUX_REG[io_num];
if (((gpio_pin_mask >> io_num) & BIT(0)) && io_reg) {
if (((gpio_pin_mask >> io_num) & BIT(0))) {
if (!io_reg) {
ESP_LOGE(GPIO_TAG, "IO%d is not a valid GPIO",io_num);
return ESP_ERR_INVALID_ARG;
}
if(RTC_GPIO_IS_VALID_GPIO(io_num)){
rtc_gpio_deinit(io_num);
}

View File

@ -249,13 +249,13 @@ esp_err_t gpio_config(const gpio_config_t *pGPIOConfig);
/**
* @brief Reset an gpio to default state (select gpio function, enable pullup and disable input and output).
*
*
* @param gpio_num GPIO number.
*
*
* @note This function also configures the IOMUX for this pin to the GPIO
* function, and disconnects any other peripheral output configured via GPIO
* Matrix.
*
*
* @return Always return ESP_OK.
*/
esp_err_t gpio_reset_pin(gpio_num_t gpio_num);

View File

@ -13,13 +13,16 @@
#include "freertos/task.h"
#include "freertos/queue.h"
#define WAKE_UP_IGNORE 1 // gpio_wakeup function development is not completed yet, set it deprecated.
#define GPIO_OUTPUT_IO 18 // default output GPIO
#define GPIO_INPUT_IO 19 // default input GPIO
#define GPIO_OUTPUT_MAX GPIO_NUM_34
static volatile int disable_intr_times = 0; // use this to calculate how many times it go into interrupt
static volatile int level_intr_times = 0; // use this to get how many times the level interrupt happened
static volatile int edge_intr_times = 0; // use this to get how many times the edge interrupt happened
#if !WAKE_UP_IGNORE
static bool wake_up_result = false; // use this to judge the wake up event happen or not
#endif
/**
* do some initialization operation in this function
@ -70,6 +73,7 @@ static void gpio_isr_level_handler2(void* arg)
ets_printf("GPIO[%d] intr, val: %d, level_intr_times = %d\n", gpio_num, gpio_get_level(gpio_num), level_intr_times);
}
#if !WAKE_UP_IGNORE
// get result of waking up or not
static void sleep_wake_up(void *arg)
{
@ -92,7 +96,7 @@ static void trigger_wake_up(void *arg)
gpio_set_level(GPIO_OUTPUT_IO, 1);
vTaskDelay(100 / portTICK_RATE_MS);
}
#endif
static void prompt_to_continue(const char* str)
{
@ -465,6 +469,7 @@ TEST_CASE("GPIO repeate call service and isr has no memory leak test","[gpio][te
TEST_ASSERT_INT32_WITHIN(size, esp_get_free_heap_size(), 100);
}
#if !WAKE_UP_IGNORE
//this function development is not completed yet, set it ignored
TEST_CASE("GPIO wake up enable and disenable test", "[gpio][ignore]")
{
@ -479,6 +484,7 @@ TEST_CASE("GPIO wake up enable and disenable test", "[gpio][ignore]")
vTaskDelay(100 / portTICK_RATE_MS);
TEST_ASSERT_FALSE(wake_up_result);
}
#endif
// this case need the resistance to pull up the voltage or pull down the voltage
// ignored because the voltage needs to be tested with multimeter