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

This commit is contained in:
2026-08-03 16:37:40 +08:00
commit dac37fd077
14095 changed files with 5603119 additions and 0 deletions
@@ -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 STM32H750B-DK Component
![latest tag](https://img.shields.io/github/v/tag/STMicroelectronics/stm32h750b-dk.svg?color=brightgreen)
## 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 **stm32h750b-dk** MCU component repository is one element of the **STM32CubeH7** MCU embedded software package, providing the **STM32H750B-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/stm32h750b-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-mt25tl01g](https://github.com/STMicroelectronics/stm32-mt25tl01g)
* [stm32-mt48lc4m32b2](https://github.com/STMicroelectronics/stm32-mt48lc4m32b2)
* [stm32-rk043fn48h](https://github.com/STMicroelectronics/stm32-rk043fn48h)
* [stm32-wm8994](https://github.com/STMicroelectronics/stm32-wm8994)
## Troubleshooting
Please refer to the [CONTRIBUTING.md](CONTRIBUTING.md) guide.
@@ -0,0 +1,159 @@
<!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 STM32H750B-DK BSP Driver</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-stm32h750b-dk-bsp-driver"><strong>Release Notes for STM32H750B-DK BSP Driver</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 drivers 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"><strong>Update History</strong></h1>
<div class="collapse">
<input type="checkbox" id="collapse-section9" checked aria-hidden="true"> <label for="collapse-section9" aria-hidden="true"><strong>V3.3.3 / 19-February-2024</strong></label>
<div>
<h2 id="main-changes">Main Changes</h2>
<ul>
<li>Align the defined symbol “SDRAM_DEVICE_SIZE” with value defined in memory datasheet.</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section8" aria-hidden="true"> <label for="collapse-section8" aria-hidden="true"><strong>V3.3.2 / 12-October-2022</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>Enable SDMMC HW flow control in MX_MMC_SD_Init() API.</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section7" aria-hidden="true"> <label for="collapse-section7" aria-hidden="true"><strong>V3.3.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>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section6" aria-hidden="true"> <label for="collapse-section6" aria-hidden="true"><strong>V3.3.0 / 29-January-2021</strong></label>
<div>
<h2 id="main-changes-3">Main Changes</h2>
<ul>
<li>BSP QSPI : Add explicit definition of “BSP_QSPI_Erase_t” type with 8KB, 64KB and 128KB erase size
<ul>
<li>Notes:
<ul>
<li>The STM32H750B-DK comes with a dual flash QSPI, the erase size for each flash is 4KB, 32KB and 64KB</li>
<li>From BSP top view these two flash are seen as a single one with twice the size</li>
</ul></li>
</ul></li>
<li>BSP LCD: Fix “BSP_LCD_DisplayOn/Off” behavior
<ul>
<li>Configure the LCD BL pin to output and set it to low state in case of display off</li>
<li>Configure the LCD BL pin to AF timer in case of display on (the pin will be then driven by the timer to ensure the desired brightness)</li>
</ul></li>
<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-section5" aria-hidden="true"> <label for="collapse-section5" aria-hidden="true"><strong>V3.2.0 / 29-September-2020</strong></label>
<div>
<h2 id="main-changes-4">Main Changes</h2>
<ul>
<li>Fix typo in BSP_PB_Init API implementation regarding EXTI button NVIC priority setting</li>
<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-section4" aria-hidden="true"> <label for="collapse-section4" aria-hidden="true"><strong>V3.1.0 / 30-April-2020</strong></label>
<div>
<h2 id="main-changes-5">Main Changes</h2>
<ul>
<li>Update BSP_BUS APIs with protection against RTOS multithread usage (under BSP_USE_CMSIS_OS pre-processor conditional define)</li>
</ul>
<h2 id="dependencies-2">Dependencies</h2>
<ul>
<li>Components/common v7.0.0</li>
</ul>
</div>
</div>
<div class="collapse">
<input type="checkbox" id="collapse-section3" aria-hidden="true"> <label for="collapse-section3" aria-hidden="true"><strong>V3.0.0 / 25-February-2020</strong></label>
<div>
<h2 id="main-changes-6">Main Changes</h2>
<ul>
<li>Rename GUI_Drv_t into UTILS_LCD_Drv_t</li>
</ul>
<h2 id="backward-compatibility">Backward Compatibility</h2>
<ul>
<li>This version breaks the compatibility with previous versions</li>
</ul>
<h2 id="dependencies-3">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>V2.0.0 / 25-November-2019</strong></label>
<div>
<h2 id="main-changes-7">Main Changes</h2>
<ul>
<li>First official release of STM32H750B-DK BSP drivers in line with STM32Cube BSP drivers development guidelines (UM2298)</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 / 05-April-2019</strong></label>
<div>
<h2 id="main-changes-8">Main Changes</h2>
<ul>
<li>First official release</li>
</ul>
</div>
</div>
</div>
</div>
<footer class="sticky">
For complete documentation on STM32 Microcontrollers </mark> , visit: <span style="font-color: blue;"><a href="http://www.st.com/stm32">www.st.com/stm32</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 STs
[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,632 @@
/**
******************************************************************************
* @file stm32h750b_discovery.c
* @author MCD Application Team
* @brief This file provides a set of firmware functions to manage
* LEDs
* push-buttons
* COM ports
* available on STM32H750B-DK board(MB1381) from STMicroelectronics.
******************************************************************************
* @attention
*
* Copyright (c) 2018 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 "stm32h750b_discovery.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup STM32H750B_DK
* @{
*/
/** @defgroup STM32H750B_DK_LOW_LEVEL LOW LEVEL
* @{
*/
/** @defgroup STM32H750B_DK_LOW_LEVEL_Private_TypesDefinitions Private Types Definitions
* @{
*/
typedef void (* BSP_EXTI_LineCallback) (void);
/**
* @}
*/
/** @defgroup STM32H750B_DK_LOW_LEVEL_Private_FunctionPrototypes Private Function Prototypes
* @{
*/
static void BUTTON_USER_EXTI_Callback(void);
#if (USE_BSP_COM_FEATURE > 0)
static void USART3_MspInit(UART_HandleTypeDef *huart);
static void USART3_MspDeInit(UART_HandleTypeDef *huart);
#endif
/**
* @}
*/
/** @defgroup STM32H750B_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 STM32H750B_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_COM_LOG == 1)
static COM_TypeDef COM_ActiveLogPort = COM1;
#endif
#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
static uint32_t IsComMspCbValid[COMn] = {0};
#endif
/**
* @}
*/
/** @defgroup STM32H750B_DK_LOW_LEVEL_Exported_Functions Exported Functions
* @{
*/
/**
* @brief This method returns the STM32H750B Discovery BSP Driver revision
* @retval version: 0xXYZR (8bits for each decimal, R for RC)
*/
int32_t BSP_GetVersion(void)
{
return (int32_t)STM32H750B_DK_BSP_VERSION;
}
/**
* @brief This method returns the board name
* @retval pointer to the board name string
*/
const uint8_t* BSP_GetBoardName(void)
{
return (uint8_t *)STM32H750B_DK_BSP_BOARD_NAME;
}
/**
* @brief This method returns the board ID
* @retval pointer to the board name string
*/
const uint8_t* BSP_GetBoardID(void)
{
return (uint8_t *)STM32H750B_DK_BSP_BOARD_ID;
}
/**
* @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.Pin = LED_PIN [Led];
gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP;
gpio_init_structure.Pull = GPIO_PULLUP;
gpio_init_structure.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
HAL_GPIO_Init (LED_PORT [Led], &gpio_init_structure);
/* By default, turn off LED */
HAL_GPIO_WritePin (LED_PORT [Led], (uint16_t)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
* @note Led DeInit does not disable the GPIO clock
* @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;
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)
USART3_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)
USART3_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 = (uint32_t)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, USART3_MspInit) != HAL_OK)
{
ret = BSP_ERROR_PERIPH_FAILURE;
}
else if(HAL_UART_RegisterCallback(&hcom_uart[COM], HAL_UART_MSPDEINIT_CB_ID, USART3_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 */
#endif
/**
* @}
*/
/** @defgroup STM32H7B3I_DISCO_LOW_LEVEL_Private_Functions Private Functions
* @{
*/
#if (USE_BSP_COM_FEATURE > 0)
/**
* @brief Initializes UART MSP.
* @param huart UART handle
* @retval None
*/
static void USART3_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 USART3_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,299 @@
/**
******************************************************************************
* @file stm32h750b_discovery.h
* @author MCD Application Team
* @brief This file contains definitions for STM32H750B_DK:
* LEDs
* push-buttons
* COM ports
* hardware resources.
******************************************************************************
* @attention
*
* Copyright (c) 2018 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 STM32H750B_DK_H
#define STM32H750B_DK_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32h750b_discovery_conf.h"
#include "stm32h750b_discovery_errno.h"
#if (USE_BSP_COM_FEATURE > 0)
#if (USE_COM_LOG > 0)
#ifndef __GNUC__
#include "stdio.h"
#endif
#endif
#endif
/** @addtogroup BSP
* @{
*/
/** @addtogroup STM32H750B_DK
* @{
*/
/** @addtogroup STM32H750B_DK_LOW_LEVEL
* @{
*/
/** @defgroup STM32H750B_DK_LOW_LEVEL_Exported_Types Exported Types
* @{
*/
typedef enum
{
LED1 = 0,
LED_GREEN = LED1,
LED2 = 1,
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 STM32H750B_DK_LOW_LEVEL_Exported_Constants Exported Constants
* @{
*/
/**
* @brief Define for STM32H750B_DK board
*/
#if !defined (USE_STM32H750B_DK)
#define USE_STM32H750B_DK
#endif
/**
* @brief STM32H750B Discovery BSP Driver version number V3.3.3
*/
#define STM32H750B_DK_BSP_VERSION_MAIN (0x03) /*!< [31:24] main version */
#define STM32H750B_DK_BSP_VERSION_SUB1 (0x03) /*!< [23:16] sub1 version */
#define STM32H750B_DK_BSP_VERSION_SUB2 (0x03) /*!< [15:8] sub2 version */
#define STM32H750B_DK_BSP_VERSION_RC (0x00) /*!< [7:0] release candidate */
#define STM32H750B_DK_BSP_VERSION ((STM32H750B_DK_BSP_VERSION_MAIN << 24)\
|(STM32H750B_DK_BSP_VERSION_SUB1 << 16)\
|(STM32H750B_DK_BSP_VERSION_SUB2 << 8 )\
|(STM32H750B_DK_BSP_VERSION_RC))
#define STM32H750B_DK_BSP_BOARD_NAME "STM32H750B-DISCO";
#define STM32H750B_DK_BSP_BOARD_ID "MB1381B";
/** @defgroup STM32H750B_DK_LOW_LEVEL_LED EVAL LOW LEVEL LED
* @{
*/
#define LED1_GPIO_PORT GPIOJ
#define LED1_PIN GPIO_PIN_2
#define LED2_GPIO_PORT GPIOI
#define LED2_PIN GPIO_PIN_13
#define LED1_GPIO_CLK_ENABLE() __HAL_RCC_GPIOJ_CLK_ENABLE()
#define LED1_GPIO_CLK_DISABLE() __HAL_RCC_GPIOJ_CLK_DISABLE()
#define LED2_GPIO_CLK_ENABLE() __HAL_RCC_GPIOI_CLK_ENABLE()
#define LED2_GPIO_CLK_DISABLE() __HAL_RCC_GPIOI_CLK_DISABLE()
/**
* @}
*/
/** @defgroup STM32H750B_DK_LOW_LEVEL_BUTTON LOW LEVEL BUTTON
* @{
*/
/* Button state */
#define BUTTON_RELEASED 0U
#define BUTTON_PRESSED 1U
/**
* @brief USER push-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 STM32H750B_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_10
#define COM1_TX_GPIO_PORT GPIOB
#define COM1_TX_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define COM1_TX_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE()
#define COM1_TX_AF GPIO_AF7_USART3
#define COM1_RX_PIN GPIO_PIN_11
#define COM1_RX_GPIO_PORT GPIOB
#define COM1_RX_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define COM1_RX_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE()
#define COM1_RX_AF GPIO_AF7_USART3
#define COM_POLL_TIMEOUT 1000
#define MX_UART_InitTypeDef COM_InitTypeDef
#endif
/**
* @}
*/
/**
* @}
*/
/** @addtogroup STM32H750B_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 STM32H750B_DK_LOW_LEVEL_Exported_FunctionsPrototypes Exported Functions Prototypes
* @{
*/
int32_t BSP_GetVersion(void);
const uint8_t* BSP_GetBoardName(void);
const uint8_t* BSP_GetBoardID(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 > 0)
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 /* (USE_BSP_COM_FEATURE > 0) */
void BSP_PB_IRQHandler(Button_TypeDef Button);
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* STM32H750B_DK_H */
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,437 @@
/**
******************************************************************************
* @file stm32h750b_discovery_audio.h
* @author MCD Application Team
* @brief This file contains the common defines and functions prototypes for
* the stm32h750b_discovery_audio.c driver.
******************************************************************************
* @attention
*
* Copyright (c) 2018 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 STM32H750B_DK_AUDIO_H
#define STM32H750B_DK_AUDIO_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32h750b_discovery_conf.h"
#include "stm32h750b_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 STM32H750B_DK
* @{
*/
/** @addtogroup STM32H750B_DK_AUDIO
* @{
*/
/** @defgroup STM32H750B_DK_AUDIO_Exported_Types 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_t;
#if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
typedef struct
{
pSAI_CallbackTypeDef pMspSaiInitCb;
pSAI_CallbackTypeDef pMspSaiDeInitCb;
}BSP_AUDIO_OUT_Cb_t;
#endif /* (USE_HAL_SAI_REGISTER_CALLBACKS == 1) */
/**
* @}
*/
/** @defgroup STM32H750B_DK_AUDIO_Exported_Constants Exported Constants
* @{
*/
/* Audio codec I2C address */
#define AUDIO_I2C_ADDRESS 0x34U
/* Audio Out instances number */
#define AUDIO_OUT_INSTANCES_NBR 1U
/* 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 RESOLUTION */
#define AUDIO_RESOLUTION_16B 16U
#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
/* 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
/*------------------------------------------------------------------------------
USER SAI defines parameters
-----------------------------------------------------------------------------*/
/** 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 SAI2_Block_A
#define AUDIO_OUT_SAIx_CLK_ENABLE() __HAL_RCC_SAI2_CLK_ENABLE()
#define AUDIO_OUT_SAIx_CLK_DISABLE() __HAL_RCC_SAI2_CLK_DISABLE()
#define AUDIO_OUT_SAIx_MCLK_ENABLE() __HAL_RCC_GPIOI_CLK_ENABLE()
#define AUDIO_OUT_SAIx_MCLK_GPIO_PORT GPIOI
#define AUDIO_OUT_SAIx_MCLK_PIN GPIO_PIN_4
#define AUDIO_OUT_SAIx_MCLK_AF GPIO_AF10_SAI2
#define AUDIO_OUT_SAIx_SCK_ENABLE() __HAL_RCC_GPIOI_CLK_ENABLE()
#define AUDIO_OUT_SAIx_SCK_GPIO_PORT GPIOI
#define AUDIO_OUT_SAIx_SCK_PIN GPIO_PIN_5
#define AUDIO_OUT_SAIx_SCK_AF GPIO_AF10_SAI2
#define AUDIO_OUT_SAIx_SD_ENABLE() __HAL_RCC_GPIOI_CLK_ENABLE()
#define AUDIO_OUT_SAIx_SD_GPIO_PORT GPIOI
#define AUDIO_OUT_SAIx_SD_PIN GPIO_PIN_6
#define AUDIO_OUT_SAIx_SD_AF GPIO_AF10_SAI2
#define AUDIO_OUT_SAIx_FS_ENABLE() __HAL_RCC_GPIOI_CLK_ENABLE()
#define AUDIO_OUT_SAIx_FS_GPIO_PORT GPIOI
#define AUDIO_OUT_SAIx_FS_PIN GPIO_PIN_7
#define AUDIO_OUT_SAIx_FS_AF GPIO_AF10_SAI2
/* SAI DMA Stream definitions */
#define AUDIO_OUT_SAIx_DMAx_CLK_ENABLE() __HAL_RCC_DMA2_CLK_ENABLE()
#define AUDIO_OUT_SAIx_DMAx_STREAM DMA2_Stream1
#define AUDIO_OUT_SAIx_DMAx_REQUEST DMA_REQUEST_SAI2_A
#define AUDIO_OUT_SAIx_DMAx_IRQ DMA2_Stream1_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_Stream1_IRQHandler
/*------------------------------------------------------------------------------
AUDIO IN defines parameters
------------------------------------------------------------------------------*/
/* SAI peripheral configuration defines */
#define AUDIO_IN_SAIx SAI2_Block_B
#define AUDIO_IN_SAIx_CLK_ENABLE() __HAL_RCC_SAI2_CLK_ENABLE()
#define AUDIO_IN_SAIx_CLK_DISABLE() __HAL_RCC_SAI2_CLK_DISABLE()
#define AUDIO_IN_SAIx_AF GPIO_AF10_SAI2
#define AUDIO_IN_SAIx_SD_ENABLE() __HAL_RCC_GPIOG_CLK_ENABLE()
#define AUDIO_IN_SAIx_SD_GPIO_PORT GPIOG
#define AUDIO_IN_SAIx_SD_PIN GPIO_PIN_10
/* 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_SAI2_B
#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_CLK_IN_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE()
#define AUDIO_IN_SAI_PDMx_CLK_IN_PIN GPIO_PIN_5
#define AUDIO_IN_SAI_PDMx_CLK_IN_PORT GPIOE
#define AUDIO_IN_SAI_PDMx_DATA_IN_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE()
#define AUDIO_IN_SAI_PDMx_DATA_IN_PIN GPIO_PIN_4
#define AUDIO_IN_SAI_PDMx_DATA_IN_PORT GPIOE
#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
/* Audio In devices */
/* Analog microphone input from 3.5 audio jack connector */
#define AUDIO_IN_DEVICE_ANALOG_MIC 0x00U
/* MP34DT01TR digital microphone on PCB top side */
#define AUDIO_IN_DEVICE_DIGITAL_MIC1 0x10U
#define AUDIO_IN_DEVICE_DIGITAL_MIC2 0x20U
#define AUDIO_IN_DEVICE_DIGITAL_MIC_LAST AUDIO_IN_DEVICE_DIGITAL_MIC2
#define AUDIO_IN_DEVICE_DIGITAL_MIC (AUDIO_IN_DEVICE_DIGITAL_MIC1 | AUDIO_IN_DEVICE_DIGITAL_MIC2)
/* 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:
Instance 0 is SAI path
Instance 1 is SAI PDM path
*/
#define AUDIO_IN_INSTANCES_NBR 2U
/**
* @}
*/
/** @defgroup STM32H750B_DK_AUDIO_Exported_Macros Exported Macros
* @{
*/
#define POS_VAL(VAL) (POSITION_VAL(VAL) - 4)
#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 STM32H750B_DK_AUDIO_Exported_Variables
* @{
*/
/* Audio in and out component object */
extern void *Audio_CompObj;
/* Play */
extern SAI_HandleTypeDef haudio_out_sai;
extern AUDIO_OUT_Ctx_t Audio_Out_Ctx[];
extern SAI_HandleTypeDef haudio_in_sai;
extern AUDIO_IN_Ctx_t Audio_In_Ctx[];
/**
* @}
*/
/** @addtogroup STM32H750B_DK_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 == 1U)
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 == 1U) */
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_SAI2_ClockConfig(SAI_HandleTypeDef *hsai, uint32_t SampleRate);
HAL_StatusTypeDef MX_SAI4_ClockConfig(SAI_HandleTypeDef *hsai, uint32_t SampleRate);
HAL_StatusTypeDef MX_SAI2_Block_A_Init(SAI_HandleTypeDef* hsai, MX_SAI_Config_t *MXConfig);
/**
* @}
*/
/** @addtogroup STM32H750B_DK_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);
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_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);
/* 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);
int32_t BSP_AUDIO_IN_RecordPDM(uint32_t Instance, uint8_t* pBuf, uint32_t NbrOfBytes);
void BSP_AUDIO_IN_IRQHandler(uint32_t Instance, uint32_t InputDevice);
/* 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_SAI2_Block_B_Init(SAI_HandleTypeDef* hsai, MX_SAI_Config_t *MXConfig);
HAL_StatusTypeDef MX_SAI4_Block_A_Init(SAI_HandleTypeDef* hsai, MX_SAI_Config_t *MXConfig);
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* STM32H750B_DK_AUDIO_H */
@@ -0,0 +1,880 @@
/**
******************************************************************************
* @file stm32h750b_discovery_bus.c
* @author MCD Application Team
* @brief This file provides a set of firmware functions to communicate
* with external devices available on STM32H750B-DK board (MB1381) 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 "stm32h750b_discovery_bus.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup STM32H750B_DK
* @{
*/
/** @defgroup STM32H750B_DK_BUS BUS
* @{
*/
/** @defgroup STM32H750B_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 STM32H750B_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;
/**
* @}
*/
/** @addtogroup STM32H750B_DK_BUS_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 STM32H750B_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 STM32H750B_DK_BUS_Exported_Variables Exported Variables
* @{
*/
I2C_HandleTypeDef hbus_i2c4;
/**
* @}
*/
/** @defgroup STM32H750B_DK_BUS_Private_FunctionPrototypes BUS 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 STM32H750B_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)
{
I2c4InitCounter++;
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;
}
}
if (ret == BSP_ERROR_NONE)
{
#endif
if (MX_I2C4_Init(&hbus_i2c4, I2C_GetTiming(HAL_RCC_GetPCLK2Freq(), BUS_I2C4_FREQUENCY)) != HAL_OK)
{
ret = BSP_ERROR_BUS_FAILURE;
}
#if (USE_HAL_I2C_REGISTER_CALLBACKS == 1)
}
#endif
}
}
return ret;
}
/**
* @brief DeInitializes I2C HAL.
* @retval BSP status
*/
int32_t BSP_I2C4_DeInit(void)
{
int32_t ret = BSP_ERROR_NONE;
I2c4InitCounter--;
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_ANALOGFILTER_ENABLE;
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 STM32H750B_DK_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_ANALOG_FILTER_DELAY_MIN;
tafdel_max = I2C_ANALOG_FILTER_DELAY_MAX;
/* 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_ANALOG_FILTER_DELAY_MIN;
/* 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_NOPULL;
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.Mode = GPIO_MODE_AF_OD;
gpio_init_structure.Pull = GPIO_NOPULL;
gpio_init_structure.Speed = GPIO_SPEED_FREQ_HIGH;
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 DevAddr 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
* @param pData The target register value to be read
* @param Length data length in bytes
* @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,136 @@
/**
******************************************************************************
* @file stm32h750b_discovery_bus.h
* @author MCD Application Team
* @brief This file is the header of stm32h750b_discovery_bus.h 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 STM32H750B_DK_BUS_H
#define STM32H750B_DK_BUS_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32h750b_discovery_conf.h"
#include "stm32h750b_discovery_errno.h"
#if defined(BSP_USE_CMSIS_OS)
#include "cmsis_os.h"
#endif
/** @addtogroup BSP
* @{
*/
/** @addtogroup STM32H750B_DK
* @{
*/
/** @addtogroup STM32H750B_DK_BUS
* @{
*/
/** @defgroup STM32H750B_DK_BUS_Exported_Types Exported Types
* @{
*/
#if (USE_HAL_I2C_REGISTER_CALLBACKS == 1)
typedef struct
{
void (* pMspInitCb)(I2C_HandleTypeDef *);
void (* pMspDeInitCb)(I2C_HandleTypeDef *);
}BSP_I2C_Cb_t;
#endif /* (USE_HAL_I2C_REGISTER_CALLBACKS == 1) */
/**
* @}
*/
/** @defgroup STM32H750B_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_GPIOD_CLK_ENABLE()
#define BUS_I2C4_SCL_GPIO_CLK_DISABLE() __HAL_RCC_GPIOD_CLK_DISABLE()
#define BUS_I2C4_SDA_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE()
#define BUS_I2C4_SDA_GPIO_CLK_DISABLE() __HAL_RCC_GPIOD_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_12
#define BUS_I2C4_SDA_PIN GPIO_PIN_13
#define BUS_I2C4_SCL_GPIO_PORT GPIOD
#define BUS_I2C4_SDA_GPIO_PORT GPIOD
#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 STM32H750B_DK_BUS_Exported_Variables
* @{
*/
extern I2C_HandleTypeDef hbus_i2c4;
/**
* @}
*/
/** @addtogroup STM32H750B_DK_BUS_Exported_Functions
* @{
*/
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 /* STM32H750B_DK_BUS_H */
@@ -0,0 +1,69 @@
/**
******************************************************************************
* @file stm32h750b_discovery_conf_template.h
* @author MCD Application Team
* @brief STM32H750B-DK 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 STM32H750B_DK_CONF_H
#define STM32H750B_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
/* Touch controllers defines */
#define USE_FT5336_TS_CTRL 1U
#define LCD_LAYER_0_ADDRESS 0xD0000000U
#define LCD_LAYER_1_ADDRESS 0xD0200000U
/* Audio codecs defines */
#define USE_AUDIO_CODEC_WM8994 1U
/* Default Audio IN internal buffer size */
#define DEFAULT_AUDIO_IN_BUFFER_SIZE 64U
/* TS supported features defines */
#define USE_TS_GESTURE 1U
#define USE_TS_MULTI_TOUCH 1U
/* Default TS touch number */
#define TS_TOUCH_NBR 2U
/* IRQ priorities */
#define BSP_SDRAM_IT_PRIORITY 15U
#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 /* STM32H750B_DK_CONF_H */
@@ -0,0 +1,65 @@
/**
******************************************************************************
* @file stm32h750b_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 STM32H750B_DK_ERRNO_H
#define STM32H750B_DK_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_QSPI_ASSIGN_FAILURE -24
#define BSP_ERROR_QSPI_SETUP_FAILURE -25
#define BSP_ERROR_QSPI_MMP_LOCK_FAILURE -26
#define BSP_ERROR_QSPI_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 /* STM32H750B_DK_ERRNO_H */
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,312 @@
/**
******************************************************************************
* @file stm32h750b_discovery_lcd.h
* @author MCD Application Team
* @brief This file contains the common defines and functions prototypes for
* the stm32h750b_discovery_lcd.c driver.
******************************************************************************
* @attention
*
* Copyright (c) 2018 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 STM32H750B_DK_LCD_H
#define STM32H750B_DK_LCD_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32h750b_discovery_conf.h"
#include "stm32h750b_discovery_errno.h"
#ifndef USE_LCD_CTRL_RK043FN48H
#define USE_LCD_CTRL_RK043FN48H 1
#endif
#if (USE_LCD_CTRL_RK043FN48H == 1)
/* Include RK043FN48H LCD Driver IC driver code */
#include "../Components/rk043fn48h/rk043fn48h.h"
#endif
#include "lcd.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup STM32H750B_DK
* @{
*/
/** @defgroup STM32H750B_DK_LCD LCD
* @{
*/
/** @defgroup STM32H750B_DK_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 reset pin */
#define LCD_RESET_PIN GPIO_PIN_2
#define LCD_RESET_PULL GPIO_NOPULL
#define LCD_RESET_GPIO_PORT GPIOA
#define LCD_RESET_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
#define LCD_RESET_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE()
/* LCD display enable pin */
#define LCD_DISP_EN_PIN GPIO_PIN_7
#define LCD_DISP_EN_GPIO_PORT GPIOK
#define LCD_DISP_EN_GPIO_CLK_ENABLE() __HAL_RCC_GPIOK_CLK_ENABLE()
#define LCD_DISP_EN_GPIO_CLK_DISABLE() __HAL_RCC_GPIOK_CLK_DISABLE()
/* Back-light control pin */
#define LCD_BL_CTRL_PIN GPIO_PIN_0
#define LCD_BL_CTRL_GPIO_PORT GPIOK
#define LCD_BL_CTRL_GPIO_CLK_ENABLE() __HAL_RCC_GPIOK_CLK_ENABLE()
#define LCD_BL_CTRL_GPIO_CLK_DISABLE() __HAL_RCC_GPIOK_CLK_DISABLE()
/**
* @brief Definition for LCD Timer used to control the Brightnes
*/
#define LCD_TIMx TIM8
#define LCD_TIMx_CLK_ENABLE() __HAL_RCC_TIM8_CLK_ENABLE()
#define LCD_TIMx_CLK_DISABLE() __HAL_RCC_TIM8_CLK_DISABLE()
#define LCD_TIMx_CHANNEL TIM_CHANNEL_3
#define LCD_TIMx_CHANNEL_AF GPIO_AF3_TIM8
#define LCD_TIMX_PERIOD_VALUE ((uint32_t)50000) /* Period Value */
#define LCD_TIMX_PRESCALER_VALUE ((uint32_t)4) /* Prescaler Value */
/* 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 STM32H750B_DK_LCD_Exported_Types Exported Types
* @{
*/
typedef struct
{
uint32_t XSize;
uint32_t YSize;
uint32_t ActiveLayer;
uint32_t PixelFormat;
uint32_t BppFactor;
uint32_t IsMspCallbacksValid;
uint32_t ReloadEnable;
uint32_t Brightness;
} 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 STM32H750B_DK_LCD_Exported_Variables
* @{
*/
extern const LCD_UTILS_Drv_t LCD_Driver;
extern DMA2D_HandleTypeDef hlcd_dma2d;
extern LTDC_HandleTypeDef hlcd_ltdc;
extern BSP_LCD_Ctx_t LcdCtx[];
/**
* @}
*/
/** @defgroup STM32H750B_DK_LCD_Exported_FunctionsPrototypes Exported Functions Prototypes
* @{
*/
/* 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);
/* 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 STM32H750B_DK_LCD_Private_Constants Private Constants
* @{
*/
/* Legacy defines */
#define LCD_ORIENTATION_PORTRAIT 0x00U /* Portrait orientation choice of LCD screen */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* STM32H750B_DK_LCD_H */
@@ -0,0 +1,658 @@
/**
******************************************************************************
* @file stm32h750b_discovery_mmc.c
* @author MCD Application Team
* @brief This file includes the EMMC driver mounted on STM32H750B-DK
* board.
******************************************************************************
* @attention
*
* Copyright (c) 2018 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 EMMC mounted on STM32H750B-DK board.
- This driver does not need a specific component driver for the EMMC device
to be included with.
2. Driver description:
---------------------
+ Initialization steps:
o Initialize the external EMMC memory using the BSP_MMC_Init() function. This
function includes the MSP layer hardware resources initialization and the
SDIO interface configuration to interface with the external EMMC. It
also includes the EMMC initialization sequence.
o The function BSP_MMC_GetCardInfo() is used to get the MMC information
which is stored in the structure "HAL_MMC_CardInfoTypedef".
+ Micro MMC card operations
o The micro MMC 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_MMC_ReadBlocks()/BSP_MMC_WriteBlocks(), or by DMA
transfer using the functions BSP_MMC_ReadBlocks_DMA()/BSP_MMC_WriteBlocks_DMA()
o The DMA transfer complete is used with interrupt mode. Once the MMC transfer
is complete, the MMC interrupt is handled using the function BSP_MMC_IRQHandler(),
the DMA Tx/Rx transfer complete are handled using the functions
MMC_DMA_Tx_IRQHandler()/MMC_DMA_Rx_IRQHandler() that should be defined by user.
The corresponding user callbacks are implemented by the user at application level.
o The MMC erase block(s) is performed using the function BSP_MMC_Erase() with specifying
the number of blocks to erase.
o The MMC runtime status is returned when calling the function BSP_MMC_GetStatus().
------------------------------------------------------------------------------*/
/* Includes ------------------------------------------------------------------*/
#include "stm32h750b_discovery_mmc.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup STM32H750B_DK
* @{
*/
/** @defgroup STM32H750B_DK_MMC MMC
* @{
*/
/** @defgroup STM32H750B_DK_MMC_Exported_Variables Exported Variables
* @{
*/
MMC_HandleTypeDef hsd_sdmmc[MMC_INSTANCES_NBR];
/**
* @}
*/
/** @defgroup STM32H750B_DK_MMC_Private_FunctionsPrototypes Private Functions Prototypes
* @{
*/
static void MMC_MspInit(MMC_HandleTypeDef *hmmc);
static void MMC_MspDeInit(MMC_HandleTypeDef *hmmc);
#if (USE_HAL_MMC_REGISTER_CALLBACKS == 1)
static void MMC_AbortCallback(MMC_HandleTypeDef *hmmc);
static void MMC_TxCpltCallback(MMC_HandleTypeDef *hmmc);
static void MMC_RxCpltCallback(MMC_HandleTypeDef *hmmc);
#endif
/**
* @}
*/
/** @defgroup STM32H750B_DK_MMC_Exported_Functions Exported Functions
* @{
*/
/**
* @brief Initializes the MMC card device.
* @param Instance SDMMC Instance
* @retval BSP status
*/
int32_t BSP_MMC_Init(uint32_t Instance)
{
int32_t ret = BSP_ERROR_NONE;
if(Instance >= MMC_INSTANCES_NBR)
{
ret = BSP_ERROR_WRONG_PARAM;
}
else
{
#if (USE_HAL_MMC_REGISTER_CALLBACKS == 0)
/* Msp MMC initialization */
MMC_MspInit(&hsd_sdmmc[Instance]);
#else
/* Register the MMC MSP Callbacks */
if(IsMspCallbacksValid[Instance] == 0UL)
{
if(BSP_MMC_RegisterDefaultMspCallbacks(Instance) != BSP_ERROR_NONE)
{
ret = BSP_ERROR_PERIPH_FAILURE;
}
}
if(ret == BSP_ERROR_NONE)
{
#endif
/* HAL MMC initialization */
if(MX_MMC_SD_Init(&hsd_sdmmc[Instance]) != HAL_OK)
{
ret = BSP_ERROR_PERIPH_FAILURE;
}
#if (USE_HAL_MMC_REGISTER_CALLBACKS == 1)
/* Register MMC TC, HT and Abort callbacks */
else if(HAL_MMC_RegisterCallback(&hsd_sdmmc[Instance], HAL_MMC_TX_CPLT_CB_ID, MMC_TxCpltCallback) != HAL_OK)
{
ret = BSP_ERROR_PERIPH_FAILURE;
}
else if(HAL_MMC_RegisterCallback(&hsd_sdmmc[Instance], HAL_MMC_RX_CPLT_CB_ID, MMC_RxCpltCallback) != HAL_OK)
{
ret = BSP_ERROR_PERIPH_FAILURE;
}
else
{
if(HAL_MMC_RegisterCallback(&hsd_sdmmc[Instance], HAL_MMC_ABORT_CB_ID, MMC_AbortCallback) != HAL_OK)
{
ret = BSP_ERROR_PERIPH_FAILURE;
}
}
}
#endif /* USE_HAL_MMC_REGISTER_CALLBACKS */
}
return ret;
}
/**
* @brief DeInitializes the MMC card device.
* @param Instance SDMMC Instance
* @retval BSP status
*/
int32_t BSP_MMC_DeInit(uint32_t Instance)
{
int32_t ret = BSP_ERROR_NONE;
if(Instance >= MMC_INSTANCES_NBR)
{
ret = BSP_ERROR_WRONG_PARAM;
}/* HAL MMC deinitialization */
else if(HAL_MMC_DeInit(&hsd_sdmmc[Instance]) != HAL_OK)
{
ret = BSP_ERROR_PERIPH_FAILURE;
}
else
{
/* Msp MMC de-initialization */
#if (USE_HAL_MMC_REGISTER_CALLBACKS == 0)
MMC_MspDeInit(&hsd_sdmmc[Instance]);
#endif /* (USE_HAL_MMC_REGISTER_CALLBACKS == 0) */
}
return ret;
}
/**
* @brief Initializes the SDMMC1 peripheral.
* @param hmmc SD handle
* @retval HAL status
*/
__weak HAL_StatusTypeDef MX_MMC_SD_Init(MMC_HandleTypeDef *hmmc)
{
HAL_StatusTypeDef ret = HAL_OK;
hmmc->Instance = SDMMC1;
hmmc->Init.ClockDiv = 2;
hmmc->Init.ClockPowerSave = SDMMC_CLOCK_POWER_SAVE_DISABLE;
hmmc->Init.ClockEdge = SDMMC_CLOCK_EDGE_RISING;
hmmc->Init.HardwareFlowControl = SDMMC_HARDWARE_FLOW_CONTROL_ENABLE;
hmmc->Init.BusWide = SDMMC_BUS_WIDE_8B;
/* HAL SD initialization */
if(HAL_MMC_Init(hmmc) != HAL_OK)
{
ret = HAL_ERROR;
}
return ret;
}
#if (USE_HAL_MMC_REGISTER_CALLBACKS == 1)
/**
* @brief Default BSP MMC Msp Callbacks
* @param Instance SDMMC Instance
* @retval BSP status
*/
int32_t BSP_MMC_RegisterDefaultMspCallbacks(uint32_t Instance)
{
int32_t ret = BSP_ERROR_NONE;
if(Instance >= MMC_INSTANCES_NBR)
{
ret = BSP_ERROR_WRONG_PARAM;
}
else
{
/* Register MspInit/MspDeInit Callbacks */
if(HAL_MMC_RegisterCallback(&hsd_sdmmc[Instance], HAL_MMC_MSP_INIT_CB_ID, MMC_MspInit) != HAL_OK)
{
ret = BSP_ERROR_PERIPH_FAILURE;
}
else if(HAL_MMC_RegisterCallback(&hsd_sdmmc[Instance], HAL_MMC_MSP_DEINIT_CB_ID, MMC_MspDeInit) != HAL_OK)
{
ret = BSP_ERROR_PERIPH_FAILURE;
}
else
{
IsMspCallbacksValid[Instance] = 1U;
}
}
/* Return BSP status */
return ret;
}
/**
* @brief BSP MMC Msp Callback registering
* @param Instance SDMMC Instance
* @param CallBacks pointer to MspInit/MspDeInit callbacks functions
* @retval BSP status
*/
int32_t BSP_MMC_RegisterMspCallbacks(uint32_t Instance, BSP_MMC_Cb_t *CallBacks)
{
int32_t ret = BSP_ERROR_NONE;
if(Instance >= MMC_INSTANCES_NBR)
{
ret = BSP_ERROR_WRONG_PARAM;
}
else
{
/* Register MspInit/MspDeInit Callbacks */
if(HAL_MMC_RegisterCallback(&hsd_sdmmc[Instance], HAL_MMC_MSP_INIT_CB_ID, CallBacks->pMspInitCb) != HAL_OK)
{
ret = BSP_ERROR_PERIPH_FAILURE;
}
else if(HAL_MMC_RegisterCallback(&hsd_sdmmc[Instance], HAL_MMC_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_MMC_REGISTER_CALLBACKS == 1) */
/**
* @brief Reads block(s) from a specified address in an SD card, in polling mode.
* @param Instance MMC 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 MMC blocks to read
* @retval BSP status
*/
int32_t BSP_MMC_ReadBlocks(uint32_t Instance, uint32_t *pData, uint32_t BlockIdx, uint32_t BlocksNbr)
{
uint32_t timeout = MMC_READ_TIMEOUT*BlocksNbr;
int32_t ret;
if(Instance >= MMC_INSTANCES_NBR)
{
ret = BSP_ERROR_WRONG_PARAM;
}
else if(HAL_MMC_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 MMC 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 MMC blocks to write
* @retval BSP status
*/
int32_t BSP_MMC_WriteBlocks(uint32_t Instance, uint32_t *pData, uint32_t BlockIdx, uint32_t BlocksNbr)
{
uint32_t timeout = MMC_READ_TIMEOUT*BlocksNbr;
int32_t ret;
if(Instance >= MMC_INSTANCES_NBR)
{
ret = BSP_ERROR_WRONG_PARAM;
}
else if(HAL_MMC_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 MMC 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 MMC blocks to read
* @retval BSP status
*/
int32_t BSP_MMC_ReadBlocks_DMA(uint32_t Instance, uint32_t *pData, uint32_t BlockIdx, uint32_t BlocksNbr)
{
int32_t ret;
if(Instance >= MMC_INSTANCES_NBR)
{
ret = BSP_ERROR_WRONG_PARAM;
}
else if(HAL_MMC_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 MMC 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 MMC blocks to write
* @retval BSP status
*/
int32_t BSP_MMC_WriteBlocks_DMA(uint32_t Instance, uint32_t *pData, uint32_t BlockIdx, uint32_t BlocksNbr)
{
int32_t ret;
if(Instance >= MMC_INSTANCES_NBR)
{
ret = BSP_ERROR_WRONG_PARAM;
}
else if(HAL_MMC_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 Erases the specified memory area of the given MMC card.
* @param Instance MMC Instance
* @param StartAddr : Start byte address
* @param EndAddr : End byte address
* @retval BSP status
*/
int32_t BSP_MMC_Erase(uint32_t Instance, uint32_t StartAddr, uint32_t EndAddr)
{
int32_t ret;
if(Instance >= MMC_INSTANCES_NBR)
{
ret = BSP_ERROR_WRONG_PARAM;
}
else if( HAL_MMC_Erase(&hsd_sdmmc[Instance], StartAddr, EndAddr) != HAL_OK)
{
ret = BSP_ERROR_PERIPH_FAILURE;
}
else
{
ret = BSP_ERROR_NONE;
}
return ret ;
}
/**
* @brief Handles MMC card interrupt request.
* @param Instance MMC Instance
* @retval None
*/
void BSP_MMC_IRQHandler(uint32_t Instance)
{
HAL_MMC_IRQHandler(&hsd_sdmmc[Instance]);
}
/**
* @brief Gets the current MMC card data status.
* @param Instance MMC Instance
* @retval Data transfer state.
* This value can be one of the following values:
* @arg MMC_TRANSFER_OK: No data transfer is acting
* @arg MMC_TRANSFER_BUSY: Data transfer is acting
* @arg MMC_TRANSFER_ERROR: Data transfer error
*/
int32_t BSP_MMC_GetCardState(uint32_t Instance)
{
return((HAL_MMC_GetCardState(&hsd_sdmmc[Instance]) == HAL_MMC_CARD_TRANSFER ) ? MMC_TRANSFER_OK : MMC_TRANSFER_BUSY);
}
/**
* @brief Get MMC information about specific MMC card.
* @param Instance MMC Instance
* @param CardInfo : Pointer to HAL_MMC_CardInfoTypedef structure
* @retval None
*/
int32_t BSP_MMC_GetCardInfo(uint32_t Instance, BSP_MMC_CardInfo *CardInfo)
{
int32_t ret;
if(Instance >= MMC_INSTANCES_NBR)
{
ret = BSP_ERROR_WRONG_PARAM;
}
else if(HAL_MMC_GetCardInfo(&hsd_sdmmc[Instance], CardInfo) != HAL_OK)
{
ret = BSP_ERROR_PERIPH_FAILURE;
}
else
{
ret = BSP_ERROR_NONE;
}
/* Return BSP status */
return ret;
}
/**
* @brief BSP MMC Abort callbacks
* @param Instance MMC Instance
* @retval None
*/
__weak void BSP_MMC_AbortCallback(uint32_t Instance)
{
/* Prevent unused argument(s) compilation warning */
UNUSED(Instance);
}
/**
* @brief BSP Tx Transfer completed callbacks
* @param Instance MMC Instance
* @retval None
*/
__weak void BSP_MMC_WriteCpltCallback(uint32_t Instance)
{
/* Prevent unused argument(s) compilation warning */
UNUSED(Instance);
}
/**
* @brief BSP Rx Transfer completed callbacks
* @param Instance MMC Instance
* @retval None
*/
__weak void BSP_MMC_ReadCpltCallback(uint32_t Instance)
{
/* Prevent unused argument(s) compilation warning */
UNUSED(Instance);
}
#if (USE_HAL_MMC_REGISTER_CALLBACKS == 0)
/**
* @brief MMC Abort callbacks
* @param hmmc : MMC handle
* @retval None
*/
void HAL_MMC_AbortCallback(MMC_HandleTypeDef *hmmc)
{
BSP_MMC_AbortCallback(0);
}
/**
* @brief Tx Transfer completed callbacks
* @param hmmc: MMC handle
* @retval None
*/
void HAL_MMC_TxCpltCallback(MMC_HandleTypeDef *hmmc)
{
BSP_MMC_WriteCpltCallback(0);
}
/**
* @brief Rx Transfer completed callbacks
* @param hmmc: MMC handle
* @retval None
*/
void HAL_MMC_RxCpltCallback(MMC_HandleTypeDef *hmmc)
{
BSP_MMC_ReadCpltCallback(0);
}
#endif
/**
* @}
*/
/** @defgroup STM32H750B_DK_MMC_Private_Functions Private Functions
* @{
*/
/**
* @brief Initializes the MMC MSP.
* @param hmmc MMC handle
* @retval None
*/
static void MMC_MspInit(MMC_HandleTypeDef *hmmc)
{
/* Prevent unused argument(s) compilation warning */
UNUSED(hmmc);
/* __weak function can be modified by the application */
GPIO_InitTypeDef gpio_init_structure;
/* Enable SDIO clock */
__HAL_RCC_SDMMC1_CLK_ENABLE();
/* Enable GPIOs clock */
__HAL_RCC_GPIOB_CLK_ENABLE();
__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;
gpio_init_structure.Alternate = GPIO_AF12_SDIO1;
/* SDMMC GPIO CLKIN PB8, D0 PC8, D1 PC9, D2 PC10, D3 PC11, CK PC12, CMD PD2 */
/* GPIOC configuration */
gpio_init_structure.Pin = GPIO_PIN_6 | GPIO_PIN_7 | 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.Pin = GPIO_PIN_2;
HAL_GPIO_Init(GPIOD, &gpio_init_structure);
gpio_init_structure.Pin = GPIO_PIN_8 | GPIO_PIN_9;
HAL_GPIO_Init(GPIOB, &gpio_init_structure);
/* NVIC configuration for SDIO interrupts */
HAL_NVIC_SetPriority(SDMMC1_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(SDMMC1_IRQn);
}
/**
* @brief DeInitializes the MMC MSP.
* @param hmmc : MMC handle
* @retval None
*/
static void MMC_MspDeInit(MMC_HandleTypeDef *hmmc)
{
/* Prevent unused argument(s) compilation warning */
UNUSED(hmmc);
/* Disable NVIC for SDIO interrupts */
HAL_NVIC_DisableIRQ(SDMMC1_IRQn);
/* DeInit GPIO pins can be done in the application
(by surcharging this __weak function) */
/* Disable SDMMC1 clock */
__HAL_RCC_SDMMC1_CLK_DISABLE();
/* GPIO pins clock and DMA clocks can be shut down in the application
by surcharging this __weak function */
}
#if (USE_HAL_MMC_REGISTER_CALLBACKS == 1)
/**
* @brief MMC Abort callbacks
* @param hmmc : MMC handle
* @retval None
*/
static void MMC_AbortCallback(MMC_HandleTypeDef *hmmc)
{
BSP_MMC_AbortCallback(0);
}
/**
* @brief Tx Transfer completed callbacks
* @param hmmc : MMC handle
* @retval None
*/
static void MMC_TxCpltCallback(MMC_HandleTypeDef *hmmc)
{
BSP_MMC_WriteCpltCallback(0);
}
/**
* @brief Rx Transfer completed callbacks
* @param hmmc : MMC handle
* @retval None
*/
static void MMC_RxCpltCallback(MMC_HandleTypeDef *hmmc)
{
BSP_MMC_ReadCpltCallback(0);
}
#endif
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
@@ -0,0 +1,145 @@
/**
******************************************************************************
* @file stm32h750b_discovery_mmc.h
* @author MCD Application Team
* @brief This file contains the common defines and functions prototypes for
* the stm32h750b_discovery_mmc.c driver.
******************************************************************************
* @attention
*
* Copyright (c) 2018 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 STM32H750B_DK_MMC_H
#define STM32H750B_DK_MMC_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32h750b_discovery_conf.h"
#include "stm32h750b_discovery_errno.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup STM32H750B_DK
* @{
*/
/** @addtogroup STM32H750B_DK_MMC
* @{
*/
/** @defgroup STM32H750B_DK_MMC_Exported_Types Exported Types
* @{
*/
/**
* @brief SD Card information structure
*/
#define BSP_MMC_CardInfo HAL_MMC_CardInfoTypeDef
#if (USE_HAL_MMC_REGISTER_CALLBACKS == 1)
typedef struct
{
pMMC_CallbackTypeDef pMspInitCb;
pMMC_CallbackTypeDef pMspDeInitCb;
}BSP_MMC_Cb_t;
#endif /* (USE_HAL_MMC_REGISTER_CALLBACKS == 1) */
/**
* @}
*/
/** @defgroup STM32H750B_DK_MMC_Exported_Constants Exported Constants
* @{
*/
/**
* @brief MMC status structure definition
*/
#define MMC_INSTANCES_NBR 1UL
/**
* @brief MMC read/write timeout
*/
#ifndef MMC_WRITE_TIMEOUT
#define MMC_WRITE_TIMEOUT 100U
#endif
#ifndef MMC_READ_TIMEOUT
#define MMC_READ_TIMEOUT 100U
#endif
/**
* @brief MMC transfer state definition
*/
#define MMC_TRANSFER_OK 0U
#define MMC_TRANSFER_BUSY 1U
#define MMC_PRESENT 1UL
#define MMC_NOT_PRESENT 0UL
/**
* @}
*/
/** @addtogroup STM32H750B_DK_MMC_Exported_Variables
* @{
*/
extern MMC_HandleTypeDef hsd_sdmmc[MMC_INSTANCES_NBR];
/**
* @}
*/
/** @addtogroup STM32H750B_DK_MMC_Exported_Functions
* @{
*/
int32_t BSP_MMC_Init(uint32_t Instance);
int32_t BSP_MMC_DeInit(uint32_t Instance);
int32_t BSP_MMC_ReadBlocks(uint32_t Instance, uint32_t *pData, uint32_t BlockIdx, uint32_t BlocksNbr);
int32_t BSP_MMC_WriteBlocks(uint32_t Instance, uint32_t *pData, uint32_t BlockIdx, uint32_t NbrOfBlocks);
int32_t BSP_MMC_ReadBlocks_DMA(uint32_t Instance, uint32_t *pData, uint32_t BlockIdx, uint32_t NbrOfBlocks);
int32_t BSP_MMC_WriteBlocks_DMA(uint32_t Instance, uint32_t *pData, uint32_t BlockIdx, uint32_t NbrOfBlocks);
int32_t BSP_MMC_Erase(uint32_t Instance,uint32_t StartAddr, uint32_t EndAddr);
int32_t BSP_MMC_GetCardState(uint32_t Instance);
int32_t BSP_MMC_GetCardInfo(uint32_t Instance, BSP_MMC_CardInfo *CardInfo);
void BSP_MMC_IRQHandler(uint32_t Instance);
HAL_StatusTypeDef MX_MMC_SD_Init(MMC_HandleTypeDef *hmmc);
/* These functions can be modified in case the current settings (e.g. DMA stream)
need to be changed for specific application needs */
void BSP_MMC_AbortCallback(uint32_t Instance);
void BSP_MMC_WriteCpltCallback(uint32_t Instance);
void BSP_MMC_ReadCpltCallback(uint32_t Instance);
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* STM32H750B_DK_MMC_H */
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,245 @@
/**
******************************************************************************
* @file stm32h750b_discovery_qspi.h
* @author MCD Application Team
* @brief This file contains the common defines and functions prototypes for
* the stm32h750b_discovery_qspi.c driver.
******************************************************************************
* @attention
*
* Copyright (c) 2018 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 STM32H750B_DK_QSPI_H
#define STM32H750B_DK_QSPI_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32h750b_discovery_conf.h"
#include "stm32h750b_discovery_errno.h"
#include "../Components/mt25tl01g/mt25tl01g.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup STM32H750B_DK
* @{
*/
/** @addtogroup STM32H750B_DK_QSPI
* @{
*/
/* Exported types ------------------------------------------------------------*/
/** @defgroup STM32H750B_DK_QSPI_Exported_Types Exported Types
* @{
*/
#define BSP_QSPI_Info_t MT25TL01G_Info_t
#define BSP_QSPI_Interface_t MT25TL01G_Interface_t
#define BSP_QSPI_Transfer_t MT25TL01G_Transfer_t
#define BSP_QSPI_DualFlash_t MT25TL01G_DualFlash_t
#define BSP_QSPI_ODS_t MT25TL01G_ODS_t
typedef enum
{
BSP_QSPI_ERASE_8K = MT25TL01G_ERASE_4K , /*!< 8K size Sector erase = 2 x 4K as Dual flash mode is used for this board */
BSP_QSPI_ERASE_64K = MT25TL01G_ERASE_32K , /*!< 64K size Sector erase = 2 x 32K as Dual flash mode is used for this board */
BSP_QSPI_ERASE_128K = MT25TL01G_ERASE_64K , /*!< 128K size Sector erase = 2 x 64K as Dual mode is used for this board */
BSP_QSPI_ERASE_CHIP = MT25TL01G_ERASE_CHIP /*!< Whole chip erase */
} BSP_QSPI_Erase_t;
typedef enum
{
QSPI_ACCESS_NONE = 0, /*!< Instance not initialized, */
QSPI_ACCESS_INDIRECT, /*!< Instance use indirect mode access */
QSPI_ACCESS_MMP /*!< Instance use Memory Mapped Mode read */
} BSP_QSPI_Access_t;
typedef struct
{
BSP_QSPI_Access_t IsInitialized; /*!< Instance access Flash method */
BSP_QSPI_Interface_t InterfaceMode; /*!< Flash Interface mode of Instance */
BSP_QSPI_Transfer_t TransferRate; /*!< Flash Transfer mode of Instance */
uint32_t DualFlashMode; /*!< Flash dual mode */
uint32_t IsMspCallbacksValid;
} BSP_QSPI_Ctx_t;
typedef struct
{
BSP_QSPI_Interface_t InterfaceMode; /*!< Current Flash Interface mode */
BSP_QSPI_Transfer_t TransferRate; /*!< Current Flash Transfer mode */
BSP_QSPI_DualFlash_t DualFlashMode; /*!< Dual Flash mode */
} BSP_QSPI_Init_t;
typedef struct
{
uint32_t FlashSize;
uint32_t ClockPrescaler;
uint32_t SampleShifting;
uint32_t DualFlashMode;
}MX_QSPI_Init_t;
#if (USE_HAL_QSPI_REGISTER_CALLBACKS == 1)
typedef struct
{
void(*pMspInitCb)(pQSPI_CallbackTypeDef);
void(*pMspDeInitCb)(pQSPI_CallbackTypeDef);
}BSP_QSPI_Cb_t;
#endif /* (USE_HAL_QSPI_REGISTER_CALLBACKS == 1) */
/**
* @}
*/
/* Exported constants --------------------------------------------------------*/
/** @defgroup STM32H750B_DK_QSPI_Exported_Constants Exported Constants
* @{
*/
/* QSPI instances number */
#define QSPI_INSTANCES_NUMBER 1U
/* Definition for QSPI modes */
#define BSP_QSPI_SPI_MODE (BSP_QSPI_Interface_t)MT25TL01G_SPI_MODE /* 1 Cmd Line, 1 Address Line and 1 Data Line */
#define BSP_QSPI_SPI_1I2O_MODE (BSP_QSPI_Interface_t)MT25TL01G_SPI_1I2O_MODE /* 1 Cmd Line, 1 Address Line and 2 Data Lines */
#define BSP_QSPI_SPI_2IO_MODE (BSP_QSPI_Interface_t)MT25TL01G_SPI_2IO_MODE /* 1 Cmd Line, 2 Address Lines and 2 Data Lines */
#define BSP_QSPI_SPI_1I4O_MODE (BSP_QSPI_Interface_t)MT25TL01G_SPI_1I4O_MODE /* 1 Cmd Line, 1 Address Line and 4 Data Lines */
#define BSP_QSPI_SPI_4IO_MODE (BSP_QSPI_Interface_t)MT25TL01G_SPI_4IO_MODE /* 1 Cmd Line, 4 Address Lines and 4 Data Lines */
#define BSP_QSPI_DPI_MODE (BSP_QSPI_Interface_t)MT25TL01G_DPI_MODE /* 2 Cmd Lines, 2 Address Lines and 2 Data Lines */
#define BSP_QSPI_QPI_MODE (BSP_QSPI_Interface_t)MT25TL01G_QPI_MODE /* 4 Cmd Lines, 4 Address Lines and 4 Data Lines */
/* Definition for QSPI transfer rates */
#define BSP_QSPI_STR_TRANSFER (BSP_QSPI_Transfer_t)MT25TL01G_STR_TRANSFER /* Single Transfer Rate */
#define BSP_QSPI_DTR_TRANSFER (BSP_QSPI_Transfer_t)MT25TL01G_DTR_TRANSFER /* Double Transfer Rate */
/* Definition for QSPI dual flash mode */
#define BSP_QSPI_DUALFLASH_DISABLE (BSP_QSPI_DualFlash_t)MT25TL01G_DUALFLASH_DISABLE /* Dual flash mode enabled */
/* Definition for QSPI Flash ID */
#define BSP_QSPI_FLASH_ID QSPI_FLASH_ID_1
/* QSPI block sizes for dual flash */
#define BSP_QSPI_BLOCK_8K MT25TL01G_SECTOR_4K
#define BSP_QSPI_BLOCK_64K MT25TL01G_BLOCK_32K
#define BSP_QSPI_BLOCK_128K MT25TL01G_BLOCK_64K
/* Definition for QSPI clock resources */
#define QSPI_CLK_ENABLE() __HAL_RCC_QSPI_CLK_ENABLE()
#define QSPI_CLK_DISABLE() __HAL_RCC_QSPI_CLK_DISABLE()
#define QSPI_CLK_GPIO_CLK_ENABLE() __HAL_RCC_GPIOF_CLK_ENABLE()
#define QSPI_BK1_CS_GPIO_CLK_ENABLE() __HAL_RCC_GPIOG_CLK_ENABLE()
#define QSPI_BK1_D0_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE()
#define QSPI_BK1_D1_GPIO_CLK_ENABLE() __HAL_RCC_GPIOF_CLK_ENABLE()
#define QSPI_BK1_D2_GPIO_CLK_ENABLE() __HAL_RCC_GPIOF_CLK_ENABLE()
#define QSPI_BK1_D3_GPIO_CLK_ENABLE() __HAL_RCC_GPIOF_CLK_ENABLE()
#define QSPI_BK2_CS_GPIO_CLK_ENABLE() __HAL_RCC_GPIOG_CLK_ENABLE()
#define QSPI_BK2_D0_GPIO_CLK_ENABLE() __HAL_RCC_GPIOH_CLK_ENABLE()
#define QSPI_BK2_D1_GPIO_CLK_ENABLE() __HAL_RCC_GPIOH_CLK_ENABLE()
#define QSPI_BK2_D2_GPIO_CLK_ENABLE() __HAL_RCC_GPIOG_CLK_ENABLE()
#define QSPI_BK2_D3_GPIO_CLK_ENABLE() __HAL_RCC_GPIOG_CLK_ENABLE()
#define QSPI_FORCE_RESET() __HAL_RCC_QSPI_FORCE_RESET()
#define QSPI_RELEASE_RESET() __HAL_RCC_QSPI_RELEASE_RESET()
/* Definition for QSPI Pins */
#define QSPI_CLK_PIN GPIO_PIN_10
#define QSPI_CLK_GPIO_PORT GPIOF
/* Bank 1 */
#define QSPI_BK1_CS_PIN GPIO_PIN_6
#define QSPI_BK1_CS_GPIO_PORT GPIOG
#define QSPI_BK1_D0_PIN GPIO_PIN_11
#define QSPI_BK1_D0_GPIO_PORT GPIOD
#define QSPI_BK1_D1_PIN GPIO_PIN_9
#define QSPI_BK1_D1_GPIO_PORT GPIOF
#define QSPI_BK1_D2_PIN GPIO_PIN_7
#define QSPI_BK1_D2_GPIO_PORT GPIOF
#define QSPI_BK1_D3_PIN GPIO_PIN_6
#define QSPI_BK1_D3_GPIO_PORT GPIOF
/* Bank 2 */
#define QSPI_BK2_CS_PIN GPIO_PIN_6
#define QSPI_BK2_CS_GPIO_PORT GPIOG
#define QSPI_BK2_D0_PIN GPIO_PIN_2
#define QSPI_BK2_D0_GPIO_PORT GPIOH
#define QSPI_BK2_D1_PIN GPIO_PIN_3
#define QSPI_BK2_D1_GPIO_PORT GPIOH
#define QSPI_BK2_D2_PIN GPIO_PIN_9
#define QSPI_BK2_D2_GPIO_PORT GPIOG
#define QSPI_BK2_D3_PIN GPIO_PIN_14
#define QSPI_BK2_D3_GPIO_PORT GPIOG
/* MT25TL01G Micron memory */
/* Size of the flash */
#define QSPI_FLASH_SIZE 26 /* Address bus width to access whole memory space */
#define QSPI_PAGE_SIZE 256
/* QSPI Base Address */
#define QSPI_BASE_ADDRESS 0x90000000
/**
* @}
*/
/** @addtogroup STM32H750B_DK_QSPI_Exported_Variables
* @{
*/
extern QSPI_HandleTypeDef hqspi;
extern BSP_QSPI_Ctx_t QSPI_Ctx[QSPI_INSTANCES_NUMBER];
/**
* @}
*/
/* Exported functions --------------------------------------------------------*/
/** @addtogroup STM32H750B_DK_QSPI_Exported_Functions
* @{
*/
int32_t BSP_QSPI_Init(uint32_t Instance, BSP_QSPI_Init_t *Init);
int32_t BSP_QSPI_DeInit(uint32_t Instance);
#if (USE_HAL_QSPI_REGISTER_CALLBACKS == 1)
int32_t BSP_QSPI_RegisterMspCallbacks (uint32_t Instance, BSP_QSPI_Cb_t *CallBacks);
int32_t BSP_QSPI_RegisterDefaultMspCallbacks (uint32_t Instance);
#endif /* (USE_HAL_QSPI_REGISTER_CALLBACKS == 1) */
int32_t BSP_QSPI_Read(uint32_t Instance, uint8_t *pData, uint32_t ReadAddr, uint32_t Size);
int32_t BSP_QSPI_Write(uint32_t Instance, uint8_t *pData, uint32_t WriteAddr, uint32_t Size);
int32_t BSP_QSPI_EraseBlock(uint32_t Instance, uint32_t BlockAddress, BSP_QSPI_Erase_t BlockSize);
int32_t BSP_QSPI_EraseChip(uint32_t Instance);
int32_t BSP_QSPI_GetStatus(uint32_t Instance);
int32_t BSP_QSPI_GetInfo(uint32_t Instance, BSP_QSPI_Info_t *pInfo);
int32_t BSP_QSPI_EnableMemoryMappedMode(uint32_t Instance);
int32_t BSP_QSPI_DisableMemoryMappedMode(uint32_t Instance);
int32_t BSP_QSPI_ReadID(uint32_t Instance, uint8_t *Id);
int32_t BSP_QSPI_ConfigFlash(uint32_t Instance, BSP_QSPI_Interface_t Mode, BSP_QSPI_Transfer_t Rate);
/* These functions can be modified in case the current settings
need to be changed for specific application needs */
HAL_StatusTypeDef MX_QSPI_Init(QSPI_HandleTypeDef *hQspi, MX_QSPI_Init_t *Config);
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* STM32H750B_DK_QSPI_H */
@@ -0,0 +1,469 @@
/**
******************************************************************************
* @file stm32h750b_discovery_sdram.c
* @author MCD Application Team
* @brief This file includes the SDRAM driver for the MT48LC4M32B2B5-6A memory
* device mounted on STM32H750B-DK boards.
@verbatim
How To use this driver:
-----------------------
- This driver is used to drive the MT48LC4M32B2B5-6A SDRAM external memory mounted
on STM32H750B-DK board.
- This driver does not need a specific component driver for the SDRAM device
to be included with.
Driver description:
------------------
+ Initialization steps:
o Initialize the SDRAM external memory using the BSP_SDRAM_Init() function. This
function includes the MSP layer hardware resources initialization and the
FMC controller configuration to interface with the external SDRAM memory.
o It contains the SDRAM initialization sequence to program the SDRAM external
device using the function BSP_SDRAM_Initialization_sequence(). Note that this
sequence is standard for all SDRAM devices, but can include some differences
from a device to another. If it is the case, the right sequence should be
implemented separately.
+ SDRAM read/write operations
o SDRAM external memory can be accessed with read/write operations once it is
initialized.
Read/write operation can be performed with AHB access using the functions
BSP_SDRAM_ReadData()/BSP_SDRAM_WriteData(), or by MDMA transfer using the functions
BSP_SDRAM_ReadData_DMA()/BSP_SDRAM_WriteData_DMA().
o The AHB access is performed with 32-bit width transaction, the MDMA transfer
configuration is fixed at single (no burst) word transfer (see the
SDRAM_MspInit() static function).
o User can implement his own functions for read/write access with his desired
configurations.
o If interrupt mode is used for MDMA transfer, the function BSP_SDRAM_MDMA_IRQHandler()
is called in IRQ handler file, to serve the generated interrupt once the MDMA
transfer is complete.
o You can send a command to the SDRAM device in runtime using the function
BSP_SDRAM_Sendcmd(), and giving the desired command as parameter chosen between
the predefined commands of the "FMC_SDRAM_CommandTypeDef" structure.
@endverbatim
******************************************************************************
* @attention
*
* Copyright (c) 2018 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 "stm32h750b_discovery_sdram.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup STM32H750B_DK
* @{
*/
/** @defgroup STM32H750B_DK_SDRAM SDRAM
* @{
*/
/** @defgroup STM32H750B_DK_SDRAM_Exported_Variables Exported Variables
* @{
*/
SDRAM_HandleTypeDef hsdram[SDRAM_INSTANCES_NBR];
/**
* @}
*/
/** @defgroup STM32H750B_DK_SDRAM_Private_Variables Private Variables
* @{
*/
#if (USE_HAL_SDRAM_REGISTER_CALLBACKS == 1)
static uint32_t IsMspCallbacksValid = 0;
#endif
/**
* @}
*/
/** @defgroup STM32H750B_DK_SDRAM_Private_Function_Prototypes Private Functions Prototypes
* @{
*/
static void SDRAM_MspInit(SDRAM_HandleTypeDef *hSdram);
static void SDRAM_MspDeInit(SDRAM_HandleTypeDef *hSdram);
/**
* @}
*/
/** @defgroup STM32H750B_DK_SDRAM_Exported_Functions Exported Functions
* @{
*/
/**
* @brief Initializes the SDRAM device.
* @param Instance SDRAM Instance
* @retval BSP status
*/
int32_t BSP_SDRAM_Init(uint32_t Instance)
{
int32_t ret = BSP_ERROR_NONE;
static MT48LC4M32B2_Context_t pRegMode;
if(Instance >=SDRAM_INSTANCES_NBR)
{
ret = BSP_ERROR_WRONG_PARAM;
}
else
{
#if (USE_HAL_SDRAM_REGISTER_CALLBACKS == 1)
/* Register the SDRAM MSP Callbacks */
if(IsMspCallbacksValid == 0)
{
if(BSP_SDRAM_RegisterDefaultMspCallbacks(Instance) != BSP_ERROR_NONE)
{
return BSP_ERROR_PERIPH_FAILURE;
}
}
#else
/* Msp SDRAM initialization */
SDRAM_MspInit(&hsdram[Instance]);
#endif /* USE_HAL_SDRAM_REGISTER_CALLBACKS */
if(MX_SDRAM_BANK2_Init(&hsdram[Instance],FMC_SDRAM_ROW_BITS_NUM_12, FMC_SDRAM_MEM_BUS_WIDTH_16) != HAL_OK)
{
ret = BSP_ERROR_NO_INIT;
}
else
{
/* External memory mode register configuration */
pRegMode.TargetBank = FMC_SDRAM_CMD_TARGET_BANK2;
pRegMode.RefreshMode = MT48LC4M32B2_AUTOREFRESH_MODE_CMD;
pRegMode.RefreshRate = REFRESH_COUNT;
pRegMode.BurstLength = MT48LC4M32B2_BURST_LENGTH_1;
pRegMode.BurstType = MT48LC4M32B2_BURST_TYPE_SEQUENTIAL;
pRegMode.CASLatency = MT48LC4M32B2_CAS_LATENCY_3;
pRegMode.OperationMode = MT48LC4M32B2_OPERATING_MODE_STANDARD;
pRegMode.WriteBurstMode = MT48LC4M32B2_WRITEBURST_MODE_SINGLE;
/* SDRAM initialization sequence */
if(MT48LC4M32B2_Init(&hsdram[Instance], &pRegMode) != MT48LC4M32B2_OK)
{
ret = BSP_ERROR_COMPONENT_FAILURE;
}
}
}
return ret;
}
/**
* @brief DeInitializes the SDRAM device.
* @param Instance SDRAM Instance
* @retval BSP status
*/
int32_t BSP_SDRAM_DeInit(uint32_t Instance)
{
int32_t ret = BSP_ERROR_NONE;
if(Instance >= SDRAM_INSTANCES_NBR)
{
ret = BSP_ERROR_WRONG_PARAM;
}
else
{
(void)HAL_SDRAM_DeInit(&hsdram[Instance]);
#if (USE_HAL_SDRAM_REGISTER_CALLBACKS == 0)
/* SDRAM controller de-initialization */
SDRAM_MspDeInit(&hsdram[Instance]);
#endif /* (USE_HAL_SDRAM_REGISTER_CALLBACKS == 0) */
}
return ret;
}
/**
* @brief Initializes the SDRAM periperal.
* @param hSdram SDRAM handle
* @param RowBitsNumber Number of row to set
* @param MemoryDataWidth The momory width 16 or 32bits
* @retval HAL status
*/
__weak HAL_StatusTypeDef MX_SDRAM_BANK2_Init(SDRAM_HandleTypeDef *hSdram, uint32_t RowBitsNumber, uint32_t MemoryDataWidth)
{
FMC_SDRAM_TimingTypeDef sdram_timing;
/* SDRAM device configuration */
hsdram->Instance = FMC_SDRAM_DEVICE;
/* SDRAM handle configuration */
hSdram->Init.SDBank = FMC_SDRAM_BANK2;
hSdram->Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_8;
hSdram->Init.RowBitsNumber = RowBitsNumber;
hSdram->Init.MemoryDataWidth = MemoryDataWidth;
hsdram->Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4;
hSdram->Init.CASLatency = FMC_SDRAM_CAS_LATENCY_3;
hSdram->Init.WriteProtection = FMC_SDRAM_WRITE_PROTECTION_DISABLE;
hSdram->Init.SDClockPeriod = FMC_SDRAM_CLOCK_PERIOD_2;
hSdram->Init.ReadBurst = FMC_SDRAM_RBURST_ENABLE;
hSdram->Init.ReadPipeDelay = FMC_SDRAM_RPIPE_DELAY_0;
/* Timing configuration for as SDRAM */
sdram_timing.LoadToActiveDelay = 2;
sdram_timing.ExitSelfRefreshDelay = 7;
sdram_timing.SelfRefreshTime = 4;
sdram_timing.RowCycleDelay = 7;
sdram_timing.WriteRecoveryTime = 2;
sdram_timing.RPDelay = 2;
sdram_timing.RCDDelay = 2;
/* SDRAM controller initialization */
if(HAL_SDRAM_Init(hSdram, &sdram_timing) != HAL_OK)
{
return HAL_ERROR;
}
return HAL_OK;
}
#if (USE_HAL_SDRAM_REGISTER_CALLBACKS == 1)
/**
* @brief Default BSP SDRAM Msp Callbacks
* @param Instance SDRAM Instance
* @retval BSP status
*/
int32_t BSP_SDRAM_RegisterDefaultMspCallbacks (uint32_t Instance)
{
int32_t ret = BSP_ERROR_NONE;
/* Check if the instance is supported */
if(Instance >= SDRAM_INSTANCES_NBR)
{
ret = BSP_ERROR_WRONG_PARAM;
}
else
{
/* Register MspInit/MspDeInit Callbacks */
if(HAL_SDRAM_RegisterCallback(&hsdram[Instance], HAL_SDRAM_MSP_INIT_CB_ID, SDRAM_MspInit) != HAL_OK)
{
ret = BSP_ERROR_PERIPH_FAILURE;
}
if(HAL_SDRAM_RegisterCallback(&hsdram[Instance], HAL_SDRAM_MSP_DEINIT_CB_ID, SDRAM_MspDeInit) != HAL_OK)
{
ret = BSP_ERROR_PERIPH_FAILURE;
}
else
{
IsMspCallbacksValid = 1;
}
}
/* Return BSP status */
return ret;
}
/**
* @brief BSP SDRAM Msp Callback registering
* @param Instance SDRAM Instance
* @param CallBacks pointer to MspInit/MspDeInit callbacks functions
* @retval BSP status
*/
int32_t BSP_SDRAM_RegisterMspCallbacks (uint32_t Instance, BSP_SDRAM_Cb_t *CallBacks)
{
int32_t ret = BSP_ERROR_NONE;
/* Check if the instance is supported */
if(Instance >= SDRAM_INSTANCES_NBR)
{
ret = BSP_ERROR_WRONG_PARAM;
}
else
{
/* Register MspInit/MspDeInit Callbacks */
if(HAL_SDRAM_RegisterCallback(&hsdram[Instance], HAL_SDRAM_MSP_INIT_CB_ID, CallBacks->pMspInitCb) != HAL_OK)
{
ret = BSP_ERROR_PERIPH_FAILURE;
}
if(HAL_SDRAM_RegisterCallback(&hsdram[Instance], HAL_SDRAM_MSP_DEINIT_CB_ID, CallBacks->pMspDeInitCb) != HAL_OK)
{
ret = BSP_ERROR_PERIPH_FAILURE;
}
else
{
IsMspCallbacksValid = 1;
}
}
/* Return BSP status */
return ret;
}
#endif /* (USE_HAL_SDRAM_REGISTER_CALLBACKS == 1) */
/**
* @brief Sends command to the SDRAM bank.
* @param Instance SDRAM Instance
* @param SdramCmd Pointer to SDRAM command structure
* @retval BSP status
*/
int32_t BSP_SDRAM_SendCmd(uint32_t Instance, FMC_SDRAM_CommandTypeDef *SdramCmd)
{
int32_t ret;
if(Instance >= SDRAM_INSTANCES_NBR)
{
ret = BSP_ERROR_WRONG_PARAM;
}
else if(MT48LC4M32B2_Sendcmd(&hsdram[Instance], SdramCmd) != MT48LC4M32B2_OK)
{
ret = BSP_ERROR_PERIPH_FAILURE;
}
else
{
ret = BSP_ERROR_NONE;
}
return ret;
}
/**
* @brief This function handles SDRAM MDMA interrupt request.
* @param Instance SDRAM instance
* @retval None
*/
void BSP_SDRAM_IRQHandler(uint32_t Instance)
{
HAL_MDMA_IRQHandler(hsdram[Instance].hmdma);
}
/**
* @}
*/
/** @defgroup STM32H750B_DK_SDRAM_Private_Functions Private Functions
* @{
*/
/**
* @brief Initializes SDRAM MSP.
* @param hSdram SDRAM handle
* @retval None
*/
static void SDRAM_MspInit(SDRAM_HandleTypeDef *hSdram)
{
static MDMA_HandleTypeDef mdma_handle;
GPIO_InitTypeDef gpio_init_structure;
/* Enable FMC clock */
__HAL_RCC_FMC_CLK_ENABLE();
/* Enable chosen MDMAx clock */
SDRAM_MDMAx_CLK_ENABLE();
/* Enable GPIOs clock */
__HAL_RCC_GPIOD_CLK_ENABLE();
__HAL_RCC_GPIOE_CLK_ENABLE();
__HAL_RCC_GPIOF_CLK_ENABLE();
__HAL_RCC_GPIOG_CLK_ENABLE();
__HAL_RCC_GPIOH_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;
gpio_init_structure.Alternate = GPIO_AF12_FMC;
/* GPIOD configuration */
gpio_init_structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_8| GPIO_PIN_9 | GPIO_PIN_10 |\
GPIO_PIN_14 | GPIO_PIN_15;
HAL_GPIO_Init(GPIOD, &gpio_init_structure);
/* GPIOE configuration */
gpio_init_structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_7| GPIO_PIN_8 | GPIO_PIN_9 |\
GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 |\
GPIO_PIN_15;
HAL_GPIO_Init(GPIOE, &gpio_init_structure);
/* GPIOF configuration */
gpio_init_structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2| GPIO_PIN_3 | GPIO_PIN_4 |\
GPIO_PIN_5 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 |\
GPIO_PIN_15;
HAL_GPIO_Init(GPIOF, &gpio_init_structure);
/* GPIOG configuration */
gpio_init_structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_8 | GPIO_PIN_15;
HAL_GPIO_Init(GPIOG, &gpio_init_structure);
/* GPIOH configuration */
gpio_init_structure.Pin = GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7 ;
HAL_GPIO_Init(GPIOH, &gpio_init_structure);
/* Configure common MDMA parameters */
mdma_handle.Init.Request = MDMA_REQUEST_SW;
mdma_handle.Init.TransferTriggerMode = MDMA_BLOCK_TRANSFER;
mdma_handle.Init.Priority = MDMA_PRIORITY_HIGH;
mdma_handle.Init.Endianness = MDMA_LITTLE_ENDIANNESS_PRESERVE;
mdma_handle.Init.SourceInc = MDMA_SRC_INC_WORD;
mdma_handle.Init.DestinationInc = MDMA_DEST_INC_WORD;
mdma_handle.Init.SourceDataSize = MDMA_SRC_DATASIZE_WORD;
mdma_handle.Init.DestDataSize = MDMA_DEST_DATASIZE_WORD;
mdma_handle.Init.DataAlignment = MDMA_DATAALIGN_PACKENABLE;
mdma_handle.Init.SourceBurst = MDMA_SOURCE_BURST_SINGLE;
mdma_handle.Init.DestBurst = MDMA_DEST_BURST_SINGLE;
mdma_handle.Init.BufferTransferLength = 128;
mdma_handle.Init.SourceBlockAddressOffset = 0;
mdma_handle.Init.DestBlockAddressOffset = 0;
mdma_handle.Instance = SDRAM_MDMAx_CHANNEL;
/* Associate the DMA handle */
__HAL_LINKDMA(hsdram, hmdma, mdma_handle);
/* Deinitialize the stream for new transfer */
HAL_MDMA_DeInit(&mdma_handle);
/* Configure the DMA stream */
HAL_MDMA_Init(&mdma_handle);
/* NVIC configuration for DMA transfer complete interrupt */
HAL_NVIC_SetPriority(SDRAM_MDMAx_IRQn, 0x0F, 0);
HAL_NVIC_EnableIRQ(SDRAM_MDMAx_IRQn);
}
/**
* @brief DeInitializes SDRAM MSP.
* @param hSdram SDRAM handle
* @retval None
*/
static void SDRAM_MspDeInit(SDRAM_HandleTypeDef *hSdram)
{
static MDMA_HandleTypeDef mdma_handle;
/* Prevent unused argument(s) compilation warning */
UNUSED(hSdram);
/* Disable NVIC configuration for DMA interrupt */
HAL_NVIC_DisableIRQ(SDRAM_MDMAx_IRQn);
/* Deinitialize the stream for new transfer */
mdma_handle.Instance = SDRAM_MDMAx_CHANNEL;
(void)HAL_MDMA_DeInit(&mdma_handle);
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
@@ -0,0 +1,124 @@
/**
******************************************************************************
* @file stm32h750b_discovery_sdram.h
* @author MCD Application Team
* @brief This file contains the common defines and functions prototypes for
* the stm32h750b_discovery_sdram.c driver.
******************************************************************************
* @attention
*
* Copyright (c) 2018 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 STM32H750B_DK_SDRAM_H
#define STM32H750B_DK_SDRAM_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32h750b_discovery_conf.h"
#include "stm32h750b_discovery_errno.h"
#include "../Components/mt48lc4m32b2/mt48lc4m32b2.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup STM32H750B_DK
* @{
*/
/** @addtogroup STM32H750B_DK_SDRAM
* @{
*/
/** @defgroup STM32H750B_DK_SDRAM_Exported_Types Exported Types
* @{
*/
#if (USE_HAL_SDRAM_REGISTER_CALLBACKS == 1)
typedef struct
{
void (* pMspInitCb)(SDRAM_HandleTypeDef *);
void (* pMspDeInitCb)(SDRAM_HandleTypeDef *);
}BSP_SDRAM_Cb_t;
#endif /* (USE_HAL_SDRAM_REGISTER_CALLBACKS == 1) */
/**
* @}
*/
/** @defgroup STM32H750B_DK_SDRAM_Exported_Constants Exported Constants
* @{
*/
#define SDRAM_INSTANCES_NBR 1U
#define SDRAM_DEVICE_ADDR 0xD0000000U
#define SDRAM_DEVICE_SIZE 0x01000000U /* IS42S32400F-6BL (128Mb) = 1M x32 bit x4 Banks */
/* DMA definitions for SDRAM DMA transfer */
#define SDRAM_MDMAx_CLK_ENABLE __HAL_RCC_MDMA_CLK_ENABLE
#define SDRAM_MDMAx_CLK_DISABLE __HAL_RCC_MDMA_CLK_DISABLE
#define SDRAM_MDMAx_CHANNEL MDMA_Channel0
#define SDRAM_MDMAx_IRQn MDMA_IRQn
#define SDRAM_MDMA_IRQHandler MDMA_IRQHandler
/**
* @}
*/
/** @defgroup STM32H750B_DK_SDRAM_Exported_Macro Exported Macro
* @{
*/
/**
* @}
*/
/** @addtogroup STM32H750B_DK_SDRAM_Exported_Variables
* @{
*/
extern SDRAM_HandleTypeDef hsdram[SDRAM_INSTANCES_NBR];
/**
* @}
*/
/** @addtogroup STM32H750B_DK_SDRAM_Exported_Functions
* @{
*/
int32_t BSP_SDRAM_Init(uint32_t Instance);
int32_t BSP_SDRAM_DeInit(uint32_t Instance);
#if (USE_HAL_SDRAM_REGISTER_CALLBACKS == 1)
int32_t BSP_SDRAM_RegisterDefaultMspCallbacks (uint32_t Instance);
int32_t BSP_SDRAM_RegisterMspCallbacks (uint32_t Instance, BSP_SDRAM_Cb_t *CallBacks);
#endif /* (USE_HAL_SDRAM_REGISTER_CALLBACKS == 1) */
int32_t BSP_SDRAM_SendCmd(uint32_t Instance, FMC_SDRAM_CommandTypeDef *SdramCmd);
/* These functions can be modified in case the current settings need to be
changed for specific application needs */
HAL_StatusTypeDef MX_SDRAM_BANK2_Init(SDRAM_HandleTypeDef *hsdram, uint32_t RowBitsNumber, uint32_t MemoryDataWidth);
void BSP_SDRAM_IRQHandler(uint32_t Instance);
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /*STM32H750B_DK_SDRAM_H */
@@ -0,0 +1,697 @@
/**
******************************************************************************
* @file stm32h750b_discovery_ts.c
* @author MCD Application Team
* @brief This file provides a set of functions needed to manage the Touch
* Screen on STM32H750B-DK board.
******************************************************************************
* @attention
*
* Copyright (c) 2018 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 STM32H750B-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 "stm32h750b_discovery_ts.h"
#include "stm32h750b_discovery_bus.h"
#include "../Components/Common/ts.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup STM32H750B_DK
* @{
*/
/** @defgroup STM32H750B_DK_TS TS
* @{
*/
/** @defgroup STM32H750B_DK_TS_Private_Types_Definitions Private Types Definitions
* @{
*/
typedef void (* BSP_EXTI_LineCallback) (void);
/**
* @}
*/
/** @defgroup STM32H750B_DK_TS_Private_Defines Private Types Defines
* @{
*/
/**
* @}
*/
/** @defgroup STM32H750B_DK_TS_Private_Macros Private Macros
* @{
*/
#define TS_MIN(a,b) ((a > b) ? b : a)
/**
* @}
*/
/** @defgroup STM32H750B_DK_TS_Private_Function_Prototypes Private Function Prototypes
* @{
*/
static int32_t FT5336_Probe(uint32_t Instance);
static void TS_EXTI_Callback(void);
/**
* @}
*/
/** @defgroup STM32H750B_DK_TS_Privates_Variables Privates Variables
* @{
*/
static TS_Drv_t *Ts_Drv = NULL;
/**
* @}
*/
/** @defgroup STM32H750B_DK_TS_Exported_Variables 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};
/**
* @}
*/
/** @defgroup STM32H750B_DK_TS_Exported_Functions 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(FT5336_Probe(Instance) != BSP_ERROR_NONE)
{
ret = BSP_ERROR_NO_INIT;
}
else
{
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_PULLUP;
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.
* @param Instance : TS instance
* @retval None.
*/
__weak void BSP_TS_Callback(uint32_t Instance)
{
/* Prevent unused argument(s) compilation warning */
UNUSED(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
{
FT5336_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
{
FT5336_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 STM32H750B_DK_TS_Private_Functions Private Functions
* @{
*/
/**
* @brief Register Bus IOs if component ID is OK
* @param Instance TS instance. Could be only 0.
* @retval BSP status
*/
static 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,235 @@
/**
******************************************************************************
* @file stm32h750b_discovery_ts.h
* @author MCD Application Team
* @brief This file contains the common defines and functions prototypes for
* the stm32h750b_discovery_ts.c driver.
******************************************************************************
* @attention
*
* Copyright (c) 2018 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 STM32H750B_DK_TS_H
#define STM32H750B_DK_TS_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32h750b_discovery_conf.h"
#include "stm32h750b_discovery_errno.h"
#include "../Components/ft5336/ft5336.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup STM32H750B_DK
* @{
*/
/** @addtogroup STM32H750B_DK_TS
* @{
*/
/** @defgroup STM32H750B_DK_TS_Exported_Constants 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 1U
/* 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
/**
* @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 STM32H750B_DK_TS_Exported_Types 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 STM32H750B_DK_TS_Exported_Variables
* @{
*/
extern void *Ts_CompObj[TS_INSTANCES_NBR];
extern EXTI_HandleTypeDef hts_exti[TS_INSTANCES_NBR];
extern TS_Ctx_t Ts_Ctx[TS_INSTANCES_NBR];
/**
* @}
*/
/** @defgroup STM32H750B_DK_TS_Exported_Functions 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);
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* STM32H750B_DK_TS_H */