esp_err_t Core2ForAWS_Port_Write(gpio_num_t pin, bool level)
Writes the specified level (0 or 1) to the specified digital pin.
Definition: core2forAWS.c:508
Writes the specified level (0 or 1) to the specified digital pin.
- Note
- pin_mode_t for a GPIO pin must be set to OUTPUT before using Core2ForAWS_Port_Write for that pin.
-
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 sets the specified pin to either high(1) or low(0) digital level.
The example code sets the GPIO 26 (same as PORT_B_DAC_PIN) pin mode to OUTPUT, creates a FreeRTOS task which periodically (1s) toggles GPIO 26 pin between high and low and prints the output level 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_WRITE_DEMO";
void pin_write_task(){
bool output = 0;
for(;;){
ESP_LOGI(
TAG,
"Output on GPIO %d: %s", GPIO_NUM_26, output ?
"HIGH" :
"LOW");
output = !output;
vTaskDelay(pdMS_TO_TICKS(1000));
}
}
void app_main(void){
if (err == ESP_OK){
xTaskCreatePinnedToCore(pin_write_task, "write_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.
@ OUTPUT
Set GPIO to output mode.
Definition: core2forAWS.h:214
#define TAG
Definition: i2c_device.c:10
- Parameters
-
| [in] | pin | The GPIO pin to set the digital output level of. |
| [in] | level | The digital out level of the pin (low = 0, high = 1). |
- Returns
- esp_err_t. 0 or
ESP_OK if successful.