Core2 for AWS IoT EduKit BSP 1.5.1
Core2ForAWS_Port_PinMode
esp_err_t Core2ForAWS_Port_PinMode(gpio_num_t pin, pin_mode_t mode);
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
pin_mode_t
Modes supported by the BSP for the GPIO pins.
Definition: core2forAWS.h:212

Sets the pin mode of the specified pin.

This function sets the mode of the pin. The available modes are defined by pin_mode_t. All pins support digital input/ouput of high/low. Only specified pins support digital output, I2C, ADC, DAC, or UART. View the ESP32 datasheet or official ]Espressif GPIO driver documentation](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/gpio.html)

INPUT sets the pin to be able to perform a digital read. Enables the internal pullup resistor. Voltage should not exceed 3.3v.

OUTPUT sets the pin to be able to perform a digital write. Outputs 3.3v when the pin set to high. Not available on Port B GPIO 36.

I2C checks to ensure the pin you're planning to use is meant for I2C communications. You must use PORT_A_SDA_PIN (same as GPIO 32) for the I2C data pin and PORT_A_SCL_PIN (same as GPIO 33) for the I2C clock line pin. Peripherals attached to expansion port A will use I2C port number 0 (I2C_NUM_0) as the on-board peripherals are on I2C port number 1 (I2C_NUM_1). The APIs provided utilize the built-in pullup resistors on the SDA and SCL lines with the Core2 for AWS IoT EduKit as the I2C controller, and all attached devices as the peripheral.

ADC sets the pin to analog single read mode. Single read mode is suitable for low-frequency sampling operations. Must use PORT_B_ADC_PIN (same as GPIO_NUM_36) since it is the only expansion port pin that is ADC capable.

DAC allows the pin to be set to specified voltages. Must use PORT_B_DAC_PIN (same as GPIO_NUM_26) since it is the only expansion port pin that is DAC capable.

UART enables full-duplex Universal Asynchronous Receiver/ Transmitter (UART) serial communications, utilizing both PORT_C_UART_TX_PIN and PORT_C_UART_RX_PIN for transmiting and receiving data. This function should only be called once for UART since setting one pin to UART will automatically set the other. Must use PORT_C_UART_TX_PIN (same as GPIO_NUM_14) as the UART transmit pin since it is the only expansion port pin that is UART TX capable. Must use PORT_C_UART_RX_PIN (same as GPIO_NUM_13) as the UART receive pin since it is the only expansion port pin that is UART RX capable.

NONE resets the pin and removes frees memory.

The example code below sets the ADC pin (GPIO 36) to ADC mode after initializing the Core2 for AWS IoT EduKit and prints out the result of attempting to set the pin.

Example:

#include <stdio.h>
#include "esp_log.h"
#include "core2forAWS.h"
static const char *TAG = "SET_PINMODE_DEMO";
void app_main(void){
esp_err_t err = Core2ForAWS_Port_PinMode(GPIO_NUM_36, ADC);
ESP_LOGI(TAG, "Status of setting the pin: %d", err);
}
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.
@ ADC
Enable ADC mode. Only available on Port B—GPIO 36.
Definition: core2forAWS.h:218
#define TAG
Definition: i2c_device.c:10
Parameters
[in]pinThe GPIO pin to set the mode of.
[in]modeThe mode to set the GPIO pin.
Returns
esp_err_t. 0 or ESP_OK if successful.