Sync inav to Gitea
Make sure docs are updated / settings_md (push) Canceled after 0s
Build firmware / test (push) Canceled after 0s
Build firmware / build-SITL-Windows (push) Canceled after 0s
Build firmware / build-SITL-Mac (push) Canceled after 0s
Build firmware / build-SITL-Linux (push) Canceled after 0s
Build firmware / build-SITL-Linux-arm64 (push) Canceled after 0s
Build firmware / upload-artifacts (push) Canceled after 0s
Build firmware / build-single-target (push) Canceled after 0s
Build firmware / build (9) (push) Canceled after 0s
Build firmware / build (8) (push) Canceled after 0s
Build firmware / build (7) (push) Canceled after 0s
Build firmware / build (6) (push) Canceled after 0s
Build firmware / build (5) (push) Canceled after 0s
Build firmware / build (4) (push) Canceled after 0s
Build firmware / build (3) (push) Canceled after 0s
Build firmware / build (2) (push) Canceled after 0s
Build firmware / build (14) (push) Canceled after 0s
Build firmware / build (13) (push) Canceled after 0s
Build firmware / build (12) (push) Canceled after 0s
Build firmware / build (11) (push) Canceled after 0s
Build firmware / build (10) (push) Canceled after 0s
Build firmware / build (1) (push) Canceled after 0s
Build firmware / build (0) (push) Canceled after 0s
Build firmware / detect (push) Canceled after 0s
Build pre-release / build (push) Canceled after 0s
Build pre-release / Release (push) Canceled after 0s
Make sure docs are updated / settings_md (push) Canceled after 0s
Build firmware / test (push) Canceled after 0s
Build firmware / build-SITL-Windows (push) Canceled after 0s
Build firmware / build-SITL-Mac (push) Canceled after 0s
Build firmware / build-SITL-Linux (push) Canceled after 0s
Build firmware / build-SITL-Linux-arm64 (push) Canceled after 0s
Build firmware / upload-artifacts (push) Canceled after 0s
Build firmware / build-single-target (push) Canceled after 0s
Build firmware / build (9) (push) Canceled after 0s
Build firmware / build (8) (push) Canceled after 0s
Build firmware / build (7) (push) Canceled after 0s
Build firmware / build (6) (push) Canceled after 0s
Build firmware / build (5) (push) Canceled after 0s
Build firmware / build (4) (push) Canceled after 0s
Build firmware / build (3) (push) Canceled after 0s
Build firmware / build (2) (push) Canceled after 0s
Build firmware / build (14) (push) Canceled after 0s
Build firmware / build (13) (push) Canceled after 0s
Build firmware / build (12) (push) Canceled after 0s
Build firmware / build (11) (push) Canceled after 0s
Build firmware / build (10) (push) Canceled after 0s
Build firmware / build (1) (push) Canceled after 0s
Build firmware / build (0) (push) Canceled after 0s
Build firmware / detect (push) Canceled after 0s
Build pre-release / build (push) Canceled after 0s
Build pre-release / Release (push) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
---
|
||||
name: 'Issue report'
|
||||
about: 'Create a report to help us improve the quality of our software'
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
---
|
||||
|
||||
**Caution**
|
||||
|
||||
The Issues are strictly limited for the reporting of problem encountered with the software provided in this project.
|
||||
For any other problem related to the STM32 product, the performance, the hardware characteristics and boards, the tools the environment in general, please post your report to the **ST Community** in the STM32 MCUs dedicated [page](https://community.st.com/s/group/0F90X000000AXsASAW/stm32-mcus).
|
||||
|
||||
**Describe the set-up**
|
||||
|
||||
* The board (either ST RPN reference or your custom board)
|
||||
* IDE or at least the compiler and its version
|
||||
|
||||
**Describe the bug (skip if none)**
|
||||
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**How to reproduce the bug (skip if none)**
|
||||
|
||||
1. Indicate the global behavior of your application project
|
||||
2. List the modules that you suspect to be the cause of the problem (Drivers, BSP, MW...)
|
||||
3. Describe the use case that generates the problem
|
||||
4. How we can reproduce the problem
|
||||
|
||||
|
||||
**Additional context**
|
||||
|
||||
If you have a first analysis, an enhancement, a fix or a patch, thank you to share your proposal.
|
||||
|
||||
**Screenshots**
|
||||
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
@@ -0,0 +1,5 @@
|
||||
## IMPORTANT INFORMATION
|
||||
|
||||
### Contributor License Agreement (CLA)
|
||||
* The Pull Request feature will be considered by STMicroelectronics after the signature of a **Contributor License Agreement (CLA)** by the submitter.
|
||||
* If you did not sign such agreement, please follow the steps mentioned in the [CONTRIBUTING.md](CONTRIBUTING.md) file.
|
||||
@@ -0,0 +1,73 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and maintainers pledge to making participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
||||
level of experience, education, socio-economic status, nationality, personal
|
||||
appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||
advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic
|
||||
address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable
|
||||
behavior and are expected to take appropriate and fair corrective action in
|
||||
response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or
|
||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any contributor for other behaviors that they deem inappropriate,
|
||||
threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community. Examples of
|
||||
representing a project or community include using an official project e-mail
|
||||
address, posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event. Representation of a project may be
|
||||
further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by contacting the project team via this [link](https://www.st.com/content/st_com/en/contact-us.html).
|
||||
All complaints will be reviewed and investigated and will result in a response that
|
||||
is deemed necessary and appropriate to the circumstances. The project team is
|
||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||
Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||
faith may face temporary or permanent repercussions as determined by other
|
||||
members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 1.4,
|
||||
available [here](https://www.contributor-covenant.org/version/1/4/code-of-conduct.html).
|
||||
|
||||
For answers to common questions about this code of conduct, refer to the FAQ section [here](https://www.contributor-covenant.org/faq).
|
||||
@@ -0,0 +1,40 @@
|
||||
## Contributing guide
|
||||
|
||||
This guide serves as a checklist before contributing to this repository. It mainly focuses on the steps to follow to submit an issue or a pull-request.
|
||||
|
||||
### 1. Issues
|
||||
|
||||
#### 1.1 Before opening an issue
|
||||
|
||||
Please check the following points before posting an issue:
|
||||
* Make sure you are using the latest commit (major releases are tagged, but corrections are available as new commits).
|
||||
* Make sure your issue is a question/feedback/suggestions **related to** the software provided in this repository. Otherwise, please refer to section [3](CONTRIBUTING.md#3.-support-requests-and-questions) below.
|
||||
* Make sure your issue is not already reported/fixed on GitHub or discussed on a previous issue. Please refer to this [dashboard](https://github.com/orgs/STMicroelectronics/projects/2) for the list of issues and pull-requests. Do not forget to browse into the **closed** issues.
|
||||
|
||||
#### 1.2 Posting the issue
|
||||
|
||||
When you have checked the previous points, create a new report from the **Issues** tab of this repository. A template is available [here](issues/new/choose) to help you report the issue you are facing or the enhancement you would like to propose.
|
||||
|
||||
### 2. Pull Requests
|
||||
|
||||
#### 2.1 Before opening a pull-request
|
||||
|
||||
STMicrolectronics is happy to receive contributions from the community, based on an initial Contributor License Agreement (CLA) procedure.
|
||||
|
||||
* If you are an individual writing original source code and you are sure **you own the intellectual property**, then you need to sign an Individual [CLA](https://cla.st.com).
|
||||
* If you work for a company that wants also to allow you to contribute with your work, your company needs to provide a Corporate [CLA](https://cla.st.com) mentioning your GitHub account name.
|
||||
* If you are not sure that a CLA (Individual or Corporate) has been signed for your GitHub account you can check the [CLA](https://cla.st.com) dedicated page.
|
||||
|
||||
Please note that:
|
||||
* The Corporate CLA will always take precedence over the Individual CLA.
|
||||
* One CLA submission is sufficient, for any project proposed by STMicroelectronics.
|
||||
|
||||
#### 2.2 How to proceed
|
||||
|
||||
* We recommend to engage first a communication thru an issue, in order to present your proposal, just to confirm that it corresponds to STMicroelectronics' domain or scope.
|
||||
* Then fork the project to your GitHub account to further develop your contribution. Please use the latest commit version.
|
||||
* Please, submit one pull-request per new feature or proposal. This will ease the analysis and the final merge if accepted.
|
||||
|
||||
### 3. Support requests and questions
|
||||
|
||||
For support requests or any other question related to the product, the tools, the environment, you can submit a post to the **ST Community** on the appropriate topic [page](https://community.st.com/s/topiccatalog).
|
||||
@@ -0,0 +1,11 @@
|
||||
Copyright 2019 STMicroelectronics. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
@@ -0,0 +1,41 @@
|
||||
# BSP STM32H735G-DK Component
|
||||
|
||||

|
||||
|
||||
## Overview
|
||||
|
||||
**STM32Cube** is an STMicroelectronics original initiative to ease developers' life by reducing efforts, time and cost.
|
||||
|
||||
**STM32Cube** covers the overall STM32 products portfolio. It includes a comprehensive embedded software platform delivered for each STM32 series.
|
||||
* The CMSIS modules (core and device) corresponding to the ARM(tm) core implemented in this STM32 product.
|
||||
* The STM32 HAL-LL drivers, an abstraction layer offering a set of APIs ensuring maximized portability across the STM32 portfolio.
|
||||
* The BSP drivers of each evaluation, demonstration or nucleo board provided for this STM32 series.
|
||||
* A consistent set of middleware libraries such as RTOS, USB, FatFS, graphics, touch sensing library...
|
||||
* A full set of software projects (basic examples, applications, and demonstrations) for each board provided for this STM32 series.
|
||||
|
||||
Two models of publication are proposed for the STM32Cube embedded software:
|
||||
* The monolithic **MCU Package**: all STM32Cube software modules of one STM32 series are present (Drivers, Middleware, Projects, Utilities) in the repository (usual name **STM32Cubexx**, xx corresponding to the STM32 series).
|
||||
* The **MCU component**: each STM32Cube software module being part of the STM32Cube MCU Package, is delivered as an individual repository, allowing the user to select and get only the required software functions.
|
||||
|
||||
## Description
|
||||
|
||||
This **stm32h735g-dk** MCU component repository is one element of the **STM32CubeH7** MCU embedded software package, providing the **STM32H735G-DK** BSP BOARD component part.
|
||||
|
||||
## Release note
|
||||
|
||||
Details about the content of this release are available in the release note [here](https://htmlpreview.github.io/?https://github.com/STMicroelectronics/stm32h735g-dk/blob/main/Release_Notes.html).
|
||||
|
||||
## Compatibility information
|
||||
|
||||
Below is the list of the BSP *component* drivers to be used with this BSP *board* driver. It is **crucial** that you use a consistent set of CMSIS - HAL - BSP versions, as mentioned in [this](https://htmlpreview.github.io/?https://github.com/STMicroelectronics/STM32CubeH7/blob/master/Release_Notes.html) release note.
|
||||
|
||||
* [stm32-bsp-common](https://github.com/STMicroelectronics/stm32-bsp-common)
|
||||
* [stm32-ft5336](https://github.com/STMicroelectronics/stm32-ft5336)
|
||||
* [stm32-mx25lm51245g](https://github.com/STMicroelectronics/stm32-mx25lm51245g)
|
||||
* [stm32-rk043fn48h](https://github.com/STMicroelectronics/stm32-rk043fn48h)
|
||||
* [stm32-s70kl1281](https://github.com/STMicroelectronics/stm32-s70kl1281)
|
||||
* [stm32-wm8994](https://github.com/STMicroelectronics/stm32-wm8994)
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
Please refer to the [CONTRIBUTING.md](CONTRIBUTING.md) guide.
|
||||
@@ -0,0 +1,112 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="generator" content="pandoc" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
|
||||
<title>Release Notes for STM32H735G-DK BSP Drivers</title>
|
||||
<style type="text/css">
|
||||
code{white-space: pre-wrap;}
|
||||
span.smallcaps{font-variant: small-caps;}
|
||||
span.underline{text-decoration: underline;}
|
||||
div.column{display: inline-block; vertical-align: top; width: 50%;}
|
||||
</style>
|
||||
<link rel="stylesheet" href="_htmresc/mini-st_2020.css" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
|
||||
<![endif]-->
|
||||
</head>
|
||||
<body>
|
||||
<div class="row">
|
||||
<div class="col-sm-12 col-lg-4">
|
||||
<center>
|
||||
<h1 id="release-notes-for-stm32h735g-dk-bsp-drivers"><strong>Release Notes for STM32H735G-DK BSP Drivers</strong></h1>
|
||||
<p>Copyright © 2019 STMicroelectronics<br />
|
||||
</p>
|
||||
<a href="https://www.st.com" class="logo"><img src="_htmresc/st_logo_2020.png" alt="ST logo" /></a>
|
||||
</center>
|
||||
<h1 id="purpose">Purpose</h1>
|
||||
<p>The BSP (Board Specific Package) drivers are parts of the STM32Cube package based on the HAL drivers and provide a set of high level APIs relative to the hardware components and features in the evaluation boards, discovery kits and nucleo boards coming with the STM32Cube package for a given STM32 series.</p>
|
||||
<p>The BSP drivers allow a quick access to the boards’ services using high level APIs and without any specific configuration as the link with the HAL and the external components is done in intrinsic within the drivers.</p>
|
||||
<p>From project settings points of view, user has only to add the necessary driver’s files in the workspace and call the needed functions from examples. However some low level configuration functions are weak and can be overridden by the applications if user wants to change some BSP drivers default behavior.</p>
|
||||
</div>
|
||||
<div class="col-sm-12 col-lg-8">
|
||||
<h1 id="update-history">Update History</h1>
|
||||
<div class="collapse">
|
||||
<input type="checkbox" id="collapse-section6" checked aria-hidden="true"> <label for="collapse-section6" aria-hidden="true"><strong>V1.2.3 / 04-Septyember-2024</strong></label>
|
||||
<div>
|
||||
<h2 id="main-changes">Main Changes</h2>
|
||||
<ul>
|
||||
<li>Update STM32H735G-DK BSP drivers to support new Touch Screen component GT911.</li>
|
||||
<li>Apply general code Artistic Style fixes.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="collapse">
|
||||
<input type="checkbox" id="collapse-section5" aria-hidden="true"> <label for="collapse-section5" aria-hidden="true"><strong>V1.2.2 / 19-February-2024</strong></label>
|
||||
<div>
|
||||
<h2 id="main-changes-1">Main Changes</h2>
|
||||
<ul>
|
||||
<li>Invert argument order between definitions and declarations of I2C4_WriteReg() and I2C4_ReadReg().</li>
|
||||
<li>Fix timeout value in BSP_SD_WriteBlocks() API.</li>
|
||||
<li>Increase timeout compliantly to the SD Cards specification.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="collapse">
|
||||
<input type="checkbox" id="collapse-section4" aria-hidden="true"> <label for="collapse-section4" aria-hidden="true"><strong>V1.2.1 / 11-February-2022</strong></label>
|
||||
<div>
|
||||
<h2 id="main-changes-2">Main Changes</h2>
|
||||
<ul>
|
||||
<li>All source files: update disclaimer to add reference to the new license agreement.</li>
|
||||
<li>Modified the address calculation in the BSP_LCD_FillRGBRect() function when USE_DMA2D_TO_FILL_RGB_RECT is enabled to suppress the display of a distorted shape instead of a rectangle when trying to draw a rectangle with a bigger height.</li>
|
||||
<li>Cache maintained operation is included in the BSP_LCD_FillRGBRect() function to solve the display issue when USE_DMA2D_TO_FILL_RGB_RECT is enabled.</li>
|
||||
<li>Fix supported latency type and delete Deep power feature for external RAM.</li>
|
||||
<li>Add check on the audio OUT device to select the appropriate Output Device in the BSP_AUDIO_OUT_Init() function.</li>
|
||||
<li>Fix Hard Fault in the BSP_AUDIO_IN_Init() function by adding the WM8994_Probe() function at the appropriate place.</li>
|
||||
<li>Fix OSPI memory erasing issue in the BSP_OSPI_NOR_Erase_Block() function.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="collapse">
|
||||
<input type="checkbox" id="collapse-section3" aria-hidden="true"> <label for="collapse-section3" aria-hidden="true"><strong>V1.2.0 / 29-January-2021</strong></label>
|
||||
<div>
|
||||
<h2 id="main-changes-3">Main Changes</h2>
|
||||
<ul>
|
||||
<li>Minor typo fixes in comments</li>
|
||||
</ul>
|
||||
<h2 id="dependencies">Dependencies</h2>
|
||||
<ul>
|
||||
<li>Components/common v7.0.0</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="collapse">
|
||||
<input type="checkbox" id="collapse-section2" aria-hidden="true"> <label for="collapse-section2" aria-hidden="true"><strong>V1.1.0 / 29-September-2020</strong></label>
|
||||
<div>
|
||||
<h2 id="main-changes-4">Main Changes</h2>
|
||||
<ul>
|
||||
<li>Add License.md file</li>
|
||||
</ul>
|
||||
<h2 id="dependencies-1">Dependencies</h2>
|
||||
<ul>
|
||||
<li>Components/common v7.0.0</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="collapse">
|
||||
<input type="checkbox" id="collapse-section1" aria-hidden="true"> <label for="collapse-section1" aria-hidden="true"><strong>V1.0.0 / 19-May-2020</strong></label>
|
||||
<div>
|
||||
<h2 id="main-changes-5">Main Changes</h2>
|
||||
<ul>
|
||||
<li>First release of STM32H735G-DK BSP drivers in line with STM32Cube BSP drivers development guidelines (UM2298)</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<footer class="sticky">
|
||||
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <span style="font-color: blue;"><a href="http://www.st.com/STM32">www.st.com</a></span>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,31 @@
|
||||
# Report potential product security vulnerabilities
|
||||
|
||||
ST places a high priority on security, and our Product Security Incident
|
||||
Response Team (PSIRT) is committed to rapidly addressing potential security
|
||||
vulnerabilities affecting our products. PSIRT's long history and vast experience
|
||||
in security allows ST to perform clear analyses and provide appropriate guidance
|
||||
on mitigations and solutions when applicable.
|
||||
|
||||
If you wish to report potential security vulnerabilities regarding our products,
|
||||
**please do not report them through public GitHub issues.** Instead, we
|
||||
encourage you to report them to our ST PSIRT following the process described at:
|
||||
**https://www.st.com/content/st_com/en/security/report-vulnerabilities.html**
|
||||
|
||||
### IMPORTANT - READ CAREFULLY:
|
||||
|
||||
STMicroelectronics International N.V., on behalf of itself, its affiliates and
|
||||
subsidiaries, (collectively “ST”) takes all potential security vulnerability
|
||||
reports or other related communications (“Report(s)”) seriously. In order to
|
||||
review Your Report (the terms “You” and “Yours” include your employer, and all
|
||||
affiliates, subsidiaries and related persons or entities) and take actions as
|
||||
deemed appropriate, ST requires that we have the rights and Your permission to
|
||||
do so.
|
||||
|
||||
As such, by submitting Your Report to ST, You agree that You have the right to
|
||||
do so, and You grant to ST the rights to use the Report for purposes related to
|
||||
security vulnerability analysis, testing, correction, patching, reporting and
|
||||
any other related purpose or function.
|
||||
|
||||
By submitting Your Report, You agree that ST’s
|
||||
[Privacy Policy](https://www.st.com/content/st_com/en/common/privacy-portal.html)
|
||||
applies to all related communications.
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 4.0 KiB |
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
After Width: | Height: | Size: 7.3 KiB |
@@ -0,0 +1,620 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32h735g_discovery.c
|
||||
* @author MCD Application Team
|
||||
* @brief This file provides a set of firmware functions to manage
|
||||
* LEDs
|
||||
* push-buttons
|
||||
* COM ports
|
||||
* available on STM32H735G_DK board(MB1520) from STMicroelectronics.
|
||||
@endverbatim
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2019 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32h735g_discovery.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H735G_DK
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H735G_DK_LOW_LEVEL LOW LEVEL
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H735G_DK_LOW_LEVEL_Private_TypesDefinitions Private Types Definitions
|
||||
* @{
|
||||
*/
|
||||
typedef void (* BSP_EXTI_LineCallback)(void);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H735G_DK_LOW_LEVEL_Private_FunctionPrototypes Private Function Prototypes
|
||||
* @{
|
||||
*/
|
||||
static void BUTTON_USER_EXTI_Callback(void);
|
||||
#if (USE_BSP_COM_FEATURE > 0)
|
||||
static void USART1_MspInit(UART_HandleTypeDef *huart);
|
||||
static void USART1_MspDeInit(UART_HandleTypeDef *huart);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H735G_DK_LOW_LEVEL_Exported_Variables Exported Variables
|
||||
* @{
|
||||
*/
|
||||
EXTI_HandleTypeDef hpb_exti[BUTTONn];
|
||||
#if (USE_BSP_COM_FEATURE > 0)
|
||||
UART_HandleTypeDef hcom_uart[COMn];
|
||||
USART_TypeDef *COM_USART[COMn] = {COM1_UART};
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H735G_DK_LOW_LEVEL_Private_Variables Private Variables
|
||||
* @{
|
||||
*/
|
||||
static GPIO_TypeDef *LED_PORT[LEDn] =
|
||||
{
|
||||
LED1_GPIO_PORT,
|
||||
LED2_GPIO_PORT
|
||||
};
|
||||
static const uint32_t LED_PIN[LEDn] = {LED1_PIN,
|
||||
LED2_PIN
|
||||
};
|
||||
|
||||
static GPIO_TypeDef *BUTTON_PORT[BUTTONn] = {BUTTON_USER_GPIO_PORT};
|
||||
static const uint16_t BUTTON_PIN[BUTTONn] = {BUTTON_USER_PIN};
|
||||
static const IRQn_Type BUTTON_IRQn[BUTTONn] = {BUTTON_USER_EXTI_IRQn};
|
||||
#if (USE_BSP_COM_FEATURE > 0)
|
||||
#if (USE_COM_LOG == 1)
|
||||
static COM_TypeDef COM_ActiveLogPort = COM1;
|
||||
#endif
|
||||
#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
|
||||
static uint32_t IsComMspCbValid[COMn] = {0};
|
||||
#endif
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H735G_DK_LOW_LEVEL_Exported_Functions Exported Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief This method returns the STM32H735G_DK BSP Driver revision
|
||||
* @retval version: 0xXYZR (8bits for each decimal, R for RC)
|
||||
*/
|
||||
int32_t BSP_GetVersion(void)
|
||||
{
|
||||
return (int32_t)STM32H735G_DK_BSP_VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configures LED on GPIO.
|
||||
* @param Led LED to be configured.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg LED1
|
||||
* @arg LED2
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_LED_Init(Led_TypeDef Led)
|
||||
{
|
||||
int32_t ret = BSP_ERROR_NONE;
|
||||
|
||||
GPIO_InitTypeDef gpio_init_structure;
|
||||
|
||||
/* Enable the GPIO_LED clock */
|
||||
if (Led == LED1)
|
||||
{
|
||||
LED1_GPIO_CLK_ENABLE();
|
||||
}
|
||||
else if (Led == LED2)
|
||||
{
|
||||
|
||||
LED2_GPIO_CLK_ENABLE();
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = BSP_ERROR_WRONG_PARAM;
|
||||
}
|
||||
|
||||
/* Configure the GPIO_LED pin */
|
||||
gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
gpio_init_structure.Pull = GPIO_PULLUP;
|
||||
gpio_init_structure.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
gpio_init_structure.Pin = LED_PIN [Led];
|
||||
HAL_GPIO_Init(LED_PORT [Led], &gpio_init_structure);
|
||||
HAL_GPIO_WritePin(LED_PORT [Led], LED_PIN[Led], GPIO_PIN_SET);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DeInit LEDs.
|
||||
* @param Led LED to be configured.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg LED1
|
||||
* @arg LED2
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_LED_DeInit(Led_TypeDef Led)
|
||||
{
|
||||
int32_t ret = BSP_ERROR_NONE;
|
||||
GPIO_InitTypeDef gpio_init_structure;
|
||||
|
||||
/* DeInit the GPIO_LED pin */
|
||||
gpio_init_structure.Pin = LED_PIN [Led];
|
||||
/* Turn off LED */
|
||||
HAL_GPIO_WritePin(LED_PORT [Led], (uint16_t)LED_PIN[Led], GPIO_PIN_SET);
|
||||
HAL_GPIO_DeInit(LED_PORT [Led], gpio_init_structure.Pin);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Turns selected LED On.
|
||||
* @param Led LED to be set on
|
||||
* This parameter can be one of the following values:
|
||||
* @arg LED1
|
||||
* @arg LED2
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_LED_On(Led_TypeDef Led)
|
||||
{
|
||||
int32_t ret = BSP_ERROR_NONE;
|
||||
|
||||
HAL_GPIO_WritePin(LED_PORT [Led], (uint16_t)LED_PIN [Led], GPIO_PIN_RESET);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Turns selected LED Off.
|
||||
* @param Led LED to be set off
|
||||
* This parameter can be one of the following values:
|
||||
* @arg LED1
|
||||
* @arg LED2
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_LED_Off(Led_TypeDef Led)
|
||||
{
|
||||
int32_t ret = BSP_ERROR_NONE;
|
||||
HAL_GPIO_WritePin(LED_PORT [Led], (uint16_t)LED_PIN [Led], GPIO_PIN_SET);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Toggles the selected LED.
|
||||
* @param Led LED to be toggled
|
||||
* This parameter can be one of the following values:
|
||||
* @arg LED1
|
||||
* @arg LED2
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_LED_Toggle(Led_TypeDef Led)
|
||||
{
|
||||
int32_t ret = BSP_ERROR_NONE;
|
||||
HAL_GPIO_TogglePin(LED_PORT[Led], (uint16_t)LED_PIN[Led]);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the selected LED state.
|
||||
* @param Led LED to be get its state
|
||||
* This parameter can be one of the following values:
|
||||
* @arg LED1
|
||||
* @arg LED2
|
||||
* @retval LED status
|
||||
*/
|
||||
int32_t BSP_LED_GetState(Led_TypeDef Led)
|
||||
{
|
||||
int32_t ret = BSP_ERROR_NONE;
|
||||
ret = (int32_t)HAL_GPIO_ReadPin(LED_PORT [Led], (uint16_t)LED_PIN [Led]);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configures button GPIO and EXTI Line.
|
||||
* @param Button: Button to be configured
|
||||
* This parameter can be one of the following values:
|
||||
* @arg BUTTON_USER: User Push Button
|
||||
* @param ButtonMode Button mode
|
||||
* This parameter can be one of the following values:
|
||||
* @arg BUTTON_MODE_GPIO: Button will be used as simple IO
|
||||
* @arg BUTTON_MODE_EXTI: Button will be connected to EXTI line
|
||||
* with interrupt generation capability
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef ButtonMode)
|
||||
{
|
||||
GPIO_InitTypeDef gpio_init_structure;
|
||||
static BSP_EXTI_LineCallback ButtonCallback[BUTTONn] = {BUTTON_USER_EXTI_Callback};
|
||||
static uint32_t BSP_BUTTON_PRIO [BUTTONn] = {BSP_BUTTON_USER_IT_PRIORITY};
|
||||
static const uint32_t BUTTON_EXTI_LINE[BUTTONn] = {BUTTON_USER_EXTI_LINE};
|
||||
/* Enable the BUTTON clock*/
|
||||
BUTTON_USER_GPIO_CLK_ENABLE();
|
||||
gpio_init_structure.Pin = BUTTON_PIN [Button];
|
||||
gpio_init_structure.Pull = GPIO_PULLDOWN;
|
||||
gpio_init_structure.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
|
||||
if (ButtonMode == BUTTON_MODE_GPIO)
|
||||
{
|
||||
/* Configure Button pin as input */
|
||||
gpio_init_structure.Mode = GPIO_MODE_INPUT;
|
||||
HAL_GPIO_Init(BUTTON_PORT [Button], &gpio_init_structure);
|
||||
}
|
||||
else /* (ButtonMode == BUTTON_MODE_EXTI) */
|
||||
{
|
||||
/* Configure Button pin as input with External interrupt */
|
||||
gpio_init_structure.Mode = GPIO_MODE_IT_RISING;
|
||||
|
||||
HAL_GPIO_Init(BUTTON_PORT[Button], &gpio_init_structure);
|
||||
|
||||
(void)HAL_EXTI_GetHandle(&hpb_exti[Button], BUTTON_EXTI_LINE[Button]);
|
||||
(void)HAL_EXTI_RegisterCallback(&hpb_exti[Button], HAL_EXTI_COMMON_CB_ID, ButtonCallback[Button]);
|
||||
|
||||
/* Enable and set Button EXTI Interrupt to the lowest priority */
|
||||
HAL_NVIC_SetPriority((BUTTON_IRQn[Button]), BSP_BUTTON_PRIO[Button], 0x00);
|
||||
HAL_NVIC_EnableIRQ((BUTTON_IRQn[Button]));
|
||||
}
|
||||
return BSP_ERROR_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Push Button DeInit.
|
||||
* @param Button Button to be configured
|
||||
* This parameter can be one of the following values:
|
||||
* @arg BUTTON_USER: User Push Button
|
||||
* @note PB DeInit does not disable the GPIO clock
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_PB_DeInit(Button_TypeDef Button)
|
||||
{
|
||||
GPIO_InitTypeDef gpio_init_structure;
|
||||
|
||||
gpio_init_structure.Pin = BUTTON_PIN[Button];
|
||||
HAL_NVIC_DisableIRQ((IRQn_Type)(BUTTON_IRQn[Button]));
|
||||
HAL_GPIO_DeInit(BUTTON_PORT[Button], gpio_init_structure.Pin);
|
||||
|
||||
return BSP_ERROR_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns the selected button state.
|
||||
* @param Button Button to be checked
|
||||
* This parameter can be one of the following values:
|
||||
* @arg BUTTON_USER: User Push Button
|
||||
* @retval The Button GPIO pin value
|
||||
*/
|
||||
int32_t BSP_PB_GetState(Button_TypeDef Button)
|
||||
{
|
||||
return (int32_t)HAL_GPIO_ReadPin(BUTTON_PORT[Button], BUTTON_PIN[Button]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles Push-Button interrupt requests.
|
||||
* @param Button Specifies the pin connected EXTI line
|
||||
* @retval None
|
||||
*/
|
||||
void BSP_PB_IRQHandler(Button_TypeDef Button)
|
||||
{
|
||||
HAL_EXTI_IRQHandler(&hpb_exti[Button]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief KEY EXTI line detection callbacks.
|
||||
* @retval None
|
||||
*/
|
||||
static void BUTTON_USER_EXTI_Callback(void)
|
||||
{
|
||||
BSP_PB_Callback(BUTTON_USER);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief BSP Push Button callback
|
||||
* @param Button Specifies the pin connected EXTI line
|
||||
* @retval None.
|
||||
*/
|
||||
__weak void BSP_PB_Callback(Button_TypeDef Button)
|
||||
{
|
||||
/* Prevent unused argument(s) compilation warning */
|
||||
UNUSED(Button);
|
||||
/* This function should be implemented by the user application.
|
||||
It is called into this driver when an event on Button is triggered. */
|
||||
}
|
||||
|
||||
#if (USE_BSP_COM_FEATURE > 0)
|
||||
/**
|
||||
* @brief Configures COM port.
|
||||
* @param COM COM port to be configured.
|
||||
* This parameter can be COM1
|
||||
* @param COM_Init Pointer to a UART_HandleTypeDef structure that contains the
|
||||
* configuration information for the specified USART peripheral.
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_COM_Init(COM_TypeDef COM, COM_InitTypeDef *COM_Init)
|
||||
{
|
||||
int32_t ret = BSP_ERROR_NONE;
|
||||
|
||||
if (COM >= COMn)
|
||||
{
|
||||
ret = BSP_ERROR_WRONG_PARAM;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Init the UART Msp */
|
||||
#if (USE_HAL_UART_REGISTER_CALLBACKS == 0)
|
||||
USART1_MspInit(&hcom_uart[COM]);
|
||||
#else
|
||||
if (IsComMspCbValid[COM] == 0U)
|
||||
{
|
||||
if (BSP_COM_RegisterDefaultMspCallbacks(COM) != BSP_ERROR_NONE)
|
||||
{
|
||||
return BSP_ERROR_MSP_FAILURE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (MX_USART3_Init(&hcom_uart[COM], COM_Init) != HAL_OK)
|
||||
{
|
||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DeInit COM port.
|
||||
* @param COM COM port to be configured.
|
||||
* This parameter can be COM1
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_COM_DeInit(COM_TypeDef COM)
|
||||
{
|
||||
int32_t ret = BSP_ERROR_NONE;
|
||||
|
||||
if (COM >= COMn)
|
||||
{
|
||||
ret = BSP_ERROR_WRONG_PARAM;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* USART configuration */
|
||||
hcom_uart[COM].Instance = COM_USART[COM];
|
||||
|
||||
#if (USE_HAL_UART_REGISTER_CALLBACKS == 0)
|
||||
USART1_MspDeInit(&hcom_uart[COM]);
|
||||
#endif /* (USE_HAL_UART_REGISTER_CALLBACKS == 0) */
|
||||
|
||||
if (HAL_UART_DeInit(&hcom_uart[COM]) != HAL_OK)
|
||||
{
|
||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configures COM1 port.
|
||||
* @param huart USART handle
|
||||
* @param COM_Init Pointer to a UART_HandleTypeDef structure that contains the
|
||||
* configuration information for the specified USART peripheral.
|
||||
* @retval HAL error code
|
||||
*/
|
||||
__weak HAL_StatusTypeDef MX_USART3_Init(UART_HandleTypeDef *huart, MX_UART_InitTypeDef *COM_Init)
|
||||
{
|
||||
/* USART configuration */
|
||||
huart->Instance = COM_USART[COM1];
|
||||
huart->Init.BaudRate = COM_Init->BaudRate;
|
||||
huart->Init.Mode = UART_MODE_TX_RX;
|
||||
huart->Init.Parity = (uint32_t)COM_Init->Parity;
|
||||
huart->Init.WordLength = COM_Init->WordLength;
|
||||
huart->Init.StopBits = (uint32_t)COM_Init->StopBits;
|
||||
huart->Init.HwFlowCtl = (uint32_t)COM_Init->HwFlowCtl;
|
||||
huart->Init.OverSampling = UART_OVERSAMPLING_8;
|
||||
|
||||
return HAL_UART_Init(huart);
|
||||
}
|
||||
|
||||
|
||||
#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
|
||||
/**
|
||||
* @brief Register Default COM Msp Callbacks
|
||||
* @param COM COM port to be configured.
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_COM_RegisterDefaultMspCallbacks(COM_TypeDef COM)
|
||||
{
|
||||
int32_t ret = BSP_ERROR_NONE;
|
||||
|
||||
if (COM >= COMn)
|
||||
{
|
||||
ret = BSP_ERROR_WRONG_PARAM;
|
||||
}
|
||||
else
|
||||
{
|
||||
__HAL_UART_RESET_HANDLE_STATE(&hcom_uart[COM]);
|
||||
|
||||
/* Register default MspInit/MspDeInit Callback */
|
||||
if (HAL_UART_RegisterCallback(&hcom_uart[COM], HAL_UART_MSPINIT_CB_ID, USART1_MspInit) != HAL_OK)
|
||||
{
|
||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
else if (HAL_UART_RegisterCallback(&hcom_uart[COM], HAL_UART_MSPDEINIT_CB_ID, USART1_MspDeInit) != HAL_OK)
|
||||
{
|
||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
IsComMspCbValid[COM] = 1U;
|
||||
}
|
||||
}
|
||||
|
||||
/* BSP status */
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Register COM1 Msp Callback registering
|
||||
* @param COM COM port to be configured.
|
||||
* @param Callbacks pointer to COM MspInit/MspDeInit callback functions
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_COM_RegisterMspCallbacks(COM_TypeDef COM, BSP_COM_Cb_t *Callback)
|
||||
{
|
||||
int32_t ret = BSP_ERROR_NONE;
|
||||
|
||||
if (COM >= COMn)
|
||||
{
|
||||
ret = BSP_ERROR_WRONG_PARAM;
|
||||
}
|
||||
else
|
||||
{
|
||||
__HAL_UART_RESET_HANDLE_STATE(&hcom_uart[COM]);
|
||||
|
||||
/* Register MspInit/MspDeInit Callbacks */
|
||||
if (HAL_UART_RegisterCallback(&hcom_uart[COM], HAL_UART_MSPINIT_CB_ID, Callback->pMspInitCb) != HAL_OK)
|
||||
{
|
||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
else if (HAL_UART_RegisterCallback(&hcom_uart[COM], HAL_UART_MSPDEINIT_CB_ID, Callback->pMspDeInitCb) != HAL_OK)
|
||||
{
|
||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
IsComMspCbValid[COM] = 1U;
|
||||
}
|
||||
}
|
||||
|
||||
/* BSP status */
|
||||
return ret;
|
||||
}
|
||||
#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
|
||||
|
||||
#if (USE_COM_LOG == 1)
|
||||
/**
|
||||
* @brief Select the active COM port.
|
||||
* @param COM COM port to be activated.
|
||||
* This parameter can be COM1
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_COM_SelectLogPort(COM_TypeDef COM)
|
||||
{
|
||||
if (COM_ActiveLogPort != COM)
|
||||
{
|
||||
COM_ActiveLogPort = COM;
|
||||
}
|
||||
return BSP_ERROR_NONE;
|
||||
}
|
||||
|
||||
#ifdef __GNUC__
|
||||
int __io_putchar(int ch)
|
||||
#else
|
||||
int fputc(int ch, FILE *f)
|
||||
#endif /* __GNUC__ */
|
||||
{
|
||||
HAL_UART_Transmit(&hcom_uart [COM_ActiveLogPort], (uint8_t *) &ch, 1, COM_POLL_TIMEOUT);
|
||||
return ch;
|
||||
}
|
||||
#endif /* USE_COM_LOG */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H735G_DK_LOW_LEVEL_Private_Functions Private Functions
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief Initializes UART MSP.
|
||||
* @param huart UART handle
|
||||
* @retval None
|
||||
*/
|
||||
static void USART1_MspInit(UART_HandleTypeDef *huart)
|
||||
{
|
||||
GPIO_InitTypeDef gpio_init_structure;
|
||||
|
||||
/* Prevent unused argument(s) compilation warning */
|
||||
UNUSED(huart);
|
||||
|
||||
/* Enable GPIO clock */
|
||||
COM1_TX_GPIO_CLK_ENABLE();
|
||||
COM1_RX_GPIO_CLK_ENABLE();
|
||||
|
||||
/* Enable USART clock */
|
||||
COM1_CLK_ENABLE();
|
||||
|
||||
/* Configure USART Tx as alternate function */
|
||||
gpio_init_structure.Pin = COM1_TX_PIN;
|
||||
gpio_init_structure.Mode = GPIO_MODE_AF_PP;
|
||||
gpio_init_structure.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
gpio_init_structure.Pull = GPIO_PULLUP;
|
||||
gpio_init_structure.Alternate = COM1_TX_AF;
|
||||
HAL_GPIO_Init(COM1_TX_GPIO_PORT, &gpio_init_structure);
|
||||
|
||||
/* Configure USART Rx as alternate function */
|
||||
gpio_init_structure.Pin = COM1_RX_PIN;
|
||||
gpio_init_structure.Mode = GPIO_MODE_AF_PP;
|
||||
gpio_init_structure.Alternate = COM1_RX_AF;
|
||||
HAL_GPIO_Init(COM1_RX_GPIO_PORT, &gpio_init_structure);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize USART3 Msp part
|
||||
* @param huart UART handle
|
||||
* @retval None
|
||||
*/
|
||||
static void USART1_MspDeInit(UART_HandleTypeDef *huart)
|
||||
{
|
||||
GPIO_InitTypeDef gpio_init_structure;
|
||||
|
||||
/* Prevent unused argument(s) compilation warning */
|
||||
UNUSED(huart);
|
||||
|
||||
/* COM GPIO pin configuration */
|
||||
gpio_init_structure.Pin = COM1_TX_PIN;
|
||||
HAL_GPIO_DeInit(COM1_TX_GPIO_PORT, gpio_init_structure.Pin);
|
||||
|
||||
gpio_init_structure.Pin = COM1_RX_PIN;
|
||||
HAL_GPIO_DeInit(COM1_RX_GPIO_PORT, gpio_init_structure.Pin);
|
||||
|
||||
/* Disable USART clock */
|
||||
COM1_CLK_DISABLE();
|
||||
}
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@@ -0,0 +1,284 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32h735g_discovery.h
|
||||
* @author MCD Application Team
|
||||
* @brief This file contains definitions for STM32H735G_DK:
|
||||
* LEDs
|
||||
* push-buttons
|
||||
* COM ports
|
||||
* hardware resources.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2019 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef STM32H735G_DK_H
|
||||
#define STM32H735G_DK_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32h735g_discovery_conf.h"
|
||||
#include "stm32h735g_discovery_errno.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32H735G_DK
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32H735G_DK_LOW_LEVEL
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H735G_DK_LOW_LEVEL_Exported_Types LOW LEVEL Exported Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LED1 = 0U,
|
||||
LED_GREEN = LED1,
|
||||
LED2 = 1U,
|
||||
LED_RED = LED2,
|
||||
LEDn
|
||||
} Led_TypeDef;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
BUTTON_USER = 0U,
|
||||
BUTTONn
|
||||
} Button_TypeDef;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
BUTTON_MODE_GPIO = 0U,
|
||||
BUTTON_MODE_EXTI = 1U
|
||||
} ButtonMode_TypeDef;
|
||||
|
||||
#if (USE_BSP_COM_FEATURE > 0)
|
||||
typedef enum
|
||||
{
|
||||
COM1 = 0U,
|
||||
COMn
|
||||
} COM_TypeDef;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
COM_STOPBITS_1 = UART_STOPBITS_1,
|
||||
COM_STOPBITS_2 = UART_STOPBITS_2,
|
||||
} COM_StopBitsTypeDef;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
COM_PARITY_NONE = UART_PARITY_NONE,
|
||||
COM_PARITY_EVEN = UART_PARITY_EVEN,
|
||||
COM_PARITY_ODD = UART_PARITY_ODD,
|
||||
} COM_ParityTypeDef;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
COM_HWCONTROL_NONE = UART_HWCONTROL_NONE,
|
||||
COM_HWCONTROL_RTS = UART_HWCONTROL_RTS,
|
||||
COM_HWCONTROL_CTS = UART_HWCONTROL_CTS,
|
||||
COM_HWCONTROL_RTS_CTS = UART_HWCONTROL_RTS_CTS,
|
||||
} COM_HwFlowCtlTypeDef;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
COM_WORDLENGTH_7B = UART_WORDLENGTH_7B,
|
||||
COM_WORDLENGTH_8B = UART_WORDLENGTH_8B,
|
||||
COM_WORDLENGTH_9B = UART_WORDLENGTH_9B,
|
||||
} COM_WordLengthTypeDef;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t BaudRate;
|
||||
COM_WordLengthTypeDef WordLength;
|
||||
COM_StopBitsTypeDef StopBits;
|
||||
COM_ParityTypeDef Parity;
|
||||
COM_HwFlowCtlTypeDef HwFlowCtl;
|
||||
} COM_InitTypeDef;
|
||||
|
||||
#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
|
||||
typedef struct
|
||||
{
|
||||
void (* pMspInitCb)(UART_HandleTypeDef *);
|
||||
void (* pMspDeInitCb)(UART_HandleTypeDef *);
|
||||
} BSP_COM_Cb_t;
|
||||
#endif /* (USE_HAL_UART_REGISTER_CALLBACKS == 1) */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H735G_DK_LOW_LEVEL_Exported_Constants LOW LEVEL Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Define for STM32H735G_DK board
|
||||
*/
|
||||
#if !defined (USE_STM32H735G_DK)
|
||||
#define USE_STM32H735G_DK
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief STM32H735G_DK BSP Driver version number
|
||||
*/
|
||||
#define STM32H735G_DK_BSP_VERSION_MAIN (uint32_t)(0x01) /*!< [31:24] main version */
|
||||
#define STM32H735G_DK_BSP_VERSION_SUB1 (uint32_t)(0x02) /*!< [23:16] sub1 version */
|
||||
#define STM32H735G_DK_BSP_VERSION_SUB2 (uint32_t)(0x03) /*!< [15:8] sub2 version */
|
||||
#define STM32H735G_DK_BSP_VERSION_RC (uint32_t)(0x00) /*!< [7:0] release candidate */
|
||||
#define STM32H735G_DK_BSP_VERSION ((STM32H735G_DK_BSP_VERSION_MAIN << 24)\
|
||||
|(STM32H735G_DK_BSP_VERSION_SUB1 << 16)\
|
||||
|(STM32H735G_DK_BSP_VERSION_SUB2 << 8 )\
|
||||
|(STM32H735G_DK_BSP_VERSION_RC))
|
||||
|
||||
|
||||
/** @defgroup STM32H735G_DK_LOW_LEVEL_LED EVAL LOW LEVEL LED
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define LED1_GPIO_PORT GPIOC
|
||||
#define LED1_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE()
|
||||
#define LED1_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE()
|
||||
#define LED1_PIN GPIO_PIN_3
|
||||
|
||||
#define LED2_GPIO_PORT GPIOC
|
||||
#define LED2_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE()
|
||||
#define LED2_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE()
|
||||
#define LED2_PIN GPIO_PIN_2
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/** @defgroup STM32H735G_DK_LOW_LEVEL_BUTTON LOW LEVEL BUTTON
|
||||
* @{
|
||||
*/
|
||||
/* Button state */
|
||||
#define BUTTON_RELEASED 0U
|
||||
#define BUTTON_PRESSED 1U
|
||||
|
||||
/**
|
||||
* @brief User-button
|
||||
*/
|
||||
#define BUTTON_USER_PIN GPIO_PIN_13
|
||||
#define BUTTON_USER_GPIO_PORT GPIOC
|
||||
#define BUTTON_USER_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE()
|
||||
#define BUTTON_USER_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE()
|
||||
#define BUTTON_USER_EXTI_IRQn EXTI15_10_IRQn
|
||||
#define BUTTON_USER_EXTI_LINE EXTI_LINE_13
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H735G_DK_LOW_LEVEL_COM LOW LEVEL COM
|
||||
* @{
|
||||
*/
|
||||
#if (USE_BSP_COM_FEATURE > 0)
|
||||
/**
|
||||
* @brief Definition for COM port1, connected to USART3
|
||||
*/
|
||||
#define COM1_UART USART3
|
||||
#define COM1_CLK_ENABLE() __HAL_RCC_USART3_CLK_ENABLE()
|
||||
#define COM1_CLK_DISABLE() __HAL_RCC_USART3_CLK_DISABLE()
|
||||
|
||||
#define COM1_TX_PIN GPIO_PIN_8
|
||||
#define COM1_TX_GPIO_PORT GPIOD
|
||||
#define COM1_TX_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE()
|
||||
#define COM1_TX_GPIO_CLK_DISABLE() __HAL_RCC_GPIOD_CLK_DISABLE()
|
||||
#define COM1_TX_AF GPIO_AF7_USART3
|
||||
|
||||
#define COM1_RX_PIN GPIO_PIN_9
|
||||
#define COM1_RX_GPIO_PORT GPIOD
|
||||
#define COM1_RX_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE()
|
||||
#define COM1_RX_GPIO_CLK_DISABLE() __HAL_RCC_GPIOD_CLK_DISABLE()
|
||||
#define COM1_RX_AF GPIO_AF7_USART3
|
||||
#define COM_POLL_TIMEOUT 1000
|
||||
|
||||
#define MX_UART_InitTypeDef COM_InitTypeDef
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtgroup STM32H735G_DK_LOW_LEVEL_Exported_Variables
|
||||
* @{
|
||||
*/
|
||||
extern EXTI_HandleTypeDef hpb_exti[];
|
||||
#if (USE_BSP_COM_FEATURE > 0)
|
||||
extern UART_HandleTypeDef hcom_uart[];
|
||||
extern USART_TypeDef *COM_USART[];
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H735G_DK_LOW_LEVEL_Exported_FunctionsPrototypes LOW LEVEL Exported Functions Prototypes
|
||||
* @{
|
||||
*/
|
||||
int32_t BSP_GetVersion(void);
|
||||
int32_t BSP_LED_Init(Led_TypeDef Led);
|
||||
int32_t BSP_LED_DeInit(Led_TypeDef Led);
|
||||
int32_t BSP_LED_On(Led_TypeDef Led);
|
||||
int32_t BSP_LED_Off(Led_TypeDef Led);
|
||||
int32_t BSP_LED_Toggle(Led_TypeDef Led);
|
||||
int32_t BSP_LED_GetState(Led_TypeDef Led);
|
||||
int32_t BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef ButtonMode);
|
||||
int32_t BSP_PB_DeInit(Button_TypeDef Button);
|
||||
int32_t BSP_PB_GetState(Button_TypeDef Button);
|
||||
void BSP_PB_Callback(Button_TypeDef Button);
|
||||
#if (USE_BSP_COM_FEATURE > 0)
|
||||
int32_t BSP_COM_Init(COM_TypeDef COM, COM_InitTypeDef *COM_Init);
|
||||
int32_t BSP_COM_DeInit(COM_TypeDef COM);
|
||||
#if( USE_COM_LOG == 1)
|
||||
int32_t BSP_COM_SelectLogPort(COM_TypeDef COM);
|
||||
#endif
|
||||
|
||||
#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
|
||||
int32_t BSP_COM_RegisterDefaultMspCallbacks(COM_TypeDef COM);
|
||||
int32_t BSP_COM_RegisterMspCallbacks(COM_TypeDef COM, BSP_COM_Cb_t *Callback);
|
||||
#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
|
||||
HAL_StatusTypeDef MX_USART3_Init(UART_HandleTypeDef *huart, MX_UART_InitTypeDef *COM_Init);
|
||||
#endif
|
||||
void BSP_PB_IRQHandler(Button_TypeDef Button);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* STM32H735G_DK_H */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,592 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32h735g_discovery_audio.h
|
||||
* @author MCD Application Team
|
||||
* @brief This file contains the common defines and functions prototypes for
|
||||
* the stm32h735g_discovery_audio.c driver.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2019 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef STM32H735G_DISCO_AUDIO_H
|
||||
#define STM32H735G_DISCO_AUDIO_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32h735g_discovery_conf.h"
|
||||
#include "stm32h735g_discovery_errno.h"
|
||||
|
||||
#if (USE_AUDIO_CODEC_WM8994 == 1U)
|
||||
/* Include audio component Driver */
|
||||
#include "../Components/wm8994/wm8994.h"
|
||||
#endif
|
||||
#include "../Components/Common/audio.h"
|
||||
/* Include PDM to PCM lib header file */
|
||||
#include "pdm2pcm_glo.h"
|
||||
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32H735G_DISCO
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup AUDIO
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H735G_DISCO_AUDIO_Exported_Types AUDIO Exported Types
|
||||
* @{
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t Device;
|
||||
uint32_t SampleRate;
|
||||
uint32_t BitsPerSample;
|
||||
uint32_t ChannelsNbr;
|
||||
uint32_t Volume;
|
||||
} BSP_AUDIO_Init_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t Instance; /* Audio IN instance */
|
||||
uint32_t Device; /* Audio IN device to be used */
|
||||
uint32_t SampleRate; /* Audio IN Sample rate */
|
||||
uint32_t BitsPerSample; /* Audio IN Sample resolution */
|
||||
uint32_t ChannelsNbr; /* Audio IN number of channel */
|
||||
uint16_t *pBuff; /* Audio IN record buffer */
|
||||
uint8_t **pMultiBuff; /* Audio IN multi-buffer */
|
||||
uint32_t Size; /* Audio IN record buffer size */
|
||||
uint32_t Volume; /* Audio IN volume */
|
||||
uint32_t State; /* Audio IN State */
|
||||
uint32_t IsMultiBuff; /* Audio IN multi-buffer usage */
|
||||
uint32_t IsMspCallbacksValid; /* Is Msp Callbacks registered */
|
||||
} AUDIO_IN_Ctx_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t Instance; /* Audio OUT instance */
|
||||
uint32_t Device; /* Audio OUT device to be used */
|
||||
uint32_t SampleRate; /* Audio OUT Sample rate */
|
||||
uint32_t BitsPerSample; /* Audio OUT Sample Bit Per Sample */
|
||||
uint32_t Volume; /* Audio OUT volume */
|
||||
uint32_t ChannelsNbr; /* Audio OUT number of channel */
|
||||
uint32_t IsMute; /* Mute state */
|
||||
uint32_t State; /* Audio OUT State */
|
||||
uint32_t IsMspCallbacksValid; /* Is Msp Callbacks registered */
|
||||
} AUDIO_OUT_Ctx_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t AudioFrequency;
|
||||
uint32_t AudioMode;
|
||||
uint32_t DataSize;
|
||||
uint32_t MonoStereoMode;
|
||||
uint32_t ClockStrobing;
|
||||
uint32_t Synchro;
|
||||
uint32_t OutputDrive;
|
||||
uint32_t SynchroExt;
|
||||
uint32_t FrameLength;
|
||||
uint32_t ActiveFrameLength;
|
||||
uint32_t SlotActive;
|
||||
} MX_SAI_Config;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t SampleRate;
|
||||
uint32_t AudioMode;
|
||||
uint32_t FullDuplexMode;
|
||||
} MX_I2S_Config;
|
||||
|
||||
#if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)||(USE_HAL_I2S_REGISTER_CALLBACKS == 1)
|
||||
typedef struct
|
||||
{
|
||||
#if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
|
||||
pSAI_CallbackTypeDef pMspSaiInitCb;
|
||||
pSAI_CallbackTypeDef pMspSaiDeInitCb;
|
||||
#endif
|
||||
#if (USE_HAL_I2S_REGISTER_CALLBACKS == 1)
|
||||
pI2S_CallbackTypeDef pMspI2sInitCb;
|
||||
pI2S_CallbackTypeDef pMspI2sDeInitCb;
|
||||
#endif
|
||||
} BSP_AUDIO_OUT_Cb_t;
|
||||
#endif /* (USE_HAL_SAI_REGISTER_CALLBACKS == 1)||(USE_HAL_I2S_REGISTER_CALLBACKS == 1) */
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/* Filter parameters */
|
||||
DFSDM_Filter_TypeDef *FilterInstance;
|
||||
uint32_t RegularTrigger;
|
||||
uint32_t SincOrder;
|
||||
uint32_t Oversampling;
|
||||
/* Channel parameters */
|
||||
DFSDM_Channel_TypeDef *ChannelInstance;
|
||||
uint32_t DigitalMicPins;
|
||||
uint32_t DigitalMicType;
|
||||
uint32_t Channel4Filter;
|
||||
uint32_t ClockDivider;
|
||||
uint32_t RightBitShift;
|
||||
} MX_DFSDM_Config;
|
||||
|
||||
#if ((USE_HAL_DFSDM_REGISTER_CALLBACKS == 1) || (USE_HAL_SAI_REGISTER_CALLBACKS == 1))
|
||||
typedef struct
|
||||
{
|
||||
#if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
|
||||
pSAI_CallbackTypeDef pMspSaiInitCb;
|
||||
pSAI_CallbackTypeDef pMspSaiDeInitCb;
|
||||
#endif
|
||||
#if (USE_HAL_DFSDM_REGISTER_CALLBACKS == 1)
|
||||
pDFSDM_Filter_CallbackTypeDef pMspFltrInitCb;
|
||||
pDFSDM_Filter_CallbackTypeDef pMspFltrDeInitCb;
|
||||
pDFSDM_Channel_CallbackTypeDef pMspChInitCb;
|
||||
pDFSDM_Channel_CallbackTypeDef pMspChDeInitCb;
|
||||
#endif /* (USE_HAL_DFSDM_REGISTER_CALLBACKS == 1) */
|
||||
} BSP_AUDIO_IN_Cb_t;
|
||||
#endif /* ((USE_HAL_DFSDM_REGISTER_CALLBACKS == 1) || (USE_HAL_SAI_REGISTER_CALLBACKS == 1)) */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H735G_DISCO_AUDIO_Exported_Constants AUDIO Exported Constants
|
||||
* @{
|
||||
*/
|
||||
#define AUDIO_I2C_ADDRESS 0x34U
|
||||
|
||||
/* AUDIO FREQUENCY */
|
||||
#define AUDIO_FREQUENCY_192K 192000U
|
||||
#define AUDIO_FREQUENCY_176K 176400U
|
||||
#define AUDIO_FREQUENCY_96K 96000U
|
||||
#define AUDIO_FREQUENCY_88K 88200U
|
||||
#define AUDIO_FREQUENCY_48K 48000U
|
||||
#define AUDIO_FREQUENCY_44K 44100U
|
||||
#define AUDIO_FREQUENCY_32K 32000U
|
||||
#define AUDIO_FREQUENCY_22K 22050U
|
||||
#define AUDIO_FREQUENCY_16K 16000U
|
||||
#define AUDIO_FREQUENCY_11K 11025U
|
||||
#define AUDIO_FREQUENCY_8K 8000U
|
||||
|
||||
/* Audio bits per sample */
|
||||
#define AUDIO_RESOLUTION_8B 8U
|
||||
#define AUDIO_RESOLUTION_16B 16U
|
||||
#define AUDIO_RESOLUTION_24B 24U
|
||||
#define AUDIO_RESOLUTION_32B 32U
|
||||
|
||||
/* Audio Out devices */
|
||||
#define AUDIO_OUT_DEVICE_NONE 0U
|
||||
#define AUDIO_OUT_DEVICE_SPEAKER 1U
|
||||
#define AUDIO_OUT_DEVICE_HEADPHONE 2U
|
||||
#define AUDIO_OUT_DEVICE_SPK_HP 3U
|
||||
#define AUDIO_OUT_DEVICE_AUTO 4U
|
||||
#define AUDIO_OUT_DEVICE_HDMI 5U
|
||||
|
||||
/* Audio Mute state */
|
||||
#define BSP_AUDIO_MUTE_DISABLED 0U
|
||||
#define BSP_AUDIO_MUTE_ENABLED 1U
|
||||
|
||||
/* Audio Out states */
|
||||
#define AUDIO_OUT_STATE_RESET 0U
|
||||
#define AUDIO_OUT_STATE_PLAYING 1U
|
||||
#define AUDIO_OUT_STATE_STOP 2U
|
||||
#define AUDIO_OUT_STATE_PAUSE 3U
|
||||
|
||||
/* Audio Out states */
|
||||
/* Volume Input Output selection */
|
||||
#define AUDIO_VOLUME_INPUT 0U
|
||||
#define AUDIO_VOLUME_OUTPUT 1U
|
||||
|
||||
/* Codec commands */
|
||||
#define CODEC_PDWN_SW 1U
|
||||
#define CODEC_MUTE_ON 1U
|
||||
#define CODEC_MUTE_OFF 0U
|
||||
|
||||
/* Audio Out instances number */
|
||||
#define AUDIO_OUT_INSTANCES_NBR 1U
|
||||
|
||||
/** CODEC_AudioFrame_SLOT_TDMMode In W8994 codec the Audio frame contains 4 slots : TDM Mode
|
||||
* TDM format :
|
||||
* +------------------|------------------|--------------------|-------------------+
|
||||
* | CODEC_SLOT0 Left | CODEC_SLOT1 Left | CODEC_SLOT0 Right | CODEC_SLOT1 Right |
|
||||
* +------------------------------------------------------------------------------+
|
||||
*/
|
||||
/* To have 2 separate audio stream in Both headphone and speaker the 4 slot must be activated */
|
||||
#define CODEC_AUDIOFRAME_SLOT_0123 SAI_SLOTACTIVE_0 |\
|
||||
SAI_SLOTACTIVE_1 | SAI_SLOTACTIVE_2 | SAI_SLOTACTIVE_3
|
||||
/* To have an audio stream in headphone only SAI Slot 0 and Slot 2 must be activated */
|
||||
#define CODEC_AUDIOFRAME_SLOT_02 SAI_SLOTACTIVE_0 | SAI_SLOTACTIVE_2
|
||||
/* To have an audio stream in speaker only SAI Slot 1 and Slot 3 must be activated */
|
||||
#define CODEC_AUDIOFRAME_SLOT_13 SAI_SLOTACTIVE_1 | SAI_SLOTACTIVE_3
|
||||
/* SAI peripheral configuration defines */
|
||||
#define AUDIO_OUT_SAIx SAI1_Block_B
|
||||
#define AUDIO_OUT_SAIx_CLK_ENABLE() __HAL_RCC_SAI1_CLK_ENABLE()
|
||||
#define AUDIO_OUT_SAIx_CLK_DISABLE() __HAL_RCC_SAI1_CLK_DISABLE()
|
||||
|
||||
#define AUDIO_OUT_SAIx_MCLK_ENABLE() __HAL_RCC_GPIOF_CLK_ENABLE()
|
||||
#define AUDIO_OUT_SAIx_MCLK_GPIO_PORT GPIOF
|
||||
#define AUDIO_OUT_SAIx_MCLK_PIN GPIO_PIN_7
|
||||
#define AUDIO_OUT_SAIx_MCLK_AF GPIO_AF6_SAI1
|
||||
|
||||
#define AUDIO_OUT_SAIx_SCK_ENABLE() __HAL_RCC_GPIOF_CLK_ENABLE()
|
||||
#define AUDIO_OUT_SAIx_SCK_GPIO_PORT GPIOF
|
||||
#define AUDIO_OUT_SAIx_SCK_PIN GPIO_PIN_8
|
||||
#define AUDIO_OUT_SAIx_SCK_AF GPIO_AF6_SAI1
|
||||
|
||||
#define AUDIO_OUT_SAIx_SD_ENABLE() __HAL_RCC_GPIOF_CLK_ENABLE()
|
||||
#define AUDIO_OUT_SAIx_SD_GPIO_PORT GPIOF
|
||||
#define AUDIO_OUT_SAIx_SD_PIN GPIO_PIN_6
|
||||
#define AUDIO_OUT_SAIx_SD_AF GPIO_AF6_SAI1
|
||||
|
||||
#define AUDIO_OUT_SAIx_FS_ENABLE() __HAL_RCC_GPIOF_CLK_ENABLE()
|
||||
#define AUDIO_OUT_SAIx_FS_GPIO_PORT GPIOF
|
||||
#define AUDIO_OUT_SAIx_FS_PIN GPIO_PIN_9
|
||||
#define AUDIO_OUT_SAIx_FS_AF GPIO_AF6_SAI1
|
||||
|
||||
/* SAI DMA Stream definitions */
|
||||
#define AUDIO_OUT_SAIx_DMAx_CLK_ENABLE() __HAL_RCC_DMA2_CLK_ENABLE()
|
||||
#define AUDIO_OUT_SAIx_DMAx_STREAM DMA2_Stream6
|
||||
#define AUDIO_OUT_SAIx_DMAx_REQUEST DMA_REQUEST_SAI1_B
|
||||
#define AUDIO_OUT_SAIx_DMAx_IRQ DMA2_Stream6_IRQn
|
||||
#define AUDIO_OUT_SAIx_DMAx_PERIPH_DATA_SIZE DMA_PDATAALIGN_HALFWORD
|
||||
#define AUDIO_OUT_SAIx_DMAx_MEM_DATA_SIZE DMA_MDATAALIGN_HALFWORD
|
||||
#define AUDIO_OUT_SAIx_DMAx_IRQHandler DMA2_Stream6_IRQHandler
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
AUDIO IN CONFIGURATION
|
||||
------------------------------------------------------------------------------*/
|
||||
/* SAI peripheral configuration defines */
|
||||
#define AUDIO_IN_SAIx SAI1_Block_A
|
||||
#define AUDIO_IN_SAIx_CLK_ENABLE() __HAL_RCC_SAI1_CLK_ENABLE()
|
||||
#define AUDIO_IN_SAIx_CLK_DISABLE() __HAL_RCC_SAI1_CLK_DISABLE()
|
||||
#define AUDIO_IN_SAIx_AF GPIO_AF6_SAI1
|
||||
#define AUDIO_IN_SAIx_SD_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE()
|
||||
#define AUDIO_IN_SAIx_SD_GPIO_PORT GPIOE
|
||||
#define AUDIO_IN_SAIx_SD_PIN GPIO_PIN_6
|
||||
|
||||
/* SAI DMA Stream definitions */
|
||||
#define AUDIO_IN_SAIx_DMAx_CLK_ENABLE() __HAL_RCC_DMA2_CLK_ENABLE()
|
||||
#define AUDIO_IN_SAIx_DMAx_STREAM DMA2_Stream4
|
||||
#define AUDIO_IN_SAIx_DMAx_REQUEST DMA_REQUEST_SAI1_A
|
||||
#define AUDIO_IN_SAIx_DMAx_IRQ DMA2_Stream4_IRQn
|
||||
#define AUDIO_IN_SAIx_DMAx_PERIPH_DATA_SIZE DMA_PDATAALIGN_HALFWORD
|
||||
#define AUDIO_IN_SAIx_DMAx_MEM_DATA_SIZE DMA_MDATAALIGN_HALFWORD
|
||||
#define AUDIO_IN_SAIx_DMAx_IRQHandler DMA2_Stream4_IRQHandler
|
||||
|
||||
/* SAI PDM input definitions */
|
||||
#define AUDIO_IN_SAI_PDMx SAI4_Block_A
|
||||
#define AUDIO_IN_SAI_PDMx_CLK_ENABLE() __HAL_RCC_SAI4_CLK_ENABLE()
|
||||
#define AUDIO_IN_SAI_PDMx_CLK_DISABLE() __HAL_RCC_SAI4_CLK_DISABLE()
|
||||
#define AUDIO_IN_SAI_PDMx_FS_SCK_AF GPIO_AF8_SAI4
|
||||
#define AUDIO_IN_SAI_PDMx_FS_SCK_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE()
|
||||
#define AUDIO_IN_SAI_PDMx_FS_SCK_GPIO_PORT GPIOE
|
||||
#define AUDIO_IN_SAI_PDMx_FS_PIN GPIO_PIN_4
|
||||
#define AUDIO_IN_SAI_PDMx_SCK_PIN GPIO_PIN_5
|
||||
|
||||
#define AUDIO_IN_SAI_PDMx_CLK_IN_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE()
|
||||
#define AUDIO_IN_SAI_PDMx_CLK_IN_PIN GPIO_PIN_2
|
||||
#define AUDIO_IN_SAI_PDMx_CLK_IN_PORT GPIOE
|
||||
#define AUDIO_IN_SAI_PDMx_DATA_IN_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE()
|
||||
#define AUDIO_IN_SAI_PDMx_DATA_IN_PIN GPIO_PIN_1
|
||||
#define AUDIO_IN_SAI_PDMx_DATA_IN_PORT GPIOC
|
||||
#define AUDIO_IN_SAI_PDMx_DATA_CLK_AF GPIO_AF10_SAI4
|
||||
#define AUDIO_IN_SAI_PDMx_IRQHandler SAI4_IRQHandler
|
||||
#define AUDIO_IN_SAI_PDMx_IRQ SAI4_IRQn
|
||||
|
||||
/* SAI PDM DMA Stream definitions */
|
||||
#define AUDIO_IN_SAI_PDMx_DMAx_CLK_ENABLE() __HAL_RCC_BDMA_CLK_ENABLE()
|
||||
#define AUDIO_IN_SAI_PDMx_DMAx_STREAM BDMA_Channel1
|
||||
#define AUDIO_IN_SAI_PDMx_DMAx_REQUEST BDMA_REQUEST_SAI4_A
|
||||
#define AUDIO_IN_SAI_PDMx_DMAx_IRQ BDMA_Channel1_IRQn
|
||||
#define AUDIO_IN_SAI_PDMx_DMAx_PERIPH_DATA_SIZE DMA_PDATAALIGN_HALFWORD
|
||||
#define AUDIO_IN_SAI_PDMx_DMAx_MEM_DATA_SIZE DMA_MDATAALIGN_HALFWORD
|
||||
#define AUDIO_IN_SAI_PDMx_DMAx_IRQHandler BDMA_Channel1_IRQHandler
|
||||
|
||||
/* DFSDM Configuration defines */
|
||||
#define AUDIO_DFSDMx_MIC1_CHANNEL DFSDM1_Channel2
|
||||
#define AUDIO_DFSDMx_MIC2_CHANNEL DFSDM1_Channel1
|
||||
#define AUDIO_DFSDMx_MIC3_CHANNEL DFSDM1_Channel6
|
||||
#define AUDIO_DFSDMx_MIC4_CHANNEL DFSDM1_Channel5
|
||||
|
||||
#define AUDIO_DFSDMx_MIC1_CHANNEL_FOR_FILTER DFSDM_CHANNEL_2
|
||||
#define AUDIO_DFSDMx_MIC2_CHANNEL_FOR_FILTER DFSDM_CHANNEL_1
|
||||
#define AUDIO_DFSDMx_MIC3_CHANNEL_FOR_FILTER DFSDM_CHANNEL_6
|
||||
#define AUDIO_DFSDMx_MIC4_CHANNEL_FOR_FILTER DFSDM_CHANNEL_5
|
||||
|
||||
#define AUDIO_DFSDMx_MIC1_FILTER DFSDM1_Filter0
|
||||
#define AUDIO_DFSDMx_MIC2_FILTER DFSDM1_Filter1
|
||||
#define AUDIO_DFSDMx_MIC3_FILTER DFSDM1_Filter2
|
||||
#define AUDIO_DFSDMx_MIC4_FILTER DFSDM1_Filter3
|
||||
|
||||
#define AUDIO_DFSDM1_CLK_ENABLE() __HAL_RCC_DFSDM1_CLK_ENABLE()
|
||||
|
||||
/* DATIN for MIC1 (GPIOE_PIN_7) */
|
||||
#define AUDIO_DFSDMx_DATIN_MIC1_PIN GPIO_PIN_7
|
||||
#define AUDIO_DFSDMx_DATIN_MIC1_AF GPIO_AF3_DFSDM1
|
||||
#define AUDIO_DFSDMx_DATIN_MIC1_GPIO_PORT GPIOE
|
||||
#define AUDIO_DFSDMx_DATIN_MIC1_GPIO_CLK_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE()
|
||||
|
||||
/* DATIN for MIC2 (GPIOE_PIN_7)*/
|
||||
#define AUDIO_DFSDMx_DATIN_MIC2_PIN GPIO_PIN_7
|
||||
#define AUDIO_DFSDMx_DATIN_MIC2_AF GPIO_AF3_DFSDM1
|
||||
#define AUDIO_DFSDMx_DATIN_MIC2_GPIO_PORT GPIOE
|
||||
#define AUDIO_DFSDMx_DATIN_MIC2_GPIO_CLK_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE()
|
||||
|
||||
/* DATIN for MIC3 (GPIOF_PIN_13) */
|
||||
#define AUDIO_DFSDMx_DATIN_MIC3_PIN GPIO_PIN_13
|
||||
#define AUDIO_DFSDMx_DATIN_MIC3_AF GPIO_AF3_DFSDM1
|
||||
#define AUDIO_DFSDMx_DATIN_MIC3_GPIO_PORT GPIOF
|
||||
#define AUDIO_DFSDMx_DATIN_MIC3_GPIO_CLK_ENABLE() __HAL_RCC_GPIOF_CLK_ENABLE()
|
||||
|
||||
/* DATIN for MIC4 (GPIOF_PIN_13)*/
|
||||
#define AUDIO_DFSDMx_DATIN_MIC4_PIN GPIO_PIN_13
|
||||
#define AUDIO_DFSDMx_DATIN_MIC4_AF GPIO_AF3_DFSDM1
|
||||
#define AUDIO_DFSDMx_DATIN_MIC4_GPIO_PORT GPIOF
|
||||
#define AUDIO_DFSDMx_DATIN_MIC4_GPIO_CLK_ENABLE() __HAL_RCC_GPIOF_CLK_ENABLE()
|
||||
|
||||
/* CKOUT for all mics connected to DFSDM1 (GPIOE_PIN_9)*/
|
||||
#define AUDIO_DFSDM1_CKOUT_PIN GPIO_PIN_9
|
||||
#define AUDIO_DFSDM1_CKOUT_AF GPIO_AF3_DFSDM1
|
||||
#define AUDIO_DFSDM1_CKOUT_GPIO_PORT GPIOE
|
||||
#define AUDIO_DFSDM1_CKOUT_GPIO_CLK_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE()
|
||||
|
||||
/* DFSDM DMA MIC1, MIC2, MIC3 and MIC4 channels definitions */
|
||||
#define AUDIO_DFSDMx_DMAx_MIC1_STREAM DMA2_Stream7
|
||||
#define AUDIO_DFSDMx_DMAx_MIC1_REQUEST (uint32_t)DMA_REQUEST_DFSDM1_FLT0
|
||||
#define AUDIO_DFSDMx_DMAx_MIC1_IRQ DMA2_Stream7_IRQn
|
||||
#define AUDIO_DFSDM_DMAx_MIC1_IRQHandler DMA2_Stream7_IRQHandler
|
||||
|
||||
#define AUDIO_DFSDMx_DMAx_MIC2_STREAM DMA2_Stream0
|
||||
#define AUDIO_DFSDMx_DMAx_MIC2_REQUEST (uint32_t)DMA_REQUEST_DFSDM1_FLT1
|
||||
#define AUDIO_DFSDMx_DMAx_MIC2_IRQ DMA2_Stream0_IRQn
|
||||
#define AUDIO_DFSDM_DMAx_MIC2_IRQHandler DMA2_Stream0_IRQHandler
|
||||
|
||||
#define AUDIO_DFSDMx_DMAx_MIC3_STREAM DMA2_Stream3
|
||||
#define AUDIO_DFSDMx_DMAx_MIC3_REQUEST (uint32_t)DMA_REQUEST_DFSDM1_FLT2
|
||||
#define AUDIO_DFSDMx_DMAx_MIC3_IRQ DMA2_Stream3_IRQn
|
||||
#define AUDIO_DFSDM_DMAx_MIC3_IRQHandler DMA2_Stream3_IRQHandler
|
||||
|
||||
#define AUDIO_DFSDMx_DMAx_MIC4_STREAM DMA2_Stream2
|
||||
#define AUDIO_DFSDMx_DMAx_MIC4_REQUEST (uint32_t)DMA_REQUEST_DFSDM1_FLT3
|
||||
#define AUDIO_DFSDMx_DMAx_MIC4_IRQ DMA2_Stream2_IRQn
|
||||
#define AUDIO_DFSDM_DMAx_MIC4_IRQHandler DMA2_Stream2_IRQHandler
|
||||
|
||||
#define AUDIO_DFSDMx_DMAx_PERIPH_DATA_SIZE DMA_PDATAALIGN_WORD
|
||||
#define AUDIO_DFSDMx_DMAx_MEM_DATA_SIZE DMA_MDATAALIGN_WORD
|
||||
#define AUDIO_DFSDM1_DMAx_CLK_ENABLE() __HAL_RCC_DMA2_CLK_ENABLE()
|
||||
|
||||
/* Audio In devices */
|
||||
/* Analog microphone input from 3.5 audio jack connector */
|
||||
#define AUDIO_IN_DEVICE_ANALOG_MIC 0x00U
|
||||
#define AUDIO_IN_DEVICE_ANALOG_LINE1 0x01U
|
||||
|
||||
/* MP34DT01TR digital microphone on PCB top side */
|
||||
#define AUDIO_IN_DEVICE_DIGITAL_MIC1 0x010U
|
||||
#define AUDIO_IN_DEVICE_DIGITAL_MIC2 0x020U
|
||||
#define AUDIO_IN_DEVICE_DIGITAL_MIC3 0x040U
|
||||
#define AUDIO_IN_DEVICE_DIGITAL_MIC4 0x080U
|
||||
#define AUDIO_IN_DEVICE_DIGITAL_MIC_LAST AUDIO_IN_DEVICE_DIGITAL_MIC4
|
||||
#define AUDIO_IN_DEVICE_DIGITAL_MIC (AUDIO_IN_DEVICE_DIGITAL_MIC1 | AUDIO_IN_DEVICE_DIGITAL_MIC2)
|
||||
|
||||
#define DFSDM_MIC_NUMBER 4U
|
||||
|
||||
/* Audio In states */
|
||||
#define AUDIO_IN_STATE_RESET 0U
|
||||
#define AUDIO_IN_STATE_RECORDING 1U
|
||||
#define AUDIO_IN_STATE_STOP 2U
|
||||
#define AUDIO_IN_STATE_PAUSE 3U
|
||||
|
||||
/* Audio In instances number */
|
||||
#define AUDIO_IN_INSTANCES_NBR 3U
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H735G_DISCO_AUDIO_Exported_Macros AUDIO Exported Macros
|
||||
* @{
|
||||
*/
|
||||
#define POS_VAL(VAL) (POSITION_VAL(VAL) - 4U)
|
||||
#define VOLUME_OUT_CONVERT(Volume) (((Volume) > 100)? 63:((uint8_t)(((Volume) * 63) / 100)))
|
||||
#define VOLUME_IN_CONVERT(Volume) (((Volume) >= 100)? 239:((uint8_t)(((Volume) * 239) / 100)))
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32H735G_DISCO_AUDIO_Exported_Variables
|
||||
* @{
|
||||
*/
|
||||
/* Audio in and out component object */
|
||||
extern void *AudioCompObj;
|
||||
/* Play */
|
||||
extern SAI_HandleTypeDef haudio_out_sai;
|
||||
extern AUDIO_OUT_Ctx_t Audio_Out_Ctx[];
|
||||
|
||||
/* Record */
|
||||
extern DFSDM_Filter_HandleTypeDef haudio_in_dfsdm_filter[];
|
||||
extern DFSDM_Channel_HandleTypeDef haudio_in_dfsdm_channel[];
|
||||
extern SAI_HandleTypeDef haudio_in_sai[];
|
||||
extern AUDIO_IN_Ctx_t Audio_In_Ctx[];
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32H735G_DISCO_AUDIO_OUT_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
int32_t BSP_AUDIO_OUT_Init(uint32_t Instance, BSP_AUDIO_Init_t *AudioInit);
|
||||
int32_t BSP_AUDIO_OUT_DeInit(uint32_t Instance);
|
||||
|
||||
#if (USE_HAL_SAI_REGISTER_CALLBACKS == 1) || (USE_HAL_I2S_REGISTER_CALLBACKS == 1)
|
||||
int32_t BSP_AUDIO_OUT_RegisterMspCallbacks(uint32_t Instance, BSP_AUDIO_OUT_Cb_t *CallBacks);
|
||||
int32_t BSP_AUDIO_OUT_RegisterDefaultMspCallbacks(uint32_t Instance);
|
||||
#endif /* (USE_HAL_SAI_REGISTER_CALLBACKS == 1)|| (USE_HAL_I2S_REGISTER_CALLBACKS == 1) */
|
||||
|
||||
int32_t BSP_AUDIO_OUT_Play(uint32_t Instance, uint8_t *pData, uint32_t NbrOfBytes);
|
||||
int32_t BSP_AUDIO_OUT_Pause(uint32_t Instance);
|
||||
int32_t BSP_AUDIO_OUT_Resume(uint32_t Instance);
|
||||
int32_t BSP_AUDIO_OUT_Stop(uint32_t Instance);
|
||||
int32_t BSP_AUDIO_OUT_Mute(uint32_t Instance);
|
||||
int32_t BSP_AUDIO_OUT_UnMute(uint32_t Instance);
|
||||
int32_t BSP_AUDIO_OUT_IsMute(uint32_t Instance, uint32_t *IsMute);
|
||||
|
||||
int32_t BSP_AUDIO_OUT_SetDevice(uint32_t Instance, uint32_t Device);
|
||||
int32_t BSP_AUDIO_OUT_GetDevice(uint32_t Instance, uint32_t *Device);
|
||||
|
||||
int32_t BSP_AUDIO_OUT_SetSampleRate(uint32_t Instance, uint32_t SampleRate);
|
||||
int32_t BSP_AUDIO_OUT_GetSampleRate(uint32_t Instance, uint32_t *SampleRate);
|
||||
|
||||
int32_t BSP_AUDIO_OUT_SetBitsPerSample(uint32_t Instance, uint32_t BitsPerSample);
|
||||
int32_t BSP_AUDIO_OUT_GetBitsPerSample(uint32_t Instance, uint32_t *BitsPerSample);
|
||||
|
||||
int32_t BSP_AUDIO_OUT_SetChannelsNbr(uint32_t Instance, uint32_t ChannelNbr);
|
||||
int32_t BSP_AUDIO_OUT_GetChannelsNbr(uint32_t Instance, uint32_t *ChannelNbr);
|
||||
|
||||
int32_t BSP_AUDIO_OUT_SetVolume(uint32_t Instance, uint32_t Volume);
|
||||
int32_t BSP_AUDIO_OUT_GetVolume(uint32_t Instance, uint32_t *Volume);
|
||||
int32_t BSP_AUDIO_OUT_GetState(uint32_t Instance, uint32_t *State);
|
||||
|
||||
void BSP_AUDIO_OUT_IRQHandler(uint32_t Instance);
|
||||
|
||||
/* User Callbacks: user has to implement these functions in his code if they are needed. */
|
||||
/* This function is called when the requested data has been completely transferred.*/
|
||||
void BSP_AUDIO_OUT_TransferComplete_CallBack(uint32_t Instance);
|
||||
|
||||
/* This function is called when half of the requested buffer has been transferred. */
|
||||
void BSP_AUDIO_OUT_HalfTransfer_CallBack(uint32_t Instance);
|
||||
|
||||
/* This function is called when an Interrupt due to transfer error on or peripheral
|
||||
error occurs. */
|
||||
void BSP_AUDIO_OUT_Error_CallBack(uint32_t Instance);
|
||||
|
||||
/* These function can be modified in case the current settings need to be changed
|
||||
for specific application needs */
|
||||
HAL_StatusTypeDef MX_SAI1_ClockConfig(SAI_HandleTypeDef *hsai, uint32_t SampleRate);
|
||||
HAL_StatusTypeDef MX_SAI1_Block_A_Init(SAI_HandleTypeDef *hsai, MX_SAI_Config *MXConfig);
|
||||
HAL_StatusTypeDef MX_I2S6_ClockConfig(I2S_HandleTypeDef *hi2s, uint32_t SampleRate);
|
||||
HAL_StatusTypeDef MX_I2S6_Init(I2S_HandleTypeDef *hi2s, MX_I2S_Config *MXConfig);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32H735G_DISCO_AUDIO_IN_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
int32_t BSP_AUDIO_IN_Init(uint32_t Instance, BSP_AUDIO_Init_t *AudioInit);
|
||||
int32_t BSP_AUDIO_IN_DeInit(uint32_t Instance);
|
||||
#if ((USE_HAL_DFSDM_REGISTER_CALLBACKS == 1) || (USE_HAL_SAI_REGISTER_CALLBACKS == 1))
|
||||
int32_t BSP_AUDIO_IN_RegisterDefaultMspCallbacks(uint32_t Instance);
|
||||
int32_t BSP_AUDIO_IN_RegisterMspCallbacks(uint32_t Instance, BSP_AUDIO_IN_Cb_t *CallBacks);
|
||||
#endif /* ((USE_HAL_DFSDM_REGISTER_CALLBACKS == 1) || (USE_HAL_SAI_REGISTER_CALLBACKS == 1)) */
|
||||
int32_t BSP_AUDIO_IN_Record(uint32_t Instance, uint8_t *pBuf, uint32_t NbrOfBytes);
|
||||
int32_t BSP_AUDIO_IN_Stop(uint32_t Instance);
|
||||
int32_t BSP_AUDIO_IN_Pause(uint32_t Instance);
|
||||
int32_t BSP_AUDIO_IN_Resume(uint32_t Instance);
|
||||
|
||||
int32_t BSP_AUDIO_IN_RecordChannels(uint32_t Instance, uint8_t **pBuf, uint32_t NbrOfBytes);
|
||||
int32_t BSP_AUDIO_IN_StopChannels(uint32_t Instance, uint32_t Device);
|
||||
int32_t BSP_AUDIO_IN_PauseChannels(uint32_t Instance, uint32_t Device);
|
||||
int32_t BSP_AUDIO_IN_ResumeChannels(uint32_t Instance, uint32_t Device);
|
||||
|
||||
int32_t BSP_AUDIO_IN_SetDevice(uint32_t Instance, uint32_t Device);
|
||||
int32_t BSP_AUDIO_IN_GetDevice(uint32_t Instance, uint32_t *Device);
|
||||
|
||||
int32_t BSP_AUDIO_IN_SetSampleRate(uint32_t Instance, uint32_t SampleRate);
|
||||
int32_t BSP_AUDIO_IN_GetSampleRate(uint32_t Instance, uint32_t *SampleRate);
|
||||
|
||||
int32_t BSP_AUDIO_IN_SetBitsPerSample(uint32_t Instance, uint32_t BitsPerSample);
|
||||
int32_t BSP_AUDIO_IN_GetBitsPerSample(uint32_t Instance, uint32_t *BitsPerSample);
|
||||
|
||||
int32_t BSP_AUDIO_IN_SetChannelsNbr(uint32_t Instance, uint32_t ChannelNbr);
|
||||
int32_t BSP_AUDIO_IN_GetChannelsNbr(uint32_t Instance, uint32_t *ChannelNbr);
|
||||
|
||||
int32_t BSP_AUDIO_IN_SetVolume(uint32_t Instance, uint32_t Volume);
|
||||
int32_t BSP_AUDIO_IN_GetVolume(uint32_t Instance, uint32_t *Volume);
|
||||
int32_t BSP_AUDIO_IN_GetState(uint32_t Instance, uint32_t *State);
|
||||
void BSP_AUDIO_IN_IRQHandler(uint32_t Instance, uint32_t InputDevice);
|
||||
|
||||
#if (USE_BSP_PDM_LIB_FEATURE > 0U)
|
||||
/* Specific PDM recodr APIs */
|
||||
int32_t BSP_AUDIO_IN_PDMToPCM_Init(uint32_t Instance, uint32_t AudioFreq, uint32_t ChnlNbrIn, uint32_t ChnlNbrOut);
|
||||
int32_t BSP_AUDIO_IN_PDMToPCM(uint32_t Instance, uint16_t *PDMBuf, uint16_t *PCMBuf);
|
||||
#endif
|
||||
int32_t BSP_AUDIO_IN_RecordPDM(uint32_t Instance, uint8_t *pBuf, uint32_t NbrOfBytes);
|
||||
|
||||
/* User Callbacks: user has to implement these functions in his code if they are needed. */
|
||||
/* This function should be implemented by the user application.
|
||||
It is called into this driver when the current buffer is filled to prepare the next
|
||||
buffer pointer and its size. */
|
||||
void BSP_AUDIO_IN_TransferComplete_CallBack(uint32_t Instance);
|
||||
void BSP_AUDIO_IN_HalfTransfer_CallBack(uint32_t Instance);
|
||||
|
||||
/* This function is called when an Interrupt due to transfer error on or peripheral
|
||||
error occurs. */
|
||||
void BSP_AUDIO_IN_Error_CallBack(uint32_t Instance);
|
||||
|
||||
/* These function can be modified in case the current settings (e.g. DMA stream)
|
||||
need to be changed for specific application needs */
|
||||
HAL_StatusTypeDef MX_DFSDM1_ClockConfig(DFSDM_Channel_HandleTypeDef *hDfsdmChannel, uint32_t SampleRate);
|
||||
HAL_StatusTypeDef MX_DFSDM1_Init(DFSDM_Filter_HandleTypeDef *hDfsdmFilter, DFSDM_Channel_HandleTypeDef *hDfsdmChannel,
|
||||
MX_DFSDM_Config *MXConfig);
|
||||
HAL_StatusTypeDef MX_DFSDM2_ClockConfig(DFSDM_Channel_HandleTypeDef *hDfsdmChannel, uint32_t SampleRate);
|
||||
HAL_StatusTypeDef MX_DFSDM2_Init(DFSDM_Filter_HandleTypeDef *hDfsdmFilter, DFSDM_Channel_HandleTypeDef *hDfsdmChannel,
|
||||
MX_DFSDM_Config *MXConfig);
|
||||
HAL_StatusTypeDef MX_SAI1_Block_B_Init(SAI_HandleTypeDef *hsai, MX_SAI_Config *MXConfig);
|
||||
HAL_StatusTypeDef MX_SAI4_ClockConfig(SAI_HandleTypeDef *hsai, uint32_t SampleRate);
|
||||
HAL_StatusTypeDef MX_SAI4_Block_A_Init(SAI_HandleTypeDef *hsai, MX_SAI_Config *MXConfig);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* STM32H735G_DISCO_AUDIO_H */
|
||||
@@ -0,0 +1,881 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32h735g_discovery_bus.c
|
||||
* @author MCD Application Team
|
||||
* @brief This file provides a set of firmware functions to communicate
|
||||
* with external devices available on STM32H735G-DK board (MB1520) from
|
||||
* STMicroelectronics.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2019 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32h735g_discovery_bus.h"
|
||||
#include "stm32h735g_discovery_errno.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32H735G_DK
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H735G_DK_BUS BUS
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H735G_DK_BUS_Private_Marcos Private Marcos
|
||||
* @{
|
||||
*/
|
||||
#define DIV_ROUND_CLOSEST(x, d) (((x) + ((d) / 2U)) / (d))
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/** @defgroup STM32H735G_DK_BUS_Private_Constants Private Constants
|
||||
* @{
|
||||
*/
|
||||
#ifndef I2C_VALID_TIMING_NBR
|
||||
#define I2C_VALID_TIMING_NBR 128U
|
||||
#endif
|
||||
#define I2C_SPEED_FREQ_STANDARD 0U /* 100 kHz */
|
||||
#define I2C_SPEED_FREQ_FAST 1U /* 400 kHz */
|
||||
#define I2C_SPEED_FREQ_FAST_PLUS 2U /* 1 MHz */
|
||||
#define I2C_ANALOG_FILTER_DELAY_MIN 50U /* ns */
|
||||
#define I2C_ANALOG_FILTER_DELAY_MAX 260U /* ns */
|
||||
#define I2C_USE_ANALOG_FILTER 1U
|
||||
#define I2C_DIGITAL_FILTER_COEF 0U
|
||||
#define I2C_PRESC_MAX 16U
|
||||
#define I2C_SCLDEL_MAX 16U
|
||||
#define I2C_SDADEL_MAX 16U
|
||||
#define I2C_SCLH_MAX 256U
|
||||
#define I2C_SCLL_MAX 256U
|
||||
#define SEC2NSEC 1000000000UL
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H735G_DK_BUS_Private_Types Private Types
|
||||
* @{
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t freq; /* Frequency in Hz */
|
||||
uint32_t freq_min; /* Minimum frequency in Hz */
|
||||
uint32_t freq_max; /* Maximum frequency in Hz */
|
||||
uint32_t hddat_min; /* Minimum data hold time in ns */
|
||||
uint32_t vddat_max; /* Maximum data valid time in ns */
|
||||
uint32_t sudat_min; /* Minimum data setup time in ns */
|
||||
uint32_t lscl_min; /* Minimum low period of the SCL clock in ns */
|
||||
uint32_t hscl_min; /* Minimum high period of SCL clock in ns */
|
||||
uint32_t trise; /* Rise time in ns */
|
||||
uint32_t tfall; /* Fall time in ns */
|
||||
uint32_t dnf; /* Digital noise filter coefficient */
|
||||
} I2C_Charac_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t presc; /* Timing prescaler */
|
||||
uint32_t tscldel; /* SCL delay */
|
||||
uint32_t tsdadel; /* SDA delay */
|
||||
uint32_t sclh; /* SCL high period */
|
||||
uint32_t scll; /* SCL low period */
|
||||
} I2C_Timings_t;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H735G_DK_BUS_Private_Constants Private Constants
|
||||
* @{
|
||||
*/
|
||||
static const I2C_Charac_t I2C_Charac[] =
|
||||
{
|
||||
[I2C_SPEED_FREQ_STANDARD] =
|
||||
{
|
||||
.freq = 100000,
|
||||
.freq_min = 80000,
|
||||
.freq_max = 120000,
|
||||
.hddat_min = 0,
|
||||
.vddat_max = 3450,
|
||||
.sudat_min = 250,
|
||||
.lscl_min = 4700,
|
||||
.hscl_min = 4000,
|
||||
.trise = 640,
|
||||
.tfall = 20,
|
||||
.dnf = I2C_DIGITAL_FILTER_COEF,
|
||||
},
|
||||
[I2C_SPEED_FREQ_FAST] =
|
||||
{
|
||||
.freq = 400000,
|
||||
.freq_min = 320000,
|
||||
.freq_max = 480000,
|
||||
.hddat_min = 0,
|
||||
.vddat_max = 900,
|
||||
.sudat_min = 100,
|
||||
.lscl_min = 1300,
|
||||
.hscl_min = 600,
|
||||
.trise = 250,
|
||||
.tfall = 100,
|
||||
.dnf = I2C_DIGITAL_FILTER_COEF,
|
||||
},
|
||||
[I2C_SPEED_FREQ_FAST_PLUS] =
|
||||
{
|
||||
.freq = 1000000,
|
||||
.freq_min = 800000,
|
||||
.freq_max = 1200000,
|
||||
.hddat_min = 0,
|
||||
.vddat_max = 450,
|
||||
.sudat_min = 50,
|
||||
.lscl_min = 500,
|
||||
.hscl_min = 260,
|
||||
.trise = 60,
|
||||
.tfall = 100,
|
||||
.dnf = I2C_DIGITAL_FILTER_COEF,
|
||||
},
|
||||
};
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H735G_DK_BUS_Exported_Variables Exported Variables
|
||||
* @{
|
||||
*/
|
||||
I2C_HandleTypeDef hbus_i2c4;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H735G_DK_BUS_Private_Variables Private Variables
|
||||
* @{
|
||||
*/
|
||||
#if (USE_HAL_I2C_REGISTER_CALLBACKS == 1)
|
||||
static uint32_t IsI2c4MspCbValid = 0;
|
||||
#endif /* USE_HAL_I2C_REGISTER_CALLBACKS */
|
||||
static uint32_t I2c4InitCounter = 0;
|
||||
static I2C_Timings_t I2c_valid_timing[I2C_VALID_TIMING_NBR];
|
||||
static uint32_t I2c_valid_timing_nbr = 0;
|
||||
#if defined(BSP_USE_CMSIS_OS)
|
||||
static osSemaphoreId BspI2cSemaphore = 0;
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H735G_DK_BUS_Private_FunctionPrototypes Private FunctionPrototypes
|
||||
* @{
|
||||
*/
|
||||
static void I2C4_MspInit(I2C_HandleTypeDef *phi2c);
|
||||
static void I2C4_MspDeInit(I2C_HandleTypeDef *phi2c);
|
||||
static int32_t I2C4_WriteReg(uint16_t DevAddr, uint16_t Reg, uint16_t MemAddSize, uint8_t *pData, uint16_t Length);
|
||||
static int32_t I2C4_ReadReg(uint16_t DevAddr, uint16_t Reg, uint16_t MemAddSize, uint8_t *pData, uint16_t Length);
|
||||
static uint32_t I2C_GetTiming(uint32_t clock_src_freq, uint32_t i2c_freq);
|
||||
static uint32_t I2C_Compute_SCLL_SCLH(uint32_t clock_src_freq, uint32_t I2C_speed);
|
||||
static void I2C_Compute_PRESC_SCLDEL_SDADEL(uint32_t clock_src_freq, uint32_t I2C_speed);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H735G_DK_BUS_Exported_Functions Exported Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Initializes I2C HAL.
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_I2C4_Init(void)
|
||||
{
|
||||
int32_t ret = BSP_ERROR_NONE;
|
||||
|
||||
hbus_i2c4.Instance = BUS_I2C4;
|
||||
|
||||
if (I2c4InitCounter++ == 0U)
|
||||
{
|
||||
if (HAL_I2C_GetState(&hbus_i2c4) == HAL_I2C_STATE_RESET)
|
||||
{
|
||||
#if defined(BSP_USE_CMSIS_OS)
|
||||
if (BspI2cSemaphore == NULL)
|
||||
{
|
||||
/* Create semaphore to prevent multiple I2C access */
|
||||
osSemaphoreDef(BSP_I2C_SEM);
|
||||
BspI2cSemaphore = osSemaphoreCreate(osSemaphore(BSP_I2C_SEM), 1);
|
||||
}
|
||||
#endif
|
||||
#if (USE_HAL_I2C_REGISTER_CALLBACKS == 0)
|
||||
/* Init the I2C4 Msp */
|
||||
I2C4_MspInit(&hbus_i2c4);
|
||||
#else
|
||||
if (IsI2c4MspCbValid == 0U)
|
||||
{
|
||||
if (BSP_I2C4_RegisterDefaultMspCallbacks() != BSP_ERROR_NONE)
|
||||
{
|
||||
ret = BSP_ERROR_MSP_FAILURE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (ret == BSP_ERROR_NONE)
|
||||
{
|
||||
if (MX_I2C4_Init(&hbus_i2c4, I2C_GetTiming(HAL_RCC_GetPCLK2Freq(), BUS_I2C4_FREQUENCY)) != HAL_OK)
|
||||
{
|
||||
ret = BSP_ERROR_BUS_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DeInitializes I2C HAL.
|
||||
* @retval None
|
||||
*/
|
||||
int32_t BSP_I2C4_DeInit(void)
|
||||
{
|
||||
int32_t ret = BSP_ERROR_NONE;
|
||||
|
||||
if (I2c4InitCounter > 0U)
|
||||
{
|
||||
if (--I2c4InitCounter == 0U)
|
||||
{
|
||||
#if (USE_HAL_I2C_REGISTER_CALLBACKS == 0)
|
||||
I2C4_MspDeInit(&hbus_i2c4);
|
||||
#endif /* (USE_HAL_I2C_REGISTER_CALLBACKS == 0) */
|
||||
|
||||
/* Init the I2C */
|
||||
if (HAL_I2C_DeInit(&hbus_i2c4) != HAL_OK)
|
||||
{
|
||||
ret = BSP_ERROR_BUS_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MX I2C4 initialization.
|
||||
* @param hI2c I2C handle
|
||||
* @param timing I2C timing
|
||||
* @retval HAL status
|
||||
*/
|
||||
__weak HAL_StatusTypeDef MX_I2C4_Init(I2C_HandleTypeDef *hI2c, uint32_t timing)
|
||||
{
|
||||
HAL_StatusTypeDef status = HAL_OK;
|
||||
|
||||
hI2c->Init.Timing = timing;
|
||||
hI2c->Init.OwnAddress1 = 0;
|
||||
hI2c->Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
|
||||
hI2c->Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
|
||||
hI2c->Init.OwnAddress2 = 0;
|
||||
hI2c->Init.OwnAddress2Masks = I2C_OA2_NOMASK;
|
||||
hI2c->Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
|
||||
hI2c->Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
|
||||
|
||||
if (HAL_I2C_Init(hI2c) != HAL_OK)
|
||||
{
|
||||
status = HAL_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t analog_filter;
|
||||
|
||||
analog_filter = (I2C_USE_ANALOG_FILTER == 1U) ? I2C_ANALOGFILTER_ENABLE : I2C_ANALOGFILTER_DISABLE;
|
||||
if (HAL_I2CEx_ConfigAnalogFilter(hI2c, analog_filter) != HAL_OK)
|
||||
{
|
||||
status = HAL_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (HAL_I2CEx_ConfigDigitalFilter(hI2c, I2C_DIGITAL_FILTER_COEF) != HAL_OK)
|
||||
{
|
||||
status = HAL_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Write a 8bit value in a register of the device through BUS.
|
||||
* @param DevAddr Device address on Bus.
|
||||
* @param Reg The target register address to write
|
||||
* @param pData The target register value to be written
|
||||
* @param Length buffer size to be written
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_I2C4_WriteReg(uint16_t DevAddr, uint16_t Reg, uint8_t *pData, uint16_t Length)
|
||||
{
|
||||
int32_t ret;
|
||||
#if defined(BSP_USE_CMSIS_OS)
|
||||
/* Get semaphore to prevent multiple I2C access */
|
||||
osSemaphoreWait(BspI2cSemaphore, osWaitForever);
|
||||
#endif
|
||||
if (I2C4_WriteReg(DevAddr, Reg, I2C_MEMADD_SIZE_8BIT, pData, Length) == 0)
|
||||
{
|
||||
ret = BSP_ERROR_NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (HAL_I2C_GetError(&hbus_i2c4) == HAL_I2C_ERROR_AF)
|
||||
{
|
||||
ret = BSP_ERROR_BUS_ACKNOWLEDGE_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
}
|
||||
#if defined(BSP_USE_CMSIS_OS)
|
||||
/* Release semaphore to prevent multiple I2C access */
|
||||
osSemaphoreRelease(BspI2cSemaphore);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read a 8bit register of the device through BUS
|
||||
* @param DevAddr Device address on BUS
|
||||
* @param Reg The target register address to read
|
||||
* @param pData Pointer to data buffer
|
||||
* @param Length Length of the data
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_I2C4_ReadReg(uint16_t DevAddr, uint16_t Reg, uint8_t *pData, uint16_t Length)
|
||||
{
|
||||
int32_t ret;
|
||||
#if defined(BSP_USE_CMSIS_OS)
|
||||
/* Get semaphore to prevent multiple I2C access */
|
||||
osSemaphoreWait(BspI2cSemaphore, osWaitForever);
|
||||
#endif
|
||||
if (I2C4_ReadReg(DevAddr, Reg, I2C_MEMADD_SIZE_8BIT, pData, Length) == 0)
|
||||
{
|
||||
ret = BSP_ERROR_NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (HAL_I2C_GetError(&hbus_i2c4) == HAL_I2C_ERROR_AF)
|
||||
{
|
||||
ret = BSP_ERROR_BUS_ACKNOWLEDGE_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
}
|
||||
#if defined(BSP_USE_CMSIS_OS)
|
||||
/* Release semaphore to prevent multiple I2C access */
|
||||
osSemaphoreRelease(BspI2cSemaphore);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Write a 16bit value in a register of the device through BUS.
|
||||
* @param DevAddr Device address on Bus.
|
||||
* @param Reg The target register address to write
|
||||
* @param pData The target register value to be written
|
||||
* @param Length buffer size to be written
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_I2C4_WriteReg16(uint16_t DevAddr, uint16_t Reg, uint8_t *pData, uint16_t Length)
|
||||
{
|
||||
int32_t ret;
|
||||
#if defined(BSP_USE_CMSIS_OS)
|
||||
/* Get semaphore to prevent multiple I2C access */
|
||||
osSemaphoreWait(BspI2cSemaphore, osWaitForever);
|
||||
#endif
|
||||
if (I2C4_WriteReg(DevAddr, Reg, I2C_MEMADD_SIZE_16BIT, pData, Length) == 0)
|
||||
{
|
||||
ret = BSP_ERROR_NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (HAL_I2C_GetError(&hbus_i2c4) == HAL_I2C_ERROR_AF)
|
||||
{
|
||||
ret = BSP_ERROR_BUS_ACKNOWLEDGE_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
}
|
||||
#if defined(BSP_USE_CMSIS_OS)
|
||||
/* Release semaphore to prevent multiple I2C access */
|
||||
osSemaphoreRelease(BspI2cSemaphore);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read a 16bit register of the device through BUS
|
||||
* @param DevAddr Device address on BUS
|
||||
* @param Reg The target register address to read
|
||||
* @param pData Pointer to data buffer
|
||||
* @param Length Length of the data
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_I2C4_ReadReg16(uint16_t DevAddr, uint16_t Reg, uint8_t *pData, uint16_t Length)
|
||||
{
|
||||
int32_t ret;
|
||||
#if defined(BSP_USE_CMSIS_OS)
|
||||
/* Get semaphore to prevent multiple I2C access */
|
||||
osSemaphoreWait(BspI2cSemaphore, osWaitForever);
|
||||
#endif
|
||||
if (I2C4_ReadReg(DevAddr, Reg, I2C_MEMADD_SIZE_16BIT, pData, Length) == 0)
|
||||
{
|
||||
ret = BSP_ERROR_NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (HAL_I2C_GetError(&hbus_i2c4) == HAL_I2C_ERROR_AF)
|
||||
{
|
||||
ret = BSP_ERROR_BUS_ACKNOWLEDGE_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
}
|
||||
#if defined(BSP_USE_CMSIS_OS)
|
||||
/* Release semaphore to prevent multiple I2C access */
|
||||
osSemaphoreRelease(BspI2cSemaphore);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Checks if target device is ready for communication.
|
||||
* @note This function is used with Memory devices
|
||||
* @param DevAddr Target device address
|
||||
* @param Trials Number of trials
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_I2C4_IsReady(uint16_t DevAddr, uint32_t Trials)
|
||||
{
|
||||
int32_t ret = BSP_ERROR_NONE;
|
||||
#if defined(BSP_USE_CMSIS_OS)
|
||||
/* Get semaphore to prevent multiple I2C access */
|
||||
osSemaphoreWait(BspI2cSemaphore, osWaitForever);
|
||||
#endif
|
||||
if (HAL_I2C_IsDeviceReady(&hbus_i2c4, DevAddr, Trials, 1000) != HAL_OK)
|
||||
{
|
||||
ret = BSP_ERROR_BUSY;
|
||||
}
|
||||
#if defined(BSP_USE_CMSIS_OS)
|
||||
/* Release semaphore to prevent multiple I2C access */
|
||||
osSemaphoreRelease(BspI2cSemaphore);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Delay function
|
||||
* @retval Tick value
|
||||
*/
|
||||
int32_t BSP_GetTick(void)
|
||||
{
|
||||
return (int32_t)HAL_GetTick();
|
||||
}
|
||||
|
||||
#if (USE_HAL_I2C_REGISTER_CALLBACKS == 1)
|
||||
/**
|
||||
* @brief Register Default I2C4 Bus Msp Callbacks
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_I2C4_RegisterDefaultMspCallbacks(void)
|
||||
{
|
||||
int32_t ret = BSP_ERROR_NONE;
|
||||
#if defined(BSP_USE_CMSIS_OS)
|
||||
/* Get semaphore to prevent multiple I2C access */
|
||||
osSemaphoreWait(BspI2cSemaphore, osWaitForever);
|
||||
#endif
|
||||
__HAL_I2C_RESET_HANDLE_STATE(&hbus_i2c4);
|
||||
|
||||
/* Register default MspInit/MspDeInit Callback */
|
||||
if (HAL_I2C_RegisterCallback(&hbus_i2c4, HAL_I2C_MSPINIT_CB_ID, I2C4_MspInit) != HAL_OK)
|
||||
{
|
||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
else if (HAL_I2C_RegisterCallback(&hbus_i2c4, HAL_I2C_MSPDEINIT_CB_ID, I2C4_MspDeInit) != HAL_OK)
|
||||
{
|
||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
IsI2c4MspCbValid = 1U;
|
||||
}
|
||||
#if defined(BSP_USE_CMSIS_OS)
|
||||
/* Release semaphore to prevent multiple I2C access */
|
||||
osSemaphoreRelease(BspI2cSemaphore);
|
||||
#endif
|
||||
/* BSP status */
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Register I2C4 Bus Msp Callback registering
|
||||
* @param Callbacks pointer to I2C4 MspInit/MspDeInit callback functions
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_I2C4_RegisterMspCallbacks(BSP_I2C_Cb_t *Callback)
|
||||
{
|
||||
int32_t ret = BSP_ERROR_NONE;
|
||||
#if defined(BSP_USE_CMSIS_OS)
|
||||
/* Get semaphore to prevent multiple I2C access */
|
||||
osSemaphoreWait(BspI2cSemaphore, osWaitForever);
|
||||
#endif
|
||||
__HAL_I2C_RESET_HANDLE_STATE(&hbus_i2c4);
|
||||
|
||||
/* Register MspInit/MspDeInit Callbacks */
|
||||
if (HAL_I2C_RegisterCallback(&hbus_i2c4, HAL_I2C_MSPINIT_CB_ID, Callback->pMspI2cInitCb) != HAL_OK)
|
||||
{
|
||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
else if (HAL_I2C_RegisterCallback(&hbus_i2c4, HAL_I2C_MSPDEINIT_CB_ID, Callback->pMspI2cDeInitCb) != HAL_OK)
|
||||
{
|
||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
IsI2c4MspCbValid = 1U;
|
||||
}
|
||||
#if defined(BSP_USE_CMSIS_OS)
|
||||
/* Release semaphore to prevent multiple I2C access */
|
||||
osSemaphoreRelease(BspI2cSemaphore);
|
||||
#endif
|
||||
/* BSP status */
|
||||
return ret;
|
||||
}
|
||||
#endif /* USE_HAL_I2C_REGISTER_CALLBACKS */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H735G_EVAL_BUS_Private_Functions Private Functions
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief Compute I2C timing according current I2C clock source and required I2C clock.
|
||||
* @param clock_src_freq I2C clock source in Hz.
|
||||
* @param i2c_freq Required I2C clock in Hz.
|
||||
* @retval I2C timing or 0 in case of error.
|
||||
*/
|
||||
static uint32_t I2C_GetTiming(uint32_t clock_src_freq, uint32_t i2c_freq)
|
||||
{
|
||||
uint32_t ret = 0;
|
||||
uint32_t speed;
|
||||
uint32_t idx;
|
||||
|
||||
if ((clock_src_freq != 0U) && (i2c_freq != 0U))
|
||||
{
|
||||
for (speed = 0 ; speed <= (uint32_t)I2C_SPEED_FREQ_FAST_PLUS ; speed++)
|
||||
{
|
||||
if ((i2c_freq >= I2C_Charac[speed].freq_min) &&
|
||||
(i2c_freq <= I2C_Charac[speed].freq_max))
|
||||
{
|
||||
I2C_Compute_PRESC_SCLDEL_SDADEL(clock_src_freq, speed);
|
||||
idx = I2C_Compute_SCLL_SCLH(clock_src_freq, speed);
|
||||
|
||||
if (idx < I2C_VALID_TIMING_NBR)
|
||||
{
|
||||
ret = ((I2c_valid_timing[idx].presc & 0x0FU) << 28) | \
|
||||
((I2c_valid_timing[idx].tscldel & 0x0FU) << 20) | \
|
||||
((I2c_valid_timing[idx].tsdadel & 0x0FU) << 16) | \
|
||||
((I2c_valid_timing[idx].sclh & 0xFFU) << 8) | \
|
||||
((I2c_valid_timing[idx].scll & 0xFFU) << 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Compute PRESC, SCLDEL and SDADEL.
|
||||
* @param clock_src_freq I2C source clock in HZ.
|
||||
* @param I2C_speed I2C frequency (index).
|
||||
* @retval None.
|
||||
*/
|
||||
static void I2C_Compute_PRESC_SCLDEL_SDADEL(uint32_t clock_src_freq, uint32_t I2C_speed)
|
||||
{
|
||||
uint32_t prev_presc = I2C_PRESC_MAX;
|
||||
uint32_t ti2cclk;
|
||||
int32_t tsdadel_min, tsdadel_max;
|
||||
int32_t tscldel_min;
|
||||
uint32_t presc, scldel, sdadel;
|
||||
uint32_t tafdel_min, tafdel_max;
|
||||
|
||||
ti2cclk = (SEC2NSEC + (clock_src_freq / 2U)) / clock_src_freq;
|
||||
|
||||
tafdel_min = (I2C_USE_ANALOG_FILTER == 1U) ? I2C_ANALOG_FILTER_DELAY_MIN : 0U;
|
||||
tafdel_max = (I2C_USE_ANALOG_FILTER == 1U) ? I2C_ANALOG_FILTER_DELAY_MAX : 0U;
|
||||
|
||||
/* tDNF = DNF x tI2CCLK
|
||||
tPRESC = (PRESC+1) x tI2CCLK
|
||||
SDADEL >= {tf +tHD;DAT(min) - tAF(min) - tDNF - [3 x tI2CCLK]} / {tPRESC}
|
||||
SDADEL <= {tVD;DAT(max) - tr - tAF(max) - tDNF- [4 x tI2CCLK]} / {tPRESC} */
|
||||
|
||||
tsdadel_min = (int32_t)I2C_Charac[I2C_speed].tfall + (int32_t)I2C_Charac[I2C_speed].hddat_min -
|
||||
(int32_t)tafdel_min - (int32_t)(((int32_t)I2C_Charac[I2C_speed].dnf + 3) * (int32_t)ti2cclk);
|
||||
|
||||
tsdadel_max = (int32_t)I2C_Charac[I2C_speed].vddat_max - (int32_t)I2C_Charac[I2C_speed].trise -
|
||||
(int32_t)tafdel_max - (int32_t)(((int32_t)I2C_Charac[I2C_speed].dnf + 4) * (int32_t)ti2cclk);
|
||||
|
||||
|
||||
/* {[tr+ tSU;DAT(min)] / [tPRESC]} - 1 <= SCLDEL */
|
||||
tscldel_min = (int32_t)I2C_Charac[I2C_speed].trise + (int32_t)I2C_Charac[I2C_speed].sudat_min;
|
||||
|
||||
if (tsdadel_min <= 0)
|
||||
{
|
||||
tsdadel_min = 0;
|
||||
}
|
||||
|
||||
if (tsdadel_max <= 0)
|
||||
{
|
||||
tsdadel_max = 0;
|
||||
}
|
||||
|
||||
for (presc = 0; presc < I2C_PRESC_MAX; presc++)
|
||||
{
|
||||
for (scldel = 0; scldel < I2C_SCLDEL_MAX; scldel++)
|
||||
{
|
||||
/* TSCLDEL = (SCLDEL+1) * (PRESC+1) * TI2CCLK */
|
||||
uint32_t tscldel = (scldel + 1U) * (presc + 1U) * ti2cclk;
|
||||
|
||||
if (tscldel >= (uint32_t)tscldel_min)
|
||||
{
|
||||
for (sdadel = 0; sdadel < I2C_SDADEL_MAX; sdadel++)
|
||||
{
|
||||
/* TSDADEL = SDADEL * (PRESC+1) * TI2CCLK */
|
||||
uint32_t tsdadel = (sdadel * (presc + 1U)) * ti2cclk;
|
||||
|
||||
if ((tsdadel >= (uint32_t)tsdadel_min) && (tsdadel <= (uint32_t)tsdadel_max))
|
||||
{
|
||||
if (presc != prev_presc)
|
||||
{
|
||||
I2c_valid_timing[I2c_valid_timing_nbr].presc = presc;
|
||||
I2c_valid_timing[I2c_valid_timing_nbr].tscldel = scldel;
|
||||
I2c_valid_timing[I2c_valid_timing_nbr].tsdadel = sdadel;
|
||||
prev_presc = presc;
|
||||
I2c_valid_timing_nbr ++;
|
||||
|
||||
if (I2c_valid_timing_nbr >= I2C_VALID_TIMING_NBR)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Calculate SCLL and SCLH and find best configuration.
|
||||
* @param clock_src_freq I2C source clock in HZ.
|
||||
* @param I2C_speed I2C frequency (index).
|
||||
* @retval config index (0 to I2C_VALID_TIMING_NBR], 0xFFFFFFFF for no valid config.
|
||||
*/
|
||||
static uint32_t I2C_Compute_SCLL_SCLH(uint32_t clock_src_freq, uint32_t I2C_speed)
|
||||
{
|
||||
uint32_t ret = 0xFFFFFFFFU;
|
||||
uint32_t ti2cclk;
|
||||
uint32_t ti2cspeed;
|
||||
uint32_t prev_error;
|
||||
uint32_t dnf_delay;
|
||||
uint32_t clk_min, clk_max;
|
||||
uint32_t scll, sclh;
|
||||
uint32_t tafdel_min;
|
||||
|
||||
ti2cclk = (SEC2NSEC + (clock_src_freq / 2U)) / clock_src_freq;
|
||||
ti2cspeed = (SEC2NSEC + (I2C_Charac[I2C_speed].freq / 2U)) / I2C_Charac[I2C_speed].freq;
|
||||
|
||||
tafdel_min = (I2C_USE_ANALOG_FILTER == 1U) ? I2C_ANALOG_FILTER_DELAY_MIN : 0U;
|
||||
|
||||
/* tDNF = DNF x tI2CCLK */
|
||||
dnf_delay = I2C_Charac[I2C_speed].dnf * ti2cclk;
|
||||
|
||||
clk_max = SEC2NSEC / I2C_Charac[I2C_speed].freq_min;
|
||||
clk_min = SEC2NSEC / I2C_Charac[I2C_speed].freq_max;
|
||||
|
||||
prev_error = ti2cspeed;
|
||||
|
||||
for (uint32_t count = 0; count < I2c_valid_timing_nbr; count++)
|
||||
{
|
||||
/* tPRESC = (PRESC+1) x tI2CCLK*/
|
||||
uint32_t tpresc = (I2c_valid_timing[count].presc + 1U) * ti2cclk;
|
||||
|
||||
for (scll = 0; scll < I2C_SCLL_MAX; scll++)
|
||||
{
|
||||
/* tLOW(min) <= tAF(min) + tDNF + 2 x tI2CCLK + [(SCLL+1) x tPRESC ] */
|
||||
uint32_t tscl_l = tafdel_min + dnf_delay + (2U * ti2cclk) + ((scll + 1U) * tpresc);
|
||||
|
||||
|
||||
/* The I2CCLK period tI2CCLK must respect the following conditions:
|
||||
tI2CCLK < (tLOW - tfilters) / 4 and tI2CCLK < tHIGH */
|
||||
if ((tscl_l > I2C_Charac[I2C_speed].lscl_min) && (ti2cclk < ((tscl_l - tafdel_min - dnf_delay) / 4U)))
|
||||
{
|
||||
for (sclh = 0; sclh < I2C_SCLH_MAX; sclh++)
|
||||
{
|
||||
/* tHIGH(min) <= tAF(min) + tDNF + 2 x tI2CCLK + [(SCLH+1) x tPRESC] */
|
||||
uint32_t tscl_h = tafdel_min + dnf_delay + (2U * ti2cclk) + ((sclh + 1U) * tpresc);
|
||||
|
||||
/* tSCL = tf + tLOW + tr + tHIGH */
|
||||
uint32_t tscl = tscl_l + tscl_h + I2C_Charac[I2C_speed].trise + I2C_Charac[I2C_speed].tfall;
|
||||
|
||||
if ((tscl >= clk_min) && (tscl <= clk_max) && (tscl_h >= I2C_Charac[I2C_speed].hscl_min) && (ti2cclk < tscl_h))
|
||||
{
|
||||
int32_t error = (int32_t)tscl - (int32_t)ti2cspeed;
|
||||
|
||||
if (error < 0)
|
||||
{
|
||||
error = -error;
|
||||
}
|
||||
|
||||
/* look for the timings with the lowest clock error */
|
||||
if ((uint32_t)error < prev_error)
|
||||
{
|
||||
prev_error = (uint32_t)error;
|
||||
I2c_valid_timing[count].scll = scll;
|
||||
I2c_valid_timing[count].sclh = sclh;
|
||||
ret = count;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initializes I2C MSP.
|
||||
* @param phi2c I2C handler
|
||||
* @retval None
|
||||
*/
|
||||
static void I2C4_MspInit(I2C_HandleTypeDef *phi2c)
|
||||
{
|
||||
GPIO_InitTypeDef gpio_init_structure;
|
||||
|
||||
/* Prevent unused argument(s) compilation warning */
|
||||
UNUSED(phi2c);
|
||||
|
||||
/*** Configure the GPIOs ***/
|
||||
/* Enable SCL GPIO clock */
|
||||
BUS_I2C4_SCL_GPIO_CLK_ENABLE();
|
||||
/* Enable SDA GPIO clock */
|
||||
BUS_I2C4_SDA_GPIO_CLK_ENABLE();
|
||||
|
||||
/* Configure I2C Tx as alternate function */
|
||||
gpio_init_structure.Pin = BUS_I2C4_SCL_PIN;
|
||||
gpio_init_structure.Mode = GPIO_MODE_AF_OD;
|
||||
gpio_init_structure.Pull = GPIO_PULLUP;
|
||||
gpio_init_structure.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
gpio_init_structure.Alternate = BUS_I2C4_SCL_AF;
|
||||
HAL_GPIO_Init(BUS_I2C4_SCL_GPIO_PORT, &gpio_init_structure);
|
||||
|
||||
/* Configure I2C Rx as alternate function */
|
||||
gpio_init_structure.Pin = BUS_I2C4_SDA_PIN;
|
||||
gpio_init_structure.Alternate = BUS_I2C4_SDA_AF;
|
||||
HAL_GPIO_Init(BUS_I2C4_SDA_GPIO_PORT, &gpio_init_structure);
|
||||
|
||||
/*** Configure the I2C peripheral ***/
|
||||
/* Enable I2C clock */
|
||||
BUS_I2C4_CLK_ENABLE();
|
||||
|
||||
/* Force the I2C peripheral clock reset */
|
||||
BUS_I2C4_FORCE_RESET();
|
||||
|
||||
/* Release the I2C peripheral clock reset */
|
||||
BUS_I2C4_RELEASE_RESET();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DeInitializes I2C MSP.
|
||||
* @param phi2c I2C handler
|
||||
* @retval None
|
||||
*/
|
||||
static void I2C4_MspDeInit(I2C_HandleTypeDef *phi2c)
|
||||
{
|
||||
GPIO_InitTypeDef gpio_init_structure;
|
||||
|
||||
/* Prevent unused argument(s) compilation warning */
|
||||
UNUSED(phi2c);
|
||||
|
||||
/* Configure I2C Tx, Rx as alternate function */
|
||||
gpio_init_structure.Pin = BUS_I2C4_SCL_PIN;
|
||||
HAL_GPIO_DeInit(BUS_I2C4_SCL_GPIO_PORT, gpio_init_structure.Pin);
|
||||
gpio_init_structure.Pin = BUS_I2C4_SDA_PIN;
|
||||
HAL_GPIO_DeInit(BUS_I2C4_SDA_GPIO_PORT, gpio_init_structure.Pin);
|
||||
|
||||
/* Disable I2C clock */
|
||||
BUS_I2C4_CLK_DISABLE();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Write a value in a register of the device through BUS.
|
||||
* @param Addr Device address on Bus.
|
||||
* @param MemAddSize Size of internal memory address
|
||||
* @param Reg The target register address to write
|
||||
* @param pData The target register value to be written
|
||||
* @param Length data length in bytes
|
||||
* @retval BSP status
|
||||
*/
|
||||
static int32_t I2C4_WriteReg(uint16_t DevAddr, uint16_t Reg, uint16_t MemAddSize, uint8_t *pData, uint16_t Length)
|
||||
{
|
||||
if (HAL_I2C_Mem_Write(&hbus_i2c4, DevAddr, Reg, MemAddSize, pData, Length, 1000) == HAL_OK)
|
||||
{
|
||||
return BSP_ERROR_NONE;
|
||||
}
|
||||
|
||||
return BSP_ERROR_BUS_FAILURE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read a register of the device through BUS
|
||||
* @param DevAddr Device address on BUS
|
||||
* @param MemAddSize Size of internal memory address
|
||||
* @param Reg The target register address to read
|
||||
* @retval BSP status
|
||||
*/
|
||||
static int32_t I2C4_ReadReg(uint16_t DevAddr, uint16_t Reg, uint16_t MemAddSize, uint8_t *pData, uint16_t Length)
|
||||
{
|
||||
if (HAL_I2C_Mem_Read(&hbus_i2c4, DevAddr, Reg, MemAddSize, pData, Length, 1000) == HAL_OK)
|
||||
{
|
||||
return BSP_ERROR_NONE;
|
||||
}
|
||||
|
||||
return BSP_ERROR_BUS_FAILURE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@@ -0,0 +1,139 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32h735g_discovery_bus.h
|
||||
* @author MCD Application Team
|
||||
* @brief This file contains definitions for STM32H735G_DK LEDs,
|
||||
* push-buttons hardware resources.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2019 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef STM32H735G_DK_BUS_H
|
||||
#define STM32H735G_DK_BUS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32h735g_discovery_conf.h"
|
||||
|
||||
#if defined(BSP_USE_CMSIS_OS)
|
||||
#include "cmsis_os.h"
|
||||
#endif
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32H735G_DK
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32H735G_DK_BUS
|
||||
* @{
|
||||
*/
|
||||
/** @defgroup STM32H735G_DK_BUS_Exported_Types Exported Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if (USE_HAL_I2C_REGISTER_CALLBACKS == 1)
|
||||
typedef struct
|
||||
{
|
||||
pI2C_CallbackTypeDef pMspI2cInitCb;
|
||||
pI2C_CallbackTypeDef pMspI2cDeInitCb;
|
||||
} BSP_I2C_Cb_t;
|
||||
#endif /* (USE_HAL_I2C_REGISTER_CALLBACKS == 1) */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H735G_DK_BUS_Exported_Constants Exported Constants
|
||||
* @{
|
||||
*/
|
||||
/* Definition for I2C4 clock resources */
|
||||
#define BUS_I2C4 I2C4
|
||||
#define BUS_I2C4_CLK_ENABLE() __HAL_RCC_I2C4_CLK_ENABLE()
|
||||
#define BUS_I2C4_CLK_DISABLE() __HAL_RCC_I2C4_CLK_DISABLE()
|
||||
#define BUS_I2C4_SCL_GPIO_CLK_ENABLE() __HAL_RCC_GPIOF_CLK_ENABLE()
|
||||
#define BUS_I2C4_SCL_GPIO_CLK_DISABLE() __HAL_RCC_GPIOF_CLK_DISABLE()
|
||||
#define BUS_I2C4_SDA_GPIO_CLK_ENABLE() __HAL_RCC_GPIOF_CLK_ENABLE()
|
||||
#define BUS_I2C4_SDA_GPIO_CLK_DISABLE() __HAL_RCC_GPIOF_CLK_DISABLE()
|
||||
|
||||
#define BUS_I2C4_FORCE_RESET() __HAL_RCC_I2C4_FORCE_RESET()
|
||||
#define BUS_I2C4_RELEASE_RESET() __HAL_RCC_I2C4_RELEASE_RESET()
|
||||
|
||||
/* Definition for I2C4 Pins */
|
||||
#define BUS_I2C4_SCL_PIN GPIO_PIN_14
|
||||
#define BUS_I2C4_SDA_PIN GPIO_PIN_15
|
||||
#define BUS_I2C4_SCL_GPIO_PORT GPIOF
|
||||
#define BUS_I2C4_SDA_GPIO_PORT GPIOF
|
||||
#define BUS_I2C4_SCL_AF GPIO_AF4_I2C4
|
||||
#define BUS_I2C4_SDA_AF GPIO_AF4_I2C4
|
||||
|
||||
#ifndef BUS_I2C4_FREQUENCY
|
||||
#define BUS_I2C4_FREQUENCY 100000U /* Frequency of I2Cn = 100 KHz*/
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32H735G_DK_BUS_Private_Variables
|
||||
* @{
|
||||
*/
|
||||
extern I2C_HandleTypeDef hbus_i2c4;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H735G_DK_BUS_Exported_FunctionsPrototypes Exported Functions Prototypes
|
||||
* @{
|
||||
*/
|
||||
int32_t BSP_I2C4_Init(void);
|
||||
int32_t BSP_I2C4_DeInit(void);
|
||||
int32_t BSP_I2C4_WriteReg(uint16_t DevAddr, uint16_t Reg, uint8_t *pData, uint16_t Length);
|
||||
int32_t BSP_I2C4_ReadReg(uint16_t DevAddr, uint16_t Reg, uint8_t *pData, uint16_t Length);
|
||||
int32_t BSP_I2C4_WriteReg16(uint16_t DevAddr, uint16_t Reg, uint8_t *pData, uint16_t Length);
|
||||
int32_t BSP_I2C4_ReadReg16(uint16_t DevAddr, uint16_t Reg, uint8_t *pData, uint16_t Length);
|
||||
int32_t BSP_I2C4_Recv(uint16_t DevAddr, uint16_t Reg, uint16_t MemAddSize, uint8_t *pData, uint16_t Length);
|
||||
int32_t BSP_I2C4_Send(uint16_t DevAddr, uint16_t Reg, uint16_t MemAddSize, uint8_t *pData, uint16_t Length);
|
||||
int32_t BSP_I2C4_IsReady(uint16_t DevAddr, uint32_t Trials);
|
||||
int32_t BSP_GetTick(void);
|
||||
#if (USE_HAL_I2C_REGISTER_CALLBACKS == 1)
|
||||
int32_t BSP_I2C4_RegisterDefaultMspCallbacks(void);
|
||||
int32_t BSP_I2C4_RegisterMspCallbacks(BSP_I2C_Cb_t *Callback);
|
||||
#endif /* USE_HAL_I2C_REGISTER_CALLBACKS */
|
||||
HAL_StatusTypeDef MX_I2C4_Init(I2C_HandleTypeDef *phi2c, uint32_t timing);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* STM32H735G_DK_BUS_H */
|
||||
@@ -0,0 +1,73 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32h735g_discovery_conf.h
|
||||
* @author MCD Application Team
|
||||
* @brief STM32H735G_DISCO board configuration file.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2019 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef STM32H735G_DK_CONF_H
|
||||
#define STM32H735G_DK_CONF_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32h7xx_hal.h"
|
||||
|
||||
/* COM define */
|
||||
#define USE_COM_LOG 0U
|
||||
#define USE_BSP_COM_FEATURE 0U
|
||||
|
||||
/* I2C BUS timing define */
|
||||
#define I2C_VALID_TIMING_NBR 128U
|
||||
|
||||
/* Audio codecs defines */
|
||||
#define USE_AUDIO_CODEC_WM8994 1U
|
||||
#define USE_BSP_PDM_LIB_FEATURE 1U
|
||||
|
||||
/* Default Audio IN internal buffer size */
|
||||
#define DEFAULT_AUDIO_IN_BUFFER_SIZE 2048U
|
||||
#define USE_BSP_CPU_CACHE_MAINTENANCE 1U
|
||||
|
||||
/* LCD defines */
|
||||
#define LCD_LAYER_0_ADDRESS 0x70000000U
|
||||
#define LCD_LAYER_1_ADDRESS 0x70200000U
|
||||
#define USE_DMA2D_TO_FILL_RGB_RECT 0U
|
||||
#define USE_LCD_CTRL_RK043FN48H 1U
|
||||
|
||||
/* TS defines */
|
||||
#define USE_TS_GESTURE 1U
|
||||
#define USE_TS_MULTI_TOUCH 1U
|
||||
#define TS_TOUCH_NBR 2U
|
||||
|
||||
/* OSPI RAM interrupt priority */
|
||||
#define BSP_OSPI_RAM_IT_PRIORITY 0x07UL
|
||||
#define BSP_OSPI_RAM_DMA_IT_PRIORITY 0x07UL
|
||||
|
||||
/* IRQ priorities */
|
||||
#define BSP_BUTTON_USER_IT_PRIORITY 15U
|
||||
#define BSP_AUDIO_OUT_IT_PRIORITY 14U
|
||||
#define BSP_AUDIO_IN_IT_PRIORITY 15U
|
||||
#define BSP_SD_IT_PRIORITY 14U
|
||||
#define BSP_SD_RX_IT_PRIORITY 14U
|
||||
#define BSP_SD_TX_IT_PRIORITY 15U
|
||||
#define BSP_TS_IT_PRIORITY 15U
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* STM32H735G_DK_CONF_H */
|
||||
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32h735g_discovery_errno.h
|
||||
* @author MCD Application Team
|
||||
* @brief Error Code.
|
||||
*
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2019 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef STM32H735G_DISCO_ERRNO_H
|
||||
#define STM32H735G_DISCO_ERRNO_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Common Error codes */
|
||||
#define BSP_ERROR_NONE 0
|
||||
#define BSP_ERROR_NO_INIT -1
|
||||
#define BSP_ERROR_WRONG_PARAM -2
|
||||
#define BSP_ERROR_BUSY -3
|
||||
#define BSP_ERROR_PERIPH_FAILURE -4
|
||||
#define BSP_ERROR_COMPONENT_FAILURE -5
|
||||
#define BSP_ERROR_UNKNOWN_FAILURE -6
|
||||
#define BSP_ERROR_UNKNOWN_COMPONENT -7
|
||||
#define BSP_ERROR_BUS_FAILURE -8
|
||||
#define BSP_ERROR_CLOCK_FAILURE -9
|
||||
#define BSP_ERROR_MSP_FAILURE -10
|
||||
#define BSP_ERROR_FEATURE_NOT_SUPPORTED -11
|
||||
|
||||
/* BSP OSPI error codes */
|
||||
#define BSP_ERROR_OSPI_SUSPENDED -20
|
||||
#define BSP_ERROR_OSPI_ASSIGN_FAILURE -24
|
||||
#define BSP_ERROR_OSPI_SETUP_FAILURE -25
|
||||
#define BSP_ERROR_OSPI_MMP_LOCK_FAILURE -26
|
||||
#define BSP_ERROR_OSPI_MMP_UNLOCK_FAILURE -27
|
||||
|
||||
/* BSP TS error code */
|
||||
#define BSP_ERROR_TS_TOUCH_NOT_DETECTED -30
|
||||
|
||||
/* BSP BUS error codes */
|
||||
#define BSP_ERROR_BUS_TRANSACTION_FAILURE -100
|
||||
#define BSP_ERROR_BUS_ARBITRATION_LOSS -101
|
||||
#define BSP_ERROR_BUS_ACKNOWLEDGE_FAILURE -102
|
||||
#define BSP_ERROR_BUS_PROTOCOL_FAILURE -103
|
||||
|
||||
#define BSP_ERROR_BUS_MODE_FAULT -104
|
||||
#define BSP_ERROR_BUS_FRAME_ERROR -105
|
||||
#define BSP_ERROR_BUS_CRC_ERROR -106
|
||||
#define BSP_ERROR_BUS_DMA_FAILURE -107
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* STM32H735G_DISCO_ERRNO_H */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,316 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32h735g_discovery_lcd.h
|
||||
* @author MCD Application Team
|
||||
* @brief This file contains the common defines and functions prototypes for
|
||||
* the stm32h735g_discovery_lcd.c driver.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2019 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef STM32H735G_DISCO_LCD_H
|
||||
#define STM32H735G_DISCO_LCD_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32h735g_discovery_conf.h"
|
||||
#include "stm32h735g_discovery_errno.h"
|
||||
|
||||
#include "lcd.h"
|
||||
|
||||
|
||||
#if (USE_LCD_CTRL_RK043FN48H == 1)
|
||||
/* Include RK043FN48H LCD Driver IC driver code */
|
||||
#include "../Components/rk043fn48h/rk043fn48h.h"
|
||||
#endif
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32H735G_DISCO
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32H735G_DISCO_LCD
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H735G_DISCO_LCD_Exported_Constants Exported Constants
|
||||
* @{
|
||||
*/
|
||||
#define LCD_INSTANCES_NBR 1U
|
||||
|
||||
#define LCD_ORIENTATION_LANDSCAPE 0x01U /* Landscape orientation choice of LCD screen */
|
||||
|
||||
#define LCD_DEFAULT_WIDTH 480U
|
||||
#define LCD_DEFAULT_HEIGHT 272U
|
||||
|
||||
#define BSP_LCD_RELOAD_NONE 0U /* No reload executed */
|
||||
#define BSP_LCD_RELOAD_IMMEDIATE LTDC_RELOAD_IMMEDIATE /* Immediate Reload */
|
||||
#define BSP_LCD_RELOAD_VERTICAL_BLANKING LTDC_RELOAD_VERTICAL_BLANKING /* Vertical Blanking Reload */
|
||||
/**
|
||||
* @brief LCD special pins
|
||||
*/
|
||||
/* LCD Display control pin */
|
||||
#define LCD_DISP_CTRL_PIN GPIO_PIN_10
|
||||
#define LCD_DISP_CTRL_PULL GPIO_NOPULL
|
||||
#define LCD_DISP_CTRL_GPIO_PORT GPIOD
|
||||
#define LCD_DISP_CTRL_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE()
|
||||
#define LCD_DISP_CTRL_GPIO_CLK_DISABLE() __HAL_RCC_GPIOD_CLK_DISABLE()
|
||||
|
||||
/* LCD Display enable pin */
|
||||
#define LCD_DISP_EN_PIN GPIO_PIN_13
|
||||
#define LCD_DISP_EN_PULL GPIO_NOPULL
|
||||
#define LCD_DISP_EN_GPIO_PORT GPIOE
|
||||
#define LCD_DISP_EN_GPIO_CLK_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE()
|
||||
#define LCD_DISP_EN_GPIO_CLK_DISABLE() __HAL_RCC_GPIOE_CLK_DISABLE()
|
||||
|
||||
/* Back-light control pin */
|
||||
#define LCD_BL_CTRL_PIN GPIO_PIN_15
|
||||
#define LCD_BL_CTRL_GPIO_PORT GPIOG
|
||||
#define LCD_BL_CTRL_GPIO_CLK_ENABLE() __HAL_RCC_GPIOG_CLK_ENABLE()
|
||||
#define LCD_BL_CTRL_GPIO_CLK_DISABLE() __HAL_RCC_GPIOG_CLK_DISABLE()
|
||||
|
||||
/* RGB565 colors definitions */
|
||||
#define LCD_COLOR_RGB565_BLUE 0x001FU
|
||||
#define LCD_COLOR_RGB565_GREEN 0x07E0U
|
||||
#define LCD_COLOR_RGB565_RED 0xF800U
|
||||
#define LCD_COLOR_RGB565_CYAN 0x07FFU
|
||||
#define LCD_COLOR_RGB565_MAGENTA 0xF81FU
|
||||
#define LCD_COLOR_RGB565_YELLOW 0xFFE0U
|
||||
#define LCD_COLOR_RGB565_LIGHTBLUE 0x841FU
|
||||
#define LCD_COLOR_RGB565_LIGHTGREEN 0x87F0U
|
||||
#define LCD_COLOR_RGB565_LIGHTRED 0xFC10U
|
||||
#define LCD_COLOR_RGB565_LIGHTCYAN 0x87FFU
|
||||
#define LCD_COLOR_RGB565_LIGHTMAGENTA 0xFC1FU
|
||||
#define LCD_COLOR_RGB565_LIGHTYELLOW 0xFFF0U
|
||||
#define LCD_COLOR_RGB565_DARKBLUE 0x0010U
|
||||
#define LCD_COLOR_RGB565_DARKGREEN 0x0400U
|
||||
#define LCD_COLOR_RGB565_DARKRED 0x8000U
|
||||
#define LCD_COLOR_RGB565_DARKCYAN 0x0410U
|
||||
#define LCD_COLOR_RGB565_DARKMAGENTA 0x8010U
|
||||
#define LCD_COLOR_RGB565_DARKYELLOW 0x8400U
|
||||
#define LCD_COLOR_RGB565_WHITE 0xFFFFU
|
||||
#define LCD_COLOR_RGB565_LIGHTGRAY 0xD69AU
|
||||
#define LCD_COLOR_RGB565_GRAY 0x8410U
|
||||
#define LCD_COLOR_RGB565_DARKGRAY 0x4208U
|
||||
#define LCD_COLOR_RGB565_BLACK 0x0000U
|
||||
#define LCD_COLOR_RGB565_BROWN 0xA145U
|
||||
#define LCD_COLOR_RGB565_ORANGE 0xFD20U
|
||||
/* Definition of Official ST COLOR */
|
||||
#define LCD_COLOR_RGB565_ST_BLUE_DARK 0x0001U
|
||||
#define LCD_COLOR_RGB565_ST_BLUE 0x01EBU
|
||||
#define LCD_COLOR_RGB565_ST_BLUE_LIGHT 0x06A7U
|
||||
#define LCD_COLOR_RGB565_ST_GREEN_LIGHT 0x05ECU
|
||||
#define LCD_COLOR_RGB565_ST_GREEN_DARK 0x001CU
|
||||
#define LCD_COLOR_RGB565_ST_YELLOW 0x07F0U
|
||||
#define LCD_COLOR_RGB565_ST_BROWN 0x02C8U
|
||||
#define LCD_COLOR_RGB565_ST_PINK 0x0681U
|
||||
#define LCD_COLOR_RGB565_ST_PURPLE 0x02CDU
|
||||
#define LCD_COLOR_RGB565_ST_GRAY_DARK 0x0251U
|
||||
#define LCD_COLOR_RGB565_ST_GRAY 0x04BAU
|
||||
#define LCD_COLOR_RGB565_ST_GRAY_LIGHT 0x05E7U
|
||||
|
||||
/* ARGB8888 colors definitions */
|
||||
#define LCD_COLOR_ARGB8888_BLUE 0xFF0000FFUL
|
||||
#define LCD_COLOR_ARGB8888_GREEN 0xFF00FF00UL
|
||||
#define LCD_COLOR_ARGB8888_RED 0xFFFF0000UL
|
||||
#define LCD_COLOR_ARGB8888_CYAN 0xFF00FFFFUL
|
||||
#define LCD_COLOR_ARGB8888_MAGENTA 0xFFFF00FFUL
|
||||
#define LCD_COLOR_ARGB8888_YELLOW 0xFFFFFF00UL
|
||||
#define LCD_COLOR_ARGB8888_LIGHTBLUE 0xFF8080FFUL
|
||||
#define LCD_COLOR_ARGB8888_LIGHTGREEN 0xFF80FF80UL
|
||||
#define LCD_COLOR_ARGB8888_LIGHTRED 0xFFFF8080UL
|
||||
#define LCD_COLOR_ARGB8888_LIGHTCYAN 0xFF80FFFFUL
|
||||
#define LCD_COLOR_ARGB8888_LIGHTMAGENTA 0xFFFF80FFUL
|
||||
#define LCD_COLOR_ARGB8888_LIGHTYELLOW 0xFFFFFF80UL
|
||||
#define LCD_COLOR_ARGB8888_DARKBLUE 0xFF000080UL
|
||||
#define LCD_COLOR_ARGB8888_DARKGREEN 0xFF008000UL
|
||||
#define LCD_COLOR_ARGB8888_DARKRED 0xFF800000UL
|
||||
#define LCD_COLOR_ARGB8888_DARKCYAN 0xFF008080UL
|
||||
#define LCD_COLOR_ARGB8888_DARKMAGENTA 0xFF800080UL
|
||||
#define LCD_COLOR_ARGB8888_DARKYELLOW 0xFF808000UL
|
||||
#define LCD_COLOR_ARGB8888_WHITE 0xFFFFFFFFUL
|
||||
#define LCD_COLOR_ARGB8888_LIGHTGRAY 0xFFD3D3D3UL
|
||||
#define LCD_COLOR_ARGB8888_GRAY 0xFF808080UL
|
||||
#define LCD_COLOR_ARGB8888_DARKGRAY 0xFF404040UL
|
||||
#define LCD_COLOR_ARGB8888_BLACK 0xFF000000UL
|
||||
#define LCD_COLOR_ARGB8888_BROWN 0xFFA52A2AUL
|
||||
#define LCD_COLOR_ARGB8888_ORANGE 0xFFFFA500UL
|
||||
/* Definition of Official ST Colors */
|
||||
#define LCD_COLOR_ARGB8888_ST_BLUE_DARK 0xFF002052UL
|
||||
#define LCD_COLOR_ARGB8888_ST_BLUE 0xFF39A9DCUL
|
||||
#define LCD_COLOR_ARGB8888_ST_BLUE_LIGHT 0xFFD1E4F3UL
|
||||
#define LCD_COLOR_ARGB8888_ST_GREEN_LIGHT 0xFFBBCC01UL
|
||||
#define LCD_COLOR_ARGB8888_ST_GREEN_DARK 0xFF003D14UL
|
||||
#define LCD_COLOR_ARGB8888_ST_YELLOW 0xFFFFD300UL
|
||||
#define LCD_COLOR_ARGB8888_ST_BROWN 0xFF5C0915UL
|
||||
#define LCD_COLOR_ARGB8888_ST_PINK 0xFFD4007AUL
|
||||
#define LCD_COLOR_ARGB8888_ST_PURPLE 0xFF590D58UL
|
||||
#define LCD_COLOR_ARGB8888_ST_GRAY_DARK 0xFF4F5251UL
|
||||
#define LCD_COLOR_ARGB8888_ST_GRAY 0xFF90989EUL
|
||||
#define LCD_COLOR_ARGB8888_ST_GRAY_LIGHT 0xFFB9C4CAUL
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H735G_DISCO_LCD_Exported_Variables Exported Variables
|
||||
* @{
|
||||
*/
|
||||
extern const LCD_UTILS_Drv_t LCD_Driver;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H735G_DISCO_LCD_Exported_Types Exported Types
|
||||
* @{
|
||||
*/
|
||||
typedef uint32_t(*ConvertColor_Func)(uint32_t);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t XSize;
|
||||
uint32_t YSize;
|
||||
uint32_t ActiveLayer;
|
||||
uint32_t PixelFormat;
|
||||
uint32_t IsMspCallbacksValid;
|
||||
uint32_t ReloadEnable;
|
||||
} BSP_LCD_Ctx_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t X0;
|
||||
uint32_t X1;
|
||||
uint32_t Y0;
|
||||
uint32_t Y1;
|
||||
uint32_t PixelFormat;
|
||||
uint32_t Address;
|
||||
} MX_LTDC_LayerConfig_t;
|
||||
|
||||
#define BSP_LCD_LayerConfig_t MX_LTDC_LayerConfig_t
|
||||
|
||||
|
||||
#if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1)
|
||||
typedef struct
|
||||
{
|
||||
pLTDC_CallbackTypeDef pMspLtdcInitCb;
|
||||
pLTDC_CallbackTypeDef pMspLtdcDeInitCb;
|
||||
} BSP_LCD_Cb_t;
|
||||
#endif /*(USE_HAL_LTDC_REGISTER_CALLBACKS == 1) */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32H735G_DISCO_LCD_Exported_Variables
|
||||
* @{
|
||||
*/
|
||||
extern DMA2D_HandleTypeDef hlcd_dma2d;
|
||||
extern LTDC_HandleTypeDef hlcd_ltdc;
|
||||
extern BSP_LCD_Ctx_t LcdCtx[];
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/** @addtogroup STM32H735G_DISCO_LCD_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
/* Initialization APIs */
|
||||
int32_t BSP_LCD_Init(uint32_t Instance, uint32_t Orientation);
|
||||
int32_t BSP_LCD_InitEx(uint32_t Instance, uint32_t Orientation, uint32_t PixelFormat, uint32_t Width, uint32_t Height);
|
||||
int32_t BSP_LCD_DeInit(uint32_t Instance);
|
||||
|
||||
/* Register Callbacks APIs */
|
||||
#if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1)
|
||||
int32_t BSP_LCD_RegisterDefaultMspCallbacks(uint32_t Instance);
|
||||
int32_t BSP_LCD_RegisterMspCallbacks(uint32_t Instance, BSP_LCD_Cb_t *CallBacks);
|
||||
#endif /*(USE_HAL_LTDC_REGISTER_CALLBACKS == 1) */
|
||||
|
||||
/* LCD specific APIs: Layer control & LCD HW reset */
|
||||
int32_t BSP_LCD_Relaod(uint32_t Instance, uint32_t ReloadType);
|
||||
int32_t BSP_LCD_ConfigLayer(uint32_t Instance, uint32_t LayerIndex, BSP_LCD_LayerConfig_t *Config);
|
||||
int32_t BSP_LCD_SetLayerVisible(uint32_t Instance, uint32_t LayerIndex, FunctionalState State);
|
||||
int32_t BSP_LCD_SetTransparency(uint32_t Instance, uint32_t LayerIndex, uint8_t Transparency);
|
||||
int32_t BSP_LCD_SetLayerAddress(uint32_t Instance, uint32_t LayerIndex, uint32_t Address);
|
||||
int32_t BSP_LCD_SetLayerWindow(uint32_t Instance, uint16_t LayerIndex, uint16_t Xpos, uint16_t Ypos, uint16_t Width,
|
||||
uint16_t Height);
|
||||
int32_t BSP_LCD_SetColorKeying(uint32_t Instance, uint32_t LayerIndex, uint32_t Color);
|
||||
int32_t BSP_LCD_ResetColorKeying(uint32_t Instance, uint32_t LayerIndex);
|
||||
void BSP_LCD_Reset(uint32_t Instance);
|
||||
|
||||
/* LCD generic APIs: Display control */
|
||||
int32_t BSP_LCD_DisplayOn(uint32_t Instance);
|
||||
int32_t BSP_LCD_DisplayOff(uint32_t Instance);
|
||||
int32_t BSP_LCD_SetBrightness(uint32_t Instance, uint32_t Brightness);
|
||||
int32_t BSP_LCD_GetBrightness(uint32_t Instance, uint32_t *Brightness);
|
||||
int32_t BSP_LCD_GetXSize(uint32_t Instance, uint32_t *XSize);
|
||||
int32_t BSP_LCD_GetYSize(uint32_t Instance, uint32_t *YSize);
|
||||
|
||||
/* LCD generic APIs: Draw operations. This list of APIs is required for
|
||||
lcd gfx utilities */
|
||||
int32_t BSP_LCD_SetActiveLayer(uint32_t Instance, uint32_t LayerIndex);
|
||||
int32_t BSP_LCD_GetPixelFormat(uint32_t Instance, uint32_t *PixelFormat);
|
||||
int32_t BSP_LCD_DrawBitmap(uint32_t Instance, uint32_t Xpos, uint32_t Ypos, uint8_t *pBmp);
|
||||
int32_t BSP_LCD_DrawHLine(uint32_t Instance, uint32_t Xpos, uint32_t Ypos, uint32_t Length, uint32_t Color);
|
||||
int32_t BSP_LCD_DrawVLine(uint32_t Instance, uint32_t Xpos, uint32_t Ypos, uint32_t Length, uint32_t Color);
|
||||
int32_t BSP_LCD_FillRGBRect(uint32_t Instance, uint32_t Xpos, uint32_t Ypos, uint8_t *pData, uint32_t Width,
|
||||
uint32_t Height);
|
||||
int32_t BSP_LCD_FillRect(uint32_t Instance, uint32_t Xpos, uint32_t Ypos, uint32_t Width, uint32_t Height,
|
||||
uint32_t Color);
|
||||
int32_t BSP_LCD_ReadPixel(uint32_t Instance, uint32_t Xpos, uint32_t Ypos, uint32_t *Color);
|
||||
int32_t BSP_LCD_WritePixel(uint32_t Instance, uint32_t Xpos, uint32_t Ypos, uint32_t Color);
|
||||
|
||||
/* LCD MX APIs */
|
||||
HAL_StatusTypeDef MX_LTDC_ConfigLayer(LTDC_HandleTypeDef *hltdc, uint32_t LayerIndex, MX_LTDC_LayerConfig_t *Config);
|
||||
HAL_StatusTypeDef MX_LTDC_ClockConfig(LTDC_HandleTypeDef *hltdc);
|
||||
HAL_StatusTypeDef MX_LTDC_Init(LTDC_HandleTypeDef *hltdc, uint32_t Width, uint32_t Height);
|
||||
HAL_StatusTypeDef MX_LTDC_ClockConfig2(LTDC_HandleTypeDef *hltdc);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Private constants --------------------------------------------------------*/
|
||||
/** @defgroup STM32H735G_DISCO_LCD_Private_Constants Private Constants
|
||||
* @{
|
||||
*/
|
||||
/* Legacy defines */
|
||||
#define LCD_ORIENTATION_PORTRAIT 0x00U /* Portrait orientation choice of LCD screen */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* STM32H735G_DISCO_LCD_H */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,395 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32h735g_discovery_ospi.h
|
||||
* @author MCD Application Team
|
||||
* @brief This file contains the common defines and functions prototypes for
|
||||
* the stm32h735g_discovery_ospi.c driver.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2019 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef STM32H735G_DK_OSPI_H
|
||||
#define STM32H735G_DK_OSPI_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32h735g_discovery_conf.h"
|
||||
#include "stm32h735g_discovery_errno.h"
|
||||
#include "../Components/mx25lm51245g/mx25lm51245g.h"
|
||||
#include "../Components/s70kl1281/s70kl1281.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32H735G_DK
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32H735G_DK_OSPI
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/** @defgroup STM32H735G_DK_OSPI_Exported_Types Exported Types
|
||||
* @{
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
OSPI_ACCESS_NONE = 0, /*!< Instance not initialized, */
|
||||
OSPI_ACCESS_INDIRECT, /*!< Instance use indirect mode access */
|
||||
OSPI_ACCESS_MMP /*!< Instance use Memory Mapped Mode read */
|
||||
} OSPI_Access_t;
|
||||
|
||||
#if (USE_HAL_OSPI_REGISTER_CALLBACKS == 1)
|
||||
typedef struct
|
||||
{
|
||||
pOSPI_CallbackTypeDef pMspInitCb;
|
||||
pOSPI_CallbackTypeDef pMspDeInitCb;
|
||||
} BSP_OSPI_Cb_t;
|
||||
#endif /* (USE_HAL_OSPI_REGISTER_CALLBACKS == 1) */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t MemorySize;
|
||||
uint32_t ClockPrescaler;
|
||||
uint32_t SampleShifting;
|
||||
uint32_t TransferRate;
|
||||
} MX_OSPI_InitTypeDef;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H735G_DK_OSPI_NOR_Exported_Types OSPI_NOR Exported Types
|
||||
* @{
|
||||
*/
|
||||
#define BSP_OSPI_NOR_Info_t MX25LM51245G_Info_t
|
||||
#define BSP_OSPI_NOR_Interface_t MX25LM51245G_Interface_t
|
||||
#define BSP_OSPI_NOR_Transfer_t MX25LM51245G_Transfer_t
|
||||
#define BSP_OSPI_NOR_Erase_t MX25LM51245G_Erase_t
|
||||
|
||||
typedef struct
|
||||
{
|
||||
OSPI_Access_t IsInitialized; /*!< Instance access Flash method */
|
||||
BSP_OSPI_NOR_Interface_t InterfaceMode; /*!< Flash Interface mode of Instance */
|
||||
BSP_OSPI_NOR_Transfer_t TransferRate; /*!< Flash Transfer mode of Instance */
|
||||
uint32_t IsMspCallbacksValid;
|
||||
} OSPI_NOR_Ctx_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
BSP_OSPI_NOR_Interface_t InterfaceMode; /*!< Current Flash Interface mode */
|
||||
BSP_OSPI_NOR_Transfer_t TransferRate; /*!< Current Flash Transfer rate */
|
||||
} BSP_OSPI_NOR_Init_t;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/** @defgroup STM32H735G_DK_OSPI_RAM_Exported_Types OSPI_RAM Exported Types
|
||||
* @{
|
||||
*/
|
||||
#define BSP_OSPI_RAM_BurstLength_t S70KL1281_BurstLength_t
|
||||
|
||||
typedef enum
|
||||
{
|
||||
BSP_OSPI_RAM_VARIABLE_LATENCY = HAL_OSPI_VARIABLE_LATENCY,
|
||||
BSP_OSPI_RAM_FIXED_LATENCY = HAL_OSPI_FIXED_LATENCY
|
||||
} BSP_OSPI_RAM_Latency_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
BSP_OSPI_RAM_HYBRID_BURST = 0,
|
||||
BSP_OSPI_RAM_LINEAR_BURST
|
||||
} BSP_OSPI_RAM_BurstType_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
OSPI_Access_t IsInitialized; /*!< Instance access Flash method */
|
||||
BSP_OSPI_RAM_Latency_t LatencyType; /*!< Latency Type of Instance */
|
||||
BSP_OSPI_RAM_BurstType_t BurstType; /*!< Burst Type of Instance */
|
||||
BSP_OSPI_RAM_BurstLength_t BurstLength; /*!< Burst Length of Instance */
|
||||
uint32_t IsMspCallbacksValid;
|
||||
} OSPI_RAM_Ctx_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
BSP_OSPI_RAM_Latency_t LatencyType; /*!< Current HyperRAM Latency Type */
|
||||
BSP_OSPI_RAM_BurstType_t BurstType; /*!< Current HyperRAM Burst Type */
|
||||
BSP_OSPI_RAM_BurstLength_t BurstLength; /*!< Current HyperRAM Burst Length */
|
||||
} BSP_OSPI_RAM_Init_t;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/** @defgroup STM32H735G_DK_OSPI_NOR_Exported_Constants OSPI_NOR Exported Constants
|
||||
* @{
|
||||
*/
|
||||
#define OSPI_NOR_INSTANCES_NUMBER 1U
|
||||
|
||||
/* Definition for OSPI modes */
|
||||
#define BSP_OSPI_NOR_SPI_MODE (BSP_OSPI_NOR_Interface_t)MX25LM51245G_SPI_MODE /* 1 Cmd Line, 1 Address Line and 1 Data Line */
|
||||
#define BSP_OSPI_NOR_OPI_MODE (BSP_OSPI_NOR_Interface_t)MX25LM51245G_OPI_MODE /* 8 Cmd Lines, 8 Address Lines and 8 Data Lines */
|
||||
|
||||
/* Definition for OSPI transfer rates */
|
||||
#define BSP_OSPI_NOR_STR_TRANSFER (BSP_OSPI_NOR_Transfer_t)MX25LM51245G_STR_TRANSFER /* Single Transfer Rate */
|
||||
#define BSP_OSPI_NOR_DTR_TRANSFER (BSP_OSPI_NOR_Transfer_t)MX25LM51245G_DTR_TRANSFER /* Double Transfer Rate */
|
||||
|
||||
/* OSPI erase types */
|
||||
#define BSP_OSPI_NOR_ERASE_4K MX25LM51245G_ERASE_4K
|
||||
#define BSP_OSPI_NOR_ERASE_64K MX25LM51245G_ERASE_64K
|
||||
#define BSP_OSPI_NOR_ERASE_CHIP MX25LM51245G_ERASE_BULK
|
||||
|
||||
/* OSPI block sizes */
|
||||
#define BSP_OSPI_NOR_BLOCK_4K MX25LM51245G_SUBSECTOR_4K
|
||||
#define BSP_OSPI_NOR_BLOCK_64K MX25LM51245G_SECTOR_64K
|
||||
|
||||
/* Definition for OSPI clock resources */
|
||||
#define OSPI_NOR_CLK_ENABLE() __HAL_RCC_OSPI1_CLK_ENABLE()
|
||||
#define OSPI_NOR_CLK_DISABLE() __HAL_RCC_OSPI1_CLK_DISABLE()
|
||||
|
||||
#define OSPI_NOR_FORCE_RESET() __HAL_RCC_OSPI1_FORCE_RESET()
|
||||
#define OSPI_NOR_RELEASE_RESET() __HAL_RCC_OSPI1_RELEASE_RESET()
|
||||
|
||||
/* Definition for OSPI NOR Pins */
|
||||
#define OSPI_NOR_CS_GPIO_CLK_ENABLE() __HAL_RCC_GPIOG_CLK_ENABLE()
|
||||
#define OSPI_NOR_CS_PIN GPIO_PIN_6
|
||||
#define OSPI_NOR_CS_GPIO_PORT GPIOG
|
||||
#define OSPI_NOR_CS_PIN_AF GPIO_AF10_OCTOSPIM_P1
|
||||
|
||||
#define OSPI_NOR_CLK_GPIO_CLK_ENABLE() __HAL_RCC_GPIOF_CLK_ENABLE()
|
||||
#define OSPI_NOR_CLK_PIN GPIO_PIN_10
|
||||
#define OSPI_NOR_CLK_GPIO_PORT GPIOF
|
||||
#define OSPI_NOR_CLK_PIN_AF GPIO_AF9_OCTOSPIM_P1
|
||||
|
||||
#define OSPI_NOR_DQS_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
|
||||
#define OSPI_NOR_DQS_PIN GPIO_PIN_2
|
||||
#define OSPI_NOR_DQS_GPIO_PORT GPIOB
|
||||
#define OSPI_NOR_DQS_PIN_AF GPIO_AF10_OCTOSPIM_P1
|
||||
|
||||
#define OSPI_NOR_D0_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE()
|
||||
#define OSPI_NOR_D0_PIN GPIO_PIN_11
|
||||
#define OSPI_NOR_D0_GPIO_PORT GPIOD
|
||||
#define OSPI_NOR_D0_PIN_AF GPIO_AF9_OCTOSPIM_P1
|
||||
|
||||
#define OSPI_NOR_D1_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE()
|
||||
#define OSPI_NOR_D1_PIN GPIO_PIN_12
|
||||
#define OSPI_NOR_D1_GPIO_PORT GPIOD
|
||||
#define OSPI_NOR_D1_PIN_AF GPIO_AF9_OCTOSPIM_P1
|
||||
|
||||
#define OSPI_NOR_D2_GPIO_CLK_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE()
|
||||
#define OSPI_NOR_D2_PIN GPIO_PIN_2
|
||||
#define OSPI_NOR_D2_GPIO_PORT GPIOE
|
||||
#define OSPI_NOR_D2_PIN_AF GPIO_AF9_OCTOSPIM_P1
|
||||
|
||||
#define OSPI_NOR_D3_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE()
|
||||
#define OSPI_NOR_D3_PIN GPIO_PIN_13
|
||||
#define OSPI_NOR_D3_GPIO_PORT GPIOD
|
||||
#define OSPI_NOR_D3_PIN_AF GPIO_AF9_OCTOSPIM_P1
|
||||
|
||||
#define OSPI_NOR_D4_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE()
|
||||
#define OSPI_NOR_D4_PIN GPIO_PIN_4
|
||||
#define OSPI_NOR_D4_GPIO_PORT GPIOD
|
||||
#define OSPI_NOR_D4_PIN_AF GPIO_AF10_OCTOSPIM_P1
|
||||
|
||||
#define OSPI_NOR_D5_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE()
|
||||
#define OSPI_NOR_D5_PIN GPIO_PIN_5
|
||||
#define OSPI_NOR_D5_GPIO_PORT GPIOD
|
||||
#define OSPI_NOR_D5_PIN_AF GPIO_AF10_OCTOSPIM_P1
|
||||
|
||||
#define OSPI_NOR_D6_GPIO_CLK_ENABLE() __HAL_RCC_GPIOG_CLK_ENABLE()
|
||||
#define OSPI_NOR_D6_PIN GPIO_PIN_9
|
||||
#define OSPI_NOR_D6_GPIO_PORT GPIOG
|
||||
#define OSPI_NOR_D6_PIN_AF GPIO_AF9_OCTOSPIM_P1
|
||||
|
||||
#define OSPI_NOR_D7_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE()
|
||||
#define OSPI_NOR_D7_PIN GPIO_PIN_7
|
||||
#define OSPI_NOR_D7_GPIO_PORT GPIOD
|
||||
#define OSPI_NOR_D7_PIN_AF GPIO_AF10_OCTOSPIM_P1
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/** @defgroup STM32H735G_DK_OSPI_RAM_Exported_Constants OSPI_RAM Exported Constants
|
||||
* @{
|
||||
*/
|
||||
#define OSPI_RAM_INSTANCES_NUMBER 1U
|
||||
|
||||
/* OSPI Burst length */
|
||||
#define BSP_OSPI_RAM_BURST_16_BYTES (BSP_OSPI_RAM_BurstLength_t)S70KL1281_BURST_16_BYTES
|
||||
#define BSP_OSPI_RAM_BURST_32_BYTES (BSP_OSPI_RAM_BurstLength_t)S70KL1281_BURST_32_BYTES
|
||||
#define BSP_OSPI_RAM_BURST_64_BYTES (BSP_OSPI_RAM_BurstLength_t)S70KL1281_BURST_64_BYTES
|
||||
#define BSP_OSPI_RAM_BURST_128_BYTES (BSP_OSPI_RAM_BurstLength_t)S70KL1281_BURST_128_BYTES
|
||||
|
||||
/* DMA definitions for OSPI RAM DMA transfer */
|
||||
#define OSPI_RAM_MDMAx_CLK_ENABLE __HAL_RCC_MDMA_CLK_ENABLE
|
||||
#define OSPI_RAM_MDMAx_CLK_DISABLE __HAL_RCC_MDMA_CLK_DISABLE
|
||||
#define OSPI_RAM_MDMAx_CHANNEL MDMA_Channel0
|
||||
#define OSPI_RAM_MDMAx_IRQn MDMA_IRQn
|
||||
#define OPSI_RAM_MDMA_IRQHandler MDMA_IRQHandler
|
||||
|
||||
/* Definition for OSPI clock resources */
|
||||
#define OSPI_RAM_CLK_ENABLE() __HAL_RCC_OSPI2_CLK_ENABLE()
|
||||
#define OSPI_RAM_CLK_DISABLE() __HAL_RCC_OSPI2_CLK_DISABLE()
|
||||
|
||||
#define OSPI_RAM_FORCE_RESET() __HAL_RCC_OSPI2_FORCE_RESET()
|
||||
#define OSPI_RAM_RELEASE_RESET() __HAL_RCC_OSPI2_RELEASE_RESET()
|
||||
|
||||
/* Definition for OSPI RAM Pins */
|
||||
#define OSPI_RAM_CS_GPIO_CLK_ENABLE() __HAL_RCC_GPIOG_CLK_ENABLE()
|
||||
#define OSPI_RAM_CS_PIN GPIO_PIN_12
|
||||
#define OSPI_RAM_CS_GPIO_PORT GPIOG
|
||||
#define OSPI_RAM_CS_PIN_AF GPIO_AF3_OCTOSPIM_P2
|
||||
|
||||
#define OSPI_RAM_CLK_GPIO_CLK_ENABLE() __HAL_RCC_GPIOF_CLK_ENABLE()
|
||||
#define OSPI_RAM_CLK_PIN GPIO_PIN_4
|
||||
#define OSPI_RAM_CLK_GPIO_PORT GPIOF
|
||||
#define OSPI_RAM_CLK_PIN_AF GPIO_AF9_OCTOSPIM_P2
|
||||
|
||||
#define OSPI_RAM_DQS_GPIO_CLK_ENABLE() __HAL_RCC_GPIOF_CLK_ENABLE()
|
||||
#define OSPI_RAM_DQS_PIN GPIO_PIN_12
|
||||
#define OSPI_RAM_DQS_GPIO_PORT GPIOF
|
||||
#define OSPI_RAM_DQS_PIN_AF GPIO_AF9_OCTOSPIM_P2
|
||||
|
||||
#define OSPI_RAM_D0_GPIO_CLK_ENABLE() __HAL_RCC_GPIOF_CLK_ENABLE()
|
||||
#define OSPI_RAM_D0_PIN GPIO_PIN_0
|
||||
#define OSPI_RAM_D0_GPIO_PORT GPIOF
|
||||
#define OSPI_RAM_D0_PIN_AF GPIO_AF9_OCTOSPIM_P2
|
||||
|
||||
#define OSPI_RAM_D1_GPIO_CLK_ENABLE() __HAL_RCC_GPIOF_CLK_ENABLE()
|
||||
#define OSPI_RAM_D1_PIN GPIO_PIN_1
|
||||
#define OSPI_RAM_D1_GPIO_PORT GPIOF
|
||||
#define OSPI_RAM_D1_PIN_AF GPIO_AF9_OCTOSPIM_P2
|
||||
|
||||
#define OSPI_RAM_D2_GPIO_CLK_ENABLE() __HAL_RCC_GPIOF_CLK_ENABLE()
|
||||
#define OSPI_RAM_D2_PIN GPIO_PIN_2
|
||||
#define OSPI_RAM_D2_GPIO_PORT GPIOF
|
||||
#define OSPI_RAM_D2_PIN_AF GPIO_AF9_OCTOSPIM_P2
|
||||
|
||||
#define OSPI_RAM_D3_GPIO_CLK_ENABLE() __HAL_RCC_GPIOF_CLK_ENABLE()
|
||||
#define OSPI_RAM_D3_PIN GPIO_PIN_3
|
||||
#define OSPI_RAM_D3_GPIO_PORT GPIOF
|
||||
#define OSPI_RAM_D3_PIN_AF GPIO_AF9_OCTOSPIM_P2
|
||||
|
||||
#define OSPI_RAM_D4_GPIO_CLK_ENABLE() __HAL_RCC_GPIOG_CLK_ENABLE()
|
||||
#define OSPI_RAM_D4_PIN GPIO_PIN_0
|
||||
#define OSPI_RAM_D4_GPIO_PORT GPIOG
|
||||
#define OSPI_RAM_D4_PIN_AF GPIO_AF9_OCTOSPIM_P2
|
||||
|
||||
#define OSPI_RAM_D5_GPIO_CLK_ENABLE() __HAL_RCC_GPIOG_CLK_ENABLE()
|
||||
#define OSPI_RAM_D5_PIN GPIO_PIN_1
|
||||
#define OSPI_RAM_D5_GPIO_PORT GPIOG
|
||||
#define OSPI_RAM_D5_PIN_AF GPIO_AF9_OCTOSPIM_P2
|
||||
|
||||
#define OSPI_RAM_D6_GPIO_CLK_ENABLE() __HAL_RCC_GPIOG_CLK_ENABLE()
|
||||
#define OSPI_RAM_D6_PIN GPIO_PIN_10
|
||||
#define OSPI_RAM_D6_GPIO_PORT GPIOG
|
||||
#define OSPI_RAM_D6_PIN_AF GPIO_AF3_OCTOSPIM_P2
|
||||
|
||||
#define OSPI_RAM_D7_GPIO_CLK_ENABLE() __HAL_RCC_GPIOG_CLK_ENABLE()
|
||||
#define OSPI_RAM_D7_PIN GPIO_PIN_11
|
||||
#define OSPI_RAM_D7_GPIO_PORT GPIOG
|
||||
#define OSPI_RAM_D7_PIN_AF GPIO_AF9_OCTOSPIM_P2
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported variables --------------------------------------------------------*/
|
||||
/** @addtogroup STM32H735G_DK_OSPI_NOR_Exported_Variables NOR Exported Variables
|
||||
* @{
|
||||
*/
|
||||
extern OSPI_HandleTypeDef hospi_nor[];
|
||||
extern OSPI_NOR_Ctx_t OSPINORCtx[];
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/** @defgroup STM32H735G_DK_OSPI_NOR_Exported_Functions NOR Exported Functions
|
||||
* @{
|
||||
*/
|
||||
int32_t BSP_OSPI_NOR_Init(uint32_t Instance, BSP_OSPI_NOR_Init_t *Init);
|
||||
int32_t BSP_OSPI_NOR_DeInit(uint32_t Instance);
|
||||
#if (USE_HAL_OSPI_REGISTER_CALLBACKS == 1)
|
||||
int32_t BSP_OSPI_NOR_RegisterMspCallbacks(uint32_t Instance, BSP_OSPI_Cb_t *CallBacks);
|
||||
int32_t BSP_OSPI_NOR_RegisterDefaultMspCallbacks(uint32_t Instance);
|
||||
#endif /* (USE_HAL_OSPI_REGISTER_CALLBACKS == 1) */
|
||||
int32_t BSP_OSPI_NOR_Read(uint32_t Instance, uint8_t *pData, uint32_t ReadAddr, uint32_t Size);
|
||||
int32_t BSP_OSPI_NOR_Write(uint32_t Instance, uint8_t *pData, uint32_t WriteAddr, uint32_t Size);
|
||||
int32_t BSP_OSPI_NOR_Erase_Block(uint32_t Instance, uint32_t BlockAddress, BSP_OSPI_NOR_Erase_t BlockSize);
|
||||
int32_t BSP_OSPI_NOR_Erase_Chip(uint32_t Instance);
|
||||
int32_t BSP_OSPI_NOR_GetStatus(uint32_t Instance);
|
||||
int32_t BSP_OSPI_NOR_GetInfo(uint32_t Instance, BSP_OSPI_NOR_Info_t *pInfo);
|
||||
int32_t BSP_OSPI_NOR_EnableMemoryMappedMode(uint32_t Instance);
|
||||
int32_t BSP_OSPI_NOR_DisableMemoryMappedMode(uint32_t Instance);
|
||||
int32_t BSP_OSPI_NOR_ReadID(uint32_t Instance, uint8_t *Id);
|
||||
int32_t BSP_OSPI_NOR_ConfigFlash(uint32_t Instance, BSP_OSPI_NOR_Interface_t Mode, BSP_OSPI_NOR_Transfer_t Rate);
|
||||
int32_t BSP_OSPI_NOR_SuspendErase(uint32_t Instance);
|
||||
int32_t BSP_OSPI_NOR_ResumeErase(uint32_t Instance);
|
||||
|
||||
/* These functions can be modified in case the current settings
|
||||
need to be changed for specific application needs */
|
||||
HAL_StatusTypeDef MX_OSPI_NOR_Init(OSPI_HandleTypeDef *hospi, MX_OSPI_InitTypeDef *Config);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/** @defgroup STM32H735G_DK_OSPI_RAM_Exported_FunctionsPrototypes OSPI_RAM Exported Functions Prototypes
|
||||
* @{
|
||||
*/
|
||||
int32_t BSP_OSPI_RAM_Init(uint32_t Instance, BSP_OSPI_RAM_Init_t *Init);
|
||||
int32_t BSP_OSPI_RAM_DeInit(uint32_t Instance);
|
||||
#if (USE_HAL_OSPI_REGISTER_CALLBACKS == 1)
|
||||
int32_t BSP_OSPI_RAM_RegisterMspCallbacks(uint32_t Instance, BSP_OSPI_Cb_t *CallBacks);
|
||||
int32_t BSP_OSPI_RAM_RegisterDefaultMspCallbacks(uint32_t Instance);
|
||||
#endif /* (USE_HAL_OSPI_REGISTER_CALLBACKS == 1) */
|
||||
int32_t BSP_OSPI_RAM_Read(uint32_t Instance, uint8_t *pData, uint32_t ReadAddr, uint32_t Size);
|
||||
int32_t BSP_OSPI_RAM_Read_DMA(uint32_t Instance, uint8_t *pData, uint32_t ReadAddr, uint32_t Size);
|
||||
int32_t BSP_OSPI_RAM_Write(uint32_t Instance, uint8_t *pData, uint32_t WriteAddr, uint32_t Size);
|
||||
int32_t BSP_OSPI_RAM_Write_DMA(uint32_t Instance, uint8_t *pData, uint32_t WriteAddr, uint32_t Size);
|
||||
int32_t BSP_OSPI_RAM_EnableMemoryMappedMode(uint32_t Instance);
|
||||
int32_t BSP_OSPI_RAM_DisableMemoryMappedMode(uint32_t Instance);
|
||||
int32_t BSP_OSPI_RAM_ConfigHyperRAM(uint32_t Instance, BSP_OSPI_RAM_Latency_t Latency,
|
||||
BSP_OSPI_RAM_BurstType_t BurstType, BSP_OSPI_RAM_BurstLength_t BurstLength);
|
||||
|
||||
void BSP_OSPI_RAM_DMA_IRQHandler(uint32_t Instance);
|
||||
void BSP_OSPI_RAM_IRQHandler(uint32_t Instance);
|
||||
|
||||
/* These functions can be modified in case the current settings
|
||||
need to be changed for specific application needs */
|
||||
HAL_StatusTypeDef MX_OSPI_RAM_Init(OSPI_HandleTypeDef *hospi, MX_OSPI_InitTypeDef *Init);
|
||||
HAL_StatusTypeDef MX_OSPI_ClockConfig(OSPI_HandleTypeDef *hospi);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* STM32H735G_DK_OSPI_H */
|
||||
@@ -0,0 +1,888 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32h735g_discovery_sd.c
|
||||
* @author MCD Application Team
|
||||
* @brief This file includes the uSD card driver mounted on STM32H735G_DK
|
||||
* boards.
|
||||
@verbatim
|
||||
How To use this driver:
|
||||
-----------------------
|
||||
- This driver is used to drive the micro SD external cards mounted on STM32H735G_DK
|
||||
board.
|
||||
- This driver does not need a specific component driver for the micro SD device
|
||||
to be included with.
|
||||
|
||||
Driver description:
|
||||
------------------
|
||||
+ Initialization steps:
|
||||
o Initialize the micro SD card using the BSP_SD_Init() function. This
|
||||
function includes the MSP layer hardware resources initialization and the
|
||||
SDIO interface configuration to interface with the external micro SD. It
|
||||
also includes the micro SD initialization sequence.
|
||||
|
||||
o To check the SD card presence you can use the function BSP_SD_IsDetected() which
|
||||
returns the detection status.
|
||||
|
||||
o If SD presence detection interrupt mode is desired, you must configure the
|
||||
SD detection interrupt mode by calling the function BSP_SD_DetectITConfig().
|
||||
The interrupt is generated as an external interrupt whenever the micro SD card is
|
||||
plugged/unplugged in/from the evaluation board.
|
||||
The SD detection interrupt is handled by calling the function BSP_SD_DetectIT()
|
||||
which is called in the IRQ handler file, the user callback is implemented in
|
||||
the function BSP_SD_DetectCallback().
|
||||
|
||||
o The function BSP_SD_GetCardInfo()are used to get the micro SD card information
|
||||
which is stored in the structure "HAL_SD_CardInfoTypedef".
|
||||
|
||||
+ Micro SD card operations
|
||||
o The micro SD card can be accessed with read/write block(s) operations once
|
||||
it is ready for access. The access can be performed whether
|
||||
using the polling mode by calling the functions BSP_SD_ReadBlocks()/BSP_SD_WriteBlocks(),
|
||||
using the interrupt mode by calling the functions BSP_SD_ReadBlocks_IT()/BSP_SD_WriteBlocks_IT(),
|
||||
or by DMA transfer using the functions BSP_SD_ReadBlocks_DMA()/BSP_SD_WriteBlocks_DMA().
|
||||
o The DMA transfer complete is used with interrupt mode. Once the SD transfer
|
||||
is complete, the SD interrupt is handled using the function BSP_SDMMC1_IRQHandler()
|
||||
The DMA Tx/Rx transfer complete are handled using the functions
|
||||
SD_SDMMC1_DMA_Tx_IRQHandler(), SD_SDMMC1_DMA_Rx_IRQHandler().The corresponding
|
||||
user callbacks are implemented by the user at application level.
|
||||
o The SD erase block(s) is performed using the functions BSP_SD_Erase() with specifying
|
||||
the number of blocks to erase.
|
||||
o The SD runtime status is returned when calling the function BSP_SD_GetCardState().
|
||||
|
||||
@endverbatim
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2019 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32h735g_discovery_sd.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32H735G_DK
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H735G_DK_SD SD
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup STM32H735G_DK_SD_Private_TypesDefinitions Private TypesDefinitions
|
||||
* @{
|
||||
*/
|
||||
#if (USE_HAL_SD_REGISTER_CALLBACKS == 1)
|
||||
/* Is Msp Callbacks registered */
|
||||
static uint32_t IsMspCallbacksValid[SD_INSTANCES_NBR] = {0};
|
||||
#endif
|
||||
typedef void (* BSP_EXTI_LineCallback)(void);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H735G_DK_SD_Private_Variables Private Variables
|
||||
* @{
|
||||
*/
|
||||
static uint32_t PinDetect[SD_INSTANCES_NBR] = {SD_DETECT_PIN};
|
||||
static GPIO_TypeDef *SD_GPIO_PORT[SD_INSTANCES_NBR] = {SD_DETECT_GPIO_PORT};
|
||||
static IRQn_Type SD_EXTI_IRQn[SD_INSTANCES_NBR] = {SD_DETECT_EXTI_IRQn};
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H735G_DK_SD_Exported_Variables Exported Variables
|
||||
* @{
|
||||
*/
|
||||
SD_HandleTypeDef hsd_sdmmc[SD_INSTANCES_NBR];
|
||||
EXTI_HandleTypeDef hsd_exti[SD_INSTANCES_NBR];
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H735G_DK_SD_Private_Functions_Prototypes Private Functions Prototypes
|
||||
* @{
|
||||
*/
|
||||
static void SD_MspInit(SD_HandleTypeDef *hsd);
|
||||
static void SD_MspDeInit(SD_HandleTypeDef *hsd);
|
||||
#if (USE_HAL_SD_REGISTER_CALLBACKS == 1)
|
||||
static void SD_AbortCallback(SD_HandleTypeDef *hsd);
|
||||
static void SD_TxCpltCallback(SD_HandleTypeDef *hsd);
|
||||
static void SD_RxCpltCallback(SD_HandleTypeDef *hsd);
|
||||
#endif /* (USE_HAL_SD_REGISTER_CALLBACKS == 1) */
|
||||
static void SD_EXTI_Callback(void);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addgroup STM32H735G_DK_SD_Exported_Functions Exported Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Initializes the SD card device.
|
||||
* @param Instance SD Instance
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_SD_Init(uint32_t Instance)
|
||||
{
|
||||
int32_t ret = BSP_ERROR_NONE;
|
||||
GPIO_InitTypeDef gpio_init_structure;
|
||||
|
||||
if (Instance >= SD_INSTANCES_NBR)
|
||||
{
|
||||
ret = BSP_ERROR_WRONG_PARAM;
|
||||
}
|
||||
else
|
||||
{
|
||||
SD_DETECT_GPIO_CLK_ENABLE();
|
||||
|
||||
/* Configure Interrupt mode for SD detection pin */
|
||||
gpio_init_structure.Pin = PinDetect[Instance];
|
||||
gpio_init_structure.Pull = GPIO_PULLUP;
|
||||
gpio_init_structure.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
gpio_init_structure.Mode = GPIO_MODE_INPUT;
|
||||
HAL_GPIO_Init(SD_GPIO_PORT[Instance], &gpio_init_structure);
|
||||
|
||||
/* Check if SD card is present */
|
||||
if ((uint32_t)BSP_SD_IsDetected(Instance) != SD_PRESENT)
|
||||
{
|
||||
ret = BSP_ERROR_UNKNOWN_COMPONENT;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if (USE_HAL_SD_REGISTER_CALLBACKS == 0)
|
||||
/* Msp SD initialization */
|
||||
SD_MspInit(&hsd_sdmmc[Instance]);
|
||||
#else
|
||||
/* Register the SD MSP Callbacks */
|
||||
if (IsMspCallbacksValid[Instance] == 0UL)
|
||||
{
|
||||
if (BSP_SD_RegisterDefaultMspCallbacks(Instance) != BSP_ERROR_NONE)
|
||||
{
|
||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
}
|
||||
#endif /* USE_HAL_SD_REGISTER_CALLBACKS */
|
||||
if (ret == BSP_ERROR_NONE)
|
||||
{
|
||||
/* HAL SD initialization and Enable wide operation */
|
||||
if (MX_SDMMC1_SD_Init(&hsd_sdmmc[Instance]) != HAL_OK)
|
||||
{
|
||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
else if (HAL_SD_ConfigWideBusOperation(&hsd_sdmmc[Instance], SDMMC_BUS_WIDE_4B) != HAL_OK)
|
||||
{
|
||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Switch to High Speed mode if the card support this mode */
|
||||
(void)HAL_SD_ConfigSpeedBusOperation(&hsd_sdmmc[Instance], SDMMC_SPEED_MODE_HIGH);
|
||||
|
||||
#if (USE_HAL_SD_REGISTER_CALLBACKS == 1)
|
||||
/* Register SD TC, HT and Abort callbacks */
|
||||
if (HAL_SD_RegisterCallback(&hsd_sdmmc[Instance], HAL_SD_TX_CPLT_CB_ID, SD_TxCpltCallback) != HAL_OK)
|
||||
{
|
||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
else if (HAL_SD_RegisterCallback(&hsd_sdmmc[Instance], HAL_SD_RX_CPLT_CB_ID, SD_RxCpltCallback) != HAL_OK)
|
||||
{
|
||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (HAL_SD_RegisterCallback(&hsd_sdmmc[Instance], HAL_SD_ABORT_CB_ID, SD_AbortCallback) != HAL_OK)
|
||||
{
|
||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
}
|
||||
#endif /* USE_HAL_SD_REGISTER_CALLBACKS */
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DeInitializes the SD card device.
|
||||
* @param Instance SD Instance
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_SD_DeInit(uint32_t Instance)
|
||||
{
|
||||
int32_t ret = BSP_ERROR_NONE;
|
||||
|
||||
if (Instance >= SD_INSTANCES_NBR)
|
||||
{
|
||||
ret = BSP_ERROR_WRONG_PARAM;
|
||||
}
|
||||
else if (HAL_SD_DeInit(&hsd_sdmmc[Instance]) != HAL_OK) /* HAL SD de-initialization */
|
||||
{
|
||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Msp SD de-initialization */
|
||||
#if (USE_HAL_SD_REGISTER_CALLBACKS == 0)
|
||||
SD_MspDeInit(&hsd_sdmmc[Instance]);
|
||||
#endif /* (USE_HAL_SD_REGISTER_CALLBACKS == 0) */
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initializes the SDMMC1 peripheral.
|
||||
* @param hsd SD handle
|
||||
* @retval HAL status
|
||||
*/
|
||||
__weak HAL_StatusTypeDef MX_SDMMC1_SD_Init(SD_HandleTypeDef *hsd)
|
||||
{
|
||||
HAL_StatusTypeDef ret = HAL_OK;
|
||||
/* uSD device interface configuration */
|
||||
hsd->Instance = SDMMC1;
|
||||
hsd->Init.ClockEdge = SDMMC_CLOCK_EDGE_RISING;
|
||||
hsd->Init.ClockPowerSave = SDMMC_CLOCK_POWER_SAVE_DISABLE;
|
||||
hsd->Init.BusWide = SDMMC_BUS_WIDE_1B;
|
||||
hsd->Init.HardwareFlowControl = SDMMC_HARDWARE_FLOW_CONTROL_DISABLE;
|
||||
hsd->Init.ClockDiv = SDMMC_NSpeed_CLK_DIV;
|
||||
/* HAL SD initialization */
|
||||
if (HAL_SD_Init(hsd) != HAL_OK)
|
||||
{
|
||||
ret = HAL_ERROR;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
#if (USE_HAL_SD_REGISTER_CALLBACKS == 1)
|
||||
/**
|
||||
* @brief Default BSP SD Msp Callbacks
|
||||
* @param Instance SD Instance
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_SD_RegisterDefaultMspCallbacks(uint32_t Instance)
|
||||
{
|
||||
int32_t ret = BSP_ERROR_NONE;
|
||||
|
||||
if (Instance >= SD_INSTANCES_NBR)
|
||||
{
|
||||
ret = BSP_ERROR_WRONG_PARAM;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Register MspInit/MspDeInit Callbacks */
|
||||
if (HAL_SD_RegisterCallback(&hsd_sdmmc[Instance], HAL_SD_MSP_INIT_CB_ID, SD_MspInit) != HAL_OK)
|
||||
{
|
||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
else if (HAL_SD_RegisterCallback(&hsd_sdmmc[Instance], HAL_SD_MSP_DEINIT_CB_ID, SD_MspDeInit) != HAL_OK)
|
||||
{
|
||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
IsMspCallbacksValid[Instance] = 1U;
|
||||
}
|
||||
}
|
||||
/* Return BSP status */
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief BSP SD Msp Callback registering
|
||||
* @param Instance SD Instance
|
||||
* @param CallBacks pointer to MspInit/MspDeInit callbacks functions
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_SD_RegisterMspCallbacks(uint32_t Instance, BSP_SD_Cb_t *CallBacks)
|
||||
{
|
||||
int32_t ret = BSP_ERROR_NONE;
|
||||
|
||||
if (Instance >= SD_INSTANCES_NBR)
|
||||
{
|
||||
ret = BSP_ERROR_WRONG_PARAM;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Register MspInit/MspDeInit Callbacks */
|
||||
if (HAL_SD_RegisterCallback(&hsd_sdmmc[Instance], HAL_SD_MSP_INIT_CB_ID, CallBacks->pMspInitCb) != HAL_OK)
|
||||
{
|
||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
else if (HAL_SD_RegisterCallback(&hsd_sdmmc[Instance], HAL_SD_MSP_DEINIT_CB_ID, CallBacks->pMspDeInitCb) != HAL_OK)
|
||||
{
|
||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
IsMspCallbacksValid[Instance] = 1U;
|
||||
}
|
||||
}
|
||||
|
||||
/* Return BSP status */
|
||||
return ret;
|
||||
}
|
||||
#endif /* (USE_HAL_SD_REGISTER_CALLBACKS == 1) */
|
||||
|
||||
/**
|
||||
* @brief Configures Interrupt mode for SD detection pin.
|
||||
* @param Instance SD Instance
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_SD_DetectITConfig(uint32_t Instance)
|
||||
{
|
||||
int32_t ret;
|
||||
GPIO_InitTypeDef gpio_init_structure;
|
||||
const uint32_t SD_EXTI_LINE[SD_INSTANCES_NBR] = {SD_DETECT_EXTI_LINE};
|
||||
static BSP_EXTI_LineCallback SdCallback[SD_INSTANCES_NBR] = {SD_EXTI_Callback};
|
||||
if (Instance >= SD_INSTANCES_NBR)
|
||||
{
|
||||
ret = BSP_ERROR_WRONG_PARAM;
|
||||
}
|
||||
else
|
||||
{
|
||||
SD_DETECT_GPIO_CLK_ENABLE();
|
||||
/* Configure Interrupt mode for SD detection pin */
|
||||
gpio_init_structure.Pin = PinDetect[Instance];
|
||||
gpio_init_structure.Pull = GPIO_PULLUP;
|
||||
gpio_init_structure.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||
gpio_init_structure.Mode = GPIO_MODE_IT_RISING_FALLING;
|
||||
HAL_GPIO_Init(SD_GPIO_PORT[Instance], &gpio_init_structure);
|
||||
|
||||
if (HAL_EXTI_GetHandle(&hsd_exti[Instance], SD_EXTI_LINE[Instance]) != HAL_OK)
|
||||
{
|
||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
else if (HAL_EXTI_RegisterCallback(&hsd_exti[Instance], HAL_EXTI_COMMON_CB_ID, SdCallback[Instance]) != HAL_OK)
|
||||
{
|
||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Enable and set Button EXTI Interrupt to the lowest priority */
|
||||
HAL_NVIC_SetPriority(SD_EXTI_IRQn[Instance], BSP_SD_IT_PRIORITY, 0x00);
|
||||
HAL_NVIC_EnableIRQ(SD_EXTI_IRQn[Instance]);
|
||||
ret = BSP_ERROR_NONE;
|
||||
}
|
||||
}
|
||||
/* Return BSP status */
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief BSP SD Callback.
|
||||
* @param Instance SD Instance
|
||||
* @param Status Pin status
|
||||
* @retval None.
|
||||
*/
|
||||
__weak void BSP_SD_DetectCallback(uint32_t Instance, uint32_t Status)
|
||||
{
|
||||
/* Prevent unused argument(s) compilation warning */
|
||||
UNUSED(Instance);
|
||||
UNUSED(Status);
|
||||
|
||||
/* This function should be implemented by the user application.
|
||||
It is called into this driver when an event on JoyPin is triggered. */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Detects if SD card is correctly plugged in the memory slot or not.
|
||||
* @param Instance SD Instance
|
||||
* @retval Returns if SD is detected or not
|
||||
*/
|
||||
int32_t BSP_SD_IsDetected(uint32_t Instance)
|
||||
{
|
||||
int32_t ret;
|
||||
if (Instance >= SD_INSTANCES_NBR)
|
||||
{
|
||||
ret = BSP_ERROR_WRONG_PARAM;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Check SD card detect pin */
|
||||
if (HAL_GPIO_ReadPin(SD_GPIO_PORT[Instance], PinDetect[Instance]) == GPIO_PIN_SET)
|
||||
{
|
||||
ret = SD_NOT_PRESENT;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = SD_PRESENT;
|
||||
}
|
||||
}
|
||||
|
||||
return (int32_t)ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reads block(s) from a specified address in an SD card, in polling mode.
|
||||
* @param Instance SD Instance
|
||||
* @param pData Pointer to the buffer that will contain the data to transmit
|
||||
* @param BlockIdx Block index from where data is to be read
|
||||
* @param BlocksNbr Number of SD blocks to read
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_SD_ReadBlocks(uint32_t Instance, uint32_t *pData, uint32_t BlockIdx, uint32_t BlocksNbr)
|
||||
{
|
||||
uint32_t timeout = SD_READ_TIMEOUT * BlocksNbr;
|
||||
int32_t ret;
|
||||
|
||||
if (Instance >= SD_INSTANCES_NBR)
|
||||
{
|
||||
ret = BSP_ERROR_WRONG_PARAM;
|
||||
}
|
||||
else if (HAL_SD_ReadBlocks(&hsd_sdmmc[Instance], (uint8_t *)pData, BlockIdx, BlocksNbr, timeout) != HAL_OK)
|
||||
{
|
||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = BSP_ERROR_NONE;
|
||||
}
|
||||
/* Return BSP status */
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Writes block(s) to a specified address in an SD card, in polling mode.
|
||||
* @param Instance SD Instance
|
||||
* @param pData Pointer to the buffer that will contain the data to transmit
|
||||
* @param BlockIdx Block index from where data is to be written
|
||||
* @param BlocksNbr Number of SD blocks to write
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_SD_WriteBlocks(uint32_t Instance, uint32_t *pData, uint32_t BlockIdx, uint32_t BlocksNbr)
|
||||
{
|
||||
uint32_t timeout = SD_WRITE_TIMEOUT * BlocksNbr;
|
||||
int32_t ret;
|
||||
|
||||
if (Instance >= SD_INSTANCES_NBR)
|
||||
{
|
||||
ret = BSP_ERROR_WRONG_PARAM;
|
||||
}
|
||||
else if (HAL_SD_WriteBlocks(&hsd_sdmmc[Instance], (uint8_t *)pData, BlockIdx, BlocksNbr, timeout) != HAL_OK)
|
||||
{
|
||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = BSP_ERROR_NONE;
|
||||
}
|
||||
/* Return BSP status */
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reads block(s) from a specified address in an SD card, in DMA mode.
|
||||
* @param Instance SD Instance
|
||||
* @param pData Pointer to the buffer that will contain the data to transmit
|
||||
* @param BlockIdx Block index from where data is to be read
|
||||
* @param BlocksNbr Number of SD blocks to read
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_SD_ReadBlocks_DMA(uint32_t Instance, uint32_t *pData, uint32_t BlockIdx, uint32_t BlocksNbr)
|
||||
{
|
||||
int32_t ret;
|
||||
|
||||
if (Instance >= SD_INSTANCES_NBR)
|
||||
{
|
||||
ret = BSP_ERROR_WRONG_PARAM;
|
||||
}
|
||||
else if (HAL_SD_ReadBlocks_DMA(&hsd_sdmmc[Instance], (uint8_t *)pData, BlockIdx, BlocksNbr) != HAL_OK)
|
||||
{
|
||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = BSP_ERROR_NONE;
|
||||
}
|
||||
/* Return BSP status */
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Writes block(s) to a specified address in an SD card, in DMA mode.
|
||||
* @param Instance SD Instance
|
||||
* @param pData Pointer to the buffer that will contain the data to transmit
|
||||
* @param BlockIdx Block index from where data is to be written
|
||||
* @param BlocksNbr Number of SD blocks to write
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_SD_WriteBlocks_DMA(uint32_t Instance, uint32_t *pData, uint32_t BlockIdx, uint32_t BlocksNbr)
|
||||
{
|
||||
int32_t ret;
|
||||
|
||||
if (Instance >= SD_INSTANCES_NBR)
|
||||
{
|
||||
ret = BSP_ERROR_WRONG_PARAM;
|
||||
}
|
||||
else if (HAL_SD_WriteBlocks_DMA(&hsd_sdmmc[Instance], (uint8_t *)pData, BlockIdx, BlocksNbr) != HAL_OK)
|
||||
{
|
||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = BSP_ERROR_NONE;
|
||||
}
|
||||
/* Return BSP status */
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reads block(s) from a specified address in an SD card, in DMA mode.
|
||||
* @param Instance SD Instance
|
||||
* @param pData Pointer to the buffer that will contain the data to transmit
|
||||
* @param BlockIdx Block index from where data is to be read
|
||||
* @param BlocksNbr Number of SD blocks to read
|
||||
* @retval SD status
|
||||
*/
|
||||
int32_t BSP_SD_ReadBlocks_IT(uint32_t Instance, uint32_t *pData, uint32_t BlockIdx, uint32_t BlocksNbr)
|
||||
{
|
||||
int32_t ret;
|
||||
|
||||
if (Instance >= SD_INSTANCES_NBR)
|
||||
{
|
||||
ret = BSP_ERROR_WRONG_PARAM;
|
||||
}
|
||||
else if (HAL_SD_ReadBlocks_IT(&hsd_sdmmc[Instance], (uint8_t *)pData, BlockIdx, BlocksNbr) != HAL_OK)
|
||||
{
|
||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = BSP_ERROR_NONE;
|
||||
}
|
||||
/* Return BSP status */
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Writes block(s) to a specified address in an SD card, in DMA mode.
|
||||
* @param Instance SD Instance
|
||||
* @param pData Pointer to the buffer that will contain the data to transmit
|
||||
* @param BlockIdx Block index from where data is to be written
|
||||
* @param BlocksNbr Number of SD blocks to write
|
||||
* @retval SD status
|
||||
*/
|
||||
int32_t BSP_SD_WriteBlocks_IT(uint32_t Instance, uint32_t *pData, uint32_t BlockIdx, uint32_t BlocksNbr)
|
||||
{
|
||||
int32_t ret;
|
||||
|
||||
if (Instance >= SD_INSTANCES_NBR)
|
||||
{
|
||||
ret = BSP_ERROR_WRONG_PARAM;
|
||||
}
|
||||
else if (HAL_SD_WriteBlocks_IT(&hsd_sdmmc[Instance], (uint8_t *)pData, BlockIdx, BlocksNbr) != HAL_OK)
|
||||
{
|
||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = BSP_ERROR_NONE;
|
||||
}
|
||||
/* Return BSP status */
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Erases the specified memory area of the given SD card.
|
||||
* @param Instance SD Instance
|
||||
* @param BlockIdx Block index from where data is to be
|
||||
* @param BlocksNbr Number of SD blocks to erase
|
||||
* @retval SD status
|
||||
*/
|
||||
int32_t BSP_SD_Erase(uint32_t Instance, uint32_t BlockIdx, uint32_t BlocksNbr)
|
||||
{
|
||||
int32_t ret;
|
||||
|
||||
if (Instance >= SD_INSTANCES_NBR)
|
||||
{
|
||||
ret = BSP_ERROR_WRONG_PARAM;
|
||||
}
|
||||
else if (HAL_SD_Erase(&hsd_sdmmc[Instance], BlockIdx, BlockIdx + BlocksNbr) != HAL_OK)
|
||||
{
|
||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = BSP_ERROR_NONE;
|
||||
}
|
||||
/* Return BSP status */
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the current SD card data status.
|
||||
* @param Instance SD Instance
|
||||
* @retval Data transfer state.
|
||||
* This value can be one of the following values:
|
||||
* @arg SD_TRANSFER_OK: No data transfer is acting
|
||||
* @arg SD_TRANSFER_BUSY: Data transfer is acting
|
||||
*/
|
||||
int32_t BSP_SD_GetCardState(uint32_t Instance)
|
||||
{
|
||||
return (int32_t)((HAL_SD_GetCardState(&hsd_sdmmc[Instance]) == HAL_SD_CARD_TRANSFER) ? SD_TRANSFER_OK : SD_TRANSFER_BUSY);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get SD information about specific SD card.
|
||||
* @param Instance SD Instance
|
||||
* @param CardInfo Pointer to HAL_SD_CardInfoTypedef structure
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_SD_GetCardInfo(uint32_t Instance, BSP_SD_CardInfo *CardInfo)
|
||||
{
|
||||
int32_t ret;
|
||||
|
||||
if (Instance >= SD_INSTANCES_NBR)
|
||||
{
|
||||
ret = BSP_ERROR_WRONG_PARAM;
|
||||
}
|
||||
else if (HAL_SD_GetCardInfo(&hsd_sdmmc[Instance], CardInfo) != HAL_OK)
|
||||
{
|
||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = BSP_ERROR_NONE;
|
||||
}
|
||||
/* Return BSP status */
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles SD interrupt request.
|
||||
* @param Instance SD Instance
|
||||
* @retval None
|
||||
*/
|
||||
void BSP_SD_DETECT_IRQHandler(uint32_t Instance)
|
||||
{
|
||||
HAL_EXTI_IRQHandler(&hsd_exti[Instance]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles SDMMC interrupt requests.
|
||||
* @param Instance SD Instance
|
||||
* @retval None
|
||||
*/
|
||||
void BSP_SD_IRQHandler(uint32_t Instance)
|
||||
{
|
||||
HAL_SD_IRQHandler(&hsd_sdmmc[Instance]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H735G_DK_SD_Private_Functions Private Functions
|
||||
* @{
|
||||
*/
|
||||
#if (USE_HAL_SD_REGISTER_CALLBACKS == 1)
|
||||
/**
|
||||
* @brief SD Abort callbacks
|
||||
* @param hsd SD handle
|
||||
* @retval None
|
||||
*/
|
||||
static void SD_AbortCallback(SD_HandleTypeDef *hsd)
|
||||
{
|
||||
BSP_SD_AbortCallback((hsd == &hsd_sdmmc[0]) ? 0UL : 1UL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Tx Transfer completed callbacks
|
||||
* @param hsd SD handle
|
||||
* @retval None
|
||||
*/
|
||||
static void SD_TxCpltCallback(SD_HandleTypeDef *hsd)
|
||||
{
|
||||
BSP_SD_WriteCpltCallback((hsd == &hsd_sdmmc[0]) ? 0UL : 1UL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Rx Transfer completed callbacks
|
||||
* @param hsd SD handle
|
||||
* @retval None
|
||||
*/
|
||||
static void SD_RxCpltCallback(SD_HandleTypeDef *hsd)
|
||||
{
|
||||
BSP_SD_ReadCpltCallback((hsd == &hsd_sdmmc[0]) ? 0UL : 1UL);
|
||||
}
|
||||
#else
|
||||
/**
|
||||
* @brief SD Abort callbacks
|
||||
* @param hsd SD handle
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_SD_AbortCallback(SD_HandleTypeDef *hsd)
|
||||
{
|
||||
BSP_SD_AbortCallback((hsd == &hsd_sdmmc[0]) ? 0UL : 1UL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Tx Transfer completed callbacks
|
||||
* @param hsd SD handle
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_SD_TxCpltCallback(SD_HandleTypeDef *hsd)
|
||||
{
|
||||
BSP_SD_WriteCpltCallback((hsd == &hsd_sdmmc[0]) ? 0UL : 1UL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Rx Transfer completed callbacks
|
||||
* @param hsd SD handle
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_SD_RxCpltCallback(SD_HandleTypeDef *hsd)
|
||||
{
|
||||
BSP_SD_ReadCpltCallback((hsd == &hsd_sdmmc[0]) ? 0UL : 1UL);
|
||||
}
|
||||
#endif /* (USE_HAL_SD_REGISTER_CALLBACKS == 1) */
|
||||
|
||||
/**
|
||||
* @brief BSP SD Abort callbacks
|
||||
* @param Instance SD Instance
|
||||
* @retval None
|
||||
*/
|
||||
__weak void BSP_SD_AbortCallback(uint32_t Instance)
|
||||
{
|
||||
/* Prevent unused argument(s) compilation warning */
|
||||
UNUSED(Instance);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief BSP Tx Transfer completed callbacks
|
||||
* @param Instance SD Instance
|
||||
* @retval None
|
||||
*/
|
||||
__weak void BSP_SD_WriteCpltCallback(uint32_t Instance)
|
||||
{
|
||||
/* Prevent unused argument(s) compilation warning */
|
||||
UNUSED(Instance);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief BSP Rx Transfer completed callbacks
|
||||
* @param Instance SD Instance
|
||||
* @retval None
|
||||
*/
|
||||
__weak void BSP_SD_ReadCpltCallback(uint32_t Instance)
|
||||
{
|
||||
/* Prevent unused argument(s) compilation warning */
|
||||
UNUSED(Instance);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SD EXTI line detection callbacks.
|
||||
* @retval None
|
||||
*/
|
||||
static void SD_EXTI_Callback(void)
|
||||
{
|
||||
uint32_t sd_status = SD_PRESENT;
|
||||
/* Check SD card detect pin */
|
||||
if (HAL_GPIO_ReadPin(SD_GPIO_PORT[0], PinDetect[0]) == GPIO_PIN_SET)
|
||||
{
|
||||
sd_status = SD_NOT_PRESENT;
|
||||
}
|
||||
else
|
||||
{
|
||||
sd_status = SD_PRESENT;
|
||||
}
|
||||
BSP_SD_DetectCallback(0, sd_status);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initializes the SD MSP.
|
||||
* @param hsd SD handle
|
||||
* @retval None
|
||||
*/
|
||||
static void SD_MspInit(SD_HandleTypeDef *hsd)
|
||||
{
|
||||
GPIO_InitTypeDef gpio_init_structure;
|
||||
|
||||
UNUSED(hsd);
|
||||
|
||||
/* Enable SDIO clock */
|
||||
__HAL_RCC_SDMMC1_CLK_ENABLE();
|
||||
/* Enable GPIOs clock */
|
||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOD_CLK_ENABLE();
|
||||
|
||||
/* Common GPIO configuration */
|
||||
gpio_init_structure.Mode = GPIO_MODE_AF_PP;
|
||||
gpio_init_structure.Pull = GPIO_PULLUP;
|
||||
gpio_init_structure.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||
|
||||
/* GPIOC configuration*/
|
||||
gpio_init_structure.Alternate = GPIO_AF12_SDMMC1;
|
||||
gpio_init_structure.Pin = GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12;
|
||||
HAL_GPIO_Init(GPIOC, &gpio_init_structure);
|
||||
|
||||
/* GPIOD configuration*/
|
||||
gpio_init_structure.Alternate = GPIO_AF12_SDMMC1;
|
||||
gpio_init_structure.Pin = GPIO_PIN_2;
|
||||
HAL_GPIO_Init(GPIOD, &gpio_init_structure);
|
||||
|
||||
/* NVIC configuration for SDIO interrupts */
|
||||
HAL_NVIC_SetPriority(SDMMC1_IRQn, BSP_SD_IT_PRIORITY, 0);
|
||||
HAL_NVIC_EnableIRQ(SDMMC1_IRQn);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DeInitializes the SD MSP.
|
||||
* @param hsd SD handle
|
||||
* @retval None
|
||||
*/
|
||||
static void SD_MspDeInit(SD_HandleTypeDef *hsd)
|
||||
{
|
||||
GPIO_InitTypeDef gpio_init_structure;
|
||||
|
||||
if (hsd == &hsd_sdmmc[0])
|
||||
{
|
||||
/* Disable NVIC for SDIO interrupts */
|
||||
HAL_NVIC_DisableIRQ(SDMMC1_IRQn);
|
||||
/* GPIOC configuration */
|
||||
gpio_init_structure.Pin = GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12;
|
||||
HAL_GPIO_DeInit(GPIOC, gpio_init_structure.Pin);
|
||||
|
||||
/* GPIOD configuration */
|
||||
gpio_init_structure.Pin = GPIO_PIN_2;
|
||||
HAL_GPIO_DeInit(GPIOD, gpio_init_structure.Pin);
|
||||
/* Disable SDMMC1 clock */
|
||||
__HAL_RCC_SDMMC1_CLK_DISABLE();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@@ -0,0 +1,175 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32h735g_discovery_sd.h
|
||||
* @author MCD Application Team
|
||||
* @brief This file contains the common defines and functions prototypes for
|
||||
* the stm32h735g_discovery_sd.c driver.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2019 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef STM32H735G_DK_SD_H
|
||||
#define STM32H735G_DK_SD_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32h735g_discovery_conf.h"
|
||||
#include "stm32h735g_discovery_errno.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32H735G_DK
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32H735G_DK_SD
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H735G_DK_SD_Exported_Types Exported Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief SD Card information structure
|
||||
*/
|
||||
#define BSP_SD_CardInfo HAL_SD_CardInfoTypeDef
|
||||
|
||||
#if (USE_HAL_SD_REGISTER_CALLBACKS == 1)
|
||||
typedef struct
|
||||
{
|
||||
pSD_CallbackTypeDef pMspInitCb;
|
||||
pSD_CallbackTypeDef pMspDeInitCb;
|
||||
} BSP_SD_Cb_t;
|
||||
#endif /* (USE_HAL_SD_REGISTER_CALLBACKS == 1) */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H735G_DK_SD_Exported_Constants Exported Constants
|
||||
* @{
|
||||
*/
|
||||
#define SD_INSTANCES_NBR 1UL
|
||||
|
||||
#ifndef SD_WRITE_TIMEOUT
|
||||
#define SD_WRITE_TIMEOUT 500U
|
||||
#endif
|
||||
|
||||
#ifndef SD_READ_TIMEOUT
|
||||
#define SD_READ_TIMEOUT 100U
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief SD transfer state definition
|
||||
*/
|
||||
#define SD_TRANSFER_OK 0U
|
||||
#define SD_TRANSFER_BUSY 1U
|
||||
|
||||
/**
|
||||
* @brief SD-detect signal
|
||||
*/
|
||||
#define SD_PRESENT 1UL
|
||||
#define SD_NOT_PRESENT 0UL
|
||||
|
||||
#define SD_DETECT_PIN GPIO_PIN_5
|
||||
#define SD_DETECT_GPIO_PORT GPIOF
|
||||
#define SD_DETECT_GPIO_CLK_ENABLE() __HAL_RCC_GPIOF_CLK_ENABLE()
|
||||
#define SD_DETECT_GPIO_CLK_DISABLE() __HAL_RCC_GPIOF_CLK_DISABLE()
|
||||
#define SD_DETECT_EXTI_IRQn EXTI9_5_IRQn
|
||||
#define SD_DETECT_EXTI_LINE EXTI_LINE_5
|
||||
|
||||
/* DMA definitions for SD DMA transfer */
|
||||
#define SD1_DMAx_TxRx_CLK_ENABLE __HAL_RCC_DMA2_CLK_ENABLE
|
||||
#define SD1_SDMMC1_DMAx_Tx_CHANNEL DMA_CHANNEL_4
|
||||
#define SD1_SDMMC1_DMAx_Rx_CHANNEL DMA_CHANNEL_4
|
||||
#define SD1_SDMMC1_DMAx_Tx_STREAM DMA2_Stream6
|
||||
#define SD1_SDMMC1_DMAx_Rx_STREAM DMA2_Stream3
|
||||
#define SD1_SDMMC1_DMAx_Tx_IRQn DMA2_Stream6_IRQn
|
||||
#define SD1_SDMMC1_DMAx_Rx_IRQn DMA2_Stream3_IRQn
|
||||
#define SD1_SDMMC1_DMA_Tx_IRQHandler DMA2_Stream6_IRQHandler
|
||||
#define SD1_SDMMC1_DMA_Rx_IRQHandler DMA2_Stream3_IRQHandler
|
||||
#define SD1_SDMMC1_IRQHandler SDMMC1_IRQHandler
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32H735G_DK_SD_Exported_Variables
|
||||
* @{
|
||||
*/
|
||||
extern SD_HandleTypeDef hsd_sdmmc[];
|
||||
extern EXTI_HandleTypeDef hsd_exti[];
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H735G_DK_SD_Exported_FunctionsPrototypes Exported Functions Prototypes
|
||||
* @{
|
||||
*/
|
||||
int32_t BSP_SD_Init(uint32_t Instance);
|
||||
int32_t BSP_SD_DeInit(uint32_t Instance);
|
||||
#if (USE_HAL_SD_REGISTER_CALLBACKS == 1)
|
||||
int32_t BSP_SD_RegisterMspCallbacks(uint32_t Instance, BSP_SD_Cb_t *CallBacks);
|
||||
int32_t BSP_SD_RegisterDefaultMspCallbacks(uint32_t Instance);
|
||||
#endif /* (USE_HAL_SD_REGISTER_CALLBACKS == 1) */
|
||||
int32_t BSP_SD_DetectITConfig(uint32_t Instance);
|
||||
int32_t BSP_SD_ReadBlocks(uint32_t Instance, uint32_t *pData, uint32_t BlockIdx, uint32_t BlocksNbr);
|
||||
int32_t BSP_SD_WriteBlocks(uint32_t Instance, uint32_t *pData, uint32_t BlockIdx, uint32_t NbrOfBlocks);
|
||||
int32_t BSP_SD_ReadBlocks_DMA(uint32_t Instance, uint32_t *pData, uint32_t BlockIdx, uint32_t NbrOfBlocks);
|
||||
int32_t BSP_SD_WriteBlocks_DMA(uint32_t Instance, uint32_t *pData, uint32_t BlockIdx, uint32_t NbrOfBlocks);
|
||||
int32_t BSP_SD_ReadBlocks_IT(uint32_t Instance, uint32_t *pData, uint32_t BlockIdx, uint32_t NbrOfBlocks);
|
||||
int32_t BSP_SD_WriteBlocks_IT(uint32_t Instance, uint32_t *pData, uint32_t BlockIdx, uint32_t NbrOfBlocks);
|
||||
int32_t BSP_SD_Erase(uint32_t Instance, uint32_t BlockIdx, uint32_t BlocksNbr);
|
||||
int32_t BSP_SD_GetCardState(uint32_t Instance);
|
||||
int32_t BSP_SD_GetCardInfo(uint32_t Instance, BSP_SD_CardInfo *CardInfo);
|
||||
int32_t BSP_SD_IsDetected(uint32_t Instance);
|
||||
|
||||
/* These functions can be modified in case the current settings (e.g. DMA stream or IT)
|
||||
need to be changed for specific application needs */
|
||||
void BSP_SD_AbortCallback(uint32_t Instance);
|
||||
void BSP_SD_WriteCpltCallback(uint32_t Instance);
|
||||
void BSP_SD_ReadCpltCallback(uint32_t Instance);
|
||||
|
||||
HAL_StatusTypeDef MX_SDMMC1_SD_Init(SD_HandleTypeDef *hsd);
|
||||
void BSP_SD_DetectCallback(uint32_t Instance, uint32_t Status);
|
||||
|
||||
void BSP_SD_DETECT_IRQHandler(uint32_t Instance);
|
||||
void BSP_SD_IRQHandler(uint32_t Instance);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* STM32H735G_DK_SD_H */
|
||||
@@ -0,0 +1,748 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32h735g_discovery_ts.c
|
||||
* @author MCD Application Team
|
||||
* @brief This file provides a set of functions needed to manage the Touch
|
||||
* Screen on STM32H735G_DK board.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2019 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* File Info : -----------------------------------------------------------------
|
||||
User NOTES
|
||||
1. How To use this driver:
|
||||
--------------------------
|
||||
- This driver is used to drive the FT5336 touch screen module
|
||||
mounted over TFT-LCD on the STM32H735G_DK board.
|
||||
|
||||
2. Driver description:
|
||||
---------------------
|
||||
+ Initialization steps:
|
||||
o Initialize the TS module using the BSP_TS_Init() function. This
|
||||
function includes the MSP layer hardware resources initialization and the
|
||||
communication layer configuration to start the TS use. The LCD size properties
|
||||
(x and y) are passed as parameters.
|
||||
o If TS interrupt mode is desired, you must configure the TS interrupt mode
|
||||
by calling the function BSP_TS_ITConfig(). The TS interrupt mode is generated
|
||||
as an external interrupt whenever a touch is detected.
|
||||
The interrupt mode internally uses the IO functionalities driver driven by
|
||||
the IO expander, to configure the IT line.
|
||||
|
||||
+ Touch screen use
|
||||
o The touch screen state is captured whenever the function BSP_TS_GetState() is
|
||||
used. This function returns information about the last LCD touch occurred
|
||||
in the TS_State_t structure.
|
||||
o The IT is handled using the corresponding external interrupt IRQ handler,
|
||||
the user IT callback treatment is implemented on the same external interrupt
|
||||
callback.
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32h735g_discovery_ts.h"
|
||||
#include "stm32h735g_discovery_bus.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32H735G_DK
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H735G_DK_TS STM32H735G_DK TS
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H735G_DK_TS_Private_Types_Definitions TS Private Types Definitions
|
||||
* @{
|
||||
*/
|
||||
typedef void (* BSP_EXTI_LineCallback) (void);
|
||||
typedef enum
|
||||
{
|
||||
GT911_TS_CTRL,
|
||||
FT5336_TS_CTRL
|
||||
} TS_Driver_t;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H735G_DK_TS_Private_Defines TS Private Types Defines
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H735G_DK_TS_Private_Macros TS Private Macros
|
||||
* @{
|
||||
*/
|
||||
#define TS_MIN(a,b) ((a > b) ? b : a)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/** @defgroup STM32H735G_DK_TS_Private_Function_Prototypes TS Private Function Prototypes
|
||||
* @{
|
||||
*/
|
||||
static void TS_EXTI_Callback(void);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H735G_DK_TS_Privates_Variables TS Privates Variables
|
||||
* @{
|
||||
*/
|
||||
static TS_Drv_t *Ts_Drv = NULL;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H735G_DK_TS_Exported_Variables TS Exported Variables
|
||||
* @{
|
||||
*/
|
||||
EXTI_HandleTypeDef hts_exti[TS_INSTANCES_NBR] = {0};
|
||||
void *Ts_CompObj[TS_INSTANCES_NBR] = {0};
|
||||
TS_Ctx_t Ts_Ctx[TS_INSTANCES_NBR] = {0};
|
||||
TS_Driver_t Ts_Driver_Type = GT911_TS_CTRL;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32H735G_DK_TS_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Initializes and configures the touch screen functionalities and
|
||||
* configures all necessary hardware resources (GPIOs, I2C, clocks..).
|
||||
* @param Instance TS instance. Could be only 0.
|
||||
* @param TS_Init TS Init structure
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_TS_Init(uint32_t Instance, TS_Init_t *TS_Init)
|
||||
{
|
||||
int32_t ret = BSP_ERROR_NONE;
|
||||
|
||||
if ((Instance >= TS_INSTANCES_NBR) || (TS_Init->Width == 0U) || (TS_Init->Width > TS_MAX_WIDTH) || \
|
||||
(TS_Init->Height == 0U) || (TS_Init->Height > TS_MAX_HEIGHT) || \
|
||||
(TS_Init->Accuracy > TS_MIN((TS_Init->Width), (TS_Init->Height))))
|
||||
{
|
||||
ret = BSP_ERROR_WRONG_PARAM;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GT911_Probe(Instance) != BSP_ERROR_NONE)
|
||||
{
|
||||
Ts_Driver_Type = FT5336_TS_CTRL;
|
||||
if (FT5336_Probe(Instance) != BSP_ERROR_NONE)
|
||||
{
|
||||
ret = BSP_ERROR_NO_INIT;
|
||||
}
|
||||
}
|
||||
if (ret == BSP_ERROR_NONE)
|
||||
{
|
||||
TS_Capabilities_t Capabilities;
|
||||
uint32_t i;
|
||||
/* Store parameters on TS context */
|
||||
Ts_Ctx[Instance].Width = TS_Init->Width;
|
||||
Ts_Ctx[Instance].Height = TS_Init->Height;
|
||||
Ts_Ctx[Instance].Orientation = TS_Init->Orientation;
|
||||
Ts_Ctx[Instance].Accuracy = TS_Init->Accuracy;
|
||||
/* Get capabilities to retrieve maximum values of X and Y */
|
||||
if (Ts_Drv->GetCapabilities(Ts_CompObj[Instance], &Capabilities) < 0)
|
||||
{
|
||||
ret = BSP_ERROR_COMPONENT_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Store maximum X and Y on context */
|
||||
Ts_Ctx[Instance].MaxX = Capabilities.MaxXl;
|
||||
Ts_Ctx[Instance].MaxY = Capabilities.MaxYl;
|
||||
/* Initialize previous position in order to always detect first touch */
|
||||
for (i = 0; i < TS_TOUCH_NBR; i++)
|
||||
{
|
||||
Ts_Ctx[Instance].PreviousX[i] = TS_Init->Width + TS_Init->Accuracy + 1U;
|
||||
Ts_Ctx[Instance].PreviousY[i] = TS_Init->Height + TS_Init->Accuracy + 1U;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief De-Initializes the touch screen functionalities
|
||||
* @param Instance TS instance. Could be only 0.
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_TS_DeInit(uint32_t Instance)
|
||||
{
|
||||
int32_t ret = BSP_ERROR_NONE;
|
||||
|
||||
if (Instance >= TS_INSTANCES_NBR)
|
||||
{
|
||||
ret = BSP_ERROR_WRONG_PARAM;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Ts_Drv->DeInit(Ts_CompObj[Instance]) < 0)
|
||||
{
|
||||
ret = BSP_ERROR_COMPONENT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get Touch Screen instance capabilities
|
||||
* @param Instance Touch Screen instance
|
||||
* @param Capabilities pointer to Touch Screen capabilities
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_TS_GetCapabilities(uint32_t Instance, TS_Capabilities_t *Capabilities)
|
||||
{
|
||||
int32_t ret = BSP_ERROR_NONE;
|
||||
|
||||
if (Instance >= TS_INSTANCES_NBR)
|
||||
{
|
||||
ret = BSP_ERROR_WRONG_PARAM;
|
||||
}
|
||||
else
|
||||
{
|
||||
(void)Ts_Drv->GetCapabilities(Ts_CompObj[Instance], Capabilities);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configures and enables the touch screen interrupts.
|
||||
* @param Instance TS instance. Could be only 0.
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_TS_EnableIT(uint32_t Instance)
|
||||
{
|
||||
int32_t ret = BSP_ERROR_NONE;
|
||||
GPIO_InitTypeDef gpio_init_structure;
|
||||
|
||||
if (Instance >= TS_INSTANCES_NBR)
|
||||
{
|
||||
ret = BSP_ERROR_WRONG_PARAM;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Configure Interrupt mode for TS_INT pin falling edge : when a new touch is available */
|
||||
/* TS_INT pin is active on low level on new touch available */
|
||||
gpio_init_structure.Pin = TS_INT_PIN;
|
||||
gpio_init_structure.Pull = GPIO_NOPULL;
|
||||
gpio_init_structure.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
gpio_init_structure.Mode = GPIO_MODE_IT_FALLING;
|
||||
HAL_GPIO_Init(TS_INT_GPIO_PORT, &gpio_init_structure);
|
||||
|
||||
if (Ts_Drv->EnableIT(Ts_CompObj[Instance]) < 0)
|
||||
{
|
||||
ret = BSP_ERROR_COMPONENT_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (HAL_EXTI_GetHandle(&hts_exti[Instance], TS_EXTI_LINE) != HAL_OK)
|
||||
{
|
||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
else if (HAL_EXTI_RegisterCallback(&hts_exti[Instance], HAL_EXTI_COMMON_CB_ID, TS_EXTI_Callback) != HAL_OK)
|
||||
{
|
||||
ret = BSP_ERROR_PERIPH_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Enable and set the TS_INT EXTI Interrupt to an intermediate priority */
|
||||
HAL_NVIC_SetPriority((IRQn_Type)(TS_INT_EXTI_IRQn), BSP_TS_IT_PRIORITY, 0x00);
|
||||
HAL_NVIC_EnableIRQ((IRQn_Type)(TS_INT_EXTI_IRQn));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disables the touch screen interrupts.
|
||||
* @param Instance TS instance. Could be only 0.
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_TS_DisableIT(uint32_t Instance)
|
||||
{
|
||||
int32_t ret = BSP_ERROR_NONE;
|
||||
GPIO_InitTypeDef gpio_init_structure;
|
||||
|
||||
if (Instance >= TS_INSTANCES_NBR)
|
||||
{
|
||||
ret = BSP_ERROR_WRONG_PARAM;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Configure TS_INT_PIN low level to generate MFX_IRQ_OUT in EXTI on MCU */
|
||||
gpio_init_structure.Pin = TS_INT_PIN;
|
||||
HAL_GPIO_DeInit(TS_INT_GPIO_PORT, gpio_init_structure.Pin);
|
||||
|
||||
/* Disable the TS in interrupt mode */
|
||||
/* In that case the INT output of FT5336 when new touch is available */
|
||||
/* is active on low level and directed on EXTI */
|
||||
if (Ts_Drv->DisableIT(Ts_CompObj[Instance]) < 0)
|
||||
{
|
||||
ret = BSP_ERROR_COMPONENT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles TS interrupt request.
|
||||
* @param Instance TS instance
|
||||
* @retval None
|
||||
*/
|
||||
void BSP_TS_IRQHandler(uint32_t Instance)
|
||||
{
|
||||
HAL_EXTI_IRQHandler(&hts_exti[Instance]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief BSP TS Callback.
|
||||
* @retval None.
|
||||
*/
|
||||
__weak void BSP_TS_Callback(uint32_t Instance)
|
||||
{
|
||||
/* This function should be implemented by the user application.
|
||||
It is called into this driver when an event on TS touch detection */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns positions of a single touch screen.
|
||||
* @param Instance TS instance. Could be only 0.
|
||||
* @param TS_State Pointer to touch screen current state structure
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_TS_GetState(uint32_t Instance, TS_State_t *TS_State)
|
||||
{
|
||||
int32_t ret = BSP_ERROR_NONE;
|
||||
uint32_t x_oriented, y_oriented;
|
||||
uint32_t x_diff, y_diff;
|
||||
|
||||
if (Instance >= TS_INSTANCES_NBR)
|
||||
{
|
||||
ret = BSP_ERROR_WRONG_PARAM;
|
||||
}
|
||||
else
|
||||
{
|
||||
TS_State_t state;
|
||||
|
||||
/* Get each touch coordinates */
|
||||
if (Ts_Drv->GetState(Ts_CompObj[Instance], &state) < 0)
|
||||
{
|
||||
ret = BSP_ERROR_COMPONENT_FAILURE;
|
||||
}/* Check and update the number of touches active detected */
|
||||
else if (state.TouchDetected != 0U)
|
||||
{
|
||||
x_oriented = state.TouchX;
|
||||
y_oriented = state.TouchY;
|
||||
|
||||
if ((Ts_Ctx[Instance].Orientation & TS_SWAP_XY) == TS_SWAP_XY)
|
||||
{
|
||||
x_oriented = state.TouchY;
|
||||
y_oriented = state.TouchX;
|
||||
}
|
||||
|
||||
if ((Ts_Ctx[Instance].Orientation & TS_SWAP_X) == TS_SWAP_X)
|
||||
{
|
||||
x_oriented = Ts_Ctx[Instance].MaxX - state.TouchX - 1UL;
|
||||
}
|
||||
|
||||
if ((Ts_Ctx[Instance].Orientation & TS_SWAP_Y) == TS_SWAP_Y)
|
||||
{
|
||||
y_oriented = Ts_Ctx[Instance].MaxY - state.TouchY;
|
||||
}
|
||||
|
||||
/* Apply boundary */
|
||||
TS_State->TouchX = (x_oriented * Ts_Ctx[Instance].Width) / Ts_Ctx[Instance].MaxX;
|
||||
TS_State->TouchY = (y_oriented * Ts_Ctx[Instance].Height) / Ts_Ctx[Instance].MaxY;
|
||||
/* Store Current TS state */
|
||||
TS_State->TouchDetected = state.TouchDetected;
|
||||
|
||||
/* Check accuracy */
|
||||
x_diff = (TS_State->TouchX > Ts_Ctx[Instance].PreviousX[0]) ?
|
||||
(TS_State->TouchX - Ts_Ctx[Instance].PreviousX[0]) :
|
||||
(Ts_Ctx[Instance].PreviousX[0] - TS_State->TouchX);
|
||||
|
||||
y_diff = (TS_State->TouchY > Ts_Ctx[Instance].PreviousY[0]) ?
|
||||
(TS_State->TouchY - Ts_Ctx[Instance].PreviousY[0]) :
|
||||
(Ts_Ctx[Instance].PreviousY[0] - TS_State->TouchY);
|
||||
|
||||
|
||||
if ((x_diff > Ts_Ctx[Instance].Accuracy) || (y_diff > Ts_Ctx[Instance].Accuracy))
|
||||
{
|
||||
/* New touch detected */
|
||||
Ts_Ctx[Instance].PreviousX[0] = TS_State->TouchX;
|
||||
Ts_Ctx[Instance].PreviousY[0] = TS_State->TouchY;
|
||||
}
|
||||
else
|
||||
{
|
||||
TS_State->TouchX = Ts_Ctx[Instance].PreviousX[0];
|
||||
TS_State->TouchY = Ts_Ctx[Instance].PreviousY[0];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TS_State->TouchDetected = 0U;
|
||||
TS_State->TouchX = Ts_Ctx[Instance].PreviousX[0];
|
||||
TS_State->TouchY = Ts_Ctx[Instance].PreviousY[0];
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if (USE_TS_MULTI_TOUCH > 0)
|
||||
/**
|
||||
* @brief Returns positions of multi touch screen.
|
||||
* @param Instance TS instance. Could be only 0.
|
||||
* @param TS_State Pointer to touch screen current state structure
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_TS_Get_MultiTouchState(uint32_t Instance, TS_MultiTouch_State_t *TS_State)
|
||||
{
|
||||
int32_t ret = BSP_ERROR_NONE;
|
||||
uint32_t index;
|
||||
uint32_t x_oriented, y_oriented;
|
||||
uint32_t x_diff, y_diff;
|
||||
|
||||
if (Instance >= TS_INSTANCES_NBR)
|
||||
{
|
||||
ret = BSP_ERROR_WRONG_PARAM;
|
||||
}
|
||||
else
|
||||
{
|
||||
TS_MultiTouch_State_t state;
|
||||
|
||||
/* Get each touch coordinates */
|
||||
if (Ts_Drv->GetMultiTouchState(Ts_CompObj[Instance], &state) < 0)
|
||||
{
|
||||
ret = BSP_ERROR_COMPONENT_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Check and update the number of touches active detected */
|
||||
if (state.TouchDetected != 0U)
|
||||
{
|
||||
for (index = 0; index < state.TouchDetected; index++)
|
||||
{
|
||||
x_oriented = state.TouchX[index];
|
||||
y_oriented = state.TouchY[index];
|
||||
|
||||
if ((Ts_Ctx[Instance].Orientation & TS_SWAP_XY) == TS_SWAP_XY)
|
||||
{
|
||||
x_oriented = state.TouchY[index];
|
||||
y_oriented = state.TouchX[index];
|
||||
}
|
||||
|
||||
if ((Ts_Ctx[Instance].Orientation & TS_SWAP_X) == TS_SWAP_X)
|
||||
{
|
||||
x_oriented = Ts_Ctx[Instance].MaxX - state.TouchX[index] - 1UL;
|
||||
}
|
||||
|
||||
if ((Ts_Ctx[Instance].Orientation & TS_SWAP_Y) == TS_SWAP_Y)
|
||||
{
|
||||
y_oriented = Ts_Ctx[Instance].MaxY - state.TouchY[index];
|
||||
}
|
||||
|
||||
/* Apply boundary */
|
||||
TS_State->TouchX[index] = (x_oriented * Ts_Ctx[Instance].Width) / Ts_Ctx[Instance].MaxX;
|
||||
TS_State->TouchY[index] = (y_oriented * Ts_Ctx[Instance].Height) / Ts_Ctx[Instance].MaxY;
|
||||
/* Store Current TS state */
|
||||
TS_State->TouchDetected = state.TouchDetected;
|
||||
|
||||
/* Check accuracy */
|
||||
x_diff = (TS_State->TouchX[index] > Ts_Ctx[Instance].PreviousX[index]) ?
|
||||
(TS_State->TouchX[index] - Ts_Ctx[Instance].PreviousX[index]) :
|
||||
(Ts_Ctx[Instance].PreviousX[index] - TS_State->TouchX[index]);
|
||||
|
||||
y_diff = (TS_State->TouchY[index] > Ts_Ctx[Instance].PreviousY[index]) ?
|
||||
(TS_State->TouchY[index] - Ts_Ctx[Instance].PreviousY[index]) :
|
||||
(Ts_Ctx[Instance].PreviousY[index] - TS_State->TouchY[index]);
|
||||
|
||||
if ((x_diff > Ts_Ctx[Instance].Accuracy) || (y_diff > Ts_Ctx[Instance].Accuracy))
|
||||
{
|
||||
/* New touch detected */
|
||||
Ts_Ctx[Instance].PreviousX[index] = TS_State->TouchX[index];
|
||||
Ts_Ctx[Instance].PreviousY[index] = TS_State->TouchY[index];
|
||||
}
|
||||
else
|
||||
{
|
||||
TS_State->TouchX[index] = Ts_Ctx[Instance].PreviousX[index];
|
||||
TS_State->TouchY[index] = Ts_Ctx[Instance].PreviousY[index];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TS_State->TouchDetected = 0U;
|
||||
for (index = 0; index < TS_TOUCH_NBR; index++)
|
||||
{
|
||||
TS_State->TouchX[index] = Ts_Ctx[Instance].PreviousX[index];
|
||||
TS_State->TouchY[index] = Ts_Ctx[Instance].PreviousY[index];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* USE_TS_MULTI_TOUCH == 1 */
|
||||
|
||||
#if (USE_TS_GESTURE == 1)
|
||||
/**
|
||||
* @brief Update gesture Id following a touch detected.
|
||||
* @param Instance TS instance. Could be only 0.
|
||||
* @param GestureConfig Pointer to gesture configuration structure
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_TS_GestureConfig(uint32_t Instance, TS_Gesture_Config_t *GestureConfig)
|
||||
{
|
||||
int32_t ret = BSP_ERROR_NONE;
|
||||
|
||||
if (Instance >= TS_INSTANCES_NBR)
|
||||
{
|
||||
ret = BSP_ERROR_WRONG_PARAM;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Ts_Drv->GestureConfig(Ts_CompObj[Instance], GestureConfig) < 0)
|
||||
{
|
||||
ret = BSP_ERROR_COMPONENT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Update gesture Id following a touch detected.
|
||||
* @param Instance TS instance. Could be only 0.
|
||||
* @param GestureId Pointer to gesture ID
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_TS_GetGestureId(uint32_t Instance, uint32_t *GestureId)
|
||||
{
|
||||
int32_t ret = BSP_ERROR_NONE;
|
||||
uint8_t tmp = 0;
|
||||
|
||||
if (Instance >= TS_INSTANCES_NBR)
|
||||
{
|
||||
ret = BSP_ERROR_WRONG_PARAM;
|
||||
}/* Get gesture Id */
|
||||
else if (Ts_Drv->GetGesture(Ts_CompObj[Instance], &tmp) < 0)
|
||||
{
|
||||
ret = BSP_ERROR_COMPONENT_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Remap gesture Id to a TS_Gesture_Id_t value */
|
||||
switch (tmp)
|
||||
{
|
||||
case FT5336_GEST_ID_NO_GESTURE :
|
||||
*GestureId = GESTURE_ID_NO_GESTURE;
|
||||
break;
|
||||
case FT5336_GEST_ID_MOVE_UP :
|
||||
*GestureId = GESTURE_ID_MOVE_UP;
|
||||
break;
|
||||
case FT5336_GEST_ID_MOVE_RIGHT :
|
||||
*GestureId = GESTURE_ID_MOVE_RIGHT;
|
||||
break;
|
||||
case FT5336_GEST_ID_MOVE_DOWN :
|
||||
*GestureId = GESTURE_ID_MOVE_DOWN;
|
||||
break;
|
||||
case FT5336_GEST_ID_MOVE_LEFT :
|
||||
*GestureId = GESTURE_ID_MOVE_LEFT;
|
||||
break;
|
||||
case FT5336_GEST_ID_ZOOM_IN :
|
||||
*GestureId = GESTURE_ID_ZOOM_IN;
|
||||
break;
|
||||
case FT5336_GEST_ID_ZOOM_OUT :
|
||||
*GestureId = GESTURE_ID_ZOOM_OUT;
|
||||
break;
|
||||
default :
|
||||
*GestureId = GESTURE_ID_NO_GESTURE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif /* USE_TS_GESTURE == 1 */
|
||||
|
||||
/**
|
||||
* @brief Set TS orientation
|
||||
* @param Instance TS instance. Could be only 0.
|
||||
* @param Orientation Orientation to be set
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_TS_Set_Orientation(uint32_t Instance, uint32_t Orientation)
|
||||
{
|
||||
Ts_Ctx[Instance].Orientation = Orientation;
|
||||
return BSP_ERROR_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get TS orientation
|
||||
* @param Instance TS instance. Could be only 0.
|
||||
* @param Orientation Current Orientation to be returned
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t BSP_TS_Get_Orientation(uint32_t Instance, uint32_t *Orientation)
|
||||
{
|
||||
*Orientation = Ts_Ctx[Instance].Orientation;
|
||||
return BSP_ERROR_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/** @defgroup STM32H735G_DK_TS_Private_Functions TS Private Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Register Bus IOs if component ID is OK
|
||||
* @param Instance TS instance. Could be only 0.
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t GT911_Probe(uint32_t Instance)
|
||||
{
|
||||
int32_t ret = BSP_ERROR_NONE;
|
||||
GT911_IO_t IOCtx;
|
||||
static GT911_Object_t GT911Obj;
|
||||
uint32_t gt911_id = 0;
|
||||
|
||||
/* Configure the touch screen driver */
|
||||
IOCtx.Address = TS_I2C_ADDRESS_GT;
|
||||
IOCtx.Init = BSP_I2C4_Init;
|
||||
IOCtx.DeInit = BSP_I2C4_DeInit;
|
||||
IOCtx.ReadReg = BSP_I2C4_ReadReg16;
|
||||
IOCtx.WriteReg = BSP_I2C4_WriteReg16;
|
||||
IOCtx.GetTick = BSP_GetTick;
|
||||
|
||||
if (GT911_RegisterBusIO(>911Obj, &IOCtx) != GT911_OK)
|
||||
{
|
||||
ret = BSP_ERROR_BUS_FAILURE;
|
||||
}
|
||||
else if (GT911_ReadID(>911Obj, >911_id) != GT911_OK)
|
||||
{
|
||||
ret = BSP_ERROR_COMPONENT_FAILURE;
|
||||
}
|
||||
else if (gt911_id != GT911_ID)
|
||||
{
|
||||
ret = BSP_ERROR_UNKNOWN_COMPONENT;
|
||||
}
|
||||
else
|
||||
{
|
||||
Ts_CompObj[Instance] = >911Obj;
|
||||
Ts_Drv = (TS_Drv_t *) >911_TS_Driver;
|
||||
|
||||
if (Ts_Drv->Init(Ts_CompObj[Instance]) != GT911_OK)
|
||||
{
|
||||
ret = BSP_ERROR_COMPONENT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Register Bus IOs if component ID is OK
|
||||
* @param Instance TS instance. Could be only 0.
|
||||
* @retval BSP status
|
||||
*/
|
||||
int32_t FT5336_Probe(uint32_t Instance)
|
||||
{
|
||||
int32_t ret = BSP_ERROR_NONE;
|
||||
FT5336_IO_t IOCtx;
|
||||
static FT5336_Object_t FT5336Obj;
|
||||
uint32_t ft5336_id = 0;
|
||||
|
||||
/* Configure the touch screen driver */
|
||||
IOCtx.Address = TS_I2C_ADDRESS;
|
||||
IOCtx.Init = BSP_I2C4_Init;
|
||||
IOCtx.DeInit = BSP_I2C4_DeInit;
|
||||
IOCtx.ReadReg = BSP_I2C4_ReadReg;
|
||||
IOCtx.WriteReg = BSP_I2C4_WriteReg;
|
||||
IOCtx.GetTick = BSP_GetTick;
|
||||
|
||||
if (FT5336_RegisterBusIO(&FT5336Obj, &IOCtx) != FT5336_OK)
|
||||
{
|
||||
ret = BSP_ERROR_BUS_FAILURE;
|
||||
}
|
||||
else if (FT5336_ReadID(&FT5336Obj, &ft5336_id) != FT5336_OK)
|
||||
{
|
||||
ret = BSP_ERROR_COMPONENT_FAILURE;
|
||||
}
|
||||
else if (ft5336_id != FT5336_ID)
|
||||
{
|
||||
ret = BSP_ERROR_UNKNOWN_COMPONENT;
|
||||
}
|
||||
else
|
||||
{
|
||||
Ts_CompObj[Instance] = &FT5336Obj;
|
||||
Ts_Drv = (TS_Drv_t *) &FT5336_TS_Driver;
|
||||
|
||||
if (Ts_Drv->Init(Ts_CompObj[Instance]) != FT5336_OK)
|
||||
{
|
||||
ret = BSP_ERROR_COMPONENT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TS EXTI touch detection callbacks.
|
||||
* @retval None
|
||||
*/
|
||||
static void TS_EXTI_Callback(void)
|
||||
{
|
||||
BSP_TS_Callback(0);
|
||||
|
||||
/* Clear interrupt on TS driver */
|
||||
if (Ts_Drv->ClearIT(Ts_CompObj) < 0)
|
||||
{
|
||||
/* Nothing to do */
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@@ -0,0 +1,242 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32h735g_discovery_ts.h
|
||||
* @author MCD Application Team
|
||||
* @brief This file contains the common defines and functions prototypes for
|
||||
* the stm32h735g_discovery_ts.c driver.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2019 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef STM32H735G_DK_TS_H
|
||||
#define STM32H735G_DK_TS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32h735g_discovery_conf.h"
|
||||
#include "stm32h735g_discovery_errno.h"
|
||||
|
||||
#include "../Components/ft5336/ft5336.h"
|
||||
#include "../Components/gt911/gt911.h"
|
||||
#include "../Components/Common/ts.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32H735G_DK
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32H735G_DK_TS
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H735G_DK_TS_Exported_Constants TS Exported Constants
|
||||
* @{
|
||||
*/
|
||||
#ifndef USE_TS_MULTI_TOUCH
|
||||
#define USE_TS_MULTI_TOUCH 1U
|
||||
#endif
|
||||
#ifndef USE_TS_GESTURE
|
||||
#define USE_TS_GESTURE 1U
|
||||
#endif
|
||||
|
||||
#ifndef TS_TOUCH_NBR
|
||||
#define TS_TOUCH_NBR 2U
|
||||
#endif
|
||||
|
||||
#define TS_INSTANCES_NBR 1
|
||||
|
||||
/* Maximum border values of the touchscreen pad */
|
||||
#define TS_MAX_WIDTH 480U /* Touchscreen pad max width */
|
||||
#define TS_MAX_HEIGHT 272U /* Touchscreen pad max height */
|
||||
|
||||
#define TS_SWAP_NONE 0x01U
|
||||
#define TS_SWAP_X 0x02U
|
||||
#define TS_SWAP_Y 0x04U
|
||||
#define TS_SWAP_XY 0x08U
|
||||
|
||||
/**
|
||||
* @brief TouchScreen Slave I2C address 1
|
||||
*/
|
||||
#define TS_I2C_ADDRESS 0x70U
|
||||
|
||||
#define TS_I2C_ADDRESS_GT 0xBAU
|
||||
#define TS_I2C_ADDRESS_BACK 0x28U
|
||||
/**
|
||||
* @brief Touch screen interrupt signal
|
||||
*/
|
||||
#define TS_INT_PIN GPIO_PIN_2
|
||||
#define TS_INT_GPIO_PORT GPIOG
|
||||
#define TS_INT_GPIO_CLK_ENABLE() __HAL_RCC_GPIOG_CLK_ENABLE()
|
||||
#define TS_INT_GPIO_CLK_DISABLE() __HAL_RCC_GPIOG_CLK_DISABLE()
|
||||
#define TS_INT_EXTI_IRQn EXTI2_IRQn
|
||||
#define TS_EXTI_LINE EXTI_LINE_2
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H735G_DK_TS_Exported_Types TS Exported Types
|
||||
* @{
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t Width; /* Screen Width */
|
||||
uint32_t Height; /* Screen Height */
|
||||
uint32_t Orientation; /* Touch Screen orientation from the upper left position */
|
||||
uint32_t Accuracy; /* Expressed in pixel and means the x or y difference vs old
|
||||
position to consider the new values valid */
|
||||
} TS_Init_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t Width;
|
||||
uint32_t Height;
|
||||
uint32_t Orientation;
|
||||
uint32_t Accuracy;
|
||||
uint32_t MaxX;
|
||||
uint32_t MaxY;
|
||||
uint32_t PreviousX[TS_TOUCH_NBR];
|
||||
uint32_t PreviousY[TS_TOUCH_NBR];
|
||||
} TS_Ctx_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t MultiTouch;
|
||||
uint8_t Gesture;
|
||||
uint8_t MaxTouch;
|
||||
uint32_t MaxXl;
|
||||
uint32_t MaxYl;
|
||||
} TS_Capabilities_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t TouchDetected;
|
||||
uint32_t TouchX;
|
||||
uint32_t TouchY;
|
||||
} TS_State_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t TouchDetected;
|
||||
uint32_t TouchX[TS_TOUCH_NBR];
|
||||
uint32_t TouchY[TS_TOUCH_NBR];
|
||||
uint32_t TouchWeight[TS_TOUCH_NBR];
|
||||
uint32_t TouchEvent[TS_TOUCH_NBR];
|
||||
uint32_t TouchArea[TS_TOUCH_NBR];
|
||||
} TS_MultiTouch_State_t;
|
||||
|
||||
#if (USE_TS_GESTURE > 0)
|
||||
/**
|
||||
* @brief TS_Gesture_Id_t
|
||||
* Define Possible managed gesture identification values returned by touch screen
|
||||
* driver.
|
||||
*/
|
||||
#define GESTURE_ID_NO_GESTURE 0x00U /*!< Gesture not defined / recognized */
|
||||
#define GESTURE_ID_MOVE_UP 0x01U /*!< Gesture Move Up */
|
||||
#define GESTURE_ID_MOVE_RIGHT 0x02U /*!< Gesture Move Right */
|
||||
#define GESTURE_ID_MOVE_DOWN 0x03U /*!< Gesture Move Down */
|
||||
#define GESTURE_ID_MOVE_LEFT 0x04U /*!< Gesture Move Left */
|
||||
#define GESTURE_ID_ZOOM_IN 0x05U /*!< Gesture Zoom In */
|
||||
#define GESTURE_ID_ZOOM_OUT 0x06U /*!< Gesture Zoom Out */
|
||||
#define GESTURE_ID_NB_MAX 0x07U /*!< max number of gesture id */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t Radian;
|
||||
uint32_t OffsetLeftRight;
|
||||
uint32_t OffsetUpDown;
|
||||
uint32_t DistanceLeftRight;
|
||||
uint32_t DistanceUpDown;
|
||||
uint32_t DistanceZoom;
|
||||
} TS_Gesture_Config_t;
|
||||
|
||||
#endif /* (USE_TS_GESTURE > 0) */
|
||||
|
||||
/**
|
||||
* @brief TS_TouchEventTypeDef
|
||||
* Define Possible touch events kind as returned values
|
||||
* by touch screen IC Driver.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
TOUCH_EVENT_NO_EVT = 0x00, /*!< Touch Event : undetermined */
|
||||
TOUCH_EVENT_PRESS_DOWN = 0x01, /*!< Touch Event Press Down */
|
||||
TOUCH_EVENT_LIFT_UP = 0x02, /*!< Touch Event Lift Up */
|
||||
TOUCH_EVENT_CONTACT = 0x03, /*!< Touch Event Contact */
|
||||
TOUCH_EVENT_NB_MAX = 0x04 /*!< max number of touch events kind */
|
||||
} TS_TouchEventTypeDef;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32H735G_DK_TS_Exported_Variables
|
||||
* @{
|
||||
*/
|
||||
extern void *Ts_CompObj[];
|
||||
extern EXTI_HandleTypeDef hts_exti[];
|
||||
extern TS_Ctx_t Ts_Ctx[];
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32H735G_DK_TS_Exported_Functions TS Exported Functions
|
||||
* @{
|
||||
*/
|
||||
int32_t BSP_TS_Init(uint32_t Instance, TS_Init_t *TS_Init);
|
||||
int32_t BSP_TS_DeInit(uint32_t Instance);
|
||||
int32_t BSP_TS_EnableIT(uint32_t Instance);
|
||||
int32_t BSP_TS_DisableIT(uint32_t Instance);
|
||||
int32_t BSP_TS_GetState(uint32_t Instance, TS_State_t *TS_State);
|
||||
#if (USE_TS_MULTI_TOUCH == 1)
|
||||
int32_t BSP_TS_Get_MultiTouchState(uint32_t Instance, TS_MultiTouch_State_t *TS_State);
|
||||
#endif /* USE_TS_MULTI_TOUCH == 1 */
|
||||
#if (USE_TS_GESTURE == 1)
|
||||
int32_t BSP_TS_GestureConfig(uint32_t Instance, TS_Gesture_Config_t *GestureConfig);
|
||||
int32_t BSP_TS_GetGestureId(uint32_t Instance, uint32_t *GestureId);
|
||||
#endif /* (USE_TS_GESTURE == 1) */
|
||||
int32_t BSP_TS_Set_Orientation(uint32_t Instance, uint32_t Orientation);
|
||||
int32_t BSP_TS_Get_Orientation(uint32_t Instance, uint32_t *Orientation);
|
||||
int32_t BSP_TS_GetCapabilities(uint32_t Instance, TS_Capabilities_t *Capabilities);
|
||||
void BSP_TS_Callback(uint32_t Instance);
|
||||
void BSP_TS_IRQHandler(uint32_t Instance);
|
||||
int32_t FT5336_Probe(uint32_t Instance);
|
||||
int32_t GT911_Probe(uint32_t Instance);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* STM32H735G_DK_TS_H */
|
||||
Reference in New Issue
Block a user