-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ea90699
commit 311bb52
Showing
291 changed files
with
60,887 additions
and
1,017 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,3 +108,4 @@ XUNIT_RESULT*.xml | |
|
||
# Vale | ||
.vale/styles/* | ||
/.metadata/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
FROM espressif/idf | ||
|
||
ARG DEBIAN_FRONTEND=nointeractive | ||
ARG CONTAINER_USER=esp | ||
ARG USER_UID=1050 | ||
ARG USER_GID=$USER_UID | ||
|
||
RUN apt-get update \ | ||
&& apt install -y -q \ | ||
cmake \ | ||
git \ | ||
libglib2.0-0 \ | ||
libnuma1 \ | ||
libpixman-1-0 \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# QEMU | ||
ENV QEMU_REL=esp_develop_8.2.0_20240122 | ||
ENV QEMU_SHA256=e7c72ef5705ad1444d391711088c8717fc89f42e9bf6d1487f9c2a326b8cfa83 | ||
ENV QEMU_DIST=qemu-xtensa-softmmu-${QEMU_REL}-x86_64-linux-gnu.tar.xz | ||
ENV QEMU_URL=https://github.com/espressif/qemu/releases/download/esp-develop-8.2.0-20240122/${QEMU_DIST} | ||
|
||
ENV LC_ALL=C.UTF-8 | ||
ENV LANG=C.UTF-8 | ||
|
||
RUN wget --no-verbose ${QEMU_URL} \ | ||
&& echo "${QEMU_SHA256} *${QEMU_DIST}" | sha256sum --check --strict - \ | ||
&& tar -xf $QEMU_DIST -C /opt \ | ||
&& rm ${QEMU_DIST} | ||
|
||
ENV PATH=/opt/qemu/bin:${PATH} | ||
|
||
RUN groupadd --gid $USER_GID $CONTAINER_USER \ | ||
&& adduser --uid $USER_UID --gid $USER_GID --disabled-password --gecos "" ${CONTAINER_USER} \ | ||
&& usermod -a -G root $CONTAINER_USER && usermod -a -G dialout $CONTAINER_USER | ||
|
||
RUN chmod -R 775 /opt/esp/python_env/ | ||
|
||
USER ${CONTAINER_USER} | ||
ENV USER=${CONTAINER_USER} | ||
WORKDIR /home/${CONTAINER_USER} | ||
|
||
RUN echo "source /opt/esp/idf/export.sh > /dev/null 2>&1" >> ~/.bashrc | ||
|
||
ENTRYPOINT [ "/opt/esp/entrypoint.sh" ] | ||
|
||
CMD ["/bin/bash", "-c"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"name": "ESP-IDF QEMU", | ||
"build": { | ||
"dockerfile": "Dockerfile" | ||
}, | ||
"customizations": { | ||
"vscode": { | ||
"settings": { | ||
"terminal.integrated.defaultProfile.linux": "bash", | ||
"idf.espIdfPath": "/opt/esp/idf", | ||
"idf.customExtraPaths": "", | ||
"idf.pythonBinPath": "/opt/esp/python_env/idf5.4_py3.12_env/bin/python", | ||
"idf.toolsPath": "/opt/esp", | ||
"idf.gitPath": "/usr/bin/git" | ||
}, | ||
"extensions": [ | ||
"espressif.esp-idf-extension" | ||
] | ||
}, | ||
"codespaces": { | ||
"settings": { | ||
"terminal.integrated.defaultProfile.linux": "bash", | ||
"idf.espIdfPath": "/opt/esp/idf", | ||
"idf.customExtraPaths": "", | ||
"idf.pythonBinPath": "/opt/esp/python_env/idf5.4_py3.12_env/bin/python", | ||
"idf.toolsPath": "/opt/esp", | ||
"idf.gitPath": "/usr/bin/git" | ||
}, | ||
"extensions": [ | ||
"espressif.esp-idf-extension", | ||
"espressif.esp-idf-web" | ||
] | ||
} | ||
}, | ||
"runArgs": ["--privileged"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
build/ | ||
sdkconfig | ||
sdkconfig.old |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# For more information about build system see | ||
# https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html | ||
# The following five lines of boilerplate have to be in your project's | ||
# CMakeLists in this exact order for cmake to work correctly | ||
cmake_minimum_required(VERSION 3.5) | ||
|
||
include($ENV{IDF_PATH}/tools/cmake/project.cmake) | ||
project(Lps22hb) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# _Sample project_ | ||
|
||
(See the README.md file in the upper level 'examples' directory for more information about examples.) | ||
|
||
This is the simplest buildable example. The example is used by command `idf.py create-project` | ||
that copies the project to user specified path and set it's name. For more information follow the [docs page](https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html#start-a-new-project) | ||
|
||
|
||
|
||
## How to use example | ||
We encourage the users to use the example as a template for the new projects. | ||
A recommended way is to follow the instructions on a [docs page](https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html#start-a-new-project). | ||
|
||
## Example folder contents | ||
|
||
The project **sample_project** contains one source file in C language [main.c](main/main.c). The file is located in folder [main](main). | ||
|
||
ESP-IDF projects are built using CMake. The project build configuration is contained in `CMakeLists.txt` | ||
files that provide set of directives and instructions describing the project's source files and targets | ||
(executable, library, or both). | ||
|
||
Below is short explanation of remaining files in the project folder. | ||
|
||
``` | ||
├── CMakeLists.txt | ||
├── main | ||
│ ├── CMakeLists.txt | ||
│ └── main.c | ||
└── README.md This is the file you are currently reading | ||
``` | ||
Additionally, the sample project contains Makefile and component.mk files, used for the legacy Make based build system. | ||
They are not used or needed when building with CMake and idf.py. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
idf_component_register(SRCS "lps22hb.c" | ||
INCLUDE_DIRS "." | ||
PRIV_REQUIRES "driver") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
#include "lps22hb.h" | ||
#include <stdio.h> | ||
#include <esp_log.h> | ||
#include <freertos/FreeRTOS.h> | ||
#include <driver/i2c.h> | ||
|
||
static const char *TAG = "LPS22HB"; | ||
|
||
// I2C write helper function | ||
esp_err_t i2c_write_byte(uint8_t device_addr, uint8_t reg_addr, uint8_t data) | ||
{ | ||
i2c_cmd_handle_t cmd = i2c_cmd_link_create(); | ||
i2c_master_start(cmd); | ||
i2c_master_write_byte(cmd, (device_addr << 1) | I2C_MASTER_WRITE, true); | ||
i2c_master_write_byte(cmd, reg_addr, true); | ||
i2c_master_write_byte(cmd, data, true); | ||
i2c_master_stop(cmd); | ||
esp_err_t ret = i2c_master_cmd_begin(I2C_NUM_0, cmd, 10 / portTICK_PERIOD_MS); | ||
i2c_cmd_link_delete(cmd); | ||
return ret; | ||
} | ||
|
||
// I2C read helper function | ||
esp_err_t i2c_read_bytes(uint8_t device_addr, uint8_t reg_addr, uint8_t *data, size_t len) | ||
{ | ||
i2c_cmd_handle_t cmd = i2c_cmd_link_create(); | ||
i2c_master_start(cmd); | ||
i2c_master_write_byte(cmd, (device_addr << 1) | I2C_MASTER_WRITE, true); | ||
i2c_master_write_byte(cmd, reg_addr, true); | ||
i2c_master_start(cmd); | ||
i2c_master_write_byte(cmd, (device_addr << 1) | I2C_MASTER_READ, true); | ||
i2c_master_read(cmd, data, len, I2C_MASTER_LAST_NACK); | ||
i2c_master_stop(cmd); | ||
esp_err_t ret = i2c_master_cmd_begin(I2C_NUM_0, cmd, 10 / portTICK_PERIOD_MS); | ||
i2c_cmd_link_delete(cmd); | ||
return ret; | ||
} | ||
|
||
// Initialize LPS22HB | ||
esp_err_t lps22hb_init() | ||
{ | ||
// Configure CTRL_REG1 for continuous mode at 1Hz output data rate | ||
return i2c_write_byte(LPS22HB_ADDRESS, CTRL_REG1, 0x50); // Power on, 1Hz ODR | ||
} | ||
|
||
// Verify WHO_AM_I register | ||
esp_err_t lps22hb_who_am_i(uint8_t device_addr) | ||
{ | ||
uint8_t who_am_i_reg_id; | ||
esp_err_t ret = i2c_read_bytes(device_addr, WHO_AM_I_REG, &who_am_i_reg_id, 1); | ||
|
||
if (ret == ESP_OK && who_am_i_reg_id == EXPECTED_WHO_AM_I) | ||
{ | ||
ESP_LOGI(TAG, "WHO_AM_I matched: 0x%02X", who_am_i_reg_id); | ||
return ESP_OK; // ID matched | ||
} | ||
else | ||
{ | ||
ESP_LOGE(TAG, "WHO_AM_I mismatch. Expected: 0x%02X, Got: 0x%02X", EXPECTED_WHO_AM_I, who_am_i_reg_id); | ||
return ESP_FAIL; // ID mismatch | ||
} | ||
} | ||
|
||
// Read pressure from LPS22HB | ||
esp_err_t lps22hb_read_pressure(float *pressure_hPa) | ||
{ | ||
uint8_t raw_data[3]; // Buffer to store raw pressure data | ||
esp_err_t ret = i2c_read_bytes(LPS22HB_ADDRESS, PRESS_OUT_XL, raw_data, 3); | ||
if (ret == ESP_OK) | ||
{ | ||
int32_t raw_pressure = (int32_t)((raw_data[2] << 16) | (raw_data[1] << 8) | raw_data[0]); | ||
*pressure_hPa = raw_pressure / 4096.0; // Convert to hPa | ||
} | ||
return ret; | ||
} | ||
|
||
// Read temperature from LPS22HB | ||
esp_err_t lps22hb_read_temperature(float *temperature_C) | ||
{ | ||
uint8_t raw_data[2]; // Buffer to store raw temperature data | ||
esp_err_t ret = i2c_read_bytes(LPS22HB_ADDRESS, TEMP_OUT_L, raw_data, 2); | ||
if (ret == ESP_OK) | ||
{ | ||
int16_t raw_temperature = (int16_t)((raw_data[1] << 8) | raw_data[0]); | ||
*temperature_C = raw_temperature / 100.0; // Convert to Celsius | ||
} | ||
return ret; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#ifndef LPS22HB_H | ||
#define LPS22HB_H | ||
|
||
#include <stdint.h> | ||
#include <esp_err.h> | ||
|
||
// LPS22HB I2C address | ||
#define LPS22HB_ADDRESS 0x5C | ||
|
||
// LPS22HB registers | ||
#define WHO_AM_I_REG 0x0F | ||
#define CTRL_REG1 0x10 | ||
#define PRESS_OUT_XL 0x28 | ||
#define TEMP_OUT_L 0x2B | ||
|
||
#define EXPECTED_WHO_AM_I 0xB1 // Expected device ID for LPS22HB | ||
|
||
// Function prototypes | ||
esp_err_t lps22hb_init(); | ||
esp_err_t lps22hb_who_am_i(uint8_t device_addr); | ||
esp_err_t lps22hb_read_pressure(float *pressure_hPa); | ||
esp_err_t lps22hb_read_temperature(float *temperature_C); | ||
|
||
#endif // LPS22HB_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
idf_component_register(SRCS "main.c" | ||
INCLUDE_DIRS ".") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
menu "Example Configuration" | ||
|
||
orsource "$IDF_PATH/examples/common_components/env_caps/$IDF_TARGET/Kconfig.env_caps" | ||
|
||
choice BLINK_LED | ||
prompt "Blink LED type" | ||
default BLINK_LED_GPIO | ||
help | ||
Select the LED type. A normal level controlled LED or an addressable LED strip. | ||
The default selection is based on the Espressif DevKit boards. | ||
You can change the default selection according to your board. | ||
|
||
config BLINK_LED_GPIO | ||
bool "GPIO" | ||
config BLINK_LED_STRIP | ||
bool "LED strip" | ||
endchoice | ||
|
||
choice BLINK_LED_STRIP_BACKEND | ||
depends on BLINK_LED_STRIP | ||
prompt "LED strip backend peripheral" | ||
default BLINK_LED_STRIP_BACKEND_RMT if SOC_RMT_SUPPORTED | ||
default BLINK_LED_STRIP_BACKEND_SPI | ||
help | ||
Select the backend peripheral to drive the LED strip. | ||
|
||
config BLINK_LED_STRIP_BACKEND_RMT | ||
depends on SOC_RMT_SUPPORTED | ||
bool "RMT" | ||
config BLINK_LED_STRIP_BACKEND_SPI | ||
bool "SPI" | ||
endchoice | ||
|
||
config BLINK_GPIO | ||
int "Blink GPIO number" | ||
range ENV_GPIO_RANGE_MIN ENV_GPIO_OUT_RANGE_MAX | ||
default 8 | ||
help | ||
GPIO number (IOxx) to blink on and off the LED. | ||
Some GPIOs are used for other purposes (flash connections, etc.) and cannot be used to blink. | ||
|
||
config BLINK_PERIOD | ||
int "Blink period in ms" | ||
range 10 3600000 | ||
default 1000 | ||
help | ||
Define the blinking period in milliseconds. | ||
|
||
endmenu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
dependencies: | ||
espressif/led_strip: "^2.4.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include <stdio.h> | ||
|
||
void app_main(void) | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD | ||
# SPDX-License-Identifier: CC0-1.0 | ||
import logging | ||
import os | ||
|
||
import pytest | ||
from pytest_embedded_idf.dut import IdfDut | ||
|
||
|
||
@pytest.mark.supported_targets | ||
@pytest.mark.generic | ||
def test_blink(dut: IdfDut) -> None: | ||
# check and log bin size | ||
binary_file = os.path.join(dut.app.binary_path, 'blink.bin') | ||
bin_size = os.path.getsize(binary_file) | ||
logging.info('blink_bin_size : {}KB'.format(bin_size // 1024)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
CONFIG_BLINK_LED_GPIO=y | ||
CONFIG_BLINK_GPIO=8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CONFIG_BLINK_GPIO=5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CONFIG_BLINK_LED_STRIP=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
CONFIG_BLINK_GPIO=27 | ||
CONFIG_BLINK_LED_STRIP=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CONFIG_BLINK_LED_STRIP=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CONFIG_BLINK_LED_STRIP=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CONFIG_BLINK_LED_STRIP=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
CONFIG_BLINK_LED_STRIP=y | ||
CONFIG_BLINK_GPIO=18 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
CONFIG_BLINK_LED_STRIP=y | ||
CONFIG_BLINK_GPIO=48 |
Oops, something went wrong.