![]() |
Core2 for AWS IoT EduKit BSP 1.5.1
|
Functions to initialize and access Core2 for AWS IoT EduKit hardware features. More...
#include "axp192.h"#include "freertos/FreeRTOS.h"#include "freertos/semphr.h"#include "lvgl/lvgl.h"#include "disp_driver.h"#include "disp_spi.h"#include "ft6336u.h"#include "sk6812.h"#include "button.h"#include "mpu6886.h"#include "bm8563.h"#include "cryptoauthlib.h"#include "atecc608.h"#include "driver/i2s.h"#include "microphone.h"#include "speaker.h"#include "driver/gpio.h"#include "esp_freertos_hooks.h"#include "esp_vfs_fat.h"#include "sdmmc_cmd.h"#include "driver/uart.h"#include "i2c_device.h"Go to the source code of this file.
Macros | |
| #define | SK6812_SIDE_LEFT 0 |
| LEDs on left side of the LED bar. For use with Core2ForAWS_Sk6812_SetSideColor(). More... | |
| #define | SK6812_SIDE_RIGHT 1 |
| LEDs on right side of the LED bar. For use with Core2ForAWS_Sk6812_SetSideColor(). More... | |
| #define | PORT_A_SDA_PIN GPIO_NUM_32 |
| The I2C SDA pin on expansion port A. More... | |
| #define | PORT_A_SCL_PIN GPIO_NUM_33 |
| The I2C SCL pin on expansion port A. More... | |
| #define | PORT_B_ADC_PIN GPIO_NUM_36 |
| The ADC pin on expansion port B. More... | |
| #define | PORT_B_DAC_PIN GPIO_NUM_26 |
| The DAC pin on expansion port B. More... | |
| #define | PORT_C_UART_TX_PIN GPIO_NUM_14 |
| The UART transmission pin on expansion port C. More... | |
| #define | PORT_C_UART_RX_PIN GPIO_NUM_13 |
| The UART receiver pin on expansion port C. More... | |
| #define | PORT_C_UART_NUM UART_NUM_2 |
| The default UART controller used for expansion port C. More... | |
| #define | PORT_A_I2C_STANDARD_BAUD 100000 |
| The standard baud rate for I2C peripherals connected to Port A. More... | |
| #define | UART_RX_BUF_SIZE 2048 |
| The default UART RX ring buffer size. More... | |
| #define | SPI_HOST_USE HSPI_HOST |
| The SPI2 peripheral that controls the SPI bus. More... | |
| #define | SPI_DMA_CHAN 2 |
| DMA channel for SPI bus. More... | |
Enumerations | |
| enum | pin_mode_t { NONE , OUTPUT , INPUT , I2C , ADC , DAC , UART } |
| Modes supported by the BSP for the GPIO pins. More... | |
Functions | |
| void | Core2ForAWS_Init (void) |
| Initializes the power chip with default values, enables battery charging, and initializes all enabled hardware features. More... | |
| void | Core2ForAWS_Button_Init (void) |
| Initializes the button_left, button_middle, button_right virtual buttons using the ft6336u touch controller. More... | |
| void | Core2ForAWS_Speaker_Enable (bool state) |
| Enables or disables the NS4168 speaker amplifier. More... | |
| void | Core2ForAWS_PMU_Init (uint16_t ldo2_volt, uint16_t ldo3_volt, uint16_t dc2_volt, uint16_t dc3_volt) |
| Initializes the AXP192 Power Management Unit (PMU). More... | |
| float | Core2ForAWS_PMU_GetBatVolt (void) |
| Gets the battery voltage with the AXP192. More... | |
| float | Core2ForAWS_PMU_GetBatCurrent (void) |
| Gets the battery current draw with the AXP192. More... | |
| void | Core2ForAWS_Display_Init (void) |
| Initializes the display. More... | |
| void | Core2ForAWS_Display_SetBrightness (uint8_t brightness) |
| Sets the brightness of the display. More... | |
| void | Core2ForAWS_LED_Enable (uint8_t enable) |
| Turns on or off green LED. More... | |
| void | Core2ForAWS_Motor_SetStrength (uint8_t strength) |
| Sets the speed of the vibration motor. More... | |
| void | Core2ForAWS_Sk6812_Init (void) |
| Initializes the SK6812 LED bars. More... | |
| void | Core2ForAWS_Sk6812_SetColor (uint16_t pos, uint32_t color) |
| Sets the color of a single LED in the LED bars. More... | |
| void | Core2ForAWS_Sk6812_SetSideColor (uint8_t side, uint32_t color) |
| Sets the color of all the LEDs on one side of the LED bars. More... | |
| void | Core2ForAWS_Sk6812_SetBrightness (uint8_t brightness) |
| Sets the brightness of the LED bars. More... | |
| void | Core2ForAWS_Sk6812_Show (void) |
| Updates the LEDs in the LED bars with any new values set using Core2ForAWS_Sk6812_SetColor, Core2ForAWS_Sk6812_SetSideColor or Core2ForAWS_Sk6812_SetBrightness. More... | |
| void | Core2ForAWS_Sk6812_Clear (void) |
| Turns off the LEDs in the LED bars and removes any set color. More... | |
| esp_err_t | Core2ForAWS_SDcard_Mount (const char *mount_path, sdmmc_card_t **out_card) |
| Initializes and mounts the SD-Card. More... | |
| esp_err_t | Core2ForAWS_SDcard_Unmount (const char *mount_path, sdmmc_card_t *out_card) |
| Removes the FAT partition and unmounts the SD-Card. More... | |
| esp_err_t | Core2ForAWS_Port_PinMode (gpio_num_t pin, pin_mode_t mode) |
| Sets the pin mode of the specified pin. More... | |
| 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). More... | |
| esp_err_t | Core2ForAWS_Port_Write (gpio_num_t pin, bool level) |
| Writes the specified level (0 or 1) to the specified digital pin. More... | |
| I2CDevice_t | Core2ForAWS_Port_A_I2C_Begin (uint8_t device_address, uint32_t baud) |
| Allocates a peripheral connected to expansion port A. More... | |
| esp_err_t | Core2ForAWS_Port_A_I2C_Read (I2CDevice_t device, uint32_t register_address, uint8_t *data, uint16_t length) |
| Reads from I2C peripheral connected to expansion port A. More... | |
| esp_err_t | Core2ForAWS_Port_A_I2C_Write (I2CDevice_t device, uint32_t register_address, uint8_t *data, uint16_t length) |
| Writes to I2C peripheral connected to expansion port A. More... | |
| void | Core2ForAWS_Port_A_I2C_Close (I2CDevice_t device) |
| Frees the configuration pointer to the I2C peripheral connected on port A. More... | |
| uint32_t | Core2ForAWS_Port_B_ADC_ReadRaw (void) |
| Read the raw ADC value from GPIO36. More... | |
| uint32_t | Core2ForAWS_Port_B_ADC_ReadMilliVolts (void) |
| Read the calibrated ADC voltage from GPIO36. More... | |
| esp_err_t | Core2ForAWS_Port_B_DAC_WriteMilliVolts (uint16_t mvolts) |
| Outputs the specified voltage (millivolts) to the DAC. More... | |
| esp_err_t | Core2ForAWS_Port_C_UART_Begin (uint32_t baud) |
| Configures the UART interface at the specified baud rate. More... | |
| int | Core2ForAWS_Port_C_UART_Send (const char *message, size_t len) |
| Sends a specified length of a user defined message over UART2. More... | |
| int | Core2ForAWS_Port_C_UART_Receive (uint8_t *message_buffer) |
| Reads messages in the UART2 receiver ring buffer. More... | |
Variables | |
| SemaphoreHandle_t | xGuiSemaphore |
| FreeRTOS semaphore to be used when performing any operation on the display. More... | |
| Button_t * | button_left |
| Left virtual touch button. More... | |
| Button_t * | button_middle |
| Middle virtual touch button. More... | |
| Button_t * | button_right |
| Right virtual touch button. More... | |
Functions to initialize and access Core2 for AWS IoT EduKit hardware features.
| #define SK6812_SIDE_LEFT 0 |
LEDs on left side of the LED bar. For use with Core2ForAWS_Sk6812_SetSideColor().
| #define SK6812_SIDE_RIGHT 1 |
LEDs on right side of the LED bar. For use with Core2ForAWS_Sk6812_SetSideColor().
| #define PORT_A_SDA_PIN GPIO_NUM_32 |
The I2C SDA pin on expansion port A.
This maps to GPIO 32 and can be used as the Serial DAta Line (SDA) pin for I2C bus communication. Read more about I2C capabilities of the ESP32 microcontroller and available APIs in the ESP-IDF.
| #define PORT_A_SCL_PIN GPIO_NUM_33 |
The I2C SCL pin on expansion port A.
This maps to GPIO 33 and can be used as the Serial CLock Line (SCL) pin to synchronize I2C bus communication. Read more about I2C capabilities of the ESP32 microcontroller and available APIs in the ESP-IDF.
| #define PORT_B_ADC_PIN GPIO_NUM_36 |
The ADC pin on expansion port B.
This maps to GPIO 36 and is capable of converting analog signals to digital. Read more about using ADCs with the ESP-IDF.
| #define PORT_B_DAC_PIN GPIO_NUM_26 |
The DAC pin on expansion port B.
This maps to GPIO 26 and is capable of converting digital signals to analog. Read more about using DACs with the ESP-IDF.
| #define PORT_C_UART_TX_PIN GPIO_NUM_14 |
The UART transmission pin on expansion port C.
This maps to GPIO 14 and can be used as the transmission channel for UART communication. Read more about UART communications with the ESP-IDF.
| #define PORT_C_UART_RX_PIN GPIO_NUM_13 |
The UART receiver pin on expansion port C.
This maps to GPIO 13 and can be used as the receiver channel for UART communication. Read more about UART communications with the ESP-IDF.
| #define PORT_C_UART_NUM UART_NUM_2 |
The default UART controller used for expansion port C.
This maps to UART controller UART2. Read more about UART communications with the ESP-IDF.
| #define PORT_A_I2C_STANDARD_BAUD 100000 |
The standard baud rate for I2C peripherals connected to Port A.
This is the standard baud rate for I2C peripherals that are connected on Port A, which is 100KHz. Read more about UART communications with the ESP-IDF.
| #define UART_RX_BUF_SIZE 2048 |
The default UART RX ring buffer size.
This is the default size of the UART interface's receiver ring buffer. Read more about UART communications with the ESP-IDF.
| #define SPI_HOST_USE HSPI_HOST |
The SPI2 peripheral that controls the SPI bus.
This is peripheral type used for initializing the SPI bus. There are two peripherals connected to the SPI bus, the ILI9342C display controller and the TF/SD card slot.
| #define SPI_DMA_CHAN 2 |
DMA channel for SPI bus.
This is the channel used by the SPI bus for the ILI9342C display controller and TF/SD card slot.
| enum pin_mode_t |
Modes supported by the BSP for the GPIO pins.
These are the modes supported for the GPIO pins by the BSP. Read more about UART communications with the ESP-IDF.
| void Core2ForAWS_Init | ( | void | ) |
Initializes the power chip with default values, enables battery charging, and initializes all enabled hardware features.
At minimum, this helper function initializes the AXP192 power management unit (PMU) with the green LED and vibration motor off, as well as initializing the following features (if enabled):
| void Core2ForAWS_Button_Init | ( | void | ) |
Initializes the button_left, button_middle, button_right virtual buttons using the ft6336u touch controller.
| void Core2ForAWS_Speaker_Enable | ( | bool | state | ) |
Enables or disables the NS4168 speaker amplifier.
| [in] | state | Desired state of the speaker. 1 to enable, 0 to disable. |
| void Core2ForAWS_PMU_Init | ( | uint16_t | ldo2_volt, |
| uint16_t | ldo3_volt, | ||
| uint16_t | dc2_volt, | ||
| uint16_t | dc3_volt | ||
| ) |
Initializes the AXP192 Power Management Unit (PMU).
Used to directly initialize the AXP192 LDO2, LDO3, DC2, and DC3 pins.
| [in] | ldo2_volt | low-dropout voltage of the display. |
| [in] | ldo3_volt | low-dropout voltage of the vibration motor. |
| [in] | dc2_volt | voltage of the vibration motor. |
| [in] | dc3_volt | voltage of the display. |
| float Core2ForAWS_PMU_GetBatVolt | ( | void | ) |
Gets the battery voltage with the AXP192.
EXAMPLE Get the current battery voltage in the variable named battery_voltage and print the voltage to the serial output.
| float Core2ForAWS_PMU_GetBatCurrent | ( | void | ) |
Gets the battery current draw with the AXP192.
EXAMPLE Get the current battery current in the variable named battery_current and print the current to the serial output.
| void Core2ForAWS_Display_Init | ( | void | ) |
Initializes the display.
You must use this to initialize the display before attempting to write to the display. It initializes the ILI9342C on the SPI bus and the LVGL driver.
gui. | void Core2ForAWS_Display_SetBrightness | ( | uint8_t | brightness | ) |
Sets the brightness of the display.
This function sets the brightness of the display using the AXP192 power management unit. It does not write to the display controller, so it does not require taking the xGuiSemaphore mutex prior to use.
Example:
Set the display brightness to maximum.
| [in] | brightness | the desired brightness of the display. Accepts a value from 0 to 100. |
| void Core2ForAWS_LED_Enable | ( | uint8_t | enable | ) |
Turns on or off green LED.
| [in] | enable | The desired state of the LED. 1 to turn on, 0 to turn off. |
| void Core2ForAWS_Motor_SetStrength | ( | uint8_t | strength | ) |
Sets the speed of the vibration motor.
| [in] | strength | The desired speed of the motor or strength of the vibration. 0 to turn it off, 255 for maximum speed. |
| void Core2ForAWS_Sk6812_Init | ( | void | ) |
Initializes the SK6812 LED bars.
You must use this to initialize the LED bars before attempting to use either of the LED bars.
| void Core2ForAWS_Sk6812_SetColor | ( | uint16_t | pos, |
| uint32_t | color | ||
| ) |
Sets the color of a single LED in the LED bars.
Example:
Set the color of each of the LEDs to white one at a time every second.
| [in] | pos | LED to set. Accepts a value from 0 to 9. |
| [in] | color | Color of the LED. Accepts hexadecimal (web colors). 0x000000 is black and 0xffffff is white. |
Core2ForAWS_Sk6812_Show() after this function for the setting to take effect. | void Core2ForAWS_Sk6812_SetSideColor | ( | uint8_t | side, |
| uint32_t | color | ||
| ) |
Sets the color of all the LEDs on one side of the LED bars.
Example:
Set the left LED bar to green and the right LED bar to red.
| [in] | side | Side of LEDs to set. Accepts SK6812_SIDE_LEFT or SK6812_SIDE_RIGHT. |
| [in] | color | Color of LED to set. Accepts hexadecimal (web colors). 0x000000 is black and 0xffffff is white. |
Core2ForAWS_Sk6812_Show() after this function for the setting to take effect. | void Core2ForAWS_Sk6812_SetBrightness | ( | uint8_t | brightness | ) |
Sets the brightness of the LED bars.
Core2ForAWS_Sk6812_Show() after this function for the setting to take effect.Example:
Set the LEDs to full brightness.
| [in] | brightness | Brightness of the LED bars. 0 is off, 100 is full brightness. |
| void Core2ForAWS_Sk6812_Show | ( | void | ) |
Updates the LEDs in the LED bars with any new values set using Core2ForAWS_Sk6812_SetColor, Core2ForAWS_Sk6812_SetSideColor or Core2ForAWS_Sk6812_SetBrightness.
This function must be executed after setting LED bar values. This saves execution time by updating LEDs once after making multiple changes instead of updating with every change.
| void Core2ForAWS_Sk6812_Clear | ( | void | ) |
Turns off the LEDs in the LED bars and removes any set color.
Core2ForAWS_Sk6812_Show() after this function for the setting to take effect.Example:
Set the LEDs to full brightness.
| esp_err_t Core2ForAWS_SDcard_Mount | ( | const char * | mount_path, |
| sdmmc_card_t ** | out_card | ||
| ) |
Initializes and mounts the SD-Card.
Reading/writing to an inserted SD card can use the standard C functions fopen or fprintf to work with Espressif's virtual file drivers. Visit Espressif's virtual file system component docs for usage.
The example code below, mounts the SD card and then writes a file named hello.txt on the path /sdcard with the contents "Hello <<YOUR SD CARD'S PRODUCT NAME>>!":
Example:
| [in] | mount_path | The path where partition should be registered. |
| [out] | out_card | The pointer to the card information structure. Hold this handle and use it to unmount the card later if needed. |
ESP_OK if successful. | esp_err_t Core2ForAWS_SDcard_Unmount | ( | const char * | mount_path, |
| sdmmc_card_t * | out_card | ||
| ) |
Removes the FAT partition and unmounts the SD-Card.
To learn more about using the SD card, visit Espressif's virtual file system component docs for usage.
The example code below, mounts the SD card, writes a file named hello.txt on the path /sdcard with the contents "Hello
<<YOUR SD CARD'S PRODUCT NAME>>!", and then unmounts the card:
Example:
| [in] | mount_path | The path where partition should be registered. |
| [out] | out_card | The card information structure. |
ESP_OK if successful. | esp_err_t Core2ForAWS_Port_PinMode | ( | gpio_num_t | pin, |
| pin_mode_t | mode | ||
| ) |
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:
| [in] | pin | The GPIO pin to set the mode of. |
| [in] | mode | The mode to set the GPIO pin. |
ESP_OK if successful. | 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).
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:
| [in] | pin | The GPIO pin to read. |
| esp_err_t Core2ForAWS_Port_Write | ( | gpio_num_t | pin, |
| bool | level | ||
| ) |
Writes the specified level (0 or 1) to the specified digital pin.
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:
| [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). |
ESP_OK if successful. | I2CDevice_t Core2ForAWS_Port_A_I2C_Begin | ( | uint8_t | device_address, |
| uint32_t | baud | ||
| ) |
Allocates a peripheral connected to expansion port A.
This function allocates configuration of an attached I2C peripheral on expansion port A with a minimum baud rate of 100,000Hz. The macro PORT_A_I2C_STANDARD_BAUD can used for a generally compatible baud rate for most peripherals. The maximum rate supported by the ESP32-D0WD is 5MHz.
Read more about I2C capabilities of the ESP32 microcontroller and available APIs in the ESP-IDF.
The example code allocates a I2C heart rate sensor peripheral in the variable port_A_peripheral of type I2CDevice_t that has an 8-bit device address of 0xA0 (right-shifted by 1-bit to be a 7-bit address) and using the standard baud rate. It then waits 10 seconds before looping to read from the peripheral, and since the device doesn't take a register address, it uses the macro I2C_NO_REG. The reading is printed every 10 seconds to the serial output.
Example:
| [in] | device_address | The 7-bit I2C device address. |
| [in] | baud | The baud rate of I2C communications. |
| esp_err_t Core2ForAWS_Port_A_I2C_Read | ( | I2CDevice_t | device, |
| uint32_t | register_address, | ||
| uint8_t * | data, | ||
| uint16_t | length | ||
| ) |
Reads from I2C peripheral connected to expansion port A.
This function reads a specified number of bytes starting from the specified register on the peripheral.
Read more about I2C capabilities of the ESP32 microcontroller and available APIs in the ESP-IDF.
The example code allocates a I2C heart rate sensor peripheral called port_A_peripheral of type I2CDevice_t that has an 8-bit device address of 0xA0 (right-shifted by 1-bit to be a 7-bit address) and using the standard baud rate. It then waits 10 seconds before looping to read from the peripheral, and since the device doesn't take a register address, it uses the macro I2C_NO_REG. The reading is printed every 10 seconds to the serial output.
Example:
| [in] | device | The device configuration pointer. |
| [in] | register_address | The address of the register to begin reading from. |
| [out] | data | The data read from the register(s). |
| [in] | length | The number of bytes to read from the peripheral. |
| esp_err_t Core2ForAWS_Port_A_I2C_Write | ( | I2CDevice_t | device, |
| uint32_t | register_address, | ||
| uint8_t * | data, | ||
| uint16_t | length | ||
| ) |
Writes to I2C peripheral connected to expansion port A.
This function writes a specified number of bytes starting from the specified register on the peripheral.
Read more about I2C capabilities of the ESP32 microcontroller and available APIs in the ESP-IDF.
The example code allocates an I2C peripheral called port_A_peripheral of type I2CDevice_t that has a 7-bit device address of 0x68 and uses the standard baud rate. It then writes a single byte of data to a specific register on the device, with a message printed to the serial output if successful.
Example:
| [in] | device | The device configuration pointer. |
| [in] | register_address | The address of the register to begin reading to. |
| [in] | data | The data to write to the register(s). |
| [in] | length | The number of bytes to write to the peripheral. |
| void Core2ForAWS_Port_A_I2C_Close | ( | I2CDevice_t | device | ) |
Frees the configuration pointer to the I2C peripheral connected on port A.
This function frees the allocated memory for the pointer that holds the configuration for the I2C device connected on expansion port A. I2C can have multiple peripherals connected on the same bus, using this function to close/free one will not impact the others.
Read more about I2C capabilities of the ESP32 microcontroller and available APIs in the ESP-IDF.
The example code allocates a I2C peripheral called port_A_peripheral of type I2CDevice_t at the standard baud rate. It then closes/frees that device configuration.
Example:
| [in] | device | The device configuration pointer. |
| uint32_t Core2ForAWS_Port_B_ADC_ReadRaw | ( | void | ) |
Read the raw ADC value from GPIO36.
This function reads the raw ADC value from Port B's Analog-to-Digital-Converter (ADC) on GPIO36. GPIO36 is the only pin on the external ports with access to the ADC. Read more about using ADCs with the ESP-IDF.
The example code sets the ADC pin mode for the PORT_B_ADC_PIN, creates a FreeRTOS task which periodically (1s) reads the raw ADC value of the M5Stack EARTH moisture sensor connected on Port B. It prints out the value to the serial output.
Example:
| uint32_t Core2ForAWS_Port_B_ADC_ReadMilliVolts | ( | void | ) |
Read the calibrated ADC voltage from GPIO36.
This function reads the raw ADC value from Port B's Analog-to-Digital-Converter (ADC) on GPIO36 and converts it to millivolts using the VRef calibration. GPIO36 is the only pin on the external ports with access to the ADC. Read more about using ADCs with the ESP-IDF.
The example code sets the ADC pin mode for the PORT_B_ADC_PIN, creates a FreeRTOS task which periodically (1s) reads the ADC voltage of the M5Stack EARTH moisture sensor connected on Port B. It prints out the value to the serial output.
Example:
| esp_err_t Core2ForAWS_Port_B_DAC_WriteMilliVolts | ( | uint16_t | mvolts | ) |
Outputs the specified voltage (millivolts) to the DAC.
This function accepts a range from 0 to a maximum of VDD3P3_RTC (~3300mV).
The example code sets the PORT_B_DAC_PIN (GPIO 26) pin mode to DAC and outputs 1,500mV.
Example:
| [in] | mvolts | The voltage level to set the DAC pin in millivolts. |
ESP_OK if successful. | esp_err_t Core2ForAWS_Port_C_UART_Begin | ( | uint32_t | baud | ) |
Configures the UART interface at the specified baud rate.
This is a helper function to simplify building applications with UART. It preconfigures the UART communications with word length of 8 bits, no parity bit, 1 bit for the number of stop bits, and hardware flow control disabled. It sets the baud rate to the user defined value and starts reading from the UART channel 2 and storing data into the ring buffer of length UART_RX_BUF_SIZE.
Usage of the UART convenience methods provided in this BSP aims to simplify development at the expense of compatibility and performance. The configuration above may not be suitable for your application or attached peripheral. For more information about UART communications on the Core2 for AWS IoT EduKit using the ESP32 and how to create your own configuration, visit Espressif's official documentation.
The example below sets the PORT_C_UART_TX_PIN (GPIO 14) pin mode to UART transmit, which will also set PORT_C_UART_RX_PIN (GPIO 13) to UART receiver, and sets the UART baud rate to 115200. It then starts two FreeRTOS tasks — one that transmits "Hello from AWS IoT EduKit" every two seconds and the other receives the message. The receiver task outputs the number of bytes read from the buffer, the number of bytes that remains unread in the ring buffer, and the message.
To receive the messages transmitted on the same device, run a female-female jumper wire from Port C's TX pin to PORT C's RX pin.
Example:
| [in] | baud | The baud rate (bits per second) of the UART2 channel. |
ESP_OK if successful. | int Core2ForAWS_Port_C_UART_Send | ( | const char * | message, |
| size_t | len | ||
| ) |
Sends a specified length of a user defined message over UART2.
This is a helper function to simplify transmitting data over UART using the UART channel 2. This function does not return until all bytes are either transferred from the ring buffer to the hardware FIFO buffer, or already sent.
For more information about UART communications on the Core2 for AWS IoT EduKit using the ESP32, visit Espressif's official documentation.
The example below sets the PORT_C_UART_TX_PIN (GPIO 14) pin mode to UART transmit, which will also set PORT_C_UART_RX_PIN (GPIO 13) to UART receiver, and sets the UART baud rate to 115200. It then starts two FreeRTOS tasks — one that transmits "Hello from AWS IoT EduKit" every two seconds and the other receives the message. The receiver task outputs the number of bytes read from the buffer, the number of bytes that remains unread in the ring buffer, and the message.
To receive the messages transmitted on the same device, run a female-female jumper wire from Port C's TX pin to PORT C's RX pin.
Example:
| [in] | message | A pointer to the message to be transmitted over UART2. |
| [in] | len | The size of the message that you want to transmit. |
| int Core2ForAWS_Port_C_UART_Receive | ( | uint8_t * | message_buffer | ) |
Reads messages in the UART2 receiver ring buffer.
This is a helper function to simplify development with UART. This function is used to read messages stored in the receiver hardware FIFO buffer, which was configured to a maximum of UART_RX_BUF_SIZE.
This convenience methods provided in this BSP aims to simplify development at the expense of compatibility and performance. The usage of this function requires regular polling for any new messages. For some applications, it might offer significant performance benefits to set up an interrupt for handling and processing new data. For more information about UART communications on the Core2 for AWS IoT EduKit using the ESP32 and how to create your own configuration, visit Espressif's official documentation.
The example below sets the PORT_C_UART_TX_PIN (GPIO 14) pin mode to UART transmit, which will also set PORT_C_UART_RX_PIN (GPIO 13) to UART receiver, and sets the UART baud rate to 115200. It then starts two FreeRTOS tasks — one that transmits "Hello from AWS IoT EduKit" every two seconds and the other receives the message. The receiver task outputs the number of bytes read from the buffer, the number of bytes that remains unread in the ring buffer, and the message.
To receive the messages transmitted on the same device, run a female-female jumper wire from Port C's TX pin to PORT C's RX pin.
Example:
| [out] | message_buffer | The buffer which will contain the message read from the receiver hardware FIFO buffer. At maximum, it will be of size UART_RX_BUF_SIZE. |
|
extern |
FreeRTOS semaphore to be used when performing any operation on the display.
To avoid conflicts with multiple threads attempting to write to the display, take this FreeRTOS semaphore first, use the LVGL widget API of choice, and then give the semaphore. The FreeRTOS task, guiTask(), will write to the ILI9342C display controller to update the display.
Example:
Create a LVGL label widget, set the text of the label to "Hello World!", and align the label to the center of the screen.
|
extern |
Left virtual touch button.
This is a virtual touch button which contains the definitions of a mapped region of the screen that corresponds to the button location and touch events from the FT6336U capacitive touch controller. When the screen is touched in the region that represents the left button, it will update the state of the button. You can use the APIs in the button library with this button as the input parameter to query the button's state.
Example:
Print "left button pressed" when the on-screen left button is pressed.
|
extern |
Middle virtual touch button.
This is a virtual touch button which contains the definitions of a mapped region of the screen that corresponds to the button location and touch events from the FT6336U capacitive touch controller. When the screen is touched in the region that represents the middle button, it will update the state of the button. You can use the APIs in the button library with this button as the input parameter to query the button's state.
Example:
Print "middle button pressed" when the on-screen middle button is pressed.
|
extern |
Right virtual touch button.
This is a virtual touch button which contains the definitions of a mapped region of the screen that corresponds to the button location and touch events from the FT6336U capacitive touch controller. When the screen is touched in the region that represents the right button, it will update the state of the button. You can use the APIs in the button library with this button as the input parameter to query the button's state.
Example:
Print "right button pressed" when the on-screen right button is pressed.