bool Core2ForAWS_Port_Read(gpio_num_t pin)
Reads the value from a specified digital pin that's set as an input — either 1 (high) or 0 (low).
Definition: core2forAWS.c:502
Reads the value from a specified digital pin that's set as an input — either 1 (high) or 0 (low).
- Note
- pin_mode_t for a GPIO pin must be set to INPUT before using Core2ForAWS_Port_Read for that pin.
-
Reads high when connected to Vcc.
-
The AXP192 PMU is configured to output 5v on the expansion port's VCC pin. Some peripherals require 3.3V and requires adjusting the output from the AXP192. This is currently unsupported, but can be acheived using the AXP192 driver (located in the core2forAWS/axp192 folder) for advanced developers.
This function reads if the specified pin is high (1) or low (0). In order for the pin to read high, the connected peripheral must use the available ground and Vcc pins and not an external power source.
The example code sets GPIO 26 (same as PORT_B_DAC_PIN) as an input, creates a FreeRTOS task which periodically (1s) reads from GPIO 26 to see if a compatible peripheral is connected. The task prints the returned value to the serial monitor.
Example:
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_log.h"
static const char *
TAG =
"DIGITAL_READ_DEMO";
void pin_read_task(){
for(;;){
vTaskDelay(pdMS_TO_TICKS(1000));
}
}
void app_main(void){
if (err == ESP_OK){
xTaskCreatePinnedToCore(pin_read_task, "read_pin", 1024*4, NULL, 1, NULL, 1);
}
}
esp_err_t Core2ForAWS_Port_PinMode(gpio_num_t pin, pin_mode_t mode)
Sets the pin mode of the specified pin.
Definition: core2forAWS.c:431
void Core2ForAWS_Init(void)
Initializes the power chip with default values, enables battery charging, and initializes all enabled...
Definition: core2forAWS.c:32
Functions to initialize and access Core2 for AWS IoT EduKit hardware features.
@ INPUT
Set GPIO to input mode.
Definition: core2forAWS.h:215
#define TAG
Definition: i2c_device.c:10
- Parameters
-
| [in] | pin | The GPIO pin to read. |
- Returns
- 1 for high, 0 for low.