Compare commits
133 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 86f3933c11 | |||
| b8f4775807 | |||
| 71a7a5aeac | |||
| d1cf670ac6 | |||
| bb3f65048d | |||
| 35276d320c | |||
| 7353050f4d | |||
| 8518065bf8 | |||
| 42ff16acb4 | |||
| 0668385b2c | |||
| 2bce6c5281 | |||
| 0924e7bc2c | |||
| e129cb58cd | |||
| 632b7a4544 | |||
| 7e5256f271 | |||
| 74bdd3076c | |||
| a83643cfb1 | |||
| 9a35484b76 | |||
| 2cf8157cfd | |||
| 7c8e38559a | |||
| 643364f303 | |||
| 07b922e042 | |||
| 15e5d4b48d | |||
| b437a13a7f | |||
| 39b2029b0f | |||
| 90454c2342 | |||
| 1580467b60 | |||
| 028f4501b3 | |||
| bd39c083ad | |||
| 71f96b3e2b | |||
| 3fae2f08fe | |||
| 16ecee550b | |||
| 351e5bb9a1 | |||
| ac80fcf1de | |||
| fc0e8e9fcf | |||
| e162fd1128 | |||
| 73902d640c | |||
| 69feac8526 | |||
| d6e455259d | |||
| f655f99107 | |||
| 9e6ac6e4d9 | |||
| 4ea9c1079a | |||
| c44348f1bc | |||
| 147cd8d2c1 | |||
| 6f3f6056ee | |||
| e5fa22c10a | |||
| ce7a883892 | |||
| 6d1aa846fd | |||
| a6d4718bf5 | |||
| 52d8a4826c | |||
| 363c27cd33 | |||
| b477b995e4 | |||
| c79bff40ba | |||
| 1e74a3024c | |||
| 2c3fe7c8d6 | |||
| 9ddbf76bae | |||
| 838eeb70f5 | |||
| 8d1a1f2d60 | |||
| e3a6b0ac0f | |||
| e7043978ae | |||
| eb4eca7db1 | |||
| f8a49d5354 | |||
| 18cdc818fb | |||
| a15977815e | |||
| 878a85fab1 | |||
| a402a76445 | |||
| c39e0645ff | |||
| 942ffe8b7f | |||
| cff007b792 | |||
| 920e0bb5d4 | |||
| f06ef6fd5a | |||
| f4111fcc7f | |||
| 37ef188719 | |||
| 35dab1fa34 | |||
| a81dd08f10 | |||
| 1a55f34014 | |||
| f0a6907bfb | |||
| 8e3cb948d8 | |||
| 48f1c93386 | |||
| 7a0b04b6d3 | |||
| 0d670dd6b2 | |||
| d107512720 | |||
| ccc2711129 | |||
| ced426421d | |||
| 3ce4318326 | |||
| b3dae46172 | |||
| 65fa207d68 | |||
| db4453e78c | |||
| 23ea6519b6 | |||
| a45ee1e985 | |||
| a1e4586d7f | |||
| cc7610df2d | |||
| 44a420761c | |||
| a1715125de | |||
| c29f8a222a | |||
| c46079095e | |||
| 0b9962e4d4 | |||
| 5a90cc00ce | |||
| aab9f23434 | |||
| 553e9d21dc | |||
| 84bd75e6c9 | |||
| a85affed13 | |||
| b7a83922cc | |||
| ff0d0049fd | |||
| efbfa32732 | |||
| c824e61a11 | |||
| f30802ce04 | |||
| 46ac5a920c | |||
| 2ebb66b542 | |||
| e746ec18c3 | |||
| 52aabe705f | |||
| 740d3b6d99 | |||
| f60d877acf | |||
| 95e9994eef | |||
| 29e107d080 | |||
| ba88041162 | |||
| e09cfbe3f8 | |||
| af14ed5f58 | |||
| 0551b54d7a | |||
| bb5754320e | |||
| 5d6456fa30 | |||
| 0384f0e71b | |||
| 6ebf8dd543 | |||
| 45a89cf480 | |||
| 01e3b4b5d2 | |||
| 510d4a4fe6 | |||
| 26d7c66146 | |||
| 2514d7316e | |||
| b41dbb307d | |||
| fd9c3d66a3 | |||
| 020cdd5681 | |||
| 029f919739 | |||
| 506ee11dc1 |
@@ -0,0 +1,45 @@
|
||||
name: Build examples IDF5.1
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
Build-examples:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
PROJECT_PATH: examples/factory_demo
|
||||
BIN_FILE: ESP-Box_Demo_V0.5.0.bin
|
||||
container: espressif/idf:release-v5.1
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
|
||||
- name: esp-idf build
|
||||
run: |
|
||||
pwd
|
||||
ls -al
|
||||
cd /opt/esp/idf
|
||||
git checkout 22cfbf30c3
|
||||
git submodule update --init --recursive
|
||||
tools/idf_tools.py --non-interactive install cmake
|
||||
./install.sh
|
||||
source ./export.sh
|
||||
cd $GITHUB_WORKSPACE/$PROJECT_PATH
|
||||
idf.py build
|
||||
cd build
|
||||
esptool.py --chip ESP32-S3 merge_bin -o $BIN_FILE @flash_args
|
||||
shell: bash
|
||||
|
||||
- name: Upload a Build Artifact
|
||||
uses: actions/upload-artifact@v3.0.0
|
||||
with:
|
||||
# Artifact name
|
||||
name: factory-firmware_IDF5.1
|
||||
# A file, directory or wildcard pattern that describes what to upload
|
||||
path: |
|
||||
examples/factory_demo/build/ESP-*.bin
|
||||
retention-days: 90
|
||||
@@ -0,0 +1,24 @@
|
||||
name: Sync issue comments to JIRA
|
||||
|
||||
# This workflow will be triggered when new issue comment is created (including PR comments)
|
||||
on: issue_comment
|
||||
|
||||
# Limit to single concurrent run for workflows which can create Jira issues.
|
||||
# Same concurrency group is used in new_issues.yml
|
||||
concurrency: jira_issues
|
||||
|
||||
jobs:
|
||||
sync_issue_comments_to_jira:
|
||||
name: Sync Issue Comments to Jira
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Sync issue comments to JIRA
|
||||
uses: espressif/github-actions/sync_issues_to_jira@master
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
JIRA_PASS: ${{ secrets.JIRA_PASS }}
|
||||
JIRA_PROJECT: ${{ secrets.JIRA_PROJECT }}
|
||||
JIRA_COMPONENT: ${{ secrets.JIRA_COMPONENT }}
|
||||
JIRA_URL: ${{ secrets.JIRA_URL }}
|
||||
JIRA_USER: ${{ secrets.JIRA_USER }}
|
||||
@@ -0,0 +1,24 @@
|
||||
name: Sync issues to Jira
|
||||
|
||||
# This workflow will be triggered when a new issue is opened
|
||||
on: issues
|
||||
|
||||
# Limit to single concurrent run for workflows which can create Jira issues.
|
||||
# Same concurrency group is used in issue_comment.yml
|
||||
concurrency: jira_issues
|
||||
|
||||
jobs:
|
||||
sync_issues_to_jira:
|
||||
name: Sync issues to Jira
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Sync GitHub issues to Jira project
|
||||
uses: espressif/github-actions/sync_issues_to_jira@master
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
JIRA_PASS: ${{ secrets.JIRA_PASS }}
|
||||
JIRA_PROJECT: ${{ secrets.JIRA_PROJECT }}
|
||||
JIRA_COMPONENT: ${{ secrets.JIRA_COMPONENT }}
|
||||
JIRA_URL: ${{ secrets.JIRA_URL }}
|
||||
JIRA_USER: ${{ secrets.JIRA_USER }}
|
||||
@@ -0,0 +1,29 @@
|
||||
name: Sync remain PRs to Jira
|
||||
|
||||
# This workflow will be triggered every hour, to sync remaining PRs (i.e. PRs with zero comment) to Jira project
|
||||
# Note that, PRs can also get synced when new PR comment is created
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 * * * *"
|
||||
|
||||
# Limit to single concurrent run for workflows which can create Jira issues.
|
||||
# Same concurrency group is used in issue_comment.yml
|
||||
concurrency: jira_issues
|
||||
|
||||
jobs:
|
||||
sync_prs_to_jira:
|
||||
name: Sync PRs to Jira
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Sync PRs to Jira project
|
||||
uses: espressif/github-actions/sync_issues_to_jira@master
|
||||
with:
|
||||
cron_job: true
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
JIRA_PASS: ${{ secrets.JIRA_PASS }}
|
||||
JIRA_PROJECT: ${{ secrets.JIRA_PROJECT }}
|
||||
JIRA_COMPONENT: ${{ secrets.JIRA_COMPONENT }}
|
||||
JIRA_URL: ${{ secrets.JIRA_URL }}
|
||||
JIRA_USER: ${{ secrets.JIRA_USER }}
|
||||
@@ -25,6 +25,7 @@ GPATH
|
||||
**/examples/**/sdkconfig
|
||||
**/examples/**/sdkconfig.old
|
||||
**/examples/**/build
|
||||
**/examples/**/target
|
||||
|
||||
**/sdkconfig
|
||||
**/sdkconfig.old
|
||||
@@ -80,3 +81,5 @@ build
|
||||
# lock files for examples and components
|
||||
dependencies.lock
|
||||
|
||||
# managed_components for examples
|
||||
managed_components
|
||||
|
||||
@@ -2,6 +2,21 @@ stages:
|
||||
- build
|
||||
- deploy
|
||||
|
||||
workflow:
|
||||
rules:
|
||||
# Disable those non-protected push triggered pipelines
|
||||
- if: '$CI_COMMIT_REF_NAME != "master" && $CI_COMMIT_BRANCH !~ /^release\/v/ && $CI_COMMIT_TAG !~ /^v\d+\.\d+(\.\d+)?($|-)/ && $CI_PIPELINE_SOURCE == "push"'
|
||||
when: never
|
||||
# when running merged result pipelines, it would create a temp commit id. use $CI_MERGE_REQUEST_SOURCE_BRANCH_SHA instead of $CI_COMMIT_SHA.
|
||||
# Please use PIPELINE_COMMIT_SHA at all places that require a commit sha
|
||||
- if: $CI_OPEN_MERGE_REQUESTS != null
|
||||
variables:
|
||||
PIPELINE_COMMIT_SHA: $CI_MERGE_REQUEST_SOURCE_BRANCH_SHA
|
||||
- if: $CI_OPEN_MERGE_REQUESTS == null
|
||||
variables:
|
||||
PIPELINE_COMMIT_SHA: $CI_COMMIT_SHA
|
||||
- when: always
|
||||
|
||||
variables:
|
||||
ESP_BOX_PATH: "$CI_PROJECT_DIR"
|
||||
BATCH_BUILD: "1"
|
||||
@@ -19,53 +34,7 @@ before_script:
|
||||
- git --version
|
||||
- git submodule update --init --recursive --force
|
||||
|
||||
.build_examples_template: &build_examples_template
|
||||
stage: build
|
||||
image: espressif/idf:latest
|
||||
tags:
|
||||
- build
|
||||
|
||||
build_demo_cmake:
|
||||
<<: *build_examples_template
|
||||
script:
|
||||
- cd idf_patch
|
||||
- python3 apply_patch.py -d $IDF_PATH
|
||||
- cd ../
|
||||
- cd examples/factory_demo
|
||||
- idf.py fullclean
|
||||
- idf.py build
|
||||
- rm sdkconfig sdkconfig.defaults
|
||||
- cp sdkconfig.defaults.cn sdkconfig.defaults
|
||||
- idf.py build
|
||||
- idf.py fullclean
|
||||
- cd ../
|
||||
- cd image_display
|
||||
- idf.py fullclean
|
||||
- idf.py build
|
||||
- cd ../
|
||||
- cd lv_demos
|
||||
- idf.py fullclean
|
||||
- idf.py build
|
||||
- cd ../../
|
||||
|
||||
push_to_github:
|
||||
stage: deploy
|
||||
only:
|
||||
- master
|
||||
- /^release\/v/
|
||||
# when: on_success
|
||||
image: $CI_DOCKER_REGISTRY/esp32-ci-env
|
||||
variables:
|
||||
GIT_STRATEGY: clone
|
||||
before_script:
|
||||
- echo "skip default before_script"
|
||||
script:
|
||||
- mkdir -p ~/.ssh
|
||||
- chmod 700 ~/.ssh
|
||||
- echo -n $GH_PUSH_KEY > ~/.ssh/id_rsa_base64
|
||||
- base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 > ~/.ssh/id_rsa
|
||||
- chmod 600 ~/.ssh/id_rsa
|
||||
- echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
|
||||
- git remote remove github &>/dev/null || true
|
||||
- git remote add github git@github.com:espressif/esp-box.git
|
||||
- ${ESP_BOX_PATH}/tools/ci/push_to_github.sh
|
||||
include:
|
||||
- '.gitlab/ci/rules.yml'
|
||||
- '.gitlab/ci/build.yml'
|
||||
- '.gitlab/ci/deploy.yml'
|
||||
@@ -0,0 +1,228 @@
|
||||
.build_template: &build_template
|
||||
stage: build
|
||||
image: espressif/idf:release-v5.0
|
||||
tags:
|
||||
- build
|
||||
variables:
|
||||
# Enable ccache for all build jobs. See configure_ci_environment.sh for more ccache related settings.
|
||||
IDF_CCACHE_ENABLE: "1"
|
||||
BATCH_BUILD: "1"
|
||||
V: "0"
|
||||
WARNING_STR: ""
|
||||
|
||||
.build_examples_template: &build_examples_template
|
||||
<<: *build_template
|
||||
artifacts:
|
||||
when: always
|
||||
paths:
|
||||
- "**/build*/size.json"
|
||||
- "**/build*/build_log.txt"
|
||||
- "**/build*/*.bin"
|
||||
# upload to s3 server to save the artifacts size
|
||||
- "**/build*/*.map"
|
||||
- "**/build*/*.elf"
|
||||
- "**/build*/flasher_args.json"
|
||||
- "**/build*/flash_project_args"
|
||||
- "**/build*/config/sdkconfig.json"
|
||||
- "**/build*/bootloader/*.bin"
|
||||
- "**/build*/bootloader/*.elf"
|
||||
- "**/build*/partition_table/*.bin"
|
||||
- size_info.txt
|
||||
expire_in: 1 week
|
||||
variables:
|
||||
IDF_CI_BUILD: "1"
|
||||
script:
|
||||
- pip install --upgrade idf-component-manager
|
||||
- pip install idf_build_apps
|
||||
- python -m idf_build_apps build -vv
|
||||
-p $EXAMPLE_DIR
|
||||
-t all
|
||||
--config "sdkconfig.ci.*="
|
||||
--build-dir build_@t_@w
|
||||
--build-log build_log.txt
|
||||
--size-file size.json
|
||||
--check-warnings
|
||||
--ignore-warning-str "$WARNING_STR"
|
||||
--collect-size-info size_info.txt
|
||||
--default-build-targets $IDF_TARGET
|
||||
|
||||
build_example_chatgpt_demo_v5.0:
|
||||
extends:
|
||||
- .build_examples_template
|
||||
- .rules:build:example_chatgpt_demo
|
||||
image: espressif/idf:release-v5.0
|
||||
variables:
|
||||
IDF_TARGET: esp32s3
|
||||
EXAMPLE_DIR: examples/chatgpt_demo
|
||||
|
||||
build_example_chatgpt_demo_latest:
|
||||
extends:
|
||||
- .build_examples_template
|
||||
- .rules:build:example_chatgpt_demo
|
||||
image: espressif/idf:latest
|
||||
variables:
|
||||
IDF_TARGET: esp32s3
|
||||
EXAMPLE_DIR: examples/chatgpt_demo
|
||||
|
||||
build_example_factory_demo_v5.0:
|
||||
extends:
|
||||
- .build_examples_template
|
||||
- .rules:build:example_factory_demo
|
||||
#image: espressif/idf:release-v5.0 don't support release-v5.0 now.
|
||||
image: espressif/idf:release-v5.1
|
||||
variables:
|
||||
IDF_TARGET: esp32s3
|
||||
EXAMPLE_DIR: examples/factory_demo
|
||||
|
||||
build_example_factory_demo_v5.1:
|
||||
extends:
|
||||
- .build_examples_template
|
||||
- .rules:build:example_factory_demo
|
||||
image: espressif/idf:release-v5.1
|
||||
variables:
|
||||
IDF_TARGET: esp32s3
|
||||
EXAMPLE_DIR: examples/factory_demo
|
||||
|
||||
build_example_factory_demo_latest:
|
||||
extends:
|
||||
- .build_examples_template
|
||||
- .rules:build:example_factory_demo
|
||||
image: espressif/idf:latest
|
||||
variables:
|
||||
IDF_TARGET: esp32s3
|
||||
EXAMPLE_DIR: examples/factory_demo
|
||||
|
||||
build_example_image_display_v5.0:
|
||||
extends:
|
||||
- .build_examples_template
|
||||
- .rules:build:example_image_display
|
||||
image: espressif/idf:release-v5.0
|
||||
variables:
|
||||
IDF_TARGET: esp32s3
|
||||
EXAMPLE_DIR: examples/image_display
|
||||
|
||||
build_example_image_display_v5.1:
|
||||
extends:
|
||||
- .build_examples_template
|
||||
- .rules:build:example_image_display
|
||||
image: espressif/idf:release-v5.1
|
||||
variables:
|
||||
IDF_TARGET: esp32s3
|
||||
EXAMPLE_DIR: examples/image_display
|
||||
|
||||
build_example_image_display_latest:
|
||||
extends:
|
||||
- .build_examples_template
|
||||
- .rules:build:example_image_display
|
||||
image: espressif/idf:latest
|
||||
variables:
|
||||
IDF_TARGET: esp32s3
|
||||
EXAMPLE_DIR: examples/image_display
|
||||
|
||||
build_example_lv_demos_v5.0:
|
||||
extends:
|
||||
- .build_examples_template
|
||||
- .rules:build:example_lv_demos
|
||||
image: espressif/idf:release-v5.0
|
||||
variables:
|
||||
IDF_TARGET: esp32s3
|
||||
EXAMPLE_DIR: examples/lv_demos
|
||||
|
||||
build_example_lv_demos_v5.1:
|
||||
extends:
|
||||
- .build_examples_template
|
||||
- .rules:build:example_lv_demos
|
||||
image: espressif/idf:release-v5.1
|
||||
variables:
|
||||
IDF_TARGET: esp32s3
|
||||
EXAMPLE_DIR: examples/lv_demos
|
||||
|
||||
build_example_lv_demos_latest:
|
||||
extends:
|
||||
- .build_examples_template
|
||||
- .rules:build:example_lv_demos
|
||||
image: espressif/idf:latest
|
||||
variables:
|
||||
IDF_TARGET: esp32s3
|
||||
EXAMPLE_DIR: examples/lv_demos
|
||||
|
||||
build_example_mp3_demo_v5.0:
|
||||
extends:
|
||||
- .build_examples_template
|
||||
- .rules:build:example_mp3_demo
|
||||
image: espressif/idf:release-v5.0
|
||||
variables:
|
||||
IDF_TARGET: esp32s3
|
||||
EXAMPLE_DIR: examples/mp3_demo
|
||||
|
||||
build_example_mp3_demo_v5.1:
|
||||
extends:
|
||||
- .build_examples_template
|
||||
- .rules:build:example_mp3_demo
|
||||
image: espressif/idf:release-v5.1
|
||||
variables:
|
||||
IDF_TARGET: esp32s3
|
||||
EXAMPLE_DIR: examples/mp3_demo
|
||||
|
||||
build_example_mp3_demo_latest:
|
||||
extends:
|
||||
- .build_examples_template
|
||||
- .rules:build:example_mp3_demo
|
||||
image: espressif/idf:latest
|
||||
variables:
|
||||
IDF_TARGET: esp32s3
|
||||
EXAMPLE_DIR: examples/mp3_demo
|
||||
|
||||
build_example_usb_headset_v5.0:
|
||||
extends:
|
||||
- .build_examples_template
|
||||
- .rules:build:example_usb_headset
|
||||
image: espressif/idf:release-v5.0
|
||||
variables:
|
||||
IDF_TARGET: esp32s3
|
||||
EXAMPLE_DIR: examples/usb_headset
|
||||
|
||||
build_example_usb_headset_v5.1:
|
||||
extends:
|
||||
- .build_examples_template
|
||||
- .rules:build:example_usb_headset
|
||||
image: espressif/idf:release-v5.1
|
||||
variables:
|
||||
IDF_TARGET: esp32s3
|
||||
EXAMPLE_DIR: examples/usb_headset
|
||||
|
||||
build_example_usb_headset_latest:
|
||||
extends:
|
||||
- .build_examples_template
|
||||
- .rules:build:example_usb_headset
|
||||
image: espressif/idf:latest
|
||||
variables:
|
||||
IDF_TARGET: esp32s3
|
||||
EXAMPLE_DIR: examples/usb_headset
|
||||
|
||||
build_example_watering_demo_v5.0:
|
||||
extends:
|
||||
- .build_examples_template
|
||||
- .rules:build:example_watering_demo
|
||||
image: espressif/idf:release-v5.0
|
||||
variables:
|
||||
IDF_TARGET: esp32s3
|
||||
EXAMPLE_DIR: examples/watering_demo
|
||||
|
||||
build_example_watering_demo_v5.1:
|
||||
extends:
|
||||
- .build_examples_template
|
||||
- .rules:build:example_watering_demo
|
||||
image: espressif/idf:release-v5.1
|
||||
variables:
|
||||
IDF_TARGET: esp32s3
|
||||
EXAMPLE_DIR: examples/watering_demo
|
||||
|
||||
build_example_watering_demo_latest:
|
||||
extends:
|
||||
- .build_examples_template
|
||||
- .rules:build:example_watering_demo
|
||||
image: espressif/idf:latest
|
||||
variables:
|
||||
IDF_TARGET: esp32s3
|
||||
EXAMPLE_DIR: examples/watering_demo
|
||||
@@ -0,0 +1,21 @@
|
||||
push_to_github:
|
||||
stage: deploy
|
||||
only:
|
||||
- master
|
||||
- /^release\/v/
|
||||
# when: on_success
|
||||
image: $CI_DOCKER_REGISTRY/esp32-ci-env
|
||||
variables:
|
||||
GIT_STRATEGY: clone
|
||||
before_script:
|
||||
- echo "skip default before_script"
|
||||
script:
|
||||
- mkdir -p ~/.ssh
|
||||
- chmod 700 ~/.ssh
|
||||
- echo -n $GH_PUSH_KEY > ~/.ssh/id_rsa_base64
|
||||
- base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 > ~/.ssh/id_rsa
|
||||
- chmod 600 ~/.ssh/id_rsa
|
||||
- echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
|
||||
- git remote remove github &>/dev/null || true
|
||||
- git remote add github git@github.com:espressif/esp-box.git
|
||||
- ${ESP_BOX_PATH}/tools/ci/push_to_github.sh
|
||||
@@ -0,0 +1,108 @@
|
||||
############
|
||||
# Patterns #
|
||||
############
|
||||
|
||||
# components folder, in the alphabetic order
|
||||
.patterns-components_bsp: &patterns-components_bsp
|
||||
- "components/bsp/**/*"
|
||||
|
||||
# examples folder, in the alphabetic order
|
||||
.patterns-example_chatgpt_demo: &patterns-example_chatgpt_demo
|
||||
- "examples/chatgpt_demo/**/*"
|
||||
|
||||
.patterns-example_factory_demo: &patterns-example_factory_demo
|
||||
- "examples/factory_demo/**/*"
|
||||
|
||||
.patterns-example_image_display: &patterns-example_image_display
|
||||
- "examples/image_display/**/*"
|
||||
|
||||
.patterns-example_lv_demos: &patterns-example_lv_demos
|
||||
- "examples/lv_demos/**/*"
|
||||
|
||||
.patterns-example_mp3_demo: &patterns-example_mp3_demo
|
||||
- "examples/mp3_demo/**/*"
|
||||
|
||||
.patterns-example_usb_headset: &patterns-example_usb_headset
|
||||
- "examples/usb_headset/**/*"
|
||||
|
||||
.patterns-example_watering_demo: &patterns-example_watering_demo
|
||||
- "examples/watering_demo/**/*"
|
||||
|
||||
##############
|
||||
# if anchors #
|
||||
##############
|
||||
.if-protected: &if-protected
|
||||
if: '($CI_COMMIT_REF_NAME == "master" || $CI_COMMIT_BRANCH =~ /^release\/v/ || $CI_COMMIT_TAG =~ /^v\d+\.\d+(\.\d+)?($|-)/)'
|
||||
|
||||
.if-dev-push: &if-dev-push
|
||||
if: '$CI_COMMIT_REF_NAME != "master" && $CI_COMMIT_BRANCH !~ /^release\/v/ && $CI_COMMIT_TAG !~ /^v\d+\.\d+(\.\d+)?($|-)/ && ($CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "merge_request_event")'
|
||||
|
||||
##################
|
||||
# Auto Generated #
|
||||
##################
|
||||
.if-label-build: &if-label-build
|
||||
if: '$CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*build(?:,[^,\n\r]+)*$/i'
|
||||
|
||||
# rules for examples
|
||||
.rules:build:example_chatgpt_demo:
|
||||
rules:
|
||||
- <<: *if-protected
|
||||
- <<: *if-label-build
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-components_bsp
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-example_chatgpt_demo
|
||||
|
||||
.rules:build:example_factory_demo:
|
||||
rules:
|
||||
- <<: *if-protected
|
||||
- <<: *if-label-build
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-components_bsp
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-example_factory_demo
|
||||
|
||||
.rules:build:example_image_display:
|
||||
rules:
|
||||
- <<: *if-protected
|
||||
- <<: *if-label-build
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-components_bsp
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-example_image_display
|
||||
|
||||
.rules:build:example_lv_demos:
|
||||
rules:
|
||||
- <<: *if-protected
|
||||
- <<: *if-label-build
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-components_bsp
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-example_lv_demos
|
||||
|
||||
.rules:build:example_mp3_demo:
|
||||
rules:
|
||||
- <<: *if-protected
|
||||
- <<: *if-label-build
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-components_bsp
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-example_mp3_demo
|
||||
|
||||
.rules:build:example_usb_headset:
|
||||
rules:
|
||||
- <<: *if-protected
|
||||
- <<: *if-label-build
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-components_bsp
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-example_usb_headset
|
||||
|
||||
.rules:build:example_watering_demo:
|
||||
rules:
|
||||
- <<: *if-protected
|
||||
- <<: *if-label-build
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-components_bsp
|
||||
- <<: *if-dev-push
|
||||
changes: *patterns-example_watering_demo
|
||||
@@ -1,39 +0,0 @@
|
||||
[submodule "componets/lvgl/lvgl"]
|
||||
path = componets/lvgl/lvgl
|
||||
url = https://github.com/lvgl/lvgl.git
|
||||
[submodule "componets/lvgl/lv_demos"]
|
||||
path = componets/lvgl/lv_demos
|
||||
url = https://github.com/lvgl/lv_demos.git
|
||||
[submodule "components/lvgl/lv_demos"]
|
||||
path = components/lvgl/lv_demos
|
||||
url = https://github.com/lvgl/lv_demos.git
|
||||
[submodule "components/lvgl/lvgl"]
|
||||
path = components/lvgl/lvgl
|
||||
url = https://github.com/lvgl/lvgl.git
|
||||
[submodule "components/esp32-camera"]
|
||||
path = components/esp32-camera
|
||||
url = https://github.com/espressif/esp32-camera.git
|
||||
[submodule "components/lvgl/lv_lib/lv_lib_png"]
|
||||
path = components/lvgl/lv_lib/lv_lib_png
|
||||
url = https://github.com/lvgl/lv_lib_png.git
|
||||
[submodule "components/lvgl/lv_lib/lv_lib_bmp"]
|
||||
path = components/lvgl/lv_lib/lv_lib_bmp
|
||||
url = https://github.com/lvgl/lv_lib_bmp.git
|
||||
[submodule "components/lvgl/lv_lib/lv_lib_split_jpg"]
|
||||
path = components/lvgl/lv_lib/lv_lib_split_jpg
|
||||
url = https://github.com/lvgl/lv_lib_split_jpg.git
|
||||
[submodule "components/lvgl/lv_lib/lv_lib_gif"]
|
||||
path = components/lvgl/lv_lib/lv_lib_gif
|
||||
url = https://github.com/lvgl/lv_lib_gif.git
|
||||
[submodule "components/lvgl/lv_lib/lv_lib_freetype"]
|
||||
path = components/lvgl/lv_lib/lv_lib_freetype
|
||||
url = https://github.com/lvgl/lv_lib_freetype.git
|
||||
[submodule "examples/lvgl/freetype/main/lib/freetype"]
|
||||
path = examples/lvgl/freetype/main/lib/freetype
|
||||
url = https://gitlab.freedesktop.org/freetype/freetype.git
|
||||
[submodule "components/esp-sr"]
|
||||
path = components/esp-sr
|
||||
url = https://github.com/espressif/esp-sr.git
|
||||
[submodule "examples/freetype/main/lib/freetype"]
|
||||
path = examples/freetype/main/lib/freetype
|
||||
url = https://gitlab.freedesktop.org/freetype/freetype.git
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
repos:
|
||||
- repo: https://github.com/igrr/astyle_py.git
|
||||
rev: master
|
||||
hooks:
|
||||
- id: astyle_py
|
||||
args: ['--style=otbs', '--attach-namespaces', '--attach-classes', '--indent=spaces=4', '--convert-tabs', '--align-pointer=name', '--align-reference=name', '--keep-one-line-statements', '--pad-header', '--pad-oper']
|
||||
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v4.3.0
|
||||
hooks:
|
||||
- id: trailing-whitespace
|
||||
types_or: [c, c++]
|
||||
- id: end-of-file-fixer
|
||||
types_or: [c, c++]
|
||||
- id: check-merge-conflict
|
||||
- id: mixed-line-ending
|
||||
types_or: [c, c++]
|
||||
args: ['--fix=lf']
|
||||
description: Forces to replace line ending by the UNIX 'lf' character
|
||||
@@ -2,26 +2,57 @@
|
||||
|
||||
# ESP-BOX AIoT Development Framework
|
||||
|
||||
**Important Note: We recommend [updating the ESP32-S3-BOX firmware](./docs/firmware_update.md) when you first receive the product to have the latest features and bugfix.**
|
||||
<p align="left">
|
||||
<a href="https://github.com/espressif/esp-box/blob/master/LICENSE" alt="Build examples">
|
||||
<img alt="GitHub" src="https://img.shields.io/github/license/espressif/esp-box"></a>
|
||||
<a href="https://github.com/espressif/esp-box/actions/workflows/build_IDF5.1.yml" alt="Build examples">
|
||||
<img src="https://github.com/espressif/esp-box/actions/workflows/build_IDF5.1.yml/badge.svg" /></a>
|
||||
<a href="https://github.com/espressif/esp-box/graphs/contributors" alt="Contributors">
|
||||
<img src="https://img.shields.io/github/contributors/espressif/esp-box" /></a>
|
||||
<a href="https://github.com/espressif/esp-box/releases" alt="GitHub all releases">
|
||||
<img src="https://img.shields.io/github/downloads/espressif/esp-box/total" /></a>
|
||||
</p>
|
||||
|
||||
The ESP-BOX is a new generation AIoT development platform released by Espressif Systems. The ESP32-S3-BOX is an AIoT development board that is based on Espressif’s ESP32-S3 Wi-Fi + Bluetooth 5 (LE) SoC. The ESP32-S3-BOX provides a platform for developing the control of home appliances using Voice Assistance + touch screen controller, sensor, infrared controller, and intelligent Wi-Fi gateway. The ESP32-S3-BOX comes with pre-built firmware that supports offline voice interaction, with the SDKs and examples provided by Espressif, you will be able to develop a wide variety of AIoT applications based on the ESP32-S3-BOX such as online and offline voice assistants, voice-enabled devices, HMI touch-screen devices, control panels, multi-protocol gateways easily.
|
||||
<a href="https://espressif.github.io/esp-launchpad/?flashConfigURL=https://raw.githubusercontent.com/espressif/esp-box/master/launch.toml">
|
||||
<img alt="Try it with ESP Launchpad" src="https://espressif.github.io/esp-launchpad/assets/try_with_launchpad.png" width="200" height="56">
|
||||
</a>
|
||||
|
||||

|
||||
**Important Note:**
|
||||
|
||||
**ESP-BOX features:**
|
||||
> We recommend [updating the application firmware](./docs/firmware_update.md) when you first receive the product to have the new features and bugfix. Click [here](./docs/getting_started.md) to access the user guide of the latest release firmware. Click [here](https://github.com/espressif/esp-box/releases) to visit the older firmware.
|
||||
|
||||
The ESP-BOX is a new generation AIoT development platform released by Espressif Systems. The ESP32-S3-BOX and ESP32-S3-BOX-Lite are AIoT development boards that are based on Espressif’s ESP32-S3 Wi-Fi + Bluetooth 5 (LE) SoC. They provide a platform for developing the control of home appliances using Voice Assistance + touch and screen controller, sensor, infrared controller, and intelligent Wi-Fi gateway. Development boards come with pre-built firmware that supports offline voice interaction, with the SDKs and examples provided by Espressif, you will be able to develop a wide variety of AIoT applications based on the BOX series products such as online and offline voice assistants, voice-enabled devices, human-computer interaction devices, control panels, multi-protocol gateways easily.
|
||||
|
||||
| Product Name | Product Figure |
|
||||
| :-----: | :---------------------: |
|
||||
| [ESP32-S3-BOX](docs/hardware_overview/esp32_s3_box/hardware_overview_for_box.md) | <img src="docs/_static/esp32_s3_box.png" width="200px" /> |
|
||||
| [ESP32-S3-BOX-Lite](docs/hardware_overview/esp32_s3_box_lite/hardware_overview_for_lite.md) | <img src="docs/_static/esp32_s3_box_lite.png" width="200px" /> |
|
||||
|
||||
## Versions
|
||||
|
||||
| ESP-BOX | Dependent ESP-IDF | Branch Note | Support State |
|
||||
| :--------------: | :---------------: | :----------------------------------------------------: | -------------- |
|
||||
| master | >= release/v5.1<br/>commit id: 22cfbf30c3 | Latest developing firmware <br/>esp-sr components version: v1.3.4 | Compatible with ESP32-S3-BOX and ESP32-S3-BOX-Lite <br/>Use menuconfig to select board |
|
||||
| Tag 0.5.0 | release/v5.1<br>commit id: 22cfbf30c3 | esp-sr components version: v1.3.4 | Compatible with ESP32-S3-BOX and ESP32-S3-BOX-Lite <br/>Use menuconfig to select board |
|
||||
| Tag 0.3.0 | release/v4.4<br>commit id: 2bdea81b2a | esp-sr version: dev/v2.0<br>commit id: c873a35 | Compatible with ESP32-S3-BOX and ESP32-S3-BOX-Lite |
|
||||
| Tag 0.2.1 | release/v4.4 with [patch](https://github.com/espressif/esp-box/tree/v0.2.1/idf_patch) | esp-sr version: close v1.0<br/>commit id: 3ce34fe | Support ESP32-S3-BOX only |
|
||||
| Tag 0.1.1 | release/v4.4 with [patch](https://github.com/espressif/esp-box/tree/v0.1.1/idf_patch) | esp-sr version: v0.9.6<br/>commit id: 3ce34fe | Support ESP32-S3-BOX only |
|
||||
|
||||
## Features
|
||||
|
||||
* Supports far-field voice interaction with 2 mics
|
||||
* Offline voice wake-up with high wake-up rate
|
||||
* Offline speech commands recognition in Chinese and English languages with high recognition rate
|
||||
* Reconfigurable voice commands in Chinese and English languages
|
||||
* Reconfigurable 200+ speech commands in Chinese and English languages
|
||||
* Continuous Identification and Wakeup Interrupt
|
||||
* Flexible and reusable GUI framework
|
||||
* End-to-end IoT development framework ESP-RainMaker
|
||||
* End-to-end AIoT dvelopment framwork ESP-RainMaker
|
||||
* Pmod™ compatible headers support expand peripheral modules
|
||||
|
||||
**ESP-BOX Open-Source Content Include:**
|
||||
## Open-Source Content
|
||||
|
||||
* [Schematic and PCB Source File](./hardware)
|
||||
* [Shell 3D Print Source File](./hardware/esp32_s3_box_shell_step)
|
||||
* [Shell 3D Print Source File](./hardware)
|
||||
* [Firmware Source Code](./examples/factory_demo)
|
||||
* [Examples Source Code](./examples)
|
||||
|
||||
@@ -29,25 +60,34 @@ The ESP-BOX is a new generation AIoT development platform released by Espressif
|
||||
|
||||
## User Guide
|
||||
|
||||
* For getting start of ESP32-S3-BOX, please refer to the [Getting Started](./docs/getting_started.md)
|
||||
* For voice control and customization, please refer to the [Voice Assistance Control and Customization](./docs/getting_started.md#voice-assistance-control-and-customization)
|
||||
* For control the device by graphical user interface, please refer to the [ESP32-S3-BOX GUI Guide](./docs/getting_started.md#esp32-s3-box-graphical-user-interface)
|
||||
* For product exploded-view and disassembly tutorial, please refer to [ESP32-S3-BOX Disassembly Tutorial](docs/disassembly_tutorial.md)
|
||||
* For more detils of ESP32-S3-BOX hardware, please refer to the [ESP32-S3-BOX hardware overview](./docs/hardware_overview.md).
|
||||
* For latest version firmware, please refer to the [ESP32-S3-BOX firmware update](./docs/firmware_update.md)
|
||||
* For getting start of BOX serial development boards, please refer to the [Getting Started](./docs/getting_started.md).
|
||||
* For experiencing voice assistant, please refer to the [Voice Assistance Control and Customization](./docs/getting_started.md#offline-voice-assistant-with-your-device).
|
||||
* For experiencing a more humanized interactive experience, please refer to the [Continuous Speech Recognition](./docs/getting_started.md#continuous-recognition).
|
||||
* For defining the speech commands by mobile APP, please refer to the [ESP BOX APP User Guide](./docs/getting_started.md#voice-command-customization).
|
||||
* For product exploded-view and disassembly tutorial, please refer to [Disassembly Tutorial](docs/disassembly_tutorial.md).
|
||||
* For more details of hardware information, please refer to the [Hardware Overview](./docs/hardware_overview).
|
||||
* For latest version firmware, please refer to the [Firmware Update](./docs/firmware_update.md).
|
||||
|
||||
## Developer Guide
|
||||
|
||||
* **Step 1**. ESP-IDF (Espressif IoT Development Framework) is required to build the application. If this is your first time using the ESP-IDF, please refer to [ESP-IDF development guide](https://docs.espressif.com/projects/esp-idf/en/release-v4.4/esp32s3/index.html) to understand the open-source drivers and components provided by Espressif.
|
||||
* **Step 2**. Next, setting up development environment. Please refer to [ESP-IDF(release/v4.4) Installation Step by Step](https://docs.espressif.com/projects/esp-idf/en/release-v4.4/esp32s3/get-started/index.html#installation-step-by-step).
|
||||
* **Step 3**. Additionally, apply the patch files on current ESP-IDF, please refer [Patch for ESP-IDF](./idf_patch) for details.
|
||||
ESP-BOX integrates components commonly used in AIoT development that you can leverage to build your own applications. Read more development guide [here](./docs/development_guide.md) (Updates in Progress).
|
||||
|
||||
### Quick Start
|
||||
|
||||
* **Step 1**. ESP-IDF (Espressif IoT Development Framework) is required to build the application. If this is your first time using the ESP-IDF, please refer to [ESP-IDF development guide](https://docs.espressif.com/projects/esp-idf/en/release-v5.1/esp32s3/index.html) to understand the open-source drivers and components provided by Espressif.
|
||||
* **Step 2**. Next, setting up development environment. Please refer to [ESP-IDF(release/v5.1) Installation Step by Step](https://docs.espressif.com/projects/esp-idf/en/release-v5.1/esp32s3/get-started/index.html).
|
||||
* **Step 3**. Run command `git clone --recursive https://github.com/espressif/esp-box.git` to download the code of this project and then switch the ESP-IDF version to [specified version](#versions);
|
||||
* **Step 4**. Take a small step, you can [build and flash a simple example](./examples/image_display).
|
||||
* **Step 5**. Moving further, please read [ESP-BOX technical architecture](./docs/technical_architecture.md) to understand the technical details.
|
||||
* **Step 6**. Going deeper, please read [ESP Speech Recognition Application Guide](https://github.com/espressif/esp-sr), [ESP RainMaker Programming Guide](https://docs.espressif.com/projects/esp-rainmaker/en/latest/), [LVGL GUI Quick overview](https://docs.lvgl.io/latest/en/html/get-started/quick-overview.html).
|
||||
* **Step 7**. For extended function, please read [ESP32-S3-BOX Pmod™ compatible headers](./docs/hardware_overview.md) and [ESP-IDF API reference](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/index.html), to develop drivers for more extended devices.
|
||||
* **Step 6**. Going deeper, please read [ESP Speech Recognition Application Guide](https://github.com/espressif/esp-sr), [ESP RainMaker Programming Guide](https://docs.espressif.com/projects/esp-rainmaker/en/latest/), [LVGL GUI Quick overview](https://docs.lvgl.io/8.3/).
|
||||
* **Step 7**. For extended function, please read [Pmod™ compatible headers](./docs/hardware_overview) and [ESP-IDF API reference](https://docs.espressif.com/projects/esp-idf/en/release-v5.1/esp32s3/api-reference/index.html), to develop drivers for more extended devices.
|
||||
|
||||
## Contact Us
|
||||
|
||||
* If you have any technical issues, please submit issue tickets at [GitHub Issues](https://github.com/espressif/esp-box/issues) or forum [esp32.com](https://esp32.com/) for help.
|
||||
* If you are interested in ESP-BOX project, welcome to the [ESP-BOX forum](https://esp32.com/viewforum.php?f=44) to share with us your ideas.
|
||||
* We welcome any open-source software or hardware contribution. Please commit to the [Pull Requests](https://github.com/espressif/esp-box/pulls) to contribute your code.
|
||||
|
||||
## Contributing Examples
|
||||
|
||||
We welcome any open-source software or hardware contribution. If you have any examples you want to share with us, please click the [Contributions Guide](https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/contribute/index.html) and commit to the [Pull Requests](https://github.com/espressif/esp-box/pulls) to contribute your code.
|
||||
|
||||
|
||||
@@ -1,55 +1,93 @@
|
||||
* [English Version](./README.md)
|
||||
* [Gitee 镜像仓库](https://gitee.com/EspressifSystems/esp-box)
|
||||
|
||||
# ESP-BOX AIoT 开发框架
|
||||
|
||||
**重要提醒:**
|
||||
**我们建议您在第一次收到产品时[更新 ESP32-S3-BOX 的固件](./docs/firmware_update_cn.md)以获得最新功能和 bug 的修复。**
|
||||
|
||||
ESP-BOX 是乐鑫信息科技发布的新一代 AIoT 应用开发平台。ESP32-S3-BOX 是对应的 AIoT 应用开发板,搭载支持 AI 加速的 ESP32-S3 Wi-Fi + Bluetooth 5 (LE) SoC。ESP32-S3-BOX 为用户提供了一个基于语音助手 + 触摸屏控制、传感器、红外控制器和智能 Wi-Fi 网关等功能,开发和控制智能家居设备的平台。ESP32-S3-BOX 出厂支持离线语音交互功能,通过乐鑫丰富的 SDK 和解决方案,能够轻松构建在线和离线语音助手、智能语音设备、HMI 触摸屏设备、控制面板、多协议网关等多样的应用。
|
||||
|
||||

|
||||
|
||||
**ESP-BOX 支持以下特性:**
|
||||
|
||||
* 双麦克风支持远场语音交互
|
||||
* 高唤醒率的离线语音唤醒
|
||||
* 高识别率的离线中英文命令词识别
|
||||
* 可动态配置的中英文命令词
|
||||
* 灵活可复用的 GUI 框架
|
||||
* 端到端一站式接入云平台
|
||||
* Pmod™ 兼容接口支持多种外设扩展
|
||||
|
||||
**ESP-BOX 开源内容包括:**
|
||||
|
||||
* [原理图与 PCB 源文件](./hardware)
|
||||
* [外壳 3D 打印源文件](./hardware/esp32_s3_box_shell_step)
|
||||
* [出厂固件源代码](./examples/factory_demo)
|
||||
* [示例程序源代码](./examples)
|
||||
|
||||
> 基于 [Apache 2.0](https://github.com/espressif/esp-box/blob/master/LICENSE) 开源协议,你可以免费且自由的修改、创作和分享。
|
||||
|
||||
## 使用指引
|
||||
|
||||
* 首次拿到 ESP32-S3-BOX,您可以查看[首次使用操作指引](./docs/getting_started_cn.md#给-esp32-s3-box-供电)
|
||||
* 想要设置独特的语音命令词,您可以查看[修改自定义命令词](./docs/getting_started_cn.md#语音控制命令词自定义)
|
||||
* 想要通过界面控制设备,请查看[图形界面操作指引](./docs/getting_started_cn.md#esp32-s3-box-图形界面)
|
||||
* 想要了解产品爆炸图和拆机说明, 请查看 [ESP32-S3-BOX 拆机教程](docs/disassembly_tutorial.md)
|
||||
* 想要了解 ESP32-S3-BOX 硬件和接口细节,请查看 [ESP32-S3-BOX 硬件总览](./docs/hardware_overview_cn.md)
|
||||
* 想要使用最新版本固件,请查看[固件更新说明](./docs/firmware_update_cn.md)
|
||||
|
||||
## 开发指引
|
||||
|
||||
* **Step 1**. 如果您首次接触 ESP-IDF 开发,建议先浏览 [ESP-IDF 编程指南](https://docs.espressif.com/projects/esp-idf/en/release-v4.4/esp32s3/index.html),了解乐鑫已经提供的开源驱动和组件;
|
||||
* **Step 2**. 接下来您可以详细阅读 [ESP-IDF(release/v4.4) 环境搭建指引](https://docs.espressif.com/projects/esp-idf/en/release-v4.4/esp32s3/get-started/index.html#installation-step-by-step), 一步一步完成开发环境搭建;
|
||||
* **Step 3**. 此外, 请在当前 ESP-IDF 上打上补丁, 详情请参考 [Patch for ESP-IDF](./idf_patch).
|
||||
* **Step 4**. 小试牛刀,您可以尝试 [构建并烧录一个新的示例程序](./examples/image_display);
|
||||
* **Step 5**. 更进一步,您可以阅读 [ESP-BOX 技术架构说明](./docs/technical_architecture_cn.md),了解更多技术细节;
|
||||
* **Step 6**. 深入开发,您可以阅读 [ESP 语音识别应用开发指南](https://github.com/espressif/esp-sr), [ESP RainMaker 编程指南](https://docs.espressif.com/projects/esp-rainmaker/en/latest/), [LVGL UI 界面开发快速总览](https://docs.lvgl.io/latest/en/html/get-started/quick-overview.html);
|
||||
* **Step 7**. 扩展功能,您可以阅读 [ESP32-S3-BOX Pmod™ 兼容接口介绍](./docs/hardware_overview_cn.md) 和 [ESP-IDF API 参考手册](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/index.html),为更多扩展设备开发驱动;
|
||||
|
||||
## 联系我们
|
||||
|
||||
* 如果有任何开发和使用问题,您可添加 [GitHub Issues](https://github.com/espressif/esp-box/issues) 或到 [esp32.com](https://esp32.com/) 论坛寻求帮助;
|
||||
* 如果你对 ESP-BOX 项目感兴趣,欢迎到论坛 [ESP-BOX 版块](https://esp32.com/viewforum.php?f=43)交流想法;
|
||||
* 我们欢迎任何软件或硬件相关的开源贡献,您可直接提交 [Pull Requests](https://github.com/espressif/esp-box/pulls) 贡献代码。
|
||||
* [English Version](./README.md)
|
||||
* [Gitee 镜像仓库](https://gitee.com/EspressifSystems/esp-box)
|
||||
|
||||
# ESP-BOX AIoT 开发框架
|
||||
|
||||
<p align="left">
|
||||
<a href="https://github.com/espressif/esp-box/blob/master/LICENSE" alt="Build examples">
|
||||
<img alt="GitHub" src="https://img.shields.io/github/license/espressif/esp-box"></a>
|
||||
<a href="https://github.com/espressif/esp-box/actions/workflows/build_IDF5.1.yml" alt="Build examples">
|
||||
<img src="https://github.com/espressif/esp-box/actions/workflows/build_IDF5.1.yml/badge.svg" /></a>
|
||||
<a href="https://github.com/espressif/esp-box/graphs/contributors" alt="Contributors">
|
||||
<img src="https://img.shields.io/github/contributors/espressif/esp-box" /></a>
|
||||
<a href="https://github.com/espressif/esp-box/releases" alt="GitHub all releases">
|
||||
<img src="https://img.shields.io/github/downloads/espressif/esp-box/total" /></a>
|
||||
</p>
|
||||
|
||||
<a href="https://espressif.github.io/esp-launchpad/?flashConfigURL=https://raw.githubusercontent.com/espressif/esp-box/master/launch.toml">
|
||||
<img alt="Try it with ESP Launchpad" src="https://espressif.github.io/esp-launchpad/assets/try_with_launchpad.png" width="200" height="56">
|
||||
</a>
|
||||
|
||||
**重要提醒:**
|
||||
> 我们建议您在第一次收到产品时[更新应用固件](./docs/firmware_update_cn.md)以获得最新功能和 bug 的修复,点此[链接](./docs/getting_started_cn.md)获取应用固件的使用说明。点击[此处](https://github.com/espressif/esp-box/releases)查看历史固件。
|
||||
|
||||
ESP-BOX 是乐鑫信息科技发布的新一代 AIoT 应用开发平台。ESP32-S3-BOX 和 ESP32-S3-BOX-Lite 是目前对应的 AIoT 应用开发板,搭载支持 AI 加速的 ESP32-S3 Wi-Fi + Bluetooth 5 (LE) SoC。他们为用户提供了一个基于语音助手 + 触摸屏控制、传感器、红外控制器和智能 Wi-Fi 网关等功能,开发和控制智能家居设备的平台。开发板出厂支持离线语音交互功能,用户通过乐鑫丰富的 SDK 和解决方案,能够轻松构建在线和离线语音助手、智能语音设备、HMI 人机交互设备、控制面板、多协议网关等多样的应用。
|
||||
|
||||
| 开发板名称 | 产品图 |
|
||||
| :-----: | :---------------------: |
|
||||
| [ESP32-S3-BOX](docs/hardware_overview/esp32_s3_box/hardware_overview_for_box_cn.md) | <img src="docs/_static/esp32_s3_box.png" width="200px" /> |
|
||||
| [ESP32-S3-BOX-Lite](docs/hardware_overview/esp32_s3_box_lite/hardware_overview_for_lite_cn.md) | <img src="docs/_static/esp32_s3_box_lite.png" width="200px" /> |
|
||||
|
||||
## 版本信息
|
||||
|
||||
| ESP-BOX | 依赖的 ESP-IDF | 分支信息 | 支持状态 |
|
||||
| :-------: | :----------------------------------------------------------: | :----------------------------------------------------------: | ------------------------------------------------------- |
|
||||
| master | >= release/v5.1<br/>commit id: 22cfbf30c3 | Latest developing firmware <br/>esp-sr components version: v1.3.4 | 兼容 ESP32-S3-BOX 和 ESP32-S3-BOX-Lite<br/>使用 menuconfig 选择开发板 |
|
||||
| Tag 0.5.0 | release/v5.1<br/>commit id: 22cfbf30c3 | esp-sr components version: v1.3.4 | 兼容 ESP32-S3-BOX 和 ESP32-S3-BOX-Lite<br/>使用 menuconfig 选择开发板 |
|
||||
| Tag 0.3.0 | release/v4.4<br/>commit id: 22cfbf30c3 | esp-sr version: dev/v2.0<br/>commit id: c873a35 | 兼容 ESP32-S3-BOX 和 ESP32-S3-BOX-Lite |
|
||||
| Tag 0.2.1 | release/v4.4 with [patch](https://github.com/espressif/esp-box/tree/v0.2.1/idf_patch) | esp-sr version: close v1.0<br/>commit id: 3ce34fe | 仅支持 ESP32-S3-BOX |
|
||||
| Tag 0.1.1 | Release/v4.4 with [patch](https://github.com/espressif/esp-box/tree/v0.1.1/idf_patch) | esp-sr version: v0.9.6<br/>commit id: 3ce34fe | 仅支持 ESP32-S3-BOX |
|
||||
|
||||
## 支持特性
|
||||
|
||||
* 双麦克风支持远场语音交互
|
||||
* 高唤醒率的离线语音唤醒
|
||||
* 高识别率的离线中英文命令词识别
|
||||
* 可动态配置 200+ 中英文命令词
|
||||
* 连续识别和唤醒打断
|
||||
* 灵活可复用的 GUI 框架
|
||||
* 端到端一站式接入云平台
|
||||
* Pmod™ 兼容接口支持多种外设扩展
|
||||
|
||||
## 开源内容
|
||||
|
||||
* [原理图与 PCB 源文件](./hardware)
|
||||
* [外壳 3D 打印源文件](./hardware)
|
||||
* [出厂固件源代码](./examples/factory_demo)
|
||||
* [示例程序源代码](./examples)
|
||||
|
||||
> 基于 [Apache 2.0](https://github.com/espressif/esp-box/blob/master/LICENSE) 开源协议,你可以免费且自由的修改、创作和分享。
|
||||
|
||||
## 使用指引
|
||||
|
||||
* 首次拿到 BOX 系列开发板,您可以查看 [首次使用操作指引](./docs/getting_started_cn.md#给设备供电);
|
||||
* 想要体验离线语音助手功能,您可以查看 [离线语音识别](./docs/getting_started_cn.md#体验离线语音识别);
|
||||
* 体验更人性化的语音交互,可查看 [连续语音识别](./docs/getting_started_cn.md#连续语音识别);
|
||||
* 想要通过手机 APP 设置独特的语音命令词,请查看 [ESP BOX APP 操作指引](./docs/getting_started_cn.md#语音命令词自定义);
|
||||
* 想要了解产品爆炸图和拆机说明,请查看 [拆机教程](docs/disassembly_tutorial.md);
|
||||
* 想要了解开发板硬件和接口细节,请查看 [硬件总览](./docs/hardware_overview);
|
||||
* 想要使用最新版本固件,请查看 [固件更新说明](./docs/firmware_update_cn.md)。
|
||||
|
||||
## 开发指引
|
||||
|
||||
ESP-BOX 调用乐鑫包管理器 ESP Registry 中常用的组件,您可以利用这些组件构建自己的应用。点击了解更多[开发指南](./docs/development_guide_cn.md)(持续更新中)。
|
||||
|
||||
### 快速开始
|
||||
|
||||
* **Step 1**. 如果您首次接触 ESP-IDF 开发,建议先浏览 [ESP-IDF 编程指南](https://docs.espressif.com/projects/esp-idf/zh_CN/release-v5.1/esp32s3/index.html),了解乐鑫已经提供的开源驱动和组件;
|
||||
* **Step 2**. 接下来您可以详细阅读 [ESP-IDF(release/v5.1) 环境搭建指引](https://docs.espressif.com/projects/esp-idf/en/release-v5.1/esp32s3/get-started/index.html),一步一步完成开发环境搭建;
|
||||
* **Step 3**. 使用指令 `git clone --recursive https://github.com/espressif/esp-box.git` 下载本项目的代码,然后需要将 esp-idf 版本切换到[指定的版本](#版本信息);
|
||||
* **Step 4**. 小试牛刀,您可以尝试 [构建并烧录一个新的示例程序](./examples/image_display);
|
||||
* **Step 5**. 更进一步,您可以阅读 [ESP-BOX 技术架构说明](./docs/technical_architecture_cn.md),了解更多技术细节;
|
||||
* **Step 6**. 深入开发,您可以阅读 [ESP 语音识别应用开发指南](https://github.com/espressif/esp-sr),[ESP RainMaker 编程指南](https://docs.espressif.com/projects/esp-rainmaker/en/latest/),[LVGL UI 界面开发快速总览](https://docs.lvgl.io/8.3/);
|
||||
* **Step 7**. 扩展功能,您可以阅读 [开发板 Pmod™ 兼容接口介绍](./docs/hardware_overview) 和 [ESP-IDF API 参考手册](https://docs.espressif.com/projects/esp-idf/en/release-v5.1/esp32s3/api-reference/index.html),为更多扩展设备开发驱动。
|
||||
|
||||
## 联系我们
|
||||
|
||||
* 如果有任何开发和使用问题,您可添加 [GitHub Issues](https://github.com/espressif/esp-box/issues) 或到 [esp32.com](https://esp32.com/) 论坛寻求帮助;
|
||||
* 如果你对 ESP-BOX 项目感兴趣,欢迎到论坛 [ESP-BOX 版块](https://www.esp32.com/viewforum.php?f=43) 交流想法。
|
||||
|
||||
|
||||
## 贡献示例
|
||||
|
||||
我们欢迎任何软件或硬件相关的开源贡献,如果您有任何要与我们分享的示例,请参考 [贡献指南](https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/contribute/index.html) 后提交 [Pull Requests](https://github.com/espressif/esp-box/pulls) 贡献代码。
|
||||
|
||||
@@ -1,29 +1,36 @@
|
||||
file(GLOB_RECURSE BSP_SRCS
|
||||
"src/bsp_codec.c"
|
||||
"src/bsp_i2c.c"
|
||||
"src/bsp_i2s.c"
|
||||
"src/bsp_tp.c"
|
||||
"src/lcd/*.c"
|
||||
"src/storage/*.c")
|
||||
set(bsp_src "src/storage/bsp_sdcard.c")
|
||||
|
||||
if(CONFIG_ESP32_S3_BOX_BOARD)
|
||||
list(APPEND BSP_BOARD_SRC "./boards/esp32_s3_box.c")
|
||||
message(STATUS "PROJECT_DIR: " ${PROJECT_DIR})
|
||||
|
||||
if(EXISTS ${PROJECT_DIR}/sdkconfig)
|
||||
file(READ ${PROJECT_DIR}/sdkconfig SDKCONFIG_RULE)
|
||||
string(REGEX MATCH "CONFIG_BSP_BOARD_ESP32_S3_BOX_Lite=y" CMAKE_TARGET_IS_BOX_LITE "${SDKCONFIG_RULE}")
|
||||
string(REGEX MATCH "CONFIG_BSP_BOARD_ESP32_S3_BOX=y" CMAKE_TARGET_IS_ESP_BOX "${SDKCONFIG_RULE}")
|
||||
else()
|
||||
message(STATUS "sdkconfig not exist")
|
||||
file(READ ${CMAKE_CURRENT_LIST_DIR}/Kconfig.projbuild SDKCONFIG_RULE)
|
||||
string(REGEX MATCH "default BSP_BOARD_ESP32_S3_BOX_Lite" CMAKE_TARGET_IS_BOX_LITE "${SDKCONFIG_RULE}")
|
||||
string(REGEX MATCH "default BSP_BOARD_ESP32_S3_BOX" CMAKE_TARGET_IS_ESP_BOX "${SDKCONFIG_RULE}")
|
||||
endif()
|
||||
|
||||
if(CONFIG_ESP_CUSTOM_BOARD)
|
||||
list(APPEND BSP_BOARD_SRC "./boards/esp_custom_board.c")
|
||||
if (CMAKE_TARGET_IS_ESP_BOX)
|
||||
message(STATUS "PLATFORM ESP32_S3_BOX.")
|
||||
list(APPEND bsp_src "src/boards/esp32_s3_box.c")
|
||||
elseif (CMAKE_TARGET_IS_BOX_LITE)
|
||||
message(STATUS "PLATFORM ESP32_S3_BOX_Lite.")
|
||||
list(APPEND bsp_src "src/boards/esp32_s3_box_lite.c")
|
||||
set(box_lite "-lite")
|
||||
else()
|
||||
message(FATAL_ERROR "PLATFORM unknown.")
|
||||
endif()
|
||||
|
||||
set(priv_requires "esp-box${box_lite}")
|
||||
set(requires "driver" "fatfs")
|
||||
|
||||
idf_component_register(
|
||||
SRCS
|
||||
${BSP_SRCS}
|
||||
${BSP_BOARD_SRC}
|
||||
SRCS ${bsp_src}
|
||||
INCLUDE_DIRS
|
||||
"boards"
|
||||
"src/boards"
|
||||
"include"
|
||||
REQUIRES
|
||||
codec
|
||||
i2c_devices
|
||||
esp_lcd
|
||||
fatfs
|
||||
spiffs)
|
||||
PRIV_REQUIRES ${priv_requires}
|
||||
REQUIRES ${requires})
|
||||
|
||||
@@ -1,176 +1,18 @@
|
||||
menu "HMI Board Config"
|
||||
|
||||
choice HMI_BOARD
|
||||
prompt "HMI board"
|
||||
default ESP32_S3_BOX_BOARD
|
||||
help
|
||||
Select an HMI board to use with the HMI project
|
||||
config ESP32_S3_BOX_BOARD
|
||||
bool "ESP32-S3 Box Dev Board"
|
||||
depends on IDF_TARGET_ESP32S3
|
||||
config ESP_CUSTOM_BOARD
|
||||
bool "Custom HMI board"
|
||||
choice BSP_LCD_BOARD
|
||||
prompt "Select BSP board"
|
||||
default BSP_BOARD_ESP32_S3_BOX
|
||||
config BSP_BOARD_ESP32_S3_BOX
|
||||
bool "BSP board esp32_s3_box"
|
||||
config BSP_BOARD_ESP32_S3_BOX_Lite
|
||||
bool "BSP board esp32_s3_box_lite"
|
||||
endchoice
|
||||
|
||||
choice LCD_INTERFACE
|
||||
prompt "Select LCD interface"
|
||||
depends on ESP_CUSTOM_BOARD
|
||||
default LCD_INTERFACE_I80
|
||||
config BSP_TOUCH_BUTTON
|
||||
depends on BSP_BOARD_ESP32_S3_BOX
|
||||
bool "Enable esp32_s3_box touch button"
|
||||
default y
|
||||
help
|
||||
Select LCD interface of custom board
|
||||
|
||||
config LCD_INTERFACE_I2C
|
||||
bool "LCD_INTERFACE_I2C"
|
||||
config LCD_INTERFACE_I80
|
||||
bool "LCD_INTERFACE_I80"
|
||||
config LCD_INTERFACE_SPI
|
||||
bool "LCD_INTERFACE_SPI"
|
||||
|
||||
endchoice
|
||||
|
||||
menu "I80 LCD GPIO configuration"
|
||||
depends on LCD_INTERFACE_I80
|
||||
choice LCD_BIT_WIDTH
|
||||
prompt "LCD Data Line Width"
|
||||
default LCD_BIT_WIDTH_8_BIT
|
||||
help
|
||||
Lines of LCD data bus.
|
||||
|
||||
config LCD_BIT_WIDTH_8_BIT
|
||||
bool "8 Bit"
|
||||
config LCD_BIT_WIDTH_16_BIT
|
||||
bool "16 Bit"
|
||||
endchoice
|
||||
config LCD_WR_GPIO
|
||||
int "LCD WR GPIO"
|
||||
range 0 48
|
||||
default 34
|
||||
config LCD_RS_GPIO
|
||||
int "LCD RS GPIO"
|
||||
range 0 48
|
||||
default 33
|
||||
config LCD_D00_GPIO
|
||||
int "LCD D00 GPIO"
|
||||
range 0 48
|
||||
default 16
|
||||
config LCD_D01_GPIO
|
||||
int "LCD D01 GPIO"
|
||||
range 0 48
|
||||
default 15
|
||||
config LCD_D02_GPIO
|
||||
int "LCD D02 GPIO"
|
||||
range 0 48
|
||||
default 14
|
||||
config LCD_D03_GPIO
|
||||
int "LCD D03 GPIO"
|
||||
range 0 48
|
||||
default 13
|
||||
config LCD_D04_GPIO
|
||||
int "LCD D04 GPIO"
|
||||
range 0 48
|
||||
default 12
|
||||
config LCD_D05_GPIO
|
||||
int "LCD D05 GPIO"
|
||||
range 0 48
|
||||
default 11
|
||||
config LCD_D06_GPIO
|
||||
int "LCD D06 GPIO"
|
||||
range 0 48
|
||||
default 10
|
||||
config LCD_D07_GPIO
|
||||
int "LCD D07 GPIO"
|
||||
range 0 48
|
||||
default 9
|
||||
config LCD_D08_GPIO
|
||||
int "LCD D08 GPIO"
|
||||
range 0 48
|
||||
default 8
|
||||
depends on LCD_BIT_WIDTH_16_BIT
|
||||
config LCD_D09_GPIO
|
||||
int "LCD D09 GPIO"
|
||||
range 0 48
|
||||
default 7
|
||||
depends on LCD_BIT_WIDTH_16_BIT
|
||||
config LCD_D10_GPIO
|
||||
int "LCD D10 GPIO"
|
||||
range 0 48
|
||||
default 6
|
||||
depends on LCD_BIT_WIDTH_16_BIT
|
||||
config LCD_D11_GPIO
|
||||
int "LCD D11 GPIO"
|
||||
range 0 48
|
||||
default 5
|
||||
depends on LCD_BIT_WIDTH_16_BIT
|
||||
config LCD_D12_GPIO
|
||||
int "LCD D12 GPIO"
|
||||
range 0 48
|
||||
default 4
|
||||
depends on LCD_BIT_WIDTH_16_BIT
|
||||
config LCD_D13_GPIO
|
||||
int "LCD D13 GPIO"
|
||||
range 0 48
|
||||
default 3
|
||||
depends on LCD_BIT_WIDTH_16_BIT
|
||||
config LCD_D14_GPIO
|
||||
int "LCD D14 GPIO"
|
||||
range 0 48
|
||||
default 2
|
||||
depends on LCD_BIT_WIDTH_16_BIT
|
||||
config LCD_D15_GPIO
|
||||
int "LCD D15 GPIO"
|
||||
range 0 48
|
||||
default 1
|
||||
depends on LCD_BIT_WIDTH_16_BIT
|
||||
endmenu
|
||||
|
||||
|
||||
menu "I2C GPIO configuration"
|
||||
depends on ESP_CUSTOM_BOARD
|
||||
config I2C_SCL_GPIO
|
||||
int "I2C SCL GPIO"
|
||||
range 0 48
|
||||
default 36
|
||||
config I2C_SDA_GPIO
|
||||
int "I2C SDA GPIO"
|
||||
range 0 48
|
||||
default 35
|
||||
endmenu
|
||||
|
||||
menu "SPI GPIO configuration"
|
||||
depends on ESP_CUSTOM_BOARD
|
||||
|
||||
config SPI_CS_GPIO
|
||||
int "SPI CS GPIO"
|
||||
range 0 48
|
||||
default 37
|
||||
config SPI_MISO_GPIO
|
||||
int "SPI MISO GPIO"
|
||||
range 0 48
|
||||
default 40
|
||||
config SPI_MOSI_GPIO
|
||||
int "SPI MOSI GPIO"
|
||||
range 0 48
|
||||
default 38
|
||||
config SPI_SCLK_GPIO
|
||||
int "SPI SCLK GPIO"
|
||||
range 0 48
|
||||
default 39
|
||||
endmenu
|
||||
|
||||
menu "Touch Panel Drivers"
|
||||
depends on ESP_CUSTOM_BOARD
|
||||
|
||||
menu "Config Input Value"
|
||||
config TOUCH_PANEL_INVERSE_X
|
||||
bool "Reverse X Axis"
|
||||
default n
|
||||
config TOUCH_PANEL_INVERSE_Y
|
||||
bool "Reverse Y Axis"
|
||||
default n
|
||||
config TOUCH_PANEL_SWAP_XY
|
||||
bool "Swap X and Y Axis"
|
||||
default n
|
||||
endmenu
|
||||
|
||||
endmenu
|
||||
Whether to enable the touch button.
|
||||
endmenu
|
||||
@@ -1,98 +0,0 @@
|
||||
/**
|
||||
* @file esp32_s3_box.c
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2021-07-28
|
||||
*
|
||||
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "driver/gpio.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_rom_sys.h"
|
||||
#include "bsp_board.h"
|
||||
#include "bsp_i2c.h"
|
||||
|
||||
#define GPIO_MUTE_NUM GPIO_NUM_1
|
||||
#define GPIO_MUTE_LEVEL 1
|
||||
|
||||
static const char *TAG = "board";
|
||||
|
||||
__attribute__((weak)) void mute_btn_handler(void *arg)
|
||||
{
|
||||
if (GPIO_MUTE_LEVEL == gpio_get_level(GPIO_MUTE_NUM)) {
|
||||
esp_rom_printf(DRAM_STR("Mute Off"));
|
||||
} else {
|
||||
esp_rom_printf(DRAM_STR("Mute On"));
|
||||
}
|
||||
}
|
||||
|
||||
esp_err_t bsp_board_init(void)
|
||||
{
|
||||
/*!< Mute_Button on ESP32-S3-Box */
|
||||
gpio_config_t io_conf_key;
|
||||
io_conf_key.intr_type = GPIO_INTR_ANYEDGE;
|
||||
io_conf_key.mode = GPIO_MODE_INPUT;
|
||||
io_conf_key.pin_bit_mask = 1ULL << GPIO_MUTE_NUM;
|
||||
io_conf_key.pull_down_en = GPIO_PULLDOWN_DISABLE;
|
||||
io_conf_key.pull_up_en = GPIO_PULLUP_ENABLE;
|
||||
ESP_ERROR_CHECK(gpio_config(&io_conf_key));
|
||||
|
||||
/* Install GPIO ISR service to enable GPIO ISR callback */
|
||||
gpio_install_isr_service(0);
|
||||
ESP_ERROR_CHECK(gpio_isr_handler_add(GPIO_MUTE_NUM, mute_btn_handler, NULL));
|
||||
|
||||
/*!< Initialize I2C bus, used for TP ,audio codec and IMU */
|
||||
bsp_i2c_init(I2C_NUM_0, 400 * 1000);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t bsp_board_power_ctrl(power_module_t module, bool on)
|
||||
{
|
||||
/* Config power control IO */
|
||||
static esp_err_t bsp_io_config_state = ESP_FAIL;
|
||||
if (ESP_OK != bsp_io_config_state) {
|
||||
gpio_config_t io_conf;
|
||||
io_conf.intr_type = GPIO_INTR_DISABLE;
|
||||
io_conf.mode = GPIO_MODE_OUTPUT;
|
||||
io_conf.pin_bit_mask = 1ULL << GPIO_PWR_CTRL;
|
||||
io_conf.pull_down_en = GPIO_PULLDOWN_DISABLE;
|
||||
io_conf.pull_up_en = GPIO_PULLUP_DISABLE;
|
||||
bsp_io_config_state = gpio_config(&io_conf);
|
||||
}
|
||||
|
||||
/* Checko IO config result */
|
||||
if (ESP_OK != bsp_io_config_state) {
|
||||
ESP_LOGE(TAG, "Failed initialize power control IO");
|
||||
return bsp_io_config_state;
|
||||
}
|
||||
|
||||
/* Control independent power domain */
|
||||
switch (module) {
|
||||
case POWER_MODULE_LCD:
|
||||
gpio_set_level(GPIO_LCD_BL, on ? (GPIO_LCD_BL_ON) : (!GPIO_LCD_BL_ON));
|
||||
break;
|
||||
case POWER_MODULE_AUDIO:
|
||||
case POWER_MODULE_ALL:
|
||||
gpio_set_level(GPIO_PWR_CTRL, on ? (GPIO_PWR_ON_LEVEL) : (!GPIO_PWR_ON_LEVEL));
|
||||
break;
|
||||
default:
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
/**
|
||||
* @file esp32_s3_box.h
|
||||
* @version 0.1
|
||||
* @date 2021-06-25
|
||||
*
|
||||
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "driver/gpio.h"
|
||||
|
||||
/**
|
||||
* @brief ESP32-S3-Box LCD GPIO defination and config
|
||||
*
|
||||
*/
|
||||
#define FUNC_LCD_EN (1)
|
||||
#define LCD_BUS_WIDTH (1)
|
||||
#define LCD_IFACE_SPI (1)
|
||||
#define LCD_DISP_IC_ST (1)
|
||||
#define LCD_WIDTH (320)
|
||||
#define LCD_HEIGHT (240)
|
||||
#define LCD_FREQ (40 * 1000 * 1000)
|
||||
#define LCD_HOST (SPI2_HOST)
|
||||
|
||||
#define LCD_SWAP_XY (0)
|
||||
#define LCD_MIRROR_X (true)
|
||||
#define LCD_MIRROR_Y (true)
|
||||
#define LCD_COLOR_INV (false)
|
||||
|
||||
#define GPIO_LCD_BL (GPIO_NUM_45)
|
||||
#define GPIO_LCD_BL_ON (1)
|
||||
#define GPIO_LCD_CS (GPIO_NUM_5)
|
||||
#define GPIO_LCD_RST (GPIO_NUM_48)
|
||||
#define GPIO_LCD_DC (GPIO_NUM_4)
|
||||
#define GPIO_LCD_CLK (GPIO_NUM_7)
|
||||
#define GPIO_LCD_DIN (GPIO_NUM_6)
|
||||
#define GPIO_LCD_DOUT (GPIO_NUM_NC)
|
||||
|
||||
#define TOUCH_PANEL_SWAP_XY (0)
|
||||
#define TOUCH_PANEL_INVERSE_X (1)
|
||||
#define TOUCH_PANEL_INVERSE_Y (0)
|
||||
|
||||
|
||||
/**
|
||||
* @brief ESP32-S3-Box I2C GPIO defineation
|
||||
*
|
||||
*/
|
||||
#define FUNC_I2C_EN (1)
|
||||
#define GPIO_I2C_SCL (GPIO_NUM_18)
|
||||
#define GPIO_I2C_SDA (GPIO_NUM_8)
|
||||
|
||||
/**
|
||||
* @brief ESP32-S3-Box SDMMC GPIO defination
|
||||
*
|
||||
* @note Only avaliable when PMOD connected
|
||||
*/
|
||||
#define FUNC_SDMMC_EN (1)
|
||||
#define SDMMC_BUS_WIDTH (4)
|
||||
#define GPIO_SDMMC_CLK (GPIO_NUM_13)
|
||||
#define GPIO_SDMMC_CMD (GPIO_NUM_11)
|
||||
#define GPIO_SDMMC_D0 (GPIO_NUM_14)
|
||||
#define GPIO_SDMMC_D1 (GPIO_NUM_12)
|
||||
#define GPIO_SDMMC_D2 (GPIO_NUM_10)
|
||||
#define GPIO_SDMMC_D3 (GPIO_NUM_9)
|
||||
#define GPIO_SDMMC_DET (GPIO_NUM_NC)
|
||||
|
||||
/**
|
||||
* @brief ESP32-S3-Box SDSPI GPIO definationv
|
||||
*
|
||||
*/
|
||||
#define FUNC_SDSPI_EN (0)
|
||||
#define SDSPI_HOST (SPI2_HOST)
|
||||
#define GPIO_SDSPI_CS (GPIO_NUM_NC)
|
||||
#define GPIO_SDSPI_SCLK (GPIO_NUM_NC)
|
||||
#define GPIO_SDSPI_MISO (GPIO_NUM_NC)
|
||||
#define GPIO_SDSPI_MOSI (GPIO_NUM_NC)
|
||||
|
||||
/**
|
||||
* @brief ESP32-S3-Box SPI GPIO defination
|
||||
*
|
||||
*/
|
||||
#define FUNC_SPI_EN (0)
|
||||
#define GPIO_SPI_CS (GPIO_NUM_NC)
|
||||
#define GPIO_SPI_MISO (GPIO_NUM_NC)
|
||||
#define GPIO_SPI_MOSI (GPIO_NUM_NC)
|
||||
#define GPIO_SPI_SCLK (GPIO_NUM_NC)
|
||||
|
||||
/**
|
||||
* @brief ESP32-S3-Box RMT GPIO defination
|
||||
*
|
||||
*/
|
||||
#define FUNC_RMT_EN (0)
|
||||
#define GPIO_RMT_IR (GPIO_NUM_NC)
|
||||
#define GPIO_RMT_LED (GPIO_NUM_39)
|
||||
|
||||
/**
|
||||
* @brief ESP32-S3-Box I2S GPIO defination
|
||||
*
|
||||
*/
|
||||
#define FUNC_I2S_EN (1)
|
||||
#define GPIO_I2S_LRCK (GPIO_NUM_47)
|
||||
#define GPIO_I2S_MCLK (GPIO_NUM_2)
|
||||
#define GPIO_I2S_SCLK (GPIO_NUM_17)
|
||||
#define GPIO_I2S_SDIN (GPIO_NUM_16)
|
||||
#define GPIO_I2S_DOUT (GPIO_NUM_15)
|
||||
|
||||
/**
|
||||
* @brief ESP32-S3-HMI-DevKit power control IO
|
||||
*
|
||||
* @note Some power control pins might not be listed yet
|
||||
*
|
||||
*/
|
||||
#define FUNC_PWR_CTRL (1)
|
||||
#define GPIO_PWR_CTRL (GPIO_NUM_46)
|
||||
#define GPIO_PWR_ON_LEVEL (1)
|
||||
@@ -1,42 +0,0 @@
|
||||
/**
|
||||
* @file esp_custom_board.c
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2021-10-20
|
||||
*
|
||||
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "bsp_board.h"
|
||||
#include "esp_custom_board.h"
|
||||
#include "esp_err.h"
|
||||
|
||||
esp_err_t bsp_board_init(void)
|
||||
{
|
||||
/* **************** ADD BOARD INITIAL CODE HERE **************** */
|
||||
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
esp_err_t bsp_board_power_ctrl(power_module_t module, bool on)
|
||||
{
|
||||
(void) module;
|
||||
(void) on;
|
||||
|
||||
/* **************** ADD BOARD POWER CONTROL CODE HERE **************** */
|
||||
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
/**
|
||||
* @file esp_custom_board.h
|
||||
* @version 0.1
|
||||
* @date 2021-06-25
|
||||
*
|
||||
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "driver/gpio.h"
|
||||
|
||||
/**
|
||||
* @brief ESP-Dev-Board LCD GPIO defination and config
|
||||
*
|
||||
*/
|
||||
#define FUNC_LCD_EN (1)
|
||||
#define LCD_BUS_WIDTH (1)
|
||||
#define LCD_IFACE_SPI (1)
|
||||
#define LCD_DISP_IC_ST (1)
|
||||
#define LCD_WIDTH (320)
|
||||
#define LCD_HEIGHT (240)
|
||||
#define LCD_FREQ (40 * 1000 * 1000)
|
||||
#define LCD_HOST (SPI2_HOST)
|
||||
|
||||
#define LCD_SWAP_XY (0)
|
||||
#define LCD_MIRROR_X (false)
|
||||
#define LCD_MIRROR_Y (false)
|
||||
#define LCD_COLOR_INV (false)
|
||||
|
||||
#define GPIO_LCD_BL (GPIO_NUM_NC)
|
||||
#define GPIO_LCD_BL_ON (1)
|
||||
#define GPIO_LCD_CS (GPIO_NUM_NC)
|
||||
#define GPIO_LCD_RST (GPIO_NUM_NC)
|
||||
#define GPIO_LCD_DC (GPIO_NUM_NC)
|
||||
#define GPIO_LCD_CLK (GPIO_NUM_NC)
|
||||
#define GPIO_LCD_DIN (GPIO_NUM_NC)
|
||||
#define GPIO_LCD_DOUT (GPIO_NUM_NC)
|
||||
|
||||
#define TOUCH_PANEL_SWAP_XY (0)
|
||||
#define TOUCH_PANEL_INVERSE_X (0)
|
||||
#define TOUCH_PANEL_INVERSE_Y (0)
|
||||
|
||||
|
||||
/**
|
||||
* @brief ESP-Dev-Board I2C GPIO defineation
|
||||
*
|
||||
*/
|
||||
#define FUNC_I2C_EN (1)
|
||||
#define GPIO_I2C_SCL (GPIO_NUM_NC)
|
||||
#define GPIO_I2C_SDA (GPIO_NUM_NC)
|
||||
|
||||
/**
|
||||
* @brief ESP-Dev-Board SDMMC GPIO defination
|
||||
*
|
||||
* @note Only avaliable when PMOD connected
|
||||
*/
|
||||
#define FUNC_SDMMC_EN (1)
|
||||
#define SDMMC_BUS_WIDTH (4)
|
||||
#define GPIO_SDMMC_CLK (GPIO_NUM_NC)
|
||||
#define GPIO_SDMMC_CMD (GPIO_NUM_NC)
|
||||
#define GPIO_SDMMC_D0 (GPIO_NUM_NC)
|
||||
#define GPIO_SDMMC_D1 (GPIO_NUM_NC)
|
||||
#define GPIO_SDMMC_D2 (GPIO_NUM_NC)
|
||||
#define GPIO_SDMMC_D3 (GPIO_NUM_NC)
|
||||
#define GPIO_SDMMC_DET (GPIO_NUM_NC)
|
||||
|
||||
/**
|
||||
* @brief ESP-Dev-Board SDSPI GPIO definationv
|
||||
*
|
||||
*/
|
||||
#define FUNC_SDSPI_EN (0)
|
||||
#define SDSPI_HOST (SPI2_HOST)
|
||||
#define GPIO_SDSPI_CS (GPIO_NUM_NC)
|
||||
#define GPIO_SDSPI_SCLK (GPIO_NUM_NC)
|
||||
#define GPIO_SDSPI_MISO (GPIO_NUM_NC)
|
||||
#define GPIO_SDSPI_MOSI (GPIO_NUM_NC)
|
||||
|
||||
/**
|
||||
* @brief ESP-Dev-Board SPI GPIO defination
|
||||
*
|
||||
*/
|
||||
#define FUNC_SPI_EN (0)
|
||||
#define GPIO_SPI_CS (GPIO_NUM_NC)
|
||||
#define GPIO_SPI_MISO (GPIO_NUM_NC)
|
||||
#define GPIO_SPI_MOSI (GPIO_NUM_NC)
|
||||
#define GPIO_SPI_SCLK (GPIO_NUM_NC)
|
||||
|
||||
/**
|
||||
* @brief ESP-Dev-Board RMT GPIO defination
|
||||
*
|
||||
*/
|
||||
#define FUNC_RMT_EN (0)
|
||||
#define GPIO_RMT_IR (GPIO_NUM_NC)
|
||||
#define GPIO_RMT_LED (GPIO_NUM_39)
|
||||
|
||||
/**
|
||||
* @brief ESP-Dev-Board I2S GPIO defination
|
||||
*
|
||||
*/
|
||||
#define FUNC_I2S_EN (1)
|
||||
#define GPIO_I2S_LRCK (GPIO_NUM_NC)
|
||||
#define GPIO_I2S_MCLK (GPIO_NUM_NC)
|
||||
#define GPIO_I2S_SCLK (GPIO_NUM_NC)
|
||||
#define GPIO_I2S_SDIN (GPIO_NUM_NC)
|
||||
#define GPIO_I2S_DOUT (GPIO_NUM_NC)
|
||||
|
||||
/**
|
||||
* @brief ESP32-S3-HMI-DevKit power control IO
|
||||
*
|
||||
* @note Some power control pins might not be listed yet
|
||||
*
|
||||
*/
|
||||
#define FUNC_PWR_CTRL (1)
|
||||
#define GPIO_PWR_CTRL (GPIO_NUM_NC)
|
||||
#define GPIO_PWR_ON_LEVEL (1)
|
||||
@@ -0,0 +1,10 @@
|
||||
## IDF Component Manager Manifest File
|
||||
dependencies:
|
||||
espressif/button: ^2
|
||||
|
||||
espressif/esp-box:
|
||||
version: "3.*"
|
||||
require: "no"
|
||||
espressif/esp-box-lite:
|
||||
version: "2.0.*"
|
||||
require: "no"
|
||||
@@ -1,59 +1,130 @@
|
||||
/**
|
||||
* @file bsp_board.h
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2021-06-25
|
||||
*
|
||||
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
|
||||
/**
|
||||
* @brief Add dev board pin defination and check target.
|
||||
*
|
||||
*/
|
||||
|
||||
#if CONFIG_ESP32_S3_BOX_BOARD
|
||||
#include "esp32_s3_box.h"
|
||||
#elif CONFIG_ESP_CUSTOM_BOARD
|
||||
#include "esp_custom_board.h"
|
||||
#else
|
||||
#error "Please select type of dev board"
|
||||
#endif
|
||||
#include "driver/gpio.h"
|
||||
#include "driver/spi_master.h"
|
||||
// #include "bsp/esp-bsp.h"
|
||||
#include "driver/i2s_std.h"
|
||||
#include "iot_button.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Power module of dev board. This can be expanded in the future.
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
POWER_MODULE_LCD = 1, /*!< LCD power control */
|
||||
POWER_MODULE_AUDIO, /*!< Audio PA power control */
|
||||
POWER_MODULE_ALL = 0xff, /*!< All module power control */
|
||||
} power_module_t;
|
||||
BOARD_S3_BOX,
|
||||
BOARD_S3_BOX_LITE,
|
||||
} boards_id_t;
|
||||
|
||||
typedef enum {
|
||||
#if CONFIG_BSP_BOARD_ESP32_S3_BOX
|
||||
BOARD_BTN_ID_BOOT = 0,
|
||||
BOARD_BTN_ID_MUTE,
|
||||
BOARD_BTN_ID_HOME,
|
||||
BOARD_BTN_ID_NUM
|
||||
#elif CONFIG_BSP_BOARD_ESP32_S3_BOX_Lite
|
||||
BOARD_BTN_ID_BOOT = 0,
|
||||
BOARD_BTN_ID_NUM
|
||||
#endif
|
||||
} bsp_button_id_t;
|
||||
|
||||
typedef struct {
|
||||
gpio_num_t row1[4]; //The first row
|
||||
gpio_num_t row2[4];
|
||||
} pmod_pins_t;
|
||||
|
||||
typedef struct {
|
||||
/**
|
||||
* @brief ESP-Dev-Board SDMMC GPIO defination
|
||||
*
|
||||
* @note Only avaliable when PMOD connected
|
||||
*/
|
||||
bool FUNC_SDMMC_EN ;
|
||||
int SDMMC_BUS_WIDTH ;
|
||||
int GPIO_SDMMC_CLK ;
|
||||
int GPIO_SDMMC_CMD ;
|
||||
int GPIO_SDMMC_D0 ;
|
||||
int GPIO_SDMMC_D1 ;
|
||||
int GPIO_SDMMC_D2 ;
|
||||
int GPIO_SDMMC_D3 ;
|
||||
int GPIO_SDMMC_DET ;
|
||||
|
||||
/**
|
||||
* @brief ESP-Dev-Board SDSPI GPIO definationv
|
||||
*
|
||||
*/
|
||||
bool FUNC_SDSPI_EN ;
|
||||
int SDSPI_HOST ;
|
||||
int GPIO_SDSPI_CS ;
|
||||
int GPIO_SDSPI_SCLK ;
|
||||
int GPIO_SDSPI_MISO ;
|
||||
int GPIO_SDSPI_MOSI ;
|
||||
|
||||
/**
|
||||
* @brief ESP-Dev-Board SPI GPIO defination
|
||||
*
|
||||
*/
|
||||
bool FUNC_SPI_EN ;
|
||||
int GPIO_SPI_CS ;
|
||||
int GPIO_SPI_MISO ;
|
||||
int GPIO_SPI_MOSI ;
|
||||
int GPIO_SPI_SCLK ;
|
||||
|
||||
/**
|
||||
* @brief ESP-Dev-Board RMT GPIO defination
|
||||
*
|
||||
*/
|
||||
bool FUNC_RMT_EN ;
|
||||
int GPIO_RMT_IR ;
|
||||
int GPIO_RMT_LED ;
|
||||
|
||||
const pmod_pins_t *PMOD1;
|
||||
const pmod_pins_t *PMOD2;
|
||||
|
||||
} board_res_desc_t;
|
||||
|
||||
typedef esp_err_t (*bsp_codec_reconfig_fn)();
|
||||
|
||||
typedef esp_err_t (*bsp_codec_mute_fn)(bool enable);
|
||||
|
||||
typedef esp_err_t (*bsp_codec_volume_fn)(int volume, int *volume_set);
|
||||
|
||||
typedef esp_err_t (*bsp_i2s_reconfig_clk_fn)(uint32_t rate, uint32_t bits_cfg, i2s_slot_mode_t ch);
|
||||
|
||||
typedef esp_err_t (*bsp_i2s_read_fn)(void *audio_buffer, size_t len, size_t *bytes_read, uint32_t timeout_ms);
|
||||
|
||||
typedef esp_err_t (*bsp_i2s_write_fn)(void *audio_buffer, size_t len, size_t *bytes_written, uint32_t timeout_ms);
|
||||
|
||||
typedef struct {
|
||||
bsp_codec_mute_fn mute_set_fn;
|
||||
bsp_codec_volume_fn volume_set_fn;
|
||||
bsp_codec_reconfig_fn codec_reconfig_fn;
|
||||
|
||||
bsp_i2s_read_fn i2s_read_fn;
|
||||
bsp_i2s_write_fn i2s_write_fn;
|
||||
bsp_i2s_reconfig_clk_fn i2s_reconfig_clk_fn;
|
||||
} bsp_codec_config_t;
|
||||
|
||||
typedef struct {
|
||||
boards_id_t id;
|
||||
const char *name;
|
||||
/**
|
||||
* @brief Get board description
|
||||
*/
|
||||
const board_res_desc_t *board_desc;
|
||||
|
||||
} boards_info_t;
|
||||
|
||||
/**
|
||||
* @brief Special config for dev board
|
||||
*
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Success
|
||||
* - Others: Fail
|
||||
@@ -61,15 +132,61 @@ typedef enum {
|
||||
esp_err_t bsp_board_init(void);
|
||||
|
||||
/**
|
||||
* @brief Control power of dev board
|
||||
*
|
||||
* @param module Refer to `power_module_t`
|
||||
* @param on Turn on or off specified power module. On if true
|
||||
* @brief Get the board information
|
||||
*
|
||||
* @return pointer of boards_info_t
|
||||
*/
|
||||
const boards_info_t *bsp_board_get_info(void);
|
||||
|
||||
/**
|
||||
* @brief Get board description
|
||||
*
|
||||
* @return pointer of board_res_desc_t
|
||||
*/
|
||||
const board_res_desc_t *bsp_board_get_description(void);
|
||||
|
||||
/**
|
||||
* @brief Get the codec operation function
|
||||
*
|
||||
* @return pointer of bsp_codec_config
|
||||
*/
|
||||
bsp_codec_config_t *bsp_board_get_codec_handle(void);
|
||||
|
||||
/**
|
||||
* @brief Call default button init code
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Success
|
||||
* - Others: Fail
|
||||
*/
|
||||
esp_err_t bsp_board_power_ctrl(power_module_t module, bool on);
|
||||
esp_err_t bsp_btn_init(void);
|
||||
|
||||
/**
|
||||
* @brief Register the button event callback function.
|
||||
*
|
||||
* @param btn A button handle to register
|
||||
* @param event Button event
|
||||
* @param callback Callback function.
|
||||
* @param user_data user data
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG Arguments is invalid.
|
||||
*/
|
||||
esp_err_t bsp_btn_register_callback(bsp_button_id_t btn, button_event_t event, button_cb_t callback, void *user_data);
|
||||
|
||||
/**
|
||||
* @brief Unregister the button event callback function.
|
||||
*
|
||||
* @param btn A button handle to unregister
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG Arguments is invalid.
|
||||
*/
|
||||
esp_err_t bsp_btn_rm_all_callback(bsp_button_id_t btn);
|
||||
|
||||
esp_err_t bsp_btn_rm_event_callback(bsp_button_id_t btn, size_t event);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
/**
|
||||
* @author your name (you@domain.com)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2021-07-20
|
||||
*
|
||||
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "audio_hal.h"
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Initialize Codec on dev board
|
||||
*
|
||||
* @param sample_rate
|
||||
* @return
|
||||
* - ESP_OK: Success
|
||||
* - ESP_ERR_NOT_FOUND: Codec not detected on I2C bus
|
||||
* - ESP_ERR_NOT_SUPPORTED: Unsupported Codec or t
|
||||
* - Others: Fail
|
||||
*/
|
||||
esp_err_t bsp_codec_init(audio_hal_iface_samples_t sample_rate);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -1,83 +0,0 @@
|
||||
/**
|
||||
* @file bsp_i2c.h
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2021-06-25
|
||||
*
|
||||
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "driver/i2c.h"
|
||||
#include "esp_err.h"
|
||||
#include "i2c_bus.h"
|
||||
|
||||
#ifndef I2C_ACK_CHECK_EN
|
||||
#define I2C_ACK_CHECK_EN 1
|
||||
#endif
|
||||
|
||||
#ifndef I2C_ACK_CHECK_DIS
|
||||
#define I2C_ACK_CHECK_DIS 0
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Initialize I2C bus of dev board
|
||||
*
|
||||
* @param i2c_num I2C port num
|
||||
* @param clk_speed I2C clock speed
|
||||
* @return
|
||||
* - ESP_OK: Success
|
||||
* - Others: Fail
|
||||
*/
|
||||
esp_err_t bsp_i2c_init(i2c_port_t i2c_num, uint32_t clk_speed);
|
||||
|
||||
/**
|
||||
* @brief Prob given address on I2C bus
|
||||
*
|
||||
* @param addr 7 bit Address to prob
|
||||
* @return
|
||||
* - ESP_OK: Device found on I2C bus
|
||||
* - ESP_ERR_INVALID_ARG: Invalid I2C address
|
||||
* - ESP_ERR_INVALID_STATE: I2C bus not initialized
|
||||
* - Others: Device not found on I2C bus or error occurred during I2C transmission
|
||||
*/
|
||||
esp_err_t bsp_i2c_probe_addr(uint8_t addr);
|
||||
|
||||
/**
|
||||
* @brief Add device to I2C bus
|
||||
*
|
||||
* @param i2c_device_handle Handle of I2C device
|
||||
* @param dev_addr 7 bit address of device
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - Others: Refer to error code `esp_err.h`.
|
||||
*/
|
||||
esp_err_t bsp_i2c_add_device(i2c_bus_device_handle_t *i2c_device_handle, uint8_t dev_addr);
|
||||
|
||||
/**
|
||||
* @brief Get handle of I2C bus
|
||||
*
|
||||
* @return Handle of i2c bus. NULL if not or failed initialized.
|
||||
*/
|
||||
i2c_bus_handle_t bsp_i2c_bus_get_handle(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -1,54 +0,0 @@
|
||||
/**
|
||||
* @file bsp_i2s.h
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2021-08-02
|
||||
*
|
||||
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "driver/i2s.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Init I2S bus
|
||||
*
|
||||
* @param i2s_num I2S port num
|
||||
* @param sample_rate Audio sample rate. For I2S signal, it refers to LRCK/WS frequency
|
||||
* @return
|
||||
* - ESP_OK: Success
|
||||
* - Others: Fail
|
||||
*/
|
||||
esp_err_t bsp_i2s_init(i2s_port_t i2s_num, uint32_t sample_rate);
|
||||
|
||||
/**
|
||||
* @brief Deinit I2S bus
|
||||
*
|
||||
* @param i2s_num I2S port num
|
||||
* @return
|
||||
* - ESP_OK: Success
|
||||
* - Others: Fail
|
||||
*/
|
||||
esp_err_t bsp_i2s_deinit(i2s_port_t i2s_num);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -1,114 +0,0 @@
|
||||
/**
|
||||
* @file bsp_lcd.h
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2021-07-05
|
||||
*
|
||||
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "bsp_board.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_lcd_panel_io.h"
|
||||
#include "esp_lcd_types.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef bool (*bsp_lcd_trans_cb_t)(esp_lcd_panel_io_handle_t, esp_lcd_panel_io_event_data_t *, void *);
|
||||
|
||||
/**
|
||||
* @brief Init LCD
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Success
|
||||
* - Others: Fail
|
||||
*/
|
||||
esp_err_t bsp_lcd_init(void);
|
||||
|
||||
/**
|
||||
* @brief Deinit LCD
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Success
|
||||
* - Others: Fail
|
||||
*/
|
||||
esp_err_t bsp_lcd_deinit(void);
|
||||
|
||||
/**
|
||||
* @brief Flush LCD
|
||||
*
|
||||
* @param x1 Start index on x-axis (x1 included)
|
||||
* @param y1 Start index on y-axis (y1 included)
|
||||
* @param x2 End index on x-axis (x2 not included)
|
||||
* @param y2 End index on y-axis (y2 not included)
|
||||
* @param p_data RGB color data that will be dumped to the specific range
|
||||
* @param ticks_to_wait Maximum blocking time
|
||||
* @return
|
||||
* - ESP_OK: Success
|
||||
* - ESP_ERR_TIMEOUT: Timeout waiting for previous transaction finished
|
||||
* - Others: Fail
|
||||
*/
|
||||
esp_err_t bsp_lcd_flush(int x1, int y1, int x2, int y2, const void *p_data, TickType_t ticks_to_wait);
|
||||
|
||||
/**
|
||||
* @brief Wait for a a single flush transaction finished
|
||||
*
|
||||
* @param ticks_to_wait Maximum blocking time
|
||||
* @return
|
||||
* - ESP_OK: Success
|
||||
* - Others: Fail
|
||||
*/
|
||||
esp_err_t bsp_lcd_flush_wait_done(TickType_t ticks_to_wait);
|
||||
|
||||
/**
|
||||
* @brief Set callback function when a single flush transaction is finished
|
||||
*
|
||||
* @param trans_done_cb Callback function
|
||||
* @param data User data
|
||||
* @return
|
||||
* - ESP_OK: Success
|
||||
* - Others: Fail
|
||||
*/
|
||||
esp_err_t bsp_lcd_set_cb(bool (*trans_done_cb)(void *), void *data);
|
||||
|
||||
/**
|
||||
* @brief Init LCD with SPI interface
|
||||
*
|
||||
* @param p_io_handle LCD panel IO handle
|
||||
* @param trans_done_cb callback function when a single flush transaction is finished
|
||||
* @return
|
||||
* - ESP_OK: Success
|
||||
* - Others: Fail
|
||||
*/
|
||||
esp_err_t bsp_spi_lcd_init(esp_lcd_panel_io_handle_t *p_io_handle, bsp_lcd_trans_cb_t trans_done_cb);
|
||||
|
||||
/**
|
||||
* @brief Deinit LCD with SPI interface
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Success
|
||||
* - Others: Fail
|
||||
*/
|
||||
esp_err_t bsp_spi_lcd_deinit(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -1,22 +1,7 @@
|
||||
/**
|
||||
* @file bsp_storage.h
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2021-07-06
|
||||
*
|
||||
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
@@ -30,7 +15,7 @@ extern "C" {
|
||||
|
||||
/**
|
||||
* @brief Init SD crad
|
||||
*
|
||||
*
|
||||
* @param mount_point Path where partition should be registered (e.g. "/sdcard")
|
||||
* @param max_files Maximum number of files which can be open at the same time
|
||||
* @return
|
||||
@@ -44,7 +29,7 @@ esp_err_t bsp_sdcard_init(char *mount_point, size_t max_files);
|
||||
|
||||
/**
|
||||
* @brief Init SD crad with default config
|
||||
*
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_STATE If esp_vfs_fat_register was already called
|
||||
@@ -56,9 +41,9 @@ esp_err_t bsp_sdcard_init_default(void);
|
||||
|
||||
/**
|
||||
* @brief Deinit SD card
|
||||
*
|
||||
*
|
||||
* @param mount_point Path where partition was registered (e.g. "/sdcard")
|
||||
* @return
|
||||
* @return
|
||||
* - ESP_OK: Success
|
||||
* - Others: Fail
|
||||
*/
|
||||
@@ -66,57 +51,13 @@ esp_err_t bsp_sdcard_deinit(char *mount_point);
|
||||
|
||||
/**
|
||||
* @brief Deinit SD card initialized by `bsp_sdcard_init_default`
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Success
|
||||
* - Others: Fail
|
||||
*/
|
||||
esp_err_t bsp_sdcard_deinit_default(void);
|
||||
|
||||
/**
|
||||
* @brief Init SPIFFS
|
||||
*
|
||||
* @param partition_label Label of the partition which should be used
|
||||
* @param mount_point Path where partition should be registered (e.g. "/sdcard")
|
||||
* @param max_files Maximum number of files which can be open at the same time
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_NO_MEM Objects could not be allocated
|
||||
* - ESP_ERR_INVALID_STATE Already mounted or partition is encrypted
|
||||
* - ESP_ERR_NOT_FOUND Partition for SPIFFS was not found
|
||||
* - ESP_FAIL Mount or format fails
|
||||
* - Others Fail
|
||||
*/
|
||||
esp_err_t bsp_spiffs_init(char *partition_label, char *mount_point, size_t max_files);
|
||||
|
||||
/**
|
||||
* @brief Init SPIFFS with default config
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Success
|
||||
* - Others: Fail
|
||||
*/
|
||||
esp_err_t bsp_spiffs_init_default(void);
|
||||
|
||||
/**
|
||||
* @brief Deinit SPIFFS
|
||||
*
|
||||
* @param partition_label Label of the partition which was used
|
||||
* @return
|
||||
* - ESP_OK: Success
|
||||
* - Others: Fail
|
||||
*/
|
||||
esp_err_t bsp_spiffs_deinit(char *partition_label);
|
||||
|
||||
/**
|
||||
* @brief Deinit SPIFFS initialized by `bsp_spiffs_init_default`
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Success
|
||||
* - Others: Fail
|
||||
*/
|
||||
esp_err_t bsp_spiffs_deinit_default(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
/**
|
||||
* @file bsp_tp.h
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2021-07-05
|
||||
*
|
||||
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "esp_err.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Init touch panel
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Success
|
||||
* - ESP_ERR_NOT_SUPPORTED: Unsupported touch panel
|
||||
* - Others: Fail
|
||||
*/
|
||||
esp_err_t bsp_tp_init(void);
|
||||
|
||||
/**
|
||||
* @brief Read data from touch panel
|
||||
*
|
||||
* @param tp_num Touch point number
|
||||
* @param x X coordinate
|
||||
* @param y Y coordinate
|
||||
* @param btn_val Button mask value
|
||||
* @return
|
||||
* - ESP_OK: Success
|
||||
* - Others: Fail
|
||||
*/
|
||||
esp_err_t bsp_tp_read(uint8_t *tp_num, uint16_t *x, uint16_t *y, uint8_t *btn_val);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,308 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "esp_log.h"
|
||||
#include "esp_check.h"
|
||||
|
||||
#include "bsp/esp-bsp.h"
|
||||
#include "bsp_board.h"
|
||||
#include "iot_button.h"
|
||||
|
||||
#define ES8311_SAMPLE_RATE (16000)
|
||||
#define ES8311_DEFAULT_VOLUME (60)
|
||||
|
||||
#define ES7210_SAMPLE_RATE (16000)
|
||||
#define ES7210_BIT_WIDTH (16)
|
||||
#define ES7210_ADC_VOLUME (24.0)
|
||||
#define ES7210_CHANNEL (2)
|
||||
|
||||
static uint8_t bsp_home_button_get(void *param);
|
||||
|
||||
static const pmod_pins_t g_pmod[2] = {
|
||||
{
|
||||
{BSP_PMOD2_IO5, BSP_PMOD2_IO6, BSP_PMOD2_IO7, BSP_PMOD2_IO8},
|
||||
{BSP_PMOD2_IO1, BSP_PMOD2_IO2, BSP_PMOD2_IO3, BSP_PMOD2_IO4},
|
||||
},
|
||||
{
|
||||
{BSP_PMOD1_IO5, BSP_PMOD1_IO6, BSP_PMOD1_IO7, BSP_PMOD1_IO8},
|
||||
{BSP_PMOD1_IO1, BSP_PMOD1_IO2, BSP_PMOD1_IO3, BSP_PMOD1_IO4},
|
||||
},
|
||||
};
|
||||
|
||||
static const board_res_desc_t g_board_s3_box_res = {
|
||||
|
||||
.FUNC_SDMMC_EN = (1),
|
||||
.SDMMC_BUS_WIDTH = (4),
|
||||
.GPIO_SDMMC_CLK = (BSP_PMOD2_IO3),
|
||||
.GPIO_SDMMC_CMD = (BSP_PMOD2_IO2),
|
||||
.GPIO_SDMMC_D0 = (BSP_PMOD2_IO8),
|
||||
.GPIO_SDMMC_D1 = (BSP_PMOD2_IO4),
|
||||
.GPIO_SDMMC_D2 = (BSP_PMOD2_IO1),
|
||||
.GPIO_SDMMC_D3 = (BSP_PMOD2_IO5),
|
||||
.GPIO_SDMMC_DET = (GPIO_NUM_NC),
|
||||
|
||||
.FUNC_SDSPI_EN = (0),
|
||||
.SDSPI_HOST = (SPI2_HOST),
|
||||
.GPIO_SDSPI_CS = (GPIO_NUM_NC),
|
||||
.GPIO_SDSPI_SCLK = (GPIO_NUM_NC),
|
||||
.GPIO_SDSPI_MISO = (GPIO_NUM_NC),
|
||||
.GPIO_SDSPI_MOSI = (GPIO_NUM_NC),
|
||||
|
||||
.FUNC_SPI_EN = (0),
|
||||
.GPIO_SPI_CS = (GPIO_NUM_NC),
|
||||
.GPIO_SPI_MISO = (GPIO_NUM_NC),
|
||||
.GPIO_SPI_MOSI = (GPIO_NUM_NC),
|
||||
.GPIO_SPI_SCLK = (GPIO_NUM_NC),
|
||||
|
||||
.FUNC_RMT_EN = (0),
|
||||
.GPIO_RMT_IR = (GPIO_NUM_NC),
|
||||
.GPIO_RMT_LED = (GPIO_NUM_39),
|
||||
|
||||
.PMOD1 = &g_pmod[0],
|
||||
.PMOD2 = &g_pmod[1],
|
||||
};
|
||||
|
||||
static const button_config_t BOARD_BTN_ID_config[BOARD_BTN_ID_NUM] = {
|
||||
{
|
||||
.type = BUTTON_TYPE_GPIO,
|
||||
.gpio_button_config.active_level = false,
|
||||
.gpio_button_config.gpio_num = BOARD_BTN_ID_BOOT,
|
||||
},
|
||||
{
|
||||
.type = BUTTON_TYPE_GPIO,
|
||||
.gpio_button_config.active_level = false,
|
||||
.gpio_button_config.gpio_num = BOARD_BTN_ID_MUTE,
|
||||
},
|
||||
{
|
||||
.type = BUTTON_TYPE_CUSTOM,
|
||||
.custom_button_config.priv = NULL,
|
||||
.custom_button_config.button_custom_get_key_value = bsp_home_button_get,
|
||||
.custom_button_config.active_level = true,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
static esp_codec_dev_handle_t play_dev_handle;
|
||||
static esp_codec_dev_handle_t record_dev_handle;
|
||||
|
||||
static button_handle_t *g_btn_handle = NULL;
|
||||
static bsp_codec_config_t g_codec_handle;
|
||||
|
||||
static const boards_info_t g_boards_info = {
|
||||
.id = BOARD_S3_BOX,
|
||||
.name = "S3_BOX",
|
||||
.board_desc = &g_board_s3_box_res
|
||||
};
|
||||
|
||||
static const char *TAG = "board";
|
||||
|
||||
static uint8_t bsp_home_button_get(void *param)
|
||||
{
|
||||
#if CONFIG_BSP_TOUCH_BUTTON
|
||||
return bsp_button_get(BSP_BUTTON_MAIN);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
esp_err_t bsp_btn_init(void)
|
||||
{
|
||||
ESP_ERROR_CHECK((NULL != g_btn_handle));
|
||||
|
||||
g_btn_handle = calloc(sizeof(button_handle_t), BOARD_BTN_ID_NUM);
|
||||
assert((g_btn_handle) && "memory is insufficient for button");
|
||||
|
||||
ESP_LOGI(TAG, "[+ Btn Init] ID");
|
||||
/* Init buttons */
|
||||
for (int i = 0; i < BOARD_BTN_ID_NUM; i++) {
|
||||
g_btn_handle[i] = iot_button_create(&BOARD_BTN_ID_config[i]);
|
||||
assert(g_btn_handle[i]);
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t bsp_btn_register_callback(bsp_button_id_t btn, button_event_t event, button_cb_t callback, void *user_data)
|
||||
{
|
||||
assert((g_btn_handle) && "button not initialized");
|
||||
assert((btn < BOARD_BTN_ID_NUM) && "button id incorrect");
|
||||
|
||||
ESP_LOGI(TAG, "[+ register] ID:%d, event:%d", btn, event);
|
||||
|
||||
if (NULL == callback) {
|
||||
return iot_button_unregister_cb(g_btn_handle[btn], event);
|
||||
}
|
||||
|
||||
return iot_button_register_cb(g_btn_handle[btn], event, callback, user_data);
|
||||
}
|
||||
|
||||
esp_err_t bsp_btn_rm_all_callback(bsp_button_id_t btn)
|
||||
{
|
||||
assert((g_btn_handle) && "button not initialized");
|
||||
assert((btn < BOARD_BTN_ID_NUM) && "button id incorrect");
|
||||
|
||||
ESP_LOGI(TAG, "[- register] ID:%d", btn);
|
||||
|
||||
for (size_t event = 0; event < BUTTON_EVENT_MAX; event++) {
|
||||
iot_button_unregister_cb(g_btn_handle[btn], event);
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t bsp_btn_rm_event_callback(bsp_button_id_t btn, size_t event)
|
||||
{
|
||||
assert((g_btn_handle) && "button not initialized");
|
||||
assert((btn < BOARD_BTN_ID_NUM) && "button id incorrect");
|
||||
|
||||
iot_button_unregister_cb(g_btn_handle[btn], event);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t bsp_i2s_read(void *audio_buffer, size_t len, size_t *bytes_read, uint32_t timeout_ms)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
ret = esp_codec_dev_read(record_dev_handle, audio_buffer, len);
|
||||
*bytes_read = len;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static esp_err_t bsp_i2s_write(void *audio_buffer, size_t len, size_t *bytes_written, uint32_t timeout_ms)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
ret = esp_codec_dev_write(play_dev_handle, audio_buffer, len);
|
||||
*bytes_written = len;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static esp_err_t bsp_codec_es8311_set(uint32_t rate, uint32_t bits_cfg, i2s_slot_mode_t ch)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
|
||||
esp_codec_dev_sample_info_t fs = {
|
||||
.sample_rate = rate,
|
||||
.channel = ch,
|
||||
.bits_per_sample = bits_cfg,
|
||||
};
|
||||
|
||||
ret = esp_codec_dev_close(play_dev_handle);
|
||||
ret = esp_codec_dev_close(record_dev_handle);
|
||||
|
||||
ret = esp_codec_dev_open(play_dev_handle, &fs);
|
||||
ret = esp_codec_dev_open(record_dev_handle, &fs);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static esp_err_t bsp_codec_volume_set(int volume, int *volume_set)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
float v = volume;
|
||||
ret = esp_codec_dev_set_out_vol(play_dev_handle, (int)v);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static esp_err_t bsp_codec_mute_set(bool enable)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
ret = esp_codec_dev_set_out_mute(play_dev_handle, enable);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static esp_err_t bsp_codec_es7210_set()
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
|
||||
esp_codec_dev_sample_info_t fs = {
|
||||
.sample_rate = ES7210_SAMPLE_RATE,
|
||||
.channel = ES7210_CHANNEL,
|
||||
.bits_per_sample = ES7210_BIT_WIDTH,
|
||||
};
|
||||
|
||||
assert(record_dev_handle);
|
||||
|
||||
if (play_dev_handle) {
|
||||
ret = esp_codec_dev_close(play_dev_handle);
|
||||
}
|
||||
|
||||
if (record_dev_handle) {
|
||||
ret = esp_codec_dev_close(record_dev_handle);
|
||||
}
|
||||
ret = esp_codec_dev_open(record_dev_handle, &fs);
|
||||
esp_codec_dev_set_in_gain(record_dev_handle, ES7210_ADC_VOLUME);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void bsp_codec_init()
|
||||
{
|
||||
play_dev_handle = bsp_audio_codec_speaker_init();
|
||||
assert((play_dev_handle) && "play_dev_handle not initialized");
|
||||
|
||||
record_dev_handle = bsp_audio_codec_microphone_init();
|
||||
assert((record_dev_handle) && "record_dev_handle not initialized");
|
||||
|
||||
bsp_codec_es7210_set();
|
||||
bsp_codec_es8311_set(ES7210_SAMPLE_RATE, ES7210_BIT_WIDTH, ES7210_CHANNEL);
|
||||
|
||||
bsp_codec_config_t *codec_config = bsp_board_get_codec_handle();
|
||||
codec_config->volume_set_fn = bsp_codec_volume_set;
|
||||
codec_config->mute_set_fn = bsp_codec_mute_set;
|
||||
codec_config->codec_reconfig_fn = bsp_codec_es7210_set;
|
||||
codec_config->i2s_read_fn = bsp_i2s_read;
|
||||
codec_config->i2s_write_fn = bsp_i2s_write;
|
||||
codec_config->i2s_reconfig_clk_fn = bsp_codec_es8311_set;
|
||||
}
|
||||
|
||||
__attribute__((weak)) void mute_btn_handler(void *handle, void *arg)
|
||||
{
|
||||
button_event_t event = (button_event_t)arg;
|
||||
|
||||
if (BUTTON_PRESS_DOWN == event) {
|
||||
esp_rom_printf(DRAM_STR("Mute On\r\n"));
|
||||
} else {
|
||||
esp_rom_printf(DRAM_STR("Mute Off\r\n"));
|
||||
}
|
||||
}
|
||||
|
||||
esp_err_t bsp_board_s3_box_init(void)
|
||||
{
|
||||
bsp_btn_init();
|
||||
bsp_btn_register_callback(BOARD_BTN_ID_MUTE, BUTTON_PRESS_DOWN, mute_btn_handler, (void *)BUTTON_PRESS_DOWN);
|
||||
bsp_btn_register_callback(BOARD_BTN_ID_MUTE, BUTTON_PRESS_UP, mute_btn_handler, (void *)BUTTON_PRESS_UP);
|
||||
|
||||
/**
|
||||
* @brief Initialize I2S and audio codec
|
||||
*
|
||||
* @note Actually the sampling rate can be reconfigured.
|
||||
* `MP3GetLastFrameInfo` can fill the `MP3FrameInfo`, which includes `samprate`.
|
||||
* So theoretically, the sampling rate can be dynamically changed according to the MP3 frame information.
|
||||
*/
|
||||
bsp_codec_init();
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
const boards_info_t *bsp_board_get_info(void)
|
||||
{
|
||||
return &g_boards_info;
|
||||
}
|
||||
|
||||
const board_res_desc_t *bsp_board_get_description(void)
|
||||
{
|
||||
return g_boards_info.board_desc;
|
||||
}
|
||||
|
||||
bsp_codec_config_t *bsp_board_get_codec_handle(void)
|
||||
{
|
||||
return &g_codec_handle;
|
||||
}
|
||||
|
||||
esp_err_t bsp_board_init(void)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
|
||||
ret |= bsp_board_s3_box_init();
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -0,0 +1,256 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "esp_log.h"
|
||||
#include "esp_check.h"
|
||||
|
||||
#include "bsp/esp-bsp.h"
|
||||
|
||||
#include "bsp_board.h"
|
||||
#include "iot_button.h"
|
||||
|
||||
#define es8156_SAMPLE_RATE (16000)
|
||||
#define es8156_DEFAULT_VOLUME (60)
|
||||
|
||||
#define ES7243_SAMPLE_RATE (16000)
|
||||
#define ES7243_BIT_WIDTH (16)
|
||||
#define ES7243_ADC_VOLUME (24.0)
|
||||
#define ES7243_CHANNEL (2)
|
||||
|
||||
static const pmod_pins_t g_pmod[2] = {
|
||||
{
|
||||
{BSP_PMOD2_IO5, BSP_PMOD2_IO6, BSP_PMOD2_IO7, BSP_PMOD2_IO8},
|
||||
{BSP_PMOD2_IO1, BSP_PMOD2_IO2, BSP_PMOD2_IO3, BSP_PMOD2_IO4},
|
||||
},
|
||||
{
|
||||
{BSP_PMOD1_IO5, BSP_PMOD1_IO6, BSP_PMOD1_IO7, BSP_PMOD1_IO8},
|
||||
{BSP_PMOD1_IO1, BSP_PMOD1_IO2, BSP_PMOD1_IO3, BSP_PMOD1_IO4},
|
||||
},
|
||||
};
|
||||
|
||||
static const board_res_desc_t g_board_s3_box_lite_res = {
|
||||
|
||||
.FUNC_SDMMC_EN = (1),
|
||||
.SDMMC_BUS_WIDTH = (4),
|
||||
.GPIO_SDMMC_CLK = (GPIO_NUM_13),
|
||||
.GPIO_SDMMC_CMD = (GPIO_NUM_11),
|
||||
.GPIO_SDMMC_D0 = (GPIO_NUM_14),
|
||||
.GPIO_SDMMC_D1 = (GPIO_NUM_12),
|
||||
.GPIO_SDMMC_D2 = (GPIO_NUM_10),
|
||||
.GPIO_SDMMC_D3 = (GPIO_NUM_9),
|
||||
.GPIO_SDMMC_DET = (GPIO_NUM_NC),
|
||||
|
||||
.FUNC_SDSPI_EN = (0),
|
||||
.SDSPI_HOST = (SPI2_HOST),
|
||||
.GPIO_SDSPI_CS = (GPIO_NUM_NC),
|
||||
.GPIO_SDSPI_SCLK = (GPIO_NUM_NC),
|
||||
.GPIO_SDSPI_MISO = (GPIO_NUM_NC),
|
||||
.GPIO_SDSPI_MOSI = (GPIO_NUM_NC),
|
||||
|
||||
.FUNC_SPI_EN = (0),
|
||||
.GPIO_SPI_CS = (GPIO_NUM_NC),
|
||||
.GPIO_SPI_MISO = (GPIO_NUM_NC),
|
||||
.GPIO_SPI_MOSI = (GPIO_NUM_NC),
|
||||
.GPIO_SPI_SCLK = (GPIO_NUM_NC),
|
||||
|
||||
.FUNC_RMT_EN = (0),
|
||||
.GPIO_RMT_IR = (GPIO_NUM_NC),
|
||||
.GPIO_RMT_LED = (GPIO_NUM_39),
|
||||
|
||||
.PMOD1 = &g_pmod[0],
|
||||
.PMOD2 = &g_pmod[1],
|
||||
};
|
||||
|
||||
|
||||
const button_config_t BOARD_BTN_ID_config[BOARD_BTN_ID_NUM] = {
|
||||
{
|
||||
.type = BUTTON_TYPE_GPIO,
|
||||
.gpio_button_config.active_level = false,
|
||||
.gpio_button_config.gpio_num = BOARD_BTN_ID_BOOT,
|
||||
},
|
||||
};
|
||||
|
||||
static esp_codec_dev_handle_t play_dev_handle;
|
||||
static esp_codec_dev_handle_t record_dev_handle;
|
||||
|
||||
static button_handle_t *g_btn_handle = NULL;
|
||||
static bsp_codec_config_t g_codec_handle;
|
||||
|
||||
static const boards_info_t g_boards_info = {
|
||||
.id = BOARD_S3_BOX_LITE,
|
||||
.name = "S3_BOX_LITE",
|
||||
.board_desc = &g_board_s3_box_lite_res
|
||||
};
|
||||
|
||||
static const char *TAG = "board";
|
||||
|
||||
esp_err_t bsp_btn_init(void)
|
||||
{
|
||||
ESP_ERROR_CHECK((NULL != g_btn_handle));
|
||||
|
||||
g_btn_handle = calloc(sizeof(button_handle_t), BOARD_BTN_ID_NUM);
|
||||
assert((g_btn_handle) && "memory is insufficient for button");
|
||||
|
||||
ESP_LOGI(TAG, "[+ Btn Init] ID");
|
||||
/* Init buttons */
|
||||
for (int i = 0; i < BOARD_BTN_ID_NUM; i++) {
|
||||
g_btn_handle[i] = iot_button_create(&BOARD_BTN_ID_config[i]);
|
||||
assert(g_btn_handle[i]);
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t bsp_btn_register_callback(bsp_button_id_t btn, button_event_t event, button_cb_t callback, void *user_data)
|
||||
{
|
||||
assert((g_btn_handle) && "button not initialized");
|
||||
assert((btn < BOARD_BTN_ID_NUM) && "button id incorrect");
|
||||
|
||||
ESP_LOGI(TAG, "[+ register] ID:%d, event:%d", btn, event);
|
||||
|
||||
if (NULL == callback) {
|
||||
return iot_button_unregister_cb(g_btn_handle[btn], event);
|
||||
}
|
||||
|
||||
return iot_button_register_cb(g_btn_handle[btn], event, callback, user_data);
|
||||
}
|
||||
|
||||
esp_err_t bsp_btn_rm_all_callback(bsp_button_id_t btn)
|
||||
{
|
||||
assert((g_btn_handle) && "button not initialized");
|
||||
assert((btn < BOARD_BTN_ID_NUM) && "button id incorrect");
|
||||
|
||||
ESP_LOGI(TAG, "[- register] ID:%d", btn);
|
||||
|
||||
for (size_t event = 0; event < BUTTON_EVENT_MAX; event++) {
|
||||
iot_button_unregister_cb(g_btn_handle[btn], event);
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t bsp_btn_rm_event_callback(bsp_button_id_t btn, size_t event)
|
||||
{
|
||||
assert((g_btn_handle) && "button not initialized");
|
||||
assert((btn < BOARD_BTN_ID_NUM) && "button id incorrect");
|
||||
|
||||
iot_button_unregister_cb(g_btn_handle[btn], event);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t bsp_i2s_read(void *audio_buffer, size_t len, size_t *bytes_read, uint32_t timeout_ms)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
ret = esp_codec_dev_read(record_dev_handle, audio_buffer, len);
|
||||
*bytes_read = len;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static esp_err_t bsp_i2s_write(void *audio_buffer, size_t len, size_t *bytes_written, uint32_t timeout_ms)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
ret = esp_codec_dev_write(play_dev_handle, audio_buffer, len);
|
||||
*bytes_written = len;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static esp_err_t bsp_codec_es8156_set(uint32_t rate, uint32_t bits_cfg, i2s_slot_mode_t ch)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
|
||||
esp_codec_dev_sample_info_t fs = {
|
||||
.sample_rate = rate,
|
||||
.channel = ch,
|
||||
.bits_per_sample = bits_cfg,
|
||||
};
|
||||
|
||||
ret = esp_codec_dev_close(play_dev_handle);
|
||||
ret = esp_codec_dev_close(record_dev_handle);
|
||||
|
||||
ret = esp_codec_dev_open(play_dev_handle, &fs);
|
||||
ret = esp_codec_dev_open(record_dev_handle, &fs);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static esp_err_t bsp_codec_volume_set(int volume, int *volume_set)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
float v = volume;
|
||||
ret = esp_codec_dev_set_out_vol(play_dev_handle, (int)v);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static esp_err_t bsp_codec_mute_set(bool enable)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
ret = esp_codec_dev_set_out_mute(play_dev_handle, enable);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static esp_err_t bsp_codec_es7243_set()
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
|
||||
esp_codec_dev_sample_info_t fs = {
|
||||
.sample_rate = ES7243_SAMPLE_RATE,
|
||||
.channel = ES7243_CHANNEL,
|
||||
.bits_per_sample = ES7243_BIT_WIDTH,
|
||||
};
|
||||
|
||||
assert(record_dev_handle);
|
||||
ret = esp_codec_dev_open(record_dev_handle, &fs);
|
||||
esp_codec_dev_set_in_gain(record_dev_handle, ES7243_ADC_VOLUME);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void bsp_codec_init()
|
||||
{
|
||||
play_dev_handle = bsp_audio_codec_speaker_init();
|
||||
assert((play_dev_handle) && "play_dev_handle not initialized");
|
||||
|
||||
record_dev_handle = bsp_audio_codec_microphone_init();
|
||||
assert((record_dev_handle) && "record_dev_handle not initialized");
|
||||
|
||||
bsp_codec_es7243_set();
|
||||
bsp_codec_es8156_set(ES7243_SAMPLE_RATE, ES7243_BIT_WIDTH, ES7243_CHANNEL);
|
||||
|
||||
bsp_codec_config_t *codec_config = bsp_board_get_codec_handle();
|
||||
codec_config->volume_set_fn = bsp_codec_volume_set;
|
||||
codec_config->mute_set_fn = bsp_codec_mute_set;
|
||||
codec_config->codec_reconfig_fn = bsp_codec_es7243_set;
|
||||
codec_config->i2s_read_fn = bsp_i2s_read;
|
||||
codec_config->i2s_write_fn = bsp_i2s_write;
|
||||
codec_config->i2s_reconfig_clk_fn = bsp_codec_es8156_set;
|
||||
}
|
||||
|
||||
esp_err_t bsp_board_s3_box_lite_init(void)
|
||||
{
|
||||
bsp_btn_init();
|
||||
bsp_codec_init();
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
const boards_info_t *bsp_board_get_info(void)
|
||||
{
|
||||
return &g_boards_info;
|
||||
}
|
||||
|
||||
const board_res_desc_t *bsp_board_get_description(void)
|
||||
{
|
||||
return g_boards_info.board_desc;
|
||||
}
|
||||
|
||||
bsp_codec_config_t *bsp_board_get_codec_handle(void)
|
||||
{
|
||||
return &g_codec_handle;
|
||||
}
|
||||
|
||||
esp_err_t bsp_board_init(void)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
|
||||
ret |= bsp_board_s3_box_lite_init();
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -1,143 +0,0 @@
|
||||
/**
|
||||
* @file bsp_codec.c
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2021-07-20
|
||||
*
|
||||
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "bsp_codec.h"
|
||||
#include "bsp_i2c.h"
|
||||
#include "es7210.h"
|
||||
#include "es8311.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
static const char *TAG = "codec";
|
||||
|
||||
typedef enum {
|
||||
CODEC_TYPE_ES7210 = 0,
|
||||
CODEC_TYPE_ES8311,
|
||||
CODEC_TYPE_ES8388,
|
||||
CODEC_TYPE_MAX,
|
||||
CODEC_TYPE_NONE = -1,
|
||||
} codec_type_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t dev_addr;
|
||||
char *dev_name;
|
||||
codec_type_t dev_type;
|
||||
} codec_dev_t;
|
||||
|
||||
static codec_dev_t codec_dev_list[] = {
|
||||
{ 0x40, "ES7210", CODEC_TYPE_ES7210 },
|
||||
{ 0x18, "ES8311", CODEC_TYPE_ES8311 },
|
||||
{ 0x20, "ES8388", CODEC_TYPE_ES8388 },
|
||||
};
|
||||
|
||||
static esp_err_t bsp_codec_prob(int *codec_type)
|
||||
{
|
||||
for (size_t i = 0; i < sizeof(codec_dev_list) / sizeof(codec_dev_list[0]); i++) {
|
||||
if (ESP_OK == bsp_i2c_probe_addr(codec_dev_list[i].dev_addr)) {
|
||||
*codec_type |= 1 << i;
|
||||
ESP_LOGI(TAG, "Detected codec at 0x%02X. Name : %s",
|
||||
codec_dev_list[i].dev_addr, codec_dev_list[i].dev_name);
|
||||
}
|
||||
}
|
||||
|
||||
if (0 == *codec_type) {
|
||||
*codec_type = CODEC_TYPE_NONE;
|
||||
ESP_LOGW(TAG, "Codec not detected");
|
||||
return ESP_ERR_NOT_FOUND;
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t bsp_codec_adc_init(audio_hal_iface_samples_t sample_rate)
|
||||
{
|
||||
esp_err_t ret_val = ESP_OK;
|
||||
audio_hal_codec_config_t cfg = {
|
||||
.codec_mode = AUDIO_HAL_CODEC_MODE_ENCODE,
|
||||
.adc_input = AUDIO_HAL_ADC_INPUT_ALL,
|
||||
.i2s_iface = {
|
||||
.bits = AUDIO_HAL_BIT_LENGTH_16BITS,
|
||||
.fmt = AUDIO_HAL_I2S_NORMAL,
|
||||
.mode = AUDIO_HAL_MODE_SLAVE,
|
||||
.samples = sample_rate,
|
||||
},
|
||||
};
|
||||
|
||||
ret_val |= es7210_adc_init(&cfg);
|
||||
ret_val |= es7210_adc_config_i2s(cfg.codec_mode, &cfg.i2s_iface);
|
||||
ret_val |= es7210_adc_set_gain(ES7210_INPUT_MIC1 | ES7210_INPUT_MIC2, GAIN_37_5DB);
|
||||
ret_val |= es7210_adc_set_gain(ES7210_INPUT_MIC3 | ES7210_INPUT_MIC4, GAIN_0DB);
|
||||
ret_val |= es7210_adc_ctrl_state(cfg.codec_mode, AUDIO_HAL_CTRL_START);
|
||||
|
||||
if (ESP_OK != ret_val) {
|
||||
ESP_LOGE(TAG, "Failed initialize codec");
|
||||
}
|
||||
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
esp_err_t bsp_codec_dac_init(audio_hal_iface_samples_t sample_rate)
|
||||
{
|
||||
esp_err_t ret_val = ESP_OK;
|
||||
audio_hal_codec_config_t cfg = {
|
||||
.codec_mode = AUDIO_HAL_CODEC_MODE_DECODE,
|
||||
.dac_output = AUDIO_HAL_DAC_OUTPUT_LINE1,
|
||||
.i2s_iface = {
|
||||
.bits = AUDIO_HAL_BIT_LENGTH_16BITS,
|
||||
.fmt = AUDIO_HAL_I2S_NORMAL,
|
||||
.mode = AUDIO_HAL_MODE_SLAVE,
|
||||
.samples = sample_rate,
|
||||
},
|
||||
};
|
||||
|
||||
ret_val |= es8311_codec_init(&cfg);
|
||||
ret_val |= es8311_set_bits_per_sample(cfg.i2s_iface.bits);
|
||||
ret_val |= es8311_config_fmt(cfg.i2s_iface.fmt);
|
||||
ret_val |= es8311_codec_set_voice_volume(60);
|
||||
ret_val |= es8311_codec_ctrl_state(cfg.codec_mode, AUDIO_HAL_CTRL_START);
|
||||
|
||||
if (ESP_OK != ret_val) {
|
||||
ESP_LOGE(TAG, "Failed initialize codec");
|
||||
}
|
||||
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
esp_err_t bsp_codec_init(audio_hal_iface_samples_t sample_rate)
|
||||
{
|
||||
esp_err_t ret_val = ESP_OK;
|
||||
|
||||
static int codec_type = 0;
|
||||
|
||||
ret_val |= bsp_codec_prob(&codec_type);
|
||||
|
||||
if(CODEC_TYPE_NONE == codec_type) {
|
||||
return ESP_ERR_NOT_FOUND;
|
||||
}
|
||||
|
||||
if (((1 << CODEC_TYPE_ES8311) + (1 << CODEC_TYPE_ES7210)) == codec_type) {
|
||||
ret_val |= bsp_codec_adc_init(sample_rate);
|
||||
ret_val |= bsp_codec_dac_init(sample_rate);
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
ESP_LOGW(TAG, "Currently not support");
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
/**
|
||||
* @file bsp_i2c.c
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2021-06-25
|
||||
*
|
||||
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "esp_log.h"
|
||||
#include "bsp_i2c.h"
|
||||
#include "bsp_board.h"
|
||||
#include "driver/i2c.h"
|
||||
|
||||
#define ACK_CHECK_EN 0x1 /*!< I2C master will check ack from slave*/
|
||||
|
||||
static const char *TAG= "bsp_i2c";
|
||||
static i2c_bus_handle_t i2c_bus_handle = NULL;
|
||||
|
||||
esp_err_t bsp_i2c_init(i2c_port_t i2c_num, uint32_t clk_speed)
|
||||
{
|
||||
/* Check if bus is already created */
|
||||
if (NULL != i2c_bus_handle) {
|
||||
ESP_LOGE(TAG, "I2C bus already initialized.");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
i2c_config_t conf = {
|
||||
.mode = I2C_MODE_MASTER,
|
||||
.scl_io_num = GPIO_I2C_SCL,
|
||||
.sda_io_num = GPIO_I2C_SDA,
|
||||
.scl_pullup_en = GPIO_PULLUP_ENABLE,
|
||||
.sda_pullup_en = GPIO_PULLUP_ENABLE,
|
||||
.master.clk_speed = clk_speed,
|
||||
};
|
||||
|
||||
i2c_bus_handle = i2c_bus_create(i2c_num, &conf);
|
||||
|
||||
if (NULL == i2c_bus_handle) {
|
||||
ESP_LOGE(TAG, "Failed create I2C bus");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t bsp_i2c_add_device(i2c_bus_device_handle_t *i2c_device_handle, uint8_t dev_addr)
|
||||
{
|
||||
if (NULL == i2c_bus_handle) {
|
||||
ESP_LOGE(TAG, "Failed create I2C device");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
*i2c_device_handle = i2c_bus_device_create(i2c_bus_handle, dev_addr, 400000);
|
||||
|
||||
if (NULL == i2c_device_handle) {
|
||||
ESP_LOGE(TAG, "Failed create I2C device");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t bsp_i2c_probe(void)
|
||||
{
|
||||
if (NULL == bsp_i2c_bus_get_handle()) {
|
||||
ESP_LOGE(TAG, "I2C bus not initialized");
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
i2c_bus_t *i2c_bus = (i2c_bus_t *) bsp_i2c_bus_get_handle();
|
||||
|
||||
for (size_t i = 1; i < 0x80; i++) {
|
||||
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
|
||||
i2c_master_start(cmd);
|
||||
i2c_master_write_byte(cmd, ( i << 1 ), ACK_CHECK_EN);
|
||||
i2c_master_stop(cmd);
|
||||
esp_err_t ret_val = i2c_master_cmd_begin(i2c_bus->i2c_port, cmd, pdMS_TO_TICKS(500));
|
||||
i2c_cmd_link_delete(cmd);
|
||||
if(ESP_OK == ret_val) {
|
||||
ESP_LOGW(TAG, "Found I2C Device at 0x%02X", i);
|
||||
}
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t bsp_i2c_probe_addr(uint8_t addr)
|
||||
{
|
||||
/* Use 7 bit address here */
|
||||
if (addr >= 0x80) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
/* Check if I2C bus initialized */
|
||||
if (NULL == bsp_i2c_bus_get_handle()) {
|
||||
ESP_LOGE(TAG, "I2C bus not initialized");
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
/* Get I2C bus object from i2c_bus_handle */
|
||||
i2c_bus_t *i2c_bus = (i2c_bus_t *) bsp_i2c_bus_get_handle();
|
||||
|
||||
/* Create probe cmd link */
|
||||
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
|
||||
i2c_master_start(cmd);
|
||||
i2c_master_write_byte(cmd, ( addr << 1 ), ACK_CHECK_EN);
|
||||
i2c_master_stop(cmd);
|
||||
|
||||
/* Start probe cmd link */
|
||||
esp_err_t ret_val = i2c_master_cmd_begin(i2c_bus->i2c_port, cmd, pdMS_TO_TICKS(500));
|
||||
|
||||
/* Delete cmd link after probe ends */
|
||||
i2c_cmd_link_delete(cmd);
|
||||
|
||||
/* Get probe result if ESP_OK equals to ret_val */
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
i2c_bus_handle_t bsp_i2c_bus_get_handle(void)
|
||||
{
|
||||
return i2c_bus_handle;
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
/**
|
||||
* @file bsp_i2s.c
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2021-07-23
|
||||
*
|
||||
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "bsp_board.h"
|
||||
#include "bsp_i2s.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "driver/i2s.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_log.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
|
||||
/* Required for I2S driver workaround */
|
||||
#include "esp_rom_gpio.h"
|
||||
#include "hal/gpio_hal.h"
|
||||
#include "hal/i2s_ll.h"
|
||||
|
||||
#define I2S_CONFIG_DEFAULT() { \
|
||||
.mode = I2S_MODE_MASTER | I2S_MODE_TX | I2S_MODE_RX, \
|
||||
.sample_rate = sample_rate, \
|
||||
.bits_per_sample = I2S_BITS_PER_SAMPLE_32BIT, \
|
||||
.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT, \
|
||||
.communication_format = I2S_COMM_FORMAT_STAND_I2S, \
|
||||
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1, \
|
||||
.dma_buf_count = 6, \
|
||||
.dma_buf_len = 160, \
|
||||
.use_apll = false, \
|
||||
.tx_desc_auto_clear = true, \
|
||||
.fixed_mclk = 0, \
|
||||
.mclk_multiple = I2S_MCLK_MULTIPLE_DEFAULT, \
|
||||
.bits_per_chan = I2S_BITS_PER_CHAN_32BIT, \
|
||||
}
|
||||
|
||||
esp_err_t bsp_i2s_init(i2s_port_t i2s_num, uint32_t sample_rate)
|
||||
{
|
||||
esp_err_t ret_val = ESP_OK;
|
||||
|
||||
i2s_config_t i2s_config = I2S_CONFIG_DEFAULT();
|
||||
|
||||
i2s_pin_config_t pin_config = {
|
||||
.bck_io_num = GPIO_I2S_SCLK,
|
||||
.ws_io_num = GPIO_I2S_LRCK,
|
||||
.data_out_num = GPIO_I2S_DOUT,
|
||||
.data_in_num = GPIO_I2S_SDIN,
|
||||
.mck_io_num = GPIO_I2S_MCLK,
|
||||
};
|
||||
|
||||
ret_val |= i2s_driver_install(i2s_num, &i2s_config, 0, NULL);
|
||||
ret_val |= i2s_set_pin(i2s_num, &pin_config);
|
||||
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
esp_err_t bsp_i2s_deinit(i2s_port_t i2s_num)
|
||||
{
|
||||
esp_err_t ret_val = ESP_OK;
|
||||
|
||||
ret_val |= i2s_stop(I2S_NUM_0);
|
||||
ret_val |= i2s_driver_uninstall(i2s_num);
|
||||
|
||||
return ret_val;
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
/**
|
||||
* @file bsp_tp.c
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2021-07-05
|
||||
*
|
||||
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "bsp_i2c.h"
|
||||
#include "bsp_board.h"
|
||||
#include "bsp_tp.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_err.h"
|
||||
|
||||
#include "ft5x06.h"
|
||||
#include "tt21100.h"
|
||||
|
||||
static const char *TAG = "bsp_tp";
|
||||
typedef enum {
|
||||
TP_VENDOR_NONE = -1,
|
||||
TP_VENDOR_TT = 0,
|
||||
TP_VENDOR_FT,
|
||||
TP_VENDOR_MAX,
|
||||
} tp_vendor_t;
|
||||
|
||||
typedef struct {
|
||||
char *dev_name;
|
||||
uint8_t dev_addr;
|
||||
tp_vendor_t dev_vendor;
|
||||
} tp_dev_t;
|
||||
|
||||
static tp_dev_t tp_dev_list[] = {
|
||||
{ "Parade Tech", 0x24, TP_VENDOR_TT },
|
||||
{ "Focal Tech", 0x38, TP_VENDOR_FT },
|
||||
};
|
||||
|
||||
static tp_vendor_t tp_vendor = TP_VENDOR_NONE;
|
||||
|
||||
static esp_err_t bsp_tp_prob(tp_vendor_t *p_tp_vendor)
|
||||
{
|
||||
for (size_t i = 0; i < sizeof(tp_dev_list) / sizeof(tp_dev_list[0]); i++) {
|
||||
if (ESP_OK == bsp_i2c_probe_addr(tp_dev_list[i].dev_addr)) {
|
||||
*p_tp_vendor = (tp_vendor_t) i;
|
||||
ESP_LOGI(TAG, "Detected touch panel at 0x%02X. Vendor : %s",
|
||||
tp_dev_list[i].dev_addr, tp_dev_list[i].dev_name);
|
||||
return ESP_OK;
|
||||
}
|
||||
}
|
||||
|
||||
*p_tp_vendor = TP_VENDOR_NONE;
|
||||
ESP_LOGW(TAG, "Touch panel not detected");
|
||||
return ESP_ERR_NOT_FOUND;
|
||||
}
|
||||
|
||||
esp_err_t bsp_tp_init(void)
|
||||
{
|
||||
esp_err_t ret_val = ESP_OK;
|
||||
|
||||
ret_val |= bsp_tp_prob(&tp_vendor);
|
||||
|
||||
switch (tp_vendor) {
|
||||
case TP_VENDOR_TT:
|
||||
ret_val |= tt21100_tp_init();
|
||||
break;
|
||||
case TP_VENDOR_FT:
|
||||
ret_val |= ft5x06_init();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
esp_err_t bsp_tp_read(uint8_t *tp_num, uint16_t *x, uint16_t *y, uint8_t *btn_val)
|
||||
{
|
||||
esp_err_t ret_val = ESP_OK;
|
||||
uint16_t btn_signal = 0;
|
||||
|
||||
switch (tp_vendor) {
|
||||
case TP_VENDOR_TT:
|
||||
do {
|
||||
ret_val |= tt21100_tp_read();
|
||||
} while (tt21100_data_avaliable());
|
||||
|
||||
ret_val |= tt21100_get_touch_point(tp_num, x, y);
|
||||
ret_val |= tt21100_get_btn_val(btn_val, &btn_signal);
|
||||
break;
|
||||
case TP_VENDOR_FT:
|
||||
ret_val |= ft5x06_read_pos(tp_num, x, y);
|
||||
break;
|
||||
default:
|
||||
return ESP_ERR_NOT_FOUND;
|
||||
break;
|
||||
}
|
||||
|
||||
#if TOUCH_PANEL_SWAP_XY
|
||||
uint16_t swap = *x;
|
||||
*x = *y;
|
||||
*y = swap;
|
||||
#endif
|
||||
|
||||
#if TOUCH_PANEL_INVERSE_X
|
||||
*x = LCD_WIDTH - ( *x + 1);
|
||||
#endif
|
||||
|
||||
#if TOUCH_PANEL_INVERSE_Y
|
||||
*y = LCD_HEIGHT - (*y + 1);
|
||||
#endif
|
||||
|
||||
ESP_LOGD(TAG, "[%3u, %3u]", *x, *y);
|
||||
|
||||
return ret_val;
|
||||
}
|
||||
@@ -1,174 +0,0 @@
|
||||
/**
|
||||
* @file bsp_lcd.c
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2021-06-25
|
||||
*
|
||||
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "bsp_lcd.h"
|
||||
#include "bsp_board.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "driver/spi_master.h"
|
||||
#include "esp_compiler.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_lcd_panel_io.h"
|
||||
#include "esp_lcd_panel_vendor.h"
|
||||
#include "esp_lcd_panel_ops.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "freertos/task.h"
|
||||
#include "soc/soc_memory_layout.h"
|
||||
|
||||
static const char *TAG = "bsp_lcd";
|
||||
|
||||
static esp_lcd_panel_io_handle_t io_handle = NULL;
|
||||
static esp_lcd_panel_handle_t panel_handle = NULL;
|
||||
|
||||
static void *p_user_data = NULL;
|
||||
static bool (*p_on_trans_done_cb)(void *) = NULL;
|
||||
static SemaphoreHandle_t bsp_lcd_flush_done_sem = NULL;
|
||||
static bool lcd_trans_done_cb(esp_lcd_panel_io_handle_t, esp_lcd_panel_io_event_data_t *, void *);
|
||||
|
||||
esp_err_t bsp_lcd_init(void)
|
||||
{
|
||||
|
||||
bsp_spi_lcd_init(&io_handle, lcd_trans_done_cb);
|
||||
|
||||
esp_lcd_panel_dev_config_t panel_config = {
|
||||
.reset_gpio_num = GPIO_LCD_RST,
|
||||
.color_space = ESP_LCD_COLOR_SPACE_BGR,
|
||||
.bits_per_pixel = 16,
|
||||
};
|
||||
|
||||
#if LCD_DISP_IC_NT
|
||||
ESP_ERROR_CHECK(esp_lcd_new_panel_nt35510(io_handle, &panel_config, &panel_handle));
|
||||
#elif LCD_DISP_IC_ST
|
||||
ESP_ERROR_CHECK(esp_lcd_new_panel_st7789(io_handle, &panel_config, &panel_handle));
|
||||
#else
|
||||
#error "Invalid LCD type"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Configure LCD rotation and mirror
|
||||
*
|
||||
*/
|
||||
esp_err_t ret_val = ESP_OK;
|
||||
ret_val |= esp_lcd_panel_reset(panel_handle);
|
||||
ret_val |= esp_lcd_panel_init(panel_handle);
|
||||
ret_val |= esp_lcd_panel_invert_color(panel_handle, LCD_COLOR_INV);
|
||||
ret_val |= esp_lcd_panel_set_gap(panel_handle, 0, 0);
|
||||
ret_val |= esp_lcd_panel_swap_xy(panel_handle, LCD_SWAP_XY);
|
||||
ret_val |= esp_lcd_panel_mirror(panel_handle, LCD_MIRROR_X, LCD_MIRROR_Y);
|
||||
|
||||
/**
|
||||
* @brief Configure LCD backlight IO.
|
||||
*
|
||||
*/
|
||||
if (GPIO_NUM_NC != GPIO_LCD_BL) {
|
||||
gpio_config_t bk_gpio_config = {
|
||||
.mode = GPIO_MODE_OUTPUT,
|
||||
/*!< Prevent left shift negtive value warning */
|
||||
.pin_bit_mask = GPIO_LCD_BL > 0 ? 1ULL << GPIO_LCD_BL : 0ULL,
|
||||
};
|
||||
gpio_config(&bk_gpio_config);
|
||||
gpio_set_level(GPIO_LCD_BL, GPIO_LCD_BL_ON);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Create mutex to receive LCD flush event.
|
||||
*
|
||||
*/
|
||||
if (NULL != bsp_lcd_flush_done_sem) {
|
||||
ESP_LOGE(TAG, "LCD already initialized");
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
bsp_lcd_flush_done_sem = xSemaphoreCreateBinary();
|
||||
|
||||
if (NULL == bsp_lcd_flush_done_sem) {
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
/* If any function is checking LCD trans status before transmition */
|
||||
xSemaphoreGive(bsp_lcd_flush_done_sem);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t bsp_lcd_deinit(void)
|
||||
{
|
||||
esp_err_t ret_val = ESP_OK;
|
||||
|
||||
ret_val |= esp_lcd_panel_del(panel_handle);
|
||||
ret_val |= esp_lcd_panel_io_del(io_handle);
|
||||
ret_val |= bsp_spi_lcd_deinit();
|
||||
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
esp_err_t bsp_lcd_flush(int x1, int y1, int x2, int y2, const void *p_data, TickType_t ticks_to_wait)
|
||||
{
|
||||
/* Wait for previous tansmition done */
|
||||
if (pdPASS != xSemaphoreTake(bsp_lcd_flush_done_sem, ticks_to_wait)) {
|
||||
return ESP_ERR_TIMEOUT;
|
||||
}
|
||||
|
||||
return esp_lcd_panel_draw_bitmap(panel_handle, x1, y1, x2, y2, p_data);
|
||||
}
|
||||
|
||||
esp_err_t bsp_lcd_flush_wait_done(TickType_t ticks_to_wait)
|
||||
{
|
||||
if (pdPASS != xSemaphoreTake(bsp_lcd_flush_done_sem, ticks_to_wait)) {
|
||||
return ESP_ERR_TIMEOUT;
|
||||
}
|
||||
|
||||
xSemaphoreGive(bsp_lcd_flush_done_sem);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t bsp_lcd_set_cb(bool (*trans_done_cb)(void *), void *data)
|
||||
{
|
||||
if (esp_ptr_executable(trans_done_cb)) {
|
||||
p_on_trans_done_cb = trans_done_cb;
|
||||
p_user_data = data;
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Invalid function pointer");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static bool lcd_trans_done_cb(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_io_event_data_t *user_data, void *event_data)
|
||||
{
|
||||
(void) panel_io;
|
||||
(void) user_data;
|
||||
(void) event_data;
|
||||
|
||||
/* Used for `bsp_lcd_flush_wait` */
|
||||
if (likely(NULL != bsp_lcd_flush_done_sem)) {
|
||||
xSemaphoreGive(bsp_lcd_flush_done_sem);
|
||||
}
|
||||
|
||||
/* Call user registered function */
|
||||
if (NULL != p_on_trans_done_cb) {
|
||||
return p_on_trans_done_cb(p_user_data);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -1,114 +0,0 @@
|
||||
/**
|
||||
* @file bsp_lcd_spi.c
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2021-08-25
|
||||
*
|
||||
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#include "bsp_lcd.h"
|
||||
#include "bsp_board.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "driver/spi_master.h"
|
||||
#include "esp_compiler.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_lcd_panel_io.h"
|
||||
#include "esp_lcd_panel_vendor.h"
|
||||
#include "esp_lcd_panel_ops.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "freertos/task.h"
|
||||
#include "soc/soc_memory_layout.h"
|
||||
|
||||
static const char *TAG = "bsp_lcd_spi";
|
||||
|
||||
esp_err_t bsp_spi_lcd_init(esp_lcd_panel_io_handle_t *p_io_handle, bsp_lcd_trans_cb_t trans_done_cb)
|
||||
{
|
||||
esp_err_t ret_val = ESP_OK;
|
||||
|
||||
if (NULL == p_io_handle) {
|
||||
ESP_LOGE(TAG, "Invalid LCD IO handle");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
spi_bus_config_t buscfg = {
|
||||
.sclk_io_num = GPIO_LCD_CLK,
|
||||
#if (LCD_BUS_WIDTH == 1)
|
||||
.mosi_io_num = GPIO_LCD_DIN,
|
||||
.miso_io_num = GPIO_NUM_NC,
|
||||
.quadwp_io_num = GPIO_NUM_NC,
|
||||
.quadhd_io_num = GPIO_NUM_NC,
|
||||
#elif (LCD_BUS_WIDTH == 8)
|
||||
.data0_io_num = GPIO_LCD_D00,
|
||||
.data1_io_num = GPIO_LCD_D01,
|
||||
.data2_io_num = GPIO_LCD_D02,
|
||||
.data3_io_num = GPIO_LCD_D03,
|
||||
.data4_io_num = GPIO_LCD_D04,
|
||||
.data5_io_num = GPIO_LCD_D05,
|
||||
.data6_io_num = GPIO_LCD_D06,
|
||||
.data7_io_num = GPIO_LCD_D07,
|
||||
.flags = SPICOMMON_BUSFLAG_OCTAL,
|
||||
#endif
|
||||
.max_transfer_sz = LCD_WIDTH * LCD_HEIGHT * sizeof(uint16_t)
|
||||
};
|
||||
|
||||
|
||||
ret_val |= spi_bus_initialize(LCD_HOST, &buscfg, SPI_DMA_CH_AUTO);
|
||||
|
||||
esp_lcd_panel_io_spi_config_t io_config = {
|
||||
.dc_gpio_num = GPIO_LCD_DC,
|
||||
.cs_gpio_num = GPIO_LCD_CS,
|
||||
.pclk_hz = LCD_FREQ,
|
||||
.spi_mode = 0,
|
||||
.trans_queue_depth = 10,
|
||||
.lcd_cmd_bits =
|
||||
#if LCD_DISP_IC_NT
|
||||
16,
|
||||
#elif LCD_DISP_IC_ST
|
||||
8,
|
||||
#else
|
||||
8, /* TBD */
|
||||
#endif
|
||||
.lcd_param_bits =
|
||||
#if LCD_DISP_IC_NT
|
||||
16,
|
||||
#elif LCD_DISP_IC_ST
|
||||
8,
|
||||
#else
|
||||
8, /* TBD */
|
||||
#endif
|
||||
.on_color_trans_done = trans_done_cb,
|
||||
.user_ctx = NULL,
|
||||
};
|
||||
|
||||
#if (LCD_BUS_WIDTH == 8)
|
||||
io_config.flags.octal_mode = 1;
|
||||
io_config.spi_mode = 3;
|
||||
#endif
|
||||
ret_val |= esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t) LCD_HOST, &io_config, p_io_handle);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t bsp_spi_lcd_deinit(void)
|
||||
{
|
||||
esp_err_t ret_val = ESP_OK;
|
||||
|
||||
ret_val |= spi_bus_free(LCD_HOST);
|
||||
|
||||
return ret_val;
|
||||
}
|
||||
@@ -1,25 +1,11 @@
|
||||
/**
|
||||
* @file sdmmc_private.c
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2021-11-04
|
||||
*
|
||||
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "bsp_board.h"
|
||||
#include "esp_err.h"
|
||||
@@ -27,9 +13,9 @@
|
||||
#include "esp_vfs_fat.h"
|
||||
#include "sdmmc_cmd.h"
|
||||
|
||||
#if ((SOC_SDMMC_HOST_SUPPORTED) && (FUNC_SDMMC_EN))
|
||||
#if (SOC_SDMMC_HOST_SUPPORTED)
|
||||
#include "driver/sdmmc_host.h"
|
||||
#endif /* ((SOC_SDMMC_HOST_SUPPORTED) && (FUNC_SDMMC_EN)) */
|
||||
#endif
|
||||
|
||||
#define DEFAULT_FD_NUM 2
|
||||
#define DEFAULT_MOUNT_POINT "/sdcard"
|
||||
@@ -42,123 +28,111 @@ esp_err_t bsp_sdcard_init(char *mount_point, size_t max_files)
|
||||
if (NULL != card) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
const board_res_desc_t *brd = bsp_board_get_description();
|
||||
|
||||
/* Check if SD crad is supported */
|
||||
if (!FUNC_SDMMC_EN && !FUNC_SDSPI_EN) {
|
||||
ESP_LOGE(TAG, "SDMMC and SDSPI not supported on this board!");
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
if (!brd->FUNC_SDMMC_EN && !brd->FUNC_SDSPI_EN) {
|
||||
ESP_LOGE(TAG, "SDMMC and SDSPI not supported on this board!");
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
esp_err_t ret_val = ESP_OK;
|
||||
|
||||
/**
|
||||
* @brief Options for mounting the filesystem.
|
||||
* If format_if_mount_failed is set to true, SD card will be partitioned and
|
||||
* formatted in case when mounting fails.
|
||||
*
|
||||
*/
|
||||
esp_vfs_fat_sdmmc_mount_config_t mount_config = {
|
||||
/**
|
||||
* @brief Options for mounting the filesystem.
|
||||
* If format_if_mount_failed is set to true, SD card will be partitioned and
|
||||
* formatted in case when mounting fails.
|
||||
*
|
||||
*/
|
||||
esp_vfs_fat_sdmmc_mount_config_t mount_config = {
|
||||
.format_if_mount_failed = false,
|
||||
.max_files = max_files,
|
||||
.allocation_unit_size = 16 * 1024
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Use settings defined above to initialize SD card and mount FAT filesystem.
|
||||
* Note: esp_vfs_fat_sdmmc/sdspi_mount is all-in-one convenience functions.
|
||||
* Please check its source code and implement error recovery when developing
|
||||
* production applications.
|
||||
*
|
||||
*/
|
||||
sdmmc_host_t host =
|
||||
#if FUNC_SDMMC_EN
|
||||
SDMMC_HOST_DEFAULT();
|
||||
#else
|
||||
SDSPI_HOST_DEFAULT();
|
||||
spi_bus_config_t bus_cfg = {
|
||||
.mosi_io_num = GPIO_SDSPI_MOSI,
|
||||
.miso_io_num = GPIO_SDSPI_MISO,
|
||||
.sclk_io_num = GPIO_SDSPI_SCLK,
|
||||
.quadwp_io_num = GPIO_NUM_NC,
|
||||
.quadhd_io_num = GPIO_NUM_NC,
|
||||
.max_transfer_sz = 4000,
|
||||
};
|
||||
ret_val = spi_bus_initialize(host.slot, &bus_cfg, SPI_DMA_CH_AUTO);
|
||||
if (ret_val != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to initialize bus.");
|
||||
return ret_val;
|
||||
/**
|
||||
* @brief Use settings defined above to initialize SD card and mount FAT filesystem.
|
||||
* Note: esp_vfs_fat_sdmmc/sdspi_mount is all-in-one convenience functions.
|
||||
* Please check its source code and implement error recovery when developing
|
||||
* production applications.
|
||||
*
|
||||
*/
|
||||
sdmmc_host_t host = {0};
|
||||
if (brd->FUNC_SDMMC_EN) {
|
||||
sdmmc_host_t h = SDMMC_HOST_DEFAULT();
|
||||
memcpy(&host, &h, sizeof(sdmmc_host_t));
|
||||
} else {
|
||||
sdmmc_host_t h = SDSPI_HOST_DEFAULT();
|
||||
memcpy(&host, &h, sizeof(sdmmc_host_t));
|
||||
spi_bus_config_t bus_cfg = {
|
||||
.mosi_io_num = brd->GPIO_SDSPI_MOSI,
|
||||
.miso_io_num = brd->GPIO_SDSPI_MISO,
|
||||
.sclk_io_num = brd->GPIO_SDSPI_SCLK,
|
||||
.quadwp_io_num = GPIO_NUM_NC,
|
||||
.quadhd_io_num = GPIO_NUM_NC,
|
||||
.max_transfer_sz = 4000,
|
||||
};
|
||||
ret_val = spi_bus_initialize(host.slot, &bus_cfg, SPI_DMA_CH_AUTO);
|
||||
if (ret_val != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to initialize bus.");
|
||||
return ret_val;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief This initializes the slot without card detect (CD) and write protect (WP) signals.
|
||||
* Modify slot_config.gpio_cd and slot_config.gpio_wp if your board has these signals.
|
||||
*
|
||||
*/
|
||||
#if FUNC_SDMMC_EN
|
||||
sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT();
|
||||
#else
|
||||
sdspi_device_config_t slot_config = SDSPI_DEVICE_CONFIG_DEFAULT();
|
||||
#endif
|
||||
/**
|
||||
* @brief This initializes the slot without card detect (CD) and write protect (WP) signals.
|
||||
* Modify slot_config.gpio_cd and slot_config.gpio_wp if your board has these signals.
|
||||
*
|
||||
*/
|
||||
if (brd->FUNC_SDMMC_EN) {
|
||||
sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT();
|
||||
/* Config SD data width. 0, 4 or 8. Currently for SD card, 8 bit is not supported. */
|
||||
slot_config.width = brd->SDMMC_BUS_WIDTH;
|
||||
|
||||
#if FUNC_SDMMC_EN
|
||||
/* Config SD data width. 0, 4 or 8. Currently for SD card, 8 bit is not supported. */
|
||||
slot_config.width = SDMMC_BUS_WIDTH;
|
||||
|
||||
/**
|
||||
* @brief On chips where the GPIOs used for SD card can be configured, set them in
|
||||
* the slot_config structure.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* @brief On chips where the GPIOs used for SD card can be configured, set them in
|
||||
* the slot_config structure.
|
||||
*
|
||||
*/
|
||||
#if SOC_SDMMC_USE_GPIO_MATRIX
|
||||
slot_config.clk = GPIO_SDMMC_CLK;
|
||||
slot_config.cmd = GPIO_SDMMC_CMD;
|
||||
slot_config.d0 = GPIO_SDMMC_D0;
|
||||
slot_config.d1 = GPIO_SDMMC_D1;
|
||||
slot_config.d2 = GPIO_SDMMC_D2;
|
||||
slot_config.d3 = GPIO_SDMMC_D3;
|
||||
slot_config.clk = brd->GPIO_SDMMC_CLK;
|
||||
slot_config.cmd = brd->GPIO_SDMMC_CMD;
|
||||
slot_config.d0 = brd->GPIO_SDMMC_D0;
|
||||
slot_config.d1 = brd->GPIO_SDMMC_D1;
|
||||
slot_config.d2 = brd->GPIO_SDMMC_D2;
|
||||
slot_config.d3 = brd->GPIO_SDMMC_D3;
|
||||
#endif
|
||||
slot_config.cd = GPIO_SDMMC_DET;
|
||||
slot_config.flags |= SDMMC_SLOT_FLAG_INTERNAL_PULLUP;
|
||||
#else
|
||||
slot_config.gpio_cs = GPIO_SDSPI_CS;
|
||||
slot_config.host_id = host.slot;
|
||||
#endif
|
||||
/**
|
||||
* @brief Enable internal pullups on enabled pins. The internal pullups
|
||||
* are insufficient however, please make sure 10k external pullups are
|
||||
* connected on the bus. This is for debug / example purpose only.
|
||||
*/
|
||||
slot_config.cd = brd->GPIO_SDMMC_DET;
|
||||
slot_config.flags |= SDMMC_SLOT_FLAG_INTERNAL_PULLUP;
|
||||
ret_val = esp_vfs_fat_sdmmc_mount(mount_point, &host, &slot_config, &mount_config, &card);
|
||||
} else {
|
||||
sdspi_device_config_t slot_config = SDSPI_DEVICE_CONFIG_DEFAULT();
|
||||
slot_config.gpio_cs = brd->GPIO_SDSPI_CS;
|
||||
slot_config.host_id = host.slot;
|
||||
ret_val = esp_vfs_fat_sdspi_mount(mount_point, &host, &slot_config, &mount_config, &card);
|
||||
}
|
||||
|
||||
/* get FAT filesystem on SD card registered in VFS. */
|
||||
ret_val =
|
||||
#if FUNC_SDMMC_EN
|
||||
esp_vfs_fat_sdmmc_mount(mount_point, &host, &slot_config, &mount_config, &card);
|
||||
#else
|
||||
esp_vfs_fat_sdspi_mount(mount_point, &host, &slot_config, &mount_config, &card);
|
||||
#endif
|
||||
|
||||
/* Check for SDMMC mount result. */
|
||||
/* Check for SDMMC mount result. */
|
||||
if (ret_val != ESP_OK) {
|
||||
if (ret_val == ESP_FAIL) {
|
||||
ESP_LOGE(TAG, "Failed to mount filesystem. "
|
||||
"If you want the card to be formatted, set the EXAMPLE_FORMAT_IF_MOUNT_FAILED menuconfig option.");
|
||||
"If you want the card to be formatted, set the EXAMPLE_FORMAT_IF_MOUNT_FAILED menuconfig option.");
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Failed to initialize the card (%s). "
|
||||
"Make sure SD card lines have pull-up resistors in place.", esp_err_to_name(ret_val));
|
||||
"Make sure SD card lines have pull-up resistors in place.", esp_err_to_name(ret_val));
|
||||
}
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
/* Card has been initialized, print its properties. */
|
||||
sdmmc_card_print_info(stdout, card);
|
||||
|
||||
return ret_val;
|
||||
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
esp_err_t bsp_sdcard_init_default(void)
|
||||
{
|
||||
return bsp_sdcard_init(DEFAULT_MOUNT_POINT, DEFAULT_FD_NUM);
|
||||
return bsp_sdcard_init(DEFAULT_MOUNT_POINT, DEFAULT_FD_NUM);
|
||||
}
|
||||
|
||||
esp_err_t bsp_sdcard_deinit(char *mount_point)
|
||||
@@ -173,7 +147,7 @@ esp_err_t bsp_sdcard_deinit(char *mount_point)
|
||||
/* Make SD/MMC card information structure pointer NULL */
|
||||
card = NULL;
|
||||
|
||||
return ret_val;
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
esp_err_t bsp_sdcard_deinit_default(void)
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
/**
|
||||
* @file spiffs_private.c
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2021-11-04
|
||||
*
|
||||
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_spiffs.h"
|
||||
|
||||
#define DEFAULT_FD_NUM 2
|
||||
#define DEFAULT_MOUNT_POINT "/spiffs"
|
||||
|
||||
static const char *TAG = "bsp_spiffs";
|
||||
|
||||
esp_err_t bsp_spiffs_init(char *partition_label, char *mount_point, size_t max_files)
|
||||
{
|
||||
esp_vfs_spiffs_conf_t conf = {
|
||||
.base_path = mount_point,
|
||||
.partition_label = partition_label,
|
||||
.max_files = max_files,
|
||||
.format_if_mount_failed = false,
|
||||
};
|
||||
|
||||
esp_err_t ret_val = esp_vfs_spiffs_register(&conf);
|
||||
|
||||
if (ESP_OK != ret_val) {
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
size_t total = 0, used = 0;
|
||||
ret_val = esp_spiffs_info(conf.partition_label, &total, &used);
|
||||
if (ret_val != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to get SPIFFS partition information (%s)", esp_err_to_name(ret_val));
|
||||
} else {
|
||||
ESP_LOGI(TAG, "Partition size: total: %d, used: %d", total, used);
|
||||
}
|
||||
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
esp_err_t bsp_spiffs_init_default(void)
|
||||
{
|
||||
return bsp_spiffs_init(NULL, DEFAULT_MOUNT_POINT, DEFAULT_FD_NUM);
|
||||
}
|
||||
|
||||
esp_err_t bsp_spiffs_deinit(char *partition_label)
|
||||
{
|
||||
return esp_vfs_spiffs_unregister(partition_label);
|
||||
}
|
||||
|
||||
esp_err_t bsp_spiffs_deinit_default(void)
|
||||
{
|
||||
return bsp_spiffs_deinit(NULL);
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
idf_component_register(
|
||||
SRC_DIRS
|
||||
"es7210"
|
||||
"es8311"
|
||||
"es8388"
|
||||
INCLUDE_DIRS
|
||||
"es7210"
|
||||
"es8311"
|
||||
"es8388"
|
||||
"include"
|
||||
REQUIRES
|
||||
bsp
|
||||
i2c_bus)
|
||||
@@ -1,532 +0,0 @@
|
||||
/*
|
||||
* ESPRESSIF MIT License
|
||||
*
|
||||
* Copyright (c) 2021 <ESPRESSIF SYSTEMS (SHANGHAI) CO., LTD>
|
||||
*
|
||||
* Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in which case,
|
||||
* it is free of charge, to any person obtaining a copy of this software and associated
|
||||
* documentation files (the "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or
|
||||
* substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "esp_log.h"
|
||||
#include "i2c_bus.h"
|
||||
#include "es7210.h"
|
||||
#include "bsp_i2c.h"
|
||||
|
||||
#define I2S_DSP_MODE_A 0
|
||||
#define MCLK_DIV_FRE 256
|
||||
|
||||
/* ES7210 address*/
|
||||
#define ES7210_ADDR ES7210_AD1_AD0_00
|
||||
#define ES7210_MCLK_SOURCE FROM_CLOCK_DOUBLE_PIN /* In master mode, 0 : MCLK from pad 1 : MCLK from clock doubler */
|
||||
#define FROM_PAD_PIN 0
|
||||
#define FROM_CLOCK_DOUBLE_PIN 1
|
||||
|
||||
/*
|
||||
* Clock coefficient structer
|
||||
*/
|
||||
struct _coeff_div {
|
||||
uint32_t mclk; /* mclk frequency */
|
||||
uint32_t lrck; /* lrck */
|
||||
uint8_t ss_ds;
|
||||
uint8_t adc_div; /* adcclk divider */
|
||||
uint8_t dll; /* dll_bypass */
|
||||
uint8_t doubler; /* doubler enable */
|
||||
uint8_t osr; /* adc osr */
|
||||
uint8_t mclk_src; /* select mclk source */
|
||||
uint32_t lrck_h; /* The high 4 bits of lrck */
|
||||
uint32_t lrck_l; /* The low 8 bits of lrck */
|
||||
};
|
||||
|
||||
static const char *TAG = "ES7210";
|
||||
static i2c_bus_handle_t i2c_handle;
|
||||
static es7210_input_mics_t mic_select = ES7210_INPUT_MIC1 | ES7210_INPUT_MIC2 | ES7210_INPUT_MIC3 | ES7210_INPUT_MIC4;
|
||||
|
||||
/* Codec hifi mclk clock divider coefficients
|
||||
* MEMBER REG
|
||||
* mclk: 0x03
|
||||
* lrck: standard
|
||||
* ss_ds: --
|
||||
* adc_div: 0x02
|
||||
* dll: 0x06
|
||||
* doubler: 0x02
|
||||
* osr: 0x07
|
||||
* mclk_src: 0x03
|
||||
* lrckh: 0x04
|
||||
* lrckl: 0x05
|
||||
*/
|
||||
static const struct _coeff_div coeff_div[] = {
|
||||
//mclk lrck ss_ds adc_div dll doubler osr mclk_src lrckh lrckl
|
||||
/* 8k */
|
||||
{12288000, 8000 , 0x00, 0x03, 0x01, 0x00, 0x20, 0x00, 0x06, 0x00},
|
||||
{16384000, 8000 , 0x00, 0x04, 0x01, 0x00, 0x20, 0x00, 0x08, 0x00},
|
||||
{19200000, 8000 , 0x00, 0x1e, 0x00, 0x01, 0x28, 0x00, 0x09, 0x60},
|
||||
{4096000, 8000 , 0x00, 0x01, 0x01, 0x00, 0x20, 0x00, 0x02, 0x00},
|
||||
|
||||
/* 11.025k */
|
||||
{11289600, 11025, 0x00, 0x02, 0x01, 0x00, 0x20, 0x00, 0x01, 0x00},
|
||||
|
||||
/* 12k */
|
||||
{12288000, 12000, 0x00, 0x02, 0x01, 0x00, 0x20, 0x00, 0x04, 0x00},
|
||||
{19200000, 12000, 0x00, 0x14, 0x00, 0x01, 0x28, 0x00, 0x06, 0x40},
|
||||
|
||||
/* 16k */
|
||||
{4096000, 16000, 0x00, 0x01, 0x01, 0x01, 0x20, 0x00, 0x01, 0x00},
|
||||
{19200000, 16000, 0x00, 0x0a, 0x00, 0x00, 0x1e, 0x00, 0x04, 0x80},
|
||||
{16384000, 16000, 0x00, 0x02, 0x01, 0x00, 0x20, 0x00, 0x04, 0x00},
|
||||
{12288000, 16000, 0x00, 0x03, 0x01, 0x01, 0x20, 0x00, 0x03, 0x00},
|
||||
|
||||
/* 22.05k */
|
||||
{11289600, 22050, 0x00, 0x01, 0x01, 0x00, 0x20, 0x00, 0x02, 0x00},
|
||||
|
||||
/* 24k */
|
||||
{12288000, 24000, 0x00, 0x01, 0x01, 0x00, 0x20, 0x00, 0x02, 0x00},
|
||||
{19200000, 24000, 0x00, 0x0a, 0x00, 0x01, 0x28, 0x00, 0x03, 0x20},
|
||||
|
||||
/* 32k */
|
||||
{12288000, 32000, 0x00, 0x03, 0x00, 0x00, 0x20, 0x00, 0x01, 0x80},
|
||||
{16384000, 32000, 0x00, 0x01, 0x01, 0x00, 0x20, 0x00, 0x02, 0x00},
|
||||
{19200000, 32000, 0x00, 0x05, 0x00, 0x00, 0x1e, 0x00, 0x02, 0x58},
|
||||
|
||||
/* 44.1k */
|
||||
{11289600, 44100, 0x00, 0x01, 0x01, 0x01, 0x20, 0x00, 0x01, 0x00},
|
||||
|
||||
/* 48k */
|
||||
{12288000, 48000, 0x00, 0x01, 0x01, 0x01, 0x20, 0x00, 0x01, 0x00},
|
||||
{19200000, 48000, 0x00, 0x05, 0x00, 0x01, 0x28, 0x00, 0x01, 0x90},
|
||||
|
||||
/* 64k */
|
||||
{16384000, 64000, 0x01, 0x01, 0x01, 0x00, 0x20, 0x00, 0x01, 0x00},
|
||||
{19200000, 64000, 0x00, 0x05, 0x00, 0x01, 0x1e, 0x00, 0x01, 0x2c},
|
||||
|
||||
/* 88.2k */
|
||||
{11289600, 88200, 0x01, 0x01, 0x01, 0x01, 0x20, 0x00, 0x00, 0x80},
|
||||
|
||||
/* 96k */
|
||||
{12288000, 96000, 0x01, 0x01, 0x01, 0x01, 0x20, 0x00, 0x00, 0x80},
|
||||
{19200000, 96000, 0x01, 0x05, 0x00, 0x01, 0x28, 0x00, 0x00, 0xc8},
|
||||
};
|
||||
|
||||
static esp_err_t es7210_write_reg(uint8_t reg_addr, uint8_t data)
|
||||
{
|
||||
return i2c_bus_write_byte(i2c_handle, reg_addr, data);
|
||||
}
|
||||
|
||||
static esp_err_t es7210_update_reg_bit(uint8_t reg_addr, uint8_t update_bits, uint8_t data)
|
||||
{
|
||||
uint8_t regv;
|
||||
regv = es7210_read_reg(reg_addr);
|
||||
regv = (regv & (~update_bits)) | (update_bits & data);
|
||||
return es7210_write_reg(reg_addr, regv);
|
||||
}
|
||||
|
||||
static int get_coeff(uint32_t mclk, uint32_t lrck)
|
||||
{
|
||||
for (int i = 0; i < (sizeof(coeff_div) / sizeof(coeff_div[0])); i++) {
|
||||
if (coeff_div[i].lrck == lrck && coeff_div[i].mclk == mclk)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int8_t get_es7210_mclk_src(void)
|
||||
{
|
||||
return ES7210_MCLK_SOURCE;
|
||||
}
|
||||
|
||||
int es7210_read_reg(uint8_t reg_addr)
|
||||
{
|
||||
uint8_t data;
|
||||
i2c_bus_read_byte(i2c_handle, reg_addr, &data);
|
||||
return (int)data;
|
||||
}
|
||||
|
||||
esp_err_t es7210_config_sample(audio_hal_iface_samples_t sample)
|
||||
{
|
||||
uint8_t regv;
|
||||
int coeff;
|
||||
int sample_fre = 0;
|
||||
int mclk_fre = 0;
|
||||
esp_err_t ret = ESP_OK;
|
||||
switch (sample) {
|
||||
case AUDIO_HAL_08K_SAMPLES:
|
||||
sample_fre = 8000;
|
||||
break;
|
||||
case AUDIO_HAL_11K_SAMPLES:
|
||||
sample_fre = 11025;
|
||||
break;
|
||||
case AUDIO_HAL_16K_SAMPLES:
|
||||
sample_fre = 16000;
|
||||
break;
|
||||
case AUDIO_HAL_22K_SAMPLES:
|
||||
sample_fre = 22050;
|
||||
break;
|
||||
case AUDIO_HAL_24K_SAMPLES:
|
||||
sample_fre = 24000;
|
||||
break;
|
||||
case AUDIO_HAL_32K_SAMPLES:
|
||||
sample_fre = 32000;
|
||||
break;
|
||||
case AUDIO_HAL_44K_SAMPLES:
|
||||
sample_fre = 44100;
|
||||
break;
|
||||
case AUDIO_HAL_48K_SAMPLES:
|
||||
sample_fre = 48000;
|
||||
break;
|
||||
default:
|
||||
ESP_LOGE(TAG, "Unable to configure sample rate %dHz", sample_fre);
|
||||
break;
|
||||
}
|
||||
mclk_fre = sample_fre * MCLK_DIV_FRE;
|
||||
coeff = get_coeff(mclk_fre, sample_fre);
|
||||
if (coeff < 0) {
|
||||
ESP_LOGE(TAG, "Unable to configure sample rate %dHz with %dHz MCLK", sample_fre, mclk_fre);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
/* Set clock parammeters */
|
||||
if (coeff >= 0) {
|
||||
/* Set adc_div & doubler & dll */
|
||||
regv = es7210_read_reg(ES7210_MAINCLK_REG02) & 0x00;
|
||||
regv |= coeff_div[coeff].adc_div;
|
||||
regv |= coeff_div[coeff].doubler << 6;
|
||||
regv |= coeff_div[coeff].dll << 7;
|
||||
ret |= es7210_write_reg(ES7210_MAINCLK_REG02, regv);
|
||||
/* Set osr */
|
||||
regv = coeff_div[coeff].osr;
|
||||
ret |= es7210_write_reg(ES7210_OSR_REG07, regv);
|
||||
/* Set lrck */
|
||||
regv = coeff_div[coeff].lrck_h;
|
||||
ret |= es7210_write_reg(ES7210_LRCK_DIVH_REG04, regv);
|
||||
regv = coeff_div[coeff].lrck_l;
|
||||
ret |= es7210_write_reg(ES7210_LRCK_DIVL_REG05, regv);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
esp_err_t es7210_mic_select(es7210_input_mics_t mic)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
mic_select = mic;
|
||||
if (mic_select & (ES7210_INPUT_MIC1 | ES7210_INPUT_MIC2 | ES7210_INPUT_MIC3 | ES7210_INPUT_MIC4)) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
ret |= es7210_update_reg_bit(ES7210_MIC1_GAIN_REG43 + i, 0x10, 0x00);
|
||||
}
|
||||
ret |= es7210_write_reg(ES7210_MIC12_POWER_REG4B, 0xff);
|
||||
ret |= es7210_write_reg(ES7210_MIC34_POWER_REG4C, 0xff);
|
||||
if (mic_select & ES7210_INPUT_MIC1) {
|
||||
ESP_LOGI(TAG, "Enable ES7210_INPUT_MIC1");
|
||||
ret |= es7210_update_reg_bit(ES7210_CLOCK_OFF_REG01, 0x0b, 0x00);
|
||||
ret |= es7210_write_reg(ES7210_MIC12_POWER_REG4B, 0x00);
|
||||
ret |= es7210_update_reg_bit(ES7210_MIC1_GAIN_REG43, 0x10, 0x10);
|
||||
}
|
||||
if (mic_select & ES7210_INPUT_MIC2) {
|
||||
ESP_LOGI(TAG, "Enable ES7210_INPUT_MIC2");
|
||||
ret |= es7210_update_reg_bit(ES7210_CLOCK_OFF_REG01, 0x0b, 0x00);
|
||||
ret |= es7210_write_reg(ES7210_MIC12_POWER_REG4B, 0x00);
|
||||
ret |= es7210_update_reg_bit(ES7210_MIC2_GAIN_REG44, 0x10, 0x10);
|
||||
}
|
||||
if (mic_select & ES7210_INPUT_MIC3) {
|
||||
ESP_LOGI(TAG, "Enable ES7210_INPUT_MIC3");
|
||||
ret |= es7210_update_reg_bit(ES7210_CLOCK_OFF_REG01, 0x15, 0x00);
|
||||
ret |= es7210_write_reg(ES7210_MIC34_POWER_REG4C, 0x00);
|
||||
ret |= es7210_update_reg_bit(ES7210_MIC3_GAIN_REG45, 0x10, 0x10);
|
||||
}
|
||||
if (mic_select & ES7210_INPUT_MIC4) {
|
||||
ESP_LOGI(TAG, "Enable ES7210_INPUT_MIC4");
|
||||
ret |= es7210_update_reg_bit(ES7210_CLOCK_OFF_REG01, 0x15, 0x00);
|
||||
ret |= es7210_write_reg(ES7210_MIC34_POWER_REG4C, 0x00);
|
||||
ret |= es7210_update_reg_bit(ES7210_MIC4_GAIN_REG46, 0x10, 0x10);
|
||||
}
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Microphone selection error");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
esp_err_t es7210_adc_init(audio_hal_codec_config_t *codec_cfg)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
|
||||
ret |= bsp_i2c_add_device(&i2c_handle, ES7210_ADDR);
|
||||
|
||||
ret |= es7210_write_reg(ES7210_RESET_REG00, 0xff);
|
||||
ret |= es7210_write_reg(ES7210_RESET_REG00, 0x41);
|
||||
ret |= es7210_write_reg(ES7210_CLOCK_OFF_REG01, 0x1f);
|
||||
ret |= es7210_write_reg(ES7210_TIME_CONTROL0_REG09, 0x30); /* Set chip state cycle */
|
||||
ret |= es7210_write_reg(ES7210_TIME_CONTROL1_REG0A, 0x30); /* Set power on state cycle */
|
||||
// ret |= es7210_write_reg(ES7210_ADC12_HPF2_REG23, 0x2a); /* Quick setup */
|
||||
// ret |= es7210_write_reg(ES7210_ADC12_HPF1_REG22, 0x0a);
|
||||
// ret |= es7210_write_reg(ES7210_ADC34_HPF2_REG20, 0x0a);
|
||||
// ret |= es7210_write_reg(ES7210_ADC34_HPF1_REG21, 0x2a);
|
||||
/* Set master/slave audio interface */
|
||||
audio_hal_codec_i2s_iface_t *i2s_cfg = & (codec_cfg->i2s_iface);
|
||||
switch (i2s_cfg->mode) {
|
||||
case AUDIO_HAL_MODE_MASTER: /* MASTER MODE */
|
||||
ESP_LOGI(TAG, "ES7210 in Master mode");
|
||||
// ret |= es7210_update_reg_bit(ES7210_MODE_CONFIG_REG08, 0x01, 0x01);
|
||||
ret |= es7210_write_reg(ES7210_MODE_CONFIG_REG08, 0x20);
|
||||
/* Select clock source for internal mclk */
|
||||
switch (get_es7210_mclk_src()) {
|
||||
case FROM_PAD_PIN:
|
||||
ret |= es7210_update_reg_bit(ES7210_MASTER_CLK_REG03, 0x80, 0x00);
|
||||
break;
|
||||
case FROM_CLOCK_DOUBLE_PIN:
|
||||
ret |= es7210_update_reg_bit(ES7210_MASTER_CLK_REG03, 0x80, 0x80);
|
||||
break;
|
||||
default:
|
||||
ret |= es7210_update_reg_bit(ES7210_MASTER_CLK_REG03, 0x80, 0x00);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case AUDIO_HAL_MODE_SLAVE: /* SLAVE MODE */
|
||||
ESP_LOGI(TAG, "ES7210 in Slave mode");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
ret |= es7210_write_reg(ES7210_ANALOG_REG40, 0xC3); /* Select power off analog, vdda = 3.3V, close vx20ff, VMID select 5KΩ start */
|
||||
ret |= es7210_write_reg(ES7210_MIC12_BIAS_REG41, 0x70); /* Select 2.87v */
|
||||
ret |= es7210_write_reg(ES7210_MIC34_BIAS_REG42, 0x70); /* Select 2.87v */
|
||||
ret |= es7210_write_reg(ES7210_OSR_REG07, 0x20);
|
||||
ret |= es7210_write_reg(ES7210_MAINCLK_REG02, 0xc1); /* Set the frequency division coefficient and use dll except clock doubler, and need to set 0xc1 to clear the state */
|
||||
ret |= es7210_config_sample(i2s_cfg->samples);
|
||||
ret |= es7210_mic_select(mic_select);
|
||||
ret |= es7210_adc_set_gain_all(GAIN_0DB);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t es7210_adc_deinit()
|
||||
{
|
||||
i2c_bus_delete(i2c_handle);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t es7210_config_fmt(audio_hal_iface_format_t fmt)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
uint8_t adc_iface = 0;
|
||||
adc_iface = es7210_read_reg(ES7210_SDP_INTERFACE1_REG11);
|
||||
adc_iface &= 0xfc;
|
||||
switch (fmt) {
|
||||
case AUDIO_HAL_I2S_NORMAL:
|
||||
ESP_LOGD(TAG, "ES7210 in I2S Format");
|
||||
adc_iface |= 0x00;
|
||||
break;
|
||||
case AUDIO_HAL_I2S_LEFT:
|
||||
case AUDIO_HAL_I2S_RIGHT:
|
||||
ESP_LOGD(TAG, "ES7210 in LJ Format");
|
||||
adc_iface |= 0x01;
|
||||
break;
|
||||
case AUDIO_HAL_I2S_DSP:
|
||||
if (I2S_DSP_MODE_A) {
|
||||
ESP_LOGD(TAG, "ES7210 in DSP-A Format");
|
||||
adc_iface |= 0x03;
|
||||
} else {
|
||||
ESP_LOGD(TAG, "ES7210 in DSP-B Format");
|
||||
adc_iface |= 0x13;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
adc_iface &= 0xfc;
|
||||
break;
|
||||
}
|
||||
ret |= es7210_write_reg(ES7210_SDP_INTERFACE1_REG11, adc_iface);
|
||||
return ret;
|
||||
}
|
||||
|
||||
esp_err_t es7210_set_bits(audio_hal_iface_bits_t bits)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
uint8_t adc_iface = 0;
|
||||
adc_iface = es7210_read_reg(ES7210_SDP_INTERFACE1_REG11);
|
||||
adc_iface &= 0x1f;
|
||||
switch (bits) {
|
||||
case AUDIO_HAL_BIT_LENGTH_16BITS:
|
||||
adc_iface |= 0x60;
|
||||
break;
|
||||
case AUDIO_HAL_BIT_LENGTH_24BITS:
|
||||
adc_iface |= 0x00;
|
||||
break;
|
||||
case AUDIO_HAL_BIT_LENGTH_32BITS:
|
||||
adc_iface |= 0x80;
|
||||
break;
|
||||
default:
|
||||
adc_iface |= 0x60;
|
||||
break;
|
||||
}
|
||||
ret |= es7210_write_reg(ES7210_SDP_INTERFACE1_REG11, adc_iface);
|
||||
return ret;
|
||||
}
|
||||
|
||||
esp_err_t es7210_adc_config_i2s(audio_hal_codec_mode_t mode, audio_hal_codec_i2s_iface_t *iface)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
ret |= es7210_set_bits(iface->bits);
|
||||
ret |= es7210_config_fmt(iface->fmt);
|
||||
ret |= es7210_config_sample(iface->samples);
|
||||
return ret;
|
||||
}
|
||||
|
||||
esp_err_t es7210_start(uint8_t clock_reg_value)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
ret |= es7210_write_reg(ES7210_CLOCK_OFF_REG01, clock_reg_value);
|
||||
ret |= es7210_write_reg(ES7210_POWER_DOWN_REG06, 0x00);
|
||||
// ret |= es7210_write_reg(ES7210_ANALOG_REG40, 0x40);
|
||||
ret |= es7210_write_reg(ES7210_MIC1_POWER_REG47, 0x00);
|
||||
ret |= es7210_write_reg(ES7210_MIC2_POWER_REG48, 0x00);
|
||||
ret |= es7210_write_reg(ES7210_MIC3_POWER_REG49, 0x00);
|
||||
ret |= es7210_write_reg(ES7210_MIC4_POWER_REG4A, 0x00);
|
||||
ret |= es7210_mic_select(mic_select);
|
||||
return ret;
|
||||
}
|
||||
|
||||
esp_err_t es7210_stop(void)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
ret |= es7210_write_reg(ES7210_MIC1_POWER_REG47, 0xff);
|
||||
ret |= es7210_write_reg(ES7210_MIC2_POWER_REG48, 0xff);
|
||||
ret |= es7210_write_reg(ES7210_MIC3_POWER_REG49, 0xff);
|
||||
ret |= es7210_write_reg(ES7210_MIC4_POWER_REG4A, 0xff);
|
||||
ret |= es7210_write_reg(ES7210_MIC12_POWER_REG4B,0xff);
|
||||
ret |= es7210_write_reg(ES7210_MIC34_POWER_REG4C, 0xff);
|
||||
// ret |= es7210_write_reg(ES7210_ANALOG_REG40, 0xc0);
|
||||
ret |= es7210_write_reg(ES7210_CLOCK_OFF_REG01, 0x7f);
|
||||
ret |= es7210_write_reg(ES7210_POWER_DOWN_REG06, 0x07);
|
||||
return ret;
|
||||
}
|
||||
|
||||
esp_err_t es7210_adc_ctrl_state(audio_hal_codec_mode_t mode, audio_hal_ctrl_t ctrl_state)
|
||||
{
|
||||
static uint8_t regv;
|
||||
esp_err_t ret = ESP_OK;
|
||||
// ESP_LOGW(TAG, "ES7210 only supports ADC mode");
|
||||
ret = es7210_read_reg(ES7210_CLOCK_OFF_REG01);
|
||||
if ((ret != 0x7f) && (ret != 0xff)) {
|
||||
regv = es7210_read_reg(ES7210_CLOCK_OFF_REG01);
|
||||
}
|
||||
if (ctrl_state == AUDIO_HAL_CTRL_START) {
|
||||
ESP_LOGI(TAG, "The ES7210_CLOCK_OFF_REG01 value before stop is %x",regv);
|
||||
ret |= es7210_start(regv);
|
||||
} else {
|
||||
ESP_LOGW(TAG, "The codec is about to stop");
|
||||
regv = es7210_read_reg(ES7210_CLOCK_OFF_REG01);
|
||||
ret |= es7210_stop();
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t es7210_adc_set_gain(es7210_input_mics_t mic_mask, es7210_gain_value_t gain)
|
||||
{
|
||||
esp_err_t ret_val = ESP_OK;
|
||||
|
||||
if (gain < GAIN_0DB) {
|
||||
gain = GAIN_0DB;
|
||||
}
|
||||
|
||||
if (gain > GAIN_37_5DB) {
|
||||
gain = GAIN_37_5DB;
|
||||
}
|
||||
|
||||
if (mic_mask & ES7210_INPUT_MIC1) {
|
||||
ret_val |= es7210_update_reg_bit(ES7210_MIC1_GAIN_REG43, 0x0f, gain);
|
||||
}
|
||||
if (mic_mask & ES7210_INPUT_MIC2) {
|
||||
ret_val |= es7210_update_reg_bit(ES7210_MIC2_GAIN_REG44, 0x0f, gain);
|
||||
}
|
||||
if (mic_mask & ES7210_INPUT_MIC3) {
|
||||
ret_val |= es7210_update_reg_bit(ES7210_MIC3_GAIN_REG45, 0x0f, gain);
|
||||
}
|
||||
if (mic_mask & ES7210_INPUT_MIC4) {
|
||||
ret_val |= es7210_update_reg_bit(ES7210_MIC4_GAIN_REG46, 0x0f, gain);
|
||||
}
|
||||
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
esp_err_t es7210_adc_set_gain_all(es7210_gain_value_t gain)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
uint32_t max_gain_vaule = 14;
|
||||
if (gain < 0) {
|
||||
gain = 0;
|
||||
} else if (gain > max_gain_vaule) {
|
||||
gain = max_gain_vaule;
|
||||
}
|
||||
ESP_LOGD(TAG, "SET: gain:%d", gain);
|
||||
if (mic_select & ES7210_INPUT_MIC1) {
|
||||
ret |= es7210_update_reg_bit(ES7210_MIC1_GAIN_REG43, 0x0f, gain);
|
||||
}
|
||||
if (mic_select & ES7210_INPUT_MIC2) {
|
||||
ret |= es7210_update_reg_bit(ES7210_MIC2_GAIN_REG44, 0x0f, gain);
|
||||
}
|
||||
if (mic_select & ES7210_INPUT_MIC3) {
|
||||
ret |= es7210_update_reg_bit(ES7210_MIC3_GAIN_REG45, 0x0f, gain);
|
||||
}
|
||||
if (mic_select & ES7210_INPUT_MIC4) {
|
||||
ret |= es7210_update_reg_bit(ES7210_MIC4_GAIN_REG46, 0x0f, gain);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
esp_err_t es7210_adc_get_gain(es7210_input_mics_t mic_mask, es7210_gain_value_t *gain)
|
||||
{
|
||||
int regv = 0;
|
||||
uint8_t gain_value;
|
||||
if (mic_mask & ES7210_INPUT_MIC1) {
|
||||
regv = es7210_read_reg(ES7210_MIC1_GAIN_REG43);
|
||||
} else if (mic_mask & ES7210_INPUT_MIC2) {
|
||||
regv = es7210_read_reg(ES7210_MIC2_GAIN_REG44);
|
||||
} else if (mic_mask & ES7210_INPUT_MIC3) {
|
||||
regv = es7210_read_reg(ES7210_MIC3_GAIN_REG45);
|
||||
} else if (mic_mask & ES7210_INPUT_MIC4) {
|
||||
regv = es7210_read_reg(ES7210_MIC4_GAIN_REG46);
|
||||
} else {
|
||||
ESP_LOGE(TAG, "No MIC selected");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
if (regv == ESP_FAIL) {
|
||||
return regv;
|
||||
}
|
||||
gain_value = (regv & 0x0f); /* Retain the last four bits for gain */
|
||||
*gain = gain_value;
|
||||
ESP_LOGI(TAG, "GET: gain_value:%d", gain_value);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t es7210_adc_set_volume(int volume)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
ESP_LOGD(TAG, "ADC can adjust gain");
|
||||
return ret;
|
||||
}
|
||||
|
||||
esp_err_t es7210_set_mute(bool enable)
|
||||
{
|
||||
ESP_LOGD(TAG, "ES7210 SetMute :%d", enable);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
void es7210_read_all(void)
|
||||
{
|
||||
for (int i = 0; i <= 0x4E; i++) {
|
||||
uint8_t reg = es7210_read_reg(i);
|
||||
ets_printf("REG:%02x, %02x\n", reg, i);
|
||||
}
|
||||
}
|
||||
@@ -1,254 +0,0 @@
|
||||
/*
|
||||
* ESPRESSIF MIT License
|
||||
*
|
||||
* Copyright (c) 2021 <ESPRESSIF SYSTEMS (SHANGHAI) CO., LTD>
|
||||
*
|
||||
* Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in which case,
|
||||
* it is free of charge, to any person obtaining a copy of this software and associated
|
||||
* documentation files (the "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or
|
||||
* substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _ES7210_H
|
||||
#define _ES7210_H
|
||||
|
||||
#include "audio_hal.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ES7210_RESET_REG00 0x00 /* Reset control */
|
||||
#define ES7210_CLOCK_OFF_REG01 0x01 /* Used to turn off the ADC clock */
|
||||
#define ES7210_MAINCLK_REG02 0x02 /* Set ADC clock frequency division */
|
||||
#define ES7210_MASTER_CLK_REG03 0x03 /* MCLK source $ SCLK division */
|
||||
#define ES7210_LRCK_DIVH_REG04 0x04 /* lrck_divh */
|
||||
#define ES7210_LRCK_DIVL_REG05 0x05 /* lrck_divl */
|
||||
#define ES7210_POWER_DOWN_REG06 0x06 /* power down */
|
||||
#define ES7210_OSR_REG07 0x07
|
||||
#define ES7210_MODE_CONFIG_REG08 0x08 /* Set master/slave & channels */
|
||||
#define ES7210_TIME_CONTROL0_REG09 0x09 /* Set Chip intial state period*/
|
||||
#define ES7210_TIME_CONTROL1_REG0A 0x0A /* Set Power up state period */
|
||||
#define ES7210_SDP_INTERFACE1_REG11 0x11 /* Set sample & fmt */
|
||||
#define ES7210_SDP_INTERFACE2_REG12 0x12 /* Pins state */
|
||||
#define ES7210_ADC_AUTOMUTE_REG13 0x13 /* Set mute */
|
||||
#define ES7210_ADC34_MUTERANGE_REG14 0x14 /* Set mute range */
|
||||
#define ES7210_ADC34_HPF2_REG20 0x20 /* HPF */
|
||||
#define ES7210_ADC34_HPF1_REG21 0x21
|
||||
#define ES7210_ADC12_HPF1_REG22 0x22
|
||||
#define ES7210_ADC12_HPF2_REG23 0x23
|
||||
#define ES7210_ANALOG_REG40 0x40 /* ANALOG Power */
|
||||
#define ES7210_MIC12_BIAS_REG41 0x41
|
||||
#define ES7210_MIC34_BIAS_REG42 0x42
|
||||
#define ES7210_MIC1_GAIN_REG43 0x43
|
||||
#define ES7210_MIC2_GAIN_REG44 0x44
|
||||
#define ES7210_MIC3_GAIN_REG45 0x45
|
||||
#define ES7210_MIC4_GAIN_REG46 0x46
|
||||
#define ES7210_MIC1_POWER_REG47 0x47
|
||||
#define ES7210_MIC2_POWER_REG48 0x48
|
||||
#define ES7210_MIC3_POWER_REG49 0x49
|
||||
#define ES7210_MIC4_POWER_REG4A 0x4A
|
||||
#define ES7210_MIC12_POWER_REG4B 0x4B /* MICBias & ADC & PGA Power */
|
||||
#define ES7210_MIC34_POWER_REG4C 0x4C
|
||||
|
||||
typedef enum {
|
||||
ES7210_AD1_AD0_00 = 0x40,
|
||||
ES7210_AD1_AD0_01 = 0x41,
|
||||
ES7210_AD1_AD0_10 = 0x42,
|
||||
ES7210_AD1_AD0_11 = 0x43,
|
||||
} es7210_address_t;
|
||||
|
||||
typedef enum {
|
||||
ES7210_INPUT_MIC1 = 0x01,
|
||||
ES7210_INPUT_MIC2 = 0x02,
|
||||
ES7210_INPUT_MIC3 = 0x04,
|
||||
ES7210_INPUT_MIC4 = 0x08
|
||||
} es7210_input_mics_t;
|
||||
|
||||
typedef enum gain_value{
|
||||
GAIN_0DB = 0,
|
||||
GAIN_3DB,
|
||||
GAIN_6DB,
|
||||
GAIN_9DB,
|
||||
GAIN_12DB,
|
||||
GAIN_15DB,
|
||||
GAIN_18DB,
|
||||
GAIN_21DB,
|
||||
GAIN_24DB,
|
||||
GAIN_27DB,
|
||||
GAIN_30DB,
|
||||
GAIN_33DB,
|
||||
GAIN_34_5DB,
|
||||
GAIN_36DB,
|
||||
GAIN_37_5DB,
|
||||
} es7210_gain_value_t;
|
||||
|
||||
/*
|
||||
* @brief Initialize ES7210 ADC chip
|
||||
*
|
||||
* @param[in] codec_cfg: configuration of ES7210
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t es7210_adc_init(audio_hal_codec_config_t *codec_cfg);
|
||||
|
||||
/**
|
||||
* @brief Deinitialize ES7210 ADC chip
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t es7210_adc_deinit();
|
||||
|
||||
/**
|
||||
* @brief Configure ES7210 ADC mode and I2S interface
|
||||
*
|
||||
* @param[in] mode: codec mode
|
||||
* @param[in] iface: I2S config
|
||||
*
|
||||
* @return
|
||||
* - ESP_FAIL Parameter error
|
||||
* - ESP_OK Success
|
||||
*/
|
||||
esp_err_t es7210_adc_config_i2s(audio_hal_codec_mode_t mode, audio_hal_codec_i2s_iface_t *iface);
|
||||
|
||||
/**
|
||||
* @brief Control ES7210 ADC chip
|
||||
*
|
||||
* @param[in] mode: codec mode
|
||||
* @param[in] ctrl_state: start or stop progress
|
||||
*
|
||||
* @return
|
||||
* - ESP_FAIL Parameter error
|
||||
* - ESP_OK Success
|
||||
*/
|
||||
esp_err_t es7210_adc_ctrl_state(audio_hal_codec_mode_t mode, audio_hal_ctrl_t ctrl_state);
|
||||
|
||||
/**
|
||||
* @brief Set gain of given mask
|
||||
*
|
||||
* @param[in] mic_mask Mask of MIC channel
|
||||
*
|
||||
* @param[in] gain: gain
|
||||
*
|
||||
* gain : value
|
||||
* GAIN_0DB : 1
|
||||
* GAIN_3DB : 2
|
||||
* GAIN_6DB : 3
|
||||
* ·
|
||||
* ·
|
||||
* ·
|
||||
* GAIN_30DB : 10
|
||||
* GAIN_33DB : 11
|
||||
* GAIN_34_5DB : 12
|
||||
* GAIN_36DB : 13
|
||||
* GAIN_37_5DB : 14
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t es7210_adc_set_gain(es7210_input_mics_t mic_mask, es7210_gain_value_t gain);
|
||||
|
||||
/**
|
||||
* @brief Set gain (Note: the enabled microphone sets the same gain)
|
||||
*
|
||||
* @param[in] gain: gain
|
||||
*
|
||||
* gain : value
|
||||
* GAIN_0DB : 1
|
||||
* GAIN_3DB : 2
|
||||
* GAIN_6DB : 3
|
||||
* ·
|
||||
* ·
|
||||
* ·
|
||||
* GAIN_30DB : 10
|
||||
* GAIN_33DB : 11
|
||||
* GAIN_34_5DB : 12
|
||||
* GAIN_36DB : 13
|
||||
* GAIN_37_5DB : 14
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t es7210_adc_set_gain_all(es7210_gain_value_t gain);
|
||||
|
||||
/**
|
||||
* @brief Get MIC gain
|
||||
*
|
||||
* @param mic_mask Selected MIC
|
||||
* @param gain Pointer to `es7210_gain_value_t`
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t es7210_adc_get_gain(es7210_input_mics_t mic_mask, es7210_gain_value_t *gain);
|
||||
|
||||
/**
|
||||
* @brief Set volume
|
||||
*
|
||||
* @param[in] volume: volume
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
*/
|
||||
esp_err_t es7210_adc_set_volume(int volume);
|
||||
|
||||
/**
|
||||
* @brief Set ES7210 ADC mute status
|
||||
*
|
||||
* @return
|
||||
* - ESP_FAIL
|
||||
* - ESP_OK
|
||||
*/
|
||||
esp_err_t es7210_set_mute(bool enable);
|
||||
|
||||
/**
|
||||
* @brief Select ES7210 mic
|
||||
*
|
||||
* @param[in] mic: mics
|
||||
*
|
||||
* @return
|
||||
* - ESP_FAIL
|
||||
* - ESP_OK
|
||||
*/
|
||||
esp_err_t es7210_mic_select(es7210_input_mics_t mic);
|
||||
|
||||
/**
|
||||
* @brief Read regs of ES7210
|
||||
*
|
||||
* @param[in] reg_addr: reg_addr
|
||||
*
|
||||
* @return
|
||||
* - ESP_FAIL
|
||||
* - ESP_OK
|
||||
*/
|
||||
int es7210_read_reg(uint8_t reg_addr);
|
||||
|
||||
/**
|
||||
* @brief Read all regs of ES7210
|
||||
*/
|
||||
void es7210_read_all(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ES7210_H_ */
|
||||
@@ -1,672 +0,0 @@
|
||||
/*
|
||||
* ESPRESSIF MIT License
|
||||
*
|
||||
* Copyright (c) 2019 <ESPRESSIF SYSTEMS (SHANGHAI) CO., LTD>
|
||||
*
|
||||
* Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in which case,
|
||||
* it is free of charge, to any person obtaining a copy of this software and associated
|
||||
* documentation files (the "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or
|
||||
* substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "i2c_bus.h"
|
||||
#include "esp_log.h"
|
||||
#include "es8311.h"
|
||||
#include "bsp_i2c.h"
|
||||
|
||||
/* ES8311 address
|
||||
* 0x32:CE=1;0x30:CE=0
|
||||
*/
|
||||
#define ES8311_ADDR 0x18
|
||||
|
||||
/*
|
||||
* to define the clock soure of MCLK
|
||||
*/
|
||||
#define FROM_MCLK_PIN 0
|
||||
#define FROM_SCLK_PIN 1
|
||||
#define ES8311_MCLK_SOURCE FROM_MCLK_PIN
|
||||
|
||||
/*
|
||||
* to define whether to reverse the clock
|
||||
*/
|
||||
#define INVERT_MCLK 0 // do not invert
|
||||
#define INVERT_SCLK 0
|
||||
|
||||
#define IS_DMIC 0 // Is it a digital microphone
|
||||
|
||||
#define MCLK_DIV_FRE 256
|
||||
|
||||
static i2c_bus_handle_t i2c_handle;
|
||||
|
||||
/*
|
||||
* Clock coefficient structer
|
||||
*/
|
||||
struct _coeff_div {
|
||||
uint32_t mclk; /* mclk frequency */
|
||||
uint32_t rate; /* sample rate */
|
||||
uint8_t pre_div; /* the pre divider with range from 1 to 8 */
|
||||
uint8_t pre_multi; /* the pre multiplier with x1, x2, x4 and x8 selection */
|
||||
uint8_t adc_div; /* adcclk divider */
|
||||
uint8_t dac_div; /* dacclk divider */
|
||||
uint8_t fs_mode; /* double speed or single speed, =0, ss, =1, ds */
|
||||
uint8_t lrck_h; /* adclrck divider and daclrck divider */
|
||||
uint8_t lrck_l;
|
||||
uint8_t bclk_div; /* sclk divider */
|
||||
uint8_t adc_osr; /* adc osr */
|
||||
uint8_t dac_osr; /* dac osr */
|
||||
};
|
||||
|
||||
/* codec hifi mclk clock divider coefficients */
|
||||
static const struct _coeff_div coeff_div[] = {
|
||||
//mclk rate pre_div mult adc_div dac_div fs_mode lrch lrcl bckdiv osr
|
||||
/* 8k */
|
||||
{12288000, 8000 , 0x06, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{18432000, 8000 , 0x03, 0x02, 0x03, 0x03, 0x00, 0x05, 0xff, 0x18, 0x10, 0x10},
|
||||
{16384000, 8000 , 0x08, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{8192000 , 8000 , 0x04, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{6144000 , 8000 , 0x03, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{4096000 , 8000 , 0x02, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{3072000 , 8000 , 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{2048000 , 8000 , 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{1536000 , 8000 , 0x03, 0x04, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{1024000 , 8000 , 0x01, 0x02, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
|
||||
/* 11.025k */
|
||||
{11289600, 11025, 0x04, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{5644800 , 11025, 0x02, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{2822400 , 11025, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{1411200 , 11025, 0x01, 0x02, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
|
||||
/* 12k */
|
||||
{12288000, 12000, 0x04, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{6144000 , 12000, 0x02, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{3072000 , 12000, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{1536000 , 12000, 0x01, 0x02, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
|
||||
/* 16k */
|
||||
{12288000, 16000, 0x03, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{18432000, 16000, 0x03, 0x02, 0x03, 0x03, 0x00, 0x02, 0xff, 0x0c, 0x10, 0x10},
|
||||
{16384000, 16000, 0x04, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{8192000 , 16000, 0x02, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{6144000 , 16000, 0x03, 0x02, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{4096000 , 16000, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{3072000 , 16000, 0x03, 0x04, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{2048000 , 16000, 0x01, 0x02, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{1536000 , 16000, 0x03, 0x08, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{1024000 , 16000, 0x01, 0x04, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
|
||||
/* 22.05k */
|
||||
{11289600, 22050, 0x02, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{5644800 , 22050, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{2822400 , 22050, 0x01, 0x02, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{1411200 , 22050, 0x01, 0x04, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
|
||||
/* 24k */
|
||||
{12288000, 24000, 0x02, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{18432000, 24000, 0x03, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{6144000 , 24000, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{3072000 , 24000, 0x01, 0x02, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{1536000 , 24000, 0x01, 0x04, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
|
||||
/* 32k */
|
||||
{12288000, 32000, 0x03, 0x02, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{18432000, 32000, 0x03, 0x04, 0x03, 0x03, 0x00, 0x02, 0xff, 0x0c, 0x10, 0x10},
|
||||
{16384000, 32000, 0x02, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{8192000 , 32000, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{6144000 , 32000, 0x03, 0x04, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{4096000 , 32000, 0x01, 0x02, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{3072000 , 32000, 0x03, 0x08, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{2048000 , 32000, 0x01, 0x04, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{1536000 , 32000, 0x03, 0x08, 0x01, 0x01, 0x01, 0x00, 0x7f, 0x02, 0x10, 0x10},
|
||||
{1024000 , 32000, 0x01, 0x08, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
|
||||
/* 44.1k */
|
||||
{11289600, 44100, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{5644800 , 44100, 0x01, 0x02, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{2822400 , 44100, 0x01, 0x04, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{1411200 , 44100, 0x01, 0x08, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
|
||||
/* 48k */
|
||||
{12288000, 48000, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{18432000, 48000, 0x03, 0x02, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{6144000 , 48000, 0x01, 0x02, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{3072000 , 48000, 0x01, 0x04, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{1536000 , 48000, 0x01, 0x08, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
|
||||
/* 64k */
|
||||
{12288000, 64000, 0x03, 0x04, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{18432000, 64000, 0x03, 0x04, 0x03, 0x03, 0x01, 0x01, 0x7f, 0x06, 0x10, 0x10},
|
||||
{16384000, 64000, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{8192000 , 64000, 0x01, 0x02, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{6144000 , 64000, 0x01, 0x04, 0x03, 0x03, 0x01, 0x01, 0x7f, 0x06, 0x10, 0x10},
|
||||
{4096000 , 64000, 0x01, 0x04, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{3072000 , 64000, 0x01, 0x08, 0x03, 0x03, 0x01, 0x01, 0x7f, 0x06, 0x10, 0x10},
|
||||
{2048000 , 64000, 0x01, 0x08, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{1536000 , 64000, 0x01, 0x08, 0x01, 0x01, 0x01, 0x00, 0xbf, 0x03, 0x18, 0x18},
|
||||
{1024000 , 64000, 0x01, 0x08, 0x01, 0x01, 0x01, 0x00, 0x7f, 0x02, 0x10, 0x10},
|
||||
|
||||
/* 88.2k */
|
||||
{11289600, 88200, 0x01, 0x02, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{5644800 , 88200, 0x01, 0x04, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{2822400 , 88200, 0x01, 0x08, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{1411200 , 88200, 0x01, 0x08, 0x01, 0x01, 0x01, 0x00, 0x7f, 0x02, 0x10, 0x10},
|
||||
|
||||
/* 96k */
|
||||
{12288000, 96000, 0x01, 0x02, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{18432000, 96000, 0x03, 0x04, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{6144000 , 96000, 0x01, 0x04, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{3072000 , 96000, 0x01, 0x08, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
|
||||
{1536000 , 96000, 0x01, 0x08, 0x01, 0x01, 0x01, 0x00, 0x7f, 0x02, 0x10, 0x10},
|
||||
};
|
||||
|
||||
static const char *TAG = "DRV8311";
|
||||
|
||||
#define ES_ASSERT(a, format, b, ...) \
|
||||
if ((a) != 0) { \
|
||||
ESP_LOGE(TAG, format, ##__VA_ARGS__); \
|
||||
return b;\
|
||||
}
|
||||
|
||||
static esp_err_t es8311_write_reg(uint8_t reg_addr, uint8_t data)
|
||||
{
|
||||
return i2c_bus_write_byte(i2c_handle, reg_addr, data);
|
||||
}
|
||||
|
||||
static int es8311_read_reg(uint8_t reg_addr)
|
||||
{
|
||||
uint8_t data;
|
||||
i2c_bus_read_byte(i2c_handle, reg_addr, &data);
|
||||
return (int)data;
|
||||
}
|
||||
|
||||
/*
|
||||
* look for the coefficient in coeff_div[] table
|
||||
*/
|
||||
static int get_coeff(uint32_t mclk, uint32_t rate)
|
||||
{
|
||||
for (int i = 0; i < (sizeof(coeff_div) / sizeof(coeff_div[0])); i++) {
|
||||
if (coeff_div[i].rate == rate && coeff_div[i].mclk == mclk)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* set es8311 dac mute or not
|
||||
* if mute = 0, dac un-mute
|
||||
* if mute = 1, dac mute
|
||||
*/
|
||||
static void es8311_mute(int mute)
|
||||
{
|
||||
uint8_t regv;
|
||||
regv = es8311_read_reg(ES8311_DAC_REG31) & 0x9f;
|
||||
if (mute) {
|
||||
es8311_write_reg(ES8311_SYSTEM_REG12, 0x02);
|
||||
es8311_write_reg(ES8311_DAC_REG31, regv | 0x60);
|
||||
es8311_write_reg(ES8311_DAC_REG32, 0x00);
|
||||
es8311_write_reg(ES8311_DAC_REG37, 0x08);
|
||||
} else {
|
||||
es8311_write_reg(ES8311_DAC_REG31, regv);
|
||||
es8311_write_reg(ES8311_SYSTEM_REG12, 0x00);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* set es8311 into suspend mode
|
||||
*/
|
||||
static void es8311_suspend(void)
|
||||
{
|
||||
ESP_LOGI(TAG, "Enter into es8311_suspend()");
|
||||
es8311_write_reg(ES8311_DAC_REG32, 0x00);
|
||||
es8311_write_reg(ES8311_ADC_REG17, 0x00);
|
||||
es8311_write_reg(ES8311_SYSTEM_REG0E, 0xFF);
|
||||
es8311_write_reg(ES8311_SYSTEM_REG12, 0x02);
|
||||
es8311_write_reg(ES8311_SYSTEM_REG14, 0x00);
|
||||
es8311_write_reg(ES8311_SYSTEM_REG0D, 0xFA);
|
||||
es8311_write_reg(ES8311_ADC_REG15, 0x00);
|
||||
es8311_write_reg(ES8311_DAC_REG37, 0x08);
|
||||
es8311_write_reg(ES8311_GP_REG45, 0x01);
|
||||
}
|
||||
|
||||
esp_err_t es8311_codec_init(audio_hal_codec_config_t *codec_cfg)
|
||||
{
|
||||
uint8_t datmp, regv;
|
||||
int coeff;
|
||||
esp_err_t ret = ESP_OK;
|
||||
|
||||
ret |= bsp_i2c_add_device(&i2c_handle, ES8311_ADDR);
|
||||
|
||||
ret |= es8311_write_reg(ES8311_CLK_MANAGER_REG01, 0x30);
|
||||
ret |= es8311_write_reg(ES8311_CLK_MANAGER_REG02, 0x00);
|
||||
ret |= es8311_write_reg(ES8311_CLK_MANAGER_REG03, 0x10);
|
||||
ret |= es8311_write_reg(ES8311_ADC_REG16, 0x24);
|
||||
ret |= es8311_write_reg(ES8311_CLK_MANAGER_REG04, 0x10);
|
||||
ret |= es8311_write_reg(ES8311_CLK_MANAGER_REG05, 0x00);
|
||||
ret |= es8311_write_reg(ES8311_SYSTEM_REG0B, 0x00);
|
||||
ret |= es8311_write_reg(ES8311_SYSTEM_REG0C, 0x00);
|
||||
ret |= es8311_write_reg(ES8311_SYSTEM_REG10, 0x1F);
|
||||
ret |= es8311_write_reg(ES8311_SYSTEM_REG11, 0x7F);
|
||||
ret |= es8311_write_reg(ES8311_RESET_REG00, 0x80);
|
||||
/*
|
||||
* Set Codec into Master or Slave mode
|
||||
*/
|
||||
regv = es8311_read_reg(ES8311_RESET_REG00);
|
||||
/*
|
||||
* Set master/slave audio interface
|
||||
*/
|
||||
audio_hal_codec_i2s_iface_t *i2s_cfg = &(codec_cfg->i2s_iface);
|
||||
switch (i2s_cfg->mode) {
|
||||
case AUDIO_HAL_MODE_MASTER: /* MASTER MODE */
|
||||
ESP_LOGI(TAG, "ES8311 in Master mode");
|
||||
regv |= 0x40;
|
||||
break;
|
||||
case AUDIO_HAL_MODE_SLAVE: /* SLAVE MODE */
|
||||
ESP_LOGI(TAG, "ES8311 in Slave mode");
|
||||
regv &= 0xBF;
|
||||
break;
|
||||
default:
|
||||
regv &= 0xBF;
|
||||
}
|
||||
ret |= es8311_write_reg(ES8311_RESET_REG00, regv);
|
||||
ret |= es8311_write_reg(ES8311_CLK_MANAGER_REG01, 0x3F);
|
||||
/*
|
||||
* Select clock source for internal mclk
|
||||
*/
|
||||
|
||||
int es8311_mclk_src = ES8311_MCLK_SOURCE;
|
||||
switch (es8311_mclk_src) {
|
||||
case FROM_MCLK_PIN:
|
||||
regv = es8311_read_reg(ES8311_CLK_MANAGER_REG01);
|
||||
regv &= 0x7F;
|
||||
ret |= es8311_write_reg(ES8311_CLK_MANAGER_REG01, regv);
|
||||
break;
|
||||
case FROM_SCLK_PIN:
|
||||
regv = es8311_read_reg(ES8311_CLK_MANAGER_REG01);
|
||||
regv |= 0x80;
|
||||
ret |= es8311_write_reg(ES8311_CLK_MANAGER_REG01, regv);
|
||||
break;
|
||||
default:
|
||||
regv = es8311_read_reg(ES8311_CLK_MANAGER_REG01);
|
||||
regv &= 0x7F;
|
||||
ret |= es8311_write_reg(ES8311_CLK_MANAGER_REG01, regv);
|
||||
break;
|
||||
}
|
||||
int sample_fre = 0;
|
||||
int mclk_fre = 0;
|
||||
switch (i2s_cfg->samples) {
|
||||
case AUDIO_HAL_08K_SAMPLES:
|
||||
sample_fre = 8000;
|
||||
break;
|
||||
case AUDIO_HAL_11K_SAMPLES:
|
||||
sample_fre = 11025;
|
||||
break;
|
||||
case AUDIO_HAL_16K_SAMPLES:
|
||||
sample_fre = 16000;
|
||||
break;
|
||||
case AUDIO_HAL_22K_SAMPLES:
|
||||
sample_fre = 22050;
|
||||
break;
|
||||
case AUDIO_HAL_24K_SAMPLES:
|
||||
sample_fre = 24000;
|
||||
break;
|
||||
case AUDIO_HAL_32K_SAMPLES:
|
||||
sample_fre = 32000;
|
||||
break;
|
||||
case AUDIO_HAL_44K_SAMPLES:
|
||||
sample_fre = 44100;
|
||||
break;
|
||||
case AUDIO_HAL_48K_SAMPLES:
|
||||
sample_fre = 48000;
|
||||
break;
|
||||
default:
|
||||
ESP_LOGE(TAG, "Unable to configure sample rate %dHz", sample_fre);
|
||||
break;
|
||||
}
|
||||
mclk_fre = sample_fre * MCLK_DIV_FRE;
|
||||
coeff = get_coeff(mclk_fre, sample_fre);
|
||||
if (coeff < 0) {
|
||||
ESP_LOGE(TAG, "Unable to configure sample rate %dHz with %dHz MCLK", sample_fre, mclk_fre);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
/*
|
||||
* Set clock parammeters
|
||||
*/
|
||||
if (coeff >= 0) {
|
||||
regv = es8311_read_reg(ES8311_CLK_MANAGER_REG02) & 0x07;
|
||||
regv |= (coeff_div[coeff].pre_div - 1) << 5;
|
||||
datmp = 0;
|
||||
switch (coeff_div[coeff].pre_multi) {
|
||||
case 1:
|
||||
datmp = 0;
|
||||
break;
|
||||
case 2:
|
||||
datmp = 1;
|
||||
break;
|
||||
case 4:
|
||||
datmp = 2;
|
||||
break;
|
||||
case 8:
|
||||
datmp = 3;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (ES8311_MCLK_SOURCE == FROM_SCLK_PIN) {
|
||||
datmp = 3; /* DIG_MCLK = LRCK * 256 = BCLK * 8 */
|
||||
}
|
||||
regv |= (datmp) << 3;
|
||||
ret |= es8311_write_reg(ES8311_CLK_MANAGER_REG02, regv);
|
||||
|
||||
regv = es8311_read_reg(ES8311_CLK_MANAGER_REG05) & 0x00;
|
||||
regv |= (coeff_div[coeff].adc_div - 1) << 4;
|
||||
regv |= (coeff_div[coeff].dac_div - 1) << 0;
|
||||
ret |= es8311_write_reg(ES8311_CLK_MANAGER_REG05, regv);
|
||||
|
||||
regv = es8311_read_reg(ES8311_CLK_MANAGER_REG03) & 0x80;
|
||||
regv |= coeff_div[coeff].fs_mode << 6;
|
||||
regv |= coeff_div[coeff].adc_osr << 0;
|
||||
ret |= es8311_write_reg(ES8311_CLK_MANAGER_REG03, regv);
|
||||
|
||||
regv = es8311_read_reg(ES8311_CLK_MANAGER_REG04) & 0x80;
|
||||
regv |= coeff_div[coeff].dac_osr << 0;
|
||||
ret |= es8311_write_reg(ES8311_CLK_MANAGER_REG04, regv);
|
||||
|
||||
regv = es8311_read_reg(ES8311_CLK_MANAGER_REG07) & 0xC0;
|
||||
regv |= coeff_div[coeff].lrck_h << 0;
|
||||
ret |= es8311_write_reg(ES8311_CLK_MANAGER_REG07, regv);
|
||||
|
||||
regv = es8311_read_reg(ES8311_CLK_MANAGER_REG08) & 0x00;
|
||||
regv |= coeff_div[coeff].lrck_l << 0;
|
||||
ret |= es8311_write_reg(ES8311_CLK_MANAGER_REG08, regv);
|
||||
|
||||
regv = es8311_read_reg(ES8311_CLK_MANAGER_REG06) & 0xE0;
|
||||
if (coeff_div[coeff].bclk_div < 19) {
|
||||
regv |= (coeff_div[coeff].bclk_div - 1) << 0;
|
||||
} else {
|
||||
regv |= (coeff_div[coeff].bclk_div) << 0;
|
||||
}
|
||||
ret |= es8311_write_reg(ES8311_CLK_MANAGER_REG06, regv);
|
||||
}
|
||||
|
||||
/*
|
||||
* mclk inverted or not
|
||||
*/
|
||||
if (INVERT_MCLK) {
|
||||
regv = es8311_read_reg(ES8311_CLK_MANAGER_REG01);
|
||||
regv |= 0x40;
|
||||
ret |= es8311_write_reg(ES8311_CLK_MANAGER_REG01, regv);
|
||||
} else {
|
||||
regv = es8311_read_reg(ES8311_CLK_MANAGER_REG01);
|
||||
regv &= ~(0x40);
|
||||
ret |= es8311_write_reg(ES8311_CLK_MANAGER_REG01, regv);
|
||||
}
|
||||
/*
|
||||
* sclk inverted or not
|
||||
*/
|
||||
if (INVERT_SCLK) {
|
||||
regv = es8311_read_reg(ES8311_CLK_MANAGER_REG06);
|
||||
regv |= 0x20;
|
||||
ret |= es8311_write_reg(ES8311_CLK_MANAGER_REG06, regv);
|
||||
} else {
|
||||
regv = es8311_read_reg(ES8311_CLK_MANAGER_REG06);
|
||||
regv &= ~(0x20);
|
||||
ret |= es8311_write_reg(ES8311_CLK_MANAGER_REG06, regv);
|
||||
}
|
||||
|
||||
ret |= es8311_write_reg(ES8311_SYSTEM_REG13, 0x10);
|
||||
ret |= es8311_write_reg(ES8311_ADC_REG1B, 0x0A);
|
||||
ret |= es8311_write_reg(ES8311_ADC_REG1C, 0x6A);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t es8311_codec_deinit()
|
||||
{
|
||||
i2c_bus_delete(i2c_handle);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t es8311_config_fmt(es_i2s_fmt_t fmt)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
uint8_t adc_iface = 0, dac_iface = 0;
|
||||
dac_iface = es8311_read_reg(ES8311_SDPIN_REG09);
|
||||
adc_iface = es8311_read_reg(ES8311_SDPOUT_REG0A);
|
||||
switch (fmt) {
|
||||
case AUDIO_HAL_I2S_NORMAL:
|
||||
ESP_LOGD(TAG, "ES8311 in I2S Format");
|
||||
dac_iface &= 0xFC;
|
||||
adc_iface &= 0xFC;
|
||||
break;
|
||||
case AUDIO_HAL_I2S_LEFT:
|
||||
case AUDIO_HAL_I2S_RIGHT:
|
||||
ESP_LOGD(TAG, "ES8311 in LJ Format");
|
||||
adc_iface &= 0xFC;
|
||||
dac_iface &= 0xFC;
|
||||
adc_iface |= 0x01;
|
||||
dac_iface |= 0x01;
|
||||
break;
|
||||
case AUDIO_HAL_I2S_DSP:
|
||||
ESP_LOGD(TAG, "ES8311 in DSP-B Format");
|
||||
adc_iface &= 0xDC;
|
||||
dac_iface &= 0xDC;
|
||||
adc_iface |= 0x23;
|
||||
dac_iface |= 0x23;
|
||||
break;
|
||||
default:
|
||||
dac_iface &= 0xFC;
|
||||
adc_iface &= 0xFC;
|
||||
break;
|
||||
}
|
||||
ret |= es8311_write_reg(ES8311_SDPIN_REG09, dac_iface);
|
||||
ret |= es8311_write_reg(ES8311_SDPOUT_REG0A, adc_iface);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
esp_err_t es8311_set_bits_per_sample(audio_hal_iface_bits_t bits)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
uint8_t adc_iface = 0, dac_iface = 0;
|
||||
dac_iface = es8311_read_reg(ES8311_SDPIN_REG09);
|
||||
adc_iface = es8311_read_reg(ES8311_SDPOUT_REG0A);
|
||||
switch (bits) {
|
||||
case AUDIO_HAL_BIT_LENGTH_16BITS:
|
||||
dac_iface |= 0x0c;
|
||||
adc_iface |= 0x0c;
|
||||
break;
|
||||
case AUDIO_HAL_BIT_LENGTH_24BITS:
|
||||
break;
|
||||
case AUDIO_HAL_BIT_LENGTH_32BITS:
|
||||
dac_iface |= 0x10;
|
||||
adc_iface |= 0x10;
|
||||
break;
|
||||
default:
|
||||
dac_iface |= 0x0c;
|
||||
adc_iface |= 0x0c;
|
||||
break;
|
||||
|
||||
}
|
||||
ret |= es8311_write_reg(ES8311_SDPIN_REG09, dac_iface);
|
||||
ret |= es8311_write_reg(ES8311_SDPOUT_REG0A, adc_iface);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
esp_err_t es8311_codec_config_i2s(audio_hal_codec_mode_t mode, audio_hal_codec_i2s_iface_t *iface)
|
||||
{
|
||||
int ret = ESP_OK;
|
||||
ret |= es8311_set_bits_per_sample(iface->bits);
|
||||
ret |= es8311_config_fmt(iface->fmt);
|
||||
return ret;
|
||||
}
|
||||
|
||||
esp_err_t es8311_codec_ctrl_state(audio_hal_codec_mode_t mode, audio_hal_ctrl_t ctrl_state)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
es_module_t es_mode = ES_MODULE_MIN;
|
||||
|
||||
switch (mode) {
|
||||
case AUDIO_HAL_CODEC_MODE_ENCODE:
|
||||
es_mode = ES_MODULE_ADC;
|
||||
break;
|
||||
case AUDIO_HAL_CODEC_MODE_LINE_IN:
|
||||
es_mode = ES_MODULE_LINE;
|
||||
break;
|
||||
case AUDIO_HAL_CODEC_MODE_DECODE:
|
||||
es_mode = ES_MODULE_DAC;
|
||||
break;
|
||||
case AUDIO_HAL_CODEC_MODE_BOTH:
|
||||
es_mode = ES_MODULE_ADC_DAC;
|
||||
break;
|
||||
default:
|
||||
es_mode = ES_MODULE_DAC;
|
||||
ESP_LOGW(TAG, "Codec mode not support, default is decode mode");
|
||||
break;
|
||||
}
|
||||
|
||||
if (ctrl_state == AUDIO_HAL_CTRL_START) {
|
||||
ret |= es8311_start(es_mode);
|
||||
} else {
|
||||
ESP_LOGW(TAG, "The codec is about to stop");
|
||||
ret |= es8311_stop(es_mode);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
esp_err_t es8311_start(es_module_t mode)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
uint8_t adc_iface = 0, dac_iface = 0;
|
||||
|
||||
dac_iface = es8311_read_reg(ES8311_SDPIN_REG09) & 0xBF;
|
||||
adc_iface = es8311_read_reg(ES8311_SDPOUT_REG0A) & 0xBF;
|
||||
adc_iface |= BIT(6);
|
||||
dac_iface |= BIT(6);
|
||||
|
||||
if (mode == ES_MODULE_LINE) {
|
||||
ESP_LOGE(TAG, "The codec es8311 doesn't support ES_MODULE_LINE mode");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
if (mode == ES_MODULE_ADC || mode == ES_MODULE_ADC_DAC) {
|
||||
adc_iface &= ~(BIT(6));
|
||||
}
|
||||
if (mode == ES_MODULE_DAC || mode == ES_MODULE_ADC_DAC) {
|
||||
dac_iface &= ~(BIT(6));
|
||||
}
|
||||
|
||||
ret |= es8311_write_reg(ES8311_SDPIN_REG09, dac_iface);
|
||||
ret |= es8311_write_reg(ES8311_SDPOUT_REG0A, adc_iface);
|
||||
|
||||
ret |= es8311_write_reg(ES8311_ADC_REG17, 0xBF);
|
||||
ret |= es8311_write_reg(ES8311_SYSTEM_REG0E, 0x02);
|
||||
ret |= es8311_write_reg(ES8311_SYSTEM_REG12, 0x00);
|
||||
ret |= es8311_write_reg(ES8311_SYSTEM_REG14, 0x1A);
|
||||
|
||||
/*
|
||||
* pdm dmic enable or disable
|
||||
*/
|
||||
int regv = 0;
|
||||
if (IS_DMIC) {
|
||||
regv = es8311_read_reg(ES8311_SYSTEM_REG14);
|
||||
regv |= 0x40;
|
||||
ret |= es8311_write_reg(ES8311_SYSTEM_REG14, regv);
|
||||
} else {
|
||||
regv = es8311_read_reg(ES8311_SYSTEM_REG14);
|
||||
regv &= ~(0x40);
|
||||
ret |= es8311_write_reg(ES8311_SYSTEM_REG14, regv);
|
||||
}
|
||||
|
||||
ret |= es8311_write_reg(ES8311_SYSTEM_REG0D, 0x01);
|
||||
ret |= es8311_write_reg(ES8311_ADC_REG15, 0x40);
|
||||
ret |= es8311_write_reg(ES8311_DAC_REG37, 0x48);
|
||||
ret |= es8311_write_reg(ES8311_GP_REG45, 0x00);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
esp_err_t es8311_stop(es_module_t mode)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
es8311_suspend();
|
||||
return ret;
|
||||
}
|
||||
|
||||
esp_err_t es8311_codec_set_voice_volume(int volume)
|
||||
{
|
||||
esp_err_t res = ESP_OK;
|
||||
if (volume < 0) {
|
||||
volume = 0;
|
||||
} else if (volume > 100) {
|
||||
volume = 100;
|
||||
}
|
||||
int vol = (volume) * 2550 / 1000;
|
||||
ESP_LOGD(TAG, "SET: volume:%d", vol);
|
||||
es8311_write_reg(ES8311_DAC_REG32, vol);
|
||||
return res;
|
||||
}
|
||||
|
||||
esp_err_t es8311_codec_get_voice_volume(int *volume)
|
||||
{
|
||||
esp_err_t res = ESP_OK;
|
||||
int regv = 0;
|
||||
regv = es8311_read_reg(ES8311_DAC_REG32);
|
||||
if (regv == ESP_FAIL) {
|
||||
*volume = 0;
|
||||
res = ESP_FAIL;
|
||||
} else {
|
||||
*volume = regv * 100 / 256;
|
||||
}
|
||||
ESP_LOGD(TAG, "GET: res:%d, volume:%d", regv, *volume);
|
||||
return res;
|
||||
}
|
||||
|
||||
esp_err_t es8311_set_voice_mute(bool enable)
|
||||
{
|
||||
ESP_LOGD(TAG, "Es8311SetVoiceMute volume:%d", enable);
|
||||
es8311_mute(enable);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t es8311_get_voice_mute(int *mute)
|
||||
{
|
||||
esp_err_t res = ESP_OK;
|
||||
uint8_t reg = 0;
|
||||
res = es8311_read_reg(ES8311_DAC_REG31);
|
||||
if (res != ESP_FAIL) {
|
||||
reg = (res & 0x20) >> 5;
|
||||
}
|
||||
*mute = reg;
|
||||
return res;
|
||||
}
|
||||
|
||||
esp_err_t es8311_set_mic_gain(es8311_mic_gain_t gain_db)
|
||||
{
|
||||
esp_err_t res = ESP_OK;
|
||||
res = es8311_write_reg(ES8311_ADC_REG16, gain_db); // MIC gain scale
|
||||
return res;
|
||||
}
|
||||
|
||||
void es8311_read_all()
|
||||
{
|
||||
for (int i = 0; i < 0x4A; i++) {
|
||||
uint8_t reg = es8311_read_reg(i);
|
||||
ets_printf("REG:%02x, %02x\n", reg, i);
|
||||
}
|
||||
}
|
||||
@@ -1,273 +0,0 @@
|
||||
/*
|
||||
* ESPRESSIF MIT License
|
||||
*
|
||||
* Copyright (c) 2019 <ESPRESSIF SYSTEMS (SHANGHAI) CO., LTD>
|
||||
*
|
||||
* Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in which case,
|
||||
* it is free of charge, to any person obtaining a copy of this software and associated
|
||||
* documentation files (the "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or
|
||||
* substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _ES8311_H
|
||||
#define _ES8311_H
|
||||
|
||||
#include "audio_hal.h"
|
||||
#include "esp_types.h"
|
||||
#include "esxxx_common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* ES8311_REGISTER NAME_REG_REGISTER ADDRESS
|
||||
*/
|
||||
#define ES8311_RESET_REG00 0x00 /*reset digital,csm,clock manager etc.*/
|
||||
|
||||
/*
|
||||
* Clock Scheme Register definition
|
||||
*/
|
||||
#define ES8311_CLK_MANAGER_REG01 0x01 /* select clk src for mclk, enable clock for codec */
|
||||
#define ES8311_CLK_MANAGER_REG02 0x02 /* clk divider and clk multiplier */
|
||||
#define ES8311_CLK_MANAGER_REG03 0x03 /* adc fsmode and osr */
|
||||
#define ES8311_CLK_MANAGER_REG04 0x04 /* dac osr */
|
||||
#define ES8311_CLK_MANAGER_REG05 0x05 /* clk divier for adc and dac */
|
||||
#define ES8311_CLK_MANAGER_REG06 0x06 /* bclk inverter and divider */
|
||||
#define ES8311_CLK_MANAGER_REG07 0x07 /* tri-state, lrck divider */
|
||||
#define ES8311_CLK_MANAGER_REG08 0x08 /* lrck divider */
|
||||
/*
|
||||
* SDP
|
||||
*/
|
||||
#define ES8311_SDPIN_REG09 0x09 /* dac serial digital port */
|
||||
#define ES8311_SDPOUT_REG0A 0x0A /* adc serial digital port */
|
||||
/*
|
||||
* SYSTEM
|
||||
*/
|
||||
#define ES8311_SYSTEM_REG0B 0x0B /* system */
|
||||
#define ES8311_SYSTEM_REG0C 0x0C /* system */
|
||||
#define ES8311_SYSTEM_REG0D 0x0D /* system, power up/down */
|
||||
#define ES8311_SYSTEM_REG0E 0x0E /* system, power up/down */
|
||||
#define ES8311_SYSTEM_REG0F 0x0F /* system, low power */
|
||||
#define ES8311_SYSTEM_REG10 0x10 /* system */
|
||||
#define ES8311_SYSTEM_REG11 0x11 /* system */
|
||||
#define ES8311_SYSTEM_REG12 0x12 /* system, Enable DAC */
|
||||
#define ES8311_SYSTEM_REG13 0x13 /* system */
|
||||
#define ES8311_SYSTEM_REG14 0x14 /* system, select DMIC, select analog pga gain */
|
||||
/*
|
||||
* ADC
|
||||
*/
|
||||
#define ES8311_ADC_REG15 0x15 /* ADC, adc ramp rate, dmic sense */
|
||||
#define ES8311_ADC_REG16 0x16 /* ADC */
|
||||
#define ES8311_ADC_REG17 0x17 /* ADC, volume */
|
||||
#define ES8311_ADC_REG18 0x18 /* ADC, alc enable and winsize */
|
||||
#define ES8311_ADC_REG19 0x19 /* ADC, alc maxlevel */
|
||||
#define ES8311_ADC_REG1A 0x1A /* ADC, alc automute */
|
||||
#define ES8311_ADC_REG1B 0x1B /* ADC, alc automute, adc hpf s1 */
|
||||
#define ES8311_ADC_REG1C 0x1C /* ADC, equalizer, hpf s2 */
|
||||
/*
|
||||
* DAC
|
||||
*/
|
||||
#define ES8311_DAC_REG31 0x31 /* DAC, mute */
|
||||
#define ES8311_DAC_REG32 0x32 /* DAC, volume */
|
||||
#define ES8311_DAC_REG33 0x33 /* DAC, offset */
|
||||
#define ES8311_DAC_REG34 0x34 /* DAC, drc enable, drc winsize */
|
||||
#define ES8311_DAC_REG35 0x35 /* DAC, drc maxlevel, minilevel */
|
||||
#define ES8311_DAC_REG37 0x37 /* DAC, ramprate */
|
||||
/*
|
||||
*GPIO
|
||||
*/
|
||||
#define ES8311_GPIO_REG44 0x44 /* GPIO, dac2adc for test */
|
||||
#define ES8311_GP_REG45 0x45 /* GP CONTROL */
|
||||
/*
|
||||
* CHIP
|
||||
*/
|
||||
#define ES8311_CHD1_REGFD 0xFD /* CHIP ID1 */
|
||||
#define ES8311_CHD2_REGFE 0xFE /* CHIP ID2 */
|
||||
#define ES8311_CHVER_REGFF 0xFF /* VERSION */
|
||||
#define ES8311_CHD1_REGFD 0xFD /* CHIP ID1 */
|
||||
|
||||
#define ES8311_MAX_REGISTER 0xFF
|
||||
|
||||
typedef enum {
|
||||
ES8311_MIC_GAIN_MIN = -1,
|
||||
ES8311_MIC_GAIN_0DB,
|
||||
ES8311_MIC_GAIN_6DB,
|
||||
ES8311_MIC_GAIN_12DB,
|
||||
ES8311_MIC_GAIN_18DB,
|
||||
ES8311_MIC_GAIN_24DB,
|
||||
ES8311_MIC_GAIN_30DB,
|
||||
ES8311_MIC_GAIN_36DB,
|
||||
ES8311_MIC_GAIN_42DB,
|
||||
ES8311_MIC_GAIN_MAX
|
||||
} es8311_mic_gain_t;
|
||||
|
||||
/*
|
||||
* @brief Initialize ES8311 codec chip
|
||||
*
|
||||
* @param codec_cfg configuration of ES8311
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t es8311_codec_init(audio_hal_codec_config_t *codec_cfg);
|
||||
|
||||
/**
|
||||
* @brief Deinitialize ES8311 codec chip
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t es8311_codec_deinit(void);
|
||||
|
||||
/**
|
||||
* @brief Control ES8311 codec chip
|
||||
*
|
||||
* @param mode codec mode
|
||||
* @param ctrl_state start or stop decode or encode progress
|
||||
*
|
||||
* @return
|
||||
* - ESP_FAIL Parameter error
|
||||
* - ESP_OK Success
|
||||
*/
|
||||
esp_err_t es8311_codec_ctrl_state(audio_hal_codec_mode_t mode, audio_hal_ctrl_t ctrl_state);
|
||||
|
||||
/**
|
||||
* @brief Configure ES8311 codec mode and I2S interface
|
||||
*
|
||||
* @param mode codec mode
|
||||
* @param iface I2S config
|
||||
*
|
||||
* @return
|
||||
* - ESP_FAIL Parameter error
|
||||
* - ESP_OK Success
|
||||
*/
|
||||
esp_err_t es8311_codec_config_i2s(audio_hal_codec_mode_t mode, audio_hal_codec_i2s_iface_t *iface);
|
||||
|
||||
/**
|
||||
* @brief Configure ES8311 DAC mute or not. Basically you can use this function to mute the output or unmute
|
||||
*
|
||||
* @param enable enable(1) or disable(0)
|
||||
*
|
||||
* @return
|
||||
* - ESP_FAIL Parameter error
|
||||
* - ESP_OK Success
|
||||
*/
|
||||
esp_err_t es8311_set_voice_mute(bool enable);
|
||||
|
||||
/**
|
||||
* @brief Set voice volume
|
||||
*
|
||||
* @param volume: voice volume (0~100)
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t es8311_codec_set_voice_volume(int volume);
|
||||
|
||||
/**
|
||||
* @brief Get voice volume
|
||||
*
|
||||
* @param[out] *volume: voice volume (0~100)
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t es8311_codec_get_voice_volume(int *volume);
|
||||
|
||||
/**
|
||||
* @brief Configure ES8311 I2S format
|
||||
*
|
||||
* @param mod: set ADC or DAC or both
|
||||
* @param cfg: ES8388 I2S format
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t es8311_config_fmt(es_i2s_fmt_t fmt);
|
||||
|
||||
/**
|
||||
* @brief Configure ES8311 data sample bits
|
||||
*
|
||||
* @param mode: set ADC or DAC or both
|
||||
* @param bit_per_sample: bit number of per sample
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t es8311_set_bits_per_sample(audio_hal_iface_bits_t bits);
|
||||
|
||||
/**
|
||||
* @brief Start ES8311 codec chip
|
||||
*
|
||||
* @param mode: set ADC or DAC or both
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t es8311_start(es_module_t mode);
|
||||
|
||||
/**
|
||||
* @brief Stop ES8311 codec chip
|
||||
*
|
||||
* @param mode: set ADC or DAC or both
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t es8311_stop(es_module_t mode);
|
||||
|
||||
/**
|
||||
* @brief Get ES8311 DAC mute status
|
||||
*
|
||||
* @return
|
||||
* - ESP_FAIL
|
||||
* - ESP_OK
|
||||
*/
|
||||
esp_err_t es8311_get_voice_mute(int *mute);
|
||||
|
||||
/**
|
||||
* @brief Set ES8311 mic gain
|
||||
*
|
||||
* @param gain db of mic gain
|
||||
*
|
||||
* @return
|
||||
* - ESP_FAIL Parameter error
|
||||
* - ESP_OK Success
|
||||
*/
|
||||
esp_err_t es8311_set_mic_gain(es8311_mic_gain_t gain_db);
|
||||
|
||||
/**
|
||||
* @brief Print all ES8311 registers
|
||||
*
|
||||
* @return
|
||||
* - void
|
||||
*/
|
||||
void es8311_read_all();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,494 +0,0 @@
|
||||
/*
|
||||
* ESPRESSIF MIT License
|
||||
*
|
||||
* Copyright (c) 2018 <ESPRESSIF SYSTEMS (SHANGHAI) PTE LTD>
|
||||
*
|
||||
* Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in which case,
|
||||
* it is free of charge, to any person obtaining a copy of this software and associated
|
||||
* documentation files (the "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or
|
||||
* substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "esp_log.h"
|
||||
#include "i2c_bus.h"
|
||||
#include "es8388.h"
|
||||
#include "bsp_i2c.h"
|
||||
|
||||
static const char *ES_TAG = "ES8388_DRIVER";
|
||||
static i2c_bus_handle_t i2c_handle;
|
||||
|
||||
#define ES_ASSERT(a, format, b, ...) \
|
||||
if ((a) != 0) { \
|
||||
ESP_LOGE(ES_TAG, format, ##__VA_ARGS__); \
|
||||
return b;\
|
||||
}
|
||||
|
||||
static esp_err_t es_write_reg(uint8_t slave_addr, uint8_t reg_add, uint8_t data)
|
||||
{
|
||||
return i2c_bus_write_byte(i2c_handle, reg_add, data);
|
||||
}
|
||||
|
||||
static esp_err_t es_read_reg(uint8_t reg_add, uint8_t *p_data)
|
||||
{
|
||||
return i2c_bus_read_byte(i2c_handle, reg_add, p_data);
|
||||
}
|
||||
|
||||
void es8388_read_all()
|
||||
{
|
||||
for (int i = 0; i < 50; i++) {
|
||||
uint8_t reg = 0;
|
||||
es_read_reg(i, ®);
|
||||
ets_printf("%x: %x\n", i, reg);
|
||||
}
|
||||
}
|
||||
|
||||
esp_err_t es8388_write_reg(uint8_t reg_add, uint8_t data)
|
||||
{
|
||||
return es_write_reg(ES8388_ADDR, reg_add, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure ES8388 ADC and DAC volume. Basicly you can consider this as ADC and DAC gain
|
||||
*
|
||||
* @param mode: set ADC or DAC or all
|
||||
* @param volume: -96 ~ 0 for example Es8388SetAdcDacVolume(ES_MODULE_ADC, 30, 6); means set ADC volume -30.5db
|
||||
* @param dot: whether include 0.5. for example Es8388SetAdcDacVolume(ES_MODULE_ADC, 30, 4); means set ADC volume -30db
|
||||
*
|
||||
* @return
|
||||
* - (-1) Parameter error
|
||||
* - (0) Success
|
||||
*/
|
||||
static int es8388_set_adc_dac_volume(int mode, int volume, int dot)
|
||||
{
|
||||
int res = 0;
|
||||
if ( volume < -96 || volume > 0 ) {
|
||||
ESP_LOGW(ES_TAG, "Warning: volume < -96! or > 0!\n");
|
||||
if (volume < -96)
|
||||
volume = -96;
|
||||
else
|
||||
volume = 0;
|
||||
}
|
||||
dot = (dot >= 5 ? 1 : 0);
|
||||
volume = (-volume << 1) + dot;
|
||||
if (mode == ES_MODULE_ADC || mode == ES_MODULE_ADC_DAC) {
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_ADCCONTROL8, volume);
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_ADCCONTROL9, volume); //ADC Right Volume=0db
|
||||
}
|
||||
if (mode == ES_MODULE_DAC || mode == ES_MODULE_ADC_DAC) {
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL5, volume);
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL4, volume);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Power Management
|
||||
*
|
||||
* @param mod: if ES_POWER_CHIP, the whole chip including ADC and DAC is enabled
|
||||
* @param enable: false to disable true to enable
|
||||
*
|
||||
* @return
|
||||
* - (-1) Error
|
||||
* - (0) Success
|
||||
*/
|
||||
esp_err_t es8388_start(es_module_t mode)
|
||||
{
|
||||
esp_err_t res = ESP_OK;
|
||||
uint8_t prev_data = 0, data = 0;
|
||||
es_read_reg(ES8388_DACCONTROL21, &prev_data);
|
||||
if (mode == ES_MODULE_LINE) {
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL16, 0x09); // 0x00 audio on LIN1&RIN1, 0x09 LIN2&RIN2 by pass enable
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL17, 0x50); // left DAC to left mixer enable and LIN signal to left mixer enable 0db : bupass enable
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL20, 0x50); // right DAC to right mixer enable and LIN signal to right mixer enable 0db : bupass enable
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL21, 0xC0); //enable adc
|
||||
} else {
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL21, 0x80); //enable dac
|
||||
}
|
||||
es_read_reg(ES8388_DACCONTROL21, &data);
|
||||
if (prev_data != data) {
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_CHIPPOWER, 0xF0); //start state machine
|
||||
// res |= es_write_reg(ES8388_ADDR, ES8388_CONTROL1, 0x16);
|
||||
// res |= es_write_reg(ES8388_ADDR, ES8388_CONTROL2, 0x50);
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_CHIPPOWER, 0x00); //start state machine
|
||||
}
|
||||
if (mode == ES_MODULE_ADC || mode == ES_MODULE_ADC_DAC || mode == ES_MODULE_LINE) {
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_ADCPOWER, 0x00); //power up adc and line in
|
||||
}
|
||||
if (mode == ES_MODULE_DAC || mode == ES_MODULE_ADC_DAC || mode == ES_MODULE_LINE) {
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_DACPOWER, 0x3c); //power up dac and line out
|
||||
res |= es8388_set_voice_mute(false);
|
||||
ESP_LOGD(ES_TAG, "es8388_start default is mode:%d", mode);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Power Management
|
||||
*
|
||||
* @param mod: if ES_POWER_CHIP, the whole chip including ADC and DAC is enabled
|
||||
* @param enable: false to disable true to enable
|
||||
*
|
||||
* @return
|
||||
* - (-1) Error
|
||||
* - (0) Success
|
||||
*/
|
||||
esp_err_t es8388_stop(es_module_t mode)
|
||||
{
|
||||
esp_err_t res = ESP_OK;
|
||||
if (mode == ES_MODULE_LINE) {
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL21, 0x80); //enable dac
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL16, 0x00); // 0x00 audio on LIN1&RIN1, 0x09 LIN2&RIN2
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL17, 0x90); // only left DAC to left mixer enable 0db
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL20, 0x90); // only right DAC to right mixer enable 0db
|
||||
return res;
|
||||
}
|
||||
if (mode == ES_MODULE_DAC || mode == ES_MODULE_ADC_DAC) {
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_DACPOWER, 0x00);
|
||||
res |= es8388_set_voice_mute(true); //res |= Es8388SetAdcDacVolume(ES_MODULE_DAC, -96, 5); // 0db
|
||||
//res |= es_write_reg(ES8388_ADDR, ES8388_DACPOWER, 0xC0); //power down dac and line out
|
||||
}
|
||||
if (mode == ES_MODULE_ADC || mode == ES_MODULE_ADC_DAC) {
|
||||
//res |= Es8388SetAdcDacVolume(ES_MODULE_ADC, -96, 5); // 0db
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_ADCPOWER, 0xFF); //power down adc and line in
|
||||
}
|
||||
if (mode == ES_MODULE_ADC_DAC) {
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL21, 0x9C); //disable mclk
|
||||
// res |= es_write_reg(ES8388_ADDR, ES8388_CONTROL1, 0x00);
|
||||
// res |= es_write_reg(ES8388_ADDR, ES8388_CONTROL2, 0x58);
|
||||
// res |= es_write_reg(ES8388_ADDR, ES8388_CHIPPOWER, 0xF3); //stop state machine
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Config I2s clock in MSATER mode
|
||||
*
|
||||
* @param cfg.sclkDiv: generate SCLK by dividing MCLK in MSATER mode
|
||||
* @param cfg.lclkDiv: generate LCLK by dividing MCLK in MSATER mode
|
||||
*
|
||||
* @return
|
||||
* - (-1) Error
|
||||
* - (0) Success
|
||||
*/
|
||||
esp_err_t es8388_i2s_config_clock(es_i2s_clock_t cfg)
|
||||
{
|
||||
esp_err_t res = ESP_OK;
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_MASTERMODE, cfg.sclk_div);
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_ADCCONTROL5, cfg.lclk_div); //ADCFsMode,singel SPEED,RATIO=256
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL2, cfg.lclk_div); //ADCFsMode,singel SPEED,RATIO=256
|
||||
return res;
|
||||
}
|
||||
|
||||
esp_err_t es8388_deinit(void)
|
||||
{
|
||||
int res = 0;
|
||||
res = es_write_reg(ES8388_ADDR, ES8388_CHIPPOWER, 0xFF); //reset and stop es8388
|
||||
i2c_bus_delete(i2c_handle);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
* - (-1) Error
|
||||
* - (0) Success
|
||||
*/
|
||||
esp_err_t es8388_init(audio_hal_codec_config_t *cfg)
|
||||
{
|
||||
int res = 0;
|
||||
|
||||
bsp_i2c_add_device(&i2c_handle, ES8388_ADDR);
|
||||
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL3, 0x04); // 0x04 mute/0x00 unmute&ramp;DAC unmute and disabled digital volume control soft ramp
|
||||
/* Chip Control and Power Management */
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_CONTROL2, 0x50);
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_CHIPPOWER, 0x00); //normal all and power up all
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_MASTERMODE, cfg->i2s_iface.mode); //CODEC IN I2S SLAVE MODE
|
||||
|
||||
/* dac */
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_DACPOWER, 0xC0); //disable DAC and disable Lout/Rout/1/2
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_CONTROL1, 0x12); //Enfr=0,Play&Record Mode,(0x17-both of mic&paly)
|
||||
// res |= es_write_reg(ES8388_ADDR, ES8388_CONTROL2, 0); //LPVrefBuf=0,Pdn_ana=0
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL1, 0x18);//1a 0x18:16bit iis , 0x00:24
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL2, 0x02); //DACFsMode,SINGLE SPEED; DACFsRatio,256
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL16, 0x00); // 0x00 audio on LIN1&RIN1, 0x09 LIN2&RIN2
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL17, 0x90); // only left DAC to left mixer enable 0db
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL20, 0x90); // only right DAC to right mixer enable 0db
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL21, 0x80); //set internal ADC and DAC use the same LRCK clock, ADC LRCK as internal LRCK
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL23, 0x00); //vroi=0
|
||||
res |= es8388_set_adc_dac_volume(ES_MODULE_DAC, 0, 0); // 0db
|
||||
int tmp = 0;
|
||||
if (AUDIO_HAL_DAC_OUTPUT_LINE2 == cfg->dac_output) {
|
||||
tmp = DAC_OUTPUT_LOUT1 | DAC_OUTPUT_ROUT1;
|
||||
} else if (AUDIO_HAL_DAC_OUTPUT_LINE1 == cfg->dac_output) {
|
||||
tmp = DAC_OUTPUT_LOUT2 | DAC_OUTPUT_ROUT2;
|
||||
} else {
|
||||
tmp = DAC_OUTPUT_LOUT1 | DAC_OUTPUT_LOUT2 | DAC_OUTPUT_ROUT1 | DAC_OUTPUT_ROUT2;
|
||||
}
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_DACPOWER, tmp); //0x3c Enable DAC and Enable Lout/Rout/1/2
|
||||
/* adc */
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_ADCPOWER, 0xFF);
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_ADCCONTROL1, 0xbb); // MIC Left and Right channel PGA gain
|
||||
tmp = 0;
|
||||
if (AUDIO_HAL_ADC_INPUT_LINE1 == cfg->adc_input) {
|
||||
tmp = ADC_INPUT_LINPUT1_RINPUT1;
|
||||
} else if (AUDIO_HAL_ADC_INPUT_LINE2 == cfg->adc_input) {
|
||||
tmp = ADC_INPUT_LINPUT2_RINPUT2;
|
||||
} else {
|
||||
tmp = ADC_INPUT_DIFFERENCE;
|
||||
}
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_ADCCONTROL2, tmp); //0x00 LINSEL & RINSEL, LIN1/RIN1 as ADC Input; DSSEL,use one DS Reg11; DSR, LINPUT1-RINPUT1
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_ADCCONTROL3, 0x02);
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_ADCCONTROL4, 0x0d); // Left/Right data, Left/Right justified mode, Bits length, I2S format
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_ADCCONTROL5, 0x02); //ADCFsMode,singel SPEED,RATIO=256
|
||||
//ALC for Microphone
|
||||
res |= es8388_set_adc_dac_volume(ES_MODULE_ADC, 0, 0); // 0db
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_ADCPOWER, 0x09); //Power on ADC, Enable LIN&RIN, Power off MICBIAS, set int1lp to low power mode
|
||||
|
||||
ESP_LOGI(ES_TAG, "init,out:%02x, in:%02x", cfg->dac_output, cfg->adc_input);
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure ES8388 I2S format
|
||||
*
|
||||
* @param mode: set ADC or DAC or all
|
||||
* @param bitPerSample: see Es8388I2sFmt
|
||||
*
|
||||
* @return
|
||||
* - (-1) Error
|
||||
* - (0) Success
|
||||
*/
|
||||
esp_err_t es8388_config_fmt(es_module_t mode, es_i2s_fmt_t fmt)
|
||||
{
|
||||
esp_err_t res = ESP_OK;
|
||||
uint8_t reg = 0;
|
||||
if (mode == ES_MODULE_ADC || mode == ES_MODULE_ADC_DAC) {
|
||||
res = es_read_reg(ES8388_ADCCONTROL4, ®);
|
||||
reg = reg & 0xfc;
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_ADCCONTROL4, reg | fmt);
|
||||
}
|
||||
if (mode == ES_MODULE_DAC || mode == ES_MODULE_ADC_DAC) {
|
||||
res = es_read_reg(ES8388_DACCONTROL1, ®);
|
||||
reg = reg & 0xf9;
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL1, reg | (fmt << 1));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param volume: 0 ~ 100
|
||||
*
|
||||
* @return
|
||||
* - (-1) Error
|
||||
* - (0) Success
|
||||
*/
|
||||
esp_err_t es8388_set_voice_volume(int volume)
|
||||
{
|
||||
esp_err_t res = ESP_OK;
|
||||
if (volume < 0)
|
||||
volume = 0;
|
||||
else if (volume > 100)
|
||||
volume = 100;
|
||||
volume /= 3;
|
||||
res = es_write_reg(ES8388_ADDR, ES8388_DACCONTROL24, volume);
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL25, volume);
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL26, 0);
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL27, 0);
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* volume
|
||||
*/
|
||||
esp_err_t es8388_get_voice_volume(int *volume)
|
||||
{
|
||||
esp_err_t res = ESP_OK;
|
||||
uint8_t reg = 0;
|
||||
res = es_read_reg(ES8388_DACCONTROL24, ®);
|
||||
if (res == ESP_FAIL) {
|
||||
*volume = 0;
|
||||
} else {
|
||||
*volume = reg;
|
||||
*volume *= 3;
|
||||
if (*volume == 99)
|
||||
*volume = 100;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure ES8388 data sample bits
|
||||
*
|
||||
* @param mode: set ADC or DAC or all
|
||||
* @param bitPerSample: see BitsLength
|
||||
*
|
||||
* @return
|
||||
* - (-1) Parameter error
|
||||
* - (0) Success
|
||||
*/
|
||||
esp_err_t es8388_set_bits_per_sample(es_module_t mode, es_bits_length_t bits_length)
|
||||
{
|
||||
esp_err_t res = ESP_OK;
|
||||
uint8_t reg = 0;
|
||||
int bits = (int)bits_length;
|
||||
|
||||
if (mode == ES_MODULE_ADC || mode == ES_MODULE_ADC_DAC) {
|
||||
res = es_read_reg(ES8388_ADCCONTROL4, ®);
|
||||
reg = reg & 0xe3;
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_ADCCONTROL4, reg | (bits << 2));
|
||||
}
|
||||
if (mode == ES_MODULE_DAC || mode == ES_MODULE_ADC_DAC) {
|
||||
res = es_read_reg(ES8388_DACCONTROL1, ®);
|
||||
reg = reg & 0xc7;
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL1, reg | (bits << 3));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure ES8388 DAC mute or not. Basically you can use this function to mute the output or unmute
|
||||
*
|
||||
* @param enable: enable or disable
|
||||
*
|
||||
* @return
|
||||
* - (-1) Parameter error
|
||||
* - (0) Success
|
||||
*/
|
||||
esp_err_t es8388_set_voice_mute(bool enable)
|
||||
{
|
||||
esp_err_t res = ESP_OK;
|
||||
uint8_t reg = 0;
|
||||
res = es_read_reg(ES8388_DACCONTROL3, ®);
|
||||
reg = reg & 0xFB;
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_DACCONTROL3, reg | (((int)enable) << 2));
|
||||
return res;
|
||||
}
|
||||
|
||||
esp_err_t es8388_get_voice_mute(void)
|
||||
{
|
||||
esp_err_t res = ESP_OK;
|
||||
uint8_t reg = 0;
|
||||
res = es_read_reg(ES8388_DACCONTROL3, ®);
|
||||
if (res == ESP_OK) {
|
||||
reg = (reg & 0x04) >> 2;
|
||||
}
|
||||
return res == ESP_OK ? reg : res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param gain: Config DAC Output
|
||||
*
|
||||
* @return
|
||||
* - (-1) Parameter error
|
||||
* - (0) Success
|
||||
*/
|
||||
esp_err_t es8388_config_dac_output(int output)
|
||||
{
|
||||
esp_err_t res;
|
||||
uint8_t reg = 0;
|
||||
res = es_read_reg(ES8388_DACPOWER, ®);
|
||||
reg = reg & 0xc3;
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_DACPOWER, reg | output);
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param gain: Config ADC input
|
||||
*
|
||||
* @return
|
||||
* - (-1) Parameter error
|
||||
* - (0) Success
|
||||
*/
|
||||
esp_err_t es8388_config_adc_input(es_adc_input_t input)
|
||||
{
|
||||
esp_err_t res;
|
||||
uint8_t reg = 0;
|
||||
res = es_read_reg(ES8388_ADCCONTROL2, ®);
|
||||
reg = reg & 0x0f;
|
||||
res |= es_write_reg(ES8388_ADDR, ES8388_ADCCONTROL2, reg | input);
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param gain: see es_mic_gain_t
|
||||
*
|
||||
* @return
|
||||
* - (-1) Parameter error
|
||||
* - (0) Success
|
||||
*/
|
||||
esp_err_t es8388_set_mic_gain(es_mic_gain_t gain)
|
||||
{
|
||||
esp_err_t res, gain_n;
|
||||
gain_n = (int)gain / 3;
|
||||
gain_n = (gain_n << 4) + gain_n;
|
||||
res = es_write_reg(ES8388_ADDR, ES8388_ADCCONTROL1, gain_n); //MIC PGA
|
||||
return res;
|
||||
}
|
||||
|
||||
int es8388_ctrl_state(audio_hal_codec_mode_t mode, audio_hal_ctrl_t ctrl_state)
|
||||
{
|
||||
int res = 0;
|
||||
int es_mode_t = 0;
|
||||
switch (mode) {
|
||||
case AUDIO_HAL_CODEC_MODE_ENCODE:
|
||||
es_mode_t = ES_MODULE_ADC;
|
||||
break;
|
||||
case AUDIO_HAL_CODEC_MODE_LINE_IN:
|
||||
es_mode_t = ES_MODULE_LINE;
|
||||
break;
|
||||
case AUDIO_HAL_CODEC_MODE_DECODE:
|
||||
es_mode_t = ES_MODULE_DAC;
|
||||
break;
|
||||
case AUDIO_HAL_CODEC_MODE_BOTH:
|
||||
es_mode_t = ES_MODULE_ADC_DAC;
|
||||
break;
|
||||
default:
|
||||
es_mode_t = ES_MODULE_DAC;
|
||||
ESP_LOGW(ES_TAG, "Codec mode not support, default is decode mode");
|
||||
break;
|
||||
}
|
||||
if (AUDIO_HAL_CTRL_STOP == ctrl_state) {
|
||||
res = es8388_stop(es_mode_t);
|
||||
} else {
|
||||
res = es8388_start(es_mode_t);
|
||||
ESP_LOGD(ES_TAG, "start default is decode mode:%d", es_mode_t);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
esp_err_t es8388_config_i2s(audio_hal_codec_mode_t mode, audio_hal_codec_i2s_iface_t *iface)
|
||||
{
|
||||
esp_err_t res = ESP_OK;
|
||||
int tmp = 0;
|
||||
res |= es8388_config_fmt(ES_MODULE_ADC_DAC, iface->fmt);
|
||||
if (iface->bits == AUDIO_HAL_BIT_LENGTH_16BITS) {
|
||||
tmp = BIT_LENGTH_16BITS;
|
||||
} else if (iface->bits == AUDIO_HAL_BIT_LENGTH_24BITS) {
|
||||
tmp = BIT_LENGTH_24BITS;
|
||||
} else {
|
||||
tmp = BIT_LENGTH_32BITS;
|
||||
}
|
||||
res |= es8388_set_bits_per_sample(ES_MODULE_ADC_DAC, tmp);
|
||||
return res;
|
||||
}
|
||||
@@ -1,302 +0,0 @@
|
||||
/*
|
||||
* ESPRESSIF MIT License
|
||||
*
|
||||
* Copyright (c) 2018 <ESPRESSIF SYSTEMS (SHANGHAI) PTE LTD>
|
||||
*
|
||||
* Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in which case,
|
||||
* it is free of charge, to any person obtaining a copy of this software and associated
|
||||
* documentation files (the "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or
|
||||
* substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __ES8388_H__
|
||||
#define __ES8388_H__
|
||||
|
||||
#include "esp_types.h"
|
||||
#include "audio_hal.h"
|
||||
#include "driver/i2c.h"
|
||||
#include "esxxx_common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* ES8388 address */
|
||||
#define ES8388_ADDR 0x20 /*!< 0x22:CE=1;0x20:CE=0*/
|
||||
|
||||
/* ES8388 register */
|
||||
#define ES8388_CONTROL1 0x00
|
||||
#define ES8388_CONTROL2 0x01
|
||||
|
||||
#define ES8388_CHIPPOWER 0x02
|
||||
|
||||
#define ES8388_ADCPOWER 0x03
|
||||
#define ES8388_DACPOWER 0x04
|
||||
|
||||
#define ES8388_CHIPLOPOW1 0x05
|
||||
#define ES8388_CHIPLOPOW2 0x06
|
||||
|
||||
#define ES8388_ANAVOLMANAG 0x07
|
||||
|
||||
#define ES8388_MASTERMODE 0x08
|
||||
/* ADC */
|
||||
#define ES8388_ADCCONTROL1 0x09
|
||||
#define ES8388_ADCCONTROL2 0x0a
|
||||
#define ES8388_ADCCONTROL3 0x0b
|
||||
#define ES8388_ADCCONTROL4 0x0c
|
||||
#define ES8388_ADCCONTROL5 0x0d
|
||||
#define ES8388_ADCCONTROL6 0x0e
|
||||
#define ES8388_ADCCONTROL7 0x0f
|
||||
#define ES8388_ADCCONTROL8 0x10
|
||||
#define ES8388_ADCCONTROL9 0x11
|
||||
#define ES8388_ADCCONTROL10 0x12
|
||||
#define ES8388_ADCCONTROL11 0x13
|
||||
#define ES8388_ADCCONTROL12 0x14
|
||||
#define ES8388_ADCCONTROL13 0x15
|
||||
#define ES8388_ADCCONTROL14 0x16
|
||||
/* DAC */
|
||||
#define ES8388_DACCONTROL1 0x17
|
||||
#define ES8388_DACCONTROL2 0x18
|
||||
#define ES8388_DACCONTROL3 0x19
|
||||
#define ES8388_DACCONTROL4 0x1a
|
||||
#define ES8388_DACCONTROL5 0x1b
|
||||
#define ES8388_DACCONTROL6 0x1c
|
||||
#define ES8388_DACCONTROL7 0x1d
|
||||
#define ES8388_DACCONTROL8 0x1e
|
||||
#define ES8388_DACCONTROL9 0x1f
|
||||
#define ES8388_DACCONTROL10 0x20
|
||||
#define ES8388_DACCONTROL11 0x21
|
||||
#define ES8388_DACCONTROL12 0x22
|
||||
#define ES8388_DACCONTROL13 0x23
|
||||
#define ES8388_DACCONTROL14 0x24
|
||||
#define ES8388_DACCONTROL15 0x25
|
||||
#define ES8388_DACCONTROL16 0x26
|
||||
#define ES8388_DACCONTROL17 0x27
|
||||
#define ES8388_DACCONTROL18 0x28
|
||||
#define ES8388_DACCONTROL19 0x29
|
||||
#define ES8388_DACCONTROL20 0x2a
|
||||
#define ES8388_DACCONTROL21 0x2b
|
||||
#define ES8388_DACCONTROL22 0x2c
|
||||
#define ES8388_DACCONTROL23 0x2d
|
||||
#define ES8388_DACCONTROL24 0x2e
|
||||
#define ES8388_DACCONTROL25 0x2f
|
||||
#define ES8388_DACCONTROL26 0x30
|
||||
#define ES8388_DACCONTROL27 0x31
|
||||
#define ES8388_DACCONTROL28 0x32
|
||||
#define ES8388_DACCONTROL29 0x33
|
||||
#define ES8388_DACCONTROL30 0x34
|
||||
|
||||
/**
|
||||
* @brief Initialize ES8388 codec chip
|
||||
*
|
||||
* @param cfg configuration of ES8388
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t es8388_init(audio_hal_codec_config_t *cfg);
|
||||
|
||||
/**
|
||||
* @brief Deinitialize ES8388 codec chip
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t es8388_deinit(void);
|
||||
|
||||
/**
|
||||
* @brief Configure ES8388 I2S format
|
||||
*
|
||||
* @param mod: set ADC or DAC or both
|
||||
* @param cfg: ES8388 I2S format
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t es8388_config_fmt(es_module_t mod, es_i2s_fmt_t cfg);
|
||||
|
||||
/**
|
||||
* @brief Configure I2s clock in MSATER mode
|
||||
*
|
||||
* @param cfg: set bits clock and WS clock
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t es8388_i2s_config_clock(es_i2s_clock_t cfg);
|
||||
|
||||
/**
|
||||
* @brief Configure ES8388 data sample bits
|
||||
*
|
||||
* @param mode: set ADC or DAC or both
|
||||
* @param bit_per_sample: bit number of per sample
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t es8388_set_bits_per_sample(es_module_t mode, es_bits_length_t bit_per_sample);
|
||||
|
||||
/**
|
||||
* @brief Start ES8388 codec chip
|
||||
*
|
||||
* @param mode: set ADC or DAC or both
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t es8388_start(es_module_t mode);
|
||||
|
||||
/**
|
||||
* @brief Stop ES8388 codec chip
|
||||
*
|
||||
* @param mode: set ADC or DAC or both
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t es8388_stop(es_module_t mode);
|
||||
|
||||
/**
|
||||
* @brief Set voice volume
|
||||
*
|
||||
* @param volume: voice volume (0~100)
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t es8388_set_voice_volume(int volume);
|
||||
|
||||
/**
|
||||
* @brief Get voice volume
|
||||
*
|
||||
* @param[out] *volume: voice volume (0~100)
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK
|
||||
* - ESP_FAIL
|
||||
*/
|
||||
esp_err_t es8388_get_voice_volume(int *volume);
|
||||
|
||||
/**
|
||||
* @brief Configure ES8388 DAC mute or not. Basically you can use this function to mute the output or unmute
|
||||
*
|
||||
* @param enable enable(1) or disable(0)
|
||||
*
|
||||
* @return
|
||||
* - ESP_FAIL Parameter error
|
||||
* - ESP_OK Success
|
||||
*/
|
||||
esp_err_t es8388_set_voice_mute(bool enable);
|
||||
|
||||
/**
|
||||
* @brief Get ES8388 DAC mute status
|
||||
*
|
||||
* @return
|
||||
* - ESP_FAIL Parameter error
|
||||
* - ESP_OK Success
|
||||
*/
|
||||
esp_err_t es8388_get_voice_mute(void);
|
||||
|
||||
/**
|
||||
* @brief Set ES8388 mic gain
|
||||
*
|
||||
* @param gain db of mic gain
|
||||
*
|
||||
* @return
|
||||
* - ESP_FAIL Parameter error
|
||||
* - ESP_OK Success
|
||||
*/
|
||||
esp_err_t es8388_set_mic_gain(es_mic_gain_t gain);
|
||||
|
||||
/**
|
||||
* @brief Set ES8388 adc input mode
|
||||
*
|
||||
* @param input adc input mode
|
||||
*
|
||||
* @return
|
||||
* - ESP_FAIL Parameter error
|
||||
* - ESP_OK Success
|
||||
*/
|
||||
esp_err_t es8388_config_adc_input(es_adc_input_t input);
|
||||
|
||||
/**
|
||||
* @brief Set ES8388 dac output mode
|
||||
*
|
||||
* @param output dac output mode
|
||||
*
|
||||
* @return
|
||||
* - ESP_FAIL Parameter error
|
||||
* - ESP_OK Success
|
||||
*/
|
||||
esp_err_t es8388_config_dac_output(es_dac_output_t output);
|
||||
|
||||
/**
|
||||
* @brief Write ES8388 register
|
||||
*
|
||||
* @param reg_add address of register
|
||||
* @param data data of register
|
||||
*
|
||||
* @return
|
||||
* - ESP_FAIL Parameter error
|
||||
* - ESP_OK Success
|
||||
*/
|
||||
esp_err_t es8388_write_reg(uint8_t reg_add, uint8_t data);
|
||||
|
||||
/**
|
||||
* @brief Print all ES8388 registers
|
||||
*
|
||||
* @return
|
||||
* - void
|
||||
*/
|
||||
void es8388_read_all();
|
||||
|
||||
/**
|
||||
* @brief Configure ES8388 codec mode and I2S interface
|
||||
*
|
||||
* @param mode codec mode
|
||||
* @param iface I2S config
|
||||
*
|
||||
* @return
|
||||
* - ESP_FAIL Parameter error
|
||||
* - ESP_OK Success
|
||||
*/
|
||||
esp_err_t es8388_config_i2s(audio_hal_codec_mode_t mode, audio_hal_codec_i2s_iface_t *iface);
|
||||
|
||||
/**
|
||||
* @brief Control ES8388 codec chip
|
||||
*
|
||||
* @param mode codec mode
|
||||
* @param ctrl_state start or stop decode or encode progress
|
||||
*
|
||||
* @return
|
||||
* - ESP_FAIL Parameter error
|
||||
* - ESP_OK Success
|
||||
*/
|
||||
esp_err_t es8388_ctrl_state(audio_hal_codec_mode_t mode, audio_hal_ctrl_t ctrl_state);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //__ES8388_H__
|
||||
@@ -1,136 +0,0 @@
|
||||
/*
|
||||
* ESPRESSIF MIT License
|
||||
*
|
||||
* Copyright (c) 2018 <ESPRESSIF SYSTEMS (SHANGHAI) PTE LTD>
|
||||
*
|
||||
* Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in which case,
|
||||
* it is free of charge, to any person obtaining a copy of this software and associated
|
||||
* documentation files (the "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or
|
||||
* substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _AUDIO_HAL_H_
|
||||
#define _AUDIO_HAL_H_
|
||||
|
||||
#define AUDIO_HAL_VOL_DEFAULT 60
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Select media hal codec mode
|
||||
*/
|
||||
typedef enum {
|
||||
AUDIO_HAL_CODEC_MODE_ENCODE = 1, /*!< select adc */
|
||||
AUDIO_HAL_CODEC_MODE_DECODE, /*!< select dac */
|
||||
AUDIO_HAL_CODEC_MODE_BOTH, /*!< select both adc and dac */
|
||||
AUDIO_HAL_CODEC_MODE_LINE_IN, /*!< set adc channel */
|
||||
} audio_hal_codec_mode_t;
|
||||
|
||||
/**
|
||||
* @brief Select adc channel for input mic signal
|
||||
*/
|
||||
typedef enum {
|
||||
AUDIO_HAL_ADC_INPUT_LINE1 = 0x00, /*!< mic input to adc channel 1 */
|
||||
AUDIO_HAL_ADC_INPUT_LINE2, /*!< mic input to adc channel 2 */
|
||||
AUDIO_HAL_ADC_INPUT_ALL, /*!< mic input to both channels of adc */
|
||||
AUDIO_HAL_ADC_INPUT_DIFFERENCE, /*!< mic input to adc difference channel */
|
||||
} audio_hal_adc_input_t;
|
||||
|
||||
/**
|
||||
* @brief Select channel for dac output
|
||||
*/
|
||||
typedef enum {
|
||||
AUDIO_HAL_DAC_OUTPUT_LINE1 = 0x00, /*!< dac output signal to channel 1 */
|
||||
AUDIO_HAL_DAC_OUTPUT_LINE2, /*!< dac output signal to channel 2 */
|
||||
AUDIO_HAL_DAC_OUTPUT_ALL, /*!< dac output signal to both channels */
|
||||
} audio_hal_dac_output_t;
|
||||
|
||||
/**
|
||||
* @brief Select operating mode i.e. start or stop for audio codec chip
|
||||
*/
|
||||
typedef enum {
|
||||
AUDIO_HAL_CTRL_STOP = 0x00, /*!< set stop mode */
|
||||
AUDIO_HAL_CTRL_START = 0x01, /*!< set start mode */
|
||||
} audio_hal_ctrl_t;
|
||||
|
||||
/**
|
||||
* @brief Select I2S interface operating mode i.e. master or slave for audio codec chip
|
||||
*/
|
||||
typedef enum {
|
||||
AUDIO_HAL_MODE_SLAVE = 0x00, /*!< set slave mode */
|
||||
AUDIO_HAL_MODE_MASTER = 0x01, /*!< set master mode */
|
||||
} audio_hal_iface_mode_t;
|
||||
|
||||
/**
|
||||
* @brief Select I2S interface samples per second
|
||||
*/
|
||||
typedef enum {
|
||||
AUDIO_HAL_08K_SAMPLES, /*!< set to 8k samples per second */
|
||||
AUDIO_HAL_11K_SAMPLES, /*!< set to 11.025k samples per second */
|
||||
AUDIO_HAL_16K_SAMPLES, /*!< set to 16k samples in per second */
|
||||
AUDIO_HAL_22K_SAMPLES, /*!< set to 22.050k samples per second */
|
||||
AUDIO_HAL_24K_SAMPLES, /*!< set to 24k samples in per second */
|
||||
AUDIO_HAL_32K_SAMPLES, /*!< set to 32k samples in per second */
|
||||
AUDIO_HAL_44K_SAMPLES, /*!< set to 44.1k samples per second */
|
||||
AUDIO_HAL_48K_SAMPLES, /*!< set to 48k samples per second */
|
||||
} audio_hal_iface_samples_t;
|
||||
|
||||
/**
|
||||
* @brief Select I2S interface number of bits per sample
|
||||
*/
|
||||
typedef enum {
|
||||
AUDIO_HAL_BIT_LENGTH_16BITS = 1, /*!< set 16 bits per sample */
|
||||
AUDIO_HAL_BIT_LENGTH_24BITS, /*!< set 24 bits per sample */
|
||||
AUDIO_HAL_BIT_LENGTH_32BITS, /*!< set 32 bits per sample */
|
||||
} audio_hal_iface_bits_t;
|
||||
|
||||
/**
|
||||
* @brief Select I2S interface format for audio codec chip
|
||||
*/
|
||||
typedef enum {
|
||||
AUDIO_HAL_I2S_NORMAL = 0, /*!< set normal I2S format */
|
||||
AUDIO_HAL_I2S_LEFT, /*!< set all left format */
|
||||
AUDIO_HAL_I2S_RIGHT, /*!< set all right format */
|
||||
AUDIO_HAL_I2S_DSP, /*!< set dsp/pcm format */
|
||||
} audio_hal_iface_format_t;
|
||||
|
||||
/**
|
||||
* @brief I2s interface configuration for audio codec chip
|
||||
*/
|
||||
typedef struct {
|
||||
audio_hal_iface_mode_t mode; /*!< audio codec chip mode */
|
||||
audio_hal_iface_format_t fmt; /*!< I2S interface format */
|
||||
audio_hal_iface_samples_t samples; /*!< I2S interface samples per second */
|
||||
audio_hal_iface_bits_t bits; /*!< i2s interface number of bits per sample */
|
||||
} audio_hal_codec_i2s_iface_t;
|
||||
|
||||
/**
|
||||
* @brief Configure media hal for initialization of audio codec chip
|
||||
*/
|
||||
typedef struct {
|
||||
audio_hal_adc_input_t adc_input; /*!< set adc channel */
|
||||
audio_hal_dac_output_t dac_output; /*!< set dac channel */
|
||||
audio_hal_codec_mode_t codec_mode; /*!< select codec mode: adc, dac or both */
|
||||
audio_hal_codec_i2s_iface_t i2s_iface; /*!< set I2S interface configuration */
|
||||
} audio_hal_codec_config_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //__AUDIO_HAL_H__
|
||||
@@ -1,188 +0,0 @@
|
||||
/*
|
||||
* ESPRESSIF MIT License
|
||||
*
|
||||
* Copyright (c) 2019 <ESPRESSIF SYSTEMS (SHANGHAI) CO., LTD>
|
||||
*
|
||||
* Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in which case,
|
||||
* it is free of charge, to any person obtaining a copy of this software and associated
|
||||
* documentation files (the "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished
|
||||
* to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or
|
||||
* substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _ESXXX_COMMON_H_
|
||||
#define _ESXXX_COMMON_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
BIT_LENGTH_MIN = -1,
|
||||
BIT_LENGTH_16BITS = 0x03,
|
||||
BIT_LENGTH_18BITS = 0x02,
|
||||
BIT_LENGTH_20BITS = 0x01,
|
||||
BIT_LENGTH_24BITS = 0x00,
|
||||
BIT_LENGTH_32BITS = 0x04,
|
||||
BIT_LENGTH_MAX,
|
||||
} es_bits_length_t;
|
||||
|
||||
typedef enum {
|
||||
MCLK_DIV_MIN = -1,
|
||||
MCLK_DIV_1 = 1,
|
||||
MCLK_DIV_2 = 2,
|
||||
MCLK_DIV_3 = 3,
|
||||
MCLK_DIV_4 = 4,
|
||||
MCLK_DIV_6 = 5,
|
||||
MCLK_DIV_8 = 6,
|
||||
MCLK_DIV_9 = 7,
|
||||
MCLK_DIV_11 = 8,
|
||||
MCLK_DIV_12 = 9,
|
||||
MCLK_DIV_16 = 10,
|
||||
MCLK_DIV_18 = 11,
|
||||
MCLK_DIV_22 = 12,
|
||||
MCLK_DIV_24 = 13,
|
||||
MCLK_DIV_33 = 14,
|
||||
MCLK_DIV_36 = 15,
|
||||
MCLK_DIV_44 = 16,
|
||||
MCLK_DIV_48 = 17,
|
||||
MCLK_DIV_66 = 18,
|
||||
MCLK_DIV_72 = 19,
|
||||
MCLK_DIV_5 = 20,
|
||||
MCLK_DIV_10 = 21,
|
||||
MCLK_DIV_15 = 22,
|
||||
MCLK_DIV_17 = 23,
|
||||
MCLK_DIV_20 = 24,
|
||||
MCLK_DIV_25 = 25,
|
||||
MCLK_DIV_30 = 26,
|
||||
MCLK_DIV_32 = 27,
|
||||
MCLK_DIV_34 = 28,
|
||||
MCLK_DIV_7 = 29,
|
||||
MCLK_DIV_13 = 30,
|
||||
MCLK_DIV_14 = 31,
|
||||
MCLK_DIV_MAX,
|
||||
} es_sclk_div_t;
|
||||
|
||||
typedef enum {
|
||||
LCLK_DIV_MIN = -1,
|
||||
LCLK_DIV_128 = 0,
|
||||
LCLK_DIV_192 = 1,
|
||||
LCLK_DIV_256 = 2,
|
||||
LCLK_DIV_384 = 3,
|
||||
LCLK_DIV_512 = 4,
|
||||
LCLK_DIV_576 = 5,
|
||||
LCLK_DIV_768 = 6,
|
||||
LCLK_DIV_1024 = 7,
|
||||
LCLK_DIV_1152 = 8,
|
||||
LCLK_DIV_1408 = 9,
|
||||
LCLK_DIV_1536 = 10,
|
||||
LCLK_DIV_2112 = 11,
|
||||
LCLK_DIV_2304 = 12,
|
||||
|
||||
LCLK_DIV_125 = 16,
|
||||
LCLK_DIV_136 = 17,
|
||||
LCLK_DIV_250 = 18,
|
||||
LCLK_DIV_272 = 19,
|
||||
LCLK_DIV_375 = 20,
|
||||
LCLK_DIV_500 = 21,
|
||||
LCLK_DIV_544 = 22,
|
||||
LCLK_DIV_750 = 23,
|
||||
LCLK_DIV_1000 = 24,
|
||||
LCLK_DIV_1088 = 25,
|
||||
LCLK_DIV_1496 = 26,
|
||||
LCLK_DIV_1500 = 27,
|
||||
LCLK_DIV_MAX,
|
||||
} es_lclk_div_t;
|
||||
|
||||
typedef enum {
|
||||
D2SE_PGA_GAIN_MIN = -1,
|
||||
D2SE_PGA_GAIN_DIS = 0,
|
||||
D2SE_PGA_GAIN_EN = 1,
|
||||
D2SE_PGA_GAIN_MAX = 2,
|
||||
} es_d2se_pga_t;
|
||||
|
||||
typedef enum {
|
||||
ADC_INPUT_MIN = -1,
|
||||
ADC_INPUT_LINPUT1_RINPUT1 = 0x00,
|
||||
ADC_INPUT_MIC1 = 0x05,
|
||||
ADC_INPUT_MIC2 = 0x06,
|
||||
ADC_INPUT_LINPUT2_RINPUT2 = 0x50,
|
||||
ADC_INPUT_DIFFERENCE = 0xf0,
|
||||
ADC_INPUT_MAX,
|
||||
} es_adc_input_t;
|
||||
|
||||
typedef enum {
|
||||
DAC_OUTPUT_MIN = -1,
|
||||
DAC_OUTPUT_LOUT1 = 0x04,
|
||||
DAC_OUTPUT_LOUT2 = 0x08,
|
||||
DAC_OUTPUT_SPK = 0x09,
|
||||
DAC_OUTPUT_ROUT1 = 0x10,
|
||||
DAC_OUTPUT_ROUT2 = 0x20,
|
||||
DAC_OUTPUT_ALL = 0x3c,
|
||||
DAC_OUTPUT_MAX,
|
||||
} es_dac_output_t;
|
||||
|
||||
typedef enum {
|
||||
MIC_GAIN_MIN = -1,
|
||||
MIC_GAIN_0DB = 0,
|
||||
MIC_GAIN_3DB = 3,
|
||||
MIC_GAIN_6DB = 6,
|
||||
MIC_GAIN_9DB = 9,
|
||||
MIC_GAIN_12DB = 12,
|
||||
MIC_GAIN_15DB = 15,
|
||||
MIC_GAIN_18DB = 18,
|
||||
MIC_GAIN_21DB = 21,
|
||||
MIC_GAIN_24DB = 24,
|
||||
MIC_GAIN_MAX,
|
||||
} es_mic_gain_t;
|
||||
|
||||
typedef enum {
|
||||
ES_MODULE_MIN = -1,
|
||||
ES_MODULE_ADC = 0x01,
|
||||
ES_MODULE_DAC = 0x02,
|
||||
ES_MODULE_ADC_DAC = 0x03,
|
||||
ES_MODULE_LINE = 0x04,
|
||||
ES_MODULE_MAX
|
||||
} es_module_t;
|
||||
|
||||
typedef enum {
|
||||
ES_MODE_MIN = -1,
|
||||
ES_MODE_SLAVE = 0x00,
|
||||
ES_MODE_MASTER = 0x01,
|
||||
ES_MODE_MAX,
|
||||
} es_mode_t;
|
||||
|
||||
typedef enum {
|
||||
ES_I2S_MIN = -1,
|
||||
ES_I2S_NORMAL = 0,
|
||||
ES_I2S_LEFT = 1,
|
||||
ES_I2S_RIGHT = 2,
|
||||
ES_I2S_DSP = 3,
|
||||
ES_I2S_MAX
|
||||
} es_i2s_fmt_t;
|
||||
|
||||
/**
|
||||
* @brief Configure ES8388 clock
|
||||
*/
|
||||
typedef struct {
|
||||
es_sclk_div_t sclk_div; /*!< bits clock divide */
|
||||
es_lclk_div_t lclk_div; /*!< WS clock divide */
|
||||
} es_i2s_clock_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,5 +0,0 @@
|
||||
idf_component_register(
|
||||
SRC_DIRS
|
||||
"."
|
||||
INCLUDE_DIRS
|
||||
"include" )
|
||||
@@ -1,481 +0,0 @@
|
||||
/**
|
||||
* @file i2c_bus.c
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2021-03-07
|
||||
*
|
||||
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/semphr.h"
|
||||
|
||||
#include "esp_log.h"
|
||||
#include "i2c_bus.h"
|
||||
|
||||
#define I2C_ACK_CHECK_EN 0x1 /*!< I2C master will check ack from slave*/
|
||||
#define I2C_ACK_CHECK_DIS 0x0 /*!< I2C master will not check ack from slave */
|
||||
#define I2C_BUS_FLG_DEFAULT (0)
|
||||
#define I2C_BUS_MASTER_BUF_LEN (0)
|
||||
#define I2C_BUS_MS_TO_WAIT (1000)
|
||||
#define I2C_BUS_TICKS_TO_WAIT (I2C_BUS_MS_TO_WAIT/portTICK_RATE_MS)
|
||||
#define I2C_BUS_MUTEX_TICKS_TO_WAIT (I2C_BUS_MS_TO_WAIT/portTICK_RATE_MS)
|
||||
|
||||
static const char *TAG = "i2c_bus";
|
||||
static i2c_bus_t s_i2c_bus[I2C_NUM_MAX];
|
||||
|
||||
#define I2C_BUS_CHECK(a, str, ret) if(!(a)) { \
|
||||
ESP_LOGE(TAG,"%s:%d (%s):%s", __FILE__, __LINE__, __FUNCTION__, str); \
|
||||
return (ret); \
|
||||
}
|
||||
|
||||
#define I2C_BUS_CHECK_GOTO(a, str, lable) if(!(a)) { \
|
||||
ESP_LOGE(TAG,"%s:%d (%s):%s", __FILE__, __LINE__, __FUNCTION__, str); \
|
||||
goto lable; \
|
||||
}
|
||||
|
||||
#define I2C_BUS_INIT_CHECK(is_init, ret) if(!is_init) { \
|
||||
ESP_LOGE(TAG,"%s:%d (%s):i2c_bus has not inited", __FILE__, __LINE__, __FUNCTION__); \
|
||||
return (ret); \
|
||||
}
|
||||
|
||||
#define I2C_BUS_MUTEX_TAKE(mutex, ret) if (!xSemaphoreTake(mutex, I2C_BUS_MUTEX_TICKS_TO_WAIT)) { \
|
||||
ESP_LOGE(TAG, "i2c_bus take mutex timeout, max wait = %d ms", I2C_BUS_MUTEX_TICKS_TO_WAIT); \
|
||||
return (ret); \
|
||||
}
|
||||
|
||||
#define I2C_BUS_MUTEX_TAKE_MAX_DELAY(mutex, ret) if (!xSemaphoreTake(mutex, portMAX_DELAY)) { \
|
||||
ESP_LOGE(TAG, "i2c_bus take mutex timeout, max wait = %d ms", portMAX_DELAY); \
|
||||
return (ret); \
|
||||
}
|
||||
|
||||
#define I2C_BUS_MUTEX_GIVE(mutex, ret) if (!xSemaphoreGive(mutex)) { \
|
||||
ESP_LOGE(TAG, "i2c_bus give mutex failed"); \
|
||||
return (ret); \
|
||||
}
|
||||
|
||||
static esp_err_t i2c_driver_reinit(i2c_port_t port, const i2c_config_t *conf);
|
||||
static esp_err_t i2c_driver_deinit(i2c_port_t port);
|
||||
static esp_err_t i2c_bus_write_reg8(i2c_bus_device_handle_t dev_handle, uint8_t mem_address, size_t data_len, const uint8_t *data);
|
||||
static esp_err_t i2c_bus_read_reg8(i2c_bus_device_handle_t dev_handle, uint8_t mem_address, size_t data_len, uint8_t *data);
|
||||
inline static bool i2c_config_compare(i2c_port_t port, const i2c_config_t *conf);
|
||||
/**************************************** Public Functions (Application level)*********************************************/
|
||||
|
||||
i2c_bus_handle_t i2c_bus_create(i2c_port_t port, const i2c_config_t *conf)
|
||||
{
|
||||
I2C_BUS_CHECK(port < I2C_NUM_MAX, "I2C port error", NULL);
|
||||
I2C_BUS_CHECK(conf != NULL, "pointer = NULL error", NULL);
|
||||
I2C_BUS_CHECK(conf->mode == I2C_MODE_MASTER, "i2c_bus only supports master mode", NULL);
|
||||
|
||||
if (s_i2c_bus[port].is_init) {
|
||||
/**if i2c_bus has been inited and configs not changed, return the handle directly**/
|
||||
if (i2c_config_compare(port, conf)) {
|
||||
ESP_LOGW(TAG, "i2c%d has been inited, return handle directly, ref_counter=%d", port, s_i2c_bus[port].ref_counter);
|
||||
return (i2c_bus_handle_t)&s_i2c_bus[port];
|
||||
}
|
||||
} else {
|
||||
s_i2c_bus[port].mutex = xSemaphoreCreateMutex();
|
||||
I2C_BUS_CHECK(s_i2c_bus[port].mutex != NULL, "i2c_bus xSemaphoreCreateMutex failed", NULL);
|
||||
s_i2c_bus[port].ref_counter = 0;
|
||||
}
|
||||
|
||||
esp_err_t ret = i2c_driver_reinit(port, conf);
|
||||
I2C_BUS_CHECK(ret == ESP_OK, "init error", NULL);
|
||||
s_i2c_bus[port].conf_active = *conf;
|
||||
s_i2c_bus[port].i2c_port = port;
|
||||
return (i2c_bus_handle_t)&s_i2c_bus[port];
|
||||
}
|
||||
|
||||
esp_err_t i2c_bus_delete(i2c_bus_handle_t *p_bus)
|
||||
{
|
||||
I2C_BUS_CHECK(p_bus != NULL && *p_bus != NULL, "pointer = NULL error", ESP_ERR_INVALID_ARG);
|
||||
i2c_bus_t *i2c_bus = (i2c_bus_t *)(*p_bus);
|
||||
I2C_BUS_INIT_CHECK(i2c_bus->is_init, ESP_FAIL);
|
||||
I2C_BUS_MUTEX_TAKE_MAX_DELAY(i2c_bus->mutex, ESP_ERR_TIMEOUT);
|
||||
|
||||
/** if ref_counter == 0, de-init the bus**/
|
||||
if ((i2c_bus->ref_counter) > 0) {
|
||||
ESP_LOGW(TAG, "i2c%d is also handled by others ref_counter=%u, won't be de-inited", i2c_bus->i2c_port, i2c_bus->ref_counter);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t ret = i2c_driver_deinit(i2c_bus->i2c_port);
|
||||
I2C_BUS_CHECK(ret == ESP_OK, "deinit error", ret);
|
||||
vSemaphoreDelete(i2c_bus->mutex);
|
||||
*p_bus = NULL;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
uint8_t i2c_bus_scan(i2c_bus_handle_t bus_handle, uint8_t *buf, uint8_t num)
|
||||
{
|
||||
I2C_BUS_CHECK(bus_handle != NULL, "Handle error", 0);
|
||||
i2c_bus_t *i2c_bus = (i2c_bus_t *)bus_handle;
|
||||
I2C_BUS_INIT_CHECK(i2c_bus->is_init, 0);
|
||||
uint8_t device_count = 0;
|
||||
I2C_BUS_MUTEX_TAKE_MAX_DELAY(i2c_bus->mutex, 0);
|
||||
for (uint8_t dev_address = 1; dev_address < 127; dev_address++) {
|
||||
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
|
||||
i2c_master_start(cmd);
|
||||
i2c_master_write_byte(cmd, (dev_address << 1) | I2C_MASTER_WRITE, I2C_ACK_CHECK_EN);
|
||||
i2c_master_stop(cmd);
|
||||
esp_err_t ret = i2c_master_cmd_begin(i2c_bus->i2c_port, cmd, I2C_BUS_TICKS_TO_WAIT);
|
||||
|
||||
if (ret == ESP_OK) {
|
||||
ESP_LOGI(TAG, "found i2c device address = 0x%02x", dev_address);
|
||||
if (buf != NULL && device_count < num) {
|
||||
*(buf + device_count) = dev_address;
|
||||
}
|
||||
device_count++;
|
||||
}
|
||||
|
||||
i2c_cmd_link_delete(cmd);
|
||||
}
|
||||
I2C_BUS_MUTEX_GIVE(i2c_bus->mutex, 0);
|
||||
return device_count;
|
||||
}
|
||||
|
||||
uint32_t i2c_bus_get_current_clk_speed(i2c_bus_handle_t bus_handle)
|
||||
{
|
||||
I2C_BUS_CHECK(bus_handle != NULL, "Null Bus Handle", 0);
|
||||
i2c_bus_t *i2c_bus = (i2c_bus_t *)bus_handle;
|
||||
I2C_BUS_INIT_CHECK(i2c_bus->is_init, 0);
|
||||
return i2c_bus->conf_active.master.clk_speed;
|
||||
}
|
||||
|
||||
uint8_t i2c_bus_get_created_device_num(i2c_bus_handle_t bus_handle)
|
||||
{
|
||||
I2C_BUS_CHECK(bus_handle != NULL, "Null Bus Handle", 0);
|
||||
i2c_bus_t *i2c_bus = (i2c_bus_t *)bus_handle;
|
||||
I2C_BUS_INIT_CHECK(i2c_bus->is_init, 0);
|
||||
return i2c_bus->ref_counter;
|
||||
}
|
||||
|
||||
i2c_bus_device_handle_t i2c_bus_device_create(i2c_bus_handle_t bus_handle, uint8_t dev_addr, uint32_t clk_speed)
|
||||
{
|
||||
I2C_BUS_CHECK(bus_handle != NULL, "Null Bus Handle", NULL);
|
||||
I2C_BUS_CHECK(clk_speed <= 400000, "clk_speed must <= 400000", NULL);
|
||||
i2c_bus_t *i2c_bus = (i2c_bus_t *)bus_handle;
|
||||
I2C_BUS_INIT_CHECK(i2c_bus->is_init, NULL);
|
||||
i2c_bus_device_t *i2c_device = calloc(1, sizeof(i2c_bus_device_t));
|
||||
I2C_BUS_CHECK(i2c_device != NULL, "calloc memory failed", NULL);
|
||||
I2C_BUS_MUTEX_TAKE_MAX_DELAY(i2c_bus->mutex, NULL);
|
||||
i2c_device->dev_addr = dev_addr;
|
||||
i2c_device->conf = i2c_bus->conf_active;
|
||||
|
||||
/*if clk_speed == 0, current active clock speed will be used, else set a specified value*/
|
||||
if (clk_speed != 0) {
|
||||
i2c_device->conf.master.clk_speed = clk_speed;
|
||||
}
|
||||
|
||||
i2c_device->i2c_bus = i2c_bus;
|
||||
i2c_bus->ref_counter++;
|
||||
I2C_BUS_MUTEX_GIVE(i2c_bus->mutex, NULL);
|
||||
return (i2c_bus_device_handle_t)i2c_device;
|
||||
}
|
||||
|
||||
esp_err_t i2c_bus_device_delete(i2c_bus_device_handle_t *p_dev_handle)
|
||||
{
|
||||
I2C_BUS_CHECK(p_dev_handle != NULL && *p_dev_handle != NULL, "Null Device Handle", ESP_ERR_INVALID_ARG);
|
||||
i2c_bus_device_t *i2c_device = (i2c_bus_device_t *)(*p_dev_handle);
|
||||
I2C_BUS_MUTEX_TAKE_MAX_DELAY(i2c_device->i2c_bus->mutex, ESP_ERR_TIMEOUT);
|
||||
i2c_device->i2c_bus->ref_counter--;
|
||||
I2C_BUS_MUTEX_GIVE(i2c_device->i2c_bus->mutex, ESP_FAIL);
|
||||
free(i2c_device);
|
||||
*p_dev_handle = NULL;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
uint8_t i2c_bus_device_get_address(i2c_bus_device_handle_t dev_handle)
|
||||
{
|
||||
I2C_BUS_CHECK(dev_handle != NULL, "device handle error", NULL_I2C_DEV_ADDR);
|
||||
i2c_bus_device_t *i2c_device = (i2c_bus_device_t *)dev_handle;
|
||||
return i2c_device->dev_addr;
|
||||
}
|
||||
|
||||
esp_err_t i2c_bus_read_bytes(i2c_bus_device_handle_t dev_handle, uint8_t mem_address, size_t data_len, uint8_t *data)
|
||||
{
|
||||
return i2c_bus_read_reg8(dev_handle, mem_address, data_len, data);
|
||||
}
|
||||
|
||||
esp_err_t i2c_bus_read_byte(i2c_bus_device_handle_t dev_handle, uint8_t mem_address, uint8_t *data)
|
||||
{
|
||||
return i2c_bus_read_reg8(dev_handle, mem_address, 1, data);
|
||||
}
|
||||
|
||||
esp_err_t i2c_bus_read_bit(i2c_bus_device_handle_t dev_handle, uint8_t mem_address, uint8_t bit_num, uint8_t *data)
|
||||
{
|
||||
uint8_t byte = 0;
|
||||
esp_err_t ret = i2c_bus_read_reg8(dev_handle, mem_address, 1, &byte);
|
||||
*data = byte & (1 << bit_num);
|
||||
*data = (*data != 0) ? 1 : 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
esp_err_t i2c_bus_read_bits(i2c_bus_device_handle_t dev_handle, uint8_t mem_address, uint8_t bit_start, uint8_t length, uint8_t *data)
|
||||
{
|
||||
uint8_t byte = 0;
|
||||
esp_err_t ret = i2c_bus_read_byte(dev_handle, mem_address, &byte);
|
||||
|
||||
if (ret != ESP_OK) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint8_t mask = ((1 << length) - 1) << (bit_start - length + 1);
|
||||
byte &= mask;
|
||||
byte >>= (bit_start - length + 1);
|
||||
*data = byte;
|
||||
return ret;
|
||||
}
|
||||
|
||||
esp_err_t i2c_bus_write_byte(i2c_bus_device_handle_t dev_handle, uint8_t mem_address, uint8_t data)
|
||||
{
|
||||
return i2c_bus_write_reg8(dev_handle, mem_address, 1, &data);
|
||||
}
|
||||
|
||||
esp_err_t i2c_bus_write_bytes(i2c_bus_device_handle_t dev_handle, uint8_t mem_address, size_t data_len, const uint8_t *data)
|
||||
{
|
||||
return i2c_bus_write_reg8(dev_handle, mem_address, data_len, data);
|
||||
}
|
||||
|
||||
esp_err_t i2c_bus_write_bit(i2c_bus_device_handle_t dev_handle, uint8_t mem_address, uint8_t bit_num, uint8_t data)
|
||||
{
|
||||
uint8_t byte = 0;
|
||||
esp_err_t ret = i2c_bus_read_byte(dev_handle, mem_address, &byte);
|
||||
|
||||
if (ret != ESP_OK) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
byte = (data != 0) ? (byte | (1 << bit_num)) : (byte & ~(1 << bit_num));
|
||||
return i2c_bus_write_byte(dev_handle, mem_address, byte);
|
||||
}
|
||||
|
||||
esp_err_t i2c_bus_write_bits(i2c_bus_device_handle_t dev_handle, uint8_t mem_address, uint8_t bit_start, uint8_t length, uint8_t data)
|
||||
{
|
||||
uint8_t byte = 0;
|
||||
esp_err_t ret = i2c_bus_read_byte(dev_handle, mem_address, &byte);
|
||||
|
||||
if (ret != ESP_OK) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint8_t mask = ((1 << length) - 1) << (bit_start - length + 1);
|
||||
data <<= (bit_start - length + 1); // shift data into correct position
|
||||
data &= mask; // zero all non-important bits in data
|
||||
byte &= ~(mask); // zero all important bits in existing byte
|
||||
byte |= data; // combine data with existing byte
|
||||
return i2c_bus_write_byte(dev_handle, mem_address, byte);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief I2C master send queued commands.
|
||||
* This function will trigger sending all queued commands.
|
||||
* The task will be blocked until all the commands have been sent out.
|
||||
* If I2C_BUS_DYNAMIC_CONFIG enable, i2c_bus will dynamically check configs and re-install i2c driver before each transfer,
|
||||
* hence multiple devices with different configs on a single bus can be supported.
|
||||
* @note
|
||||
* Only call this function in I2C master mode
|
||||
*
|
||||
* @param i2c_num I2C port number
|
||||
* @param cmd_handle I2C command handler
|
||||
* @param ticks_to_wait maximum wait ticks.
|
||||
* @param conf pointer to I2C parameter settings
|
||||
* @return esp_err_t
|
||||
*/
|
||||
inline static esp_err_t i2c_master_cmd_begin_with_conf(i2c_port_t i2c_num, i2c_cmd_handle_t cmd_handle, TickType_t ticks_to_wait, const i2c_config_t *conf)
|
||||
{
|
||||
esp_err_t ret;
|
||||
#ifdef CONFIG_I2C_BUS_DYNAMIC_CONFIG
|
||||
/*if configs changed, i2c driver will reinit with new configuration*/
|
||||
if (conf != NULL && false == i2c_config_compare(i2c_num, conf)) {
|
||||
ret = i2c_driver_reinit(i2c_num, conf);
|
||||
I2C_BUS_CHECK(ret == ESP_OK, "reinit error", ret);
|
||||
s_i2c_bus[i2c_num].conf_active = *conf;
|
||||
}
|
||||
#endif
|
||||
ret = i2c_master_cmd_begin(i2c_num, cmd_handle, ticks_to_wait);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**************************************** Public Functions (Low level)*********************************************/
|
||||
|
||||
esp_err_t i2c_bus_cmd_begin(i2c_bus_device_handle_t dev_handle, i2c_cmd_handle_t cmd)
|
||||
{
|
||||
I2C_BUS_CHECK(dev_handle != NULL, "device handle error", ESP_ERR_INVALID_ARG);
|
||||
I2C_BUS_CHECK(cmd != NULL, "I2C command error", ESP_ERR_INVALID_ARG);
|
||||
i2c_bus_device_t *i2c_device = (i2c_bus_device_t *)dev_handle;
|
||||
I2C_BUS_INIT_CHECK(i2c_device->i2c_bus->is_init, ESP_ERR_INVALID_STATE);
|
||||
I2C_BUS_MUTEX_TAKE(i2c_device->i2c_bus->mutex, ESP_ERR_TIMEOUT);
|
||||
esp_err_t ret = i2c_master_cmd_begin_with_conf(i2c_device->i2c_bus->i2c_port, cmd, I2C_BUS_TICKS_TO_WAIT, &i2c_device->conf);
|
||||
I2C_BUS_MUTEX_GIVE(i2c_device->i2c_bus->mutex, ESP_FAIL);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static esp_err_t i2c_bus_read_reg8(i2c_bus_device_handle_t dev_handle, uint8_t mem_address, size_t data_len, uint8_t *data)
|
||||
{
|
||||
I2C_BUS_CHECK(dev_handle != NULL, "device handle error", ESP_ERR_INVALID_ARG);
|
||||
I2C_BUS_CHECK(data != NULL, "data pointer error", ESP_ERR_INVALID_ARG);
|
||||
i2c_bus_device_t *i2c_device = (i2c_bus_device_t *)dev_handle;
|
||||
I2C_BUS_INIT_CHECK(i2c_device->i2c_bus->is_init, ESP_ERR_INVALID_STATE);
|
||||
I2C_BUS_MUTEX_TAKE(i2c_device->i2c_bus->mutex, ESP_ERR_TIMEOUT);
|
||||
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
|
||||
|
||||
if (mem_address != NULL_I2C_MEM_ADDR) {
|
||||
i2c_master_start(cmd);
|
||||
i2c_master_write_byte(cmd, (i2c_device->dev_addr << 1) | I2C_MASTER_WRITE, I2C_ACK_CHECK_EN);
|
||||
i2c_master_write_byte(cmd, mem_address, I2C_ACK_CHECK_EN);
|
||||
}
|
||||
|
||||
i2c_master_start(cmd);
|
||||
i2c_master_write_byte(cmd, (i2c_device->dev_addr << 1) | I2C_MASTER_READ, I2C_ACK_CHECK_EN);
|
||||
i2c_master_read(cmd, data, data_len, I2C_MASTER_LAST_NACK);
|
||||
i2c_master_stop(cmd);
|
||||
esp_err_t ret = i2c_master_cmd_begin_with_conf(i2c_device->i2c_bus->i2c_port, cmd, I2C_BUS_TICKS_TO_WAIT, &i2c_device->conf);
|
||||
i2c_cmd_link_delete(cmd);
|
||||
I2C_BUS_MUTEX_GIVE(i2c_device->i2c_bus->mutex, ESP_FAIL);
|
||||
return ret;
|
||||
}
|
||||
|
||||
esp_err_t i2c_bus_read_reg16(i2c_bus_device_handle_t dev_handle, uint16_t mem_address, size_t data_len, uint8_t *data)
|
||||
{
|
||||
I2C_BUS_CHECK(dev_handle != NULL, "device handle error", ESP_ERR_INVALID_ARG);
|
||||
I2C_BUS_CHECK(data != NULL, "data pointer error", ESP_ERR_INVALID_ARG);
|
||||
i2c_bus_device_t *i2c_device = (i2c_bus_device_t *)dev_handle;
|
||||
I2C_BUS_INIT_CHECK(i2c_device->i2c_bus->is_init, ESP_ERR_INVALID_STATE);
|
||||
uint8_t memAddress8[2];
|
||||
memAddress8[0] = (uint8_t)((mem_address >> 8) & 0x00FF);
|
||||
memAddress8[1] = (uint8_t)(mem_address & 0x00FF);
|
||||
I2C_BUS_MUTEX_TAKE(i2c_device->i2c_bus->mutex, ESP_ERR_TIMEOUT);
|
||||
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
|
||||
|
||||
if (mem_address != NULL_I2C_MEM_ADDR) {
|
||||
i2c_master_start(cmd);
|
||||
i2c_master_write_byte(cmd, (i2c_device->dev_addr << 1) | I2C_MASTER_WRITE, I2C_ACK_CHECK_EN);
|
||||
i2c_master_write(cmd, memAddress8, 2, I2C_ACK_CHECK_EN);
|
||||
}
|
||||
|
||||
i2c_master_start(cmd);
|
||||
i2c_master_write_byte(cmd, (i2c_device->dev_addr << 1) | I2C_MASTER_READ, I2C_ACK_CHECK_EN);
|
||||
i2c_master_read(cmd, data, data_len, I2C_MASTER_LAST_NACK);
|
||||
i2c_master_stop(cmd);
|
||||
esp_err_t ret = i2c_master_cmd_begin_with_conf(i2c_device->i2c_bus->i2c_port, cmd, I2C_BUS_TICKS_TO_WAIT, &i2c_device->conf);
|
||||
i2c_cmd_link_delete(cmd);
|
||||
I2C_BUS_MUTEX_GIVE(i2c_device->i2c_bus->mutex, ESP_FAIL);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static esp_err_t i2c_bus_write_reg8(i2c_bus_device_handle_t dev_handle, uint8_t mem_address, size_t data_len, const uint8_t *data)
|
||||
{
|
||||
I2C_BUS_CHECK(dev_handle != NULL, "device handle error", ESP_ERR_INVALID_ARG);
|
||||
I2C_BUS_CHECK(data != NULL, "data pointer error", ESP_ERR_INVALID_ARG);
|
||||
i2c_bus_device_t *i2c_device = (i2c_bus_device_t *)dev_handle;
|
||||
I2C_BUS_INIT_CHECK(i2c_device->i2c_bus->is_init, ESP_ERR_INVALID_STATE);
|
||||
I2C_BUS_MUTEX_TAKE(i2c_device->i2c_bus->mutex, ESP_ERR_TIMEOUT);
|
||||
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
|
||||
i2c_master_start(cmd);
|
||||
i2c_master_write_byte(cmd, (i2c_device->dev_addr << 1) | I2C_MASTER_WRITE, I2C_ACK_CHECK_EN);
|
||||
|
||||
if (mem_address != NULL_I2C_MEM_ADDR) {
|
||||
i2c_master_write_byte(cmd, mem_address, I2C_ACK_CHECK_EN);
|
||||
}
|
||||
|
||||
i2c_master_write(cmd, (uint8_t *)data, data_len, I2C_ACK_CHECK_EN);
|
||||
i2c_master_stop(cmd);
|
||||
esp_err_t ret = i2c_master_cmd_begin_with_conf(i2c_device->i2c_bus->i2c_port, cmd, I2C_BUS_TICKS_TO_WAIT, &i2c_device->conf);
|
||||
i2c_cmd_link_delete(cmd);
|
||||
I2C_BUS_MUTEX_GIVE(i2c_device->i2c_bus->mutex, ESP_FAIL);
|
||||
return ret;
|
||||
}
|
||||
|
||||
esp_err_t i2c_bus_write_reg16(i2c_bus_device_handle_t dev_handle, uint16_t mem_address, size_t data_len, const uint8_t *data)
|
||||
{
|
||||
I2C_BUS_CHECK(dev_handle != NULL, "device handle error", ESP_ERR_INVALID_ARG);
|
||||
I2C_BUS_CHECK(data != NULL, "data pointer error", ESP_ERR_INVALID_ARG);
|
||||
i2c_bus_device_t *i2c_device = (i2c_bus_device_t *)dev_handle;
|
||||
I2C_BUS_INIT_CHECK(i2c_device->i2c_bus->is_init, ESP_ERR_INVALID_STATE);
|
||||
uint8_t memAddress8[2];
|
||||
memAddress8[0] = (uint8_t)((mem_address >> 8) & 0x00FF);
|
||||
memAddress8[1] = (uint8_t)(mem_address & 0x00FF);
|
||||
I2C_BUS_MUTEX_TAKE(i2c_device->i2c_bus->mutex, ESP_ERR_TIMEOUT);
|
||||
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
|
||||
i2c_master_start(cmd);
|
||||
i2c_master_write_byte(cmd, (i2c_device->dev_addr << 1) | I2C_MASTER_WRITE, I2C_ACK_CHECK_EN);
|
||||
|
||||
if (mem_address != NULL_I2C_MEM_ADDR) {
|
||||
i2c_master_write(cmd, memAddress8, 2, I2C_ACK_CHECK_EN);
|
||||
}
|
||||
|
||||
i2c_master_write(cmd, (uint8_t *)data, data_len, I2C_ACK_CHECK_EN);
|
||||
i2c_master_stop(cmd);
|
||||
esp_err_t ret = i2c_master_cmd_begin_with_conf(i2c_device->i2c_bus->i2c_port, cmd, I2C_BUS_TICKS_TO_WAIT, &i2c_device->conf);
|
||||
i2c_cmd_link_delete(cmd);
|
||||
I2C_BUS_MUTEX_GIVE(i2c_device->i2c_bus->mutex, ESP_FAIL);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**************************************** Private Functions*********************************************/
|
||||
static esp_err_t i2c_driver_reinit(i2c_port_t port, const i2c_config_t *conf)
|
||||
{
|
||||
I2C_BUS_CHECK(port < I2C_NUM_MAX, "i2c port error", ESP_ERR_INVALID_ARG);
|
||||
I2C_BUS_CHECK(conf != NULL, "pointer = NULL error", ESP_ERR_INVALID_ARG);
|
||||
|
||||
if (s_i2c_bus[port].is_init) {
|
||||
i2c_driver_delete(port);
|
||||
s_i2c_bus[port].is_init = false;
|
||||
ESP_LOGI(TAG, "i2c%d bus deinited", port);
|
||||
}
|
||||
|
||||
esp_err_t ret = i2c_param_config(port, conf);
|
||||
I2C_BUS_CHECK(ret == ESP_OK, "i2c param config failed", ret);
|
||||
ret = i2c_driver_install(port, conf->mode, I2C_BUS_MASTER_BUF_LEN, I2C_BUS_MASTER_BUF_LEN, I2C_BUS_FLG_DEFAULT);
|
||||
I2C_BUS_CHECK(ret == ESP_OK, "i2c driver install failed", ret);
|
||||
s_i2c_bus[port].is_init = true;
|
||||
ESP_LOGD(TAG, "i2c%d bus inited", port);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t i2c_driver_deinit(i2c_port_t port)
|
||||
{
|
||||
I2C_BUS_CHECK(port < I2C_NUM_MAX, "i2c port error", ESP_ERR_INVALID_ARG);
|
||||
I2C_BUS_CHECK(s_i2c_bus[port].is_init == true, "i2c not inited", ESP_ERR_INVALID_STATE);
|
||||
i2c_driver_delete(port); //always return ESP_OK
|
||||
s_i2c_bus[port].is_init = false;
|
||||
ESP_LOGD(TAG,"i2c%d bus deinited",port);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief compare with active i2c_bus configuration
|
||||
*
|
||||
* @param port choose which i2c_port's configuration will be compared
|
||||
* @param conf new configuration
|
||||
* @return true new configuration is equal to active configuration
|
||||
* @return false new configuration is not equal to active configuration
|
||||
*/
|
||||
inline static bool i2c_config_compare(i2c_port_t port, const i2c_config_t *conf)
|
||||
{
|
||||
if (s_i2c_bus[port].conf_active.master.clk_speed == conf->master.clk_speed
|
||||
&& s_i2c_bus[port].conf_active.sda_io_num == conf->sda_io_num
|
||||
&& s_i2c_bus[port].conf_active.scl_io_num == conf->scl_io_num
|
||||
&& s_i2c_bus[port].conf_active.scl_pullup_en == conf->scl_pullup_en
|
||||
&& s_i2c_bus[port].conf_active.sda_pullup_en == conf->sda_pullup_en) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -1,317 +0,0 @@
|
||||
/**
|
||||
* @file i2c_bus.h
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2021-03-07
|
||||
*
|
||||
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef _I2C_BUS_H_
|
||||
#define _I2C_BUS_H_
|
||||
#include "driver/i2c.h"
|
||||
|
||||
#define NULL_I2C_MEM_ADDR 0xFF /*!< set mem_address to NULL_I2C_MEM_ADDR if i2c device has no internal address during read/write */
|
||||
#define NULL_I2C_DEV_ADDR 0xFF /*!< invalid i2c device address */
|
||||
typedef void *i2c_bus_handle_t; /*!< i2c bus handle */
|
||||
typedef void *i2c_bus_device_handle_t; /*!< i2c device handle */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
i2c_port_t i2c_port; /*!<I2C port number */
|
||||
bool is_init; /*if bus is initialized*/
|
||||
i2c_config_t conf_active; /*!<I2C active configuration */
|
||||
SemaphoreHandle_t mutex; /* mutex to achive thread-safe*/
|
||||
int32_t ref_counter; /*reference count*/
|
||||
} i2c_bus_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t dev_addr; /*device address*/
|
||||
i2c_config_t conf; /*!<I2C active configuration */
|
||||
i2c_bus_t *i2c_bus; /*!<I2C bus*/
|
||||
} i2c_bus_device_t;
|
||||
|
||||
/**************************************** Public Functions (Application level)*********************************************/
|
||||
|
||||
/**
|
||||
* @brief Create an I2C bus instance then return a handle if created successfully. Each I2C bus works in a singleton mode,
|
||||
* which means for an i2c port only one group parameter works. When i2c_bus_create is called more than one time for the
|
||||
* same i2c port, following parameter will override the previous one.
|
||||
*
|
||||
* @param port I2C port number
|
||||
* @param conf Pointer to I2C bus configuration
|
||||
* @return i2c_bus_handle_t Return the I2C bus handle if created successfully, return NULL if failed.
|
||||
*/
|
||||
i2c_bus_handle_t i2c_bus_create(i2c_port_t port, const i2c_config_t *conf);
|
||||
|
||||
/**
|
||||
* @brief Delete and release the I2C bus resource.
|
||||
*
|
||||
* @param p_bus_handle Point to the I2C bus handle, if delete succeed handle will set to NULL.
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Fail
|
||||
*/
|
||||
esp_err_t i2c_bus_delete(i2c_bus_handle_t *p_bus_handle);
|
||||
|
||||
/**
|
||||
* @brief Scan i2c devices attached on i2c bus
|
||||
*
|
||||
* @param bus_handle I2C bus handle
|
||||
* @param buf Pointer to a buffer to save devices' address, if NULL no address will be saved.
|
||||
* @param num Maximum number of addresses to save, invalid if buf set to NULL,
|
||||
* higer addresses will be discarded if num less-than the total number found on the I2C bus.
|
||||
* @return uint8_t Total number of devices found on the I2C bus
|
||||
*/
|
||||
uint8_t i2c_bus_scan(i2c_bus_handle_t bus_handle, uint8_t *buf, uint8_t num);
|
||||
|
||||
/**
|
||||
* @brief Get current active clock speed.
|
||||
*
|
||||
* @param bus_handle I2C bus handle
|
||||
* @return uint32_t current clock speed
|
||||
*/
|
||||
uint32_t i2c_bus_get_current_clk_speed(i2c_bus_handle_t bus_handle);
|
||||
|
||||
/**
|
||||
* @brief Get created device number of the bus.
|
||||
*
|
||||
* @param bus_handle I2C bus handle
|
||||
* @return uint8_t created device number of the bus
|
||||
*/
|
||||
uint8_t i2c_bus_get_created_device_num(i2c_bus_handle_t bus_handle);
|
||||
|
||||
/**
|
||||
* @brief Create an I2C device on specific bus.
|
||||
* Dynamic configuration must be enable to achieve multiple devices with different configs on a single bus.
|
||||
* menuconfig:Bus Options->I2C Bus Options->enable dynamic configuration
|
||||
*
|
||||
* @param bus_handle Point to the I2C bus handle
|
||||
* @param dev_addr i2c device address
|
||||
* @param clk_speed device specified clock frequency the i2c_bus will switch to during each transfer. 0 if use current bus speed.
|
||||
* @return i2c_bus_device_handle_t return a device handle if created successfully, return NULL if failed.
|
||||
*/
|
||||
i2c_bus_device_handle_t i2c_bus_device_create(i2c_bus_handle_t bus_handle, uint8_t dev_addr, uint32_t clk_speed);
|
||||
|
||||
/**
|
||||
* @brief Delete and release the I2C device resource, i2c_bus_device_delete should be used in pairs with i2c_bus_device_create.
|
||||
*
|
||||
* @param p_dev_handle Point to the I2C device handle, if delete succeed handle will set to NULL.
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Fail
|
||||
*/
|
||||
esp_err_t i2c_bus_device_delete(i2c_bus_device_handle_t *p_dev_handle);
|
||||
|
||||
/**
|
||||
* @brief Get device's I2C address
|
||||
*
|
||||
* @param dev_handle I2C device handle
|
||||
* @return uint8_t I2C address, return NULL_I2C_DEV_ADDR if dev_handle is invalid.
|
||||
*/
|
||||
uint8_t i2c_bus_device_get_address(i2c_bus_device_handle_t dev_handle);
|
||||
|
||||
/**
|
||||
* @brief Read single byte from i2c device with 8-bit internal register/memory address
|
||||
*
|
||||
* @param dev_handle I2C device handle
|
||||
* @param mem_address The internal reg/mem address to read from, set to NULL_I2C_MEM_ADDR if no internal address.
|
||||
* @param data Pointer to a buffer to save the data that was read
|
||||
* @return esp_err_t
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_FAIL Sending command error, slave doesn't ACK the transfer.
|
||||
* - ESP_ERR_INVALID_STATE I2C driver not installed or not in master mode.
|
||||
* - ESP_ERR_TIMEOUT Operation timeout because the bus is busy.
|
||||
*/
|
||||
esp_err_t i2c_bus_read_byte(i2c_bus_device_handle_t dev_handle, uint8_t mem_address, uint8_t *data);
|
||||
|
||||
/**
|
||||
* @brief Read multiple bytes from i2c device with 8-bit internal register/memory address.
|
||||
* If internal reg/mem address is 16-bit, please refer i2c_bus_read_reg16
|
||||
*
|
||||
* @param dev_handle I2C device handle
|
||||
* @param mem_address The internal reg/mem address to read from, set to NULL_I2C_MEM_ADDR if no internal address.
|
||||
* @param data_len Number of bytes to read
|
||||
* @param data Pointer to a buffer to save the data that was read
|
||||
* @return esp_err_t
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_FAIL Sending command error, slave doesn't ACK the transfer.
|
||||
* - ESP_ERR_INVALID_STATE I2C driver not installed or not in master mode.
|
||||
* - ESP_ERR_TIMEOUT Operation timeout because the bus is busy.
|
||||
*/
|
||||
esp_err_t i2c_bus_read_bytes(i2c_bus_device_handle_t dev_handle, uint8_t mem_address, size_t data_len, uint8_t *data);
|
||||
|
||||
/**
|
||||
* @brief Read single bit of a byte from i2c device with 8-bit internal register/memory address
|
||||
*
|
||||
* @param dev_handle I2C device handle
|
||||
* @param mem_address The internal reg/mem address to read from, set to NULL_I2C_MEM_ADDR if no internal address.
|
||||
* @param bit_num The bit number 0 - 7 to read
|
||||
* @param data Pointer to a buffer to save the data that was read. *data == 0 -> bit = 0, *data !=0 -> bit = 1.
|
||||
* @return esp_err_t
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_FAIL Sending command error, slave doesn't ACK the transfer.
|
||||
* - ESP_ERR_INVALID_STATE I2C driver not installed or not in master mode.
|
||||
* - ESP_ERR_TIMEOUT Operation timeout because the bus is busy.
|
||||
*/
|
||||
esp_err_t i2c_bus_read_bit(i2c_bus_device_handle_t dev_handle, uint8_t mem_address, uint8_t bit_num, uint8_t *data);
|
||||
|
||||
/**
|
||||
* @brief Read multiple bits of a byte from i2c device with 8-bit internal register/memory address
|
||||
*
|
||||
* @param dev_handle I2C device handle
|
||||
* @param mem_address The internal reg/mem address to read from, set to NULL_I2C_MEM_ADDR if no internal address.
|
||||
* @param bit_start The bit to start from, 0 - 7, MSB at 0
|
||||
* @param length The number of bits to read, 1 - 8
|
||||
* @param data Pointer to a buffer to save the data that was read
|
||||
* @return esp_err_t
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_FAIL Sending command error, slave doesn't ACK the transfer.
|
||||
* - ESP_ERR_INVALID_STATE I2C driver not installed or not in master mode.
|
||||
* - ESP_ERR_TIMEOUT Operation timeout because the bus is busy.
|
||||
*/
|
||||
esp_err_t i2c_bus_read_bits(i2c_bus_device_handle_t dev_handle, uint8_t mem_address, uint8_t bit_start, uint8_t length, uint8_t *data);
|
||||
|
||||
/**
|
||||
* @brief Write single byte to i2c device with 8-bit internal register/memory address
|
||||
*
|
||||
* @param dev_handle I2C device handle
|
||||
* @param mem_address The internal reg/mem address to write to, set to NULL_I2C_MEM_ADDR if no internal address.
|
||||
* @param data The byte to write.
|
||||
* @return esp_err_t
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_FAIL Sending command error, slave doesn't ACK the transfer.
|
||||
* - ESP_ERR_INVALID_STATE I2C driver not installed or not in master mode.
|
||||
* - ESP_ERR_TIMEOUT Operation timeout because the bus is busy.
|
||||
*/
|
||||
esp_err_t i2c_bus_write_byte(i2c_bus_device_handle_t dev_handle, uint8_t mem_address, uint8_t data);
|
||||
|
||||
/**
|
||||
* @brief Write multiple byte to i2c device with 8-bit internal register/memory address
|
||||
* If internal reg/mem address is 16-bit, please refer i2c_bus_write_reg16
|
||||
*
|
||||
* @param dev_handle I2C device handle
|
||||
* @param mem_address The internal reg/mem address to write to, set to NULL_I2C_MEM_ADDR if no internal address.
|
||||
* @param data_len Number of bytes to write
|
||||
* @param data Pointer to the bytes to write.
|
||||
* @return esp_err_t
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_FAIL Sending command error, slave doesn't ACK the transfer.
|
||||
* - ESP_ERR_INVALID_STATE I2C driver not installed or not in master mode.
|
||||
* - ESP_ERR_TIMEOUT Operation timeout because the bus is busy.
|
||||
*/
|
||||
esp_err_t i2c_bus_write_bytes(i2c_bus_device_handle_t dev_handle, uint8_t mem_address, size_t data_len, const uint8_t *data);
|
||||
|
||||
/**
|
||||
* @brief Write single bit of a byte to an i2c device with 8-bit internal register/memory address
|
||||
*
|
||||
* @param dev_handle I2C device handle
|
||||
* @param mem_address The internal reg/mem address to write to, set to NULL_I2C_MEM_ADDR if no internal address.
|
||||
* @param bit_num The bit number 0 - 7 to write
|
||||
* @param data The bit to write, data == 0 means set bit = 0, data !=0 means set bit = 1.
|
||||
* @return esp_err_t
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_FAIL Sending command error, slave doesn't ACK the transfer.
|
||||
* - ESP_ERR_INVALID_STATE I2C driver not installed or not in master mode.
|
||||
* - ESP_ERR_TIMEOUT Operation timeout because the bus is busy.
|
||||
*/
|
||||
esp_err_t i2c_bus_write_bit(i2c_bus_device_handle_t dev_handle, uint8_t mem_address, uint8_t bit_num, uint8_t data);
|
||||
|
||||
/**
|
||||
* @brief Write multiple bits of a byte to an i2c device with 8-bit internal register/memory address
|
||||
*
|
||||
* @param dev_handle I2C device handle
|
||||
* @param mem_address The internal reg/mem address to write to, set to NULL_I2C_MEM_ADDR if no internal address.
|
||||
* @param bit_start The bit to start from, 0 - 7, MSB at 0
|
||||
* @param length The number of bits to write, 1 - 8
|
||||
* @param data The bits to write.
|
||||
* @return esp_err_t
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_FAIL Sending command error, slave doesn't ACK the transfer.
|
||||
* - ESP_ERR_INVALID_STATE I2C driver not installed or not in master mode.
|
||||
* - ESP_ERR_TIMEOUT Operation timeout because the bus is busy.
|
||||
*/
|
||||
esp_err_t i2c_bus_write_bits(i2c_bus_device_handle_t dev_handle, uint8_t mem_address, uint8_t bit_start, uint8_t length, uint8_t data);
|
||||
|
||||
/**************************************** Public Functions (Low level)*********************************************/
|
||||
|
||||
/**
|
||||
* @brief I2C master send queued commands create by ``i2c_cmd_link_create`` .
|
||||
* This function will trigger sending all queued commands.
|
||||
* The task will be blocked until all the commands have been sent out.
|
||||
* If I2C_BUS_DYNAMIC_CONFIG enable, i2c_bus will dynamically check configs and re-install i2c driver before each transfer,
|
||||
* hence multiple devices with different configs on a single bus can be supported.
|
||||
* @note
|
||||
* Only call this function when ``i2c_bus_read/write_xx`` do not meet the requirements
|
||||
*
|
||||
* @param dev_handle I2C device handle
|
||||
* @param cmd I2C command handler
|
||||
* @return esp_err_t
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_FAIL Sending command error, slave doesn't ACK the transfer.
|
||||
* - ESP_ERR_INVALID_STATE I2C driver not installed or not in master mode.
|
||||
* - ESP_ERR_TIMEOUT Operation timeout because the bus is busy.
|
||||
*/
|
||||
esp_err_t i2c_bus_cmd_begin(i2c_bus_device_handle_t dev_handle, i2c_cmd_handle_t cmd);
|
||||
|
||||
/**
|
||||
* @brief Write date to an i2c device with 16-bit internal reg/mem address
|
||||
*
|
||||
* @param dev_handle I2C device handle
|
||||
* @param mem_address The internal 16-bit reg/mem address to write to, set to NULL_I2C_MEM_ADDR if no internal address.
|
||||
* @param data_len Number of bytes to write
|
||||
* @param data Pointer to the bytes to write.
|
||||
* @return esp_err_t
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_FAIL Sending command error, slave doesn't ACK the transfer.
|
||||
* - ESP_ERR_INVALID_STATE I2C driver not installed or not in master mode.
|
||||
* - ESP_ERR_TIMEOUT Operation timeout because the bus is busy.
|
||||
*/
|
||||
esp_err_t i2c_bus_write_reg16(i2c_bus_device_handle_t dev_handle, uint16_t mem_address, size_t data_len, const uint8_t *data);
|
||||
|
||||
/**
|
||||
* @brief Read date from i2c device with 16-bit internal reg/mem address
|
||||
*
|
||||
* @param dev_handle I2C device handle
|
||||
* @param mem_address The internal 16-bit reg/mem address to read from, set to NULL_I2C_MEM_ADDR if no internal address.
|
||||
* @param data_len Number of bytes to read
|
||||
* @param data Pointer to a buffer to save the data that was read
|
||||
* @return esp_err_t
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
* - ESP_FAIL Sending command error, slave doesn't ACK the transfer.
|
||||
* - ESP_ERR_INVALID_STATE I2C driver not installed or not in master mode.
|
||||
* - ESP_ERR_TIMEOUT Operation timeout because the bus is busy.
|
||||
*/
|
||||
esp_err_t i2c_bus_read_reg16(i2c_bus_device_handle_t dev_handle, uint16_t mem_address, size_t data_len, uint8_t *data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,15 +0,0 @@
|
||||
|
||||
idf_component_register(
|
||||
SRC_DIRS
|
||||
"icm42670"
|
||||
"touch_panel"
|
||||
INCLUDE_DIRS
|
||||
"icm42670/include"
|
||||
"touch_panel/include"
|
||||
REQUIRES
|
||||
bsp)
|
||||
|
||||
target_compile_options(${COMPONENT_LIB} PRIVATE
|
||||
-Wno-unused-variable
|
||||
-Wno-unused-function
|
||||
-Wno-incompatible-pointer-types)
|
||||
@@ -1,75 +0,0 @@
|
||||
/*
|
||||
* ________________________________________________________________________________________________________
|
||||
* Copyright (c) 2015-2015 InvenSense Inc. All rights reserved.
|
||||
*
|
||||
* This software, related documentation and any modifications thereto (collectively “Software”) is subject
|
||||
* to InvenSense and its licensors' intellectual property rights under U.S. and international copyright
|
||||
* and other intellectual property rights laws.
|
||||
*
|
||||
* InvenSense and its licensors retain all intellectual property and proprietary rights in and to the Software
|
||||
* and any use, reproduction, disclosure or distribution of the Software without an express license agreement
|
||||
* from InvenSense is strictly prohibited.
|
||||
*
|
||||
* EXCEPT AS OTHERWISE PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, THE SOFTWARE IS
|
||||
* PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
||||
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* EXCEPT AS OTHERWISE PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, IN NO EVENT SHALL
|
||||
* INVENSENSE BE LIABLE FOR ANY DIRECT, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
||||
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THE SOFTWARE.
|
||||
* ________________________________________________________________________________________________________
|
||||
*/
|
||||
|
||||
#include "Message.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static int msg_level;
|
||||
static inv_msg_printer_t msg_printer;
|
||||
|
||||
void inv_msg_printer_default(int level, const char * str, va_list ap)
|
||||
{
|
||||
#if !defined(__ICCARM__)
|
||||
const char * s[INV_MSG_LEVEL_MAX] = {
|
||||
"", // INV_MSG_LEVEL_OFF
|
||||
" [E] ", // INV_MSG_LEVEL_ERROR
|
||||
" [W] ", // INV_MSG_LEVEL_WARNING
|
||||
" [I] ", // INV_MSG_LEVEL_INFO
|
||||
" [V] ", // INV_MSG_LEVEL_VERBOSE
|
||||
" [D] ", // INV_MSG_LEVEL_DEBUG
|
||||
};
|
||||
|
||||
fprintf(stderr, "%s", s[level]);
|
||||
vfprintf(stderr, str, ap);
|
||||
fprintf(stderr, "\n");
|
||||
#else
|
||||
(void)level, (void)str, (void)ap;
|
||||
#endif
|
||||
}
|
||||
|
||||
void inv_msg_setup(int level, inv_msg_printer_t printer)
|
||||
{
|
||||
msg_level = level;
|
||||
if (level < INV_MSG_LEVEL_OFF)
|
||||
msg_level = INV_MSG_LEVEL_OFF;
|
||||
else if (level > INV_MSG_LEVEL_MAX)
|
||||
msg_level = INV_MSG_LEVEL_MAX;
|
||||
msg_printer = printer;
|
||||
}
|
||||
|
||||
void inv_msg(int level, const char * str, ...)
|
||||
{
|
||||
if(level && level <= msg_level && msg_printer) {
|
||||
va_list ap;
|
||||
va_start(ap, str);
|
||||
msg_printer(level, str, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
}
|
||||
|
||||
int inv_msg_get_level(void)
|
||||
{
|
||||
return msg_level;
|
||||
}
|
||||
@@ -1,169 +0,0 @@
|
||||
// Copyright 2020 Espressif Systems (Shanghai) Co. Ltd.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "stdio.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "esp_log.h"
|
||||
#include "bsp_i2c.h"
|
||||
#include "Message.h"
|
||||
#include "inv_imu_driver.h"
|
||||
|
||||
static const char *TAG = "icm42670";
|
||||
|
||||
|
||||
/*
|
||||
* Set of timers used throughout standalone applications
|
||||
*/
|
||||
|
||||
#define SENSOR_ODR_1600HZ 1600
|
||||
#define SENSOR_ODR_800HZ 800
|
||||
#define SENSOR_ODR_400HZ 400
|
||||
#define SENSOR_ODR_200HZ 200
|
||||
#define SENSOR_ODR_100HZ 100
|
||||
#define SENSOR_ODR_50HZ 50
|
||||
#define SENSOR_ODR_25HZ 25
|
||||
#define SENSOR_ODR_12_5HZ 12.5
|
||||
|
||||
|
||||
static i2c_bus_device_handle_t g_i2c_dev_handle;
|
||||
|
||||
static int platform_io_hal_read_reg(void *context, uint8_t reg, uint8_t *buf, uint32_t len)
|
||||
{
|
||||
return i2c_bus_read_bytes(g_i2c_dev_handle, reg, len, buf);
|
||||
}
|
||||
|
||||
static int platform_io_hal_write_reg(void *context, uint8_t reg, const uint8_t *buf, uint32_t len)
|
||||
{
|
||||
return i2c_bus_write_bytes(g_i2c_dev_handle, reg, len, buf);
|
||||
}
|
||||
|
||||
static void platform_delay_ms(uint32_t ms)
|
||||
{
|
||||
vTaskDelay(pdMS_TO_TICKS(ms));
|
||||
}
|
||||
|
||||
static void platform_delay_us(uint32_t us)
|
||||
{
|
||||
ets_delay_us(us);
|
||||
}
|
||||
|
||||
/*
|
||||
* Printer function for message facility
|
||||
*/
|
||||
static void msg_printer(int level, const char *str, va_list ap)
|
||||
{
|
||||
static char out_str[2560]; /* static to limit stack usage */
|
||||
uint32_t idx = 0;
|
||||
#define LOG_COLOR_BLACK "30"
|
||||
#define LOG_COLOR_RED "31"
|
||||
#define LOG_COLOR_GREEN "32"
|
||||
#define LOG_COLOR_BROWN "33"
|
||||
#define LOG_COLOR_BLUE "34"
|
||||
#define LOG_COLOR_PURPLE "35"
|
||||
#define LOG_COLOR_CYAN "36"
|
||||
#define LOG_COLOR(COLOR) "\033[0;" COLOR "m"
|
||||
#define LOG_BOLD(COLOR) "\033[1;" COLOR "m"
|
||||
#define LOG_RESET_COLOR "\033[0m"
|
||||
#define LOG_COLOR_E LOG_COLOR(LOG_COLOR_RED)
|
||||
#define LOG_COLOR_W LOG_COLOR(LOG_COLOR_BROWN)
|
||||
#define LOG_COLOR_I LOG_COLOR(LOG_COLOR_GREEN)
|
||||
const char *s[INV_MSG_LEVEL_MAX] = {
|
||||
"", // INV_MSG_LEVEL_OFF
|
||||
LOG_COLOR_E "[E]", // INV_MSG_LEVEL_ERROR
|
||||
LOG_COLOR_W "[W]", // INV_MSG_LEVEL_WARNING
|
||||
LOG_COLOR_I "[I]", // INV_MSG_LEVEL_INFO
|
||||
LOG_COLOR_BLUE "[V]", // INV_MSG_LEVEL_VERBOSE
|
||||
LOG_COLOR_BLUE "[D]", // INV_MSG_LEVEL_DEBUG
|
||||
};
|
||||
if (level >= INV_MSG_LEVEL_MAX) {
|
||||
printf("message error!\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
idx += snprintf(&out_str[idx], sizeof(out_str) - idx, "%s %s: ", s[level], TAG);
|
||||
if (idx >= (sizeof(out_str))) {
|
||||
return;
|
||||
}
|
||||
idx += vsnprintf(&out_str[idx], sizeof(out_str) - idx, str, ap);
|
||||
if (idx >= (sizeof(out_str))) {
|
||||
return;
|
||||
}
|
||||
idx += snprintf(&out_str[idx], sizeof(out_str) - idx, LOG_RESET_COLOR "\r\n");
|
||||
if (idx >= (sizeof(out_str))) {
|
||||
return;
|
||||
}
|
||||
printf(out_str);
|
||||
}
|
||||
|
||||
esp_err_t icm42670_init(void)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
if (NULL != g_i2c_dev_handle) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
bsp_i2c_add_device(&g_i2c_dev_handle, 0x68);
|
||||
|
||||
if (NULL == g_i2c_dev_handle) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
/* Setup message facility to see internal traces from FW */
|
||||
inv_msg_setup(INV_MSG_LEVEL_INFO, msg_printer);
|
||||
|
||||
inv_imu_set_serif(platform_io_hal_read_reg, platform_io_hal_write_reg);
|
||||
inv_imu_set_delay(platform_delay_ms, platform_delay_us);
|
||||
|
||||
float hw_rate = 0.0;
|
||||
|
||||
/* Init device */
|
||||
ret = inv_imu_initialize();
|
||||
|
||||
if (ret != INV_ERROR_SUCCESS) {
|
||||
INV_MSG(INV_MSG_LEVEL_ERROR, "Failed to initialize INV concise driver!");
|
||||
return ret;
|
||||
}
|
||||
|
||||
INV_MSG(INV_MSG_LEVEL_INFO, "IMU device successfully initialized");
|
||||
|
||||
// We may customize full scale range here.
|
||||
ret |= inv_imu_set_accel_fsr(ACCEL_CONFIG0_FS_SEL_4g);
|
||||
ret |= inv_imu_set_gyro_fsr(GYRO_CONFIG0_FS_SEL_2000dps);
|
||||
|
||||
// Below settings are required to configure and enable sensors.
|
||||
ret |= inv_imu_acc_enable();
|
||||
ret |= inv_imu_acc_set_rate(SENSOR_ODR_400HZ, 2, &hw_rate); //200Hz ODR, watermark: 2 packets.
|
||||
ret |= inv_imu_gyro_enable();
|
||||
ret |= inv_imu_gyro_set_rate(SENSOR_ODR_400HZ, 4, &hw_rate); //50Hz ODR, watermark 4.
|
||||
|
||||
if (ret != 0) {
|
||||
INV_LOG(SENSOR_LOG_LEVEL, "Feature enable Failed. Do nothing %d", ret);
|
||||
return ret;
|
||||
}
|
||||
INV_LOG(SENSOR_LOG_LEVEL, "HW odr setting %f ", hw_rate);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t icm42670_get_raw_data(AccDataPacket *accData,
|
||||
GyroDataPacket *gyroData,
|
||||
chip_temperature *imu_chip_temperature)
|
||||
{
|
||||
int ret = inv_data_handler(accData, gyroData, imu_chip_temperature, 1);
|
||||
if (0 != ret) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* ________________________________________________________________________________________________________
|
||||
* Copyright (c) 2015-2015 InvenSense Inc. All rights reserved.
|
||||
*
|
||||
* This software, related documentation and any modifications thereto (collectively “Software”) is subject
|
||||
* to InvenSense and its licensors' intellectual property rights under U.S. and international copyright
|
||||
* and other intellectual property rights laws.
|
||||
*
|
||||
* InvenSense and its licensors retain all intellectual property and proprietary rights in and to the Software
|
||||
* and any use, reproduction, disclosure or distribution of the Software without an express license agreement
|
||||
* from InvenSense is strictly prohibited.
|
||||
*
|
||||
* EXCEPT AS OTHERWISE PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, THE SOFTWARE IS
|
||||
* PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
||||
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* EXCEPT AS OTHERWISE PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, IN NO EVENT SHALL
|
||||
* INVENSENSE BE LIABLE FOR ANY DIRECT, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
||||
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THE SOFTWARE.
|
||||
* ________________________________________________________________________________________________________
|
||||
*/
|
||||
|
||||
#ifndef _INV_IDD_EXPORT_H_
|
||||
#define _INV_IDD_EXPORT_H_
|
||||
|
||||
#if defined(_WIN32)
|
||||
#if !defined(INV_EXPORT) && defined(INV_DO_DLL_EXPORT)
|
||||
#define INV_EXPORT __declspec(dllexport)
|
||||
#elif !defined(INV_EXPORT) && defined(INV_DO_DLL_IMPORT)
|
||||
#define INV_EXPORT __declspec(dllimport)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(INV_EXPORT)
|
||||
#define INV_EXPORT
|
||||
#endif
|
||||
|
||||
#endif /* _INV_IDD_EXPORT_H_ */
|
||||
@@ -1,181 +0,0 @@
|
||||
/*
|
||||
* ________________________________________________________________________________________________________
|
||||
* Copyright (c) 2015-2015 InvenSense Inc. All rights reserved.
|
||||
*
|
||||
* This software, related documentation and any modifications thereto (collectively “Software”) is subject
|
||||
* to InvenSense and its licensors' intellectual property rights under U.S. and international copyright
|
||||
* and other intellectual property rights laws.
|
||||
*
|
||||
* InvenSense and its licensors retain all intellectual property and proprietary rights in and to the Software
|
||||
* and any use, reproduction, disclosure or distribution of the Software without an express license agreement
|
||||
* from InvenSense is strictly prohibited.
|
||||
*
|
||||
* EXCEPT AS OTHERWISE PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, THE SOFTWARE IS
|
||||
* PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
||||
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* EXCEPT AS OTHERWISE PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, IN NO EVENT SHALL
|
||||
* INVENSENSE BE LIABLE FOR ANY DIRECT, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
||||
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THE SOFTWARE.
|
||||
* ________________________________________________________________________________________________________
|
||||
*/
|
||||
|
||||
/** @defgroup Message Message
|
||||
* @brief Utility functions to display and redirect diagnostic messages
|
||||
*
|
||||
* Use INV_MSG_DISABLE or INV_MSG_ENABLE define before including
|
||||
* this header to enable/disable messages for a compilation unit.
|
||||
*
|
||||
* Under Linux, Windows or Arduino, messages are enabled by default.
|
||||
* Use INV_MSG_DISABLE to disable them.
|
||||
*
|
||||
* Under orther environmment, message are disabled by default.
|
||||
* Use INV_MSG_ENABLE to disable them.
|
||||
*
|
||||
* @ingroup EmbUtils
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef _INV_MESSAGE_H_
|
||||
#define _INV_MESSAGE_H_
|
||||
|
||||
#include "InvExport.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
/** @brief For eMD target, disable log by default
|
||||
* If compile switch is set for a compilation unit
|
||||
* messages will be totally disabled by default
|
||||
*/
|
||||
#if !defined(__linux) && !defined(_WIN32) && !defined(ARDUINO)
|
||||
#define INV_MSG_DISABLE 1
|
||||
#endif
|
||||
|
||||
#define INV_MSG_ENABLE
|
||||
|
||||
/** @brief Allow to force enabling messaging using INV_MSG_ENABLE define */
|
||||
#ifdef INV_MSG_ENABLE
|
||||
#undef INV_MSG_DISABLE
|
||||
#endif
|
||||
|
||||
|
||||
/** @brief Helper macro for calling inv_msg()
|
||||
* If INV_MSG_DISABLE compile switch is set for a compilation unit
|
||||
* messages will be totally disabled
|
||||
*/
|
||||
#define INV_MSG(level, ...) _INV_MSG(level, __VA_ARGS__)
|
||||
|
||||
/** @brief Helper macro for calling inv_msg_setup()
|
||||
* If INV_MSG_DISABLE compile switch is set for a compilation unit
|
||||
* messages will be totally disabled
|
||||
*/
|
||||
#define INV_MSG_SETUP(level, printer) _INV_MSG_SETUP(level, printer)
|
||||
|
||||
/** @brief Helper macro for calling inv_msg_setup_level()
|
||||
* If INV_MSG_DISABLE compile switch is set for a compilation unit
|
||||
* messages will be totally disabled
|
||||
*/
|
||||
#define INV_MSG_SETUP_LEVEL(level) _INV_MSG_SETUP_LEVEL(level)
|
||||
|
||||
/** @brief Helper macro for calling inv_msg_setup_default()
|
||||
* If INV_MSG_DISABLE compile switch is set for a compilation unit
|
||||
* messages will be totally disabled
|
||||
*/
|
||||
#define INV_MSG_SETUP_DEFAULT() _INV_MSG_SETUP_DEFAULT()
|
||||
|
||||
/** @brief Return current level
|
||||
* @warning This macro may expand as a function call
|
||||
*/
|
||||
#define INV_MSG_LEVEL _INV_MSG_LEVEL
|
||||
|
||||
#if defined(INV_MSG_DISABLE)
|
||||
#define _INV_MSG(level, ...) (void)0
|
||||
#define _INV_MSG_SETUP(level, printer) (void)0
|
||||
#define _INV_MSG_SETUP_LEVEL(level) (void)0
|
||||
#define _INV_MSG_LEVEL INV_MSG_LEVEL_OFF
|
||||
#else
|
||||
#define _INV_MSG(level, ...) inv_msg(level, __VA_ARGS__)
|
||||
#define _INV_MSG_SETUP(level, printer) inv_msg_setup(level, printer)
|
||||
#define _INV_MSG_SETUP_LEVEL(level) inv_msg_setup(level, inv_msg_printer_default)
|
||||
#define _INV_MSG_SETUP_DEFAULT() inv_msg_setup_default()
|
||||
#define _INV_MSG_LEVEL inv_msg_get_level()
|
||||
#endif
|
||||
|
||||
/** @brief message level definition
|
||||
*/
|
||||
enum inv_msg_level {
|
||||
INV_MSG_LEVEL_OFF = 0,
|
||||
INV_MSG_LEVEL_ERROR,
|
||||
INV_MSG_LEVEL_WARNING,
|
||||
INV_MSG_LEVEL_INFO,
|
||||
INV_MSG_LEVEL_VERBOSE,
|
||||
INV_MSG_LEVEL_DEBUG,
|
||||
INV_MSG_LEVEL_MAX
|
||||
};
|
||||
|
||||
|
||||
/** @brief Prototype for print routine function
|
||||
*/
|
||||
typedef void (*inv_msg_printer_t)(int level, const char * str, va_list ap);
|
||||
|
||||
|
||||
/** @brief Set message level and printer function
|
||||
* @param[in] level only message above level will be passed to printer function
|
||||
* @param[in] printer user provided function in charge printing message
|
||||
* @return none
|
||||
*/
|
||||
void INV_EXPORT inv_msg_setup(int level, inv_msg_printer_t printer);
|
||||
|
||||
|
||||
/** @brief Default printer function that display messages to stderr
|
||||
* Function uses stdio. Care must be taken on embeded platfrom.
|
||||
* Function does nothing with IAR compiler.
|
||||
* @return none
|
||||
*/
|
||||
void INV_EXPORT inv_msg_printer_default(int level, const char * str, va_list ap);
|
||||
|
||||
/** @brief Set message level
|
||||
* Default printer function will be used.
|
||||
* @param[in] level only message above level will be passed to printer function
|
||||
* @return none
|
||||
*/
|
||||
static inline void inv_msg_setup_level(int level)
|
||||
{
|
||||
inv_msg_setup(level, inv_msg_printer_default);
|
||||
}
|
||||
|
||||
|
||||
/** @brief Set default message level and printer
|
||||
* @return none
|
||||
*/
|
||||
static inline void inv_msg_setup_default(void)
|
||||
{
|
||||
inv_msg_setup(INV_MSG_LEVEL_INFO, inv_msg_printer_default);
|
||||
}
|
||||
|
||||
/** @brief Return current message level
|
||||
* @return current message level
|
||||
*/
|
||||
int INV_EXPORT inv_msg_get_level(void);
|
||||
|
||||
/** @brief Display a message (through means of printer function)
|
||||
* @param[in] level for the message
|
||||
* @param[in] str message string
|
||||
* @param[in] ... optional arguments
|
||||
* @return none
|
||||
*/
|
||||
void INV_EXPORT inv_msg(int level, const char * str, ...);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* INV_MESSAGE_H_ */
|
||||
|
||||
/** @} */
|
||||
@@ -1,41 +0,0 @@
|
||||
|
||||
#ifndef _ICM_42670_H_
|
||||
#define _ICM_42670_H_
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "inv_imu_driver.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Init ICM-42670 IMU
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Success
|
||||
* - Others: Fail
|
||||
*/
|
||||
esp_err_t icm42670_init(void);
|
||||
|
||||
/**
|
||||
* @brief Get raw data from ICM-42670
|
||||
*
|
||||
* @param accData Pointer to accelerometer data
|
||||
* @param gyroData Pointor to gyroscope data
|
||||
* @param imu_chip_temperature Pointer to temperature data
|
||||
* @return
|
||||
* - ESP_OK: Success
|
||||
* - Others: Fail
|
||||
*/
|
||||
esp_err_t icm42670_get_raw_data(AccDataPacket *accData,
|
||||
GyroDataPacket *gyroData,
|
||||
chip_temperature *imu_chip_temperature);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,104 +0,0 @@
|
||||
/*
|
||||
* ________________________________________________________________________________________________________
|
||||
* Copyright (c) 2015-2015 InvenSense Inc. All rights reserved.
|
||||
*
|
||||
* This software, related documentation and any modifications thereto (collectively Software is subject
|
||||
* to InvenSense and its licensors' intellectual property rights under U.S. and international copyright
|
||||
* and other intellectual property rights laws.
|
||||
*
|
||||
* InvenSense and its licensors retain all intellectual property and proprietary rights in and to the Software
|
||||
* and any use, reproduction, disclosure or distribution of the Software without an express license agreement
|
||||
* from InvenSense is strictly prohibited.
|
||||
*
|
||||
* EXCEPT AS OTHERWISE PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, THE SOFTWARE IS
|
||||
* PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
||||
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* EXCEPT AS OTHERWISE PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, IN NO EVENT SHALL
|
||||
* INVENSENSE BE LIABLE FOR ANY DIRECT, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
||||
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THE SOFTWARE.
|
||||
* ________________________________________________________________________________________________________
|
||||
*/
|
||||
#ifndef _INV_ICM4N607_CONFIG_H_
|
||||
#define _INV_ICM4N607_CONFIG_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
#define FIFO_WM_MODE_EN 0 //1:fifo mode 0:dri mode
|
||||
#define IS_HIGH_RES_MODE 0 // 1: FIFO high resolution mode (20bits data format); 0: 16 bits data format;
|
||||
#define SPI_MODE_EN 1 //1:spi 0:i2c
|
||||
|
||||
#define DATA_FORMAT_DPS_G 1 // output sensor data with unit in default accel: m/s2 gyro: rad/s
|
||||
|
||||
#define SUPPORT_FIFO_TS 1 // support fifo timestamp by default
|
||||
#define DMP_POWERSAVE_FF 0 // disable apex power save mode for apex freefall for better performance
|
||||
#define DMP_POWERSAVE_PEDO 1 // setting apex power save mode for apex pedometer by default
|
||||
|
||||
#define SUPPORT_DELAY_US 1 // 1: platform supports delay in us; 0: platform does not support delay in ms.
|
||||
|
||||
#define SENSOR_REG_DUMP 0 // register dump control
|
||||
#define SENSOR_LOG_LEVEL 3 //INV_LOG_LEVEL_INFO
|
||||
#define SENSOR_LOG_TS_ONLY 1 //only print log sensor data TS , FIFO Timestampe is only available in fifo mode
|
||||
|
||||
|
||||
#define SENSOR_DIRECTION 0 // 0~7 sensorConvert map index below
|
||||
/* { { 1, 1, 1}, {0, 1, 2} },
|
||||
{ { -1, 1, 1}, {1, 0, 2} },
|
||||
{ { -1, -1, 1}, {0, 1, 2} },
|
||||
{ { 1, -1, 1}, {1, 0, 2} },
|
||||
{ { -1, 1, -1}, {0, 1, 2} },
|
||||
{ { 1, 1, -1}, {1, 0, 2} },
|
||||
{ { 1, -1, -1}, {0, 1, 2} },
|
||||
{ { -1, -1, -1}, {1, 0, 2} }, */
|
||||
|
||||
// For Xian the max FIFO size is 2048 Bytes; common FIFO package is 16 Bytes; so the max number of FIFO pakage is ~128.
|
||||
#define MAX_RECV_PACKET 128
|
||||
|
||||
|
||||
/* Initial WOM threshold to be applied to IMU in mg */
|
||||
#define WOM_THRESHOLD_INITIAL_MG 200
|
||||
|
||||
/* WOM threshold to be applied to IMU, ranges from 1 to 255, in 4mg unit */
|
||||
#define WOM_THRESHOLD WOM_THRESHOLD_INITIAL_MG/3
|
||||
#define WOM_THRESHOLD_X WOM_THRESHOLD
|
||||
#define WOM_THRESHOLD_Y WOM_THRESHOLD
|
||||
#define WOM_THRESHOLD_Z WOM_THRESHOLD
|
||||
|
||||
|
||||
#if 0
|
||||
/* customer board, need invoke system marco*/
|
||||
#define INV_LOG //define INV_LOG(loglevel,fmt,arg...) printf("ICM4n607: "fmt"\n",##arg)
|
||||
//#define INV_LOG(loglevel,fmt, args...) pr_err("INV icm4n607 "fmt"\n",##args)
|
||||
|
||||
//#define INV_MSG(loglevel,fmt, args...) pr_err("INV icm4n607 "fmt"\n",##args)
|
||||
#define EXIT(a) ;
|
||||
#else
|
||||
/* smart motion board*/
|
||||
#include "Message.h"
|
||||
#define INV_LOG INV_MSG
|
||||
#define EXIT(a) exit(a)
|
||||
#endif
|
||||
|
||||
/** @brief enumeration of serial interfaces available on IMU */
|
||||
typedef enum
|
||||
{
|
||||
UI_I2C,
|
||||
UI_SPI4,
|
||||
UI_SPI3
|
||||
} SERIAL_IF_TYPE_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif
|
||||
@@ -1,3 +0,0 @@
|
||||
idf_component_register(SRC_DIRS "."
|
||||
PRIV_INCLUDE_DIRS "."
|
||||
PRIV_REQUIRES unity test_utils icm42670)
|
||||
@@ -1,5 +0,0 @@
|
||||
#
|
||||
#Component Makefile
|
||||
#
|
||||
|
||||
COMPONENT_ADD_LDFLAGS = -Wl,--whole-archive -l$(COMPONENT_NAME) -Wl,--no-whole-archive
|
||||
@@ -1,273 +0,0 @@
|
||||
/*
|
||||
* ________________________________________________________________________________________________________
|
||||
* Copyright (c) 2017 InvenSense Inc. All rights reserved.
|
||||
*
|
||||
* This software, related documentation and any modifications thereto (collectively “Software? is subject
|
||||
* to InvenSense and its licensors' intellectual property rights under U.S. and international copyright
|
||||
* and other intellectual property rights laws.
|
||||
*
|
||||
* InvenSense and its licensors retain all intellectual property and proprietary rights in and to the Software
|
||||
* and any use, reproduction, disclosure or distribution of the Software without an express license agreement
|
||||
* from InvenSense is strictly prohibited.
|
||||
*
|
||||
* EXCEPT AS OTHERWISE PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, THE SOFTWARE IS
|
||||
* PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
||||
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* EXCEPT AS OTHERWISE PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, IN NO EVENT SHALL
|
||||
* INVENSENSE BE LIABLE FOR ANY DIRECT, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
||||
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THE SOFTWARE.
|
||||
* ________________________________________________________________________________________________________
|
||||
*/
|
||||
|
||||
/* std */
|
||||
#include <stdio.h>
|
||||
|
||||
/* board driver */
|
||||
#include "common.h"
|
||||
#include "uart_mngr.h"
|
||||
#include "delay.h"
|
||||
#include "gpio.h"
|
||||
#include "timer.h"
|
||||
#include "system_interface.h"
|
||||
|
||||
/* InvenSense utils */
|
||||
#include "Invn/EmbUtils/Message.h"
|
||||
#include "Invn/EmbUtils/RingBuffer.h"
|
||||
|
||||
#include "inv_imu_driver.h"
|
||||
|
||||
/*
|
||||
* Select UART port on which INV_MSG() will be printed.
|
||||
*/
|
||||
#define LOG_UART_ID INV_UART_SENSOR_CTRL
|
||||
|
||||
/*
|
||||
* Define msg level
|
||||
*/
|
||||
#define MSG_LEVEL INV_MSG_LEVEL_DEBUG
|
||||
|
||||
/*
|
||||
* Set of timers used throughout standalone applications
|
||||
*/
|
||||
#define TIMEBASE_TIMER INV_TIMER1
|
||||
#define DELAY_TIMER INV_TIMER2
|
||||
|
||||
#if !USE_FIFO
|
||||
/*
|
||||
* Buffer to keep track of the timestamp when IMU data ready interrupt fires.
|
||||
* The buffer can contain up to 64 items in order to store one timestamp for each packet in FIFO.
|
||||
*/
|
||||
RINGBUFFER(timestamp_buffer, 64, uint64_t);
|
||||
#endif
|
||||
|
||||
/* --------------------------------------------------------------------------------------
|
||||
* Static variables
|
||||
* -------------------------------------------------------------------------------------- */
|
||||
|
||||
/* Flag set from IMU device irq handler */
|
||||
static volatile int irq_from_device;
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------------------------
|
||||
* Forward declaration
|
||||
* -------------------------------------------------------------------------------------- */
|
||||
static int setup_mcu();
|
||||
static void ext_interrupt_cb(void * context, unsigned int int_num);
|
||||
|
||||
void msg_printer(int level, const char * str, va_list ap);
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------------------------
|
||||
* Functions definitions
|
||||
* -------------------------------------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* This function initializes MCU on which this software is running.
|
||||
* It configures:
|
||||
* - a UART link used to print some messages
|
||||
* - interrupt priority group and GPIO so that MCU can receive interrupts from IMU
|
||||
* - a microsecond timer requested by IMU driver to compute some delay
|
||||
* - a microsecond timer used to get some timestamps
|
||||
* - a serial link to communicate from MCU to IMU
|
||||
*/
|
||||
static int setup_mcu()
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
platform_io_hal_board_init();
|
||||
|
||||
/* configure UART */
|
||||
config_uart(LOG_UART_ID);
|
||||
|
||||
/* Setup message facility to see internal traces from FW */
|
||||
PLATFORM_MSG_SETUP(MSG_LEVEL, msg_printer);
|
||||
|
||||
INV_MSG(INV_MSG_LEVEL_INFO, "######################################");
|
||||
INV_MSG(INV_MSG_LEVEL_INFO, "# #XIAN MCU Driver V1.0 FF EXAMPLE #");
|
||||
INV_MSG(INV_MSG_LEVEL_INFO, "######################################");
|
||||
|
||||
/*
|
||||
* Configure input capture mode GPIO connected to pin EXT3-9 (pin PB03).
|
||||
* This pin is connected to Icm406xx INT1 output and thus will receive interrupts
|
||||
* enabled on INT1 from the device.
|
||||
* A callback function is also passed that will be executed each time an interrupt
|
||||
* fires.
|
||||
*/
|
||||
platform_gpio_sensor_irq_init(INV_GPIO_INT1, ext_interrupt_cb, 0);
|
||||
|
||||
/* Init timer peripheral for delay */
|
||||
rc |= platform_delay_init(DELAY_TIMER);
|
||||
|
||||
/*
|
||||
* Configure the timer for the timebase
|
||||
*/
|
||||
rc |= platform_timer_configure_timebase(1000000);
|
||||
platform_timer_enable(TIMEBASE_TIMER);
|
||||
|
||||
inv_imu_set_serif(platform_io_hal_read_reg, platform_io_hal_write_reg);
|
||||
inv_imu_set_delay(platform_delay_ms,platform_delay_us); //void (*delay_ms)(uint32_t), void (*delay_us)(uint32_t))
|
||||
rc |= platform_io_hal_init();
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* IMU interrupt handler.
|
||||
* Function is executed when an IMU interrupt rises on MCU.
|
||||
* This function get a timestamp and store it in the timestamp buffer.
|
||||
* Note that this function is executed in an interrupt handler and thus no protection
|
||||
* are implemented for shared variable timestamp_buffer.
|
||||
*/
|
||||
static void ext_interrupt_cb(void * context, unsigned int int_num)
|
||||
{
|
||||
(void)context;
|
||||
|
||||
#if !USE_FIFO
|
||||
/*
|
||||
* Read timestamp from the timer dedicated to timestamping
|
||||
*/
|
||||
uint64_t timestamp = platform_timer_get_counter(TIMEBASE_TIMER);
|
||||
|
||||
if(int_num == INV_GPIO_INT1) {
|
||||
if (!RINGBUFFER_FULL(×tamp_buffer))
|
||||
RINGBUFFER_PUSH(×tamp_buffer, ×tamp);
|
||||
}
|
||||
#endif
|
||||
|
||||
irq_from_device |= TO_MASK(int_num);
|
||||
}
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------------------------
|
||||
* Functions definition
|
||||
* -------------------------------------------------------------------------------------- */
|
||||
|
||||
int setup_imu_device()
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
/* Init device */
|
||||
rc = inv_imu_initialize();
|
||||
if (rc != INV_ERROR_SUCCESS) {
|
||||
INV_MSG(INV_MSG_LEVEL_ERROR, "Failed to initialize IMU!");
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
#if !USE_FIFO
|
||||
RINGBUFFER_CLEAR(×tamp_buffer);
|
||||
#endif
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------------------------
|
||||
* Main
|
||||
* -------------------------------------------------------------------------------------- */
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int rc = 0;
|
||||
bool ff_detect_result = false;
|
||||
float freefall_distance = 0.0f;
|
||||
|
||||
rc |= setup_mcu();
|
||||
|
||||
|
||||
#if !USE_FIFO
|
||||
RINGBUFFER_CLEAR(×tamp_buffer);
|
||||
#endif
|
||||
|
||||
/* Init device */
|
||||
rc = inv_imu_initialize();
|
||||
|
||||
if (rc != INV_ERROR_SUCCESS) {
|
||||
INV_MSG(INV_MSG_LEVEL_ERROR, "Failed to initialize INV concise driver!");
|
||||
return rc;
|
||||
}
|
||||
|
||||
INV_MSG(INV_MSG_LEVEL_INFO, "IMU device successfully initialized");
|
||||
|
||||
rc = inv_imu_freefall_enable() ;
|
||||
|
||||
|
||||
if (rc != 0) {
|
||||
INV_LOG(SENSOR_LOG_LEVEL, "freefall enable Failed. Do nothing %d", rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
|
||||
do {
|
||||
/* Poll device for data */
|
||||
if (irq_from_device & TO_MASK(INV_GPIO_INT1)) {
|
||||
|
||||
inv_disable_irq();
|
||||
|
||||
freefall_distance = inv_imu_freefall_get_event(&ff_detect_result);
|
||||
INV_LOG(SENSOR_LOG_LEVEL, "ff result %d, cm %f",ff_detect_result,freefall_distance);
|
||||
|
||||
irq_from_device &= ~TO_MASK(INV_GPIO_INT1);
|
||||
inv_enable_irq();
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
if (i == 30) {
|
||||
rc = inv_imu_freefall_disable();
|
||||
i++;
|
||||
}
|
||||
} while(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Printer function for message facility
|
||||
*/
|
||||
void msg_printer(int level, const char * str, va_list ap)
|
||||
{
|
||||
static char out_str[256]; /* static to limit stack usage */
|
||||
unsigned idx = 0;
|
||||
const char * s[INV_MSG_LEVEL_MAX] = {
|
||||
"", // INV_MSG_LEVEL_OFF
|
||||
"[E] ", // INV_MSG_LEVEL_ERROR
|
||||
"[W] ", // INV_MSG_LEVEL_WARNING
|
||||
"[I] ", // INV_MSG_LEVEL_INFO
|
||||
"[V] ", // INV_MSG_LEVEL_VERBOSE
|
||||
"[D] ", // INV_MSG_LEVEL_DEBUG
|
||||
};
|
||||
idx += snprintf(&out_str[idx], sizeof(out_str) - idx, "%s", s[level]);
|
||||
if(idx >= (sizeof(out_str)))
|
||||
return;
|
||||
idx += vsnprintf(&out_str[idx], sizeof(out_str) - idx, str, ap);
|
||||
if(idx >= (sizeof(out_str)))
|
||||
return;
|
||||
idx += snprintf(&out_str[idx], sizeof(out_str) - idx, "\r\n");
|
||||
if(idx >= (sizeof(out_str)))
|
||||
return;
|
||||
|
||||
platform_uart_mngr_puts(LOG_UART_ID, out_str, idx);
|
||||
}
|
||||
@@ -1,277 +0,0 @@
|
||||
/*
|
||||
* ________________________________________________________________________________________________________
|
||||
* Copyright (c) 2017 InvenSense Inc. All rights reserved.
|
||||
*
|
||||
* This software, related documentation and any modifications thereto (collectively “Software? is subject
|
||||
* to InvenSense and its licensors' intellectual property rights under U.S. and international copyright
|
||||
* and other intellectual property rights laws.
|
||||
*
|
||||
* InvenSense and its licensors retain all intellectual property and proprietary rights in and to the Software
|
||||
* and any use, reproduction, disclosure or distribution of the Software without an express license agreement
|
||||
* from InvenSense is strictly prohibited.
|
||||
*
|
||||
* EXCEPT AS OTHERWISE PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, THE SOFTWARE IS
|
||||
* PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
||||
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* EXCEPT AS OTHERWISE PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, IN NO EVENT SHALL
|
||||
* INVENSENSE BE LIABLE FOR ANY DIRECT, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
||||
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THE SOFTWARE.
|
||||
* ________________________________________________________________________________________________________
|
||||
*/
|
||||
|
||||
/* std */
|
||||
#include <stdio.h>
|
||||
|
||||
/* board driver */
|
||||
#include "common.h"
|
||||
#include "uart_mngr.h"
|
||||
#include "delay.h"
|
||||
#include "gpio.h"
|
||||
#include "timer.h"
|
||||
#include "system_interface.h"
|
||||
|
||||
/* InvenSense utils */
|
||||
#include "Invn/EmbUtils/Message.h"
|
||||
#include "Invn/EmbUtils/RingBuffer.h"
|
||||
|
||||
#include "inv_imu_driver.h"
|
||||
|
||||
/*
|
||||
* Select UART port on which INV_MSG() will be printed.
|
||||
*/
|
||||
#define LOG_UART_ID INV_UART_SENSOR_CTRL
|
||||
|
||||
/*
|
||||
* Define msg level
|
||||
*/
|
||||
#define MSG_LEVEL INV_MSG_LEVEL_DEBUG
|
||||
|
||||
/*
|
||||
* Set of timers used throughout standalone applications
|
||||
*/
|
||||
#define TIMEBASE_TIMER INV_TIMER1
|
||||
#define DELAY_TIMER INV_TIMER2
|
||||
|
||||
#if !USE_FIFO
|
||||
/*
|
||||
* Buffer to keep track of the timestamp when IMU data ready interrupt fires.
|
||||
* The buffer can contain up to 64 items in order to store one timestamp for each packet in FIFO.
|
||||
*/
|
||||
RINGBUFFER(timestamp_buffer, 64, uint64_t);
|
||||
#endif
|
||||
|
||||
/* --------------------------------------------------------------------------------------
|
||||
* Static variables
|
||||
* -------------------------------------------------------------------------------------- */
|
||||
|
||||
/* Flag set from IMU device irq handler */
|
||||
static volatile int irq_from_device;
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------------------------
|
||||
* Forward declaration
|
||||
* -------------------------------------------------------------------------------------- */
|
||||
static int setup_mcu();
|
||||
static void ext_interrupt_cb(void * context, unsigned int int_num);
|
||||
|
||||
void msg_printer(int level, const char * str, va_list ap);
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------------------------
|
||||
* Functions definitions
|
||||
* -------------------------------------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* This function initializes MCU on which this software is running.
|
||||
* It configures:
|
||||
* - a UART link used to print some messages
|
||||
* - interrupt priority group and GPIO so that MCU can receive interrupts from IMU
|
||||
* - a microsecond timer requested by IMU driver to compute some delay
|
||||
* - a microsecond timer used to get some timestamps
|
||||
* - a serial link to communicate from MCU to IMU
|
||||
*/
|
||||
static int setup_mcu()
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
platform_io_hal_board_init();
|
||||
|
||||
/* configure UART */
|
||||
config_uart(LOG_UART_ID);
|
||||
|
||||
/* Setup message facility to see internal traces from FW */
|
||||
PLATFORM_MSG_SETUP(MSG_LEVEL, msg_printer);
|
||||
|
||||
INV_MSG(INV_MSG_LEVEL_INFO, "######################################");
|
||||
INV_MSG(INV_MSG_LEVEL_INFO, "# #XIAN MCU Driver V1.0 PEDO EXAMPLE#");
|
||||
INV_MSG(INV_MSG_LEVEL_INFO, "######################################");
|
||||
|
||||
/*
|
||||
* Configure input capture mode GPIO connected to pin EXT3-9 (pin PB03).
|
||||
* This pin is connected to Icm406xx INT1 output and thus will receive interrupts
|
||||
* enabled on INT1 from the device.
|
||||
* A callback function is also passed that will be executed each time an interrupt
|
||||
* fires.
|
||||
*/
|
||||
platform_gpio_sensor_irq_init(INV_GPIO_INT1, ext_interrupt_cb, 0);
|
||||
|
||||
/* Init timer peripheral for delay */
|
||||
rc |= platform_delay_init(DELAY_TIMER);
|
||||
|
||||
/*
|
||||
* Configure the timer for the timebase
|
||||
*/
|
||||
rc |= platform_timer_configure_timebase(1000000);
|
||||
platform_timer_enable(TIMEBASE_TIMER);
|
||||
|
||||
inv_imu_set_serif(platform_io_hal_read_reg, platform_io_hal_write_reg);
|
||||
inv_imu_set_delay(platform_delay_ms,platform_delay_us); //void (*delay_ms)(uint32_t), void (*delay_us)(uint32_t))
|
||||
rc |= platform_io_hal_init();
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* IMU interrupt handler.
|
||||
* Function is executed when an IMU interrupt rises on MCU.
|
||||
* This function get a timestamp and store it in the timestamp buffer.
|
||||
* Note that this function is executed in an interrupt handler and thus no protection
|
||||
* are implemented for shared variable timestamp_buffer.
|
||||
*/
|
||||
static void ext_interrupt_cb(void * context, unsigned int int_num)
|
||||
{
|
||||
(void)context;
|
||||
|
||||
#if !USE_FIFO
|
||||
/*
|
||||
* Read timestamp from the timer dedicated to timestamping
|
||||
*/
|
||||
uint64_t timestamp = platform_timer_get_counter(TIMEBASE_TIMER);
|
||||
|
||||
if(int_num == INV_GPIO_INT1) {
|
||||
if (!RINGBUFFER_FULL(×tamp_buffer))
|
||||
RINGBUFFER_PUSH(×tamp_buffer, ×tamp);
|
||||
}
|
||||
#endif
|
||||
|
||||
irq_from_device |= TO_MASK(int_num);
|
||||
}
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------------------------
|
||||
* Functions definition
|
||||
* -------------------------------------------------------------------------------------- */
|
||||
|
||||
int setup_imu_device()
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
/* Init device */
|
||||
rc = inv_imu_initialize();
|
||||
if (rc != INV_ERROR_SUCCESS) {
|
||||
INV_MSG(INV_MSG_LEVEL_ERROR, "Failed to initialize IMU!");
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
#if !USE_FIFO
|
||||
RINGBUFFER_CLEAR(×tamp_buffer);
|
||||
#endif
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------------------------
|
||||
* Main
|
||||
* -------------------------------------------------------------------------------------- */
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int rc = 0;
|
||||
APEX_DATA3_ACTIVITY_CLASS_t activity_class;
|
||||
float cadence_step_per_sec;
|
||||
int step_result = 0;
|
||||
|
||||
rc |= setup_mcu();
|
||||
|
||||
|
||||
#if !USE_FIFO
|
||||
RINGBUFFER_CLEAR(×tamp_buffer);
|
||||
#endif
|
||||
|
||||
/* Init device */
|
||||
rc = inv_imu_initialize();
|
||||
|
||||
if (rc != INV_ERROR_SUCCESS) {
|
||||
INV_MSG(INV_MSG_LEVEL_ERROR, "Failed to initialize INV concise driver!");
|
||||
return rc;
|
||||
}
|
||||
|
||||
INV_MSG(INV_MSG_LEVEL_INFO, "IMU device successfully initialized");
|
||||
|
||||
rc = inv_imu_pedometer_enable() ;
|
||||
|
||||
if (rc != 0) {
|
||||
INV_MSG(INV_MSG_LEVEL_INFO, "pedometer enable Failed. Do nothing %d", rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
|
||||
do {
|
||||
/* Poll device for data */
|
||||
if (irq_from_device & TO_MASK(INV_GPIO_INT1)) {
|
||||
|
||||
inv_disable_irq();
|
||||
|
||||
step_result = inv_imu_pedometer_get_event(&cadence_step_per_sec,&activity_class);
|
||||
|
||||
if(step_result < 0)
|
||||
INV_MSG(INV_MSG_LEVEL_ERROR, "pedometer get event failure %d",step_result);
|
||||
else
|
||||
INV_MSG(INV_MSG_LEVEL_INFO, "step value %d, %.2f steps/sec, type %d",step_result,cadence_step_per_sec,activity_class);
|
||||
|
||||
irq_from_device &= ~TO_MASK(INV_GPIO_INT1);
|
||||
inv_enable_irq();
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
if (i == 100) {
|
||||
rc = inv_imu_pedometer_disable();
|
||||
i++;
|
||||
}
|
||||
} while(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Printer function for message facility
|
||||
*/
|
||||
void msg_printer(int level, const char * str, va_list ap)
|
||||
{
|
||||
static char out_str[256]; /* static to limit stack usage */
|
||||
unsigned idx = 0;
|
||||
const char * s[INV_MSG_LEVEL_MAX] = {
|
||||
"", // INV_MSG_LEVEL_OFF
|
||||
"[E] ", // INV_MSG_LEVEL_ERROR
|
||||
"[W] ", // INV_MSG_LEVEL_WARNING
|
||||
"[I] ", // INV_MSG_LEVEL_INFO
|
||||
"[V] ", // INV_MSG_LEVEL_VERBOSE
|
||||
"[D] ", // INV_MSG_LEVEL_DEBUG
|
||||
};
|
||||
idx += snprintf(&out_str[idx], sizeof(out_str) - idx, "%s", s[level]);
|
||||
if(idx >= (sizeof(out_str)))
|
||||
return;
|
||||
idx += vsnprintf(&out_str[idx], sizeof(out_str) - idx, str, ap);
|
||||
if(idx >= (sizeof(out_str)))
|
||||
return;
|
||||
idx += snprintf(&out_str[idx], sizeof(out_str) - idx, "\r\n");
|
||||
if(idx >= (sizeof(out_str)))
|
||||
return;
|
||||
|
||||
platform_uart_mngr_puts(LOG_UART_ID, out_str, idx);
|
||||
}
|
||||
@@ -1,396 +0,0 @@
|
||||
/*
|
||||
* ________________________________________________________________________________________________________
|
||||
* Copyright (c) 2017 InvenSense Inc. All rights reserved.
|
||||
*
|
||||
* This software, related documentation and any modifications thereto (collectively “Software? is subject
|
||||
* to InvenSense and its licensors' intellectual property rights under U.S. and international copyright
|
||||
* and other intellectual property rights laws.
|
||||
*
|
||||
* InvenSense and its licensors retain all intellectual property and proprietary rights in and to the Software
|
||||
* and any use, reproduction, disclosure or distribution of the Software without an express license agreement
|
||||
* from InvenSense is strictly prohibited.
|
||||
*
|
||||
* EXCEPT AS OTHERWISE PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, THE SOFTWARE IS
|
||||
* PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
||||
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* EXCEPT AS OTHERWISE PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, IN NO EVENT SHALL
|
||||
* INVENSENSE BE LIABLE FOR ANY DIRECT, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
||||
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THE SOFTWARE.
|
||||
* ________________________________________________________________________________________________________
|
||||
*/
|
||||
|
||||
/* std */
|
||||
#include <stdio.h>
|
||||
|
||||
/* board driver */
|
||||
#include "common.h"
|
||||
#include "uart_mngr.h"
|
||||
#include "delay.h"
|
||||
#include "gpio.h"
|
||||
#include "timer.h"
|
||||
#include "system_interface.h"
|
||||
|
||||
/* InvenSense utils */
|
||||
#include "Invn/EmbUtils/Message.h"
|
||||
#include "Invn/EmbUtils/RingBuffer.h"
|
||||
|
||||
#include "inv_imu_driver.h"
|
||||
|
||||
|
||||
struct SensorData Acc_Receive_dataBuff[2048];
|
||||
struct SensorData Gyro_Receive_dataBuff[2048];
|
||||
|
||||
|
||||
AccDataPacket accData;
|
||||
GyroDataPacket gyroData;
|
||||
chip_temperature imu_chip_temperature;
|
||||
|
||||
uint32_t cur_index = 0;
|
||||
|
||||
|
||||
/*
|
||||
* Select UART port on which INV_MSG() will be printed.
|
||||
*/
|
||||
#define LOG_UART_ID INV_UART_SENSOR_CTRL
|
||||
|
||||
/*
|
||||
* Define msg level
|
||||
*/
|
||||
#define MSG_LEVEL INV_MSG_LEVEL_DEBUG
|
||||
|
||||
/*
|
||||
* Set of timers used throughout standalone applications
|
||||
*/
|
||||
#define TIMEBASE_TIMER INV_TIMER1
|
||||
#define DELAY_TIMER INV_TIMER2
|
||||
|
||||
#define SENSOR_ODR_1600HZ 1600
|
||||
#define SENSOR_ODR_800HZ 800
|
||||
#define SENSOR_ODR_400HZ 400
|
||||
#define SENSOR_ODR_200HZ 200
|
||||
#define SENSOR_ODR_100HZ 100
|
||||
#define SENSOR_ODR_50HZ 50
|
||||
#define SENSOR_ODR_25HZ 25
|
||||
#define SENSOR_ODR_12_5HZ 12.5
|
||||
|
||||
|
||||
#if !USE_FIFO
|
||||
/*
|
||||
* Buffer to keep track of the timestamp when IMU data ready interrupt fires.
|
||||
* The buffer can contain up to 64 items in order to store one timestamp for each packet in FIFO.
|
||||
*/
|
||||
RINGBUFFER(timestamp_buffer, 64, uint64_t);
|
||||
#endif
|
||||
|
||||
/* --------------------------------------------------------------------------------------
|
||||
* Static variables
|
||||
* -------------------------------------------------------------------------------------- */
|
||||
|
||||
/* Flag set from IMU device irq handler */
|
||||
static volatile int irq_from_device;
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------------------------
|
||||
* Forward declaration
|
||||
* -------------------------------------------------------------------------------------- */
|
||||
static int setup_mcu();
|
||||
static void ext_interrupt_cb(void * context, unsigned int int_num);
|
||||
|
||||
void msg_printer(int level, const char * str, va_list ap);
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------------------------
|
||||
* Functions definitions
|
||||
* -------------------------------------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* This function initializes MCU on which this software is running.
|
||||
* It configures:
|
||||
* - a UART link used to print some messages
|
||||
* - interrupt priority group and GPIO so that MCU can receive interrupts from IMU
|
||||
* - a microsecond timer requested by IMU driver to compute some delay
|
||||
* - a microsecond timer used to get some timestamps
|
||||
* - a serial link to communicate from MCU to IMU
|
||||
*/
|
||||
static int setup_mcu()
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
platform_io_hal_board_init();
|
||||
|
||||
/* configure UART */
|
||||
config_uart(LOG_UART_ID);
|
||||
|
||||
/* Setup message facility to see internal traces from FW */
|
||||
PLATFORM_MSG_SETUP(MSG_LEVEL, msg_printer);
|
||||
|
||||
INV_MSG(INV_MSG_LEVEL_INFO, "######################");
|
||||
INV_MSG(INV_MSG_LEVEL_INFO, "# Example Raw AG #");
|
||||
INV_MSG(INV_MSG_LEVEL_INFO, "######################");
|
||||
|
||||
/*
|
||||
* Configure input capture mode GPIO connected to pin EXT3-9 (pin PB03).
|
||||
* This pin is connected to Icm406xx INT1 output and thus will receive interrupts
|
||||
* enabled on INT1 from the device.
|
||||
* A callback function is also passed that will be executed each time an interrupt
|
||||
* fires.
|
||||
*/
|
||||
platform_gpio_sensor_irq_init(INV_GPIO_INT1, ext_interrupt_cb, 0);
|
||||
|
||||
/* Init timer peripheral for delay */
|
||||
rc |= platform_delay_init(DELAY_TIMER);
|
||||
|
||||
/*
|
||||
* Configure the timer for the timebase
|
||||
*/
|
||||
rc |= platform_timer_configure_timebase(1000000);
|
||||
platform_timer_enable(TIMEBASE_TIMER);
|
||||
|
||||
inv_imu_set_serif(platform_io_hal_read_reg, platform_io_hal_write_reg);
|
||||
inv_imu_set_delay(platform_delay_ms,platform_delay_us); //void (*delay_ms)(uint32_t), void (*delay_us)(uint32_t))
|
||||
rc |= platform_io_hal_init();
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* IMU interrupt handler.
|
||||
* Function is executed when an IMU interrupt rises on MCU.
|
||||
* This function get a timestamp and store it in the timestamp buffer.
|
||||
* Note that this function is executed in an interrupt handler and thus no protection
|
||||
* are implemented for shared variable timestamp_buffer.
|
||||
*/
|
||||
static void ext_interrupt_cb(void * context, unsigned int int_num)
|
||||
{
|
||||
(void)context;
|
||||
|
||||
#if !USE_FIFO
|
||||
/*
|
||||
* Read timestamp from the timer dedicated to timestamping
|
||||
*/
|
||||
uint64_t timestamp = platform_timer_get_counter(TIMEBASE_TIMER);
|
||||
|
||||
if(int_num == INV_GPIO_INT1) {
|
||||
if (!RINGBUFFER_FULL(×tamp_buffer))
|
||||
RINGBUFFER_PUSH(×tamp_buffer, ×tamp);
|
||||
}
|
||||
#endif
|
||||
|
||||
irq_from_device |= TO_MASK(int_num);
|
||||
}
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------------------------
|
||||
* Functions definition
|
||||
* -------------------------------------------------------------------------------------- */
|
||||
|
||||
int setup_imu_device()
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
/* Init device */
|
||||
rc = inv_imu_initialize();
|
||||
if (rc != INV_ERROR_SUCCESS) {
|
||||
INV_MSG(INV_MSG_LEVEL_ERROR, "Failed to initialize IMU!");
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
#if !USE_FIFO
|
||||
RINGBUFFER_CLEAR(×tamp_buffer);
|
||||
#endif
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
uint32_t get_imu_data()
|
||||
{
|
||||
inv_data_handler(&accData,&gyroData,&imu_chip_temperature,false);
|
||||
if(accData.accDataSize != 0){
|
||||
memcpy(&Acc_Receive_dataBuff[cur_index], &accData.databuff[0], accData.accDataSize * sizeof(accData.databuff[0]));
|
||||
//INV_MSG(INV_MSG_LEVEL_ERROR, "acDS %u cidex %u",accData.accDataSize,cur_index);
|
||||
}
|
||||
|
||||
if(gyroData.gyroDataSize != 0){
|
||||
memcpy(&Gyro_Receive_dataBuff[cur_index], &gyroData.databuff[0], gyroData.gyroDataSize * sizeof(gyroData.databuff[0]));
|
||||
}
|
||||
|
||||
if ((accData.accDataSize != 0) && (gyroData.gyroDataSize != 0))
|
||||
cur_index = cur_index + (uint32_t)accData.accDataSize;
|
||||
else if(accData.accDataSize != 0)
|
||||
cur_index = cur_index + (uint32_t)accData.accDataSize;
|
||||
else if(gyroData.gyroDataSize != 0)
|
||||
cur_index = cur_index + (uint32_t)gyroData.gyroDataSize;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------------------------
|
||||
* Main
|
||||
* -------------------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int rc = 0;
|
||||
float hw_rate = 0.0;
|
||||
|
||||
memset(Acc_Receive_dataBuff,0,sizeof(Acc_Receive_dataBuff));
|
||||
memset(Gyro_Receive_dataBuff,0,sizeof(Gyro_Receive_dataBuff));
|
||||
rc |= setup_mcu();
|
||||
|
||||
|
||||
#if !USE_FIFO
|
||||
RINGBUFFER_CLEAR(×tamp_buffer);
|
||||
#endif
|
||||
|
||||
/* Init device */
|
||||
rc = inv_imu_initialize();
|
||||
|
||||
if (rc != INV_ERROR_SUCCESS) {
|
||||
INV_MSG(INV_MSG_LEVEL_ERROR, "Failed to initialize INV concise driver!");
|
||||
return rc;
|
||||
}
|
||||
|
||||
INV_MSG(INV_MSG_LEVEL_INFO, "IMU device successfully initialized");
|
||||
|
||||
// We may customize full scale range here.
|
||||
rc |= inv_imu_set_accel_fsr(ACCEL_CONFIG0_FS_SEL_4g);
|
||||
rc |= inv_imu_set_gyro_fsr(GYRO_CONFIG0_FS_SEL_2000dps);
|
||||
|
||||
// Below settings are required to configure and enable sensors.
|
||||
rc |= inv_imu_acc_enable();
|
||||
rc |= inv_imu_acc_set_rate(SENSOR_ODR_400HZ, 2,&hw_rate); //200Hz ODR, watermark: 2 packets.
|
||||
rc |= inv_imu_gyro_enable();
|
||||
rc |= inv_imu_gyro_set_rate(SENSOR_ODR_400HZ, 4,&hw_rate); //50Hz ODR, watermark 4.
|
||||
|
||||
if (rc != 0) {
|
||||
INV_LOG(SENSOR_LOG_LEVEL, "Feature enable Failed. Do nothing %d", rc);
|
||||
return rc;
|
||||
}
|
||||
INV_LOG(SENSOR_LOG_LEVEL, "HW odr setting %f ", hw_rate);
|
||||
|
||||
do {
|
||||
|
||||
/* Poll device for data */
|
||||
if (irq_from_device & TO_MASK(INV_GPIO_INT1)) {
|
||||
|
||||
get_imu_data();
|
||||
//INV_MSG(INV_MSG_LEVEL_ERROR, "cur idex %lu!",cur_index);
|
||||
|
||||
inv_disable_irq();
|
||||
irq_from_device &= ~TO_MASK(INV_GPIO_INT1);
|
||||
inv_enable_irq();
|
||||
|
||||
}
|
||||
} while(cur_index <2048);
|
||||
|
||||
rc |= inv_imu_acc_disable();
|
||||
rc |= inv_imu_gyro_disable();
|
||||
|
||||
#if SENSOR_LOG_TS_ONLY
|
||||
uint32_t i;
|
||||
for(i=0;i< cur_index; i++){
|
||||
INV_LOG(SENSOR_LOG_LEVEL, "ACC %d TS %lld ", i+1,Acc_Receive_dataBuff[i].timeStamp);
|
||||
platform_delay_ms(5);
|
||||
}
|
||||
|
||||
for(i=0;i< cur_index; i++){
|
||||
INV_LOG(SENSOR_LOG_LEVEL, "Gyro %d TS %lld ", i+1,Gyro_Receive_dataBuff[i].timeStamp);
|
||||
platform_delay_ms(5);
|
||||
}
|
||||
#endif
|
||||
|
||||
// following code is just repeating the previous code, just to confirm the testing could be alwasys run
|
||||
int j = 2;
|
||||
while(1){
|
||||
|
||||
memset(Acc_Receive_dataBuff,0,sizeof(Acc_Receive_dataBuff));
|
||||
memset(Gyro_Receive_dataBuff,0,sizeof(Gyro_Receive_dataBuff));
|
||||
|
||||
memset(&accData,0,sizeof(accData));
|
||||
memset(&gyroData,0,sizeof(gyroData));
|
||||
|
||||
INV_LOG(SENSOR_LOG_LEVEL, "repeating test round %d", j);
|
||||
// Below settings are required to configure and enable sensors.
|
||||
rc |= inv_imu_acc_enable();
|
||||
rc |= inv_imu_acc_set_rate(SENSOR_ODR_200HZ, 2,&hw_rate); //200Hz ODR, watermark: 2 packets.
|
||||
rc |= inv_imu_gyro_enable();
|
||||
rc |= inv_imu_gyro_set_rate(SENSOR_ODR_200HZ, 4,&hw_rate); //50Hz ODR, watermark 4.
|
||||
|
||||
if (rc != 0) {
|
||||
INV_LOG(SENSOR_LOG_LEVEL, "Feature enable Failed. Do nothing %d", rc);
|
||||
return rc;
|
||||
}
|
||||
INV_LOG(SENSOR_LOG_LEVEL, "HW odr setting %f ", hw_rate);
|
||||
|
||||
|
||||
cur_index = 0;
|
||||
do {
|
||||
|
||||
/* Poll device for data */
|
||||
if (irq_from_device & TO_MASK(INV_GPIO_INT1)) {
|
||||
|
||||
get_imu_data();
|
||||
//INV_MSG(INV_MSG_LEVEL_ERROR, "cur idex %lu!",cur_index);
|
||||
|
||||
inv_disable_irq();
|
||||
irq_from_device &= ~TO_MASK(INV_GPIO_INT1);
|
||||
inv_enable_irq();
|
||||
|
||||
}
|
||||
} while(cur_index <2048);
|
||||
|
||||
rc |= inv_imu_acc_disable();
|
||||
rc |= inv_imu_gyro_disable();
|
||||
|
||||
#if SENSOR_LOG_TS_ONLY
|
||||
|
||||
for(i=0;i< cur_index; i++){
|
||||
INV_LOG(SENSOR_LOG_LEVEL, "ACC %d TS %lld ", i+1,Acc_Receive_dataBuff[i].timeStamp);
|
||||
platform_delay_ms(5);
|
||||
}
|
||||
|
||||
for(i=0;i< cur_index; i++){
|
||||
INV_LOG(SENSOR_LOG_LEVEL, "Gyro %d TS %lld ", i+1,Gyro_Receive_dataBuff[i].timeStamp);
|
||||
platform_delay_ms(5);
|
||||
}
|
||||
#endif
|
||||
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Printer function for message facility
|
||||
*/
|
||||
void msg_printer(int level, const char * str, va_list ap)
|
||||
{
|
||||
static char out_str[256]; /* static to limit stack usage */
|
||||
unsigned idx = 0;
|
||||
const char * s[INV_MSG_LEVEL_MAX] = {
|
||||
"", // INV_MSG_LEVEL_OFF
|
||||
"[E] ", // INV_MSG_LEVEL_ERROR
|
||||
"[W] ", // INV_MSG_LEVEL_WARNING
|
||||
"[I] ", // INV_MSG_LEVEL_INFO
|
||||
"[V] ", // INV_MSG_LEVEL_VERBOSE
|
||||
"[D] ", // INV_MSG_LEVEL_DEBUG
|
||||
};
|
||||
idx += snprintf(&out_str[idx], sizeof(out_str) - idx, "%s", s[level]);
|
||||
if(idx >= (sizeof(out_str)))
|
||||
return;
|
||||
idx += vsnprintf(&out_str[idx], sizeof(out_str) - idx, str, ap);
|
||||
if(idx >= (sizeof(out_str)))
|
||||
return;
|
||||
idx += snprintf(&out_str[idx], sizeof(out_str) - idx, "\r\n");
|
||||
if(idx >= (sizeof(out_str)))
|
||||
return;
|
||||
|
||||
platform_uart_mngr_puts(LOG_UART_ID, out_str, idx);
|
||||
}
|
||||
@@ -1,266 +0,0 @@
|
||||
/*
|
||||
* ________________________________________________________________________________________________________
|
||||
* Copyright (c) 2017 InvenSense Inc. All rights reserved.
|
||||
*
|
||||
* This software, related documentation and any modifications thereto (collectively “Software? is subject
|
||||
* to InvenSense and its licensors' intellectual property rights under U.S. and international copyright
|
||||
* and other intellectual property rights laws.
|
||||
*
|
||||
* InvenSense and its licensors retain all intellectual property and proprietary rights in and to the Software
|
||||
* and any use, reproduction, disclosure or distribution of the Software without an express license agreement
|
||||
* from InvenSense is strictly prohibited.
|
||||
*
|
||||
* EXCEPT AS OTHERWISE PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, THE SOFTWARE IS
|
||||
* PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
||||
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* EXCEPT AS OTHERWISE PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, IN NO EVENT SHALL
|
||||
* INVENSENSE BE LIABLE FOR ANY DIRECT, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
||||
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THE SOFTWARE.
|
||||
* ________________________________________________________________________________________________________
|
||||
*/
|
||||
|
||||
/* std */
|
||||
#include <stdio.h>
|
||||
|
||||
/* board driver */
|
||||
#include "common.h"
|
||||
#include "uart_mngr.h"
|
||||
#include "delay.h"
|
||||
#include "gpio.h"
|
||||
#include "timer.h"
|
||||
#include "system_interface.h"
|
||||
|
||||
/* InvenSense utils */
|
||||
#include "Invn/EmbUtils/Message.h"
|
||||
#include "Invn/EmbUtils/RingBuffer.h"
|
||||
|
||||
#include "inv_imu_driver.h"
|
||||
|
||||
/*
|
||||
* Select UART port on which INV_MSG() will be printed.
|
||||
*/
|
||||
#define LOG_UART_ID INV_UART_SENSOR_CTRL
|
||||
|
||||
/*
|
||||
* Define msg level
|
||||
*/
|
||||
#define MSG_LEVEL INV_MSG_LEVEL_DEBUG
|
||||
|
||||
/*
|
||||
* Set of timers used throughout standalone applications
|
||||
*/
|
||||
#define TIMEBASE_TIMER INV_TIMER1
|
||||
#define DELAY_TIMER INV_TIMER2
|
||||
|
||||
#if !USE_FIFO
|
||||
/*
|
||||
* Buffer to keep track of the timestamp when IMU data ready interrupt fires.
|
||||
* The buffer can contain up to 64 items in order to store one timestamp for each packet in FIFO.
|
||||
*/
|
||||
RINGBUFFER(timestamp_buffer, 64, uint64_t);
|
||||
#endif
|
||||
|
||||
/* --------------------------------------------------------------------------------------
|
||||
* Static variables
|
||||
* -------------------------------------------------------------------------------------- */
|
||||
|
||||
/* Flag set from IMU device irq handler */
|
||||
static volatile int irq_from_device;
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------------------------
|
||||
* Forward declaration
|
||||
* -------------------------------------------------------------------------------------- */
|
||||
static int setup_mcu();
|
||||
static void ext_interrupt_cb(void * context, unsigned int int_num);
|
||||
|
||||
void msg_printer(int level, const char * str, va_list ap);
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------------------------
|
||||
* Functions definitions
|
||||
* -------------------------------------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* This function initializes MCU on which this software is running.
|
||||
* It configures:
|
||||
* - a UART link used to print some messages
|
||||
* - interrupt priority group and GPIO so that MCU can receive interrupts from IMU
|
||||
* - a microsecond timer requested by IMU driver to compute some delay
|
||||
* - a microsecond timer used to get some timestamps
|
||||
* - a serial link to communicate from MCU to IMU
|
||||
*/
|
||||
static int setup_mcu()
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
platform_io_hal_board_init();
|
||||
|
||||
/* configure UART */
|
||||
config_uart(LOG_UART_ID);
|
||||
|
||||
/* Setup message facility to see internal traces from FW */
|
||||
PLATFORM_MSG_SETUP(MSG_LEVEL, msg_printer);
|
||||
|
||||
INV_MSG(INV_MSG_LEVEL_INFO, "######################################");
|
||||
INV_MSG(INV_MSG_LEVEL_INFO, "# #XIAN MCU Driver V1.0 SELFTEST EX #");
|
||||
INV_MSG(INV_MSG_LEVEL_INFO, "######################################");
|
||||
|
||||
/*
|
||||
* Configure input capture mode GPIO connected to pin EXT3-9 (pin PB03).
|
||||
* This pin is connected to Icm406xx INT1 output and thus will receive interrupts
|
||||
* enabled on INT1 from the device.
|
||||
* A callback function is also passed that will be executed each time an interrupt
|
||||
* fires.
|
||||
*/
|
||||
platform_gpio_sensor_irq_init(INV_GPIO_INT1, ext_interrupt_cb, 0);
|
||||
|
||||
/* Init timer peripheral for delay */
|
||||
rc |= platform_delay_init(DELAY_TIMER);
|
||||
|
||||
/*
|
||||
* Configure the timer for the timebase
|
||||
*/
|
||||
rc |= platform_timer_configure_timebase(1000000);
|
||||
platform_timer_enable(TIMEBASE_TIMER);
|
||||
|
||||
inv_imu_set_serif(platform_io_hal_read_reg, platform_io_hal_write_reg);
|
||||
inv_imu_set_delay(platform_delay_ms,platform_delay_us); //void (*delay_ms)(uint32_t), void (*delay_us)(uint32_t))
|
||||
rc |= platform_io_hal_init();
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* IMU interrupt handler.
|
||||
* Function is executed when an IMU interrupt rises on MCU.
|
||||
* This function get a timestamp and store it in the timestamp buffer.
|
||||
* Note that this function is executed in an interrupt handler and thus no protection
|
||||
* are implemented for shared variable timestamp_buffer.
|
||||
*/
|
||||
static void ext_interrupt_cb(void * context, unsigned int int_num)
|
||||
{
|
||||
(void)context;
|
||||
|
||||
#if !USE_FIFO
|
||||
/*
|
||||
* Read timestamp from the timer dedicated to timestamping
|
||||
*/
|
||||
uint64_t timestamp = platform_timer_get_counter(TIMEBASE_TIMER);
|
||||
|
||||
if(int_num == INV_GPIO_INT1) {
|
||||
if (!RINGBUFFER_FULL(×tamp_buffer))
|
||||
RINGBUFFER_PUSH(×tamp_buffer, ×tamp);
|
||||
}
|
||||
#endif
|
||||
|
||||
irq_from_device |= TO_MASK(int_num);
|
||||
}
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------------------------
|
||||
* Functions definition
|
||||
* -------------------------------------------------------------------------------------- */
|
||||
|
||||
int setup_imu_device()
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
/* Init device */
|
||||
rc = inv_imu_initialize();
|
||||
if (rc != INV_ERROR_SUCCESS) {
|
||||
INV_MSG(INV_MSG_LEVEL_ERROR, "Failed to initialize IMU!");
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
#if !USE_FIFO
|
||||
RINGBUFFER_CLEAR(×tamp_buffer);
|
||||
#endif
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------------------------
|
||||
* Main
|
||||
* -------------------------------------------------------------------------------------- */
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int rc = 0;
|
||||
uint8_t acc_control = 1;
|
||||
uint8_t gyro_control = 1;
|
||||
|
||||
struct inv_imu_selftest_output selftest_result;
|
||||
|
||||
rc |= setup_mcu();
|
||||
|
||||
|
||||
#if !USE_FIFO
|
||||
RINGBUFFER_CLEAR(×tamp_buffer);
|
||||
#endif
|
||||
|
||||
/* Init device */
|
||||
rc = inv_imu_initialize();
|
||||
|
||||
if (rc != INV_ERROR_SUCCESS) {
|
||||
INV_MSG(INV_MSG_LEVEL_ERROR, "Failed to initialize INV concise driver!");
|
||||
return rc;
|
||||
}
|
||||
|
||||
INV_MSG(INV_MSG_LEVEL_INFO, "IMU device successfully initialized");
|
||||
|
||||
rc |= inv_imu_run_selftest(acc_control,gyro_control, &selftest_result);
|
||||
|
||||
if (rc != 0) {
|
||||
INV_LOG(SENSOR_LOG_LEVEL, "selftest run failure. Do nothing %d", rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (selftest_result.accel_status == 0x1)
|
||||
INV_LOG(SENSOR_LOG_LEVEL, "accel Selftest PASS\n");
|
||||
else
|
||||
INV_LOG(SENSOR_LOG_LEVEL, "accel Selftest fail\n");
|
||||
|
||||
if (selftest_result.gyro_status == 0x1)
|
||||
INV_LOG(SENSOR_LOG_LEVEL, "gyro Selftest PASS\n");
|
||||
else
|
||||
INV_LOG(SENSOR_LOG_LEVEL, "gyro Selftest fail\n");
|
||||
|
||||
|
||||
do {
|
||||
|
||||
} while(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Printer function for message facility
|
||||
*/
|
||||
void msg_printer(int level, const char * str, va_list ap)
|
||||
{
|
||||
static char out_str[256]; /* static to limit stack usage */
|
||||
unsigned idx = 0;
|
||||
const char * s[INV_MSG_LEVEL_MAX] = {
|
||||
"", // INV_MSG_LEVEL_OFF
|
||||
"[E] ", // INV_MSG_LEVEL_ERROR
|
||||
"[W] ", // INV_MSG_LEVEL_WARNING
|
||||
"[I] ", // INV_MSG_LEVEL_INFO
|
||||
"[V] ", // INV_MSG_LEVEL_VERBOSE
|
||||
"[D] ", // INV_MSG_LEVEL_DEBUG
|
||||
};
|
||||
idx += snprintf(&out_str[idx], sizeof(out_str) - idx, "%s", s[level]);
|
||||
if(idx >= (sizeof(out_str)))
|
||||
return;
|
||||
idx += vsnprintf(&out_str[idx], sizeof(out_str) - idx, str, ap);
|
||||
if(idx >= (sizeof(out_str)))
|
||||
return;
|
||||
idx += snprintf(&out_str[idx], sizeof(out_str) - idx, "\r\n");
|
||||
if(idx >= (sizeof(out_str)))
|
||||
return;
|
||||
|
||||
platform_uart_mngr_puts(LOG_UART_ID, out_str, idx);
|
||||
}
|
||||
@@ -1,273 +0,0 @@
|
||||
/*
|
||||
* ________________________________________________________________________________________________________
|
||||
* Copyright (c) 2017 InvenSense Inc. All rights reserved.
|
||||
*
|
||||
* This software, related documentation and any modifications thereto (collectively “Software? is subject
|
||||
* to InvenSense and its licensors' intellectual property rights under U.S. and international copyright
|
||||
* and other intellectual property rights laws.
|
||||
*
|
||||
* InvenSense and its licensors retain all intellectual property and proprietary rights in and to the Software
|
||||
* and any use, reproduction, disclosure or distribution of the Software without an express license agreement
|
||||
* from InvenSense is strictly prohibited.
|
||||
*
|
||||
* EXCEPT AS OTHERWISE PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, THE SOFTWARE IS
|
||||
* PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
||||
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* EXCEPT AS OTHERWISE PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, IN NO EVENT SHALL
|
||||
* INVENSENSE BE LIABLE FOR ANY DIRECT, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
||||
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THE SOFTWARE.
|
||||
* ________________________________________________________________________________________________________
|
||||
*/
|
||||
|
||||
/* std */
|
||||
#include <stdio.h>
|
||||
|
||||
/* board driver */
|
||||
#include "common.h"
|
||||
#include "uart_mngr.h"
|
||||
#include "delay.h"
|
||||
#include "gpio.h"
|
||||
#include "timer.h"
|
||||
#include "system_interface.h"
|
||||
|
||||
/* InvenSense utils */
|
||||
#include "Invn/EmbUtils/Message.h"
|
||||
#include "Invn/EmbUtils/RingBuffer.h"
|
||||
|
||||
#include "inv_imu_driver.h"
|
||||
|
||||
|
||||
/*
|
||||
* Select UART port on which INV_MSG() will be printed.
|
||||
*/
|
||||
#define LOG_UART_ID INV_UART_SENSOR_CTRL
|
||||
|
||||
/*
|
||||
* Define msg level
|
||||
*/
|
||||
#define MSG_LEVEL INV_MSG_LEVEL_DEBUG
|
||||
|
||||
/*
|
||||
* Set of timers used throughout standalone applications
|
||||
*/
|
||||
#define TIMEBASE_TIMER INV_TIMER1
|
||||
#define DELAY_TIMER INV_TIMER2
|
||||
|
||||
#if !USE_FIFO
|
||||
/*
|
||||
* Buffer to keep track of the timestamp when IMU data ready interrupt fires.
|
||||
* The buffer can contain up to 64 items in order to store one timestamp for each packet in FIFO.
|
||||
*/
|
||||
RINGBUFFER(timestamp_buffer, 64, uint64_t);
|
||||
#endif
|
||||
|
||||
/* --------------------------------------------------------------------------------------
|
||||
* Static variables
|
||||
* -------------------------------------------------------------------------------------- */
|
||||
|
||||
/* Flag set from IMU device irq handler */
|
||||
static volatile int irq_from_device;
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------------------------
|
||||
* Forward declaration
|
||||
* -------------------------------------------------------------------------------------- */
|
||||
static int setup_mcu();
|
||||
static void ext_interrupt_cb(void * context, unsigned int int_num);
|
||||
|
||||
void msg_printer(int level, const char * str, va_list ap);
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------------------------
|
||||
* Functions definitions
|
||||
* -------------------------------------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* This function initializes MCU on which this software is running.
|
||||
* It configures:
|
||||
* - a UART link used to print some messages
|
||||
* - interrupt priority group and GPIO so that MCU can receive interrupts from IMU
|
||||
* - a microsecond timer requested by IMU driver to compute some delay
|
||||
* - a microsecond timer used to get some timestamps
|
||||
* - a serial link to communicate from MCU to IMU
|
||||
*/
|
||||
static int setup_mcu()
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
platform_io_hal_board_init();
|
||||
|
||||
/* configure UART */
|
||||
config_uart(LOG_UART_ID);
|
||||
|
||||
/* Setup message facility to see internal traces from FW */
|
||||
PLATFORM_MSG_SETUP(MSG_LEVEL, msg_printer);
|
||||
|
||||
INV_MSG(INV_MSG_LEVEL_INFO, "######################################");
|
||||
INV_MSG(INV_MSG_LEVEL_INFO, "# #XIAN MCU Driver V1.0 WOM EXAMPLE #");
|
||||
INV_MSG(INV_MSG_LEVEL_INFO, "######################################");
|
||||
|
||||
/*
|
||||
* Configure input capture mode GPIO connected to pin EXT3-9 (pin PB03).
|
||||
* This pin is connected to Icm406xx INT1 output and thus will receive interrupts
|
||||
* enabled on INT1 from the device.
|
||||
* A callback function is also passed that will be executed each time an interrupt
|
||||
* fires.
|
||||
*/
|
||||
platform_gpio_sensor_irq_init(INV_GPIO_INT1, ext_interrupt_cb, 0);
|
||||
|
||||
/* Init timer peripheral for delay */
|
||||
rc |= platform_delay_init(DELAY_TIMER);
|
||||
|
||||
/*
|
||||
* Configure the timer for the timebase
|
||||
*/
|
||||
rc |= platform_timer_configure_timebase(1000000);
|
||||
platform_timer_enable(TIMEBASE_TIMER);
|
||||
|
||||
inv_imu_set_serif(platform_io_hal_read_reg, platform_io_hal_write_reg);
|
||||
inv_imu_set_delay(platform_delay_ms,platform_delay_us); //void (*delay_ms)(uint32_t), void (*delay_us)(uint32_t))
|
||||
rc |= platform_io_hal_init();
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* IMU interrupt handler.
|
||||
* Function is executed when an IMU interrupt rises on MCU.
|
||||
* This function get a timestamp and store it in the timestamp buffer.
|
||||
* Note that this function is executed in an interrupt handler and thus no protection
|
||||
* are implemented for shared variable timestamp_buffer.
|
||||
*/
|
||||
static void ext_interrupt_cb(void * context, unsigned int int_num)
|
||||
{
|
||||
(void)context;
|
||||
|
||||
#if !USE_FIFO
|
||||
/*
|
||||
* Read timestamp from the timer dedicated to timestamping
|
||||
*/
|
||||
uint64_t timestamp = platform_timer_get_counter(TIMEBASE_TIMER);
|
||||
|
||||
if(int_num == INV_GPIO_INT1) {
|
||||
if (!RINGBUFFER_FULL(×tamp_buffer))
|
||||
RINGBUFFER_PUSH(×tamp_buffer, ×tamp);
|
||||
}
|
||||
#endif
|
||||
|
||||
irq_from_device |= TO_MASK(int_num);
|
||||
}
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------------------------
|
||||
* Functions definition
|
||||
* -------------------------------------------------------------------------------------- */
|
||||
|
||||
int setup_imu_device()
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
/* Init device */
|
||||
rc = inv_imu_initialize();
|
||||
if (rc != INV_ERROR_SUCCESS) {
|
||||
INV_MSG(INV_MSG_LEVEL_ERROR, "Failed to initialize IMU!");
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
#if !USE_FIFO
|
||||
RINGBUFFER_CLEAR(×tamp_buffer);
|
||||
#endif
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------
|
||||
* Main
|
||||
* -------------------------------------------------------------------------------------- */
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int rc = 0;
|
||||
bool wom_detect_result = false;
|
||||
int wom_flag;
|
||||
|
||||
rc |= setup_mcu();
|
||||
|
||||
|
||||
#if !USE_FIFO
|
||||
RINGBUFFER_CLEAR(×tamp_buffer);
|
||||
#endif
|
||||
|
||||
/* Init device */
|
||||
rc = inv_imu_initialize();
|
||||
|
||||
if (rc != INV_ERROR_SUCCESS) {
|
||||
INV_MSG(INV_MSG_LEVEL_ERROR, "Failed to initialize INV concise driver!");
|
||||
return rc;
|
||||
}
|
||||
|
||||
INV_MSG(INV_MSG_LEVEL_INFO, "IMU device successfully initialized");
|
||||
|
||||
rc += inv_imu_wom_enable(WOM_THRESHOLD_X,WOM_THRESHOLD_Y,WOM_THRESHOLD_Z,WOM_CONFIG_WOM_INT_DUR_4_SMPL);
|
||||
|
||||
|
||||
if (rc != 0) {
|
||||
INV_LOG(SENSOR_LOG_LEVEL, "Feature enable Failed. Do nothing %d", rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
|
||||
do {
|
||||
/* Poll device for data */
|
||||
if (irq_from_device & TO_MASK(INV_GPIO_INT1)) {
|
||||
|
||||
inv_disable_irq();
|
||||
|
||||
wom_flag = inv_imu_wom_get_event(&wom_detect_result);
|
||||
INV_LOG(SENSOR_LOG_LEVEL, "wom result %d, flag %x",wom_detect_result,wom_flag);
|
||||
|
||||
irq_from_device &= ~TO_MASK(INV_GPIO_INT1);
|
||||
inv_enable_irq();
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
if (i == 20) {
|
||||
rc = inv_imu_wom_disable();
|
||||
i++;
|
||||
}
|
||||
} while(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Printer function for message facility
|
||||
*/
|
||||
void msg_printer(int level, const char * str, va_list ap)
|
||||
{
|
||||
static char out_str[256]; /* static to limit stack usage */
|
||||
unsigned idx = 0;
|
||||
const char * s[INV_MSG_LEVEL_MAX] = {
|
||||
"", // INV_MSG_LEVEL_OFF
|
||||
"[E] ", // INV_MSG_LEVEL_ERROR
|
||||
"[W] ", // INV_MSG_LEVEL_WARNING
|
||||
"[I] ", // INV_MSG_LEVEL_INFO
|
||||
"[V] ", // INV_MSG_LEVEL_VERBOSE
|
||||
"[D] ", // INV_MSG_LEVEL_DEBUG
|
||||
};
|
||||
idx += snprintf(&out_str[idx], sizeof(out_str) - idx, "%s", s[level]);
|
||||
if(idx >= (sizeof(out_str)))
|
||||
return;
|
||||
idx += vsnprintf(&out_str[idx], sizeof(out_str) - idx, str, ap);
|
||||
if(idx >= (sizeof(out_str)))
|
||||
return;
|
||||
idx += snprintf(&out_str[idx], sizeof(out_str) - idx, "\r\n");
|
||||
if(idx >= (sizeof(out_str)))
|
||||
return;
|
||||
|
||||
platform_uart_mngr_puts(LOG_UART_ID, out_str, idx);
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
// Copyright 2020 Espressif Systems (Shanghai) Co. Ltd.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "stdio.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/queue.h"
|
||||
#include "freertos/timers.h"
|
||||
#include "esp_log.h"
|
||||
#include "unity.h"
|
||||
#include "icm42670.h"
|
||||
|
||||
static const char *TAG = "IMU TEST";
|
||||
|
||||
|
||||
static void icm42670_test(void *args)
|
||||
{
|
||||
AccDataPacket accData;
|
||||
GyroDataPacket gyroData;
|
||||
chip_temperature imu_chip_temperature;
|
||||
|
||||
icm42670_init();
|
||||
while (1) {
|
||||
int ret = icm42670_get_raw_data(&accData, &gyroData, &imu_chip_temperature);
|
||||
if (0 == ret) {
|
||||
INV_LOG(SENSOR_LOG_LEVEL, "temperature=%.1f", imu_chip_temperature);
|
||||
INV_LOG(SENSOR_LOG_LEVEL, "ACC %d (%.1f, %.1f, %.1f)", accData.accDataSize, accData.databuff[0].x, accData.databuff[0].y, accData.databuff[0].z);
|
||||
INV_LOG(SENSOR_LOG_LEVEL, "Gyro%d (%.1f, %.1f, %.1f)", gyroData.gyroDataSize, gyroData.databuff[0].x, gyroData.databuff[0].y, gyroData.databuff[0].z);
|
||||
} else {
|
||||
INV_LOG(INV_LOG_LEVEL_ERROR, "read err");
|
||||
}
|
||||
vTaskDelay(pdMS_TO_TICKS(100));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("ICM42670 test", "[imu][box]")
|
||||
{
|
||||
icm42670_test(NULL);
|
||||
}
|
||||
@@ -1,171 +0,0 @@
|
||||
/**
|
||||
* @file ft5x06.c
|
||||
* @brief FT5x06 Capacitive Touch Panel Controller Driver
|
||||
* @version 0.1
|
||||
* @date 2021-01-13
|
||||
*
|
||||
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "bsp_i2c.h"
|
||||
#include "ft5x06.h"
|
||||
|
||||
/** @brief FT5x06 register map and function codes */
|
||||
#define FT5x06_ADDR (0x38)
|
||||
|
||||
#define FT5x06_DEVICE_MODE (0x00)
|
||||
#define FT5x06_GESTURE_ID (0x01)
|
||||
#define FT5x06_TOUCH_POINTS (0x02)
|
||||
|
||||
#define FT5x06_TOUCH1_EV_FLAG (0x03)
|
||||
#define FT5x06_TOUCH1_XH (0x03)
|
||||
#define FT5x06_TOUCH1_XL (0x04)
|
||||
#define FT5x06_TOUCH1_YH (0x05)
|
||||
#define FT5x06_TOUCH1_YL (0x06)
|
||||
|
||||
#define FT5x06_TOUCH2_EV_FLAG (0x09)
|
||||
#define FT5x06_TOUCH2_XH (0x09)
|
||||
#define FT5x06_TOUCH2_XL (0x0A)
|
||||
#define FT5x06_TOUCH2_YH (0x0B)
|
||||
#define FT5x06_TOUCH2_YL (0x0C)
|
||||
|
||||
#define FT5x06_TOUCH3_EV_FLAG (0x0F)
|
||||
#define FT5x06_TOUCH3_XH (0x0F)
|
||||
#define FT5x06_TOUCH3_XL (0x10)
|
||||
#define FT5x06_TOUCH3_YH (0x11)
|
||||
#define FT5x06_TOUCH3_YL (0x12)
|
||||
|
||||
#define FT5x06_TOUCH4_EV_FLAG (0x15)
|
||||
#define FT5x06_TOUCH4_XH (0x15)
|
||||
#define FT5x06_TOUCH4_XL (0x16)
|
||||
#define FT5x06_TOUCH4_YH (0x17)
|
||||
#define FT5x06_TOUCH4_YL (0x18)
|
||||
|
||||
#define FT5x06_TOUCH5_EV_FLAG (0x1B)
|
||||
#define FT5x06_TOUCH5_XH (0x1B)
|
||||
#define FT5x06_TOUCH5_XL (0x1C)
|
||||
#define FT5x06_TOUCH5_YH (0x1D)
|
||||
#define FT5x06_TOUCH5_YL (0x1E)
|
||||
|
||||
#define FT5x06_ID_G_THGROUP (0x80)
|
||||
#define FT5x06_ID_G_THPEAK (0x81)
|
||||
#define FT5x06_ID_G_THCAL (0x82)
|
||||
#define FT5x06_ID_G_THWATER (0x83)
|
||||
#define FT5x06_ID_G_THTEMP (0x84)
|
||||
#define FT5x06_ID_G_THDIFF (0x85)
|
||||
#define FT5x06_ID_G_CTRL (0x86)
|
||||
#define FT5x06_ID_G_TIME_ENTER_MONITOR (0x87)
|
||||
#define FT5x06_ID_G_PERIODACTIVE (0x88)
|
||||
#define FT5x06_ID_G_PERIODMONITOR (0x89)
|
||||
#define FT5x06_ID_G_AUTO_CLB_MODE (0xA0)
|
||||
#define FT5x06_ID_G_LIB_VERSION_H (0xA1)
|
||||
#define FT5x06_ID_G_LIB_VERSION_L (0xA2)
|
||||
#define FT5x06_ID_G_CIPHER (0xA3)
|
||||
#define FT5x06_ID_G_MODE (0xA4)
|
||||
#define FT5x06_ID_G_PMODE (0xA5)
|
||||
#define FT5x06_ID_G_FIRMID (0xA6)
|
||||
#define FT5x06_ID_G_STATE (0xA7)
|
||||
#define FT5x06_ID_G_FT5201ID (0xA8)
|
||||
#define FT5x06_ID_G_ERR (0xA9)
|
||||
|
||||
static i2c_bus_device_handle_t ft5x06_handle = NULL;
|
||||
|
||||
static inline esp_err_t ft5x06_read_byte(uint8_t reg_addr, uint8_t *data)
|
||||
{
|
||||
return i2c_bus_read_byte(ft5x06_handle, reg_addr, data);
|
||||
}
|
||||
|
||||
static inline esp_err_t ft5x06_read_bytes(uint8_t reg_addr, size_t data_len, uint8_t *data)
|
||||
{
|
||||
return i2c_bus_read_bytes(ft5x06_handle, reg_addr, data_len, data);
|
||||
}
|
||||
|
||||
static inline esp_err_t ft5x06_write_byte(uint8_t reg_addr, uint8_t data)
|
||||
{
|
||||
return i2c_bus_write_byte(ft5x06_handle, reg_addr, data);
|
||||
}
|
||||
|
||||
esp_err_t ft5x06_init(void)
|
||||
{
|
||||
if (NULL != ft5x06_handle) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
bsp_i2c_add_device(&ft5x06_handle, FT5x06_ADDR);
|
||||
|
||||
if (NULL == ft5x06_handle) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t ret_val = ESP_OK;
|
||||
|
||||
// Valid touching detect threshold
|
||||
i2c_bus_write_byte(ft5x06_handle, FT5x06_ID_G_THGROUP, 70);
|
||||
|
||||
// valid touching peak detect threshold
|
||||
i2c_bus_write_byte(ft5x06_handle, FT5x06_ID_G_THPEAK, 60);
|
||||
|
||||
// Touch focus threshold
|
||||
i2c_bus_write_byte(ft5x06_handle, FT5x06_ID_G_THCAL, 16);
|
||||
|
||||
// threshold when there is surface water
|
||||
i2c_bus_write_byte(ft5x06_handle, FT5x06_ID_G_THWATER, 60);
|
||||
|
||||
// threshold of temperature compensation
|
||||
i2c_bus_write_byte(ft5x06_handle, FT5x06_ID_G_THTEMP, 10);
|
||||
|
||||
// Touch difference threshold
|
||||
i2c_bus_write_byte(ft5x06_handle, FT5x06_ID_G_THDIFF, 20);
|
||||
|
||||
// Delay to enter 'Monitor' status (s)
|
||||
i2c_bus_write_byte(ft5x06_handle, FT5x06_ID_G_TIME_ENTER_MONITOR, 2);
|
||||
|
||||
// Period of 'Active' status (ms)
|
||||
i2c_bus_write_byte(ft5x06_handle, FT5x06_ID_G_PERIODACTIVE, 12);
|
||||
|
||||
// Timer to enter 'idle' when in 'Monitor' (ms)
|
||||
i2c_bus_write_byte(ft5x06_handle, FT5x06_ID_G_PERIODMONITOR, 40);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t ft5x06_get_touch_points_num(uint8_t *touch_points_num)
|
||||
{
|
||||
return ft5x06_read_byte(FT5x06_TOUCH_POINTS, touch_points_num);
|
||||
}
|
||||
|
||||
esp_err_t ft5x06_read_pos(uint8_t *touch_points_num, uint16_t *x, uint16_t *y)
|
||||
{
|
||||
esp_err_t ret_val = ESP_OK;
|
||||
static uint8_t data[4];
|
||||
|
||||
ret_val |= ft5x06_get_touch_points_num(touch_points_num);
|
||||
|
||||
if (0 == *touch_points_num) {
|
||||
} else {
|
||||
ret_val |= ft5x06_read_bytes(FT5x06_TOUCH1_XH, 4, data);
|
||||
|
||||
*x = ((data[0] & 0x0f) << 8) + data[1];
|
||||
*y = ((data[2] & 0x0f) << 8) + data[3];
|
||||
}
|
||||
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
esp_err_t fx5x06_read_gesture(ft5x06_gesture_t *gesture)
|
||||
{
|
||||
return ft5x06_read_byte(FT5x06_GESTURE_ID, (uint8_t *)gesture);
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
/**
|
||||
* @file ft5x06.h
|
||||
* @brief FT5x06 driver header file.
|
||||
* @version 0.1
|
||||
* @date 2021-03-07
|
||||
*
|
||||
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
ft5x06_gesture_none = 0x00,
|
||||
ft5x06_gesture_move_up = 0x10,
|
||||
ft5x06_gesture_move_left = 0x14,
|
||||
ft5x06_gesture_move_down = 0x18,
|
||||
ft5x06_gesture_move_right = 0x1c,
|
||||
ft5x06_gesture_zoom_in = 0x48,
|
||||
ft5x06_gesture_zoom_out = 0x49,
|
||||
} ft5x06_gesture_t;
|
||||
|
||||
/**
|
||||
* @brief Init FT5x06 series touch panel
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Success
|
||||
* - Others: Fail
|
||||
*/
|
||||
esp_err_t ft5x06_init(void);
|
||||
|
||||
/**
|
||||
* @brief Read touch point from FT5x06
|
||||
*
|
||||
* @param touch_points_num Touch point number
|
||||
* @param x X coordinate
|
||||
* @param y Y coordinate
|
||||
* @return
|
||||
* - ESP_OK: Success
|
||||
* - Others: Fail
|
||||
*/
|
||||
esp_err_t ft5x06_read_pos(uint8_t *touch_points_num, uint16_t *x, uint16_t *y);
|
||||
|
||||
/**
|
||||
* @brief Read guesture from FT5x06
|
||||
*
|
||||
* @param gesture Gesture read from FT5x06
|
||||
* @return
|
||||
* - ESP_OK: Success
|
||||
* - Others: Fail
|
||||
*/
|
||||
esp_err_t fx5x06_read_gesture(ft5x06_gesture_t *gesture);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -1,80 +0,0 @@
|
||||
/**
|
||||
* @file tt21100.h
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2021-09-06
|
||||
*
|
||||
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Init TT21100 touch panel
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Success
|
||||
* - Others: Fail
|
||||
*/
|
||||
esp_err_t tt21100_tp_init(void);
|
||||
|
||||
/**
|
||||
* @brief Read packet from TT21100
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Success
|
||||
* - Others: Fail
|
||||
*/
|
||||
esp_err_t tt21100_tp_read(void);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param p_tp_num
|
||||
* @param p_x
|
||||
* @param p_y
|
||||
* @return esp_err_t
|
||||
*/
|
||||
esp_err_t tt21100_get_touch_point(uint8_t *p_tp_num, uint16_t *p_x, uint16_t *p_y);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param p_btn_val
|
||||
* @param p_btn_signal
|
||||
* @return esp_err_t
|
||||
*/
|
||||
esp_err_t tt21100_get_btn_val(uint8_t *p_btn_val, uint16_t *p_btn_signal);
|
||||
|
||||
/**
|
||||
* @brief TT21100 will keep COMM_INT low until all data read.
|
||||
* So if the INT line is low after read the packet, read again.
|
||||
*
|
||||
* @return true Data avaliable
|
||||
* @return false All data has been read
|
||||
*/
|
||||
bool tt21100_data_avaliable(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,199 +0,0 @@
|
||||
/**
|
||||
* @file tt21100.c
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2021-09-06
|
||||
*
|
||||
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "bsp_i2c.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "driver/i2c.h"
|
||||
#include "i2c_bus.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_log.h"
|
||||
#include "freertos/task.h"
|
||||
|
||||
#define TT21100_CHIP_ADDR_DEFAULT (0x24)
|
||||
#define TT21100_REG_TP_NUM (0x1)
|
||||
#define TT21100_REG_X_POS (0x2)
|
||||
#define TT21100_REG_Y_POS (0x3)
|
||||
|
||||
static const char *TAG = "tt21100";
|
||||
|
||||
static uint8_t tp_num, btn_val;
|
||||
static uint16_t x, y, btn_signal;
|
||||
static i2c_bus_device_handle_t tt21100_handle = NULL;
|
||||
|
||||
static esp_err_t tt21100_read(uint8_t *data, size_t data_len)
|
||||
{
|
||||
static uint8_t cmd_buffer[I2C_LINK_RECOMMENDED_SIZE(4)];
|
||||
i2c_cmd_handle_t cmd = i2c_cmd_link_create_static(cmd_buffer, I2C_LINK_RECOMMENDED_SIZE(4));
|
||||
|
||||
i2c_master_start(cmd);
|
||||
i2c_master_write_byte(cmd, (TT21100_CHIP_ADDR_DEFAULT << 1) | I2C_MASTER_READ, I2C_ACK_CHECK_EN);
|
||||
i2c_master_read(cmd, data, data_len, I2C_MASTER_LAST_NACK);
|
||||
i2c_master_stop(cmd);
|
||||
|
||||
esp_err_t ret_val = i2c_bus_cmd_begin(tt21100_handle, cmd);
|
||||
i2c_cmd_link_delete_static(cmd);
|
||||
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
esp_err_t tt21100_tp_init(void)
|
||||
{
|
||||
if (NULL != tt21100_handle) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t ret_val = ESP_OK;
|
||||
|
||||
ret_val |= bsp_i2c_add_device(&tt21100_handle, TT21100_CHIP_ADDR_DEFAULT);
|
||||
|
||||
if (NULL == tt21100_handle) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
uint16_t reg_val = 0;
|
||||
do {
|
||||
tt21100_read(®_val, sizeof(reg_val));
|
||||
vTaskDelay(pdMS_TO_TICKS(20));
|
||||
} while (0x0002 != reg_val);
|
||||
|
||||
gpio_config_t io_conf_key;
|
||||
io_conf_key.intr_type = GPIO_PIN_INTR_DISABLE;
|
||||
io_conf_key.mode = GPIO_MODE_INPUT;
|
||||
io_conf_key.pin_bit_mask = 1ULL << GPIO_NUM_3;
|
||||
io_conf_key.pull_down_en = GPIO_PULLDOWN_DISABLE;
|
||||
io_conf_key.pull_up_en = GPIO_PULLUP_ENABLE;
|
||||
ESP_ERROR_CHECK(gpio_config(&io_conf_key));
|
||||
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
esp_err_t tt21100_tp_read(void)
|
||||
{
|
||||
typedef struct {
|
||||
uint8_t :5;
|
||||
uint8_t touch_type:3;
|
||||
uint8_t tip:1;
|
||||
uint8_t event_id:2;
|
||||
uint8_t touch_id:5;
|
||||
uint16_t x;
|
||||
uint16_t y;
|
||||
uint8_t pressure;
|
||||
uint16_t major_axis_length;
|
||||
uint8_t orientation;
|
||||
} __attribute__((packed)) touch_record_struct_t;
|
||||
|
||||
typedef struct {
|
||||
uint16_t data_len;
|
||||
uint8_t report_id;
|
||||
uint16_t time_stamp;
|
||||
uint8_t :2;
|
||||
uint8_t large_object : 1;
|
||||
uint8_t record_num : 5;
|
||||
uint8_t report_counter:2;
|
||||
uint8_t :3;
|
||||
uint8_t noise_efect:3;
|
||||
touch_record_struct_t touch_record[0];
|
||||
} __attribute__((packed)) touch_report_struct_t;
|
||||
|
||||
typedef struct {
|
||||
uint16_t length; /*!< Always 14(0x000E) */
|
||||
uint8_t report_id; /*!< Always 03h */
|
||||
uint16_t time_stamp; /*!< Number in units of 100 us */
|
||||
uint8_t btn_val; /*!< Only use bit[0..3] */
|
||||
uint16_t btn_signal[4];
|
||||
} __attribute__((packed)) button_record_struct_t;
|
||||
|
||||
touch_report_struct_t *p_report_data = NULL;
|
||||
touch_record_struct_t *p_touch_data = NULL;
|
||||
button_record_struct_t *p_btn_data = NULL;
|
||||
|
||||
static uint16_t data_len;
|
||||
static uint8_t data[256];
|
||||
esp_err_t ret_val = ESP_OK;
|
||||
|
||||
/* Get report data length */
|
||||
ret_val |= tt21100_read(&data_len, sizeof(data_len));
|
||||
ESP_LOGD(TAG, "Data len : %u", data_len);
|
||||
|
||||
/* Read report data if length */
|
||||
if (data_len < 0xff) {
|
||||
tt21100_read(data, data_len);
|
||||
switch (data_len) {
|
||||
case 2: /* No avaliable data*/
|
||||
break;
|
||||
case 7:
|
||||
case 17:
|
||||
case 27:
|
||||
p_report_data = (touch_report_struct_t *) data;
|
||||
p_touch_data = &p_report_data->touch_record[0];
|
||||
x = p_touch_data->x;
|
||||
y = p_touch_data->y;
|
||||
|
||||
tp_num = (data_len - sizeof(touch_report_struct_t)) / sizeof(touch_record_struct_t);
|
||||
for (size_t i = 0; i < tp_num; i++) {
|
||||
p_touch_data = &p_report_data->touch_record[i];
|
||||
ESP_LOGD(TAG, "(%zu) [%3u][%3u]", i, p_touch_data->x, p_touch_data->y);
|
||||
}
|
||||
break;
|
||||
case 14: /* Button event */
|
||||
p_btn_data = (button_record_struct_t *) data;
|
||||
btn_val = p_btn_data->btn_val;
|
||||
btn_signal = p_btn_data->btn_signal[0];
|
||||
ESP_LOGD(TAG, "Len : %04Xh. ID : %02Xh. Time : %5u. Val : [%u] - [%04X][%04X][%04X][%04X]",
|
||||
p_btn_data->length, p_btn_data->report_id, p_btn_data->time_stamp, p_btn_data->btn_val,
|
||||
p_btn_data->btn_signal[0], p_btn_data->btn_signal[1], p_btn_data->btn_signal[2], p_btn_data->btn_signal[3]);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
esp_err_t tt21100_get_touch_point(uint8_t *p_tp_num, uint16_t *p_x, uint16_t *p_y)
|
||||
{
|
||||
*p_x = x;
|
||||
*p_y = y;
|
||||
*p_tp_num = tp_num;
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t tt21100_get_btn_val(uint8_t *p_btn_val, uint16_t *p_btn_signal)
|
||||
{
|
||||
*p_btn_val = btn_val;
|
||||
*p_btn_signal = btn_signal;
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
bool tt21100_data_avaliable(void)
|
||||
{
|
||||
int level = gpio_get_level(GPIO_NUM_3);
|
||||
if (level) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
# CMakeLists.txt
|
||||
#
|
||||
# Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
# Search for src files
|
||||
file(GLOB_RECURSE LVGL_SOURCES
|
||||
lvgl/src/*.c
|
||||
lvgl/examples/*.c)
|
||||
|
||||
file(GLOB_RECURSE LV_DEMOS_SOURCES lv_demos/src/*.c)
|
||||
file(GLOB_RECURSE LV_PORT_SOURCES lv_port/*.c)
|
||||
|
||||
# Resister components
|
||||
idf_component_register(
|
||||
SRCS
|
||||
${LVGL_SOURCES}
|
||||
${LV_DEMOS_SOURCES}
|
||||
${LV_PORT_SOURCES}
|
||||
INCLUDE_DIRS
|
||||
"."
|
||||
"include"
|
||||
"lvgl/src"
|
||||
"lv_demos"
|
||||
"lv_port"
|
||||
REQUIRES
|
||||
bsp
|
||||
main)
|
||||
|
||||
# Some of warinings from LVGL. Block them.
|
||||
target_compile_options(${COMPONENT_LIB} PRIVATE -w)
|
||||
|
||||
# We're using Kconfig, will will add `CONFIG_` prifix to MACRO.
|
||||
# This macro will use a wrapper macro like `#define LV_USE_XXX CONFIG_LV_USE_XXX`
|
||||
# But since `lv_conf_internal.h` will add `_LV_KCONFIG_PRESENT` if
|
||||
# `CONFIG_LV_COLOR_DEPTH` is defined. So this might not required.
|
||||
# target_compile_definitions(${COMPONENT_LIB} PUBLIC "-D_LV_KCONFIG_PRESENT")
|
||||
|
||||
# Use simple include
|
||||
target_compile_definitions(${COMPONENT_LIB} PUBLIC "-DLV_CONF_INCLUDE_SIMPLE")
|
||||
target_compile_definitions(${COMPONENT_LIB} PUBLIC "-DLV_DEMO_CONF_INCLUDE_SIMPLE")
|
||||
|
||||
# Workaround for file system support
|
||||
target_compile_definitions(${COMPONENT_LIB} PUBLIC "-DCONFIG_LV_USE_FS_STDIO='S'")
|
||||
|
||||
if (CONFIG_LV_MEM_CUSTOM)
|
||||
if (CONFIG_LV_MEM_CUSTOM_ALLOC)
|
||||
target_compile_definitions(${COMPONENT_LIB} PUBLIC "-DLV_MEM_CUSTOM_ALLOC=${CONFIG_LV_MEM_CUSTOM_ALLOC}")
|
||||
endif()
|
||||
|
||||
if (CONFIG_LV_MEM_CUSTOM_FREE)
|
||||
target_compile_definitions(${COMPONENT_LIB} PUBLIC "-DLV_MEM_CUSTOM_FREE=${CONFIG_LV_MEM_CUSTOM_FREE}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (CONFIG_LV_TICK_CUSTOM)
|
||||
if (CONFIG_LV_TICK_CUSTOM_SYS_TIME_EXPR)
|
||||
target_compile_definitions(${COMPONENT_LIB} PUBLIC "-DLV_TICK_CUSTOM_SYS_TIME_EXPR=${CONFIG_LV_TICK_CUSTOM_SYS_TIME_EXPR}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# This will make LVGL faster but use more RAM if enabled
|
||||
if (CONFIG_LV_ATTRIBUTE_FAST_MEM_USE_IRAM)
|
||||
target_compile_definitions(${COMPONENT_LIB} PUBLIC "-DLV_ATTRIBUTE_FAST_MEM=IRAM_ATTR")
|
||||
endif()
|
||||
@@ -1,853 +0,0 @@
|
||||
# Kconfig file for LVGL v8.0
|
||||
|
||||
menu "LVGL configuration"
|
||||
|
||||
# Define CONFIG_LV_CONF_SKIP so we can use LVGL
|
||||
# without lv_conf.h file, the lv_conf_internal.h and
|
||||
# lv_conf_kconfig.h files are used instead.
|
||||
config LV_CONF_SKIP
|
||||
bool
|
||||
default y
|
||||
|
||||
config LV_CONF_MINIMAL
|
||||
bool "LVGL minimal configuration."
|
||||
|
||||
menu "Color settings"
|
||||
choice
|
||||
prompt "Color depth."
|
||||
default LV_COLOR_DEPTH_16
|
||||
help
|
||||
Color depth to be used.
|
||||
|
||||
config LV_COLOR_DEPTH_32
|
||||
bool "32: ARGB8888"
|
||||
config LV_COLOR_DEPTH_16
|
||||
bool "16: RGB565"
|
||||
config LV_COLOR_DEPTH_8
|
||||
bool "8: RGB232"
|
||||
config LV_COLOR_DEPTH_1
|
||||
bool "1: 1 byte per pixel"
|
||||
endchoice
|
||||
|
||||
config LV_COLOR_DEPTH
|
||||
int
|
||||
default 1 if LV_COLOR_DEPTH_1
|
||||
default 8 if LV_COLOR_DEPTH_8
|
||||
default 16 if LV_COLOR_DEPTH_16
|
||||
default 32 if LV_COLOR_DEPTH_32
|
||||
|
||||
config LV_COLOR_16_SWAP
|
||||
bool "Swap the 2 bytes of RGB565 color. Useful if the display has an 8-bit interface (e.g. SPI)."
|
||||
depends on LV_COLOR_DEPTH_16
|
||||
default y
|
||||
|
||||
config LV_COLOR_SCREEN_TRANSP
|
||||
bool "Enable more complex drawing routines to manage screens transparency."
|
||||
depends on LV_COLOR_DEPTH_32
|
||||
help
|
||||
Can be used if the UI is above another layer, e.g. an OSD menu or video player.
|
||||
Requires `LV_COLOR_DEPTH = 32` colors and the screen's `bg_opa` should be set to
|
||||
non LV_OPA_COVER value
|
||||
|
||||
config LV_COLOR_MIX_ROUND_OFS
|
||||
int "Adjust color mix functions rounding"
|
||||
default 128 if !LV_COLOR_DEPTH_32
|
||||
default 0 if LV_COLOR_DEPTH_32
|
||||
range 0 254
|
||||
help
|
||||
0: no adjustment, get the integer part of the result (round down)
|
||||
64: round up from x.75
|
||||
128: round up from half
|
||||
192: round up from x.25
|
||||
254: round up
|
||||
|
||||
config LV_COLOR_CHROMA_KEY_HEX
|
||||
hex "Images pixels with this color will not be drawn (if they are chroma keyed)."
|
||||
range 0x000000 0xFFFFFF
|
||||
default 0x00FF00
|
||||
help
|
||||
See misc/lv_color.h for some color values examples.
|
||||
endmenu
|
||||
|
||||
menu "Memory settings"
|
||||
config LV_MEM_CUSTOM
|
||||
bool "If true use custom malloc/free, otherwise use the built-in `lv_mem_alloc()` and `lv_mem_free()`"
|
||||
default y
|
||||
|
||||
config LV_MEM_SIZE_KILOBYTES
|
||||
int "Size of the memory used by `lv_mem_alloc` in kilobytes (>= 2kB)"
|
||||
range 2 128
|
||||
default 32
|
||||
depends on !LV_MEM_CUSTOM
|
||||
|
||||
config LV_MEM_ADDR
|
||||
hex "Address for the memory pool instead of allocating it as a normal array"
|
||||
default 0x0
|
||||
depends on !LV_MEM_CUSTOM
|
||||
|
||||
config LV_MEM_CUSTOM_INCLUDE
|
||||
string "Header to include for the custom memory function"
|
||||
default "stdlib.h"
|
||||
depends on LV_MEM_CUSTOM
|
||||
|
||||
config LV_MEM_BUF_MAX_NUM
|
||||
int "Number of the memory buffer"
|
||||
default 16
|
||||
help
|
||||
Number of the intermediate memory buffer used during rendering and other
|
||||
internal processing mechanisms. You will see an error log message if
|
||||
there wasn't enough buffers.
|
||||
|
||||
config LV_MEMCPY_MEMSET_STD
|
||||
bool "Use the standard memcpy and memset instead of LVGL's own functions"
|
||||
default y
|
||||
endmenu
|
||||
|
||||
menu "HAL Settings"
|
||||
config LV_DISP_DEF_REFR_PERIOD
|
||||
int "Default display refresh period (ms)."
|
||||
default 30
|
||||
help
|
||||
Can be changed in the display driver (`lv_disp_drv_t`).
|
||||
|
||||
config LV_INDEV_DEF_READ_PERIOD
|
||||
int "Input device read period [ms]."
|
||||
default 30
|
||||
|
||||
config LV_TICK_CUSTOM
|
||||
bool "Use a custom tick source"
|
||||
|
||||
config LV_TICK_CUSTOM_INCLUDE
|
||||
string "Header for the system time function"
|
||||
default "Arduino.h"
|
||||
depends on LV_TICK_CUSTOM
|
||||
|
||||
config LV_DPI_DEF
|
||||
int "Default Dots Per Inch (in px)."
|
||||
default 130
|
||||
help
|
||||
Used to initialize default sizes such as widgets sized, style paddings.
|
||||
(Not so important, you can adjust it to modify default sizes and spaces)
|
||||
endmenu
|
||||
|
||||
menu "Feature configuration"
|
||||
|
||||
menu "Drawing"
|
||||
config LV_DRAW_COMPLEX
|
||||
bool "Enable complex draw engine"
|
||||
default y
|
||||
help
|
||||
Required to draw shadow, gradient, rounded corners, circles, arc, skew lines,
|
||||
image transformations or any masks.
|
||||
|
||||
config LV_SHADOW_CACHE_SIZE
|
||||
int "Allow buffering some shadow calculation"
|
||||
depends on LV_DRAW_COMPLEX
|
||||
default 0
|
||||
help
|
||||
LV_SHADOW_CACHE_SIZE is the max shadow size to buffer, where
|
||||
shadow size is `shadow_width + radius`.
|
||||
Caching has LV_SHADOW_CACHE_SIZE^2 RAM cost.
|
||||
|
||||
config LV_CIRCLE_CACHE_SIZE
|
||||
int "Set number of maximally cached circle data"
|
||||
depends on LV_DRAW_COMPLEX
|
||||
default 4
|
||||
help
|
||||
The circumference of 1/4 circle are saved for anti-aliasing
|
||||
radius * 4 bytes are used per circle (the most often used
|
||||
radiuses are saved).
|
||||
Set to 0 to disable caching.
|
||||
|
||||
config LV_IMG_CACHE_DEF_SIZE
|
||||
int "Default image cache size. 0 to disable caching."
|
||||
default 0
|
||||
help
|
||||
If only the built-in image formats are used there is no real advantage of caching.
|
||||
(I.e. no new image decoder is added).
|
||||
|
||||
With complex image decoders (e.g. PNG or JPG) caching can
|
||||
save the continuous open/decode of images.
|
||||
However the opened images might consume additional RAM.
|
||||
|
||||
config LV_DISP_ROT_MAX_BUF
|
||||
int "Maximum buffer size to allocate for rotation"
|
||||
default 10240
|
||||
help
|
||||
Only used if software rotation is enabled in the display driver.
|
||||
endmenu
|
||||
|
||||
menu "GPU"
|
||||
config LV_USE_EXTERNAL_RENDERER
|
||||
bool
|
||||
|
||||
config LV_USE_GPU_STM32_DMA2D
|
||||
bool "Enable STM32 DMA2D (aka Chrom Art) GPU."
|
||||
config LV_GPU_DMA2D_CMSIS_INCLUDE
|
||||
string "include path of CMSIS header of target processor"
|
||||
depends on LV_USE_GPU_STM32_DMA2D
|
||||
default ""
|
||||
help
|
||||
Must be defined to include path of CMSIS header of target processor
|
||||
e.g. "stm32f769xx.h" or "stm32f429xx.h"
|
||||
|
||||
config LV_USE_GPU_NXP_PXP
|
||||
bool "Use NXP's PXP GPU iMX RTxxx platforms."
|
||||
config LV_USE_GPU_NXP_PXP_AUTO_INIT
|
||||
bool "Call lv_gpu_nxp_pxp_init() automatically or manually."
|
||||
depends on LV_USE_GPU_NXP_PXP
|
||||
help
|
||||
1: Add default bare metal and FreeRTOS interrupt handling
|
||||
routines for PXP (lv_gpu_nxp_pxp_osa.c) and call
|
||||
lv_gpu_nxp_pxp_init() automatically during lv_init().
|
||||
Note that symbol SDK_OS_FREE_RTOS has to be defined in order
|
||||
to use FreeRTOS OSA, otherwise bare-metal implementation is
|
||||
selected.
|
||||
0: lv_gpu_nxp_pxp_init() has to be called manually before
|
||||
lv_init().
|
||||
|
||||
config LV_USE_GPU_NXP_VG_LITE
|
||||
bool "Use NXP's VG-Lite GPU iMX RTxxx platforms."
|
||||
|
||||
config LV_USE_GPU_SDL
|
||||
bool "Use SDL renderer API"
|
||||
select LV_USE_EXTERNAL_RENDERER
|
||||
default n
|
||||
config LV_GPU_SDL_INCLUDE_PATH
|
||||
string "include path of SDL header"
|
||||
depends on LV_USE_GPU_SDL
|
||||
default "SDL2/SDL.h"
|
||||
endmenu
|
||||
|
||||
menu "Logging"
|
||||
config LV_USE_LOG
|
||||
bool "Enable the log module"
|
||||
|
||||
choice
|
||||
bool "Default log verbosity" if LV_USE_LOG
|
||||
default LV_LOG_LEVEL_WARN
|
||||
help
|
||||
Specify how important log should be added.
|
||||
|
||||
config LV_LOG_LEVEL_TRACE
|
||||
bool "A lot of logs to give detailed information"
|
||||
config LV_LOG_LEVEL_INFO
|
||||
bool "Log important events"
|
||||
config LV_LOG_LEVEL_WARN
|
||||
bool "Log if something unwanted happened but didn't cause a problem"
|
||||
config LV_LOG_LEVEL_ERROR
|
||||
bool "Only critical issues, when the system may fail"
|
||||
config LV_LOG_LEVEL_USER
|
||||
bool "Only logs added by the user"
|
||||
config LV_LOG_LEVEL_NONE
|
||||
bool "Do not log anything"
|
||||
endchoice
|
||||
|
||||
config LV_LOG_LEVEL
|
||||
int
|
||||
default 0 if LV_LOG_LEVEL_TRACE
|
||||
default 1 if LV_LOG_LEVEL_INFO
|
||||
default 2 if LV_LOG_LEVEL_WARN
|
||||
default 3 if LV_LOG_LEVEL_ERROR
|
||||
default 4 if LV_LOG_LEVEL_USER
|
||||
default 5 if LV_LOG_LEVEL_NONE
|
||||
|
||||
config LV_LOG_PRINTF
|
||||
bool "Print the log with 'printf'" if LV_USE_LOG
|
||||
help
|
||||
Use printf for log output.
|
||||
If not set the user needs to register a callback with `lv_log_register_print_cb`.
|
||||
|
||||
config LV_LOG_TRACE_MEM
|
||||
bool "Enable/Disable LV_LOG_TRACE in mem module"
|
||||
default y
|
||||
depends on LV_USE_LOG
|
||||
|
||||
config LV_LOG_TRACE_TIMER
|
||||
bool "Enable/Disable LV_LOG_TRACE in timer module"
|
||||
default y
|
||||
depends on LV_USE_LOG
|
||||
|
||||
config LV_LOG_TRACE_INDEV
|
||||
bool "Enable/Disable LV_LOG_TRACE in indev module"
|
||||
default y
|
||||
depends on LV_USE_LOG
|
||||
|
||||
config LV_LOG_TRACE_DISP_REFR
|
||||
bool "Enable/Disable LV_LOG_TRACE in disp refr module"
|
||||
default y
|
||||
depends on LV_USE_LOG
|
||||
|
||||
config LV_LOG_TRACE_EVENT
|
||||
bool "Enable/Disable LV_LOG_TRACE in event module"
|
||||
default y
|
||||
depends on LV_USE_LOG
|
||||
|
||||
config LV_LOG_TRACE_OBJ_CREATE
|
||||
bool "Enable/Disable LV_LOG_TRACE in obj create module"
|
||||
default y
|
||||
depends on LV_USE_LOG
|
||||
|
||||
config LV_LOG_TRACE_LAYOUT
|
||||
bool "Enable/Disable LV_LOG_TRACE in layout module"
|
||||
default y
|
||||
depends on LV_USE_LOG
|
||||
|
||||
config LV_LOG_TRACE_ANIM
|
||||
bool "Enable/Disable LV_LOG_TRACE in anim module"
|
||||
default y
|
||||
depends on LV_USE_LOG
|
||||
endmenu
|
||||
|
||||
menu "Asserts"
|
||||
config LV_USE_ASSERT_NULL
|
||||
bool "Check if the parameter is NULL. (Very fast, recommended)"
|
||||
default y if !LV_CONF_MINIMAL
|
||||
|
||||
config LV_USE_ASSERT_MALLOC
|
||||
bool "Checks if the memory is successfully allocated or no. (Very fast, recommended)"
|
||||
default y if !LV_CONF_MINIMAL
|
||||
|
||||
config LV_USE_ASSERT_STYLE
|
||||
bool "Check if the styles are properly initialized. (Very fast, recommended)"
|
||||
|
||||
config LV_USE_ASSERT_MEM_INTEGRITY
|
||||
bool "Check the integrity of `lv_mem` after critical operations. (Slow)"
|
||||
|
||||
config LV_USE_ASSERT_OBJ
|
||||
bool "Check NULL, the object's type and existence (e.g. not deleted). (Slow)."
|
||||
|
||||
config LV_ASSERT_HANDLER_INCLUDE
|
||||
string "Header to include for the custom assert function"
|
||||
default "assert.h"
|
||||
endmenu
|
||||
|
||||
menu "Others"
|
||||
config LV_USE_PERF_MONITOR
|
||||
bool "Show CPU usage and FPS count in the right bottom corner."
|
||||
|
||||
config LV_USE_MEM_MONITOR
|
||||
bool "Show the used memory and the memory fragmentation in the left bottom corner."
|
||||
depends on !LV_MEM_CUSTOM
|
||||
|
||||
config LV_USE_REFR_DEBUG
|
||||
bool "Draw random colored rectangles over the redrawn areas."
|
||||
|
||||
config LV_SPRINTF_CUSTOM
|
||||
bool "Change the built-in (v)snprintf functions"
|
||||
|
||||
config LV_SPRINTF_INCLUDE
|
||||
string "Header to include for the custom sprintf function"
|
||||
depends on LV_SPRINTF_CUSTOM
|
||||
default "stdio.h"
|
||||
|
||||
config LV_SPRINTF_USE_FLOAT
|
||||
bool "Enable float in built-in (v)snprintf functions"
|
||||
depends on !LV_SPRINTF_CUSTOM
|
||||
|
||||
config LV_USE_USER_DATA
|
||||
bool "Add a 'user_data' to drivers and objects."
|
||||
default y
|
||||
|
||||
config LV_ENABLE_GC
|
||||
bool "Enable garbage collector"
|
||||
|
||||
config LV_GC_INCLUDE
|
||||
string "Header to include for the garbage collector related things"
|
||||
depends on LV_ENABLE_GC
|
||||
default "gc.h"
|
||||
endmenu
|
||||
|
||||
menu "Compiler settings"
|
||||
config LV_BIG_ENDIAN_SYSTEM
|
||||
bool "For big endian systems set to 1"
|
||||
|
||||
config LV_ATTRIBUTE_MEM_ALIGN_SIZE
|
||||
int "Required alignment size for buffers"
|
||||
default 1
|
||||
|
||||
config LV_ATTRIBUTE_FAST_MEM_USE_IRAM
|
||||
bool "Set IRAM as LV_ATTRIBUTE_FAST_MEM"
|
||||
help
|
||||
Set this option to configure IRAM as LV_ATTRIBUTE_FAST_MEM
|
||||
|
||||
config LV_USE_LARGE_COORD
|
||||
bool "Extend the default -32k..32k coordinate range to -4M..4M by using int32_t for coordinates instead of int16_t"
|
||||
endmenu
|
||||
endmenu
|
||||
|
||||
menu "Font usage"
|
||||
menu "Enable built-in fonts"
|
||||
config LV_FONT_MONTSERRAT_8
|
||||
bool "Enable Montserrat 8"
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_FONT_MONTSERRAT_10
|
||||
bool "Enable Montserrat 10"
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_FONT_MONTSERRAT_12
|
||||
bool "Enable Montserrat 12"
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_FONT_MONTSERRAT_14
|
||||
bool "Enable Montserrat 14"
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_FONT_MONTSERRAT_16
|
||||
bool "Enable Montserrat 16"
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_FONT_MONTSERRAT_18
|
||||
bool "Enable Montserrat 18"
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_FONT_MONTSERRAT_20
|
||||
bool "Enable Montserrat 20"
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_FONT_MONTSERRAT_22
|
||||
bool "Enable Montserrat 22"
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_FONT_MONTSERRAT_24
|
||||
bool "Enable Montserrat 24"
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_FONT_MONTSERRAT_26
|
||||
bool "Enable Montserrat 26"
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_FONT_MONTSERRAT_28
|
||||
bool "Enable Montserrat 28"
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_FONT_MONTSERRAT_30
|
||||
bool "Enable Montserrat 30"
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_FONT_MONTSERRAT_32
|
||||
bool "Enable Montserrat 32"
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_FONT_MONTSERRAT_34
|
||||
bool "Enable Montserrat 34"
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_FONT_MONTSERRAT_36
|
||||
bool "Enable Montserrat 36"
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_FONT_MONTSERRAT_38
|
||||
bool "Enable Montserrat 38"
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_FONT_MONTSERRAT_40
|
||||
bool "Enable Montserrat 40"
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_FONT_MONTSERRAT_42
|
||||
bool "Enable Montserrat 42"
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_FONT_MONTSERRAT_44
|
||||
bool "Enable Montserrat 44"
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_FONT_MONTSERRAT_46
|
||||
bool "Enable Montserrat 46"
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_FONT_MONTSERRAT_48
|
||||
bool "Enable Montserrat 48"
|
||||
default y if !LV_CONF_MINIMAL
|
||||
|
||||
config LV_FONT_MONTSERRAT_12_SUBPX
|
||||
bool "Enable Montserrat 12 sub-pixel"
|
||||
config LV_FONT_MONTSERRAT_28_COMPRESSED
|
||||
bool "Enable Montserrat 28 compressed"
|
||||
config LV_FONT_DEJAVU_16_PERSIAN_HEBREW
|
||||
bool "Enable Dejavu 16 Persian, Hebrew, Arabic letters"
|
||||
config LV_FONT_SIMSUN_16_CJK
|
||||
bool "Enable Simsun 16 CJK"
|
||||
|
||||
config LV_FONT_UNSCII_8
|
||||
bool "Enable UNSCII 8 (Perfect monospace font)"
|
||||
default y if LV_CONF_MINIMAL
|
||||
config LV_FONT_UNSCII_16
|
||||
bool "Enable UNSCII 16 (Perfect monospace font)"
|
||||
|
||||
config LV_FONT_CUSTOM
|
||||
bool "Enable the custom font"
|
||||
config LV_FONT_CUSTOM_DECLARE
|
||||
string "Header to include for the custom font"
|
||||
depends on LV_FONT_CUSTOM
|
||||
endmenu
|
||||
|
||||
choice LV_FONT_DEFAULT
|
||||
prompt "Select theme default title font"
|
||||
default LV_FONT_DEFAULT_MONTSERRAT_14 if !LV_CONF_MINIMAL
|
||||
default LV_FONT_DEFAULT_UNSCII_8 if LV_CONF_MINIMAL
|
||||
help
|
||||
Select theme default title font
|
||||
|
||||
config LV_FONT_DEFAULT_MONTSERRAT_8
|
||||
bool "Montserrat 8"
|
||||
select LV_FONT_MONTSERRAT_8
|
||||
config LV_FONT_DEFAULT_MONTSERRAT_12
|
||||
bool "Montserrat 12"
|
||||
select LV_FONT_MONTSERRAT_12
|
||||
config LV_FONT_DEFAULT_MONTSERRAT_14
|
||||
bool "Montserrat 14"
|
||||
select LV_FONT_MONTSERRAT_14
|
||||
config LV_FONT_DEFAULT_MONTSERRAT_16
|
||||
bool "Montserrat 16"
|
||||
select LV_FONT_MONTSERRAT_16
|
||||
config LV_FONT_DEFAULT_MONTSERRAT_18
|
||||
bool "Montserrat 18"
|
||||
select LV_FONT_MONTSERRAT_18
|
||||
config LV_FONT_DEFAULT_MONTSERRAT_20
|
||||
bool "Montserrat 20"
|
||||
select LV_FONT_MONTSERRAT_20
|
||||
config LV_FONT_DEFAULT_MONTSERRAT_22
|
||||
bool "Montserrat 22"
|
||||
select LV_FONT_MONTSERRAT_22
|
||||
config LV_FONT_DEFAULT_MONTSERRAT_24
|
||||
bool "Montserrat 24"
|
||||
select LV_FONT_MONTSERRAT_24
|
||||
config LV_FONT_DEFAULT_MONTSERRAT_26
|
||||
bool "Montserrat 26"
|
||||
select LV_FONT_MONTSERRAT_26
|
||||
config LV_FONT_DEFAULT_MONTSERRAT_28
|
||||
bool "Montserrat 28"
|
||||
select LV_FONT_MONTSERRAT_28
|
||||
config LV_FONT_DEFAULT_MONTSERRAT_30
|
||||
bool "Montserrat 30"
|
||||
select LV_FONT_MONTSERRAT_30
|
||||
config LV_FONT_DEFAULT_MONTSERRAT_32
|
||||
bool "Montserrat 32"
|
||||
select LV_FONT_MONTSERRAT_32
|
||||
config LV_FONT_DEFAULT_MONTSERRAT_34
|
||||
bool "Montserrat 34"
|
||||
select LV_FONT_MONTSERRAT_34
|
||||
config LV_FONT_DEFAULT_MONTSERRAT_36
|
||||
bool "Montserrat 36"
|
||||
select LV_FONT_MONTSERRAT_36
|
||||
config LV_FONT_DEFAULT_MONTSERRAT_38
|
||||
bool "Montserrat 38"
|
||||
select LV_FONT_MONTSERRAT_38
|
||||
config LV_FONT_DEFAULT_MONTSERRAT_40
|
||||
bool "Montserrat 40"
|
||||
select LV_FONT_MONTSERRAT_40
|
||||
config LV_FONT_DEFAULT_MONTSERRAT_42
|
||||
bool "Montserrat 42"
|
||||
select LV_FONT_MONTSERRAT_42
|
||||
config LV_FONT_DEFAULT_MONTSERRAT_44
|
||||
bool "Montserrat 44"
|
||||
select LV_FONT_MONTSERRAT_44
|
||||
config LV_FONT_DEFAULT_MONTSERRAT_46
|
||||
bool "Montserrat 46"
|
||||
select LV_FONT_MONTSERRAT_46
|
||||
config LV_FONT_DEFAULT_MONTSERRAT_48
|
||||
bool "Montserrat 48"
|
||||
select LV_FONT_MONTSERRAT_48
|
||||
config LV_FONT_DEFAULT_MONTSERRAT_12_SUBPX
|
||||
bool "Montserrat 12 sub-pixel"
|
||||
select LV_FONT_MONTSERRAT_12_SUBPX
|
||||
config LV_FONT_DEFAULT_MONTSERRAT_28_COMPRESSED
|
||||
bool "Montserrat 28 compressed"
|
||||
select LV_FONT_MONTSERRAT_28_COMPRESSED
|
||||
config LV_FONT_DEFAULT_DEJAVU_16_PERSIAN_HEBREW
|
||||
bool "Dejavu 16 Persian, Hebrew, Arabic letters"
|
||||
select LV_FONT_DEJAVU_16_PERSIAN_HEBREW
|
||||
config LV_FONT_DEFAULT_SIMSUN_16_CJK
|
||||
bool "Simsun 16 CJK"
|
||||
select LV_FONT_SIMSUN_16_CJK
|
||||
config LV_FONT_DEFAULT_UNSCII_8
|
||||
bool "UNSCII 8 (Perfect monospace font)"
|
||||
select LV_FONT_UNSCII_8
|
||||
config LV_FONT_DEFAULT_UNSCII_16
|
||||
bool "UNSCII 16 (Perfect monospace font)"
|
||||
select LV_FONT_UNSCII_16
|
||||
endchoice
|
||||
|
||||
config LV_FONT_FMT_TXT_LARGE
|
||||
bool "Enable it if you have fonts with a lot of characters."
|
||||
help
|
||||
The limit depends on the font size, font face and bpp
|
||||
but with > 10,000 characters if you see issues probably you
|
||||
need to enable it.
|
||||
|
||||
config LV_USE_FONT_COMPRESSED
|
||||
bool "Sets support for compressed fonts."
|
||||
|
||||
config LV_USE_FONT_SUBPX
|
||||
bool "Enable subpixel rendering."
|
||||
|
||||
config LV_FONT_SUBPX_BGR
|
||||
bool "Use BGR instead RGB for sub-pixel rendering."
|
||||
depends on LV_USE_FONT_SUBPX
|
||||
help
|
||||
Set the pixel order of the display.
|
||||
Important only if "subpx fonts" are used.
|
||||
With "normal" font it doesn't matter.
|
||||
endmenu
|
||||
|
||||
menu "Text Settings"
|
||||
choice LV_TXT_ENC
|
||||
prompt "Select a character encoding for strings"
|
||||
help
|
||||
Select a character encoding for strings. Your IDE or editor should have the same character encoding.
|
||||
default LV_TXT_ENC_UTF8 if !LV_CONF_MINIMAL
|
||||
default LV_TXT_ENC_ASCII if LV_CONF_MINIMAL
|
||||
|
||||
config LV_TXT_ENC_UTF8
|
||||
bool "UTF8"
|
||||
config LV_TXT_ENC_ASCII
|
||||
bool "ASCII"
|
||||
endchoice
|
||||
|
||||
config LV_TXT_BREAK_CHARS
|
||||
string "Can break (wrap) texts on these chars"
|
||||
default " ,.;:-_"
|
||||
|
||||
config LV_TXT_LINE_BREAK_LONG_LEN
|
||||
int "Line break long length"
|
||||
default 0
|
||||
help
|
||||
If a word is at least this long, will break wherever 'prettiest'.
|
||||
To disable, set to a value <= 0.
|
||||
|
||||
config LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN
|
||||
int "Min num chars before break"
|
||||
default 3
|
||||
depends on LV_TXT_LINE_BREAK_LONG_LEN > 0
|
||||
help
|
||||
Minimum number of characters in a long word to put on a line before a break.
|
||||
|
||||
config LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN
|
||||
int "Min num chars after break"
|
||||
default 3
|
||||
depends on LV_TXT_LINE_BREAK_LONG_LEN > 0
|
||||
help
|
||||
Minimum number of characters in a long word to put on a line after a break.
|
||||
|
||||
config LV_TXT_COLOR_CMD
|
||||
string "The control character to use for signalling text recoloring"
|
||||
default "#"
|
||||
|
||||
config LV_USE_BIDI
|
||||
bool "Support bidirectional texts"
|
||||
help
|
||||
Allows mixing Left-to-Right and Right-to-Left texts.
|
||||
The direction will be processed according to the Unicode Bidirectional Algorithm:
|
||||
https://www.w3.org/International/articles/inline-bidi-markup/uba-basics
|
||||
|
||||
choice
|
||||
prompt "Set the default BIDI direction"
|
||||
default LV_BIDI_DIR_AUTO
|
||||
depends on LV_USE_BIDI
|
||||
|
||||
config LV_BIDI_DIR_LTR
|
||||
bool "Left-to-Right"
|
||||
config LV_BIDI_DIR_RTL
|
||||
bool "Right-to-Left"
|
||||
config LV_BIDI_DIR_AUTO
|
||||
bool "Detect texts base direction"
|
||||
endchoice
|
||||
|
||||
config LV_USE_ARABIC_PERSIAN_CHARS
|
||||
bool "Enable Arabic/Persian processing"
|
||||
help
|
||||
In these languages characters should be replaced with
|
||||
an other form based on their position in the text.
|
||||
endmenu
|
||||
|
||||
menu "Widget usage"
|
||||
config LV_USE_ARC
|
||||
bool "Arc."
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_USE_BAR
|
||||
bool "Bar."
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_USE_BTN
|
||||
bool "Button."
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_USE_BTNMATRIX
|
||||
bool "Button matrix."
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_USE_CANVAS
|
||||
bool "Canvas. Dependencies: lv_img."
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_USE_CHECKBOX
|
||||
bool "Check Box"
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_USE_DROPDOWN
|
||||
bool "Drop down list. Requires: lv_label."
|
||||
select LV_USE_LABEL
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_USE_IMG
|
||||
bool "Image. Requires: lv_label."
|
||||
select LV_USE_LABEL
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_USE_LABEL
|
||||
bool "Label."
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_LABEL_TEXT_SELECTION
|
||||
bool "Enable selecting text of the label."
|
||||
depends on LV_USE_LABEL
|
||||
default y
|
||||
config LV_LABEL_LONG_TXT_HINT
|
||||
bool "Store extra some info in labels (12 bytes) to speed up drawing of very long texts."
|
||||
depends on LV_USE_LABEL
|
||||
default y
|
||||
config LV_USE_LINE
|
||||
bool "Line."
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_USE_ROLLER
|
||||
bool "Roller. Requires: lv_label."
|
||||
select LV_USE_LABEL
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_ROLLER_INF_PAGES
|
||||
int "Number of extra 'pages' when the controller is infinite."
|
||||
default 7
|
||||
depends on LV_USE_ROLLER
|
||||
config LV_USE_SLIDER
|
||||
bool "Slider. Requires: lv_bar."
|
||||
select LV_USE_BAR
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_USE_SWITCH
|
||||
bool "Switch."
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_USE_TEXTAREA
|
||||
bool "Text area. Requires: lv_label."
|
||||
select LV_USE_LABEL
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_TEXTAREA_DEF_PWD_SHOW_TIME
|
||||
int "Text area def. pwd show time [ms]."
|
||||
default 1500
|
||||
depends on LV_USE_TEXTAREA
|
||||
config LV_USE_TABLE
|
||||
bool "Table."
|
||||
default y if !LV_CONF_MINIMAL
|
||||
endmenu
|
||||
|
||||
menu "Extra Widgets"
|
||||
config LV_USE_ANIMIMG
|
||||
bool "Anim image."
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_USE_CALENDAR
|
||||
bool "Calendar."
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_CALENDAR_WEEK_STARTS_MONDAY
|
||||
bool "Calendar week starts monday."
|
||||
depends on LV_USE_CALENDAR
|
||||
config LV_USE_CALENDAR_HEADER_ARROW
|
||||
bool "Use calendar header arrow"
|
||||
depends on LV_USE_CALENDAR
|
||||
default y
|
||||
config LV_USE_CALENDAR_HEADER_DROPDOWN
|
||||
bool "Use calendar header dropdown"
|
||||
depends on LV_USE_CALENDAR
|
||||
default y
|
||||
config LV_USE_CHART
|
||||
bool "Chart."
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_USE_COLORWHEEL
|
||||
bool "Colorwheel."
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_USE_IMGBTN
|
||||
bool "Imgbtn."
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_USE_KEYBOARD
|
||||
bool "Keyboard."
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_USE_LED
|
||||
bool "LED."
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_USE_LIST
|
||||
bool "List."
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_USE_METER
|
||||
bool "Meter."
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_USE_MSGBOX
|
||||
bool "Msgbox."
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_USE_SPINBOX
|
||||
bool "Spinbox."
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_USE_SPINNER
|
||||
bool "Spinner."
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_USE_TABVIEW
|
||||
bool "Tabview."
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_USE_TILEVIEW
|
||||
bool "Tileview"
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_USE_WIN
|
||||
bool "Win"
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_USE_SPAN
|
||||
bool "span"
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_SPAN_SNIPPET_STACK_SIZE
|
||||
int "Maximum number of span descriptor"
|
||||
default 64
|
||||
depends on LV_USE_SPAN
|
||||
endmenu
|
||||
|
||||
menu "Themes"
|
||||
config LV_USE_THEME_DEFAULT
|
||||
bool "A simple, impressive and very complete theme"
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_THEME_DEFAULT_DARK
|
||||
bool "Yes to set dark mode, No to set light mode"
|
||||
depends on LV_USE_THEME_DEFAULT
|
||||
config LV_THEME_DEFAULT_GROW
|
||||
bool "Enable grow on press"
|
||||
default y
|
||||
depends on LV_USE_THEME_DEFAULT
|
||||
config LV_THEME_DEFAULT_TRANSITION_TIME
|
||||
int "Default transition time in [ms]"
|
||||
default 80
|
||||
depends on LV_USE_THEME_DEFAULT
|
||||
config LV_USE_THEME_BASIC
|
||||
bool "A very simple theme that is a good starting point for a custom theme"
|
||||
default y if !LV_CONF_MINIMAL
|
||||
endmenu
|
||||
|
||||
menu "Layouts"
|
||||
config LV_USE_FLEX
|
||||
bool "A layout similar to Flexbox in CSS."
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_USE_GRID
|
||||
bool "A layout similar to Grid in CSS."
|
||||
default y if !LV_CONF_MINIMAL
|
||||
endmenu
|
||||
|
||||
menu "3rd Party Libraries"
|
||||
config LV_USE_PNG
|
||||
bool "PNG decoder library"
|
||||
|
||||
config LV_USE_BMP
|
||||
bool "BMP decoder library"
|
||||
|
||||
config LV_USE_SJPG
|
||||
bool "JPG + split JPG decoder library"
|
||||
|
||||
config LV_USE_GIF
|
||||
bool "GIF decoder library"
|
||||
|
||||
config LV_USE_QRCODE
|
||||
bool "QR code library"
|
||||
|
||||
config LV_USE_FREETYPE
|
||||
bool "FreeType library"
|
||||
config LV_FREETYPE_CACHE_SIZE
|
||||
int "Memory used by FreeType to cache characters [bytes] (-1: no caching)"
|
||||
depends on LV_USE_FREETYPE
|
||||
default 16384
|
||||
|
||||
config LV_USE_RLOTTIE
|
||||
bool "Lottie library"
|
||||
endmenu
|
||||
|
||||
menu "Others"
|
||||
config LV_USE_SNAPSHOT
|
||||
bool "Enable API to take snapshot"
|
||||
default y if !LV_CONF_MINIMAL
|
||||
endmenu
|
||||
|
||||
menu "Examples"
|
||||
config LV_BUILD_EXAMPLES
|
||||
bool "Enable the examples to be built"
|
||||
default y if !LV_CONF_MINIMAL
|
||||
endmenu
|
||||
|
||||
config LV_BUILD_EXAMPLES
|
||||
bool "Enable the examples to be built with the library."
|
||||
default y
|
||||
|
||||
endmenu
|
||||
@@ -1,59 +0,0 @@
|
||||
/**
|
||||
* @file lv_demo_conf.h
|
||||
* Configuration file for v8.1.0
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* COPY THIS FILE AS lv_demo_conf.h
|
||||
*/
|
||||
|
||||
/* clang-format off */
|
||||
#if 1 /*Set it to "1" to enable the content*/
|
||||
|
||||
#ifndef LV_DEMO_CONF_H
|
||||
#define LV_DEMO_CONF_H
|
||||
|
||||
|
||||
/*******************
|
||||
* GENERAL SETTING
|
||||
*******************/
|
||||
#define LV_EX_PRINTF 0 /*Enable printf-ing data in demoes and examples*/
|
||||
#define LV_EX_KEYBOARD 0 /*Add PC keyboard support to some examples (`lv_drivers` repository is required)*/
|
||||
#define LV_EX_MOUSEWHEEL 0 /*Add 'encoder' (mouse wheel) support to some examples (`lv_drivers` repository is required)*/
|
||||
|
||||
/*********************
|
||||
* DEMO USAGE
|
||||
*********************/
|
||||
|
||||
/*Show some widget*/
|
||||
#define LV_USE_DEMO_WIDGETS 1
|
||||
#if LV_USE_DEMO_WIDGETS
|
||||
#define LV_DEMO_WIDGETS_SLIDESHOW 0
|
||||
#endif
|
||||
|
||||
/*Printer demo, optimized for 800x480*/
|
||||
#define LV_USE_DEMO_PRINTER 1
|
||||
|
||||
/*Demonstrate the usage of encoder and keyboard*/
|
||||
#define LV_USE_DEMO_KEYPAD_AND_ENCODER 0
|
||||
|
||||
/*Benchmark your system*/
|
||||
#define LV_USE_DEMO_BENCHMARK 1
|
||||
|
||||
/*Stress test for LVGL*/
|
||||
#define LV_USE_DEMO_STRESS 1
|
||||
|
||||
/*Music player demo*/
|
||||
#define LV_USE_DEMO_MUSIC 1
|
||||
#if LV_USE_DEMO_MUSIC
|
||||
# define LV_DEMO_MUSIC_SQUARE 0
|
||||
# define LV_DEMO_MUSIC_LANDSCAPE 0
|
||||
# define LV_DEMO_MUSIC_ROUND 0
|
||||
# define LV_DEMO_MUSIC_LARGE 0
|
||||
# define LV_DEMO_MUSIC_AUTO_PLAY 0
|
||||
#endif
|
||||
|
||||
#endif /*LV_DEMO_CONF_H*/
|
||||
|
||||
#endif /*End of "Content enable"*/
|
||||
|
||||
@@ -1,273 +0,0 @@
|
||||
/**
|
||||
* @file lv_port.c
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2021-06-28
|
||||
*
|
||||
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "bsp_board.h"
|
||||
#include "bsp_lcd.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_timer.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "lv_port.h"
|
||||
#include "lvgl.h"
|
||||
|
||||
#define LOG_LOCAL_LEVEL ESP_LOG_DEBUG
|
||||
|
||||
static lv_disp_drv_t disp_drv;
|
||||
static const char *TAG = "lv_port";
|
||||
static bool lv_port_use_fixed_buffer = false;
|
||||
|
||||
/**
|
||||
* @brief Task to generate ticks for LVGL.
|
||||
*
|
||||
* @param pvParam Not used.
|
||||
*/
|
||||
static void lv_tick_inc_cb(void *data)
|
||||
{
|
||||
uint32_t tick_inc_period_ms = *((uint32_t *) data);
|
||||
|
||||
lv_tick_inc(tick_inc_period_ms);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Tell LVGL that LCD flush done.
|
||||
*
|
||||
* @return true Call `portYIELD_FROM_ISR()` after esp-lcd ISR return.
|
||||
* @return false Do nothing after esp-lcd ISR return.v
|
||||
*/
|
||||
static bool lv_port_flush_ready(void)
|
||||
{
|
||||
/* Inform the graphics library that you are ready with the flushing */
|
||||
lv_disp_flush_ready(&disp_drv);
|
||||
|
||||
/* portYIELD_FROM_ISR (true) or not (false). */
|
||||
return false;
|
||||
}
|
||||
|
||||
static void button_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
|
||||
{
|
||||
static uint8_t prev_btn_id = 0;
|
||||
uint8_t tp_num = 0;
|
||||
uint16_t x = 0, y = 0, btn_val = 0;
|
||||
/* Read touch point(s) via touch IC */
|
||||
if (ESP_OK != bsp_tp_read(&tp_num, &x, &y, &btn_val)) {
|
||||
// ESP_LOGE(TAG, "Failed read touch panel value");
|
||||
return;
|
||||
}
|
||||
|
||||
/*Get the pressed button's ID*/
|
||||
if (btn_val) {
|
||||
data->btn_id = btn_val;
|
||||
data->state = LV_INDEV_STATE_PRESSED;
|
||||
} else {
|
||||
data->btn_id = 0;
|
||||
data->state = LV_INDEV_STATE_RELEASED;
|
||||
}
|
||||
|
||||
if (prev_btn_id != data->btn_id) {
|
||||
lv_event_send(lv_scr_act(), LV_EVENT_HIT_TEST, (void *) btn_val);
|
||||
}
|
||||
|
||||
prev_btn_id = btn_val;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read touchpad data.
|
||||
*
|
||||
* @param indev_drv
|
||||
* @param data
|
||||
* @return IRAM_ATTR
|
||||
*/
|
||||
static IRAM_ATTR void touchpad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data)
|
||||
{
|
||||
uint8_t tp_num = 0;
|
||||
uint16_t x = 0, y = 0, btn_val = 0;
|
||||
/* Read touch point(s) via touch IC */
|
||||
if (ESP_OK != bsp_tp_read(&tp_num, &x, &y, &btn_val)) {
|
||||
// ESP_LOGE(TAG, "Failed read touch panel value");
|
||||
return;
|
||||
}
|
||||
|
||||
ESP_LOGD(TAG, "Touch (%u) : [%3u, %3u]", tp_num, x, y);
|
||||
|
||||
/* FT series touch IC might return 0xff before first touch. */
|
||||
if ((0 == tp_num) || (5 < tp_num)) {
|
||||
data->state = LV_INDEV_STATE_REL;
|
||||
} else {
|
||||
data->point.x = x;
|
||||
data->point.y = y;
|
||||
data->state = LV_INDEV_STATE_PR;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief LCD flush function callback for LVGL.
|
||||
*
|
||||
* @param disp_drv
|
||||
* @param area
|
||||
* @param color_p
|
||||
*/
|
||||
static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
|
||||
{
|
||||
(void) disp_drv;
|
||||
|
||||
/*The most simple case (but also the slowest) to put all pixels to the screen one-by-one*/
|
||||
bsp_lcd_flush(area->x1, area->y1, area->x2 + 1, area->y2 + 1, (uint8_t *) color_p, portMAX_DELAY);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize display driver for LVGL.
|
||||
*
|
||||
*/
|
||||
static void lv_port_disp_init(void)
|
||||
{
|
||||
static lv_disp_draw_buf_t draw_buf_dsc;
|
||||
size_t disp_buf_height = 40;
|
||||
|
||||
/* Option 1 : Allocate memories from heap */
|
||||
// lv_color_t *p_disp_buf = NULL;
|
||||
// uint32_t buf_alloc_caps = MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT;
|
||||
// p_disp_buf = heap_caps_malloc(LCD_WIDTH * disp_buf_height * sizeof(lv_color_t), buf_alloc_caps);
|
||||
// ESP_LOGD(TAG, "Try allocate %zu * %zu display buffer", LCD_WIDTH, disp_buf_height);
|
||||
// if (NULL == p_disp_buf) {
|
||||
// ESP_LOGE(TAG, "No memory for LVGL display buffer");
|
||||
// esp_system_abort("Memory allocation failed");
|
||||
// }
|
||||
|
||||
/* Option 2 : Using static space for display buffer */
|
||||
static lv_color_t p_disp_buf[LCD_WIDTH * 40];
|
||||
|
||||
/* Initialize display buffer */
|
||||
lv_disp_draw_buf_init(&draw_buf_dsc, p_disp_buf, NULL, LCD_WIDTH * disp_buf_height);
|
||||
|
||||
/* Register the display in LVGL */
|
||||
lv_disp_drv_init(&disp_drv);
|
||||
|
||||
/*Set the resolution of the display*/
|
||||
disp_drv.hor_res = LCD_WIDTH;
|
||||
disp_drv.ver_res = LCD_HEIGHT;
|
||||
|
||||
/* Used to copy the buffer's content to the display */
|
||||
disp_drv.flush_cb = disp_flush;
|
||||
|
||||
/*Set a display buffer*/
|
||||
disp_drv.draw_buf = &draw_buf_dsc;
|
||||
|
||||
/**
|
||||
* @brief Fill a memory array with a color if you have GPU.
|
||||
* Note that, in lv_conf.h you can enable GPUs that has built-in support in LVGL.
|
||||
* But if you have a different GPU you can use with this callback.
|
||||
*
|
||||
*/
|
||||
// disp_drv.gpu_fill_cb = gpu_fill;
|
||||
|
||||
/* Use lcd_trans_done_cb to inform the graphics library that flush already done */
|
||||
bsp_lcd_set_cb(lv_port_flush_ready, NULL);
|
||||
|
||||
/*Finally register the driver*/
|
||||
lv_disp_drv_register(&disp_drv);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize input device for LVGL.
|
||||
*
|
||||
* @return esp_err_t
|
||||
*/
|
||||
static esp_err_t lv_port_indev_init(void)
|
||||
{
|
||||
/**
|
||||
* Here you will find example implementation of input devices supported by LittelvGL:
|
||||
* - Touchpad
|
||||
* - Mouse (with cursor support)
|
||||
* - Keypad (supports GUI usage only with key)
|
||||
* - Encoder (supports GUI usage only with: left, right, push)
|
||||
* - Button (external buttons to press points on the screen)
|
||||
*
|
||||
* The `..._read()` function are only examples.
|
||||
* You should shape them according to your hardware
|
||||
*/
|
||||
static lv_indev_drv_t indev_drv_tp;
|
||||
static lv_indev_drv_t indev_drv_btn;
|
||||
lv_indev_t *indev_touchpad;
|
||||
lv_indev_t *indev_button;
|
||||
|
||||
/* Initialize your touchpad if you have */
|
||||
|
||||
/* Register a touchpad input device */
|
||||
lv_indev_drv_init(&indev_drv_tp);
|
||||
indev_drv_tp.type = LV_INDEV_TYPE_POINTER;
|
||||
indev_drv_tp.read_cb = touchpad_read;
|
||||
indev_touchpad = lv_indev_drv_register(&indev_drv_tp);
|
||||
|
||||
lv_indev_drv_init(&indev_drv_btn);
|
||||
indev_drv_btn.type = LV_INDEV_TYPE_BUTTON;
|
||||
indev_drv_btn.read_cb = button_read;
|
||||
indev_button = lv_indev_drv_register(&indev_drv_btn);
|
||||
|
||||
/* Uncomment code below to display a mouse cursor on screen */
|
||||
// LV_IMG_DECLARE(mouse_cursor_icon)
|
||||
// lv_obj_t * cursor_obj = lv_img_create(lv_scr_act()); /*Create an image object for the cursor */
|
||||
// lv_img_set_src(cursor_obj, &mouse_cursor_icon); /*Set the image source*/
|
||||
// lv_indev_set_cursor(indev_touchpad, cursor_obj); /*Connect the image object to the driver*/
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Create tick task for LVGL.
|
||||
*
|
||||
* @return esp_err_t
|
||||
*/
|
||||
static esp_err_t lv_port_tick_init(void)
|
||||
{
|
||||
static const uint32_t tick_inc_period_ms = 5;
|
||||
const esp_timer_create_args_t periodic_timer_args = {
|
||||
.callback = lv_tick_inc_cb,
|
||||
.name = "", /* name is optional, but may help identify the timer when debugging */
|
||||
.arg = &tick_inc_period_ms,
|
||||
.dispatch_method = ESP_TIMER_TASK,
|
||||
.skip_unhandled_events = true,
|
||||
};
|
||||
|
||||
esp_timer_handle_t periodic_timer;
|
||||
ESP_ERROR_CHECK(esp_timer_create(&periodic_timer_args, &periodic_timer));
|
||||
|
||||
/* The timer has been created but is not running yet. Start the timer now */
|
||||
ESP_ERROR_CHECK(esp_timer_start_periodic(periodic_timer, tick_inc_period_ms * 1000));
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t lv_port_init(void)
|
||||
{
|
||||
/* Initialize LVGL library */
|
||||
lv_init();
|
||||
|
||||
/* Register display for LVGL */
|
||||
lv_port_disp_init();
|
||||
|
||||
/* Register input device for LVGL*/
|
||||
lv_port_indev_init();
|
||||
|
||||
/* Initialize LVGL's tick source */
|
||||
lv_port_tick_init();
|
||||
|
||||
/* Nothing error */
|
||||
return ESP_OK;
|
||||
}
|
||||
@@ -1,267 +0,0 @@
|
||||
/**
|
||||
* @file lv_port_fs.c
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2021-07-15
|
||||
*
|
||||
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <dirent.h>
|
||||
#include <stdio.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_log.h"
|
||||
#include "lvgl.h"
|
||||
#include "lv_port_fs.h"
|
||||
|
||||
static const char *TAG = "lv_port_fs";
|
||||
|
||||
static void fs_init(void);
|
||||
|
||||
static void * fs_open (lv_fs_drv_t * drv, const char * path, lv_fs_mode_t mode);
|
||||
static lv_fs_res_t fs_close (lv_fs_drv_t * drv, void * file_p);
|
||||
static lv_fs_res_t fs_read (lv_fs_drv_t * drv, void * file_p, void * buf, uint32_t btr, uint32_t * br);
|
||||
static lv_fs_res_t fs_write(lv_fs_drv_t * drv, void * file_p, const void * buf, uint32_t btw, uint32_t * bw);
|
||||
static lv_fs_res_t fs_seek (lv_fs_drv_t * drv, void * file_p, uint32_t pos, lv_fs_whence_t whence);
|
||||
static lv_fs_res_t fs_size (lv_fs_drv_t * drv, void * file_p, uint32_t * size_p);
|
||||
static lv_fs_res_t fs_tell (lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p);
|
||||
|
||||
static void * fs_dir_open (lv_fs_drv_t * drv, const char *path);
|
||||
static lv_fs_res_t fs_dir_read (lv_fs_drv_t * drv, void * rddir_p, char *fn);
|
||||
static lv_fs_res_t fs_dir_close (lv_fs_drv_t * drv, void * rddir_p);
|
||||
|
||||
esp_err_t lv_port_fs_init(void)
|
||||
{
|
||||
/*----------------------------------------------------
|
||||
* Initialize your storage device and File System
|
||||
* -------------------------------------------------*/
|
||||
fs_init();
|
||||
|
||||
/*---------------------------------------------------
|
||||
* Register the file system interface in LVGL
|
||||
*--------------------------------------------------*/
|
||||
|
||||
/*Add a simple drive to open images*/
|
||||
static lv_fs_drv_t fs_drv;
|
||||
lv_fs_drv_init(&fs_drv);
|
||||
|
||||
/*Set up fields...*/
|
||||
fs_drv.letter = 'S';
|
||||
fs_drv.open_cb = fs_open;
|
||||
fs_drv.close_cb = fs_close;
|
||||
fs_drv.read_cb = fs_read;
|
||||
fs_drv.write_cb = fs_write;
|
||||
fs_drv.seek_cb = fs_seek;
|
||||
fs_drv.tell_cb = fs_tell;
|
||||
|
||||
fs_drv.dir_close_cb = fs_dir_close;
|
||||
fs_drv.dir_open_cb = fs_dir_open;
|
||||
fs_drv.dir_read_cb = fs_dir_read;
|
||||
|
||||
lv_fs_drv_register(&fs_drv);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/*Initialize your Storage device and File system.*/
|
||||
static void fs_init(void)
|
||||
{
|
||||
/*E.g. for FatFS initialize the SD card and FatFS itself*/
|
||||
|
||||
/*You code here*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a file
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param path path to the file beginning with the driver letter (e.g. S:/folder/file.txt)
|
||||
* @param mode read: FS_MODE_RD, write: FS_MODE_WR, both: FS_MODE_RD | FS_MODE_WR
|
||||
* @return a file descriptor or NULL on error
|
||||
*/
|
||||
static void * fs_open (lv_fs_drv_t * drv, const char * path, lv_fs_mode_t mode)
|
||||
{
|
||||
lv_fs_res_t res = LV_FS_RES_NOT_IMP;
|
||||
|
||||
void * f = NULL;
|
||||
|
||||
if(mode == LV_FS_MODE_WR)
|
||||
{
|
||||
/*Open a file for write*/
|
||||
f = fopen(path, "w");
|
||||
}
|
||||
else if(mode == LV_FS_MODE_RD)
|
||||
{
|
||||
/*Open a file for read*/
|
||||
f = fopen(path, "r");
|
||||
}
|
||||
else if(mode == (LV_FS_MODE_WR | LV_FS_MODE_RD))
|
||||
{
|
||||
/*Open a file for read and write*/
|
||||
f = f = fopen(path, "r+");
|
||||
}
|
||||
|
||||
return (FILE *) f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close an opened file
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param file_p pointer to a file_t variable. (opened with lv_ufs_open)
|
||||
* @return LV_FS_RES_OK: no error or any error from @lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_close (lv_fs_drv_t * drv, void * file_p)
|
||||
{
|
||||
lv_fs_res_t res = LV_FS_RES_OK;
|
||||
|
||||
/*Add your code here*/
|
||||
if (EOF == fclose((FILE *) file_p)) {
|
||||
ESP_LOGE(TAG, "Failed close file");
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read data from an opened file
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param file_p pointer to a file_t variable.
|
||||
* @param buf pointer to a memory block where to store the read data
|
||||
* @param btr number of Bytes To Read
|
||||
* @param br the real number of read bytes (Byte Read)
|
||||
* @return LV_FS_RES_OK: no error or any error from @lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_read (lv_fs_drv_t * drv, void * file_p, void * buf, uint32_t btr, uint32_t * br)
|
||||
{
|
||||
(void) drv;
|
||||
|
||||
*br = fread(buf, 1, btr, (FILE *) file_p);
|
||||
|
||||
return LV_FS_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write into a file
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param file_p pointer to a file_t variable
|
||||
* @param buf pointer to a buffer with the bytes to write
|
||||
* @param btr Bytes To Write
|
||||
* @param br the number of real written bytes (Bytes Written). NULL if unused.
|
||||
* @return LV_FS_RES_OK: no error or any error from @lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_write(lv_fs_drv_t * drv, void * file_p, const void * buf, uint32_t btw, uint32_t * bw)
|
||||
{
|
||||
(void) drv;
|
||||
|
||||
*bw = fwrite(buf, 1, btw, (FILE *) file_p);
|
||||
|
||||
return LV_FS_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the read write pointer. Also expand the file size if necessary.
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param file_p pointer to a file_t variable. (opened with lv_ufs_open )
|
||||
* @param pos the new position of read write pointer
|
||||
* @param whence tells from where to interpret the `pos`. See @lv_fs_whence_t
|
||||
* @return LV_FS_RES_OK: no error or any error from @lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_seek (lv_fs_drv_t * drv, void * file_p, uint32_t pos, lv_fs_whence_t whence)
|
||||
{
|
||||
(void) drv;
|
||||
|
||||
int ret_val = fseek((FILE *) file_p, pos, whence);
|
||||
|
||||
if (0 != ret_val) {
|
||||
return LV_FS_RES_UNKNOWN;
|
||||
}
|
||||
|
||||
return LV_FS_RES_OK;
|
||||
}
|
||||
/**
|
||||
* Give the position of the read write pointer
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param file_p pointer to a file_t variable.
|
||||
* @param pos_p pointer to to store the result
|
||||
* @return LV_FS_RES_OK: no error or any error from @lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_tell (lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p)
|
||||
{
|
||||
(void) drv;
|
||||
|
||||
*pos_p = ftell((FILE *) file_p);
|
||||
|
||||
return LV_FS_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize a 'lv_fs_dir_t' variable for directory reading
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param path path to a directory
|
||||
* @return pointer to the directory read descriptor or NULL on error
|
||||
*/
|
||||
static void * fs_dir_open (lv_fs_drv_t * drv, const char *path)
|
||||
{
|
||||
(void) drv;
|
||||
|
||||
DIR *d = NULL;
|
||||
|
||||
d = opendir(path);
|
||||
|
||||
if (NULL == d) {
|
||||
return LV_FS_RES_UNKNOWN;
|
||||
}
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the next filename form a directory.
|
||||
* The name of the directories will begin with '/'
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param rddir_p pointer to an initialized 'lv_fs_dir_t' variable
|
||||
* @param fn pointer to a buffer to store the filename
|
||||
* @return LV_FS_RES_OK: no error or any error from @lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_dir_read (lv_fs_drv_t * drv, void * rddir_p, char *fn)
|
||||
{
|
||||
lv_fs_res_t res = LV_FS_RES_NOT_IMP;
|
||||
|
||||
readdir((DIR *) rddir_p);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the directory reading
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param rddir_p pointer to an initialized 'lv_fs_dir_t' variable
|
||||
* @return LV_FS_RES_OK: no error or any error from @lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_dir_close (lv_fs_drv_t * drv, void * rddir_p)
|
||||
{
|
||||
(void) drv;
|
||||
|
||||
int ret_val = closedir(rddir_p);
|
||||
|
||||
if (0 != ret_val) {
|
||||
return LV_FS_RES_UNKNOWN;
|
||||
}
|
||||
|
||||
return LV_FS_RES_OK;
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
/**
|
||||
* @file lv_port_fs.h
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2021-07-15
|
||||
*
|
||||
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Initialize LVGL file system support
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Success
|
||||
* - Others: Fail
|
||||
*/
|
||||
esp_err_t lv_port_fs_init(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
@@ -1,104 +0,0 @@
|
||||
#include "lvgl/lvgl.h"
|
||||
|
||||
const uint8_t mouse_cursor_icon_map[] = {
|
||||
#if LV_COLOR_DEPTH == 1 || LV_COLOR_DEPTH == 8
|
||||
/*Pixel format: Alpha 8 bit, Red: 3 bit, Green: 3 bit, Blue: 2 bit*/
|
||||
0x24, 0xb8, 0x24, 0xc8, 0x00, 0x13, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x49, 0xcc, 0xdb, 0xff, 0x49, 0xcc, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x49, 0xc8, 0xff, 0xff, 0xff, 0xff, 0x49, 0xe0, 0x00, 0x3b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x49, 0xcb, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0x6d, 0xf3, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x49, 0xcb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x92, 0xff, 0x00, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x49, 0xcb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x92, 0xff, 0x00, 0x90, 0x00, 0x00, 0x00, 0x00, 0xb6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x49, 0xcb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb7, 0xff, 0x24, 0xab, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x49, 0xcb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdb, 0xff, 0x24, 0xbb, 0x00, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x49, 0xcc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdb, 0xff, 0x49, 0xd8, 0x00, 0x37, 0x00, 0x00, 0x00, 0x00,
|
||||
0x49, 0xcc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x6d, 0xef, 0x00, 0x4f, 0x00, 0x00,
|
||||
0x49, 0xcc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x92, 0xff, 0x00, 0x6b,
|
||||
0x49, 0xcc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdb, 0xff, 0x92, 0xf7, 0x92, 0xf8, 0x6e, 0xfb, 0x92, 0xf8, 0x6d, 0xff, 0x00, 0xb3,
|
||||
0x49, 0xcc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdb, 0xff, 0x24, 0xb7, 0x00, 0x1b, 0x00, 0x14, 0x00, 0x13, 0x00, 0x0c, 0x25, 0x07,
|
||||
0x49, 0xcc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x6d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x6e, 0xf0, 0x00, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x49, 0xcc, 0xff, 0xff, 0xff, 0xff, 0x49, 0xd8, 0x00, 0x78, 0x92, 0xfb, 0xff, 0xff, 0xff, 0xff, 0xdb, 0xff, 0x00, 0x8b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x6d, 0xd3, 0xff, 0xff, 0x6d, 0xef, 0x00, 0x34, 0x00, 0x00, 0x49, 0xc7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x6d, 0xdc, 0x00, 0x14, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00,
|
||||
0x49, 0xe0, 0x6d, 0xff, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x57, 0x92, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb7, 0xff, 0x00, 0x78, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
|
||||
0x00, 0x68, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x49, 0xd0, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0x6d, 0xd8, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6f, 0xb7, 0xff, 0xff, 0xff, 0x92, 0xff, 0x49, 0xac, 0x00, 0x17, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x25, 0xd7, 0x49, 0xc7, 0x00, 0x47, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
#endif
|
||||
#if LV_COLOR_DEPTH == 16 && LV_COLOR_16_SWAP == 0
|
||||
/*Pixel format: Alpha 8 bit, Red: 5 bit, Green: 6 bit, Blue: 5 bit*/
|
||||
0xc3, 0x18, 0xb8, 0xe4, 0x20, 0xc8, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x49, 0x4a, 0xcc, 0x96, 0xb5, 0xff, 0xc7, 0x39, 0xcc, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xe7, 0x39, 0xc8, 0xbf, 0xff, 0xff, 0xfb, 0xde, 0xff, 0x28, 0x42, 0xe0, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xe7, 0x39, 0xcb, 0x3d, 0xef, 0xff, 0xff, 0xff, 0xfc, 0x3d, 0xef, 0xff, 0xcb, 0x5a, 0xf3, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xe7, 0x39, 0xcb, 0x5d, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xbf, 0xff, 0xff, 0x8e, 0x73, 0xff, 0x00, 0x00, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xe8, 0x41, 0xcb, 0x5d, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x51, 0x8c, 0xff, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd3, 0x9c, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xe8, 0x41, 0xcb, 0x5d, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x14, 0xa5, 0xff, 0xa2, 0x10, 0xab, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x08, 0x42, 0xcb, 0x5d, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xd7, 0xbd, 0xff, 0x04, 0x21, 0xbb, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x08, 0x42, 0xcc, 0x5d, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x59, 0xce, 0xff, 0xe8, 0x41, 0xd8, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x08, 0x42, 0xcc, 0x5d, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xe6, 0xff, 0xab, 0x5a, 0xef, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00,
|
||||
0x08, 0x42, 0xcc, 0x5d, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xbe, 0xf7, 0xff, 0xaf, 0x7b, 0xff, 0x00, 0x00, 0x6b,
|
||||
0x28, 0x42, 0xcc, 0x5d, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7a, 0xd6, 0xff, 0x10, 0x84, 0xf7, 0xae, 0x73, 0xf8, 0x6e, 0x73, 0xfb, 0x8e, 0x73, 0xf8, 0xcb, 0x5a, 0xff, 0x61, 0x08, 0xb3,
|
||||
0x28, 0x42, 0xcc, 0x7d, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x59, 0xce, 0xff, 0xa2, 0x10, 0xb7, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x14, 0x00, 0x00, 0x13, 0x00, 0x00, 0x0c, 0x45, 0x29, 0x07,
|
||||
0x29, 0x4a, 0xcc, 0x5d, 0xef, 0xff, 0xff, 0xff, 0xff, 0xdb, 0xde, 0xff, 0xec, 0x62, 0xff, 0x1c, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0c, 0x63, 0xf0, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x29, 0x4a, 0xcc, 0xdf, 0xff, 0xff, 0x7d, 0xef, 0xff, 0x49, 0x4a, 0xd8, 0x00, 0x00, 0x78, 0x51, 0x8c, 0xfb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x38, 0xc6, 0xff, 0x00, 0x00, 0x8b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xcb, 0x5a, 0xd3, 0xdb, 0xde, 0xff, 0xec, 0x62, 0xef, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0xe7, 0x39, 0xc7, 0x5d, 0xef, 0xff, 0xff, 0xff, 0xff, 0xbe, 0xf7, 0xff, 0xaa, 0x52, 0xdc, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
|
||||
0xe8, 0x41, 0xe0, 0xaa, 0x52, 0xff, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x57, 0x72, 0x94, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x96, 0xb5, 0xff, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x61, 0x08, 0x04, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x68, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x69, 0x4a, 0xd0, 0x7d, 0xef, 0xff, 0xff, 0xff, 0xfc, 0xbe, 0xf7, 0xff, 0xaa, 0x52, 0xd8, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe4, 0x20, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6f, 0x75, 0xad, 0xff, 0xbf, 0xff, 0xff, 0x10, 0x84, 0xff, 0x86, 0x31, 0xac, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x41, 0x08, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x66, 0x31, 0xd7, 0xc7, 0x39, 0xc7, 0x00, 0x00, 0x47, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
#endif
|
||||
#if LV_COLOR_DEPTH == 16 && LV_COLOR_16_SWAP != 0
|
||||
/*Pixel format: Alpha 8 bit, Red: 5 bit, Green: 6 bit, Blue: 5 bit BUT the 2 color bytes are swapped*/
|
||||
0x18, 0xc3, 0xb8, 0x20, 0xe4, 0xc8, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x4a, 0x49, 0xcc, 0xb5, 0x96, 0xff, 0x39, 0xc7, 0xcc, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x39, 0xe7, 0xc8, 0xff, 0xbf, 0xff, 0xde, 0xfb, 0xff, 0x42, 0x28, 0xe0, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x39, 0xe7, 0xcb, 0xef, 0x3d, 0xff, 0xff, 0xff, 0xfc, 0xef, 0x3d, 0xff, 0x5a, 0xcb, 0xf3, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x39, 0xe7, 0xcb, 0xef, 0x5d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xbf, 0xff, 0x73, 0x8e, 0xff, 0x00, 0x00, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x41, 0xe8, 0xcb, 0xef, 0x5d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x8c, 0x51, 0xff, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9c, 0xd3, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x41, 0xe8, 0xcb, 0xef, 0x5d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xa5, 0x14, 0xff, 0x10, 0xa2, 0xab, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x42, 0x08, 0xcb, 0xef, 0x5d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xbd, 0xd7, 0xff, 0x21, 0x04, 0xbb, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x42, 0x08, 0xcc, 0xef, 0x5d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xce, 0x59, 0xff, 0x41, 0xe8, 0xd8, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x42, 0x08, 0xcc, 0xef, 0x5d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe6, 0xfc, 0xff, 0x5a, 0xab, 0xef, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00,
|
||||
0x42, 0x08, 0xcc, 0xef, 0x5d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf7, 0xbe, 0xff, 0x7b, 0xaf, 0xff, 0x00, 0x00, 0x6b,
|
||||
0x42, 0x28, 0xcc, 0xef, 0x5d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xd6, 0x7a, 0xff, 0x84, 0x10, 0xf7, 0x73, 0xae, 0xf8, 0x73, 0x6e, 0xfb, 0x73, 0x8e, 0xf8, 0x5a, 0xcb, 0xff, 0x08, 0x61, 0xb3,
|
||||
0x42, 0x28, 0xcc, 0xef, 0x7d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xce, 0x59, 0xff, 0x10, 0xa2, 0xb7, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x14, 0x00, 0x00, 0x13, 0x00, 0x00, 0x0c, 0x29, 0x45, 0x07,
|
||||
0x4a, 0x29, 0xcc, 0xef, 0x5d, 0xff, 0xff, 0xff, 0xff, 0xde, 0xdb, 0xff, 0x62, 0xec, 0xff, 0xe7, 0x1c, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x63, 0x0c, 0xf0, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x4a, 0x29, 0xcc, 0xff, 0xdf, 0xff, 0xef, 0x7d, 0xff, 0x4a, 0x49, 0xd8, 0x00, 0x00, 0x78, 0x8c, 0x51, 0xfb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc6, 0x38, 0xff, 0x00, 0x00, 0x8b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x5a, 0xcb, 0xd3, 0xde, 0xdb, 0xff, 0x62, 0xec, 0xef, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x39, 0xe7, 0xc7, 0xef, 0x5d, 0xff, 0xff, 0xff, 0xff, 0xf7, 0xbe, 0xff, 0x52, 0xaa, 0xdc, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
|
||||
0x41, 0xe8, 0xe0, 0x52, 0xaa, 0xff, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x57, 0x94, 0x72, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb5, 0x96, 0xff, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x08, 0x61, 0x04, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x68, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x4a, 0x69, 0xd0, 0xef, 0x7d, 0xff, 0xff, 0xff, 0xfc, 0xf7, 0xbe, 0xff, 0x52, 0xaa, 0xd8, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0xe4, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6f, 0xad, 0x75, 0xff, 0xff, 0xbf, 0xff, 0x84, 0x10, 0xff, 0x31, 0x86, 0xac, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x08, 0x41, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x31, 0x66, 0xd7, 0x39, 0xc7, 0xc7, 0x00, 0x00, 0x47, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
#endif
|
||||
#if LV_COLOR_DEPTH == 32
|
||||
0x19, 0x19, 0x19, 0xb8, 0x1e, 0x1e, 0x1e, 0xc8, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x48, 0x48, 0x48, 0xcc, 0xb2, 0xb2, 0xb2, 0xff, 0x3a, 0x3a, 0x3a, 0xcc, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x0a, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x3b, 0x3b, 0x3b, 0xc8, 0xf6, 0xf6, 0xf6, 0xff, 0xdc, 0xdc, 0xdc, 0xff, 0x43, 0x43, 0x43, 0xe0, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x0a, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x3b, 0x3b, 0x3b, 0xcb, 0xe6, 0xe6, 0xe6, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xe5, 0xe5, 0xe5, 0xff, 0x59, 0x59, 0x59, 0xf3, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x3c, 0x3c, 0x3c, 0xcb, 0xe9, 0xe9, 0xe9, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf5, 0xf5, 0xf5, 0xff, 0x72, 0x72, 0x72, 0xff, 0x00, 0x00, 0x00, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x3d, 0x3d, 0x3d, 0xcb, 0xe9, 0xe9, 0xe9, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x8a, 0x8a, 0x8a, 0xff, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x99, 0x99, 0x99, 0x00, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x3e, 0x3e, 0x3e, 0xcb, 0xe9, 0xe9, 0xe9, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfe, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xa2, 0xa2, 0xa2, 0xff, 0x13, 0x13, 0x13, 0xab, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x3f, 0x3f, 0x3f, 0xcb, 0xe9, 0xe9, 0xe9, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfe, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb7, 0xb7, 0xb7, 0xff, 0x1f, 0x1f, 0x1f, 0xbb, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x41, 0x41, 0x41, 0xcc, 0xea, 0xea, 0xea, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfe, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xca, 0xca, 0xca, 0xff, 0x3d, 0x3d, 0x3d, 0xd8, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x41, 0x41, 0x41, 0xcc, 0xea, 0xea, 0xea, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xde, 0xde, 0xde, 0xff, 0x56, 0x56, 0x56, 0xef, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x00,
|
||||
0x42, 0x42, 0x42, 0xcc, 0xea, 0xea, 0xea, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfe, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xf3, 0xf3, 0xff, 0x76, 0x76, 0x76, 0xff, 0x00, 0x00, 0x00, 0x6b,
|
||||
0x43, 0x43, 0x43, 0xcc, 0xea, 0xea, 0xea, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xce, 0xce, 0xce, 0xff, 0x80, 0x80, 0x80, 0xf7, 0x74, 0x74, 0x74, 0xf8, 0x6d, 0x6d, 0x6d, 0xfb, 0x72, 0x72, 0x72, 0xf8, 0x57, 0x57, 0x57, 0xff, 0x0c, 0x0c, 0x0c, 0xb3,
|
||||
0x44, 0x44, 0x44, 0xcc, 0xeb, 0xeb, 0xeb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xfb, 0xfb, 0xfb, 0xff, 0xfe, 0xfe, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc9, 0xc9, 0xc9, 0xff, 0x13, 0x13, 0x13, 0xb7, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x0c, 0x29, 0x29, 0x29, 0x07,
|
||||
0x45, 0x45, 0x45, 0xcc, 0xe8, 0xe8, 0xe8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xd9, 0xd9, 0xd9, 0xff, 0x5e, 0x5e, 0x5e, 0xff, 0xe2, 0xe2, 0xe2, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x62, 0x62, 0x62, 0xf0, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x45, 0x45, 0x45, 0xcc, 0xf9, 0xf9, 0xf9, 0xff, 0xec, 0xec, 0xec, 0xff, 0x4a, 0x4a, 0x4a, 0xd8, 0x00, 0x00, 0x00, 0x78, 0x8a, 0x8a, 0x8a, 0xfb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc3, 0xc3, 0xc3, 0xff, 0x00, 0x00, 0x00, 0x8b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x58, 0x58, 0x58, 0xd3, 0xd9, 0xd9, 0xd9, 0xff, 0x5e, 0x5e, 0x5e, 0xef, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x00, 0x3b, 0x3b, 0x3b, 0xc7, 0xe9, 0xe9, 0xe9, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf4, 0xf4, 0xf4, 0xff, 0x54, 0x54, 0x54, 0xdc, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
|
||||
0x3e, 0x3e, 0x3e, 0xe0, 0x54, 0x54, 0x54, 0xff, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x57, 0x8e, 0x8e, 0x8e, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb0, 0xb0, 0xb0, 0xff, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x0c, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x4c, 0x4c, 0x4c, 0xd0, 0xec, 0xec, 0xec, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xf4, 0xf4, 0xf4, 0xff, 0x53, 0x53, 0x53, 0xd8, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x1e, 0x1e, 0x00, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6f, 0xab, 0xab, 0xab, 0xff, 0xf6, 0xf6, 0xf6, 0xff, 0x80, 0x80, 0x80, 0xff, 0x31, 0x31, 0x31, 0xac, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x09, 0x09, 0x09, 0x03, 0x02, 0x02, 0x02, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x2e, 0x2e, 0x2e, 0xd7, 0x38, 0x38, 0x38, 0xc7, 0x00, 0x00, 0x00, 0x47, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
#endif
|
||||
};
|
||||
|
||||
lv_img_dsc_t mouse_cursor_icon = {
|
||||
.header.always_zero = 0,
|
||||
.header.w = 14,
|
||||
.header.h = 20,
|
||||
.data_size = 280 * LV_IMG_PX_SIZE_ALPHA_BYTE,
|
||||
.header.cf = LV_IMG_CF_TRUE_COLOR_ALPHA,
|
||||
.data = mouse_cursor_icon_map,
|
||||
};
|
||||
|
After Width: | Height: | Size: 115 KiB |
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 207 KiB |
|
After Width: | Height: | Size: 5.2 KiB |
|
After Width: | Height: | Size: 277 KiB |
|
After Width: | Height: | Size: 299 KiB |
|
After Width: | Height: | Size: 181 KiB |
|
After Width: | Height: | Size: 300 KiB |
|
After Width: | Height: | Size: 396 KiB |
|
After Width: | Height: | Size: 399 KiB |
|
After Width: | Height: | Size: 286 KiB |
|
After Width: | Height: | Size: 285 KiB |
|
After Width: | Height: | Size: 4.5 KiB |
|
After Width: | Height: | Size: 4.9 KiB |
|
After Width: | Height: | Size: 4.8 KiB |
|
After Width: | Height: | Size: 4.5 KiB |
|
After Width: | Height: | Size: 4.5 KiB |
|
After Width: | Height: | Size: 4.5 KiB |
|
After Width: | Height: | Size: 238 KiB |
|
After Width: | Height: | Size: 8.5 KiB |