initial working (stm32f4-discovery)
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
---
|
||||
name: 'Issue report'
|
||||
about: 'Create a report to help us improve the quality of our software'
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
---
|
||||
|
||||
**Caution**
|
||||
|
||||
The Issues are strictly limited for the reporting of problem encountered with the software provided in this project.
|
||||
For any other problem related to the STM32 product, the performance, the hardware characteristics and boards, the tools the environment in general, please post your report to the **ST Community** in the STM32 MCUs dedicated [page](https://community.st.com/s/group/0F90X000000AXsASAW/stm32-mcus).
|
||||
|
||||
**Describe the set-up**
|
||||
|
||||
* The board (either ST RPN reference or your custom board)
|
||||
* IDE or at least the compiler and its version
|
||||
|
||||
**Describe the bug (skip if none)**
|
||||
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**How to reproduce the bug (skip if none)**
|
||||
|
||||
1. Indicate the global behavior of your application project
|
||||
2. List the modules that you suspect to be the cause of the problem (Drivers, BSP, MW...)
|
||||
3. Describe the use case that generates the problem
|
||||
4. How we can reproduce the problem
|
||||
|
||||
|
||||
**Additional context**
|
||||
|
||||
If you have a first analysis, an enhancement, a fix or a patch, thank you to share your proposal.
|
||||
|
||||
**Screenshots**
|
||||
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
@@ -0,0 +1,5 @@
|
||||
## IMPORTANT INFORMATION
|
||||
|
||||
### Contributor License Agreement (CLA)
|
||||
* The Pull Request feature will be considered by STMicroelectronics after the signature of a **Contributor License Agreement (CLA)** by the submitter.
|
||||
* If you did not sign such agreement, please follow the steps mentioned in the [CONTRIBUTING.md](https://github.com/STMicroelectronics/stm32469i-eval/blob/main/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, see the [FAQ section](https://www.contributor-covenant.org/faq).
|
||||
@@ -0,0 +1,38 @@
|
||||
## Contributing guide
|
||||
|
||||
This document serves as a checklist before contributing to this repository.
|
||||
It includes links to read up on if topics are unclear to you.
|
||||
|
||||
This guide mainly focuses on steps to be followed to submit an issue or a pull-request.
|
||||
|
||||
### 1. Before opening an issue
|
||||
|
||||
To report a bug or a request please file an issue in the right repository
|
||||
(example for [stm32469i-eval](https://github.com/STMicroelectronics/stm32469i-eval/issues/new/choose)).
|
||||
|
||||
Please check the following boxes 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, it should be submitted to the **ST Community** on the appropriate topic [page](https://community.st.com/s/topiccatalog).
|
||||
- [ ] `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.
|
||||
|
||||
### 2. Posting the issue
|
||||
|
||||
When you have checked the previous boxes, create a new report from the **Issues** tab of the repository. A template is available to help you report the issue you are facing or the enhancement you would like to propose.
|
||||
|
||||
### 3. Pull Requests
|
||||
|
||||
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.
|
||||
|
||||
### 4. 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.
|
||||
@@ -0,0 +1,27 @@
|
||||
Copyright 2017 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,43 @@
|
||||
# BSP STM32469I-EVAL Component
|
||||
|
||||

|
||||
|
||||
## Overview
|
||||
|
||||
**STM32Cube** is an STMicroelectronics original initiative to ease developers' life by reducing efforts, time and cost.
|
||||
|
||||
**STM32Cube** covers the overall STM32 products portfolio. It includes a comprehensive embedded software platform delivered for each STM32 series.
|
||||
* The CMSIS modules (core and device) corresponding to the ARM(tm) core implemented in this STM32 product.
|
||||
* The STM32 HAL-LL drivers, an abstraction layer offering a set of APIs ensuring maximized portability across the STM32 portfolio.
|
||||
* The BSP drivers of each evaluation, demonstration or nucleo board provided for this STM32 series.
|
||||
* A consistent set of middleware libraries such as RTOS, USB, FatFS, graphics, touch sensing library...
|
||||
* A full set of software projects (basic examples, applications, and demonstrations) for each board provided for this STM32 series.
|
||||
|
||||
Two models of publication are proposed for the STM32Cube embedded software:
|
||||
* The monolithic **MCU Package**: all STM32Cube software modules of one STM32 series are present (Drivers, Middleware, Projects, Utilities) in the repository (usual name **STM32Cubexx**, xx corresponding to the STM32 series).
|
||||
* The **MCU component**: each STM32Cube software module being part of the STM32Cube MCU Package, is delivered as an individual repository, allowing the user to select and get only the required software functions.
|
||||
|
||||
## Description
|
||||
|
||||
This **stm32469i-eval** MCU component repository is one element of the **STM32CubeF4** MCU embedded software package, providing the **STM32469I-EVAL** 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/stm32469i-eval/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/STM32CubeF4/blob/master/Release_Notes.html) release note.
|
||||
|
||||
* [stm32-bsp-common](https://github.com/STMicroelectronics/stm32-bsp-common)
|
||||
* [stm32-ft6x06](https://github.com/STMicroelectronics/stm32-ft6x06)
|
||||
* [stm32-mfxstm32l152](https://github.com/STMicroelectronics/stm32-mfxstm32l152)
|
||||
* [stm32-n25q512a](https://github.com/STMicroelectronics/stm32-n25q512a)
|
||||
* [stm32-ov5640](https://github.com/STMicroelectronics/stm32-ov5640)
|
||||
* [stm32-s25fl512s](https://github.com/STMicroelectronics/stm32-s25fl512s)
|
||||
* [stm32-s5k5cag](https://github.com/STMicroelectronics/stm32-s5k5cag)
|
||||
* [stm32-wm8994](https://github.com/STMicroelectronics/stm32-wm8994)
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
Please refer to the [CONTRIBUTING.md](CONTRIBUTING.md) guide.
|
||||
@@ -0,0 +1,31 @@
|
||||
# Report potential product security vulnerabilities
|
||||
|
||||
ST places a high priority on security, and our Product Security Incident
|
||||
Response Team (PSIRT) is committed to rapidly addressing potential security
|
||||
vulnerabilities affecting our products. PSIRT's long history and vast experience
|
||||
in security allows ST to perform clear analyses and provide appropriate guidance
|
||||
on mitigations and solutions when applicable.
|
||||
|
||||
If you wish to report potential security vulnerabilities regarding our products,
|
||||
**please do not report them through public GitHub issues.** Instead, we
|
||||
encourage you to report them to our ST PSIRT following the process described at:
|
||||
**https://www.st.com/content/st_com/en/security/report-vulnerabilities.html**
|
||||
|
||||
### IMPORTANT - READ CAREFULLY:
|
||||
|
||||
STMicroelectronics International N.V., on behalf of itself, its affiliates and
|
||||
subsidiaries, (collectively “ST”) takes all potential security vulnerability
|
||||
reports or other related communications (“Report(s)”) seriously. In order to
|
||||
review Your Report (the terms “You” and “Yours” include your employer, and all
|
||||
affiliates, subsidiaries and related persons or entities) and take actions as
|
||||
deemed appropriate, ST requires that we have the rights and Your permission to
|
||||
do so.
|
||||
|
||||
As such, by submitting Your Report to ST, You agree that You have the right to
|
||||
do so, and You grant to ST the rights to use the Report for purposes related to
|
||||
security vulnerability analysis, testing, correction, patching, reporting and
|
||||
any other related purpose or function.
|
||||
|
||||
By submitting Your Report, You agree that ST’s
|
||||
[Privacy Policy](https://www.st.com/content/st_com/en/common/privacy-portal.html)
|
||||
applies to all related communications.
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,423 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32469i_eval.h
|
||||
* @author MCD Application Team
|
||||
* @brief This file contains definitions for STM32469I-EVAL's LEDs,
|
||||
* push-buttons and COM ports hardware resources.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2017 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 __STM32469I_EVAL_H
|
||||
#define __STM32469I_EVAL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* USE_STM32469I_EVAL_REVA must USE USE_IOEXPANDER */
|
||||
#if defined(USE_STM32469I_EVAL_REVA)
|
||||
#ifndef USE_IOEXPANDER
|
||||
#define USE_IOEXPANDER
|
||||
#endif /* USE_IOEXPANDER */
|
||||
#endif /* USE_STM32469I_EVAL_REVA */
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32f4xx_hal.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @addtogroup STM32469I_EVAL
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I_EVAL_LOW_LEVEL STM32469I EVAL LOW LEVEL
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I_EVAL_LOW_LEVEL_Exported_Types STM32469I EVAL LOW LEVEL Exported Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @brief Led_TypeDef
|
||||
* STM32469I_EVAL board leds definitions.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
LED1 = 0,
|
||||
LED_GREEN = LED1,
|
||||
LED2 = 1,
|
||||
LED_ORANGE = LED2,
|
||||
LED3 = 2,
|
||||
LED_RED = LED3,
|
||||
LED4 = 3,
|
||||
LED_BLUE = LED4
|
||||
|
||||
} Led_TypeDef;
|
||||
|
||||
/** @brief Button_TypeDef
|
||||
* STM32469I_EVAL board Buttons definitions.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
BUTTON_WAKEUP = 0,
|
||||
BUTTON_TAMPER = 1,
|
||||
BUTTON_KEY = 2
|
||||
|
||||
} Button_TypeDef;
|
||||
|
||||
/** @brief ButtonMode_TypeDef
|
||||
* STM32469I_EVAL board Buttons Modes definitions.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
BUTTON_MODE_GPIO = 0,
|
||||
BUTTON_MODE_EXTI = 1
|
||||
|
||||
} ButtonMode_TypeDef;
|
||||
|
||||
#if defined(USE_IOEXPANDER)
|
||||
/** @brief JOYMode_TypeDef
|
||||
* STM32469I_EVAL board Joystick Mode definitions.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
JOY_MODE_GPIO = 0,
|
||||
JOY_MODE_EXTI = 1
|
||||
|
||||
} JOYMode_TypeDef;
|
||||
|
||||
/** @brief JOYState_TypeDef
|
||||
* STM32469I_EVAL board Joystick State definitions.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
JOY_NONE = 0,
|
||||
JOY_SEL = 1,
|
||||
JOY_DOWN = 2,
|
||||
JOY_LEFT = 3,
|
||||
JOY_RIGHT = 4,
|
||||
JOY_UP = 5
|
||||
|
||||
} JOYState_TypeDef;
|
||||
#endif /* USE_IOEXPANDER */
|
||||
|
||||
/** @brief COM_TypeDef
|
||||
* STM32469I_EVAL board COM ports.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
COM1 = 0,
|
||||
COM2 = 1
|
||||
|
||||
} COM_TypeDef;
|
||||
|
||||
/** @brief EVAL_Status_TypeDef
|
||||
* STM32469I_EVAL board Eval Status return possible values.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
EVAL_OK = 0,
|
||||
EVAL_ERROR = 1
|
||||
|
||||
} EVAL_Status_TypeDef;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I_EVAL_LOW_LEVEL_Exported_Constants STM32469I EVAL LOW LEVEL Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Define for STM32469I_EVAL board
|
||||
*/
|
||||
#if !defined (USE_STM32469I_EVAL)
|
||||
#define USE_STM32469I_EVAL
|
||||
#endif
|
||||
|
||||
/** @defgroup STM32469I_EVAL_LOW_LEVEL_LED STM32469I EVAL LOW LEVEL LED
|
||||
* @{
|
||||
*/
|
||||
/* Always four leds for all revisions of Eval boards */
|
||||
#define LEDn ((uint8_t)4)
|
||||
|
||||
#if !defined(USE_STM32469I_EVAL_REVA)
|
||||
/* Rev B board and beyond : 4 Leds are connected to MCU directly and not via MFX */
|
||||
/* PK3, PK4, PK5, PK6 are used */
|
||||
#define LEDx_GPIO_PORT GPIOK
|
||||
#define LEDx_GPIO_CLK_ENABLE() __HAL_RCC_GPIOK_CLK_ENABLE()
|
||||
#define LEDx_GPIO_CLK_DISABLE() __HAL_RCC_GPIOK_CLK_DISABLE()
|
||||
#define LED1_PIN GPIO_PIN_3
|
||||
#define LED2_PIN GPIO_PIN_4
|
||||
#define LED3_PIN GPIO_PIN_5
|
||||
#define LED4_PIN GPIO_PIN_6
|
||||
#else
|
||||
/* Eval Rev A board */
|
||||
#define LED1_PIN IO_PIN_16
|
||||
#define LED2_PIN IO_PIN_17
|
||||
#define LED3_PIN IO_PIN_18
|
||||
#define LED4_PIN IO_PIN_19
|
||||
#endif /* USE_STM32469I_EVAL_REVA */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief MFX_IRQOUt pin
|
||||
*/
|
||||
#define MFX_IRQOUT_PIN GPIO_PIN_8
|
||||
#define MFX_IRQOUT_GPIO_PORT GPIOI
|
||||
#define MFX_IRQOUT_GPIO_CLK_ENABLE() __HAL_RCC_GPIOI_CLK_ENABLE()
|
||||
#define MFX_IRQOUT_GPIO_CLK_DISABLE() __HAL_RCC_GPIOI_CLK_DISABLE()
|
||||
#define MFX_IRQOUT_EXTI_IRQn EXTI9_5_IRQn
|
||||
#define MFX_IRQOUT_EXTI_IRQnHandler EXTI9_5_IRQHandler
|
||||
|
||||
/** @defgroup STM32469I_EVAL_LOW_LEVEL_BUTTON STM32469I EVAL LOW LEVEL BUTTON
|
||||
* @{
|
||||
*/
|
||||
/* Joystick pins are connected to IO Expander (accessible through I2C1 interface) */
|
||||
#define BUTTONn ((uint8_t)3)
|
||||
|
||||
/**
|
||||
* @brief Wakeup push-button
|
||||
*/
|
||||
#define WAKEUP_BUTTON_PIN GPIO_PIN_0
|
||||
#define WAKEUP_BUTTON_GPIO_PORT GPIOA
|
||||
#define WAKEUP_BUTTON_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
|
||||
#define WAKEUP_BUTTON_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE()
|
||||
#define WAKEUP_BUTTON_EXTI_IRQn EXTI0_IRQn
|
||||
|
||||
/**
|
||||
* @brief Tamper push-button
|
||||
*/
|
||||
#define TAMPER_BUTTON_PIN GPIO_PIN_13
|
||||
#define TAMPER_BUTTON_GPIO_PORT GPIOC
|
||||
#define TAMPER_BUTTON_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE()
|
||||
#define TAMPER_BUTTON_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE()
|
||||
#define TAMPER_BUTTON_EXTI_IRQn EXTI15_10_IRQn
|
||||
|
||||
/**
|
||||
* @brief Key push-button
|
||||
*/
|
||||
#define KEY_BUTTON_PIN GPIO_PIN_13
|
||||
#define KEY_BUTTON_GPIO_PORT GPIOC
|
||||
#define KEY_BUTTON_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE()
|
||||
#define KEY_BUTTON_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE()
|
||||
#define KEY_BUTTON_EXTI_IRQn EXTI15_10_IRQn
|
||||
|
||||
#define BUTTONx_GPIO_CLK_ENABLE(__INDEX__) do { if((__INDEX__) == 0) {WAKEUP_BUTTON_GPIO_CLK_ENABLE();} else\
|
||||
if((__INDEX__) == 1) {TAMPER_BUTTON_GPIO_CLK_ENABLE();} else\
|
||||
{KEY_BUTTON_GPIO_CLK_ENABLE(); }} while(0)
|
||||
|
||||
#define BUTTONx_GPIO_CLK_DISABLE(__INDEX__) (((__INDEX__) == 0) ? WAKEUP_BUTTON_GPIO_CLK_DISABLE() :\
|
||||
((__INDEX__) == 1) ? TAMPER_BUTTON_GPIO_CLK_DISABLE() : KEY_BUTTON_GPIO_CLK_DISABLE())
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I_EVAL_LOW_LEVEL_COM STM32469I EVAL LOW LEVEL COM
|
||||
* @{
|
||||
*/
|
||||
#define COMn ((uint8_t)1)
|
||||
|
||||
/**
|
||||
* @brief Definition for COM port1, connected to USART1
|
||||
*/
|
||||
#define EVAL_COM1 USART1
|
||||
#define EVAL_COM1_CLK_ENABLE() __HAL_RCC_USART1_CLK_ENABLE()
|
||||
#define EVAL_COM1_CLK_DISABLE() __HAL_RCC_USART1_CLK_DISABLE()
|
||||
|
||||
#define EVAL_COM1_TX_PIN GPIO_PIN_9
|
||||
#define EVAL_COM1_RX_PIN GPIO_PIN_10
|
||||
#define EVAL_COM1_TX_GPIO_PORT GPIOA
|
||||
#define EVAL_COM1_RX_GPIO_PORT EVAL_COM1_TX_GPIO_PORT
|
||||
|
||||
#define EVAL_COM1_TX_AF GPIO_AF7_USART1
|
||||
#define EVAL_COM1_RX_AF EVAL_COM1_TX_AF
|
||||
|
||||
#define EVAL_COM1_TX_RX_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
|
||||
#define EVAL_COM1_TX_RX_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE()
|
||||
|
||||
#define EVAL_COM1_IRQn USART1_IRQn
|
||||
|
||||
#define EVAL_COMx_CLK_ENABLE(__INDEX__) do { if((__INDEX__) == 0) {EVAL_COM1_CLK_ENABLE();} } while(0)
|
||||
#define EVAL_COMx_CLK_DISABLE(__INDEX__) (((__INDEX__) == 0) ? EVAL_COM1_CLK_DISABLE() : 0)
|
||||
|
||||
#define EVAL_COMx_TX_RX_GPIO_CLK_ENABLE(__INDEX__) do { if((__INDEX__) == 0) {EVAL_COM1_TX_RX_GPIO_CLK_ENABLE();} } while(0)
|
||||
#define EVAL_COMx_TX_RX_GPIO_CLK_DISABLE(__INDEX__) (((__INDEX__) == 0) ? EVAL_COM1_TX_RX_GPIO_CLK_DISABLE() : 0)
|
||||
|
||||
/**
|
||||
* @brief Joystick Pins definition
|
||||
*/
|
||||
#if defined(USE_IOEXPANDER)
|
||||
#define JOY_SEL_PIN IO_PIN_0
|
||||
#define JOY_DOWN_PIN IO_PIN_1
|
||||
#define JOY_LEFT_PIN IO_PIN_2
|
||||
#define JOY_RIGHT_PIN IO_PIN_3
|
||||
#define JOY_UP_PIN IO_PIN_4
|
||||
#define JOY_NONE_PIN JOY_ALL_PINS
|
||||
#define JOY_ALL_PINS (IO_PIN_0 | IO_PIN_1 | IO_PIN_2 | IO_PIN_3 | IO_PIN_4)
|
||||
#endif /* USE_IOEXPANDER */
|
||||
|
||||
/**
|
||||
* @brief Eval Pins definition
|
||||
*/
|
||||
#if defined(USE_IOEXPANDER)
|
||||
#define XSDN_PIN IO_PIN_10
|
||||
#define MII_INT_PIN IO_PIN_13
|
||||
#define RSTI_PIN IO_PIN_11
|
||||
#define CAM_PLUG_PIN IO_PIN_12
|
||||
#define TS_INT_PIN IO_PIN_14
|
||||
#define AUDIO_INT_PIN IO_PIN_5
|
||||
#define OTG_FS1_OVER_CURRENT_PIN IO_PIN_6
|
||||
#define OTG_FS1_POWER_SWITCH_PIN IO_PIN_7
|
||||
#define OTG_FS2_OVER_CURRENT_PIN IO_PIN_8
|
||||
#define OTG_FS2_POWER_SWITCH_PIN IO_PIN_9
|
||||
#define SD_DETECT_PIN IO_PIN_15
|
||||
#endif /* USE_IOEXPANDER */
|
||||
|
||||
/* Exported constant IO ------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief TouchScreen FT6206 Slave I2C address 1
|
||||
*/
|
||||
#define TS_I2C_ADDRESS ((uint16_t)0x54)
|
||||
|
||||
/**
|
||||
* @brief TouchScreen FT6336G Slave I2C address 2
|
||||
*/
|
||||
#define TS_I2C_ADDRESS_A02 ((uint16_t)0x70)
|
||||
|
||||
/**
|
||||
* @brief MFX_I2C_ADDR 0
|
||||
*/
|
||||
#define IO_I2C_ADDRESS ((uint16_t)0x84)
|
||||
|
||||
/**
|
||||
* @brief Camera I2C Slave address
|
||||
*/
|
||||
#define CAMERA_I2C_ADDRESS ((uint16_t)0x5A)
|
||||
#define CAMERA_I2C_ADDRESS_2 ((uint16_t)0x78)
|
||||
|
||||
/**
|
||||
* @brief Audio I2C Slave address
|
||||
*/
|
||||
#define AUDIO_I2C_ADDRESS ((uint16_t)0x34)
|
||||
|
||||
/**
|
||||
* @brief EEPROM I2C Slave address 1
|
||||
*/
|
||||
#define EEPROM_I2C_ADDRESS_A01 ((uint16_t)0xA0)
|
||||
|
||||
/**
|
||||
* @brief EEPROM I2C Slave address 2
|
||||
*/
|
||||
#define EEPROM_I2C_ADDRESS_A02 ((uint16_t)0xA6)
|
||||
|
||||
/**
|
||||
* @brief I2C clock speed configuration (in Hz)
|
||||
* WARNING:
|
||||
* Make sure that this define is not already declared in other files
|
||||
* It can be used in parallel by other modules.
|
||||
*/
|
||||
#ifndef I2C_SCL_FREQ_KHZ
|
||||
#define I2C_SCL_FREQ_KHZ 400000 /*!< f(I2C_SCL) = 400 kHz */
|
||||
#endif /* I2C_SCL_FREQ_KHZ */
|
||||
|
||||
/**
|
||||
* @brief User can use this section to tailor I2Cx/I2Cx instance used and associated
|
||||
* resources.
|
||||
* Definition for I2Cx clock resources
|
||||
*/
|
||||
#define EVAL_I2Cx I2C1
|
||||
#define EVAL_I2Cx_CLK_ENABLE() __HAL_RCC_I2C1_CLK_ENABLE()
|
||||
#define EVAL_DMAx_CLK_ENABLE() __HAL_RCC_DMA1_CLK_ENABLE()
|
||||
#define EVAL_I2Cx_SCL_SDA_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
|
||||
|
||||
#define EVAL_I2Cx_FORCE_RESET() __HAL_RCC_I2C1_FORCE_RESET()
|
||||
#define EVAL_I2Cx_RELEASE_RESET() __HAL_RCC_I2C1_RELEASE_RESET()
|
||||
|
||||
/** @brief Definition for I2Cx Pins
|
||||
*/
|
||||
#define EVAL_I2Cx_SCL_PIN GPIO_PIN_8 /*!< PB8 */
|
||||
#define EVAL_I2Cx_SCL_SDA_GPIO_PORT GPIOB
|
||||
#define EVAL_I2Cx_SCL_SDA_AF GPIO_AF4_I2C1
|
||||
#define EVAL_I2Cx_SDA_PIN GPIO_PIN_9 /*!< PB9 */
|
||||
|
||||
/** @brief Definition of I2C interrupt requests
|
||||
*/
|
||||
#define EVAL_I2Cx_EV_IRQn I2C1_EV_IRQn
|
||||
#define EVAL_I2Cx_ER_IRQn I2C1_ER_IRQn
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I_EVAL_LOW_LEVEL_Exported_Macros STM32469I EVAL LOW LEVEL Exported Macros
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I_EVAL_LOW_LEVEL_Exported_Functions STM32469I EVAL LOW LEVEL Exported Functions
|
||||
* @{
|
||||
*/
|
||||
uint32_t BSP_GetVersion(void);
|
||||
void BSP_LED_Init(Led_TypeDef Led);
|
||||
void BSP_LED_DeInit(Led_TypeDef Led);
|
||||
void BSP_LED_On(Led_TypeDef Led);
|
||||
void BSP_LED_Off(Led_TypeDef Led);
|
||||
void BSP_LED_Toggle(Led_TypeDef Led);
|
||||
void BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef Button_Mode);
|
||||
void BSP_PB_DeInit(Button_TypeDef Button);
|
||||
uint32_t BSP_PB_GetState(Button_TypeDef Button);
|
||||
void BSP_COM_Init(COM_TypeDef COM, UART_HandleTypeDef *husart);
|
||||
void BSP_COM_DeInit(COM_TypeDef COM, UART_HandleTypeDef *huart);
|
||||
#if defined(USE_IOEXPANDER)
|
||||
uint8_t BSP_JOY_Init(JOYMode_TypeDef Joy_Mode);
|
||||
void BSP_JOY_DeInit(void);
|
||||
JOYState_TypeDef BSP_JOY_GetState(void);
|
||||
#endif /* USE_IOEXPANDER */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __STM32469I_EVAL_H */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,302 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32469i_eval_audio.h
|
||||
* @author MCD Application Team
|
||||
* @brief This file contains the common defines and functions prototypes for
|
||||
* the stm32469i_eval_audio.c driver.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2017 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 __STM32469I_EVAL_AUDIO_H
|
||||
#define __STM32469I_EVAL_AUDIO_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/* Include audio component Driver */
|
||||
#include "../Components/wm8994/wm8994.h"
|
||||
#include "stm32469i_eval.h"
|
||||
#include "../../../Middlewares/ST/STM32_Audio/Addons/PDM/Inc/pdm2pcm_glo.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32469I_EVAL
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32469I-EVAL_AUDIO
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_AUDIO_Exported_Types STM32469I EVAL AUDIO Exported Types
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_AUDIO_Exported_Constants STM32469I EVAL AUDIO Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
USER SAI defines parameters
|
||||
-----------------------------------------------------------------------------*/
|
||||
/** @defgroup CODEC_AudioFrame_SLOT_TDMMode STM32469I EVAL Audio Slot TDM mode
|
||||
* @brief 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_SAIx SAI1_Block_A
|
||||
#define AUDIO_SAIx_CLK_ENABLE() __HAL_RCC_SAI1_CLK_ENABLE()
|
||||
#define AUDIO_SAIx_CLK_DISABLE() __HAL_RCC_SAI1_CLK_DISABLE()
|
||||
#define AUDIO_SAIx_MCLK_SCK_SD_FS_AF GPIO_AF6_SAI1
|
||||
|
||||
#define AUDIO_SAIx_MCLK_ENABLE() __HAL_RCC_GPIOG_CLK_ENABLE()
|
||||
#define AUDIO_SAIx_MCLK_DISABLE() __HAL_RCC_GPIOG_CLK_DISABLE()
|
||||
|
||||
#define AUDIO_SAIx_MCK_PIN GPIO_PIN_7
|
||||
#define AUDIO_SAIx_MCLK_GPIO_PORT GPIOG
|
||||
|
||||
#define AUDIO_SAIx_SCK_SD_FS_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE()
|
||||
#define AUDIO_SAIx_SCK_SD_FS_DISABLE() __HAL_RCC_GPIOE_CLK_DISABLE()
|
||||
#define AUDIO_SAIx_FS_PIN GPIO_PIN_4
|
||||
#define AUDIO_SAIx_SCK_PIN GPIO_PIN_5
|
||||
#define AUDIO_SAIx_SD_PIN GPIO_PIN_6
|
||||
#define AUDIO_SAIx_SCK_SD_FS_GPIO_PORT GPIOE
|
||||
|
||||
|
||||
/* SAI DMA Stream definitions */
|
||||
#define AUDIO_SAIx_DMAx_CLK_ENABLE() __HAL_RCC_DMA2_CLK_ENABLE()
|
||||
#define AUDIO_SAIx_DMAx_CLK_DISABLE() __HAL_RCC_DMA2_CLK_DISABLE()
|
||||
#define AUDIO_SAIx_DMAx_STREAM DMA2_Stream3
|
||||
#define AUDIO_SAIx_DMAx_CHANNEL DMA_CHANNEL_0
|
||||
#define AUDIO_SAIx_DMAx_IRQ DMA2_Stream3_IRQn
|
||||
#define AUDIO_SAIx_DMAx_PERIPH_DATA_SIZE DMA_PDATAALIGN_HALFWORD
|
||||
#define AUDIO_SAIx_DMAx_MEM_DATA_SIZE DMA_MDATAALIGN_HALFWORD
|
||||
#define DMA_MAX_SZE 0xFFFF
|
||||
|
||||
#define AUDIO_SAIx_DMAx_IRQHandler DMA2_Stream3_IRQHandler
|
||||
|
||||
/* Select the interrupt preemption priority for the DMA interrupt */
|
||||
#define AUDIO_OUT_IRQ_PREPRIO 5 /* Select the preemption priority level(0 is the highest) */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
AUDIO IN CONFIGURATION
|
||||
------------------------------------------------------------------------------*/
|
||||
/* SPI Configuration defines */
|
||||
#define AUDIO_I2Sx SPI3
|
||||
#define AUDIO_I2Sx_CLK_ENABLE() __HAL_RCC_SPI3_CLK_ENABLE()
|
||||
#define AUDIO_I2Sx_CLK_DISABLE() __HAL_RCC_SPI3_CLK_DISABLE()
|
||||
#define AUDIO_I2Sx_SCK_PIN GPIO_PIN_3
|
||||
#define AUDIO_I2Sx_SCK_GPIO_PORT GPIOB
|
||||
#define AUDIO_I2Sx_SCK_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
|
||||
#define AUDIO_I2Sx_SCK_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE()
|
||||
#define AUDIO_I2Sx_SCK_AF GPIO_AF6_SPI3
|
||||
|
||||
#define AUDIO_I2Sx_SD_PIN GPIO_PIN_6
|
||||
#define AUDIO_I2Sx_SD_GPIO_PORT GPIOD
|
||||
#define AUDIO_I2Sx_SD_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE()
|
||||
#define AUDIO_I2Sx_SD_GPIO_CLK_DISABLE() __HAL_RCC_GPIOD_CLK_DISABLE()
|
||||
#define AUDIO_I2Sx_SD_AF GPIO_AF5_I2S3ext
|
||||
|
||||
/* I2S DMA Stream Rx definitions */
|
||||
#define AUDIO_I2Sx_DMAx_CLK_ENABLE() __HAL_RCC_DMA1_CLK_ENABLE()
|
||||
#define AUDIO_I2Sx_DMAx_CLK_DISABLE() __HAL_RCC_DMA1_CLK_DISABLE()
|
||||
#define AUDIO_I2Sx_DMAx_STREAM DMA1_Stream2
|
||||
#define AUDIO_I2Sx_DMAx_CHANNEL DMA_CHANNEL_0
|
||||
#define AUDIO_I2Sx_DMAx_IRQ DMA1_Stream2_IRQn
|
||||
#define AUDIO_I2Sx_DMAx_PERIPH_DATA_SIZE DMA_PDATAALIGN_HALFWORD
|
||||
#define AUDIO_I2Sx_DMAx_MEM_DATA_SIZE DMA_MDATAALIGN_HALFWORD
|
||||
|
||||
#define AUDIO_I2Sx_DMAx_IRQHandler DMA1_Stream2_IRQHandler
|
||||
|
||||
/* Select the interrupt preemption priority and subpriority for the IT/DMA interrupt */
|
||||
#define AUDIO_IN_IRQ_PREPRIO ((uint32_t)6) /* Select the preemption priority level(0 is the highest) */
|
||||
|
||||
|
||||
/* Two channels are used:
|
||||
- one channel as input which is connected to I2S SCK in stereo mode
|
||||
- one channel as output which divides the frequency on the input
|
||||
*/
|
||||
|
||||
#define AUDIO_TIMx_CLK_ENABLE() __HAL_RCC_TIM3_CLK_ENABLE()
|
||||
#define AUDIO_TIMx_CLK_DISABLE() __HAL_RCC_TIM3_CLK_DISABLE()
|
||||
#define AUDIO_TIMx TIM3
|
||||
#define AUDIO_TIMx_IN_CHANNEL TIM_CHANNEL_1
|
||||
#define AUDIO_TIMx_OUT_CHANNEL TIM_CHANNEL_2 /* Select channel 2 as output */
|
||||
#define AUDIO_TIMx_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE()
|
||||
#define AUDIO_TIMx_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE()
|
||||
#define AUDIO_TIMx_GPIO_PORT GPIOC
|
||||
#define AUDIO_TIMx_IN_GPIO_PIN GPIO_PIN_6
|
||||
#define AUDIO_TIMx_OUT_GPIO_PIN GPIO_PIN_7
|
||||
#define AUDIO_TIMx_AF GPIO_AF2_TIM3
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
CONFIGURATION: Audio Driver Configuration parameters
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
#define AUDIODATA_SIZE 2 /* 16-bits audio data size */
|
||||
|
||||
/* Audio status definition */
|
||||
#define AUDIO_OK ((uint8_t)0)
|
||||
#define AUDIO_ERROR ((uint8_t)1)
|
||||
#define AUDIO_TIMEOUT ((uint8_t)2)
|
||||
|
||||
/* AudioFreq * DataSize (2 bytes) * NumChannels (Stereo: 2) */
|
||||
#define DEFAULT_AUDIO_IN_FREQ I2S_AUDIOFREQ_16K
|
||||
#define DEFAULT_AUDIO_IN_BIT_RESOLUTION ((uint8_t)16)
|
||||
#define DEFAULT_AUDIO_IN_CHANNEL_NBR ((uint8_t)2) /* Mono = 1, Stereo = 2 */
|
||||
#define DEFAULT_AUDIO_IN_VOLUME ((uint16_t)64)
|
||||
|
||||
/* PDM buffer input size */
|
||||
#define INTERNAL_BUFF_SIZE (128*DEFAULT_AUDIO_IN_FREQ/16000*DEFAULT_AUDIO_IN_CHANNEL_NBR)
|
||||
/* PCM buffer output size */
|
||||
#define PCM_OUT_SIZE (DEFAULT_AUDIO_IN_FREQ/1000*DEFAULT_AUDIO_IN_CHANNEL_NBR)
|
||||
#define CHANNEL_DEMUX_MASK ((uint8_t)0x55)
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
OPTIONAL Configuration defines parameters
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* Delay for the Codec to be correctly reset */
|
||||
#define CODEC_RESET_DELAY ((uint8_t)5)
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
OUTPUT DEVICES definition
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_AUDIO_Exported_Variables STM32469I EVAL AUDIO Exported Variables
|
||||
* @{
|
||||
*/
|
||||
extern __IO uint16_t AudioInVolume;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_AUDIO_Exported_Macros STM32469I EVAL AUDIO Exported Macros
|
||||
* @{
|
||||
*/
|
||||
#define DMA_MAX(x) (((x) <= DMA_MAX_SZE)? (x):DMA_MAX_SZE)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_AUDIO_OUT_Exported_Functions STM32469I EVAL AUDIO OUT Exported Functions
|
||||
* @{
|
||||
*/
|
||||
uint8_t BSP_AUDIO_OUT_Init(uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq);
|
||||
uint8_t BSP_AUDIO_OUT_Play(uint16_t* pBuffer, uint32_t Size);
|
||||
void BSP_AUDIO_OUT_ChangeBuffer(uint16_t *pData, uint16_t Size);
|
||||
uint8_t BSP_AUDIO_OUT_Pause(void);
|
||||
uint8_t BSP_AUDIO_OUT_Resume(void);
|
||||
uint8_t BSP_AUDIO_OUT_Stop(uint32_t Option);
|
||||
uint8_t BSP_AUDIO_OUT_SetVolume(uint8_t Volume);
|
||||
void BSP_AUDIO_OUT_SetFrequency(uint32_t AudioFreq);
|
||||
void BSP_AUDIO_OUT_SetAudioFrameSlot(uint32_t AudioFrameSlot);
|
||||
uint8_t BSP_AUDIO_OUT_SetMute(uint32_t Cmd);
|
||||
uint8_t BSP_AUDIO_OUT_SetOutputMode(uint8_t Output);
|
||||
void BSP_AUDIO_OUT_DeInit(void);
|
||||
|
||||
/* 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(void);
|
||||
|
||||
/* This function is called when half of the requested buffer has been transferred. */
|
||||
void BSP_AUDIO_OUT_HalfTransfer_CallBack(void);
|
||||
|
||||
/* This function is called when an Interrupt due to transfer error on or peripheral
|
||||
error occurs. */
|
||||
void BSP_AUDIO_OUT_Error_CallBack(void);
|
||||
|
||||
/* These function can be modified in case the current settings (e.g. DMA stream)
|
||||
need to be changed for specific application needs */
|
||||
void BSP_AUDIO_OUT_ClockConfig(SAI_HandleTypeDef *hsai, uint32_t AudioFreq, void *Params);
|
||||
void BSP_AUDIO_OUT_MspInit(SAI_HandleTypeDef *hsai, void *Params);
|
||||
void BSP_AUDIO_OUT_MspDeInit(SAI_HandleTypeDef *hsai, void *Params);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_AUDIO_IN_Exported_Functions STM32469I EVAL AUDIO IN Exported Functions
|
||||
* @{
|
||||
*/
|
||||
uint8_t BSP_AUDIO_IN_Init(uint32_t AudioFreq, uint32_t BitRes, uint32_t ChnlNbr);
|
||||
uint8_t BSP_AUDIO_IN_Record(uint16_t *pData, uint32_t Size);
|
||||
uint8_t BSP_AUDIO_IN_Stop(void);
|
||||
uint8_t BSP_AUDIO_IN_Pause(void);
|
||||
uint8_t BSP_AUDIO_IN_Resume(void);
|
||||
uint8_t BSP_AUDIO_IN_SetVolume(uint8_t Volume);
|
||||
void BSP_AUDIO_IN_DeInit(void);
|
||||
uint8_t BSP_AUDIO_IN_PDMToPCM(uint16_t* PDMBuf, uint16_t* PCMBuf);
|
||||
/* 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(void);
|
||||
void BSP_AUDIO_IN_HalfTransfer_CallBack(void);
|
||||
|
||||
/* This function is called when an Interrupt due to transfer error on or peripheral
|
||||
error occurs. */
|
||||
void BSP_AUDIO_IN_Error_Callback(void);
|
||||
|
||||
/* These function can be modified in case the current settings (e.g. DMA stream)
|
||||
need to be changed for specific application needs */
|
||||
void BSP_AUDIO_IN_MspInit(I2S_HandleTypeDef *hi2s, void *Params);
|
||||
void BSP_AUDIO_IN_MspDeInit(I2S_HandleTypeDef *hi2s, void *Params);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __STM32469I_EVAL_AUDIO_H */
|
||||
@@ -0,0 +1,676 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32469i_eval_camera.c
|
||||
* @author MCD Application Team
|
||||
* @brief This file includes the driver for Camera modules mounted on
|
||||
* STM32469I-EVAL evaluation board.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2017 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 camera.
|
||||
- The S5K5CAG component driver MUST be included with this driver.
|
||||
|
||||
2. Driver description:
|
||||
---------------------
|
||||
+ Initialization steps:
|
||||
o Initialize the camera using the BSP_CAMERA_Init() function.
|
||||
o Start the camera capture/snapshot using the CAMERA_Start() function.
|
||||
o Suspend, resume or stop the camera capture using the following functions:
|
||||
- BSP_CAMERA_Suspend()
|
||||
- BSP_CAMERA_Resume()
|
||||
- BSP_CAMERA_Stop()
|
||||
|
||||
+ Options
|
||||
o Increase or decrease on the fly the brightness and/or contrast
|
||||
using the following function:
|
||||
- BSP_CAMERA_ContrastBrightnessConfig
|
||||
o Add a special effect on the fly using the following functions:
|
||||
- BSP_CAMERA_BlackWhiteConfig()
|
||||
- BSP_CAMERA_ColorEffectConfig()
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32469i_eval_camera.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32469I_EVAL
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_CAMERA STM32469I EVAL CAMERA
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_CAMERA_Private_TypesDefinitions STM32469I EVAL CAMERA Private TypesDefinitions
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_CAMERA_Private_Defines STM32469I EVAL CAMERA Private Defines
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_CAMERA_Private_Macros STM32469I EVAL CAMERA Private Macros
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_CAMERA_Imported_Variables STM32469I EVAL CAMERA Imported Variables
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief DMA2D handle variable
|
||||
*/
|
||||
extern DMA2D_HandleTypeDef hdma2d_eval;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_CAMERA_Private_Variables STM32469I EVAL CAMERA Private Variables
|
||||
* @{
|
||||
*/
|
||||
static DCMI_HandleTypeDef hDcmiEval;
|
||||
CAMERA_DrvTypeDef *CameraDrv;
|
||||
|
||||
/* Camera current resolution naming (QQVGA, VGA, ...) */
|
||||
uint32_t CameraCurrentResolution;
|
||||
|
||||
/* Camera image rotation on LCD Displayed frame buffer */
|
||||
uint32_t CameraRotation = CAMERA_ROTATION_INVALID;
|
||||
|
||||
static uint32_t CameraHwAddress;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_CAMERA_Private_FunctionPrototypes STM32469I EVAL CAMERA Private FunctionPrototypes
|
||||
* @{
|
||||
*/
|
||||
static uint32_t GetSize(uint32_t Resolution);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_CAMERA_Public_Functions STM32469I EVAL CAMERA Public Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Set Camera image rotation on LCD Displayed frame buffer.
|
||||
* @param rotation : uint32_t rotation of camera image in preview buffer sent to LCD
|
||||
* need to be of type Camera_ImageRotationTypeDef
|
||||
* @retval Camera status
|
||||
*/
|
||||
uint8_t BSP_CAMERA_SetRotation(uint32_t rotation)
|
||||
{
|
||||
uint8_t status = CAMERA_ERROR;
|
||||
|
||||
if(rotation < CAMERA_ROTATION_INVALID)
|
||||
{
|
||||
/* Set Camera image rotation on LCD Displayed frame buffer */
|
||||
CameraRotation = rotation;
|
||||
status = CAMERA_OK;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get Camera image rotation on LCD Displayed frame buffer.
|
||||
* @retval rotation : uint32_t value of type Camera_ImageRotationTypeDef
|
||||
*/
|
||||
uint32_t BSP_CAMERA_GetRotation(void)
|
||||
{
|
||||
return(CameraRotation);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initializes the camera.
|
||||
* @param Resolution : camera sensor requested resolution (x, y) : standard resolution
|
||||
* naming QQVGA, QVGA, VGA ...
|
||||
* @retval Camera status
|
||||
*/
|
||||
uint8_t BSP_CAMERA_Init(uint32_t Resolution)
|
||||
{
|
||||
DCMI_HandleTypeDef *phdcmi;
|
||||
uint8_t status = CAMERA_ERROR;
|
||||
|
||||
/* Get the DCMI handle structure */
|
||||
phdcmi = &hDcmiEval;
|
||||
|
||||
/*** Configures the DCMI to interface with the camera module ***/
|
||||
/* DCMI configuration */
|
||||
phdcmi->Init.CaptureRate = DCMI_CR_ALL_FRAME;
|
||||
phdcmi->Init.HSPolarity = DCMI_HSPOLARITY_HIGH;
|
||||
phdcmi->Init.SynchroMode = DCMI_SYNCHRO_HARDWARE;
|
||||
phdcmi->Init.VSPolarity = DCMI_VSPOLARITY_HIGH;
|
||||
phdcmi->Init.ExtendedDataMode = DCMI_EXTEND_DATA_8B;
|
||||
phdcmi->Init.PCKPolarity = DCMI_PCKPOLARITY_RISING;
|
||||
|
||||
phdcmi->Instance = DCMI;
|
||||
|
||||
/* Configure IO functionalities for CAMERA detect pin */
|
||||
BSP_IO_Init();
|
||||
/* Apply Camera Module hardware reset */
|
||||
BSP_CAMERA_HwReset();
|
||||
|
||||
/* Check if the CAMERA Module is plugged on board */
|
||||
if(BSP_IO_ReadPin(CAM_PLUG_PIN) == BSP_IO_PIN_SET)
|
||||
{
|
||||
status = CAMERA_NOT_DETECTED;
|
||||
return status; /* Exit with error */
|
||||
}
|
||||
|
||||
/* Read ID of Camera module via I2C */
|
||||
if (s5k5cag_ReadID(CAMERA_I2C_ADDRESS) == S5K5CAG_ID)
|
||||
{
|
||||
/* Initialize the camera driver structure */
|
||||
CameraDrv = &s5k5cag_drv;
|
||||
CameraHwAddress = CAMERA_I2C_ADDRESS;
|
||||
|
||||
/* DCMI Initialization */
|
||||
BSP_CAMERA_MspInit(&hDcmiEval, NULL);
|
||||
HAL_DCMI_Init(phdcmi);
|
||||
|
||||
/* Camera Module Initialization via I2C to the wanted 'Resolution' */
|
||||
CameraDrv->Init(CameraHwAddress, Resolution);
|
||||
|
||||
CameraCurrentResolution = Resolution;
|
||||
|
||||
/* Return CAMERA_OK status */
|
||||
status = CAMERA_OK;
|
||||
}
|
||||
else if(ov5640_ReadID(CAMERA_I2C_ADDRESS_2) == OV5640_ID)
|
||||
{
|
||||
/* Initialize the camera driver structure */
|
||||
CameraDrv = &ov5640_drv;
|
||||
CameraHwAddress = CAMERA_I2C_ADDRESS_2;
|
||||
|
||||
/* DCMI Initialization */
|
||||
BSP_CAMERA_MspInit(&hDcmiEval, NULL);
|
||||
HAL_DCMI_Init(phdcmi);
|
||||
|
||||
/* Camera Module Initialization via I2C to the wanted 'Resolution' */
|
||||
CameraDrv->Init(CameraHwAddress, Resolution);
|
||||
|
||||
CameraCurrentResolution = Resolution;
|
||||
|
||||
/* Return CAMERA_OK status */
|
||||
status = CAMERA_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Return CAMERA_NOT_SUPPORTED status */
|
||||
status = CAMERA_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief DeInitializes the camera.
|
||||
* @retval Camera status
|
||||
*/
|
||||
uint8_t BSP_CAMERA_DeInit(void)
|
||||
{
|
||||
hDcmiEval.Instance = DCMI;
|
||||
|
||||
HAL_DCMI_DeInit(&hDcmiEval);
|
||||
BSP_CAMERA_MspDeInit(&hDcmiEval, NULL);
|
||||
return CAMERA_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Starts the camera capture in continuous mode.
|
||||
* @param buff: pointer to the camera output buffer
|
||||
*/
|
||||
void BSP_CAMERA_ContinuousStart(uint8_t *buff)
|
||||
{
|
||||
/* Start the camera capture */
|
||||
HAL_DCMI_Start_DMA(&hDcmiEval, DCMI_MODE_CONTINUOUS, (uint32_t)buff, GetSize(CameraCurrentResolution));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Starts the camera capture in snapshot mode.
|
||||
* @param buff: pointer to the camera output buffer
|
||||
*/
|
||||
void BSP_CAMERA_SnapshotStart(uint8_t *buff)
|
||||
{
|
||||
/* Start the camera capture */
|
||||
HAL_DCMI_Start_DMA(&hDcmiEval, DCMI_MODE_SNAPSHOT, (uint32_t)buff, GetSize(CameraCurrentResolution));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Suspend the CAMERA capture
|
||||
*/
|
||||
void BSP_CAMERA_Suspend(void)
|
||||
{
|
||||
/* Suspend the Camera Capture */
|
||||
HAL_DCMI_Suspend(&hDcmiEval);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Resume the CAMERA capture
|
||||
*/
|
||||
void BSP_CAMERA_Resume(void)
|
||||
{
|
||||
/* Start the Camera Capture */
|
||||
HAL_DCMI_Resume(&hDcmiEval);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Stop the CAMERA capture
|
||||
* @retval Camera status
|
||||
*/
|
||||
uint8_t BSP_CAMERA_Stop(void)
|
||||
{
|
||||
uint8_t status = CAMERA_ERROR;
|
||||
|
||||
if(HAL_DCMI_Stop(&hDcmiEval) == HAL_OK)
|
||||
{
|
||||
status = CAMERA_OK;
|
||||
}
|
||||
|
||||
/* Set Camera in Power Down */
|
||||
BSP_CAMERA_PwrDown();
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief CANERA hardware reset
|
||||
*/
|
||||
void BSP_CAMERA_HwReset(void)
|
||||
{
|
||||
/* Camera sensor RESET sequence */
|
||||
BSP_IO_ConfigPin(RSTI_PIN, IO_MODE_OUTPUT);
|
||||
BSP_IO_ConfigPin(XSDN_PIN, IO_MODE_OUTPUT);
|
||||
|
||||
/* Assert the camera STANDBY pin (active high) */
|
||||
BSP_IO_WritePin(XSDN_PIN, BSP_IO_PIN_SET);
|
||||
|
||||
/* Assert the camera RSTI pin (active low) */
|
||||
BSP_IO_WritePin(RSTI_PIN, BSP_IO_PIN_RESET);
|
||||
|
||||
HAL_Delay(100); /* RST and XSDN signals asserted during 100ms */
|
||||
|
||||
/* De-assert the camera STANDBY pin (active high) */
|
||||
BSP_IO_WritePin(XSDN_PIN, BSP_IO_PIN_RESET);
|
||||
|
||||
HAL_Delay(3); /* RST de-asserted and XSDN asserted during 3ms */
|
||||
|
||||
/* De-assert the camera RSTI pin (active low) */
|
||||
BSP_IO_WritePin(RSTI_PIN, BSP_IO_PIN_SET);
|
||||
|
||||
HAL_Delay(6); /* RST de-asserted during 3ms */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief CAMERA power down
|
||||
*/
|
||||
void BSP_CAMERA_PwrDown(void)
|
||||
{
|
||||
/* Camera power down sequence */
|
||||
BSP_IO_ConfigPin(RSTI_PIN, IO_MODE_OUTPUT);
|
||||
BSP_IO_ConfigPin(XSDN_PIN, IO_MODE_OUTPUT);
|
||||
|
||||
/* De-assert the camera STANDBY pin (active high) */
|
||||
BSP_IO_WritePin(XSDN_PIN, BSP_IO_PIN_RESET);
|
||||
|
||||
/* Assert the camera RSTI pin (active low) */
|
||||
BSP_IO_WritePin(RSTI_PIN, BSP_IO_PIN_RESET);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configures the camera contrast and brightness.
|
||||
* @param contrast_level: Contrast level
|
||||
* This parameter can be one of the following values:
|
||||
* @arg CAMERA_CONTRAST_LEVEL4: for contrast +2
|
||||
* @arg CAMERA_CONTRAST_LEVEL3: for contrast +1
|
||||
* @arg CAMERA_CONTRAST_LEVEL2: for contrast 0
|
||||
* @arg CAMERA_CONTRAST_LEVEL1: for contrast -1
|
||||
* @arg CAMERA_CONTRAST_LEVEL0: for contrast -2
|
||||
* @param brightness_level: Contrast level
|
||||
* This parameter can be one of the following values:
|
||||
* @arg CAMERA_BRIGHTNESS_LEVEL4: for brightness +2
|
||||
* @arg CAMERA_BRIGHTNESS_LEVEL3: for brightness +1
|
||||
* @arg CAMERA_BRIGHTNESS_LEVEL2: for brightness 0
|
||||
* @arg CAMERA_BRIGHTNESS_LEVEL1: for brightness -1
|
||||
* @arg CAMERA_BRIGHTNESS_LEVEL0: for brightness -2
|
||||
*/
|
||||
void BSP_CAMERA_ContrastBrightnessConfig(uint32_t contrast_level, uint32_t brightness_level)
|
||||
{
|
||||
if(CameraDrv->Config != NULL)
|
||||
{
|
||||
CameraDrv->Config(CameraHwAddress, CAMERA_CONTRAST_BRIGHTNESS, contrast_level, brightness_level);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configures the camera white balance.
|
||||
* @param Mode: black_white mode
|
||||
* This parameter can be one of the following values:
|
||||
* @arg CAMERA_BLACK_WHITE_BW
|
||||
* @arg CAMERA_BLACK_WHITE_NEGATIVE
|
||||
* @arg CAMERA_BLACK_WHITE_BW_NEGATIVE
|
||||
* @arg CAMERA_BLACK_WHITE_NORMAL
|
||||
*/
|
||||
void BSP_CAMERA_BlackWhiteConfig(uint32_t Mode)
|
||||
{
|
||||
if(CameraDrv->Config != NULL)
|
||||
{
|
||||
CameraDrv->Config(CameraHwAddress, CAMERA_BLACK_WHITE, Mode, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configures the camera color effect.
|
||||
* @param Effect: Color effect
|
||||
* This parameter can be one of the following values:
|
||||
* @arg CAMERA_COLOR_EFFECT_NONE
|
||||
* @arg CAMERA_COLOR_EFFECT_BLUE
|
||||
* @arg CAMERA_COLOR_EFFECT_GREEN
|
||||
* @arg CAMERA_COLOR_EFFECT_RED
|
||||
* @arg CAMERA_COLOR_EFFECT_ANTIQUE
|
||||
*/
|
||||
void BSP_CAMERA_ColorEffectConfig(uint32_t Effect)
|
||||
{
|
||||
if(CameraDrv->Config != NULL)
|
||||
{
|
||||
CameraDrv->Config(CameraHwAddress, CAMERA_COLOR_EFFECT, Effect, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Handles DCMI interrupt request.
|
||||
*/
|
||||
void BSP_CAMERA_IRQHandler(void)
|
||||
{
|
||||
HAL_DCMI_IRQHandler(&hDcmiEval);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Handles DMA interrupt request.
|
||||
*/
|
||||
void BSP_CAMERA_DMA_IRQHandler(void)
|
||||
{
|
||||
HAL_DMA_IRQHandler(hDcmiEval.DMA_Handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the capture size in pixels unit.
|
||||
* @param Resolution: the current resolution.
|
||||
* @retval capture size in pixels unit.
|
||||
*/
|
||||
static uint32_t GetSize(uint32_t Resolution)
|
||||
{
|
||||
uint32_t size = 0;
|
||||
|
||||
/* Get capture size */
|
||||
switch (Resolution)
|
||||
{
|
||||
case CAMERA_R160x120:
|
||||
{
|
||||
size = 0x2580;
|
||||
}
|
||||
break;
|
||||
case CAMERA_R320x240:
|
||||
{
|
||||
size = 0x9600;
|
||||
}
|
||||
break;
|
||||
case CAMERA_R480x272:
|
||||
{
|
||||
size = 0xFF00;
|
||||
}
|
||||
break;
|
||||
case CAMERA_R640x480:
|
||||
{
|
||||
size = 0x25800;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initializes the DCMI MSP.
|
||||
* @param hdcmi: HDMI handle
|
||||
* @param Params : pointer on additional configuration parameters, can be NULL.
|
||||
*/
|
||||
__weak void BSP_CAMERA_MspInit(DCMI_HandleTypeDef *hdcmi, void *Params)
|
||||
{
|
||||
static DMA_HandleTypeDef hdma_eval;
|
||||
GPIO_InitTypeDef gpio_init_structure;
|
||||
|
||||
/*** Enable peripherals and GPIO clocks ***/
|
||||
/* Enable DCMI clock */
|
||||
__HAL_RCC_DCMI_CLK_ENABLE();
|
||||
|
||||
/* Enable DMA2 clock */
|
||||
__HAL_RCC_DMA2_CLK_ENABLE();
|
||||
|
||||
/* Enable GPIO clocks */
|
||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOD_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOE_CLK_ENABLE();
|
||||
|
||||
/*** Configure the GPIO ***/
|
||||
/* Configure DCMI GPIO as alternate function */
|
||||
gpio_init_structure.Pin = GPIO_PIN_4 | GPIO_PIN_6;
|
||||
gpio_init_structure.Mode = GPIO_MODE_AF_PP;
|
||||
gpio_init_structure.Pull = GPIO_PULLUP;
|
||||
gpio_init_structure.Speed = GPIO_SPEED_HIGH;
|
||||
gpio_init_structure.Alternate = GPIO_AF13_DCMI;
|
||||
HAL_GPIO_Init(GPIOA, &gpio_init_structure);
|
||||
|
||||
gpio_init_structure.Pin = GPIO_PIN_7;
|
||||
gpio_init_structure.Mode = GPIO_MODE_AF_PP;
|
||||
gpio_init_structure.Pull = GPIO_PULLUP;
|
||||
gpio_init_structure.Speed = GPIO_SPEED_HIGH;
|
||||
gpio_init_structure.Alternate = GPIO_AF13_DCMI;
|
||||
HAL_GPIO_Init(GPIOB, &gpio_init_structure);
|
||||
|
||||
gpio_init_structure.Pin = GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_8 |\
|
||||
GPIO_PIN_9 | GPIO_PIN_11;
|
||||
gpio_init_structure.Mode = GPIO_MODE_AF_PP;
|
||||
gpio_init_structure.Pull = GPIO_PULLUP;
|
||||
gpio_init_structure.Speed = GPIO_SPEED_HIGH;
|
||||
gpio_init_structure.Alternate = GPIO_AF13_DCMI;
|
||||
HAL_GPIO_Init(GPIOC, &gpio_init_structure);
|
||||
|
||||
gpio_init_structure.Pin = GPIO_PIN_3 | GPIO_PIN_6;
|
||||
gpio_init_structure.Mode = GPIO_MODE_AF_PP;
|
||||
gpio_init_structure.Pull = GPIO_PULLUP;
|
||||
gpio_init_structure.Speed = GPIO_SPEED_HIGH;
|
||||
gpio_init_structure.Alternate = GPIO_AF13_DCMI;
|
||||
HAL_GPIO_Init(GPIOD, &gpio_init_structure);
|
||||
|
||||
gpio_init_structure.Pin = GPIO_PIN_5 | GPIO_PIN_6;
|
||||
gpio_init_structure.Mode = GPIO_MODE_AF_PP;
|
||||
gpio_init_structure.Pull = GPIO_PULLUP;
|
||||
gpio_init_structure.Speed = GPIO_SPEED_HIGH;
|
||||
gpio_init_structure.Alternate = GPIO_AF13_DCMI;
|
||||
HAL_GPIO_Init(GPIOE, &gpio_init_structure);
|
||||
|
||||
/*** Configure the DMA ***/
|
||||
/* Set the parameters to be configured */
|
||||
hdma_eval.Init.Channel = DMA_CHANNEL_1;
|
||||
hdma_eval.Init.Direction = DMA_PERIPH_TO_MEMORY;
|
||||
hdma_eval.Init.PeriphInc = DMA_PINC_DISABLE;
|
||||
hdma_eval.Init.MemInc = DMA_MINC_ENABLE;
|
||||
hdma_eval.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
|
||||
hdma_eval.Init.MemDataAlignment = DMA_MDATAALIGN_WORD;
|
||||
hdma_eval.Init.Mode = DMA_CIRCULAR;
|
||||
hdma_eval.Init.Priority = DMA_PRIORITY_HIGH;
|
||||
hdma_eval.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
|
||||
hdma_eval.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
|
||||
hdma_eval.Init.MemBurst = DMA_MBURST_SINGLE;
|
||||
hdma_eval.Init.PeriphBurst = DMA_PBURST_SINGLE;
|
||||
|
||||
hdma_eval.Instance = DMA2_Stream1;
|
||||
|
||||
/* Associate the initialized DMA handle to the DCMI handle */
|
||||
__HAL_LINKDMA(hdcmi, DMA_Handle, hdma_eval);
|
||||
|
||||
/*** Configure the NVIC for DCMI and DMA ***/
|
||||
/* NVIC configuration for DCMI transfer complete interrupt */
|
||||
HAL_NVIC_SetPriority(DCMI_IRQn, 5, 0);
|
||||
HAL_NVIC_EnableIRQ(DCMI_IRQn);
|
||||
|
||||
/* NVIC configuration for DMA2D transfer complete interrupt */
|
||||
HAL_NVIC_SetPriority(DMA2_Stream1_IRQn, 5, 0);
|
||||
HAL_NVIC_EnableIRQ(DMA2_Stream1_IRQn);
|
||||
|
||||
/* Configure the DMA stream */
|
||||
HAL_DMA_Init(hdcmi->DMA_Handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DeInitializes the DCMI MSP.
|
||||
* @param hdcmi: HDMI handle
|
||||
* @param Params : pointer on additional configuration parameters, can be NULL.
|
||||
*/
|
||||
__weak void BSP_CAMERA_MspDeInit(DCMI_HandleTypeDef *hdcmi, void *Params)
|
||||
{
|
||||
/* Disable NVIC for DCMI transfer complete interrupt */
|
||||
HAL_NVIC_DisableIRQ(DCMI_IRQn);
|
||||
|
||||
/* Disable NVIC for DMA2 transfer complete interrupt */
|
||||
HAL_NVIC_DisableIRQ(DMA2_Stream1_IRQn);
|
||||
|
||||
/* Configure the DMA stream */
|
||||
HAL_DMA_DeInit(hdcmi->DMA_Handle);
|
||||
|
||||
/* Disable DCMI clock */
|
||||
__HAL_RCC_DCMI_CLK_DISABLE();
|
||||
|
||||
/* GPIO pins clock and DMA clock can be shut down in the application
|
||||
by surcharging this __weak function */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Line event callback
|
||||
* @param hdcmi: pointer to the DCMI handle
|
||||
*/
|
||||
void HAL_DCMI_LineEventCallback(DCMI_HandleTypeDef *hdcmi)
|
||||
{
|
||||
BSP_CAMERA_LineEventCallback();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Line Event callback.
|
||||
*/
|
||||
__weak void BSP_CAMERA_LineEventCallback(void)
|
||||
{
|
||||
/* NOTE : This function Should not be modified, when the callback is needed,
|
||||
the HAL_DCMI_LineEventCallback could be implemented in the user file
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief VSYNC event callback
|
||||
* @param hdcmi: pointer to the DCMI handle
|
||||
*/
|
||||
void HAL_DCMI_VsyncEventCallback(DCMI_HandleTypeDef *hdcmi)
|
||||
{
|
||||
BSP_CAMERA_VsyncEventCallback();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief VSYNC Event callback.
|
||||
*/
|
||||
__weak void BSP_CAMERA_VsyncEventCallback(void)
|
||||
{
|
||||
/* NOTE : This function Should not be modified, when the callback is needed,
|
||||
the HAL_DCMI_VsyncEventCallback could be implemented in the user file
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Frame event callback
|
||||
* @param hdcmi: pointer to the DCMI handle
|
||||
*/
|
||||
void HAL_DCMI_FrameEventCallback(DCMI_HandleTypeDef *hdcmi)
|
||||
{
|
||||
BSP_CAMERA_FrameEventCallback();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Frame Event callback.
|
||||
*/
|
||||
__weak void BSP_CAMERA_FrameEventCallback(void)
|
||||
{
|
||||
/* NOTE : This function Should not be modified, when the callback is needed,
|
||||
the HAL_DCMI_FrameEventCallback could be implemented in the user file
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Error callback
|
||||
* @param hdcmi: pointer to the DCMI handle
|
||||
*/
|
||||
void HAL_DCMI_ErrorCallback(DCMI_HandleTypeDef *hdcmi)
|
||||
{
|
||||
BSP_CAMERA_ErrorCallback();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Error callback.
|
||||
*/
|
||||
__weak void BSP_CAMERA_ErrorCallback(void)
|
||||
{
|
||||
/* NOTE : This function Should not be modified, when the callback is needed,
|
||||
the HAL_DCMI_ErrorCallback could be implemented in the user file
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@@ -0,0 +1,158 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32469i_eval_camera.h
|
||||
* @author MCD Application Team
|
||||
* @brief This file contains the common defines and functions prototypes for
|
||||
* the stm32469i_eval_camera.c driver.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2017 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 __STM32469I_EVAL_CAMERA_H
|
||||
#define __STM32469I_EVAL_CAMERA_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/* Include Camera component Driver */
|
||||
#include "../Components/s5k5cag/s5k5cag.h"
|
||||
#include "../Components/ov5640/ov5640.h"
|
||||
|
||||
/* Include IO Driver */
|
||||
#include "stm32469i_eval_io.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32469I_EVAL
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32469I-EVAL_CAMERA
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_CAMERA_Exported_Types STM32469I EVAL CAMERA Exported Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Camera State structures definition
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
CAMERA_OK = 0x00,
|
||||
CAMERA_ERROR = 0x01,
|
||||
CAMERA_TIMEOUT = 0x02,
|
||||
CAMERA_NOT_DETECTED = 0x03,
|
||||
CAMERA_NOT_SUPPORTED = 0x04
|
||||
|
||||
} Camera_StatusTypeDef;
|
||||
|
||||
/**
|
||||
* @brief Camera Image rotation definition
|
||||
* in frame buffer for LCD Display.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
CAMERA_NO_ROTATION = 0x00,
|
||||
CAMERA_ROTATION_90 = 0x01,
|
||||
CAMERA_ROTATION_INVALID = 0x02
|
||||
|
||||
} Camera_RotationTypeDef;
|
||||
|
||||
#define RESOLUTION_R160x120 CAMERA_R160x120 /* QQVGA Resolution */
|
||||
#define RESOLUTION_R320x240 CAMERA_R320x240 /* QVGA Resolution */
|
||||
#define RESOLUTION_R480x272 CAMERA_R480x272 /* 480x272 Resolution */
|
||||
#define RESOLUTION_R640x480 CAMERA_R640x480 /* VGA Resolution */
|
||||
|
||||
#define CAMERA_VGA_RES_X 640
|
||||
#define CAMERA_VGA_RES_Y 480
|
||||
#define CAMERA_480x272_RES_X 480
|
||||
#define CAMERA_480x272_RES_Y 272
|
||||
#define CAMERA_QVGA_RES_X 320
|
||||
#define CAMERA_QVGA_RES_Y 240
|
||||
#define CAMERA_QQVGA_RES_X 160
|
||||
#define CAMERA_QQVGA_RES_Y 120
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_CAMERA_Exported_Constants STM32469I EVAL CAMERA Exported Constants
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_CAMERA_Exported_Functions STM32469I EVAL CAMERA Exported Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
uint8_t BSP_CAMERA_SetRotation(uint32_t rotation);
|
||||
uint32_t BSP_CAMERA_GetRotation(void);
|
||||
|
||||
uint8_t BSP_CAMERA_Init(uint32_t Resolution);
|
||||
uint8_t BSP_CAMERA_DeInit(void);
|
||||
void BSP_CAMERA_ContinuousStart(uint8_t *buff);
|
||||
void BSP_CAMERA_SnapshotStart(uint8_t *buff);
|
||||
void BSP_CAMERA_Suspend(void);
|
||||
void BSP_CAMERA_Resume(void);
|
||||
uint8_t BSP_CAMERA_Stop(void);
|
||||
void BSP_CAMERA_HwReset(void);
|
||||
void BSP_CAMERA_PwrDown(void);
|
||||
void BSP_CAMERA_LineEventCallback(void);
|
||||
void BSP_CAMERA_VsyncEventCallback(void);
|
||||
void BSP_CAMERA_FrameEventCallback(void);
|
||||
void BSP_CAMERA_ErrorCallback(void);
|
||||
|
||||
/* Camera features functions prototype */
|
||||
void BSP_CAMERA_ContrastBrightnessConfig(uint32_t contrast_level, uint32_t brightness_level);
|
||||
void BSP_CAMERA_BlackWhiteConfig(uint32_t Mode);
|
||||
void BSP_CAMERA_ColorEffectConfig(uint32_t Effect);
|
||||
|
||||
/* To be called in DCMI_IRQHandler function */
|
||||
void BSP_CAMERA_IRQHandler(void);
|
||||
|
||||
/* To be called in DMA2_Stream1_IRQHandler function */
|
||||
void BSP_CAMERA_DMA_IRQHandler(void);
|
||||
/* These functions can be modified in case the current settings (e.g. DMA stream)
|
||||
need to be changed for specific application needs */
|
||||
void BSP_CAMERA_MspInit(DCMI_HandleTypeDef *hdcmi, void *Params);
|
||||
void BSP_CAMERA_MspDeInit(DCMI_HandleTypeDef *hdcmi, void *Params);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __STM32469I_EVAL_CAMERA_H */
|
||||
@@ -0,0 +1,453 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32469i_eval_eeprom.c
|
||||
* @author MCD Application Team
|
||||
* @brief This file provides a set of functions needed to manage an I2C M24LR64
|
||||
* EEPROM memory.
|
||||
* To be able to use this driver, the switch EE_M24LR64 must be defined
|
||||
* in your toolchain compiler preprocessor
|
||||
*
|
||||
* ===================================================================
|
||||
* Notes:
|
||||
* - This driver is intended for STM32F4xx families devices only.
|
||||
* - The I2C EEPROM memory (M24LR64) is available on separate daughter
|
||||
* board ANT7-M24LR-A, which is not provided with the STM32469I-EVAL
|
||||
* board.
|
||||
* To use this driver you have to connect the ANT7-M24LR-A to CN2
|
||||
* connector of STM32469I-EVAL board.
|
||||
* ===================================================================
|
||||
*
|
||||
* It implements a high level communication layer for read and write
|
||||
* from/to this memory. The needed STM32F4xx hardware resources (I2C and
|
||||
* GPIO) are defined in stm32469i_eval.h file, and the initialization is
|
||||
* performed in EEPROM_IO_Init() function declared in stm32469i_eval.c
|
||||
* file.
|
||||
* You can easily tailor this driver to any other development board,
|
||||
* by just adapting the defines for hardware resources and
|
||||
* EEPROM_IO_Init() function.
|
||||
*
|
||||
* @note In this driver, basic read and write functions (BSP_EEPROM_ReadBuffer()
|
||||
* and BSP_EEPROM_WritePage()) use DMA mode to perform the data
|
||||
* transfer to/from EEPROM memory.
|
||||
*
|
||||
* @note Regarding BSP_EEPROM_WritePage(), it is a optimized function to perform
|
||||
* small write (less than 1 page) BUT The number of bytes (combined to write start address) must not
|
||||
* cross the EEPROM page boundary. This function can only write into
|
||||
* the boundaries of an EEPROM page.
|
||||
* This function doesn't check on boundaries condition (in this driver
|
||||
* the function BSP_EEPROM_WriteBuffer() which calls BSP_EEPROM_WritePage() is
|
||||
* responsible of checking on Page boundaries).
|
||||
*
|
||||
*
|
||||
* +-----------------------------------------------------------------+
|
||||
* | Pin assignment for M24LR64 EEPROM |
|
||||
* +---------------------------------------+-----------+-------------+
|
||||
* | STM32F4xx I2C Pins | EEPROM | Pin |
|
||||
* +---------------------------------------+-----------+-------------+
|
||||
* | . | E0(GND) | 1 (0V) |
|
||||
* | . | AC0 | 2 |
|
||||
* | . | AC1 | 3 |
|
||||
* | . | VSS | 4 (0V) |
|
||||
* | SDA | SDA | 5 |
|
||||
* | SCL | SCL | 6 |
|
||||
* | . | E1(GND) | 7 (0V) |
|
||||
* | . | VDD | 8 (3.3V) |
|
||||
* +---------------------------------------+-----------+-------------+
|
||||
*
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2017 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 "stm32469i_eval_eeprom.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32469I_EVAL
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_EEPROM STM32469I EVAL EEPROM
|
||||
* @brief This file includes the I2C EEPROM driver of STM32469I-EVAL evaluation board.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_EEPROM_Private_Types STM32469I EVAL EEPROM Private Types
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_EEPROM_Private_Defines STM32469I EVAL EEPROM Private Defines
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_EEPROM_Private_Macros STM32469I EVAL EEPROM Private Macros
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_EEPROM_Private_Variables STM32469I EVAL EEPROM Private Variables
|
||||
* @{
|
||||
*/
|
||||
__IO uint16_t EEPROMAddress = 0;
|
||||
__IO uint32_t EEPROMTimeout = EEPROM_READ_TIMEOUT;
|
||||
__IO uint16_t EEPROMDataRead;
|
||||
__IO uint8_t EEPROMDataWrite;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_EEPROM_Private_Function_Prototypes STM32469I EVAL EEPROM Private Prototypes
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_EEPROM_Private_Functions STM32469I EVAL EEPROM Private Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Initializes peripherals used by the I2C EEPROM driver.
|
||||
*
|
||||
* @note There are 2 different versions of M24LR64 (A01 & A02).
|
||||
* Then try to connect on 1st one (EEPROM_I2C_ADDRESS_A01)
|
||||
* and if problem, check the 2nd one (EEPROM_I2C_ADDRESS_A02)
|
||||
* @retval EEPROM_OK (0) if operation is correctly performed, else return value
|
||||
* different from EEPROM_OK (0)
|
||||
*/
|
||||
uint32_t BSP_EEPROM_Init(void)
|
||||
{
|
||||
/* I2C Initialization */
|
||||
EEPROM_IO_Init();
|
||||
|
||||
/* Select the EEPROM address for A01 and check if OK */
|
||||
EEPROMAddress = EEPROM_I2C_ADDRESS_A01;
|
||||
if(EEPROM_IO_IsDeviceReady(EEPROMAddress, EEPROM_MAX_TRIALS) != HAL_OK)
|
||||
{
|
||||
/* Select the EEPROM address for A02 and check if OK */
|
||||
EEPROMAddress = EEPROM_I2C_ADDRESS_A02;
|
||||
if(EEPROM_IO_IsDeviceReady(EEPROMAddress, EEPROM_MAX_TRIALS) != HAL_OK)
|
||||
{
|
||||
return EEPROM_FAIL;
|
||||
}
|
||||
}
|
||||
return EEPROM_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DeInitializes the EEPROM.
|
||||
* @retval EEPROM state
|
||||
*/
|
||||
uint8_t BSP_EEPROM_DeInit(void)
|
||||
{
|
||||
/* I2C won't be disabled because common to other functionalities */
|
||||
return EEPROM_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reads a block of data from the EEPROM.
|
||||
* @param pBuffer: pointer to the buffer that receives the data read from
|
||||
* the EEPROM.
|
||||
* @param ReadAddr: EEPROM's internal address to start reading from.
|
||||
* @param NumByteToRead: pointer to the variable holding number of bytes to
|
||||
* be read from the EEPROM.
|
||||
*
|
||||
* @note The variable pointed by NumByteToRead is reset to 0 when all the
|
||||
* data are read from the EEPROM. Application should monitor this
|
||||
* variable in order know when the transfer is complete.
|
||||
*
|
||||
* @retval EEPROM_OK (0) if operation is correctly performed, else return value
|
||||
* different from EEPROM_OK (0) or the timeout user callback.
|
||||
*/
|
||||
uint32_t BSP_EEPROM_ReadBuffer(uint8_t* pBuffer, uint16_t ReadAddr, uint16_t* NumByteToRead)
|
||||
{
|
||||
uint32_t buffersize = *NumByteToRead;
|
||||
|
||||
/* Set the pointer to the Number of data to be read. This pointer will be used
|
||||
by the DMA Transfer Completer interrupt Handler in order to reset the
|
||||
variable to 0. User should check on this variable in order to know if the
|
||||
DMA transfer has been complete or not. */
|
||||
EEPROMDataRead = *NumByteToRead;
|
||||
|
||||
if(EEPROM_IO_ReadData(EEPROMAddress, ReadAddr, pBuffer, buffersize) != HAL_OK)
|
||||
{
|
||||
BSP_EEPROM_TIMEOUT_UserCallback();
|
||||
return EEPROM_FAIL;
|
||||
}
|
||||
|
||||
/* If all operations OK, return EEPROM_OK (0) */
|
||||
return EEPROM_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Writes more than one byte to the EEPROM with a single WRITE cycle.
|
||||
*
|
||||
* @note The number of bytes (combined to write start address) must not
|
||||
* cross the EEPROM page boundary. This function can only write into
|
||||
* the boundaries of an EEPROM page.
|
||||
* This function doesn't check on boundaries condition (in this driver
|
||||
* the function BSP_EEPROM_WriteBuffer() which calls BSP_EEPROM_WritePage() is
|
||||
* responsible of checking on Page boundaries).
|
||||
*
|
||||
* @param pBuffer: pointer to the buffer containing the data to be written to
|
||||
* the EEPROM.
|
||||
* @param WriteAddr: EEPROM's internal address to write to.
|
||||
* @param NumByteToWrite: pointer to the variable holding number of bytes to
|
||||
* be written into the EEPROM.
|
||||
*
|
||||
* @note The variable pointed by NumByteToWrite is reset to 0 when all the
|
||||
* data are written to the EEPROM. Application should monitor this
|
||||
* variable in order know when the transfer is complete.
|
||||
*
|
||||
* @note This function just configure the communication and enable the DMA
|
||||
* channel to transfer data. Meanwhile, the user application may perform
|
||||
* other tasks in parallel.
|
||||
*
|
||||
* @retval EEPROM_OK (0) if operation is correctly performed, else return value
|
||||
* different from EEPROM_OK (0) or the timeout user callback.
|
||||
*/
|
||||
uint32_t BSP_EEPROM_WritePage(uint8_t* pBuffer, uint16_t WriteAddr, uint8_t* NumByteToWrite)
|
||||
{
|
||||
uint32_t buffersize = *NumByteToWrite;
|
||||
uint32_t status = EEPROM_OK;
|
||||
|
||||
/* Set the pointer to the Number of data to be written. This pointer will be used
|
||||
by the DMA Transfer Completer interrupt Handler in order to reset the
|
||||
variable to 0. User should check on this variable in order to know if the
|
||||
DMA transfer has been complete or not. */
|
||||
EEPROMDataWrite = *NumByteToWrite;
|
||||
|
||||
if(EEPROM_IO_WriteData(EEPROMAddress, WriteAddr, pBuffer, buffersize) != HAL_OK)
|
||||
{
|
||||
BSP_EEPROM_TIMEOUT_UserCallback();
|
||||
status = EEPROM_FAIL;
|
||||
}
|
||||
|
||||
if(BSP_EEPROM_WaitEepromStandbyState() != EEPROM_OK)
|
||||
{
|
||||
return EEPROM_FAIL;
|
||||
}
|
||||
|
||||
/* If all operations OK, return EEPROM_OK (0) */
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Writes buffer of data to the I2C EEPROM.
|
||||
* @param pBuffer: pointer to the buffer containing the data to be written
|
||||
* to the EEPROM.
|
||||
* @param WriteAddr: EEPROM's internal address to write to.
|
||||
* @param NumByteToWrite: number of bytes to write to the EEPROM.
|
||||
* @retval EEPROM_OK (0) if operation is correctly performed, else return value
|
||||
* different from EEPROM_OK (0) or the timeout user callback.
|
||||
*/
|
||||
uint32_t BSP_EEPROM_WriteBuffer(uint8_t *pBuffer, uint16_t WriteAddr, uint16_t NumByteToWrite)
|
||||
{
|
||||
uint16_t numofpage = 0, numofsingle = 0, count = 0;
|
||||
uint16_t addr = 0;
|
||||
uint8_t dataindex = 0;
|
||||
uint32_t status = EEPROM_OK;
|
||||
|
||||
addr = WriteAddr % EEPROM_PAGESIZE;
|
||||
count = EEPROM_PAGESIZE - addr;
|
||||
numofpage = NumByteToWrite / EEPROM_PAGESIZE;
|
||||
numofsingle = NumByteToWrite % EEPROM_PAGESIZE;
|
||||
|
||||
/* If WriteAddr is EEPROM_PAGESIZE aligned */
|
||||
if(addr == 0)
|
||||
{
|
||||
/* If NumByteToWrite < EEPROM_PAGESIZE */
|
||||
if(numofpage == 0)
|
||||
{
|
||||
/* Store the number of data to be written */
|
||||
dataindex = numofsingle;
|
||||
/* Start writing data */
|
||||
status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex));
|
||||
if(status != EEPROM_OK)
|
||||
{
|
||||
return status;
|
||||
}
|
||||
}
|
||||
/* If NumByteToWrite > EEPROM_PAGESIZE */
|
||||
else
|
||||
{
|
||||
while(numofpage--)
|
||||
{
|
||||
/* Store the number of data to be written */
|
||||
dataindex = EEPROM_PAGESIZE;
|
||||
status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex));
|
||||
if(status != EEPROM_OK)
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
WriteAddr += EEPROM_PAGESIZE;
|
||||
pBuffer += EEPROM_PAGESIZE;
|
||||
}
|
||||
|
||||
if(numofsingle!=0)
|
||||
{
|
||||
/* Store the number of data to be written */
|
||||
dataindex = numofsingle;
|
||||
status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex));
|
||||
if(status != EEPROM_OK)
|
||||
{
|
||||
return status;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* If WriteAddr is not EEPROM_PAGESIZE aligned */
|
||||
else
|
||||
{
|
||||
/* If NumByteToWrite < EEPROM_PAGESIZE */
|
||||
if(numofpage== 0)
|
||||
{
|
||||
/* If the number of data to be written is more than the remaining space
|
||||
in the current page: */
|
||||
if(NumByteToWrite > count)
|
||||
{
|
||||
/* Store the number of data to be written */
|
||||
dataindex = count;
|
||||
/* Write the data contained in same page */
|
||||
status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex));
|
||||
if(status != EEPROM_OK)
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
/* Store the number of data to be written */
|
||||
dataindex = (NumByteToWrite - count);
|
||||
/* Write the remaining data in the following page */
|
||||
status = BSP_EEPROM_WritePage((uint8_t*)(pBuffer + count), (WriteAddr + count), (uint8_t*)(&dataindex));
|
||||
if(status != EEPROM_OK)
|
||||
{
|
||||
return status;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Store the number of data to be written */
|
||||
dataindex = numofsingle;
|
||||
status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex));
|
||||
if(status != EEPROM_OK)
|
||||
{
|
||||
return status;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* If NumByteToWrite > EEPROM_PAGESIZE */
|
||||
else
|
||||
{
|
||||
NumByteToWrite -= count;
|
||||
numofpage = NumByteToWrite / EEPROM_PAGESIZE;
|
||||
numofsingle = NumByteToWrite % EEPROM_PAGESIZE;
|
||||
|
||||
if(count != 0)
|
||||
{
|
||||
/* Store the number of data to be written */
|
||||
dataindex = count;
|
||||
status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex));
|
||||
if(status != EEPROM_OK)
|
||||
{
|
||||
return status;
|
||||
}
|
||||
WriteAddr += count;
|
||||
pBuffer += count;
|
||||
}
|
||||
|
||||
while(numofpage--)
|
||||
{
|
||||
/* Store the number of data to be written */
|
||||
dataindex = EEPROM_PAGESIZE;
|
||||
status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex));
|
||||
if(status != EEPROM_OK)
|
||||
{
|
||||
return status;
|
||||
}
|
||||
WriteAddr += EEPROM_PAGESIZE;
|
||||
pBuffer += EEPROM_PAGESIZE;
|
||||
}
|
||||
if(numofsingle != 0)
|
||||
{
|
||||
/* Store the number of data to be written */
|
||||
dataindex = numofsingle;
|
||||
status = BSP_EEPROM_WritePage(pBuffer, WriteAddr, (uint8_t*)(&dataindex));
|
||||
if(status != EEPROM_OK)
|
||||
{
|
||||
return status;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* If all operations OK, return EEPROM_OK (0) */
|
||||
return EEPROM_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Wait for EEPROM Standby state.
|
||||
*
|
||||
* @note This function allows to wait and check that EEPROM has finished the
|
||||
* last operation. It is mostly used after Write operation: after receiving
|
||||
* the buffer to be written, the EEPROM may need additional time to actually
|
||||
* perform the write operation. During this time, it doesn't answer to
|
||||
* I2C packets addressed to it. Once the write operation is complete
|
||||
* the EEPROM responds to its address.
|
||||
*
|
||||
* @retval EEPROM_OK (0) if operation is correctly performed, else return value
|
||||
* different from EEPROM_OK (0) or the timeout user callback.
|
||||
*/
|
||||
uint32_t BSP_EEPROM_WaitEepromStandbyState(void)
|
||||
{
|
||||
/* Check if the maximum allowed number of trials has bee reached */
|
||||
if(EEPROM_IO_IsDeviceReady(EEPROMAddress, EEPROM_MAX_TRIALS) != HAL_OK)
|
||||
{
|
||||
/* If the maximum number of trials has been reached, exit the function */
|
||||
BSP_EEPROM_TIMEOUT_UserCallback();
|
||||
return EEPROM_TIMEOUT;
|
||||
}
|
||||
return EEPROM_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Basic management of the timeout situation.
|
||||
*/
|
||||
__weak void BSP_EEPROM_TIMEOUT_UserCallback(void)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@@ -0,0 +1,125 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32469i_eval_eeprom.h
|
||||
* @author MCD Application Team
|
||||
* @brief This file contains all the functions prototypes for
|
||||
* the stm32469i_eval_eeprom.c firmware driver.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2017 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 __STM32F469I_EVAL_EEPROM_H
|
||||
#define __STM32F469I_EVAL_EEPROM_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32469i_eval.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32469I_EVAL
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32469I-EVAL_EEPROM
|
||||
* @brief This file includes the I2C EEPROM driver of STM32469I EVAL evaluation board.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_EEPROM_Exported_Types STM32469I EVAL EEPROM Exported Types
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_EEPROM_Exported_Constants STM32469I EVAL EEPROM Exported Constants
|
||||
* @{
|
||||
*/
|
||||
/* EEPROM hardware address and page size */
|
||||
#define EEPROM_PAGESIZE ((uint8_t)4)
|
||||
#define EEPROM_MAX_SIZE ((uint16_t)0x2000) /* 64Kbit */
|
||||
|
||||
/* Maximum Timeout values for flags and events waiting loops.
|
||||
This timeout is based on systick set to 1ms*/
|
||||
/* Timeout for read based if read all the EEPROM : EEPROM_MAX_SIZE * I2C_SPEED (640ms) */
|
||||
#define EEPROM_READ_TIMEOUT ((uint32_t)(1000))
|
||||
/* Timeout for write based on max write which is EEPROM_PAGESIZE bytes: EEPROM_PAGESIZE * I2C_SPEED (320us) */
|
||||
#define EEPROM_WRITE_TIMEOUT ((uint32_t)(10))
|
||||
|
||||
/* Maximum number of trials for EEPROM_WaitEepromStandbyState() function */
|
||||
#define EEPROM_MAX_TRIALS 3000
|
||||
|
||||
#define EEPROM_OK 0
|
||||
#define EEPROM_FAIL 1
|
||||
#define EEPROM_TIMEOUT 2
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_EEPROM_Exported_Macros STM32469I EVAL EEPROM Exported Macros
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_EEPROM_Exported_Functions STM32469I EVAL EEPROM Exported Functions
|
||||
* @{
|
||||
*/
|
||||
uint32_t BSP_EEPROM_Init(void);
|
||||
uint8_t BSP_EEPROM_DeInit(void);
|
||||
uint32_t BSP_EEPROM_ReadBuffer(uint8_t* pBuffer, uint16_t ReadAddr, uint16_t* NumByteToRead);
|
||||
uint32_t BSP_EEPROM_WritePage(uint8_t* pBuffer, uint16_t WriteAddr, uint8_t* NumByteToWrite);
|
||||
uint32_t BSP_EEPROM_WriteBuffer(uint8_t* pBuffer, uint16_t WriteAddr, uint16_t NumByteToWrite);
|
||||
uint32_t BSP_EEPROM_WaitEepromStandbyState(void);
|
||||
|
||||
/* USER Callbacks: This function is declared as __weak in EEPROM driver and
|
||||
should be implemented into user application.
|
||||
BSP_EEPROM_TIMEOUT_UserCallback() function is called whenever a timeout condition
|
||||
occur during communication (waiting on an event that doesn't occur, bus
|
||||
errors, busy devices ...). */
|
||||
void BSP_EEPROM_TIMEOUT_UserCallback(void);
|
||||
|
||||
/* Link function for I2C EEPROM peripheral */
|
||||
void EEPROM_IO_Init(void);
|
||||
HAL_StatusTypeDef EEPROM_IO_WriteData(uint16_t DevAddress, uint16_t MemAddress, uint8_t *pBuffer, uint32_t BufferSize);
|
||||
HAL_StatusTypeDef EEPROM_IO_ReadData(uint16_t DevAddress, uint16_t MemAddress, uint8_t *pBuffer, uint32_t BufferSize);
|
||||
HAL_StatusTypeDef EEPROM_IO_IsDeviceReady(uint16_t DevAddress, uint32_t Trials);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __STM32469I_EVAL_EEPROM_H */
|
||||
@@ -0,0 +1,281 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32469i_eval_io.c
|
||||
* @author MCD Application Team
|
||||
* @brief This file provides a set of functions needed to manage the IO pins
|
||||
* on STM32469I-EVAL evaluation board.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2017 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 IO module of the STM32469I-EVAL evaluation
|
||||
board.
|
||||
- The MFXSTM32L152 IO expander device component driver must be included with this
|
||||
driver in order to run the IO functionalities commanded by the IO expander
|
||||
device mounted on the evaluation board.
|
||||
|
||||
2. Driver description:
|
||||
---------------------
|
||||
+ Initialization steps:
|
||||
o Initialize the IO module using the BSP_IO_Init() function. This
|
||||
function includes the MSP layer hardware resources initialization and the
|
||||
communication layer configuration to start the IO functionalities use.
|
||||
|
||||
+ IO functionalities use
|
||||
o The IO pin mode is configured when calling the function BSP_IO_ConfigPin(), you
|
||||
must specify the desired IO mode by choosing the "IO_ModeTypedef" parameter
|
||||
predefined value.
|
||||
o If an IO pin is used in interrupt mode, the function BSP_IO_ITGetStatus() is
|
||||
needed to get the interrupt status. To clear the IT pending bits, you should
|
||||
call the function BSP_IO_ITClearPin() with specifying the IO pending bit to clear.
|
||||
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.
|
||||
o To get/set an IO pin combination state you can use the functions
|
||||
BSP_IO_ReadPin()/BSP_IO_WritePin() or the function BSP_IO_TogglePin() to toggle the pin
|
||||
state.
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32469i_eval_io.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32469I_EVAL
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_IO STM32469I EVAL IO
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_IO_Private_Types_Definitions STM32469I EVAL IO Private Types Definitions
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_IO_Private_Defines STM32469I EVAL IO Private Defines
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_IO_Private_Macros STM32469I EVAL IO Private Macros
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_IO_Private_Variables STM32469I EVAL IO Private Variables
|
||||
* @{
|
||||
*/
|
||||
static IO_DrvTypeDef *IoDrv = NULL;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_IO_Private_Function_Prototypes STM32469I EVAL IO Private Function Prototypes
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_IO_Private_Functions STM32469I EVAL IO Private Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Initializes and configures the IO functionalities and configures all
|
||||
* necessary hardware resources (GPIOs, clocks..).
|
||||
* @note BSP_IO_Init() is using HAL_Delay() function to ensure that MFXSTM32L152
|
||||
* IO Expander is correctly reset. HAL_Delay() function provides accurate
|
||||
* delay (in milliseconds) based on variable incremented in SysTick ISR.
|
||||
* This implies that if BSP_IO_Init() is called from a peripheral ISR process,
|
||||
* then the SysTick interrupt must have higher priority (numerically lower)
|
||||
* than the peripheral interrupt. Otherwise the caller ISR process will be blocked.
|
||||
* @retval IO_OK if all initializations are OK. Other value if error.
|
||||
*/
|
||||
uint8_t BSP_IO_Init(void)
|
||||
{
|
||||
uint8_t ret = IO_ERROR;
|
||||
uint8_t mfxstm32l152_id = 0;
|
||||
HAL_Delay(1);
|
||||
/* Read ID and verify the IO expander is ready */
|
||||
mfxstm32l152_id = mfxstm32l152_io_drv.ReadID(IO_I2C_ADDRESS);
|
||||
if((mfxstm32l152_id == MFXSTM32L152_ID_1) || (mfxstm32l152_id == MFXSTM32L152_ID_2))
|
||||
{
|
||||
/* Initialize the IO driver structure */
|
||||
IoDrv = &mfxstm32l152_io_drv;
|
||||
ret = IO_OK;
|
||||
}
|
||||
|
||||
if(ret == IO_OK)
|
||||
{
|
||||
IoDrv->Init(IO_I2C_ADDRESS);
|
||||
IoDrv->Start(IO_I2C_ADDRESS, IO_PIN_ALL);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DeInit allows Mfx Initialization to be executed again
|
||||
* @note BSP_IO_Init() has no effect if the IoDrv is already initialized
|
||||
* BSP_IO_DeInit() allows to erase the pointer such to allow init to be effective
|
||||
* @retval IO_OK
|
||||
*/
|
||||
uint8_t BSP_IO_DeInit(void)
|
||||
{
|
||||
IoDrv = NULL;
|
||||
return IO_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the selected pins IT status.
|
||||
* @param IoPin: Selected pins to check the status.
|
||||
* This parameter can be any combination of the IO pins.
|
||||
* @retval IO_OK if read status OK. Other value if error.
|
||||
*/
|
||||
uint32_t BSP_IO_ITGetStatus(uint32_t IoPin)
|
||||
{
|
||||
/* Return the IO Pin IT status */
|
||||
return (IoDrv->ITStatus(IO_I2C_ADDRESS, IoPin));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clears all the IO IT pending bits.
|
||||
*/
|
||||
void BSP_IO_ITClear(void)
|
||||
{
|
||||
/* Clear all IO IT pending bits */
|
||||
IoDrv->ClearIT(IO_I2C_ADDRESS, MFXSTM32L152_GPIO_PINS_ALL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear only one or a selection of IO IT pending bits.
|
||||
* @param IO_Pins_To_Clear : MFX IRQ status IO pin to clear (or combination of several IOs)
|
||||
*/
|
||||
void BSP_IO_ITClearPin(uint32_t IO_Pins_To_Clear)
|
||||
{
|
||||
/* Clear only the selected list of IO IT pending bits */
|
||||
IoDrv->ClearIT(IO_I2C_ADDRESS, IO_Pins_To_Clear);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configures the IO pin(s) according to IO mode structure value.
|
||||
* @param IO_Pin: IO pin(s) to be configured.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg MFXSTM32L152_GPIO_PIN_x: where x can be from 0 to 23.
|
||||
* @param IO_Mode: IO pin mode to configure
|
||||
* This parameter can be one of the following values:
|
||||
* @arg IO_MODE_INPUT
|
||||
* @arg IO_MODE_OUTPUT
|
||||
* @arg IO_MODE_IT_RISING_EDGE
|
||||
* @arg IO_MODE_IT_FALLING_EDGE
|
||||
* @arg IO_MODE_IT_LOW_LEVEL
|
||||
* @arg IO_MODE_IT_HIGH_LEVEL
|
||||
* @arg IO_MODE_ANALOG
|
||||
* @arg IO_MODE_OFF
|
||||
* @arg IO_MODE_INPUT_PU,
|
||||
* @arg IO_MODE_INPUT_PD,
|
||||
* @arg IO_MODE_OUTPUT_OD,
|
||||
* @arg IO_MODE_OUTPUT_OD_PU,
|
||||
* @arg IO_MODE_OUTPUT_OD_PD,
|
||||
* @arg IO_MODE_OUTPUT_PP,
|
||||
* @arg IO_MODE_OUTPUT_PP_PU,
|
||||
* @arg IO_MODE_OUTPUT_PP_PD,
|
||||
* @arg IO_MODE_IT_RISING_EDGE_PU
|
||||
* @arg IO_MODE_IT_FALLING_EDGE_PU
|
||||
* @arg IO_MODE_IT_LOW_LEVEL_PU
|
||||
* @arg IO_MODE_IT_HIGH_LEVEL_PU
|
||||
* @arg IO_MODE_IT_RISING_EDGE_PD
|
||||
* @arg IO_MODE_IT_FALLING_EDGE_PD
|
||||
* @arg IO_MODE_IT_LOW_LEVEL_PD
|
||||
* @arg IO_MODE_IT_HIGH_LEVEL_PD
|
||||
* @retval IO_OK if all initializations are OK. Other value if error.
|
||||
*/
|
||||
uint8_t BSP_IO_ConfigPin(uint32_t IO_Pin, IO_ModeTypedef IO_Mode)
|
||||
{
|
||||
/* Configure the selected IO pin(s) mode */
|
||||
IoDrv->Config(IO_I2C_ADDRESS, IO_Pin, IO_Mode);
|
||||
|
||||
return IO_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets the selected pins state.
|
||||
* @param IO_Pin: Selected pins to write.
|
||||
* This parameter can be any combination of the IO pins.
|
||||
* @param PinState: New pins state to write
|
||||
*/
|
||||
void BSP_IO_WritePin(uint32_t IO_Pin, BSP_IO_PinStateTypeDef PinState)
|
||||
{
|
||||
/* Set the Pin state */
|
||||
IoDrv->WritePin(IO_I2C_ADDRESS, IO_Pin, PinState);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the selected pins current state.
|
||||
* @param IO_Pin: Selected pins to read.
|
||||
* This parameter can be any combination of the IO pins.
|
||||
* @retval The current pins state
|
||||
*/
|
||||
uint32_t BSP_IO_ReadPin(uint32_t IO_Pin)
|
||||
{
|
||||
return(IoDrv->ReadPin(IO_I2C_ADDRESS, IO_Pin));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Toggles the selected pins state.
|
||||
* @param IO_Pin: Selected pins to toggle.
|
||||
* This parameter can be any combination of the IO pins.
|
||||
* @note This function is only used to toggle one pin in the same time
|
||||
*/
|
||||
void BSP_IO_TogglePin(uint32_t IO_Pin)
|
||||
{
|
||||
/* Toggle the current pin state */
|
||||
if(IoDrv->ReadPin(IO_I2C_ADDRESS, IO_Pin) != 0) /* Set */
|
||||
{
|
||||
IoDrv->WritePin(IO_I2C_ADDRESS, IO_Pin, 0); /* Reset */
|
||||
}
|
||||
else
|
||||
{
|
||||
IoDrv->WritePin(IO_I2C_ADDRESS, IO_Pin, 1); /* Set */
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@@ -0,0 +1,138 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32469i_eval_io.h
|
||||
* @author MCD Application Team
|
||||
* @brief This file contains the common defines and functions prototypes for
|
||||
* the stm32469i_eval_io.c driver.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2017 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 __STM32469I_EVAL_IO_H
|
||||
#define __STM32469I_EVAL_IO_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32469i_eval.h"
|
||||
/* Include IO component driver */
|
||||
#include "../Components/mfxstm32l152/mfxstm32l152.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32469I_EVAL
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_IO STM32469I EVAL IO
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_IO_Exported_Types STM32469I EVAL IO Exported Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
BSP_IO_PIN_RESET = 0,
|
||||
BSP_IO_PIN_SET = 1
|
||||
}BSP_IO_PinStateTypeDef;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
IO_OK = 0,
|
||||
IO_ERROR = 1,
|
||||
IO_TIMEOUT = 2
|
||||
}IO_StatusTypeDef;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_IO_Exported_Constants STM32469I EVAL IO Exported Constants
|
||||
* @{
|
||||
*/
|
||||
#define IO_PIN_0 ((uint32_t)0x0001)
|
||||
#define IO_PIN_1 ((uint32_t)0x0002)
|
||||
#define IO_PIN_2 ((uint32_t)0x0004)
|
||||
#define IO_PIN_3 ((uint32_t)0x0008)
|
||||
#define IO_PIN_4 ((uint32_t)0x0010)
|
||||
#define IO_PIN_5 ((uint32_t)0x0020)
|
||||
#define IO_PIN_6 ((uint32_t)0x0040)
|
||||
#define IO_PIN_7 ((uint32_t)0x0080)
|
||||
#define IO_PIN_8 ((uint32_t)0x0100)
|
||||
#define IO_PIN_9 ((uint32_t)0x0200)
|
||||
#define IO_PIN_10 ((uint32_t)0x0400)
|
||||
#define IO_PIN_11 ((uint32_t)0x0800)
|
||||
#define IO_PIN_12 ((uint32_t)0x1000)
|
||||
#define IO_PIN_13 ((uint32_t)0x2000)
|
||||
#define IO_PIN_14 ((uint32_t)0x4000)
|
||||
#define IO_PIN_15 ((uint32_t)0x8000)
|
||||
#define IO_PIN_16 ((uint32_t)0x010000)
|
||||
#define IO_PIN_17 ((uint32_t)0x020000)
|
||||
#define IO_PIN_18 ((uint32_t)0x040000)
|
||||
#define IO_PIN_19 ((uint32_t)0x080000)
|
||||
#define IO_PIN_20 ((uint32_t)0x100000)
|
||||
#define IO_PIN_21 ((uint32_t)0x200000)
|
||||
#define IO_PIN_22 ((uint32_t)0x400000)
|
||||
#define IO_PIN_23 ((uint32_t)0x800000)
|
||||
#define IO_PIN_ALL ((uint32_t)0xFFFFFF)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_IO_Exported_Macro STM32469I EVAL IO Exported Macro
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_IO_Exported_Functions STM32469I EVAL IO Exported Functions
|
||||
* @{
|
||||
*/
|
||||
uint8_t BSP_IO_Init(void);
|
||||
uint8_t BSP_IO_DeInit(void);
|
||||
uint32_t BSP_IO_ITGetStatus(uint32_t IO_Pin);
|
||||
void BSP_IO_ITClear(void);
|
||||
void BSP_IO_ITClearPin(uint32_t IO_Pins_To_Clear);
|
||||
uint8_t BSP_IO_ConfigPin(uint32_t IO_Pin, IO_ModeTypedef IO_Mode);
|
||||
void BSP_IO_WritePin(uint32_t IO_Pin, BSP_IO_PinStateTypeDef PinState);
|
||||
uint32_t BSP_IO_ReadPin(uint32_t IO_Pin);
|
||||
void BSP_IO_TogglePin(uint32_t IO_Pin);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __STM32469I_EVAL_IO_H */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,381 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32469i_eval_lcd.h
|
||||
* @author MCD Application Team
|
||||
* @brief This file contains the common defines and functions prototypes for
|
||||
* the stm32469i_eval_lcd.c driver.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2017 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 __STM32469I_EVAL_LCD_H
|
||||
#define __STM32469I_EVAL_LCD_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/* Include LCD component Driver */
|
||||
|
||||
/* Include OTM8009A LCD Driver IC driver code */
|
||||
#include "../Components/otm8009a/otm8009a.h"
|
||||
|
||||
/* Include SDRAM Driver */
|
||||
#include "stm32469i_eval_sdram.h"
|
||||
#include "stm32469i_eval.h"
|
||||
|
||||
#include "../../../Utilities/Fonts/fonts.h"
|
||||
|
||||
#include <string.h> /* use of memset() */
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32469I_EVAL
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32469I_EVAL_LCD STM32469I EVAL LCD
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I_EVAL_LCD_Exported_Constants STM32469I EVAL LCD Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define LCD_LayerCfgTypeDef LTDC_LayerCfgTypeDef
|
||||
/**
|
||||
* @brief LCD FB_StartAddress
|
||||
*/
|
||||
#define LCD_FB_START_ADDRESS ((uint32_t)0xC0000000)
|
||||
|
||||
/** @brief Maximum number of LTDC layers
|
||||
*/
|
||||
#define LTDC_MAX_LAYER_NUMBER ((uint32_t) 2)
|
||||
|
||||
/** @brief LTDC Background layer index
|
||||
*/
|
||||
#define LTDC_ACTIVE_LAYER_BACKGROUND ((uint32_t) 0)
|
||||
|
||||
/** @brief LTDC Foreground layer index
|
||||
*/
|
||||
#define LTDC_ACTIVE_LAYER_FOREGROUND ((uint32_t) 1)
|
||||
|
||||
/** @brief Number of LTDC layers
|
||||
*/
|
||||
#define LTDC_NB_OF_LAYERS ((uint32_t) 2)
|
||||
|
||||
/** @brief LTDC Default used layer index
|
||||
*/
|
||||
#define LTDC_DEFAULT_ACTIVE_LAYER LTDC_ACTIVE_LAYER_FOREGROUND
|
||||
|
||||
/**
|
||||
* @brief LCD status structure definition
|
||||
*/
|
||||
#define LCD_OK 0x00
|
||||
#define LCD_ERROR 0x01
|
||||
#define LCD_TIMEOUT 0x02
|
||||
|
||||
/**
|
||||
* @brief LCD Display OTM8009A ID
|
||||
*/
|
||||
#define LCD_OTM8009A_ID ((uint32_t) 0)
|
||||
|
||||
/**
|
||||
* @brief LCD color definitions values
|
||||
* in ARGB8888 format.
|
||||
*/
|
||||
|
||||
/** @brief Blue value in ARGB8888 format
|
||||
*/
|
||||
#define LCD_COLOR_BLUE ((uint32_t) 0xFF0000FF)
|
||||
|
||||
/** @brief Green value in ARGB8888 format
|
||||
*/
|
||||
#define LCD_COLOR_GREEN ((uint32_t) 0xFF00FF00)
|
||||
|
||||
/** @brief Red value in ARGB8888 format
|
||||
*/
|
||||
#define LCD_COLOR_RED ((uint32_t) 0xFFFF0000)
|
||||
|
||||
/** @brief Cyan value in ARGB8888 format
|
||||
*/
|
||||
#define LCD_COLOR_CYAN ((uint32_t) 0xFF00FFFF)
|
||||
|
||||
/** @brief Magenta value in ARGB8888 format
|
||||
*/
|
||||
#define LCD_COLOR_MAGENTA ((uint32_t) 0xFFFF00FF)
|
||||
|
||||
/** @brief Yellow value in ARGB8888 format
|
||||
*/
|
||||
#define LCD_COLOR_YELLOW ((uint32_t) 0xFFFFFF00)
|
||||
|
||||
/** @brief Light Blue value in ARGB8888 format
|
||||
*/
|
||||
#define LCD_COLOR_LIGHTBLUE ((uint32_t) 0xFF8080FF)
|
||||
|
||||
/** @brief Light Green value in ARGB8888 format
|
||||
*/
|
||||
#define LCD_COLOR_LIGHTGREEN ((uint32_t) 0xFF80FF80)
|
||||
|
||||
/** @brief Light Red value in ARGB8888 format
|
||||
*/
|
||||
#define LCD_COLOR_LIGHTRED ((uint32_t) 0xFFFF8080)
|
||||
|
||||
/** @brief Light Cyan value in ARGB8888 format
|
||||
*/
|
||||
#define LCD_COLOR_LIGHTCYAN ((uint32_t) 0xFF80FFFF)
|
||||
|
||||
/** @brief Light Magenta value in ARGB8888 format
|
||||
*/
|
||||
#define LCD_COLOR_LIGHTMAGENTA ((uint32_t) 0xFFFF80FF)
|
||||
|
||||
/** @brief Light Yellow value in ARGB8888 format
|
||||
*/
|
||||
#define LCD_COLOR_LIGHTYELLOW ((uint32_t) 0xFFFFFF80)
|
||||
|
||||
/** @brief Dark Blue value in ARGB8888 format
|
||||
*/
|
||||
#define LCD_COLOR_DARKBLUE ((uint32_t) 0xFF000080)
|
||||
|
||||
/** @brief Light Dark Green value in ARGB8888 format
|
||||
*/
|
||||
#define LCD_COLOR_DARKGREEN ((uint32_t) 0xFF008000)
|
||||
|
||||
/** @brief Light Dark Red value in ARGB8888 format
|
||||
*/
|
||||
#define LCD_COLOR_DARKRED ((uint32_t) 0xFF800000)
|
||||
|
||||
/** @brief Dark Cyan value in ARGB8888 format
|
||||
*/
|
||||
#define LCD_COLOR_DARKCYAN ((uint32_t) 0xFF008080)
|
||||
|
||||
/** @brief Dark Magenta value in ARGB8888 format
|
||||
*/
|
||||
#define LCD_COLOR_DARKMAGENTA ((uint32_t) 0xFF800080)
|
||||
|
||||
/** @brief Dark Yellow value in ARGB8888 format
|
||||
*/
|
||||
#define LCD_COLOR_DARKYELLOW ((uint32_t) 0xFF808000)
|
||||
|
||||
/** @brief White value in ARGB8888 format
|
||||
*/
|
||||
#define LCD_COLOR_WHITE ((uint32_t) 0xFFFFFFFF)
|
||||
|
||||
/** @brief Light Gray value in ARGB8888 format
|
||||
*/
|
||||
#define LCD_COLOR_LIGHTGRAY ((uint32_t) 0xFFD3D3D3)
|
||||
|
||||
/** @brief Gray value in ARGB8888 format
|
||||
*/
|
||||
#define LCD_COLOR_GRAY ((uint32_t) 0xFF808080)
|
||||
|
||||
/** @brief Dark Gray value in ARGB8888 format
|
||||
*/
|
||||
#define LCD_COLOR_DARKGRAY ((uint32_t) 0xFF404040)
|
||||
|
||||
/** @brief Black value in ARGB8888 format
|
||||
*/
|
||||
#define LCD_COLOR_BLACK ((uint32_t) 0xFF000000)
|
||||
|
||||
/** @brief Brown value in ARGB8888 format
|
||||
*/
|
||||
#define LCD_COLOR_BROWN ((uint32_t) 0xFFA52A2A)
|
||||
|
||||
/** @brief Orange value in ARGB8888 format
|
||||
*/
|
||||
#define LCD_COLOR_ORANGE ((uint32_t) 0xFFFFA500)
|
||||
|
||||
/** @brief Transparent value in ARGB8888 format
|
||||
*/
|
||||
#define LCD_COLOR_TRANSPARENT ((uint32_t) 0xFF000000)
|
||||
|
||||
/**
|
||||
* @brief LCD default font
|
||||
*/
|
||||
#define LCD_DEFAULT_FONT Font24
|
||||
|
||||
/**
|
||||
* @brief Possible values of
|
||||
* pixel data format (ie color coding) transmitted on DSI Data lane in DSI packets
|
||||
*/
|
||||
|
||||
#define LCD_DSI_PIXEL_DATA_FMT_RBG888 DSI_RGB888 /*!< DSI packet pixel format chosen is RGB888 : 24 bpp */
|
||||
#define LCD_DSI_PIXEL_DATA_FMT_RBG565 DSI_RGB565 /*!< DSI packet pixel format chosen is RGB565 : 16 bpp */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_LCD_Exported_Types STM32469I EVAL LCD Exported Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief LCD Drawing main properties
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t TextColor; /*!< Specifies the color of text */
|
||||
uint32_t BackColor; /*!< Specifies the background color below the text */
|
||||
sFONT *pFont; /*!< Specifies the font used for the text */
|
||||
|
||||
} LCD_DrawPropTypeDef;
|
||||
|
||||
/**
|
||||
* @brief LCD Drawing point (pixel) geometric definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int16_t X; /*!< geometric X position of drawing */
|
||||
int16_t Y; /*!< geometric Y position of drawing */
|
||||
|
||||
} Point;
|
||||
|
||||
/**
|
||||
* @brief Pointer on LCD Drawing point (pixel) geometric definition
|
||||
*/
|
||||
typedef Point * pPoint;
|
||||
|
||||
/**
|
||||
* @brief LCD drawing Line alignment mode definitions
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
CENTER_MODE = 0x01, /*!< Center mode */
|
||||
RIGHT_MODE = 0x02, /*!< Right mode */
|
||||
LEFT_MODE = 0x03 /*!< Left mode */
|
||||
|
||||
} Text_AlignModeTypdef;
|
||||
|
||||
|
||||
/**
|
||||
* @brief LCD_OrientationTypeDef
|
||||
* Possible values of Display Orientation
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
LCD_ORIENTATION_PORTRAIT = 0x00, /*!< Portrait orientation choice of LCD screen */
|
||||
LCD_ORIENTATION_LANDSCAPE = 0x01, /*!< Landscape orientation choice of LCD screen */
|
||||
LCD_ORIENTATION_INVALID = 0x02 /*!< Invalid orientation choice of LCD screen */
|
||||
} LCD_OrientationTypeDef;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_LCD_Exported_Macro STM32469I EVAL LCD Exported Macro
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32469I-EVAL_LCD_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
void BSP_LCD_DMA2D_IRQHandler(void);
|
||||
void BSP_LCD_DSI_IRQHandler(void);
|
||||
void BSP_LCD_LTDC_IRQHandler(void);
|
||||
void BSP_LCD_LTDC_ER_IRQHandler(void);
|
||||
|
||||
uint8_t BSP_LCD_Init(void);
|
||||
uint8_t BSP_LCD_InitEx(LCD_OrientationTypeDef orientation);
|
||||
|
||||
void BSP_LCD_MspDeInit(void);
|
||||
void BSP_LCD_MspInit(void);
|
||||
void BSP_LCD_Reset(void);
|
||||
|
||||
uint32_t BSP_LCD_GetXSize(void);
|
||||
uint32_t BSP_LCD_GetYSize(void);
|
||||
void BSP_LCD_SetXSize(uint32_t imageWidthPixels);
|
||||
void BSP_LCD_SetYSize(uint32_t imageHeightPixels);
|
||||
|
||||
void BSP_LCD_LayerDefaultInit(uint16_t LayerIndex, uint32_t FB_Address);
|
||||
void BSP_LCD_SetTransparency(uint32_t LayerIndex, uint8_t Transparency);
|
||||
void BSP_LCD_SetLayerAddress(uint32_t LayerIndex, uint32_t Address);
|
||||
void BSP_LCD_SetColorKeying(uint32_t LayerIndex, uint32_t RGBValue);
|
||||
void BSP_LCD_ResetColorKeying(uint32_t LayerIndex);
|
||||
void BSP_LCD_SetLayerWindow(uint16_t LayerIndex, uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height);
|
||||
|
||||
void BSP_LCD_SelectLayer(uint32_t LayerIndex);
|
||||
void BSP_LCD_SetLayerVisible(uint32_t LayerIndex, FunctionalState State);
|
||||
|
||||
void BSP_LCD_SetTextColor(uint32_t Color);
|
||||
uint32_t BSP_LCD_GetTextColor(void);
|
||||
void BSP_LCD_SetBackColor(uint32_t Color);
|
||||
uint32_t BSP_LCD_GetBackColor(void);
|
||||
void BSP_LCD_SetFont(sFONT *fonts);
|
||||
sFONT *BSP_LCD_GetFont(void);
|
||||
|
||||
uint32_t BSP_LCD_ReadPixel(uint16_t Xpos, uint16_t Ypos);
|
||||
void BSP_LCD_DrawPixel(uint16_t Xpos, uint16_t Ypos, uint32_t pixel);
|
||||
void BSP_LCD_Clear(uint32_t Color);
|
||||
void BSP_LCD_ClearStringLine(uint32_t Line);
|
||||
void BSP_LCD_DisplayStringAtLine(uint16_t Line, uint8_t *ptr);
|
||||
void BSP_LCD_DisplayStringAt(uint16_t Xpos, uint16_t Ypos, uint8_t *Text, Text_AlignModeTypdef Mode);
|
||||
void BSP_LCD_DisplayChar(uint16_t Xpos, uint16_t Ypos, uint8_t Ascii);
|
||||
|
||||
void BSP_LCD_DrawHLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length);
|
||||
void BSP_LCD_DrawVLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length);
|
||||
void BSP_LCD_DrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
|
||||
void BSP_LCD_DrawRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height);
|
||||
void BSP_LCD_DrawCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius);
|
||||
void BSP_LCD_DrawPolygon(pPoint Points, uint16_t PointCount);
|
||||
void BSP_LCD_DrawEllipse(int Xpos, int Ypos, int XRadius, int YRadius);
|
||||
void BSP_LCD_DrawBitmap(uint32_t Xpos, uint32_t Ypos, uint8_t *pbmp);
|
||||
|
||||
void BSP_LCD_FillRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height);
|
||||
void BSP_LCD_FillCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius);
|
||||
void BSP_LCD_FillPolygon(pPoint Points, uint16_t PointCount);
|
||||
void BSP_LCD_FillEllipse(int Xpos, int Ypos, int XRadius, int YRadius);
|
||||
|
||||
void BSP_LCD_DisplayOff(void);
|
||||
void BSP_LCD_DisplayOn(void);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32469I-EVAL_LCD_Exported_Variables
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* @brief DMA2D handle variable */
|
||||
extern DMA2D_HandleTypeDef hdma2d_eval;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __STM32469I_EVAL_LCD_H */
|
||||
@@ -0,0 +1,422 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32469i_eval_nor.c
|
||||
* @author MCD Application Team
|
||||
* @brief This file includes a standard driver for the M29W256GL70ZA6E NOR flash memory
|
||||
* device mounted on STM32469I-EVAL evaluation board.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2017 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 M29W128GL NOR flash external memory mounted
|
||||
on STM32469I-EVAL evaluation board.
|
||||
- This driver does not need a specific component driver for the NOR device
|
||||
to be included with.
|
||||
|
||||
2. Driver description:
|
||||
---------------------
|
||||
+ Initialization steps:
|
||||
o Initialize the NOR external memory using the BSP_NOR_Init() function. This
|
||||
function includes the MSP layer hardware resources initialization and the
|
||||
FMC controller configuration to interface with the external NOR memory.
|
||||
|
||||
+ NOR flash operations
|
||||
o NOR 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_NOR_ReadData()/BSP_NOR_WriteData(). The BSP_NOR_WriteData() performs write operation
|
||||
of an amount of data by unit (halfword). You can also perform a program data
|
||||
operation of an amount of data using the function BSP_NOR_ProgramData().
|
||||
o The function BSP_NOR_Read_ID() returns the chip IDs stored in the structure
|
||||
"NOR_IDTypeDef". (see the NOR IDs in the memory data sheet)
|
||||
o Perform erase block operation using the function BSP_NOR_Erase_Block() and by
|
||||
specifying the block address. You can perform an erase operation of the whole
|
||||
chip by calling the function BSP_NOR_Erase_Chip().
|
||||
o After other operations, the function BSP_NOR_ReturnToReadMode() allows the NOR
|
||||
flash to return to read mode to perform read operations on it.
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32469i_eval_nor.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32469I_EVAL
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_NOR STM32469I EVAL NOR
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_NOR_Private_Types_Definitions STM32469I EVAL NOR Private Types Definitions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_NOR_Private_Defines STM32469I EVAL NOR Private Defines
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_NOR_Private_Macros STM32469I EVAL NOR Private Macros
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_NOR_Private_Variables STM32469I EVAL NOR Private Variables
|
||||
* @{
|
||||
*/
|
||||
NOR_HandleTypeDef NorHandle;
|
||||
static FMC_NORSRAM_TimingTypeDef Timing;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_NOR_Private_Function_Prototypes STM32469I EVAL NOR Private Function Prototypes
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Initializes the NOR device.
|
||||
* @retval NOR memory status
|
||||
*/
|
||||
uint8_t BSP_NOR_Init(void)
|
||||
{
|
||||
NorHandle.Instance = FMC_NORSRAM_DEVICE;
|
||||
NorHandle.Extended = FMC_NORSRAM_EXTENDED_DEVICE;
|
||||
|
||||
/* NOR device configuration */
|
||||
Timing.AddressSetupTime = 8;
|
||||
Timing.AddressHoldTime = 3;
|
||||
Timing.DataSetupTime = 9;
|
||||
Timing.BusTurnAroundDuration = 0;
|
||||
Timing.CLKDivision = 2;
|
||||
Timing.DataLatency = 2;
|
||||
Timing.AccessMode = FMC_ACCESS_MODE_A;
|
||||
|
||||
NorHandle.Init.NSBank = FMC_NORSRAM_BANK1;
|
||||
NorHandle.Init.DataAddressMux = FMC_DATA_ADDRESS_MUX_DISABLE;
|
||||
NorHandle.Init.MemoryType = FMC_MEMORY_TYPE_NOR;
|
||||
NorHandle.Init.MemoryDataWidth = NOR_MEMORY_WIDTH;
|
||||
NorHandle.Init.BurstAccessMode = NOR_BURSTACCESS;
|
||||
NorHandle.Init.WaitSignalPolarity = FMC_WAIT_SIGNAL_POLARITY_LOW;
|
||||
NorHandle.Init.WrapMode = FMC_WRAP_MODE_DISABLE;
|
||||
NorHandle.Init.WaitSignalActive = FMC_WAIT_TIMING_BEFORE_WS;
|
||||
NorHandle.Init.WriteOperation = FMC_WRITE_OPERATION_ENABLE;
|
||||
NorHandle.Init.WaitSignal = FMC_WAIT_SIGNAL_ENABLE;
|
||||
NorHandle.Init.ExtendedMode = FMC_EXTENDED_MODE_DISABLE;
|
||||
NorHandle.Init.AsynchronousWait = FMC_ASYNCHRONOUS_WAIT_ENABLE;
|
||||
NorHandle.Init.WriteBurst = NOR_WRITEBURST;
|
||||
NorHandle.Init.ContinuousClock = CONTINUOUSCLOCK_FEATURE;
|
||||
|
||||
/* NOR controller initialization */
|
||||
BSP_NOR_MspInit(&NorHandle, NULL);
|
||||
|
||||
if(HAL_NOR_Init(&NorHandle, &Timing, &Timing) != HAL_OK)
|
||||
{
|
||||
return NOR_STATUS_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NOR_STATUS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DeInitializes the NOR device.
|
||||
* @retval NOR memory status
|
||||
*/
|
||||
uint8_t BSP_NOR_DeInit(void)
|
||||
{
|
||||
/* NOR controller initialization */
|
||||
BSP_NOR_MspDeInit(&NorHandle, NULL);
|
||||
|
||||
if(HAL_NOR_DeInit(&NorHandle) != HAL_OK)
|
||||
{
|
||||
return NOR_STATUS_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NOR_STATUS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reads an amount of data from the NOR device.
|
||||
* @param uwStartAddress: Read start address
|
||||
* @param pData: Pointer to data to be read
|
||||
* @param uwDataSize: Size of data to read
|
||||
* @retval NOR memory status
|
||||
*/
|
||||
uint8_t BSP_NOR_ReadData(uint32_t uwStartAddress, uint16_t* pData, uint32_t uwDataSize)
|
||||
{
|
||||
if(HAL_NOR_ReadBuffer(&NorHandle, NOR_DEVICE_ADDR + uwStartAddress, pData, uwDataSize) != HAL_OK)
|
||||
{
|
||||
return NOR_STATUS_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NOR_STATUS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns the NOR memory to read mode.
|
||||
*/
|
||||
void BSP_NOR_ReturnToReadMode(void)
|
||||
{
|
||||
HAL_NOR_ReturnToReadMode(&NorHandle);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Writes an amount of data to the NOR device.
|
||||
* @param uwStartAddress: Write start address
|
||||
* @param pData: Pointer to data to be written
|
||||
* @param uwDataSize: Size of data to write
|
||||
* @retval NOR memory status
|
||||
*/
|
||||
uint8_t BSP_NOR_WriteData(uint32_t uwStartAddress, uint16_t* pData, uint32_t uwDataSize)
|
||||
{
|
||||
uint32_t index = uwDataSize;
|
||||
|
||||
while(index > 0)
|
||||
{
|
||||
/* Write data to NOR */
|
||||
HAL_NOR_Program(&NorHandle, (uint32_t *)(NOR_DEVICE_ADDR + uwStartAddress), pData);
|
||||
|
||||
/* Read NOR device status */
|
||||
if(HAL_NOR_GetStatus(&NorHandle, NOR_DEVICE_ADDR, PROGRAM_TIMEOUT) != HAL_NOR_STATUS_SUCCESS)
|
||||
{
|
||||
return NOR_STATUS_ERROR;
|
||||
}
|
||||
|
||||
/* Update the counters */
|
||||
index--;
|
||||
uwStartAddress += 2;
|
||||
pData++;
|
||||
}
|
||||
|
||||
return NOR_STATUS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Programs an amount of data to the NOR device.
|
||||
* @param uwStartAddress: Write start address
|
||||
* @param pData: Pointer to data to be written
|
||||
* @param uwDataSize: Size of data to write
|
||||
* @retval NOR memory status
|
||||
*/
|
||||
uint8_t BSP_NOR_ProgramData(uint32_t uwStartAddress, uint16_t* pData, uint32_t uwDataSize)
|
||||
{
|
||||
/* Send NOR program buffer operation */
|
||||
HAL_NOR_ProgramBuffer(&NorHandle, uwStartAddress, pData, uwDataSize);
|
||||
|
||||
/* Return the NOR memory status */
|
||||
if(HAL_NOR_GetStatus(&NorHandle, NOR_DEVICE_ADDR, PROGRAM_TIMEOUT) != HAL_NOR_STATUS_SUCCESS)
|
||||
{
|
||||
return NOR_STATUS_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NOR_STATUS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Erases the specified block of the NOR device.
|
||||
* @param BlockAddress: Block address to erase
|
||||
* @retval NOR memory status
|
||||
*/
|
||||
uint8_t BSP_NOR_Erase_Block(uint32_t BlockAddress)
|
||||
{
|
||||
/* Send NOR erase block operation */
|
||||
HAL_NOR_Erase_Block(&NorHandle, BlockAddress, NOR_DEVICE_ADDR);
|
||||
|
||||
/* Return the NOR memory status */
|
||||
if(HAL_NOR_GetStatus(&NorHandle, NOR_DEVICE_ADDR, BLOCKERASE_TIMEOUT) != HAL_NOR_STATUS_SUCCESS)
|
||||
{
|
||||
return NOR_STATUS_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NOR_STATUS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Erases the entire NOR chip.
|
||||
* @retval NOR memory status
|
||||
*/
|
||||
uint8_t BSP_NOR_Erase_Chip(void)
|
||||
{
|
||||
/* Send NOR Erase chip operation */
|
||||
HAL_NOR_Erase_Chip(&NorHandle, NOR_DEVICE_ADDR);
|
||||
|
||||
/* Return the NOR memory status */
|
||||
if(HAL_NOR_GetStatus(&NorHandle, NOR_DEVICE_ADDR, CHIPERASE_TIMEOUT) != HAL_NOR_STATUS_SUCCESS)
|
||||
{
|
||||
return NOR_STATUS_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NOR_STATUS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reads NOR flash IDs.
|
||||
* @param pNOR_ID : Pointer to NOR ID structure
|
||||
* @retval NOR memory status
|
||||
*/
|
||||
uint8_t BSP_NOR_Read_ID(NOR_IDTypeDef *pNOR_ID)
|
||||
{
|
||||
if(HAL_NOR_Read_ID(&NorHandle, pNOR_ID) != HAL_OK)
|
||||
{
|
||||
return NOR_STATUS_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NOR_STATUS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initializes the NOR MSP.
|
||||
* @param hnor: pointer to nor structure
|
||||
* @param Params : pointer on additional configuration parameters, can be NULL.
|
||||
*/
|
||||
__weak void BSP_NOR_MspInit(NOR_HandleTypeDef *hnor, void *Params)
|
||||
{
|
||||
GPIO_InitTypeDef gpio_init_structure;
|
||||
|
||||
/* Enable FMC clock */
|
||||
__HAL_RCC_FMC_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();
|
||||
|
||||
/* Common GPIO configuration */
|
||||
gpio_init_structure.Mode = GPIO_MODE_AF_PP;
|
||||
gpio_init_structure.Pull = GPIO_PULLUP;
|
||||
gpio_init_structure.Speed = GPIO_SPEED_HIGH;
|
||||
gpio_init_structure.Alternate = GPIO_AF12_FMC;
|
||||
|
||||
/* GPIOD configuration */
|
||||
gpio_init_structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 |\
|
||||
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(GPIOD, &gpio_init_structure);
|
||||
|
||||
/* GPIOE configuration */
|
||||
gpio_init_structure.Pin = GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 |\
|
||||
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_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_2| GPIO_PIN_3 | GPIO_PIN_4 |\
|
||||
GPIO_PIN_5;
|
||||
HAL_GPIO_Init(GPIOG, &gpio_init_structure);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DeInitializes the NOR MSP.
|
||||
* @param hnor pointer to NOR structure
|
||||
* @param Params : pointer on additional configuration parameters, can be NULL.
|
||||
* @retval status
|
||||
*/
|
||||
__weak uint8_t BSP_NOR_MspDeInit(NOR_HandleTypeDef *hnor, void *Params)
|
||||
{
|
||||
/* FMC won't be disabled because common to other functionalities */
|
||||
|
||||
/* Disable only NOR specific GPIOs */
|
||||
HAL_GPIO_DeInit(GPIOD, (GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7));
|
||||
|
||||
return HAL_OK;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief NOR BSP Wait for Ready/Busy signal.
|
||||
* @param hnor: Pointer to NOR handle
|
||||
* @param Timeout: Timeout duration
|
||||
*/
|
||||
void HAL_NOR_MspWait(NOR_HandleTypeDef *hnor, uint32_t Timeout)
|
||||
{
|
||||
uint32_t timeout = Timeout;
|
||||
|
||||
/* Polling on Ready/Busy signal */
|
||||
while((HAL_GPIO_ReadPin(NOR_READY_BUSY_GPIO, NOR_READY_BUSY_PIN) != NOR_BUSY_STATE) && (timeout > 0))
|
||||
{
|
||||
timeout--;
|
||||
}
|
||||
|
||||
timeout = Timeout;
|
||||
|
||||
/* Polling on Ready/Busy signal */
|
||||
while((HAL_GPIO_ReadPin(NOR_READY_BUSY_GPIO, NOR_READY_BUSY_PIN) != NOR_READY_STATE) && (timeout > 0))
|
||||
{
|
||||
timeout--;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@@ -0,0 +1,130 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32469i_eval_nor.h
|
||||
* @author MCD Application Team
|
||||
* @brief This file contains the common defines and functions prototypes for
|
||||
* the stm32469i_eval_nor.c driver.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2017 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 __STM32469I_EVAL_NOR_H
|
||||
#define __STM32469I_EVAL_NOR_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32f4xx_hal.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32469I_EVAL
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_NOR STM32469I EVAL NOR
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_NOR_Exported_Types STM32469I EVAL NOR Exported Types
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_NOR_Exported_Constants STM32469I EVAL NOR Exported Constants
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief NOR status structure definition
|
||||
*/
|
||||
#define NOR_STATUS_OK ((uint8_t) 0x00)
|
||||
#define NOR_STATUS_ERROR ((uint8_t) 0x01)
|
||||
#define NOR_DEVICE_ADDR ((uint32_t)0x60000000)
|
||||
|
||||
/* #define NOR_MEMORY_WIDTH FMC_NORSRAM_MEM_BUS_WIDTH_8 */
|
||||
#define NOR_MEMORY_WIDTH FMC_NORSRAM_MEM_BUS_WIDTH_16
|
||||
|
||||
#define NOR_BURSTACCESS FMC_BURST_ACCESS_MODE_DISABLE
|
||||
/* #define NOR_BURSTACCESS FMC_BURST_ACCESS_MODE_ENABLE*/
|
||||
|
||||
#define NOR_WRITEBURST FMC_WRITE_BURST_DISABLE
|
||||
/* #define NOR_WRITEBURST FMC_WRITE_BURST_ENABLE */
|
||||
|
||||
#define CONTINUOUSCLOCK_FEATURE FMC_CONTINUOUS_CLOCK_SYNC_ONLY
|
||||
/* #define CONTINUOUSCLOCK_FEATURE FMC_CONTINUOUS_CLOCK_SYNC_ASYNC */
|
||||
|
||||
/* NOR operations Timeout definitions */
|
||||
#define BLOCKERASE_TIMEOUT ((uint32_t)0x00A00000) /* NOR block erase timeout */
|
||||
#define CHIPERASE_TIMEOUT ((uint32_t)0x30000000) /* NOR chip erase timeout */
|
||||
#define PROGRAM_TIMEOUT ((uint32_t)0x00004400) /* NOR program timeout */
|
||||
|
||||
/* NOR Ready/Busy signal GPIO definitions */
|
||||
#define NOR_READY_BUSY_PIN GPIO_PIN_6
|
||||
#define NOR_READY_BUSY_GPIO GPIOD
|
||||
#define NOR_READY_STATE GPIO_PIN_SET
|
||||
#define NOR_BUSY_STATE GPIO_PIN_RESET
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_NOR_Exported_Macro STM32469I EVAL NOR Exported Macro
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_NOR_Exported_Functions STM32469I EVAL NOR Exported Functions
|
||||
* @{
|
||||
*/
|
||||
uint8_t BSP_NOR_Init(void);
|
||||
uint8_t BSP_NOR_DeInit(void);
|
||||
uint8_t BSP_NOR_ReadData(uint32_t uwStartAddress, uint16_t *pData, uint32_t uwDataSize);
|
||||
uint8_t BSP_NOR_WriteData(uint32_t uwStartAddress, uint16_t *pData, uint32_t uwDataSize);
|
||||
uint8_t BSP_NOR_ProgramData(uint32_t uwStartAddress, uint16_t *pData, uint32_t uwDataSize);
|
||||
uint8_t BSP_NOR_Erase_Block(uint32_t BlockAddress);
|
||||
uint8_t BSP_NOR_Erase_Chip(void);
|
||||
uint8_t BSP_NOR_Read_ID(NOR_IDTypeDef *pNOR_ID);
|
||||
void BSP_NOR_ReturnToReadMode(void);
|
||||
|
||||
/* These functions can be modified in case the current settings (e.g. DMA stream)
|
||||
need to be changed for specific application needs */
|
||||
void BSP_NOR_MspInit(NOR_HandleTypeDef *hnor, void *Params);
|
||||
uint8_t BSP_NOR_MspDeInit(NOR_HandleTypeDef *hnor, void *Params);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __STM32469I_EVAL_NOR_H */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,153 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32469i_eval_qspi.h
|
||||
* @author MCD Application Team
|
||||
* @brief This file contains the common defines and functions prototypes for
|
||||
* the stm32469i_eval_qspi.c driver.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2015 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.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32469I_EVAL
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __STM32469I_EVAL_QSPI_H
|
||||
#define __STM32469I_EVAL_QSPI_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32f4xx_hal.h"
|
||||
#include "../Components/s25fl512s/s25fl512s.h"
|
||||
#include "../Components/n25q512a/n25q512a.h"
|
||||
|
||||
|
||||
/** @addtogroup STM32469I_EVAL_QSPI
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/** @defgroup STM32446E_EVAL_QSPI_Exported_Constants STM32469I EVAL QSPI Exported Constants
|
||||
* @{
|
||||
*/
|
||||
/* QSPI Error codes */
|
||||
#define QSPI_OK ((uint8_t)0x00)
|
||||
#define QSPI_ERROR ((uint8_t)0x01)
|
||||
#define QSPI_BUSY ((uint8_t)0x02)
|
||||
#define QSPI_NOT_SUPPORTED ((uint8_t)0x04)
|
||||
#define QSPI_SUSPENDED ((uint8_t)0x08)
|
||||
#define QSPI_PROTECTED ((uint8_t)0x10)
|
||||
|
||||
#define QSPI_S25FL512S ((uint8_t)0x20)
|
||||
#define QSPI_N25Q512A ((uint8_t)0x40)
|
||||
|
||||
/* 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_CS_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
|
||||
#define QSPI_CS_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE()
|
||||
#define QSPI_DX_CLK_GPIO_CLK_ENABLE() __HAL_RCC_GPIOF_CLK_ENABLE()
|
||||
#define QSPI_DX_CLK_GPIO_CLK_DISABLE() __HAL_RCC_GPIOF_CLK_DISABLE()
|
||||
|
||||
#define QSPI_FORCE_RESET() __HAL_RCC_QSPI_FORCE_RESET()
|
||||
#define QSPI_RELEASE_RESET() __HAL_RCC_QSPI_RELEASE_RESET()
|
||||
|
||||
/* Definition for QSPI Pins */
|
||||
#define QSPI_CS_PIN GPIO_PIN_6
|
||||
#define QSPI_CS_GPIO_PORT GPIOB
|
||||
#define QSPI_CLK_PIN GPIO_PIN_10
|
||||
#define QSPI_CLK_GPIO_PORT GPIOF
|
||||
#define QSPI_D0_PIN GPIO_PIN_8
|
||||
#define QSPI_D1_PIN GPIO_PIN_9
|
||||
#define QSPI_D2_PIN GPIO_PIN_7
|
||||
#define QSPI_D3_PIN GPIO_PIN_6
|
||||
#define QSPI_DX_GPIO_PORT GPIOF
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/** @defgroup STM32446E_EVAL_QSPI_Exported_Types STM32469I EVAL QSPI Exported Types
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief QSPI Info
|
||||
* */
|
||||
typedef struct {
|
||||
uint32_t FlashSize; /*!< Size of the flash */
|
||||
uint32_t EraseSectorSize; /*!< Size of sectors for the erase operation */
|
||||
uint32_t EraseSectorsNumber; /*!< Number of sectors for the erase operation */
|
||||
uint32_t ProgPageSize; /*!< Size of pages for the program operation */
|
||||
uint32_t ProgPagesNumber; /*!< Number of pages for the program operation */
|
||||
uint32_t DummyCyclesRead; /*!< Number of dummy read cycles */
|
||||
uint8_t ManufID; /*!< Manufacturor value */
|
||||
uint32_t SectorEraseMaxTime; /*!< Sector Erase max value */
|
||||
uint32_t BulkEraseMaxTime; /*!< Bulk Erase Max Time */
|
||||
} QSPI_InfoTypeDef;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/** @defgroup STM32469I_EVAL_QSPI_Exported_Functions STM32469I EVAL QSPI Exported Functions
|
||||
* @{
|
||||
*/
|
||||
uint8_t BSP_QSPI_Init (void);
|
||||
uint8_t BSP_QSPI_DeInit (void);
|
||||
uint8_t BSP_QSPI_Read (uint8_t* pData, uint32_t ReadAddr, uint32_t Size);
|
||||
uint8_t BSP_QSPI_Write (uint8_t* pData, uint32_t WriteAddr, uint32_t Size);
|
||||
uint8_t BSP_QSPI_Erase_Block(uint32_t BlockAddress);
|
||||
uint8_t BSP_QSPI_Erase_Chip (void);
|
||||
uint8_t BSP_QSPI_GetStatus (void);
|
||||
uint8_t BSP_QSPI_GetInfo (QSPI_InfoTypeDef* pInfo);
|
||||
uint8_t BSP_QSPI_EnableMemoryMappedMode(void);
|
||||
/* BSP Aliased function maintained for legacy purpose */
|
||||
#define BSP_QSPI_MemoryMappedMode BSP_QSPI_EnableMemoryMappedMode
|
||||
|
||||
/* These function can be modified in case the current settings (e.g. DMA stream)
|
||||
need to be changed for specific application needs */
|
||||
void BSP_QSPI_MspInit(QSPI_HandleTypeDef *hqspi, void *Params);
|
||||
void BSP_QSPI_MspDeInit(QSPI_HandleTypeDef *hqspi, void *Params);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __STM32446E_EVAL_QSPI_H */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@@ -0,0 +1,578 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32469i_eval_sd.c
|
||||
* @author MCD Application Team
|
||||
* @brief This file includes the uSD card driver mounted on STM32469I-EVAL
|
||||
* evaluation board.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2017 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 micro SD external card mounted on STM32469I-EVAL
|
||||
evaluation board.
|
||||
- This driver does not need a specific component driver for the micro SD device
|
||||
to be included with.
|
||||
|
||||
2. Driver description:
|
||||
---------------------
|
||||
+ Initialization steps:
|
||||
o Initialize the micro SD card using the BSP_SD_Init() function. This
|
||||
function includes the MSP layer hardware resources initialization and the
|
||||
SDIO interface configuration to interface with the external micro SD. It
|
||||
also includes the micro SD initialization sequence.
|
||||
o To check the SD card presence you can use the function BSP_SD_IsDetected() which
|
||||
returns the detection status
|
||||
o If SD presence detection interrupt mode is desired, you must configure the
|
||||
SD detection interrupt mode by calling the function BSP_SD_ITConfig(). The interrupt
|
||||
is generated as an external interrupt whenever the micro SD card is
|
||||
plugged/unplugged in/from the evaluation board.
|
||||
o The function BSP_SD_GetCardInfo() is used to get the micro SD card information
|
||||
which is stored in the structure "HAL_SD_CardInfoTypeDef".
|
||||
|
||||
+ Micro SD card operations
|
||||
o The micro SD card can be accessed with read/write block(s) operations once
|
||||
it is ready for access. The access can be performed whether using the polling
|
||||
mode by calling the functions BSP_SD_ReadBlocks()/BSP_SD_WriteBlocks(), or by DMA
|
||||
transfer using the functions BSP_SD_ReadBlocks_DMA()/BSP_SD_WriteBlocks_DMA()
|
||||
o The DMA transfer complete is used with interrupt mode. Once the SD transfer
|
||||
is complete, the SD interrupt is handled using the function BSP_SD_IRQHandler(),
|
||||
the DMA Tx/Rx transfer complete are handled using the functions
|
||||
BSP_SD_DMA_Tx_IRQHandler()/BSP_SD_DMA_Rx_IRQHandler(). The corresponding user callbacks
|
||||
are implemented by the user at application level.
|
||||
o The SD erase block(s) is performed using the function BSP_SD_Erase() with specifying
|
||||
the number of blocks to erase.
|
||||
o The SD runtime status is returned when calling the function BSP_SD_GetCardState().
|
||||
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32469i_eval_sd.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32469I_EVAL
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_SD STM32469I EVAL SD
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup STM32469I-EVAL_SD_Private_TypesDefinitions STM32469I EVAL SD Private TypesDef
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_SD_Private_Defines STM32469I EVAL SD Private Defines
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_SD_Private_Macros STM32469I EVAL SD Private Macro
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_SD_Private_Variables STM32469I EVAL SD Private Variables
|
||||
* @{
|
||||
*/
|
||||
SD_HandleTypeDef uSdHandle;
|
||||
static uint8_t UseExtiModeDetection = 0;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_SD_Private_FunctionPrototypes STM32469I EVAL SD Private Prototypes
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_SD_Private_Functions STM32469I EVAL SD Private Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Initializes the SD card device.
|
||||
* @retval SD status
|
||||
*/
|
||||
uint8_t BSP_SD_Init(void)
|
||||
{
|
||||
uint8_t sd_state = MSD_OK;
|
||||
|
||||
/* PLLSAI is dedicated to LCD periph. Do not use it to get 48MHz*/
|
||||
|
||||
/* uSD device interface configuration */
|
||||
uSdHandle.Instance = SDIO;
|
||||
|
||||
uSdHandle.Init.ClockEdge = SDIO_CLOCK_EDGE_RISING;
|
||||
uSdHandle.Init.ClockBypass = SDIO_CLOCK_BYPASS_DISABLE;
|
||||
uSdHandle.Init.ClockPowerSave = SDIO_CLOCK_POWER_SAVE_DISABLE;
|
||||
uSdHandle.Init.BusWide = SDIO_BUS_WIDE_1B;
|
||||
uSdHandle.Init.HardwareFlowControl = SDIO_HARDWARE_FLOW_CONTROL_ENABLE;
|
||||
uSdHandle.Init.ClockDiv = SDIO_TRANSFER_CLK_DIV;
|
||||
|
||||
/* Configure IO functionalities for SD detect pin */
|
||||
BSP_IO_Init();
|
||||
|
||||
/* Check if the SD card is plugged in the slot */
|
||||
BSP_IO_ConfigPin(SD_DETECT_PIN, IO_MODE_INPUT_PU);
|
||||
if(BSP_SD_IsDetected() != SD_PRESENT)
|
||||
{
|
||||
return MSD_ERROR_SD_NOT_PRESENT;
|
||||
}
|
||||
|
||||
/* Msp SD initialization */
|
||||
BSP_SD_MspInit(&uSdHandle, NULL);
|
||||
|
||||
/* HAL SD initialization */
|
||||
if(HAL_SD_Init(&uSdHandle) != HAL_OK)
|
||||
{
|
||||
sd_state = MSD_ERROR;
|
||||
}
|
||||
|
||||
/* Configure SD Bus width */
|
||||
if(sd_state == MSD_OK)
|
||||
{
|
||||
/* Enable wide operation */
|
||||
if(HAL_SD_ConfigWideBusOperation(&uSdHandle, SDIO_BUS_WIDE_4B) != HAL_OK)
|
||||
{
|
||||
sd_state = MSD_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
sd_state = MSD_OK;
|
||||
}
|
||||
}
|
||||
return sd_state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DeInitializes the SD card device.
|
||||
* @retval SD status
|
||||
*/
|
||||
uint8_t BSP_SD_DeInit(void)
|
||||
{
|
||||
uint8_t sd_state = MSD_OK;
|
||||
|
||||
uSdHandle.Instance = SDIO;
|
||||
|
||||
/* Set back Mfx pin to INPUT mode in case it was in exti */
|
||||
UseExtiModeDetection = 0;
|
||||
BSP_IO_ConfigPin(SD_DETECT_PIN, IO_MODE_INPUT_PU);
|
||||
|
||||
/* HAL SD deinitialization */
|
||||
if(HAL_SD_DeInit(&uSdHandle) != HAL_OK)
|
||||
{
|
||||
sd_state = MSD_ERROR;
|
||||
}
|
||||
|
||||
/* Msp SD deinitialization */
|
||||
uSdHandle.Instance = SDIO;
|
||||
BSP_SD_MspDeInit(&uSdHandle, NULL);
|
||||
|
||||
return sd_state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configures Interrupt mode for SD detection pin.
|
||||
* @retval Returns 0
|
||||
*/
|
||||
uint8_t BSP_SD_ITConfig(void)
|
||||
{
|
||||
/* Configure Interrupt mode for SD detection pin */
|
||||
/* Note: disabling exti mode can be done calling SD_DeInit() */
|
||||
UseExtiModeDetection = 1;
|
||||
BSP_SD_IsDetected();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Detects if SD card is correctly plugged in the memory slot or not.
|
||||
* @retval Returns if SD is detected or not
|
||||
*/
|
||||
uint8_t BSP_SD_IsDetected(void)
|
||||
{
|
||||
__IO uint8_t status = SD_PRESENT;
|
||||
|
||||
/* Check SD card detect pin */
|
||||
if((BSP_IO_ReadPin(SD_DETECT_PIN)&SD_DETECT_PIN) != SD_DETECT_PIN)
|
||||
{
|
||||
if (UseExtiModeDetection)
|
||||
BSP_IO_ConfigPin(SD_DETECT_PIN, IO_MODE_IT_RISING_EDGE_PU);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
status = SD_NOT_PRESENT;
|
||||
if (UseExtiModeDetection)
|
||||
BSP_IO_ConfigPin(SD_DETECT_PIN, IO_MODE_IT_FALLING_EDGE_PU);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reads block(s) from a specified address in an SD card, in polling mode.
|
||||
* @param pData: Pointer to the buffer that will contain the data to transmit
|
||||
* @param ReadAddr: Address from where data is to be read
|
||||
* @param NumOfBlocks: Number of SD blocks to read
|
||||
* @param Timeout: Timeout for read operation
|
||||
* @retval SD status
|
||||
*/
|
||||
uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint32_t ReadAddr, uint32_t NumOfBlocks, uint32_t Timeout)
|
||||
{
|
||||
if(HAL_SD_ReadBlocks(&uSdHandle, (uint8_t *)pData, ReadAddr, NumOfBlocks, Timeout) != HAL_OK)
|
||||
{
|
||||
return MSD_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
return MSD_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Writes block(s) to a specified address in an SD card, in polling mode.
|
||||
* @param pData: Pointer to the buffer that will contain the data to transmit
|
||||
* @param WriteAddr: Address from where data is to be written
|
||||
* @param NumOfBlocks: Number of SD blocks to write
|
||||
* @param Timeout: Timeout for write operation
|
||||
* @retval SD status
|
||||
*/
|
||||
uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBlocks, uint32_t Timeout)
|
||||
{
|
||||
if(HAL_SD_WriteBlocks(&uSdHandle, (uint8_t *)pData, WriteAddr, NumOfBlocks, Timeout) != HAL_OK)
|
||||
{
|
||||
return MSD_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
return MSD_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reads block(s) from a specified address in an SD card, in DMA mode.
|
||||
* @param pData: Pointer to the buffer that will contain the data to transmit
|
||||
* @param ReadAddr: Address from where data is to be read
|
||||
* @param NumOfBlocks: Number of SD blocks to read
|
||||
* @retval SD status
|
||||
*/
|
||||
uint8_t BSP_SD_ReadBlocks_DMA(uint32_t *pData, uint32_t ReadAddr, uint32_t NumOfBlocks)
|
||||
{
|
||||
/* Read block(s) in DMA transfer mode */
|
||||
if(HAL_SD_ReadBlocks_DMA(&uSdHandle, (uint8_t *)pData, ReadAddr, NumOfBlocks) != HAL_OK)
|
||||
{
|
||||
return MSD_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
return MSD_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Writes block(s) to a specified address in an SD card, in DMA mode.
|
||||
* @param pData: Pointer to the buffer that will contain the data to transmit
|
||||
* @param WriteAddr: Address from where data is to be written
|
||||
* @param NumOfBlocks: Number of SD blocks to write
|
||||
* @retval SD status
|
||||
*/
|
||||
uint8_t BSP_SD_WriteBlocks_DMA(uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBlocks)
|
||||
{
|
||||
/* Write block(s) in DMA transfer mode */
|
||||
if(HAL_SD_WriteBlocks_DMA(&uSdHandle, (uint8_t *)pData, WriteAddr, NumOfBlocks) != HAL_OK)
|
||||
{
|
||||
return MSD_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
return MSD_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Erases the specified memory area of the given SD card.
|
||||
* @param StartAddr: Start byte address
|
||||
* @param EndAddr: End byte address
|
||||
* @retval SD status
|
||||
*/
|
||||
uint8_t BSP_SD_Erase(uint32_t StartAddr, uint32_t EndAddr)
|
||||
{
|
||||
if(HAL_SD_Erase(&uSdHandle, StartAddr, EndAddr) != HAL_OK)
|
||||
{
|
||||
return MSD_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
return MSD_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initializes the SD MSP.
|
||||
* @param hsd: SD handle
|
||||
* @param Params : pointer on additional configuration parameters, can be NULL.
|
||||
*/
|
||||
__weak void BSP_SD_MspInit(SD_HandleTypeDef *hsd, void *Params)
|
||||
{
|
||||
static DMA_HandleTypeDef dma_rx_handle;
|
||||
static DMA_HandleTypeDef dma_tx_handle;
|
||||
GPIO_InitTypeDef gpio_init_structure;
|
||||
|
||||
/* SD pins are in conflict with Camera pins therefore Camera is power down */
|
||||
/* __weak function can be modified by the application */
|
||||
BSP_IO_ConfigPin(RSTI_PIN, IO_MODE_OUTPUT);
|
||||
BSP_IO_ConfigPin(XSDN_PIN, IO_MODE_OUTPUT);
|
||||
/* De-assert the camera STANDBY pin (active high) */
|
||||
BSP_IO_WritePin(XSDN_PIN, BSP_IO_PIN_RESET);
|
||||
/* Assert the camera RSTI pin (active low) */
|
||||
BSP_IO_WritePin(RSTI_PIN, BSP_IO_PIN_RESET);
|
||||
HAL_Delay(100);
|
||||
|
||||
/* Enable SDIO clock */
|
||||
__HAL_RCC_SDIO_CLK_ENABLE();
|
||||
|
||||
/* Enable DMA2 clocks */
|
||||
__DMAx_TxRx_CLK_ENABLE();
|
||||
|
||||
/* Enable GPIOs clock */
|
||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOD_CLK_ENABLE();
|
||||
|
||||
/* Common GPIO configuration */
|
||||
gpio_init_structure.Mode = GPIO_MODE_AF_PP;
|
||||
gpio_init_structure.Pull = GPIO_PULLUP;
|
||||
gpio_init_structure.Speed = GPIO_SPEED_HIGH;
|
||||
gpio_init_structure.Alternate = GPIO_AF12_SDIO;
|
||||
|
||||
/* GPIOC configuration */
|
||||
gpio_init_structure.Pin = GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12;
|
||||
|
||||
HAL_GPIO_Init(GPIOC, &gpio_init_structure);
|
||||
|
||||
/* GPIOD configuration */
|
||||
gpio_init_structure.Pin = GPIO_PIN_2;
|
||||
HAL_GPIO_Init(GPIOD, &gpio_init_structure);
|
||||
|
||||
/* NVIC configuration for SDIO interrupts */
|
||||
HAL_NVIC_SetPriority(SDIO_IRQn, 0x0E, 0);
|
||||
HAL_NVIC_EnableIRQ(SDIO_IRQn);
|
||||
|
||||
/* Configure DMA Rx parameters */
|
||||
dma_rx_handle.Init.Channel = SD_DMAx_Rx_CHANNEL;
|
||||
dma_rx_handle.Init.Direction = DMA_PERIPH_TO_MEMORY;
|
||||
dma_rx_handle.Init.PeriphInc = DMA_PINC_DISABLE;
|
||||
dma_rx_handle.Init.MemInc = DMA_MINC_ENABLE;
|
||||
dma_rx_handle.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
|
||||
dma_rx_handle.Init.MemDataAlignment = DMA_MDATAALIGN_WORD;
|
||||
dma_rx_handle.Init.Mode = DMA_PFCTRL;
|
||||
dma_rx_handle.Init.Priority = DMA_PRIORITY_VERY_HIGH;
|
||||
dma_rx_handle.Init.FIFOMode = DMA_FIFOMODE_ENABLE;
|
||||
dma_rx_handle.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
|
||||
dma_rx_handle.Init.MemBurst = DMA_MBURST_INC4;
|
||||
dma_rx_handle.Init.PeriphBurst = DMA_PBURST_INC4;
|
||||
|
||||
dma_rx_handle.Instance = SD_DMAx_Rx_STREAM;
|
||||
|
||||
/* Associate the DMA handle */
|
||||
__HAL_LINKDMA(hsd, hdmarx, dma_rx_handle);
|
||||
|
||||
/* Deinitialize the stream for new transfer */
|
||||
HAL_DMA_DeInit(&dma_rx_handle);
|
||||
|
||||
/* Configure the DMA stream */
|
||||
HAL_DMA_Init(&dma_rx_handle);
|
||||
|
||||
/* Configure DMA Tx parameters */
|
||||
dma_tx_handle.Init.Channel = SD_DMAx_Tx_CHANNEL;
|
||||
dma_tx_handle.Init.Direction = DMA_MEMORY_TO_PERIPH;
|
||||
dma_tx_handle.Init.PeriphInc = DMA_PINC_DISABLE;
|
||||
dma_tx_handle.Init.MemInc = DMA_MINC_ENABLE;
|
||||
dma_tx_handle.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
|
||||
dma_tx_handle.Init.MemDataAlignment = DMA_MDATAALIGN_WORD;
|
||||
dma_tx_handle.Init.Mode = DMA_PFCTRL;
|
||||
dma_tx_handle.Init.Priority = DMA_PRIORITY_VERY_HIGH;
|
||||
dma_tx_handle.Init.FIFOMode = DMA_FIFOMODE_ENABLE;
|
||||
dma_tx_handle.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
|
||||
dma_tx_handle.Init.MemBurst = DMA_MBURST_INC4;
|
||||
dma_tx_handle.Init.PeriphBurst = DMA_PBURST_INC4;
|
||||
|
||||
dma_tx_handle.Instance = SD_DMAx_Tx_STREAM;
|
||||
|
||||
/* Associate the DMA handle */
|
||||
__HAL_LINKDMA(hsd, hdmatx, dma_tx_handle);
|
||||
|
||||
/* Deinitialize the stream for new transfer */
|
||||
HAL_DMA_DeInit(&dma_tx_handle);
|
||||
|
||||
/* Configure the DMA stream */
|
||||
HAL_DMA_Init(&dma_tx_handle);
|
||||
|
||||
/* NVIC configuration for DMA transfer complete interrupt */
|
||||
HAL_NVIC_SetPriority(SD_DMAx_Rx_IRQn, 0x0F, 0);
|
||||
HAL_NVIC_EnableIRQ(SD_DMAx_Rx_IRQn);
|
||||
|
||||
/* NVIC configuration for DMA transfer complete interrupt */
|
||||
HAL_NVIC_SetPriority(SD_DMAx_Tx_IRQn, 0x0F, 0);
|
||||
HAL_NVIC_EnableIRQ(SD_DMAx_Tx_IRQn);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DeInitializes the SD MSP.
|
||||
* @param hsd: SD handle
|
||||
* @param Params : pointer on additional configuration parameters, can be NULL.
|
||||
*/
|
||||
__weak void BSP_SD_MspDeInit(SD_HandleTypeDef *hsd, void *Params)
|
||||
{
|
||||
static DMA_HandleTypeDef dma_rx_handle;
|
||||
static DMA_HandleTypeDef dma_tx_handle;
|
||||
|
||||
/* Disable NVIC for DMA transfer complete interrupts */
|
||||
HAL_NVIC_DisableIRQ(SD_DMAx_Rx_IRQn);
|
||||
HAL_NVIC_DisableIRQ(SD_DMAx_Tx_IRQn);
|
||||
|
||||
/* Deinitialize the stream for new transfer */
|
||||
dma_rx_handle.Instance = SD_DMAx_Rx_STREAM;
|
||||
HAL_DMA_DeInit(&dma_rx_handle);
|
||||
|
||||
/* Deinitialize the stream for new transfer */
|
||||
dma_tx_handle.Instance = SD_DMAx_Tx_STREAM;
|
||||
HAL_DMA_DeInit(&dma_tx_handle);
|
||||
|
||||
/* Disable NVIC for SDIO interrupts */
|
||||
HAL_NVIC_DisableIRQ(SDIO_IRQn);
|
||||
|
||||
/* DeInit GPIO pins can be done in the application
|
||||
(by surcharging this __weak function) */
|
||||
|
||||
/* Disable SDIO clock */
|
||||
__HAL_RCC_SDIO_CLK_DISABLE();
|
||||
|
||||
/* GPOI pins clock and DMA cloks can be shut down in the applic
|
||||
by surcgarging this __weak function */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the current SD card data status.
|
||||
* @retval Data transfer state.
|
||||
* This value can be one of the following values:
|
||||
* @arg SD_TRANSFER_OK: No data transfer is acting
|
||||
* @arg SD_TRANSFER_BUSY: Data transfer is acting
|
||||
*/
|
||||
uint8_t BSP_SD_GetCardState(void)
|
||||
{
|
||||
return((HAL_SD_GetCardState(&uSdHandle) == HAL_SD_CARD_TRANSFER ) ? SD_TRANSFER_OK : SD_TRANSFER_BUSY);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get SD information about specific SD card.
|
||||
* @param CardInfo: Pointer to HAL_SD_CardInfoTypedef structure
|
||||
* @retval None
|
||||
*/
|
||||
void BSP_SD_GetCardInfo(HAL_SD_CardInfoTypeDef *CardInfo)
|
||||
{
|
||||
/* Get SD card Information */
|
||||
HAL_SD_GetCardInfo(&uSdHandle, CardInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SD Abort callbacks
|
||||
* @param hsd: SD handle
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_SD_AbortCallback(SD_HandleTypeDef *hsd)
|
||||
{
|
||||
BSP_SD_AbortCallback();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Tx Transfer completed callbacks
|
||||
* @param hsd: SD handle
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_SD_TxCpltCallback(SD_HandleTypeDef *hsd)
|
||||
{
|
||||
BSP_SD_WriteCpltCallback();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Rx Transfer completed callbacks
|
||||
* @param hsd: SD handle
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_SD_RxCpltCallback(SD_HandleTypeDef *hsd)
|
||||
{
|
||||
BSP_SD_ReadCpltCallback();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief BSP SD Abort callbacks
|
||||
* @retval None
|
||||
*/
|
||||
__weak void BSP_SD_AbortCallback(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief BSP Tx Transfer completed callbacks
|
||||
* @retval None
|
||||
*/
|
||||
__weak void BSP_SD_WriteCpltCallback(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief BSP Rx Transfer completed callbacks
|
||||
* @retval None
|
||||
*/
|
||||
__weak void BSP_SD_ReadCpltCallback(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@@ -0,0 +1,144 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32469i_eval_sd.h
|
||||
* @author MCD Application Team
|
||||
* @brief This file contains the common defines and functions prototypes for
|
||||
* the stm32469i_eval_sd.c driver.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2017 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 __STM32469I_EVAL_SD_H
|
||||
#define __STM32469I_EVAL_SD_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32469i_eval.h"
|
||||
#include "stm32469i_eval_io.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32469I_EVAL
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_SD STM32469I EVAL SD
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_SD_Exported_Types STM32469I EVAL SD Exported Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief SD Card information structure
|
||||
*/
|
||||
#define BSP_SD_CardInfo HAL_SD_CardInfoTypeDef
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief SD status structure definition
|
||||
*/
|
||||
#define MSD_OK ((uint8_t)0x00)
|
||||
#define MSD_ERROR ((uint8_t)0x01)
|
||||
#define MSD_ERROR_SD_NOT_PRESENT ((uint8_t)0x02)
|
||||
|
||||
/**
|
||||
* @brief SD transfer state definition
|
||||
*/
|
||||
#define SD_TRANSFER_OK ((uint8_t)0x00)
|
||||
#define SD_TRANSFER_BUSY ((uint8_t)0x01)
|
||||
|
||||
/** @defgroup STM32469I-EVAL_SD_Exported_Constants STM32469I EVAL SD Exported Constants
|
||||
* @{
|
||||
*/
|
||||
#define SD_PRESENT ((uint8_t)0x01)
|
||||
#define SD_NOT_PRESENT ((uint8_t)0x00)
|
||||
|
||||
#define SD_DATATIMEOUT ((uint32_t)100000000)
|
||||
|
||||
/* DMA definitions for SD DMA transfer */
|
||||
#define __DMAx_TxRx_CLK_ENABLE __HAL_RCC_DMA2_CLK_ENABLE
|
||||
#define SD_DMAx_Tx_CHANNEL DMA_CHANNEL_4
|
||||
#define SD_DMAx_Rx_CHANNEL DMA_CHANNEL_4
|
||||
#define SD_DMAx_Tx_STREAM DMA2_Stream6
|
||||
#define SD_DMAx_Rx_STREAM DMA2_Stream3
|
||||
#define SD_DMAx_Tx_IRQn DMA2_Stream6_IRQn
|
||||
#define SD_DMAx_Rx_IRQn DMA2_Stream3_IRQn
|
||||
#define BSP_SD_IRQHandler SDIO_IRQHandler
|
||||
#define BSP_SD_DMA_Tx_IRQHandler DMA2_Stream6_IRQHandler
|
||||
#define BSP_SD_DMA_Rx_IRQHandler DMA2_Stream3_IRQHandler
|
||||
#define SD_DetectIRQHandler() HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_8)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_SD_Exported_Macro STM32469I EVAL SD Exported Macro
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_SD_Exported_Functions STM32469I EVAL SD Exported Functions
|
||||
* @{
|
||||
*/
|
||||
uint8_t BSP_SD_Init(void);
|
||||
uint8_t BSP_SD_DeInit(void);
|
||||
uint8_t BSP_SD_ITConfig(void);
|
||||
uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint32_t ReadAddr, uint32_t NumOfBlocks, uint32_t Timeout);
|
||||
uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBlocks, uint32_t Timeout);
|
||||
uint8_t BSP_SD_ReadBlocks_DMA(uint32_t *pData, uint32_t ReadAddr, uint32_t NumOfBlocks);
|
||||
uint8_t BSP_SD_WriteBlocks_DMA(uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBlocks);
|
||||
uint8_t BSP_SD_Erase(uint32_t StartAddr, uint32_t EndAddr);
|
||||
uint8_t BSP_SD_GetCardState(void);
|
||||
void BSP_SD_GetCardInfo(HAL_SD_CardInfoTypeDef *CardInfo);
|
||||
uint8_t BSP_SD_IsDetected(void);
|
||||
|
||||
/* These functions can be modified in case the current settings (e.g. DMA stream)
|
||||
need to be changed for specific application needs */
|
||||
void BSP_SD_MspInit(SD_HandleTypeDef *hsd, void *Params);
|
||||
void BSP_SD_Detect_MspInit(SD_HandleTypeDef *hsd, void *Params);
|
||||
void BSP_SD_MspDeInit(SD_HandleTypeDef *hsd, void *Params);
|
||||
void BSP_SD_AbortCallback(void);
|
||||
void BSP_SD_WriteCpltCallback(void);
|
||||
void BSP_SD_ReadCpltCallback(void);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __STM32469I_EVAL_SD_H */
|
||||
@@ -0,0 +1,503 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32469i_eval_sdram.c
|
||||
* @author MCD Application Team
|
||||
* @brief This file includes the SDRAM driver for the MT48LC4M32B2B5-7 memory
|
||||
* device mounted on STM32469I-EVAL evaluation board.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2017 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 MT48LC4M32B2B5-7 SDRAM external memory mounted
|
||||
on STM32469I-EVAL evaluation board.
|
||||
- This driver does not need a specific component driver for the SDRAM device
|
||||
to be included with.
|
||||
|
||||
2. 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 DMA transfer using the functions
|
||||
BSP_SDRAM_ReadData_DMA()/BSP_SDRAM_WriteData_DMA().
|
||||
o The AHB access is performed with 32-bit width transaction, the DMA transfer
|
||||
configuration is fixed at single (no burst) word transfer (see the
|
||||
BSP_SDRAM_MspInit() weak function).
|
||||
o User can implement his own functions for read/write access with his desired
|
||||
configurations.
|
||||
o If interrupt mode is used for DMA transfer, the function BSP_SDRAM_DMA_IRQHandler()
|
||||
is called in IRQ handler file, to serve the generated interrupt once the DMA
|
||||
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.
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32469i_eval_sdram.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32469I_EVAL
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_SDRAM STM32469I EVAL SDRAM
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_SDRAM_Private_Types_Definitions STM32469I EVAL SDRAM Private TypesDef
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_SDRAM_Private_Defines STM32469I EVAL SDRAM Private Defines
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_SDRAM_Private_Macros STM32469I EVAL SDRAM Private Macros
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_SDRAM_Private_Variables STM32469I EVAL SDRAM Private Variables
|
||||
* @{
|
||||
*/
|
||||
static SDRAM_HandleTypeDef sdramHandle;
|
||||
static FMC_SDRAM_TimingTypeDef Timing;
|
||||
static FMC_SDRAM_CommandTypeDef Command;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_SDRAM_Private_Function_Prototypes STM32469I EVAL SDRAM Private Prototypes
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_SDRAM_Private_Functions STM32469I EVAL SDRAM Private Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I_EVAL_SDRAM_Exported_Functions STM32469I EVAL SDRAM Exported Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Initializes the SDRAM device.
|
||||
* @retval SDRAM status
|
||||
*/
|
||||
uint8_t BSP_SDRAM_Init(void)
|
||||
{
|
||||
static uint8_t sdramstatus = SDRAM_ERROR;
|
||||
|
||||
/* SDRAM device configuration */
|
||||
sdramHandle.Instance = FMC_SDRAM_DEVICE;
|
||||
|
||||
/* Timing configuration for 90 MHz as SD clock frequency (System clock is up to 180 MHz) */
|
||||
Timing.LoadToActiveDelay = 2; /* TMRD: 2 Clock cycles */
|
||||
Timing.ExitSelfRefreshDelay = 7; /* TXSR: min=70ns (7x11.11ns) */
|
||||
Timing.SelfRefreshTime = 4; /* TRAS: min=42ns (4x11.11ns) max=120k (ns) */
|
||||
Timing.RowCycleDelay = 7; /* TRC: min=70 (7x11.11ns) */
|
||||
Timing.WriteRecoveryTime = 2; /* TWR: min=1+ 7ns (1+1x11.11ns) */
|
||||
Timing.RPDelay = 2; /* TRP: 20ns => 2x11.11ns */
|
||||
Timing.RCDDelay = 2; /* TRCD: 20ns => 2x11.11ns */
|
||||
|
||||
sdramHandle.Init.SDBank = FMC_SDRAM_BANK1;
|
||||
sdramHandle.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_9;
|
||||
sdramHandle.Init.RowBitsNumber = FMC_SDRAM_ROW_BITS_NUM_12;
|
||||
sdramHandle.Init.MemoryDataWidth = SDRAM_MEMORY_WIDTH;
|
||||
sdramHandle.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4;
|
||||
sdramHandle.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_3;
|
||||
sdramHandle.Init.WriteProtection = FMC_SDRAM_WRITE_PROTECTION_DISABLE;
|
||||
sdramHandle.Init.SDClockPeriod = SDCLOCK_PERIOD;
|
||||
sdramHandle.Init.ReadBurst = FMC_SDRAM_RBURST_ENABLE;
|
||||
sdramHandle.Init.ReadPipeDelay = FMC_SDRAM_RPIPE_DELAY_0;
|
||||
|
||||
/* SDRAM controller initialization */
|
||||
/* __weak function can be surcharged by the application code */
|
||||
BSP_SDRAM_MspInit(&sdramHandle, (void *)NULL);
|
||||
if(HAL_SDRAM_Init(&sdramHandle, &Timing) != HAL_OK)
|
||||
{
|
||||
sdramstatus = SDRAM_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
sdramstatus = SDRAM_OK;
|
||||
}
|
||||
|
||||
/* SDRAM initialization sequence */
|
||||
BSP_SDRAM_Initialization_sequence(REFRESH_COUNT);
|
||||
|
||||
return sdramstatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DeInitializes the SDRAM device.
|
||||
* @retval SDRAM status : SDRAM_OK or SDRAM_ERROR.
|
||||
*/
|
||||
uint8_t BSP_SDRAM_DeInit(void)
|
||||
{
|
||||
static uint8_t sdramstatus = SDRAM_ERROR;
|
||||
|
||||
/* SDRAM device configuration */
|
||||
sdramHandle.Instance = FMC_SDRAM_DEVICE;
|
||||
|
||||
if(HAL_SDRAM_DeInit(&sdramHandle) == HAL_OK)
|
||||
{
|
||||
sdramstatus = SDRAM_OK;
|
||||
|
||||
/* SDRAM controller De-initialization */
|
||||
BSP_SDRAM_MspDeInit(&sdramHandle, (void *)NULL);
|
||||
}
|
||||
|
||||
return sdramstatus;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Programs the SDRAM device.
|
||||
* @param RefreshCount: SDRAM refresh counter value
|
||||
*/
|
||||
void BSP_SDRAM_Initialization_sequence(uint32_t RefreshCount)
|
||||
{
|
||||
__IO uint32_t tmpmrd = 0;
|
||||
|
||||
/* Step 1: Configure a clock configuration enable command */
|
||||
Command.CommandMode = FMC_SDRAM_CMD_CLK_ENABLE;
|
||||
Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1;
|
||||
Command.AutoRefreshNumber = 1;
|
||||
Command.ModeRegisterDefinition = 0;
|
||||
|
||||
/* Send the command */
|
||||
HAL_SDRAM_SendCommand(&sdramHandle, &Command, SDRAM_TIMEOUT);
|
||||
|
||||
/* Step 2: Insert 100 us minimum delay */
|
||||
/* Inserted delay is equal to 1 ms due to systick time base unit (ms) */
|
||||
HAL_Delay(1);
|
||||
|
||||
/* Step 3: Configure a PALL (precharge all) command */
|
||||
Command.CommandMode = FMC_SDRAM_CMD_PALL;
|
||||
Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1;
|
||||
Command.AutoRefreshNumber = 1;
|
||||
Command.ModeRegisterDefinition = 0;
|
||||
|
||||
/* Send the command */
|
||||
HAL_SDRAM_SendCommand(&sdramHandle, &Command, SDRAM_TIMEOUT);
|
||||
|
||||
/* Step 4: Configure an Auto Refresh command */
|
||||
Command.CommandMode = FMC_SDRAM_CMD_AUTOREFRESH_MODE;
|
||||
Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1;
|
||||
Command.AutoRefreshNumber = 8;
|
||||
Command.ModeRegisterDefinition = 0;
|
||||
|
||||
/* Send the command */
|
||||
HAL_SDRAM_SendCommand(&sdramHandle, &Command, SDRAM_TIMEOUT);
|
||||
|
||||
/* Step 5: Program the external memory mode register */
|
||||
tmpmrd = (uint32_t)SDRAM_MODEREG_BURST_LENGTH_1 |\
|
||||
SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL |\
|
||||
SDRAM_MODEREG_CAS_LATENCY_3 |\
|
||||
SDRAM_MODEREG_OPERATING_MODE_STANDARD |\
|
||||
SDRAM_MODEREG_WRITEBURST_MODE_SINGLE;
|
||||
|
||||
Command.CommandMode = FMC_SDRAM_CMD_LOAD_MODE;
|
||||
Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1;
|
||||
Command.AutoRefreshNumber = 1;
|
||||
Command.ModeRegisterDefinition = tmpmrd;
|
||||
|
||||
/* Send the command */
|
||||
HAL_SDRAM_SendCommand(&sdramHandle, &Command, SDRAM_TIMEOUT);
|
||||
|
||||
/* Step 6: Set the refresh rate counter */
|
||||
/* Set the device refresh rate */
|
||||
HAL_SDRAM_ProgramRefreshRate(&sdramHandle, RefreshCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reads an mount of data from the SDRAM memory in polling mode.
|
||||
* @param uwStartAddress: Read start address
|
||||
* @param pData: Pointer to data to be read
|
||||
* @param uwDataSize: Size of read data from the memory
|
||||
* @retval SDRAM status : SDRAM_OK or SDRAM_ERROR.
|
||||
*/
|
||||
uint8_t BSP_SDRAM_ReadData(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize)
|
||||
{
|
||||
if(HAL_SDRAM_Read_32b(&sdramHandle, (uint32_t *)uwStartAddress, pData, uwDataSize) != HAL_OK)
|
||||
{
|
||||
return SDRAM_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
return SDRAM_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reads an mount of data from the SDRAM memory in DMA mode.
|
||||
* @param uwStartAddress: Read start address
|
||||
* @param pData: Pointer to data to be read
|
||||
* @param uwDataSize: Size of read data from the memory
|
||||
* @retval SDRAM status : SDRAM_OK or SDRAM_ERROR.
|
||||
*/
|
||||
uint8_t BSP_SDRAM_ReadData_DMA(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize)
|
||||
{
|
||||
if(HAL_SDRAM_Read_DMA(&sdramHandle, (uint32_t *)uwStartAddress, pData, uwDataSize) != HAL_OK)
|
||||
{
|
||||
return SDRAM_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
return SDRAM_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Writes an mount of data to the SDRAM memory in polling mode.
|
||||
* @param uwStartAddress: Write start address
|
||||
* @param pData: Pointer to data to be written
|
||||
* @param uwDataSize: Size of written data from the memory
|
||||
* @retval SDRAM status : SDRAM_OK or SDRAM_ERROR.
|
||||
*/
|
||||
uint8_t BSP_SDRAM_WriteData(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize)
|
||||
{
|
||||
if(HAL_SDRAM_Write_32b(&sdramHandle, (uint32_t *)uwStartAddress, pData, uwDataSize) != HAL_OK)
|
||||
{
|
||||
return SDRAM_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
return SDRAM_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Writes an mount of data to the SDRAM memory in DMA mode.
|
||||
* @param uwStartAddress: Write start address
|
||||
* @param pData: Pointer to data to be written
|
||||
* @param uwDataSize: Size of written data from the memory
|
||||
* @retval SDRAM status : SDRAM_OK or SDRAM_ERROR.
|
||||
*/
|
||||
uint8_t BSP_SDRAM_WriteData_DMA(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize)
|
||||
{
|
||||
if(HAL_SDRAM_Write_DMA(&sdramHandle, (uint32_t *)uwStartAddress, pData, uwDataSize) != HAL_OK)
|
||||
{
|
||||
return SDRAM_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
return SDRAM_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sends command to the SDRAM bank.
|
||||
* @param SdramCmd: Pointer to SDRAM command structure
|
||||
* @retval HAL status : SDRAM_OK or SDRAM_ERROR.
|
||||
*/
|
||||
uint8_t BSP_SDRAM_Sendcmd(FMC_SDRAM_CommandTypeDef *SdramCmd)
|
||||
{
|
||||
if(HAL_SDRAM_SendCommand(&sdramHandle, SdramCmd, SDRAM_TIMEOUT) != HAL_OK)
|
||||
{
|
||||
return SDRAM_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
return SDRAM_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Handles SDRAM DMA transfer interrupt request.
|
||||
*/
|
||||
void BSP_SDRAM_DMA_IRQHandler(void)
|
||||
{
|
||||
HAL_DMA_IRQHandler(sdramHandle.hdma);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initializes SDRAM MSP.
|
||||
* @note This function can be surcharged by application code.
|
||||
* @param hsdram: pointer on SDRAM handle
|
||||
* @param Params: pointer on additional configuration parameters, can be NULL.
|
||||
*/
|
||||
__weak void BSP_SDRAM_MspInit(SDRAM_HandleTypeDef *hsdram, void *Params)
|
||||
{
|
||||
static DMA_HandleTypeDef dma_handle;
|
||||
GPIO_InitTypeDef gpio_init_structure;
|
||||
|
||||
if(hsdram != (SDRAM_HandleTypeDef *)NULL)
|
||||
{
|
||||
/* Enable FMC clock */
|
||||
__HAL_RCC_FMC_CLK_ENABLE();
|
||||
|
||||
/* Enable chosen DMAx clock */
|
||||
__DMAx_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();
|
||||
__HAL_RCC_GPIOI_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_FAST;
|
||||
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_2 | GPIO_PIN_3 | GPIO_PIN_5 | 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(GPIOH, &gpio_init_structure);
|
||||
|
||||
/* GPIOI 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_6 | GPIO_PIN_7 | GPIO_PIN_9 | GPIO_PIN_10;
|
||||
HAL_GPIO_Init(GPIOI, &gpio_init_structure);
|
||||
|
||||
/* Configure common DMA parameters */
|
||||
dma_handle.Init.Channel = SDRAM_DMAx_CHANNEL;
|
||||
dma_handle.Init.Direction = DMA_MEMORY_TO_MEMORY;
|
||||
dma_handle.Init.PeriphInc = DMA_PINC_ENABLE;
|
||||
dma_handle.Init.MemInc = DMA_MINC_ENABLE;
|
||||
dma_handle.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
|
||||
dma_handle.Init.MemDataAlignment = DMA_MDATAALIGN_WORD;
|
||||
dma_handle.Init.Mode = DMA_NORMAL;
|
||||
dma_handle.Init.Priority = DMA_PRIORITY_HIGH;
|
||||
dma_handle.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
|
||||
dma_handle.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
|
||||
dma_handle.Init.MemBurst = DMA_MBURST_SINGLE;
|
||||
dma_handle.Init.PeriphBurst = DMA_PBURST_SINGLE;
|
||||
|
||||
dma_handle.Instance = SDRAM_DMAx_STREAM;
|
||||
|
||||
/* Associate the DMA handle */
|
||||
__HAL_LINKDMA(hsdram, hdma, dma_handle);
|
||||
|
||||
/* Deinitialize the stream for new transfer */
|
||||
HAL_DMA_DeInit(&dma_handle);
|
||||
|
||||
/* Configure the DMA stream */
|
||||
HAL_DMA_Init(&dma_handle);
|
||||
|
||||
/* NVIC configuration for DMA transfer complete interrupt */
|
||||
HAL_NVIC_SetPriority(SDRAM_DMAx_IRQn, 5, 0);
|
||||
HAL_NVIC_EnableIRQ(SDRAM_DMAx_IRQn);
|
||||
|
||||
} /* of if(hsdram != (SDRAM_HandleTypeDef *)NULL) */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DeInitializes SDRAM MSP.
|
||||
* @note This function can be surcharged by application code.
|
||||
* @param hsdram: pointer on SDRAM handle
|
||||
* @param Params: pointer on additional configuration parameters, can be NULL.
|
||||
*/
|
||||
__weak void BSP_SDRAM_MspDeInit(SDRAM_HandleTypeDef *hsdram, void *Params)
|
||||
{
|
||||
static DMA_HandleTypeDef dma_handle;
|
||||
|
||||
if(hsdram != (SDRAM_HandleTypeDef *)NULL)
|
||||
{
|
||||
/* Disable NVIC configuration for DMA interrupt */
|
||||
HAL_NVIC_DisableIRQ(SDRAM_DMAx_IRQn);
|
||||
|
||||
/* Deinitialize the stream for new transfer */
|
||||
dma_handle.Instance = SDRAM_DMAx_STREAM;
|
||||
HAL_DMA_DeInit(&dma_handle);
|
||||
|
||||
/* DeInit GPIO pins can be done in the application
|
||||
(by surcharging this __weak function) */
|
||||
|
||||
/* GPIO pins clock, FMC clock and DMA clock can be shut down in the application
|
||||
by surcharging this __weak function */
|
||||
|
||||
} /* of if(hsdram != (SDRAM_HandleTypeDef *)NULL) */
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@@ -0,0 +1,151 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32469i_eval_sdram.h
|
||||
* @author MCD Application Team
|
||||
* @brief This file contains the common defines and functions prototypes for
|
||||
* the stm32469i_eval_sdram.c driver.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2017 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 __STM32469I_EVAL_SDRAM_H
|
||||
#define __STM32469I_EVAL_SDRAM_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32f4xx_hal.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32469I_EVAL
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32469I-EVAL_SDRAM
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_SDRAM_Exported_Types STM32469I EVAL SDRAM Exported Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief SDRAM status structure definition
|
||||
*/
|
||||
#define SDRAM_OK ((uint8_t)0x00)
|
||||
#define SDRAM_ERROR ((uint8_t)0x01)
|
||||
|
||||
/** @defgroup STM32469I-EVAL_SDRAM_Exported_Constants STM32469I EVAL SDRAM Exported Constants
|
||||
* @{
|
||||
*/
|
||||
#define SDRAM_DEVICE_ADDR ((uint32_t)0xC0000000)
|
||||
|
||||
/* SDRAM device size in Bytes */
|
||||
#define SDRAM_DEVICE_SIZE ((uint32_t)0x2000000)
|
||||
|
||||
#define SDRAM_MEMORY_WIDTH FMC_SDRAM_MEM_BUS_WIDTH_32
|
||||
#define SDCLOCK_PERIOD FMC_SDRAM_CLOCK_PERIOD_2
|
||||
|
||||
/* SDRAM refresh counter (90 MHz SD clock) */
|
||||
#define REFRESH_COUNT ((uint32_t)0x0569)
|
||||
#define SDRAM_TIMEOUT ((uint32_t)0xFFFF)
|
||||
|
||||
/* DMA definitions for SDRAM DMA transfer */
|
||||
#define __DMAx_CLK_ENABLE __HAL_RCC_DMA2_CLK_ENABLE
|
||||
#define __DMAx_CLK_DISABLE __HAL_RCC_DMA2_CLK_DISABLE
|
||||
#define SDRAM_DMAx_CHANNEL DMA_CHANNEL_0
|
||||
#define SDRAM_DMAx_STREAM DMA2_Stream0
|
||||
#define SDRAM_DMAx_IRQn DMA2_Stream0_IRQn
|
||||
#define SDRAM_DMAx_IRQHandler DMA2_Stream0_IRQHandler
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief FMC SDRAM Mode definition register defines
|
||||
*/
|
||||
#define SDRAM_MODEREG_BURST_LENGTH_1 ((uint16_t)0x0000)
|
||||
#define SDRAM_MODEREG_BURST_LENGTH_2 ((uint16_t)0x0001)
|
||||
#define SDRAM_MODEREG_BURST_LENGTH_4 ((uint16_t)0x0002)
|
||||
#define SDRAM_MODEREG_BURST_LENGTH_8 ((uint16_t)0x0004)
|
||||
#define SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL ((uint16_t)0x0000)
|
||||
#define SDRAM_MODEREG_BURST_TYPE_INTERLEAVED ((uint16_t)0x0008)
|
||||
#define SDRAM_MODEREG_CAS_LATENCY_2 ((uint16_t)0x0020)
|
||||
#define SDRAM_MODEREG_CAS_LATENCY_3 ((uint16_t)0x0030)
|
||||
#define SDRAM_MODEREG_OPERATING_MODE_STANDARD ((uint16_t)0x0000)
|
||||
#define SDRAM_MODEREG_WRITEBURST_MODE_PROGRAMMED ((uint16_t)0x0000)
|
||||
#define SDRAM_MODEREG_WRITEBURST_MODE_SINGLE ((uint16_t)0x0200)
|
||||
|
||||
/** @defgroup STM32469I-EVAL_SDRAM_Exported_Macro STM32469I EVAL SDRAM Exported Macro
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32469I_EVAL_SDRAM_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
uint8_t BSP_SDRAM_Init(void);
|
||||
uint8_t BSP_SDRAM_DeInit(void);
|
||||
void BSP_SDRAM_Initialization_sequence(uint32_t RefreshCount);
|
||||
uint8_t BSP_SDRAM_ReadData(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize);
|
||||
uint8_t BSP_SDRAM_ReadData_DMA(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize);
|
||||
uint8_t BSP_SDRAM_WriteData(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize);
|
||||
uint8_t BSP_SDRAM_WriteData_DMA(uint32_t uwStartAddress, uint32_t *pData, uint32_t uwDataSize);
|
||||
uint8_t BSP_SDRAM_Sendcmd(FMC_SDRAM_CommandTypeDef *SdramCmd);
|
||||
void BSP_SDRAM_DMA_IRQHandler(void);
|
||||
|
||||
/* These function can be modified in case the current settings (e.g. DMA stream)
|
||||
need to be changed for specific application needs */
|
||||
void BSP_SDRAM_MspInit(SDRAM_HandleTypeDef *hsdram, void *Params);
|
||||
void BSP_SDRAM_MspDeInit(SDRAM_HandleTypeDef *hsdram, void *Params);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __STM32469I_EVAL_SDRAM_H */
|
||||
@@ -0,0 +1,398 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32469i_eval_sram.c
|
||||
* @author MCD Application Team
|
||||
* @brief This file includes the SRAM driver for the IS61WV102416BLL-10M memory
|
||||
* device mounted on STM32469I-EVAL evaluation board.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2017 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 IS61WV102416BLL-10M SRAM external memory mounted
|
||||
on STM32469I-EVAL evaluation board.
|
||||
- This driver does not need a specific component driver for the SRAM device
|
||||
to be included with.
|
||||
|
||||
2. Driver description:
|
||||
---------------------
|
||||
+ Initialization steps:
|
||||
o Initialize the SRAM external memory using the BSP_SRAM_Init() function. This
|
||||
function includes the MSP layer hardware resources initialization and the
|
||||
FMC controller configuration to interface with the external SRAM memory.
|
||||
|
||||
+ SRAM read/write operations
|
||||
o SRAM 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_SRAM_ReadData()/BSP_SRAM_WriteData(), or by DMA transfer using the functions
|
||||
BSP_SRAM_ReadData_DMA()/BSP_SRAM_WriteData_DMA().
|
||||
o The AHB access is performed with 16-bit width transaction, the DMA transfer
|
||||
configuration is fixed at single (no burst) halfword transfer
|
||||
(see the BSP_SRAM_MspInit() __weak function). This function BSP_SRAM_MspInit()
|
||||
can be surcharged by application code above BSP.
|
||||
o User can implement his own functions for read/write access with his desired
|
||||
configurations.
|
||||
o If interrupt mode is used for DMA transfer, the function BSP_SRAM_DMA_IRQHandler()
|
||||
is called in IRQ handler file, to serve the generated interrupt once the DMA
|
||||
transfer is complete.
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32469i_eval_sram.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32469I_EVAL
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_SRAM STM32469I EVAL SRAM
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_SRAM_Private_Types_Definitions STM32469I EVAL SRAM Private Types Definitions
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_SRAM_Private_Defines STM32469I EVAL SRAM Private Defines
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_SRAM_Private_Macros STM32469I EVAL SRAM Private Macros
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_SRAM_Private_Variables STM32469I EVAL SRAM Private Variables
|
||||
* @{
|
||||
*/
|
||||
static SRAM_HandleTypeDef sramHandle;
|
||||
static FMC_NORSRAM_TimingTypeDef Timing;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_SRAM_Private_Function_Prototypes STM32469I EVAL SRAM Private Function Prototypes
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_SRAM_Private_Functions STM32469I EVAL SRAM Private Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_SRAM_Exported_Functions STM32469I EVAL SRAM Exported Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Initializes the SRAM device.
|
||||
* @retval SRAM status
|
||||
*/
|
||||
uint8_t BSP_SRAM_Init(void)
|
||||
{
|
||||
sramHandle.Instance = FMC_NORSRAM_DEVICE;
|
||||
sramHandle.Extended = FMC_NORSRAM_EXTENDED_DEVICE;
|
||||
|
||||
/* SRAM device configuration */
|
||||
Timing.AddressSetupTime = 2;
|
||||
Timing.AddressHoldTime = 1;
|
||||
Timing.DataSetupTime = 2;
|
||||
Timing.BusTurnAroundDuration = 1;
|
||||
Timing.CLKDivision = 2;
|
||||
Timing.DataLatency = 2;
|
||||
Timing.AccessMode = FMC_ACCESS_MODE_A;
|
||||
|
||||
sramHandle.Init.NSBank = FMC_NORSRAM_BANK2;
|
||||
sramHandle.Init.DataAddressMux = FMC_DATA_ADDRESS_MUX_DISABLE;
|
||||
sramHandle.Init.MemoryType = FMC_MEMORY_TYPE_SRAM;
|
||||
sramHandle.Init.MemoryDataWidth = SRAM_MEMORY_WIDTH;
|
||||
sramHandle.Init.BurstAccessMode = SRAM_BURSTACCESS;
|
||||
sramHandle.Init.WaitSignalPolarity = FMC_WAIT_SIGNAL_POLARITY_LOW;
|
||||
sramHandle.Init.WrapMode = FMC_WRAP_MODE_DISABLE;
|
||||
sramHandle.Init.WaitSignalActive = FMC_WAIT_TIMING_BEFORE_WS;
|
||||
sramHandle.Init.WriteOperation = FMC_WRITE_OPERATION_ENABLE;
|
||||
sramHandle.Init.WaitSignal = FMC_WAIT_SIGNAL_DISABLE;
|
||||
sramHandle.Init.ExtendedMode = FMC_EXTENDED_MODE_DISABLE;
|
||||
sramHandle.Init.AsynchronousWait = FMC_ASYNCHRONOUS_WAIT_DISABLE;
|
||||
sramHandle.Init.WriteBurst = SRAM_WRITEBURST;
|
||||
sramHandle.Init.ContinuousClock = CONTINUOUSCLOCK_FEATURE;
|
||||
|
||||
/* SRAM controller initialization */
|
||||
/* __weak function can be surcharged by the application code */
|
||||
BSP_SRAM_MspInit(&sramHandle, (void*)NULL);
|
||||
if(HAL_SRAM_Init(&sramHandle, &Timing, &Timing) != HAL_OK)
|
||||
{
|
||||
return SRAM_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
return SRAM_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DeInitializes the SRAM device.
|
||||
* @retval SRAM status : SRAM_OK or SRAM_ERROR.
|
||||
*/
|
||||
uint8_t BSP_SRAM_DeInit(void)
|
||||
{
|
||||
static uint8_t sramstatus = SRAM_ERROR;
|
||||
|
||||
/* SRAM device configuration */
|
||||
sramHandle.Instance = FMC_NORSRAM_DEVICE;
|
||||
|
||||
if(HAL_SRAM_DeInit(&sramHandle) == HAL_OK)
|
||||
{
|
||||
sramstatus = SRAM_OK;
|
||||
|
||||
/* SRAM controller De-initialization */
|
||||
BSP_SRAM_MspDeInit(&sramHandle, (void *)NULL);
|
||||
}
|
||||
|
||||
return sramstatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reads an amount of data from the SRAM device in polling mode.
|
||||
* @param uwStartAddress: Read start address
|
||||
* @param pData: Pointer to data to be read
|
||||
* @param uwDataSize: Size of read data from the memory
|
||||
* @retval SRAM status : SRAM_OK or SRAM_ERROR.
|
||||
*/
|
||||
uint8_t BSP_SRAM_ReadData(uint32_t uwStartAddress, uint16_t *pData, uint32_t uwDataSize)
|
||||
{
|
||||
if(HAL_SRAM_Read_16b(&sramHandle, (uint32_t *)uwStartAddress, pData, uwDataSize) != HAL_OK)
|
||||
{
|
||||
return SRAM_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
return SRAM_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reads an amount of data from the SRAM device in DMA mode.
|
||||
* @param uwStartAddress: Read start address
|
||||
* @param pData: Pointer to data to be read
|
||||
* @param uwDataSize: Size of read data from the memory
|
||||
* @retval SRAM status : SRAM_OK or SRAM_ERROR.
|
||||
*/
|
||||
uint8_t BSP_SRAM_ReadData_DMA(uint32_t uwStartAddress, uint16_t *pData, uint32_t uwDataSize)
|
||||
{
|
||||
if(HAL_SRAM_Read_DMA(&sramHandle, (uint32_t *)uwStartAddress, (uint32_t *)pData, uwDataSize) != HAL_OK)
|
||||
{
|
||||
return SRAM_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
return SRAM_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Writes an amount of data from the SRAM device in polling mode.
|
||||
* @param uwStartAddress: Write start address
|
||||
* @param pData: Pointer to data to be written
|
||||
* @param uwDataSize: Size of written data from the memory
|
||||
* @retval SRAM status : SRAM_OK or SRAM_ERROR.
|
||||
*/
|
||||
uint8_t BSP_SRAM_WriteData(uint32_t uwStartAddress, uint16_t *pData, uint32_t uwDataSize)
|
||||
{
|
||||
if(HAL_SRAM_Write_16b(&sramHandle, (uint32_t *)uwStartAddress, pData, uwDataSize) != HAL_OK)
|
||||
{
|
||||
return SRAM_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
return SRAM_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Writes an amount of data from the SRAM device in DMA mode.
|
||||
* @param uwStartAddress: Write start address
|
||||
* @param pData: Pointer to data to be written
|
||||
* @param uwDataSize: Size of written data from the memory
|
||||
* @retval SRAM status : SRAM_OK or SRAM_ERROR.
|
||||
*/
|
||||
uint8_t BSP_SRAM_WriteData_DMA(uint32_t uwStartAddress, uint16_t *pData, uint32_t uwDataSize)
|
||||
{
|
||||
if(HAL_SRAM_Write_DMA(&sramHandle, (uint32_t *)uwStartAddress, (uint32_t *)pData, uwDataSize) != HAL_OK)
|
||||
{
|
||||
return SRAM_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
return SRAM_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Handles SRAM DMA transfer interrupt request.
|
||||
*/
|
||||
void BSP_SRAM_DMA_IRQHandler(void)
|
||||
{
|
||||
HAL_DMA_IRQHandler(sramHandle.hdma);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initializes SRAM MSP.
|
||||
* @note This function can be surcharged by application code.
|
||||
* @param hsram : pointer on SRAM handle
|
||||
* @param Params : pointer on additional configuration parameters, can be NULL.
|
||||
*/
|
||||
__weak void BSP_SRAM_MspInit(SRAM_HandleTypeDef *hsram, void *Params)
|
||||
{
|
||||
static DMA_HandleTypeDef dma_handle;
|
||||
GPIO_InitTypeDef gpio_init_structure;
|
||||
|
||||
if(hsram != (SRAM_HandleTypeDef *)NULL)
|
||||
{
|
||||
/* Enable FMC clock */
|
||||
__HAL_RCC_FMC_CLK_ENABLE();
|
||||
|
||||
/* Enable chosen DMAx clock */
|
||||
__SRAM_DMAx_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();
|
||||
|
||||
/* Common GPIO configuration */
|
||||
gpio_init_structure.Mode = GPIO_MODE_AF_PP;
|
||||
gpio_init_structure.Pull = GPIO_PULLUP;
|
||||
gpio_init_structure.Speed = GPIO_SPEED_HIGH;
|
||||
gpio_init_structure.Alternate = GPIO_AF12_FMC;
|
||||
|
||||
/* GPIOD configuration */
|
||||
gpio_init_structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | 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(GPIOD, &gpio_init_structure);
|
||||
|
||||
/* GPIOE configuration */
|
||||
gpio_init_structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_3| GPIO_PIN_4 | 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_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_2| GPIO_PIN_3 | GPIO_PIN_4 |\
|
||||
GPIO_PIN_5 | GPIO_PIN_9;
|
||||
HAL_GPIO_Init(GPIOG, &gpio_init_structure);
|
||||
|
||||
/* Configure common DMA parameters */
|
||||
dma_handle.Init.Channel = SRAM_DMAx_CHANNEL;
|
||||
dma_handle.Init.Direction = DMA_MEMORY_TO_MEMORY;
|
||||
dma_handle.Init.PeriphInc = DMA_PINC_ENABLE;
|
||||
dma_handle.Init.MemInc = DMA_MINC_ENABLE;
|
||||
dma_handle.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;
|
||||
dma_handle.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD;
|
||||
dma_handle.Init.Mode = DMA_NORMAL;
|
||||
dma_handle.Init.Priority = DMA_PRIORITY_HIGH;
|
||||
dma_handle.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
|
||||
dma_handle.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
|
||||
dma_handle.Init.MemBurst = DMA_MBURST_SINGLE;
|
||||
dma_handle.Init.PeriphBurst = DMA_PBURST_SINGLE;
|
||||
|
||||
dma_handle.Instance = SRAM_DMAx_STREAM;
|
||||
|
||||
/* Associate the DMA handle */
|
||||
__HAL_LINKDMA(hsram, hdma, dma_handle);
|
||||
|
||||
/* Deinitialize the Stream for new transfer */
|
||||
HAL_DMA_DeInit(&dma_handle);
|
||||
|
||||
/* Configure the DMA Stream */
|
||||
HAL_DMA_Init(&dma_handle);
|
||||
|
||||
/* NVIC configuration for DMA transfer complete interrupt */
|
||||
HAL_NVIC_SetPriority(SRAM_DMAx_IRQn, 5, 0);
|
||||
HAL_NVIC_EnableIRQ(SRAM_DMAx_IRQn);
|
||||
|
||||
} /* of if(hsram != (SRAM_HandleTypeDef *)NULL) */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DeInitializes SRAM MSP.
|
||||
* @note This function can be surcharged by application code.
|
||||
* @param hsram : pointer on SRAM handle
|
||||
* @param Params: pointer on additional configuration parameters, can be NULL.
|
||||
*/
|
||||
__weak void BSP_SRAM_MspDeInit(SRAM_HandleTypeDef *hsram, void *Params)
|
||||
{
|
||||
static DMA_HandleTypeDef dma_handle;
|
||||
|
||||
if(hsram != (SRAM_HandleTypeDef *)NULL)
|
||||
{
|
||||
/* Disable NVIC configuration for DMA interrupt */
|
||||
HAL_NVIC_DisableIRQ(SRAM_DMAx_IRQn);
|
||||
|
||||
/* Deinitialize the stream for new transfer */
|
||||
dma_handle.Instance = SRAM_DMAx_STREAM;
|
||||
HAL_DMA_DeInit(&dma_handle);
|
||||
|
||||
/* DeInit GPIO pins can be done in the application
|
||||
(by surcharging this __weak function) */
|
||||
|
||||
/* GPIO pins clock, FMC clock and DMA clock can be shut down in the application
|
||||
by surcharging this __weak function */
|
||||
|
||||
} /* of if(hsram != (SRAM_HandleTypeDef *)NULL) */
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@@ -0,0 +1,122 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32469i_eval_sram.h
|
||||
* @author MCD Application Team
|
||||
* @brief This file contains the common defines and functions prototypes for
|
||||
* the stm32469i_eval_sram.c driver.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2017 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 __STM32469I_EVAL_SRAM_H
|
||||
#define __STM32469I_EVAL_SRAM_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32f4xx_hal.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32469I_EVAL
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32469I-EVAL_SRAM
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_SRAM_Exported_Types STM32469I EVAL SRAM Exported Types
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_SRAM_Exported_Constants STM32469I EVAL SRAM Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define SRAM_OK ((uint8_t)0x00)
|
||||
#define SRAM_ERROR ((uint8_t)0x01)
|
||||
|
||||
#define SRAM_DEVICE_ADDR ((uint32_t)0x64000000)
|
||||
|
||||
/* SRAM device size in Bytes */
|
||||
#define SRAM_DEVICE_SIZE ((uint32_t)0x200000)
|
||||
|
||||
#define SRAM_MEMORY_WIDTH FMC_NORSRAM_MEM_BUS_WIDTH_16
|
||||
#define SRAM_BURSTACCESS FMC_BURST_ACCESS_MODE_DISABLE
|
||||
#define SRAM_WRITEBURST FMC_WRITE_BURST_DISABLE
|
||||
#define CONTINUOUSCLOCK_FEATURE FMC_CONTINUOUS_CLOCK_SYNC_ONLY
|
||||
|
||||
/* DMA definitions for SRAM DMA transfer */
|
||||
#define __SRAM_DMAx_CLK_ENABLE __HAL_RCC_DMA2_CLK_ENABLE
|
||||
#define __SRAM_DMAx_CLK_DISABLE __HAL_RCC_DMA2_CLK_DISABLE
|
||||
#define SRAM_DMAx_CHANNEL DMA_CHANNEL_0
|
||||
#define SRAM_DMAx_STREAM DMA2_Stream4
|
||||
#define SRAM_DMAx_IRQn DMA2_Stream4_IRQn
|
||||
#define SRAM_DMAx_IRQHandler DMA2_Stream4_IRQHandler
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_SRAM_Exported_Macro STM32469I EVAL SRAM Exported Macro
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32469I-EVAL_SRAM_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
uint8_t BSP_SRAM_Init(void);
|
||||
uint8_t BSP_SRAM_DeInit(void);
|
||||
uint8_t BSP_SRAM_ReadData(uint32_t uwStartAddress, uint16_t *pData, uint32_t uwDataSize);
|
||||
uint8_t BSP_SRAM_ReadData_DMA(uint32_t uwStartAddress, uint16_t *pData, uint32_t uwDataSize);
|
||||
uint8_t BSP_SRAM_WriteData(uint32_t uwStartAddress, uint16_t *pData, uint32_t uwDataSize);
|
||||
uint8_t BSP_SRAM_WriteData_DMA(uint32_t uwStartAddress, uint16_t *pData, uint32_t uwDataSize);
|
||||
void BSP_SRAM_DMA_IRQHandler(void);
|
||||
|
||||
/* These function can be modified in case the current settings (e.g. DMA stream)
|
||||
need to be changed for specific application needs */
|
||||
void BSP_SRAM_MspInit(SRAM_HandleTypeDef *hsram, void *Params);
|
||||
void BSP_SRAM_MspDeInit(SRAM_HandleTypeDef *hsram, void *Params);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __STM32469I_EVAL_SRAM_H */
|
||||
@@ -0,0 +1,476 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32469i_eval_ts.c
|
||||
* @author MCD Application Team
|
||||
* @brief This file provides a set of functions needed to manage the Touch
|
||||
* Screen on STM32469I-EVAL evaluation board.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2017 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 touch screen module of the STM32469I-EVAL
|
||||
evaluation board on the K.O.D Optica Technology 480x800 TFT-LCD mounted on
|
||||
MB1166 daughter board. The touch screen driver IC inside the K.O.D module KM-040TMP-02
|
||||
is a FT6206 by Focal Tech.
|
||||
|
||||
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_StateTypeDef structure.
|
||||
o If TS interrupt mode is used, the function BSP_TS_ITGetStatus() is needed to get
|
||||
the interrupt status. To clear the IT pending bits, you should call the
|
||||
function BSP_TS_ITClear().
|
||||
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 "stm32469i_eval.h"
|
||||
#include "stm32469i_eval_ts.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32469I_EVAL
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_TS STM32469I EVAL TS
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_TS_Private_Types_Definitions STM32469I EVAL TS Private Types Definitions
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_TS_Private_Defines STM32469I EVAL TS Private Types Defines
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_TS_Private_Macros STM32469I EVAL TS Private Macros
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_TS_Imported_Variables STM32469I EVAL TS Imported Variables
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_TS_Private_Variables STM32469I EVAL TS Private Variables
|
||||
* @{
|
||||
*/
|
||||
static TS_DrvTypeDef *ts_driver;
|
||||
static uint8_t ts_orientation;
|
||||
uint8_t I2C_Address = 0;
|
||||
|
||||
/* Table for touchscreen event information display on LCD : table indexed on enum @ref TS_TouchEventTypeDef information */
|
||||
char * ts_event_string_tab[TOUCH_EVENT_NB_MAX] = { "None",
|
||||
"Press down",
|
||||
"Lift up",
|
||||
"Contact"
|
||||
};
|
||||
|
||||
/* Table for touchscreen gesture Id information display on LCD : table indexed on enum @ref TS_GestureIdTypeDef information */
|
||||
char * ts_gesture_id_string_tab[GEST_ID_NB_MAX] = { "None",
|
||||
"Move Up",
|
||||
"Move Right",
|
||||
"Move Down",
|
||||
"Move Left",
|
||||
"Zoom In",
|
||||
"Zoom Out"
|
||||
};
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_TS_Private_Function_Prototypes STM32469I EVAL TS Private Function Prototypes
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_TS_Public_Functions STM32469I EVAL TS Public Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Initializes and configures the touch screen functionalities and
|
||||
* configures all necessary hardware resources (GPIOs, I2C, clocks..).
|
||||
* @param ts_SizeX : Maximum X size of the TS area on LCD
|
||||
* @param ts_SizeY : Maximum Y size of the TS area on LCD
|
||||
* @retval TS_OK if all initializations are OK. Other value if error.
|
||||
*/
|
||||
uint8_t BSP_TS_Init(uint16_t ts_SizeX, uint16_t ts_SizeY)
|
||||
{
|
||||
uint8_t ts_status = TS_OK;
|
||||
uint8_t ts_id1, ts_id2 = 0;
|
||||
/* Note : I2C_Address is un-initialized here, but is not used at all in init function */
|
||||
/* but the prototype of Init() is like that in template and should be respected */
|
||||
|
||||
/* Initialize the communication channel to sensor (I2C) if necessary */
|
||||
/* that is initialization is done only once after a power up */
|
||||
ft6x06_ts_drv.Init(I2C_Address);
|
||||
|
||||
ts_id1 = ft6x06_ts_drv.ReadID(TS_I2C_ADDRESS);
|
||||
if(ts_id1 != FT6206_ID_VALUE)
|
||||
{
|
||||
ts_id2 = ft6x06_ts_drv.ReadID(TS_I2C_ADDRESS_A02);
|
||||
I2C_Address = TS_I2C_ADDRESS_A02;
|
||||
}
|
||||
else
|
||||
{
|
||||
I2C_Address = TS_I2C_ADDRESS;
|
||||
}
|
||||
|
||||
/* Scan FT6xx6 TouchScreen IC controller ID register by I2C Read */
|
||||
/* Verify this is a FT6206 or FT6336G, otherwise this is an error case */
|
||||
if((ts_id1 == FT6206_ID_VALUE) || (ts_id2 == FT6x36_ID_VALUE))
|
||||
{
|
||||
/* Found FT6206 : Initialize the TS driver structure */
|
||||
ts_driver = &ft6x06_ts_drv;
|
||||
|
||||
/* Get LCD chosen orientation */
|
||||
if(ts_SizeX < ts_SizeY)
|
||||
{
|
||||
ts_orientation = TS_SWAP_NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
ts_orientation = TS_SWAP_XY | TS_SWAP_Y;
|
||||
}
|
||||
|
||||
if(ts_status == TS_OK)
|
||||
{
|
||||
/* Software reset the TouchScreen */
|
||||
ts_driver->Reset(I2C_Address);
|
||||
|
||||
/* Calibrate, Configure and Start the TouchScreen driver */
|
||||
ts_driver->Start(I2C_Address);
|
||||
|
||||
} /* of if(ts_status == TS_OK) */
|
||||
}
|
||||
else
|
||||
{
|
||||
ts_status = TS_DEVICE_NOT_FOUND;
|
||||
}
|
||||
|
||||
return (ts_status);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configures and enables the touch screen interrupts.
|
||||
* @retval TS_OK if all initializations are OK. Other value if error.
|
||||
*/
|
||||
uint8_t BSP_TS_ITConfig(void)
|
||||
{
|
||||
uint8_t ts_status = TS_ERROR;
|
||||
uint8_t io_status = IO_ERROR;
|
||||
|
||||
/* Initialize the IO */
|
||||
io_status = BSP_IO_Init();
|
||||
if(io_status != IO_OK)
|
||||
{
|
||||
return (ts_status);
|
||||
}
|
||||
|
||||
/* Configure TS IT line IO : is active low on FT6206 (see data sheet) */
|
||||
/* Configure TS_INT_PIN (MFX_IO_14) low level to generate MFX_IRQ_OUT in EXTI on MCU */
|
||||
/* This will call HAL_GPIO_EXTI_Callback() that is setting variable 'mfx_exti_received' to 1b1' */
|
||||
io_status = BSP_IO_ConfigPin(TS_INT_PIN, IO_MODE_IT_LOW_LEVEL_PU);
|
||||
if(io_status != IO_OK)
|
||||
{
|
||||
return (ts_status);
|
||||
}
|
||||
|
||||
/* Enable the TS in interrupt mode */
|
||||
/* In that case the INT output of FT6206 when new touch is available */
|
||||
/* is active low and directed on MFX IO14 */
|
||||
ts_driver->EnableIT(I2C_Address);
|
||||
|
||||
/* If arrived here : set good status on exit */
|
||||
ts_status = TS_OK;
|
||||
|
||||
return (ts_status);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the touch screen interrupt status.
|
||||
* @retval TS_IRQ_PENDING if touchscreen IRQ is pending, TS_NO_IRQ_PENDING when no IRQ TS is pending.
|
||||
*/
|
||||
uint8_t BSP_TS_ITGetStatus(void)
|
||||
{
|
||||
uint8_t itStatus = TS_NO_IRQ_PENDING; /* By default no IRQ TS pending */
|
||||
uint32_t mfx_irq_status = 0; /* No MFX IRQ by default */
|
||||
|
||||
/* Check status of MFX_IO14 in particular which is the Touch Screen INT pin active low */
|
||||
mfx_irq_status = BSP_IO_ITGetStatus(TS_INT_PIN);
|
||||
if(mfx_irq_status != 0) /* Note : returned mfx_irq_status = 0x4000 == (1<<TS_INT_PIN) == (1<<14) */
|
||||
{
|
||||
/* This is Touch Screen INT case : so this is a new touch available that produced the IRQ EXTI */
|
||||
itStatus = TS_IRQ_PENDING;
|
||||
}
|
||||
|
||||
/* Return the TS IT status */
|
||||
return (itStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns status and positions of the touch screen.
|
||||
* @param TS_State: Pointer to touch screen current state structure
|
||||
* @retval TS_OK if all initializations are OK. Other value if error.
|
||||
*/
|
||||
uint8_t BSP_TS_GetState(TS_StateTypeDef *TS_State)
|
||||
{
|
||||
static uint32_t _x[TS_MAX_NB_TOUCH] = {0, 0};
|
||||
static uint32_t _y[TS_MAX_NB_TOUCH] = {0, 0};
|
||||
uint8_t ts_status = TS_OK;
|
||||
uint16_t tmp;
|
||||
uint16_t Raw_x[TS_MAX_NB_TOUCH];
|
||||
uint16_t Raw_y[TS_MAX_NB_TOUCH];
|
||||
uint16_t xDiff;
|
||||
uint16_t yDiff;
|
||||
uint32_t index;
|
||||
#if (TS_MULTI_TOUCH_SUPPORTED == 1)
|
||||
uint32_t weight = 0;
|
||||
uint32_t area = 0;
|
||||
uint32_t event = 0;
|
||||
#endif /* TS_MULTI_TOUCH_SUPPORTED == 1 */
|
||||
|
||||
/* Check and update the number of touches active detected */
|
||||
TS_State->touchDetected = ts_driver->DetectTouch(I2C_Address);
|
||||
if(TS_State->touchDetected)
|
||||
{
|
||||
for(index=0; index < TS_State->touchDetected; index++)
|
||||
{
|
||||
/* Get each touch coordinates */
|
||||
ts_driver->GetXY(I2C_Address, &(Raw_x[index]), &(Raw_y[index]));
|
||||
|
||||
if(ts_orientation & TS_SWAP_XY)
|
||||
{
|
||||
tmp = Raw_x[index];
|
||||
Raw_x[index] = Raw_y[index];
|
||||
Raw_y[index] = tmp;
|
||||
}
|
||||
|
||||
if(ts_orientation & TS_SWAP_X)
|
||||
{
|
||||
Raw_x[index] = FT_6206_MAX_WIDTH - 1 - Raw_x[index];
|
||||
}
|
||||
|
||||
if(ts_orientation & TS_SWAP_Y)
|
||||
{
|
||||
Raw_y[index] = FT_6206_MAX_HEIGHT - 1 - Raw_y[index];
|
||||
}
|
||||
|
||||
xDiff = Raw_x[index] > _x[index]? (Raw_x[index] - _x[index]): (_x[index] - Raw_x[index]);
|
||||
yDiff = Raw_y[index] > _y[index]? (Raw_y[index] - _y[index]): (_y[index] - Raw_y[index]);
|
||||
|
||||
if ((xDiff + yDiff) > 5)
|
||||
{
|
||||
_x[index] = Raw_x[index];
|
||||
_y[index] = Raw_y[index];
|
||||
}
|
||||
|
||||
|
||||
TS_State->touchX[index] = _x[index];
|
||||
TS_State->touchY[index] = _y[index];
|
||||
|
||||
#if (TS_MULTI_TOUCH_SUPPORTED == 1)
|
||||
|
||||
/* Get touch info related to the current touch */
|
||||
ft6x06_TS_GetTouchInfo(I2C_Address, index, &weight, &area, &event);
|
||||
|
||||
/* Update TS_State structure */
|
||||
TS_State->touchWeight[index] = weight;
|
||||
TS_State->touchArea[index] = area;
|
||||
|
||||
/* Remap touch event */
|
||||
switch(event)
|
||||
{
|
||||
case FT6206_TOUCH_EVT_FLAG_PRESS_DOWN :
|
||||
TS_State->touchEventId[index] = TOUCH_EVENT_PRESS_DOWN;
|
||||
break;
|
||||
case FT6206_TOUCH_EVT_FLAG_LIFT_UP :
|
||||
TS_State->touchEventId[index] = TOUCH_EVENT_LIFT_UP;
|
||||
break;
|
||||
case FT6206_TOUCH_EVT_FLAG_CONTACT :
|
||||
TS_State->touchEventId[index] = TOUCH_EVENT_CONTACT;
|
||||
break;
|
||||
case FT6206_TOUCH_EVT_FLAG_NO_EVENT :
|
||||
TS_State->touchEventId[index] = TOUCH_EVENT_NO_EVT;
|
||||
break;
|
||||
default :
|
||||
ts_status = TS_ERROR;
|
||||
break;
|
||||
} /* of switch(event) */
|
||||
|
||||
#endif /* TS_MULTI_TOUCH_SUPPORTED == 1 */
|
||||
|
||||
} /* of for(index=0; index < TS_State->touchDetected; index++) */
|
||||
|
||||
#if (TS_MULTI_TOUCH_SUPPORTED == 1)
|
||||
/* Get gesture Id */
|
||||
ts_status = BSP_TS_Get_GestureId(TS_State);
|
||||
#endif /* TS_MULTI_TOUCH_SUPPORTED == 1 */
|
||||
|
||||
} /* end of if(TS_State->touchDetected != 0) */
|
||||
|
||||
return (ts_status);
|
||||
}
|
||||
|
||||
#if (TS_MULTI_TOUCH_SUPPORTED == 1)
|
||||
/**
|
||||
* @brief Update gesture Id following a touch detected.
|
||||
* @param TS_State: Pointer to touch screen current state structure
|
||||
* @retval TS_OK if all initializations are OK. Other value if error.
|
||||
*/
|
||||
uint8_t BSP_TS_Get_GestureId(TS_StateTypeDef *TS_State)
|
||||
{
|
||||
uint32_t gestureId = 0;
|
||||
uint8_t ts_status = TS_OK;
|
||||
|
||||
/* Get gesture Id */
|
||||
ft6x06_TS_GetGestureID(I2C_Address, &gestureId);
|
||||
|
||||
/* Remap gesture Id to a TS_GestureIdTypeDef value */
|
||||
switch(gestureId)
|
||||
{
|
||||
case FT6206_GEST_ID_NO_GESTURE :
|
||||
TS_State->gestureId = GEST_ID_NO_GESTURE;
|
||||
break;
|
||||
case FT6206_GEST_ID_MOVE_UP :
|
||||
TS_State->gestureId = GEST_ID_MOVE_UP;
|
||||
break;
|
||||
case FT6206_GEST_ID_MOVE_RIGHT :
|
||||
TS_State->gestureId = GEST_ID_MOVE_RIGHT;
|
||||
break;
|
||||
case FT6206_GEST_ID_MOVE_DOWN :
|
||||
TS_State->gestureId = GEST_ID_MOVE_DOWN;
|
||||
break;
|
||||
case FT6206_GEST_ID_MOVE_LEFT :
|
||||
TS_State->gestureId = GEST_ID_MOVE_LEFT;
|
||||
break;
|
||||
case FT6206_GEST_ID_ZOOM_IN :
|
||||
TS_State->gestureId = GEST_ID_ZOOM_IN;
|
||||
break;
|
||||
case FT6206_GEST_ID_ZOOM_OUT :
|
||||
TS_State->gestureId = GEST_ID_ZOOM_OUT;
|
||||
break;
|
||||
default :
|
||||
ts_status = TS_ERROR;
|
||||
break;
|
||||
} /* of switch(gestureId) */
|
||||
|
||||
return(ts_status);
|
||||
}
|
||||
#endif /* TS_MULTI_TOUCH_SUPPORTED == 1 */
|
||||
|
||||
|
||||
/**
|
||||
* @brief Clears all touch screen interrupts.
|
||||
*/
|
||||
void BSP_TS_ITClear(void)
|
||||
{
|
||||
/* Clear TS_INT_PIN IRQ in MFX */
|
||||
BSP_IO_ITClearPin(TS_INT_PIN);
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_TS_Private_Functions STM32469I EVAL TS Private Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if (TS_MULTI_TOUCH_SUPPORTED == 1)
|
||||
/**
|
||||
* @brief Function used to reset all touch data before a new acquisition
|
||||
* of touch information.
|
||||
* @param TS_State: Pointer to touch screen current state structure
|
||||
* @retval TS_OK if OK, TE_ERROR if problem found.
|
||||
*/
|
||||
uint8_t BSP_TS_ResetTouchData(TS_StateTypeDef *TS_State)
|
||||
{
|
||||
uint8_t ts_status = TS_ERROR;
|
||||
uint32_t index;
|
||||
|
||||
if (TS_State != (TS_StateTypeDef *)NULL)
|
||||
{
|
||||
TS_State->gestureId = GEST_ID_NO_GESTURE;
|
||||
TS_State->touchDetected = 0;
|
||||
|
||||
for(index = 0; index < TS_MAX_NB_TOUCH; index++)
|
||||
{
|
||||
TS_State->touchX[index] = 0;
|
||||
TS_State->touchY[index] = 0;
|
||||
TS_State->touchArea[index] = 0;
|
||||
TS_State->touchEventId[index] = TOUCH_EVENT_NO_EVT;
|
||||
TS_State->touchWeight[index] = 0;
|
||||
}
|
||||
|
||||
ts_status = TS_OK;
|
||||
|
||||
} /* of if (TS_State != (TS_StateTypeDef *)NULL) */
|
||||
|
||||
return (ts_status);
|
||||
}
|
||||
#endif /* TS_MULTI_TOUCH_SUPPORTED == 1 */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@@ -0,0 +1,191 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32469i_eval_ts.h
|
||||
* @author MCD Application Team
|
||||
* @brief This file contains the common defines and functions prototypes for
|
||||
* the stm32469i_eval_ts.c driver.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2017 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 __STM32469I_EVAL_TS_H
|
||||
#define __STM32469I_EVAL_TS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32469i_eval.h"
|
||||
#include "stm32469i_eval_lcd.h"
|
||||
#include "stm32469i_eval_io.h"
|
||||
|
||||
/* Include TouchScreen component driver */
|
||||
#include "../Components/ft6x06/ft6x06.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32469I_EVAL
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_TS STM32469I EVAL TS
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_TS_Exported_Constants STM32469I EVAL TS Exported Constants
|
||||
* @{
|
||||
*/
|
||||
/** @brief With FT6206 : maximum 2 touches detected simultaneously
|
||||
*/
|
||||
#define TS_MAX_NB_TOUCH ((uint32_t) FT6206_MAX_DETECTABLE_TOUCH)
|
||||
|
||||
#define TS_NO_IRQ_PENDING ((uint8_t) 0)
|
||||
#define TS_IRQ_PENDING ((uint8_t) 1)
|
||||
|
||||
#define TS_SWAP_NONE ((uint8_t) 0x01)
|
||||
#define TS_SWAP_X ((uint8_t) 0x02)
|
||||
#define TS_SWAP_Y ((uint8_t) 0x04)
|
||||
#define TS_SWAP_XY ((uint8_t) 0x08)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_TS_Exported_Types STM32469I EVAL TS Exported Types
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief TS_StateTypeDef
|
||||
* Define TS State structure
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t touchDetected; /*!< Total number of active touches detected at last scan */
|
||||
uint16_t touchX[TS_MAX_NB_TOUCH]; /*!< Touch X[0], X[1] coordinates on 12 bits */
|
||||
uint16_t touchY[TS_MAX_NB_TOUCH]; /*!< Touch Y[0], Y[1] coordinates on 12 bits */
|
||||
|
||||
#if (TS_MULTI_TOUCH_SUPPORTED == 1)
|
||||
uint8_t touchWeight[TS_MAX_NB_TOUCH]; /*!< Touch_Weight[0], Touch_Weight[1] : weight property of touches */
|
||||
uint8_t touchEventId[TS_MAX_NB_TOUCH]; /*!< Touch_EventId[0], Touch_EventId[1] : take value of type @ref TS_TouchEventTypeDef */
|
||||
uint8_t touchArea[TS_MAX_NB_TOUCH]; /*!< Touch_Area[0], Touch_Area[1] : touch area of each touch */
|
||||
uint32_t gestureId; /*!< type of gesture detected : take value of type @ref TS_GestureIdTypeDef */
|
||||
#endif /* TS_MULTI_TOUCH_SUPPORTED == 1 */
|
||||
|
||||
} TS_StateTypeDef;
|
||||
|
||||
/**
|
||||
* @brief TS_StatusTypeDef
|
||||
* Define BSP_TS_xxx() functions possible return value,
|
||||
* when status is returned by those functions.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
TS_OK = 0x00, /*!< Touch Ok */
|
||||
TS_ERROR = 0x01, /*!< Touch Error */
|
||||
TS_TIMEOUT = 0x02, /*!< Touch Timeout */
|
||||
TS_DEVICE_NOT_FOUND = 0x03 /*!< Touchscreen device not found */
|
||||
} TS_StatusTypeDef;
|
||||
|
||||
/**
|
||||
* @brief TS_GestureIdTypeDef
|
||||
* Define Possible managed gesture identification values returned by touch screen
|
||||
* driver.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GEST_ID_NO_GESTURE = 0x00, /*!< Gesture not defined / recognized */
|
||||
GEST_ID_MOVE_UP = 0x01, /*!< Gesture Move Up */
|
||||
GEST_ID_MOVE_RIGHT = 0x02, /*!< Gesture Move Right */
|
||||
GEST_ID_MOVE_DOWN = 0x03, /*!< Gesture Move Down */
|
||||
GEST_ID_MOVE_LEFT = 0x04, /*!< Gesture Move Left */
|
||||
GEST_ID_ZOOM_IN = 0x05, /*!< Gesture Zoom In */
|
||||
GEST_ID_ZOOM_OUT = 0x06, /*!< Gesture Zoom Out */
|
||||
GEST_ID_NB_MAX = 0x07 /*!< max number of gesture id */
|
||||
} TS_GestureIdTypeDef;
|
||||
|
||||
/**
|
||||
* @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;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_TS_Imported_Variables STM32469I EVAL TS Imported Variables
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief Table for touchscreen event information display on LCD :
|
||||
* table indexed on enum @ref TS_TouchEventTypeDef information
|
||||
*/
|
||||
extern char * ts_event_string_tab[TOUCH_EVENT_NB_MAX];
|
||||
|
||||
/**
|
||||
* @brief Table for touchscreen gesture Id information display on LCD : table indexed
|
||||
* on enum @ref TS_GestureIdTypeDef information
|
||||
*/
|
||||
extern char * ts_gesture_id_string_tab[GEST_ID_NB_MAX];
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32469I-EVAL_TS_Exported_Functions STM32469I EVAL TS Exported Functions
|
||||
* @{
|
||||
*/
|
||||
uint8_t BSP_TS_Init(uint16_t ts_SizeX, uint16_t ts_SizeY);
|
||||
uint8_t BSP_TS_GetState(TS_StateTypeDef *TS_State);
|
||||
|
||||
#if (TS_MULTI_TOUCH_SUPPORTED == 1)
|
||||
uint8_t BSP_TS_Get_GestureId(TS_StateTypeDef *TS_State);
|
||||
uint8_t BSP_TS_ResetTouchData(TS_StateTypeDef *TS_State);
|
||||
#endif /* TS_MULTI_TOUCH_SUPPORTED == 1 */
|
||||
|
||||
uint8_t BSP_TS_ITConfig(void);
|
||||
uint8_t BSP_TS_ITGetStatus(void);
|
||||
void BSP_TS_ITClear(void);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __STM32469I_EVAL_TS_H */
|
||||
Reference in New Issue
Block a user