add LittlevGL demo
add LittlevGL demo on stm32f746 discovery board
This commit is contained in:
@@ -44,17 +44,17 @@
|
||||
/* #define HAL_CRYP_MODULE_ENABLED */
|
||||
/* #define HAL_DAC_MODULE_ENABLED */
|
||||
/* #define HAL_DCMI_MODULE_ENABLED */
|
||||
/* #define HAL_DMA2D_MODULE_ENABLED */
|
||||
#define HAL_DMA2D_MODULE_ENABLED
|
||||
/* #define HAL_ETH_MODULE_ENABLED */
|
||||
/* #define HAL_NAND_MODULE_ENABLED */
|
||||
/* #define HAL_NOR_MODULE_ENABLED */
|
||||
/* #define HAL_SRAM_MODULE_ENABLED */
|
||||
/* #define HAL_SDRAM_MODULE_ENABLED */
|
||||
#define HAL_SDRAM_MODULE_ENABLED
|
||||
/* #define HAL_HASH_MODULE_ENABLED */
|
||||
/* #define HAL_I2S_MODULE_ENABLED */
|
||||
/* #define HAL_IWDG_MODULE_ENABLED */
|
||||
/* #define HAL_LPTIM_MODULE_ENABLED */
|
||||
/* #define HAL_LTDC_MODULE_ENABLED */
|
||||
#define HAL_LTDC_MODULE_ENABLED
|
||||
/* #define HAL_QSPI_MODULE_ENABLED */
|
||||
/* #define HAL_RNG_MODULE_ENABLED */
|
||||
/* #define HAL_RTC_MODULE_ENABLED */
|
||||
|
226
board/STM32F746NGH6_discovery/BSP/Src/stm32f7xx_it_lvgl.c
Normal file
226
board/STM32F746NGH6_discovery/BSP/Src/stm32f7xx_it_lvgl.c
Normal file
@@ -0,0 +1,226 @@
|
||||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32f7xx_it.c
|
||||
* @brief Interrupt Service Routines.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "main.h"
|
||||
#include "stm32f7xx_it.h"
|
||||
#include "tos.h"
|
||||
#include "lvgl/src/lv_hal/lv_hal_tick.h"
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN TD */
|
||||
|
||||
/* USER CODE END TD */
|
||||
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PD */
|
||||
|
||||
/* USER CODE END PD */
|
||||
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PM */
|
||||
|
||||
/* USER CODE END PM */
|
||||
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PV */
|
||||
|
||||
/* USER CODE END PV */
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
/* USER CODE BEGIN PFP */
|
||||
|
||||
/* USER CODE END PFP */
|
||||
|
||||
/* Private user code ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN 0 */
|
||||
|
||||
/* USER CODE END 0 */
|
||||
|
||||
/* External variables --------------------------------------------------------*/
|
||||
extern UART_HandleTypeDef huart1;
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
|
||||
/******************************************************************************/
|
||||
/* Cortex-M7 Processor Interruption and Exception Handlers */
|
||||
/******************************************************************************/
|
||||
/**
|
||||
* @brief This function handles Non maskable interrupt.
|
||||
*/
|
||||
void NMI_Handler(void)
|
||||
{
|
||||
/* USER CODE BEGIN NonMaskableInt_IRQn 0 */
|
||||
|
||||
/* USER CODE END NonMaskableInt_IRQn 0 */
|
||||
/* USER CODE BEGIN NonMaskableInt_IRQn 1 */
|
||||
|
||||
/* USER CODE END NonMaskableInt_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles Hard fault interrupt.
|
||||
*/
|
||||
void HardFault_Handler(void)
|
||||
{
|
||||
/* USER CODE BEGIN HardFault_IRQn 0 */
|
||||
|
||||
/* USER CODE END HardFault_IRQn 0 */
|
||||
while (1)
|
||||
{
|
||||
/* USER CODE BEGIN W1_HardFault_IRQn 0 */
|
||||
/* USER CODE END W1_HardFault_IRQn 0 */
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles Memory management fault.
|
||||
*/
|
||||
void MemManage_Handler(void)
|
||||
{
|
||||
/* USER CODE BEGIN MemoryManagement_IRQn 0 */
|
||||
|
||||
/* USER CODE END MemoryManagement_IRQn 0 */
|
||||
while (1)
|
||||
{
|
||||
/* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */
|
||||
/* USER CODE END W1_MemoryManagement_IRQn 0 */
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles Pre-fetch fault, memory access fault.
|
||||
*/
|
||||
void BusFault_Handler(void)
|
||||
{
|
||||
/* USER CODE BEGIN BusFault_IRQn 0 */
|
||||
|
||||
/* USER CODE END BusFault_IRQn 0 */
|
||||
while (1)
|
||||
{
|
||||
/* USER CODE BEGIN W1_BusFault_IRQn 0 */
|
||||
/* USER CODE END W1_BusFault_IRQn 0 */
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles Undefined instruction or illegal state.
|
||||
*/
|
||||
void UsageFault_Handler(void)
|
||||
{
|
||||
/* USER CODE BEGIN UsageFault_IRQn 0 */
|
||||
|
||||
/* USER CODE END UsageFault_IRQn 0 */
|
||||
while (1)
|
||||
{
|
||||
/* USER CODE BEGIN W1_UsageFault_IRQn 0 */
|
||||
/* USER CODE END W1_UsageFault_IRQn 0 */
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles System service call via SWI instruction.
|
||||
*/
|
||||
void SVC_Handler(void)
|
||||
{
|
||||
/* USER CODE BEGIN SVCall_IRQn 0 */
|
||||
|
||||
/* USER CODE END SVCall_IRQn 0 */
|
||||
/* USER CODE BEGIN SVCall_IRQn 1 */
|
||||
|
||||
/* USER CODE END SVCall_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles Debug monitor.
|
||||
*/
|
||||
void DebugMon_Handler(void)
|
||||
{
|
||||
/* USER CODE BEGIN DebugMonitor_IRQn 0 */
|
||||
|
||||
/* USER CODE END DebugMonitor_IRQn 0 */
|
||||
/* USER CODE BEGIN DebugMonitor_IRQn 1 */
|
||||
|
||||
/* USER CODE END DebugMonitor_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles Pendable request for system service.
|
||||
*/
|
||||
__weak void PendSV_Handler(void)
|
||||
{
|
||||
/* USER CODE BEGIN PendSV_IRQn 0 */
|
||||
|
||||
/* USER CODE END PendSV_IRQn 0 */
|
||||
/* USER CODE BEGIN PendSV_IRQn 1 */
|
||||
|
||||
/* USER CODE END PendSV_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles System tick timer.
|
||||
*/
|
||||
void SysTick_Handler(void)
|
||||
{
|
||||
/* USER CODE BEGIN SysTick_IRQn 0 */
|
||||
|
||||
/* USER CODE END SysTick_IRQn 0 */
|
||||
HAL_IncTick();
|
||||
lv_tick_inc(1);
|
||||
if(tos_knl_is_running())
|
||||
{
|
||||
tos_knl_irq_enter();
|
||||
tos_tick_handler();
|
||||
tos_knl_irq_leave();
|
||||
}
|
||||
/* USER CODE BEGIN SysTick_IRQn 1 */
|
||||
|
||||
/* USER CODE END SysTick_IRQn 1 */
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/* STM32F7xx Peripheral Interrupt Handlers */
|
||||
/* Add here the Interrupt Handlers for the used peripherals. */
|
||||
/* For the available peripheral interrupt handler names, */
|
||||
/* please refer to the startup file (startup_stm32f7xx.s). */
|
||||
/******************************************************************************/
|
||||
|
||||
/**
|
||||
* @brief This function handles USART1 global interrupt.
|
||||
*/
|
||||
void USART1_IRQHandler(void)
|
||||
{
|
||||
/* USER CODE BEGIN USART1_IRQn 0 */
|
||||
|
||||
/* USER CODE END USART1_IRQn 0 */
|
||||
HAL_UART_IRQHandler(&huart1);
|
||||
/* USER CODE BEGIN USART1_IRQn 1 */
|
||||
|
||||
/* USER CODE END USART1_IRQn 1 */
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
/* USER CODE END 1 */
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@@ -0,0 +1,107 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file ts.h
|
||||
* @author MCD Application Team
|
||||
* @version V4.0.1
|
||||
* @date 21-July-2015
|
||||
* @brief This file contains all the functions prototypes for the Touch Screen driver.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
|
||||
*
|
||||
* 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 STMicroelectronics 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.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __TS_H
|
||||
#define __TS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include <stdint.h>
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup Components
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup TS
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup TS_Exported_Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup TS_Driver_structure Touch Sensor Driver structure
|
||||
* @{
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
void (*Init)(uint16_t);
|
||||
uint16_t (*ReadID)(uint16_t);
|
||||
void (*Reset)(uint16_t);
|
||||
void (*Start)(uint16_t);
|
||||
uint8_t (*DetectTouch)(uint16_t);
|
||||
void (*GetXY)(uint16_t, uint16_t*, uint16_t*);
|
||||
void (*EnableIT)(uint16_t);
|
||||
void (*ClearIT)(uint16_t);
|
||||
uint8_t (*GetITStatus)(uint16_t);
|
||||
void (*DisableIT)(uint16_t);
|
||||
}TS_DrvTypeDef;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __TS_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@@ -0,0 +1,215 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40"><head>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
|
||||
|
||||
<link rel="File-List" href="Library_files/filelist.xml">
|
||||
|
||||
|
||||
<link rel="Edit-Time-Data" href="Library_files/editdata.mso"><!--[if !mso]> <style> v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} </style> <![endif]--><title>Release Notes for FT5336GQQ Component Driver</title><!--[if gte mso 9]><xml> <o:DocumentProperties> <o:Author>STMicroelectronics</o:Author> <o:LastAuthor>STMicroelectronics</o:LastAuthor> <o:Revision>37</o:Revision> <o:TotalTime>136</o:TotalTime> <o:Created>2009-02-27T19:26:00Z</o:Created> <o:LastSaved>2009-03-01T17:56:00Z</o:LastSaved> <o:Pages>1</o:Pages> <o:Words>522</o:Words> <o:Characters>2977</o:Characters> <o:Company>STMicroelectronics</o:Company> <o:Lines>24</o:Lines> <o:Paragraphs>6</o:Paragraphs> <o:CharactersWithSpaces>3493</o:CharactersWithSpaces> <o:Version>11.6568</o:Version> </o:DocumentProperties> </xml><![endif]--><!--[if gte mso 9]><xml> <w:WordDocument> <w:Zoom>110</w:Zoom> <w:ValidateAgainstSchemas/> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" LatentStyleCount="156"> </w:LatentStyles> </xml><![endif]-->
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<style>
|
||||
<!--
|
||||
/* Style Definitions */
|
||||
p.MsoNormal, li.MsoNormal, div.MsoNormal
|
||||
{mso-style-parent:"";
|
||||
margin:0in;
|
||||
margin-bottom:.0001pt;
|
||||
mso-pagination:widow-orphan;
|
||||
font-size:12.0pt;
|
||||
font-family:"Times New Roman";
|
||||
mso-fareast-font-family:"Times New Roman";}
|
||||
h2
|
||||
{mso-style-next:Normal;
|
||||
margin-top:12.0pt;
|
||||
margin-right:0in;
|
||||
margin-bottom:3.0pt;
|
||||
margin-left:0in;
|
||||
mso-pagination:widow-orphan;
|
||||
page-break-after:avoid;
|
||||
mso-outline-level:2;
|
||||
font-size:14.0pt;
|
||||
font-family:Arial;
|
||||
font-weight:bold;
|
||||
font-style:italic;}
|
||||
a:link, span.MsoHyperlink
|
||||
{color:blue;
|
||||
text-decoration:underline;
|
||||
text-underline:single;}
|
||||
a:visited, span.MsoHyperlinkFollowed
|
||||
{color:blue;
|
||||
text-decoration:underline;
|
||||
text-underline:single;}
|
||||
p
|
||||
{mso-margin-top-alt:auto;
|
||||
margin-right:0in;
|
||||
mso-margin-bottom-alt:auto;
|
||||
margin-left:0in;
|
||||
mso-pagination:widow-orphan;
|
||||
font-size:12.0pt;
|
||||
font-family:"Times New Roman";
|
||||
mso-fareast-font-family:"Times New Roman";}
|
||||
@page Section1
|
||||
{size:8.5in 11.0in;
|
||||
margin:1.0in 1.25in 1.0in 1.25in;
|
||||
mso-header-margin:.5in;
|
||||
mso-footer-margin:.5in;
|
||||
mso-paper-source:0;}
|
||||
div.Section1
|
||||
{page:Section1;}
|
||||
-->
|
||||
</style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]--><!--[if gte mso 9]><xml> <o:shapedefaults v:ext="edit" spidmax="5122"/> </xml><![endif]--><!--[if gte mso 9]><xml> <o:shapelayout v:ext="edit"> <o:idmap v:ext="edit" data="1"/> </o:shapelayout></xml><![endif]-->
|
||||
<meta content="MCD Application Team" name="author"></head>
|
||||
<body link="blue" vlink="blue">
|
||||
<div class="Section1">
|
||||
<p class="MsoNormal"><span style="font-family: Arial;"><o:p><br>
|
||||
</o:p></span></p>
|
||||
<div align="center">
|
||||
<table class="MsoNormalTable" style="width: 675pt;" border="0" cellpadding="0" cellspacing="0" width="900">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="padding: 0cm;" valign="top">
|
||||
<table class="MsoNormalTable" style="width: 675pt;" border="0" cellpadding="0" cellspacing="0" width="900">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="vertical-align: top;">
|
||||
<p class="MsoNormal"><span style="font-size: 8pt; font-family: Arial; color: blue;"><a href="../../../../Release_Notes.html">Back to Release page</a><o:p></o:p></span></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="">
|
||||
<td style="padding: 1.5pt;">
|
||||
<h1 style="margin-bottom: 18pt; text-align: center;" align="center"><span style="font-size: 20pt; font-family: Verdana; color: rgb(51, 102, 255);">Release
|
||||
Notes for FT5336GQQ Component Driver</span><span style="font-size: 20pt; font-family: Verdana;"><o:p></o:p></span></h1>
|
||||
<p class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;">Copyright
|
||||
2015 STMicroelectronics</span><span style="color: black;"><u1:p></u1:p><o:p></o:p></span></p>
|
||||
<p class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"><img alt="" id="_x0000_i1025" src="../../../../_htmresc/st_logo.png" style="border: 0px solid ; width: 86px; height: 65px;"></span><span style="font-size: 10pt;"><o:p></o:p></span></p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p class="MsoNormal"><span style="font-family: Arial; display: none;"><o:p> </o:p></span></p>
|
||||
<table class="MsoNormalTable" style="width: 675pt;" border="0" cellpadding="0" width="900">
|
||||
<tbody>
|
||||
<tr style="">
|
||||
<td style="padding: 0cm;" valign="top">
|
||||
<span style="font-family: "Times New Roman";">
|
||||
</span>
|
||||
<h2 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial;"><a name="History"></a><span style="font-size: 12pt; color: white;">Update History</span></h2><span style="font-size: 10pt; font-family: Verdana;"><span style="font-style: italic; font-weight: bold;"></span></span><span style="font-size: 10pt; font-family: Verdana;"><span style="font-style: italic; font-weight: bold;"></span></span><span style="font-size: 10pt; font-family: Verdana;"><span style="font-style: italic; font-weight: bold;"></span></span><span style="font-size: 10pt; font-family: Verdana;"><span style="font-style: italic; font-weight: bold;"></span></span><span style="font-size: 10pt; font-family: Verdana;"><span style="font-style: italic; font-weight: bold;"></span></span><span style="font-size: 10pt; font-family: Verdana;"></span><h3 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; width: 180px; margin-right: 500pt;"><span style="color: white; font-family: Arial; font-size: 10pt;">V1.0.1 / 07-April-2017 <o:p></o:p></span></h3><p class="MsoNormal" style="margin: 4.5pt 0cm 4.5pt 18pt;"><b><u><span style="color: black; font-family: Verdana; font-size: 10pt;">Main Changes<o:p></o:p></span></u></b></p><span style="font-family: Verdana; font-size: 10pt;"></span> <span style="font-family: Verdana; font-size: 10pt;"></span> <span style="font-family: Verdana; font-size: 10pt;"></span><span style="font-family: Verdana; font-size: 10pt;"></span> <span style="font-family: Verdana; font-size: 10pt;"></span> <span style="font-family: Verdana; font-size: 10pt;"></span> <span style="font-family: Verdana; font-size: 10pt;"></span> <span style="font-family: Verdana; font-size: 10pt;"></span> <span style="font-family: Verdana; font-size: 10pt;"></span> <span style="font-family: Verdana; font-size: 10pt;"></span> <ul style="list-style-type: square;"><li><span style="font-family: Verdana; font-size: 10pt;"></span><span style="font-family: Verdana;"></span><span style="font-family: Verdana; font-size: 10pt;">Update comments to be used for PDSC generation</span></li></ul><h3 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; margin-right: 500pt; width: 180px;"><span style="font-size: 10pt; font-family: Arial; color: white;">V1.0.0 / 25-June-2015 <o:p></o:p></span></h3>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<p class="MsoNormal" style="margin: 4.5pt 0cm 4.5pt 18pt;"><b style=""><u><span style="font-size: 10pt; font-family: Verdana; color: black;">Main
|
||||
Changes<o:p></o:p></span></u></b></p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<span style="font-size: 10pt; font-family: Verdana;"></span>
|
||||
|
||||
|
||||
|
||||
<span style="font-size: 10pt; font-family: Verdana;"></span>
|
||||
|
||||
|
||||
|
||||
<span style="font-size: 10pt; font-family: Verdana;"></span><span style="font-size: 10pt; font-family: Verdana;"></span>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<span style="font-size: 10pt; font-family: Verdana;"></span>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<span style="font-size: 10pt; font-family: Verdana;"></span>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<span style="font-size: 10pt; font-family: Verdana;"></span>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<ul style="list-style-type: square;">
|
||||
<li><span style="font-size: 10pt; font-family: Verdana;">First official release of FT5336 TS driver </span><span style="font-size: 10pt; font-family: Verdana;"></span></li>
|
||||
</ul><span style="font-size: 10pt; font-family: Verdana;"><span style="font-style: italic; font-weight: bold;"></span></span><span style="font-size: 10pt; font-family: Verdana;"><span style="font-style: italic; font-weight: bold;"></span></span><span style="font-size: 10pt; font-family: Verdana;"><span style="font-style: italic; font-weight: bold;"></span></span><span style="font-size: 10pt; font-family: Verdana;"><span style="font-style: italic; font-weight: bold;"></span></span><span style="font-size: 10pt; font-family: Verdana;"><span style="font-style: italic; font-weight: bold;"></span></span><span style="font-size: 10pt; font-family: Verdana;"></span><h2 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial;"><a name="License"></a><span style="font-size: 12pt; color: white;">License<o:p></o:p></span><br></h2>
|
||||
<div style="text-align: justify;"><font size="-1"><span style="font-family: "Verdana","sans-serif";">
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:</span><br>
|
||||
</font>
|
||||
<ol><li><font size="-1"><span style="font-family: "Verdana","sans-serif";">Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.</span><span style="font-family: "Verdana","sans-serif";"></span></font></li><li><font size="-1"><span style="font-family: "Verdana","sans-serif";">Redistributions
|
||||
in binary form must reproduce the above copyright notice, this list of
|
||||
conditions and the following disclaimer in </span><span style="font-family: "Verdana","sans-serif";">the documentation and/or other materials provided with the distribution.</span><span style="font-family: "Verdana","sans-serif";"></span></font></li><li><font size="-1"><span style="font-family: "Verdana","sans-serif";">Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived </span><br>
|
||||
</font>
|
||||
</li></ol>
|
||||
<font size="-1"><span style="font-family: "Verdana","sans-serif";"> from this software without specific prior written permission.</span><br>
|
||||
<span style="font-family: "Verdana","sans-serif";"></span><br>
|
||||
<span style="font-family: "Verdana","sans-serif";">THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED</span><span style="font-family: "Verdana","sans-serif";"> WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A </span><span style="font-family: "Verdana","sans-serif";">PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY </span><span style="font-family: "Verdana","sans-serif";">DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, </span><span style="font-family: "Verdana","sans-serif";">PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER</span><span style="font-family: "Verdana","sans-serif";"> CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR </span><span style="font-family: "Verdana","sans-serif";">OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span></font>
|
||||
|
||||
</div>
|
||||
<p class="MsoNormal"><span style="font-size: 10pt; font-family: "Verdana","sans-serif"; color: black;"><font size="-1"></font><o:p></o:p></span></p>
|
||||
<b><span style="font-size: 10pt; font-family: Verdana; color: black;"></span></b>
|
||||
|
||||
<div class="MsoNormal" style="text-align: center;" align="center"><span style="color: black;">
|
||||
<hr align="center" size="2" width="100%"></span></div>
|
||||
<p class="MsoNormal" style="margin: 4.5pt 0cm 4.5pt 18pt; text-align: center;" align="center"><span style="font-size: 10pt; font-family: Verdana; color: black;">For
|
||||
complete documentation on </span><span style="font-size: 10pt; font-family: Verdana;">STM32<span style="color: black;"> Microcontrollers
|
||||
visit </span><u><span style="color: blue;"><a href="http://www.st.com/internet/mcu/class/1734.jsp" target="_blank">www.st.com/STM32</a></span></u></span><span style="font-size: 10pt; font-family: Verdana;"><a target="_blank" href="http://www.st.com/internet/mcu/family/141.jsp"><u><span style="color: blue;"></span></u></a></span><span style="font-size: 10pt; font-family: Verdana;"><u><span style="color: blue;"></span></u></span><span style="color: black;"><o:p></o:p></span></p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p class="MsoNormal"><span style="font-size: 10pt;"><o:p></o:p></span></p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<p class="MsoNormal"><o:p> </o:p></p>
|
||||
</div>
|
||||
|
||||
</body></html>
|
@@ -0,0 +1,623 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file ft5336.c
|
||||
* @author MCD Application Team
|
||||
* @brief This file provides a set of functions needed to manage the FT5336
|
||||
* touch screen devices.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
|
||||
*
|
||||
* 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 STMicroelectronics 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.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "ft5336.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup Component
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup FT5336
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
|
||||
/** @defgroup FT5336_Private_Types_Definitions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
|
||||
/** @defgroup FT5336_Private_Defines
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
|
||||
/** @defgroup FT5336_Private_Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
|
||||
/** @defgroup FT5336_Private_Variables
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Touch screen driver structure initialization */
|
||||
TS_DrvTypeDef ft5336_ts_drv =
|
||||
{
|
||||
ft5336_Init,
|
||||
ft5336_ReadID,
|
||||
ft5336_Reset,
|
||||
|
||||
ft5336_TS_Start,
|
||||
ft5336_TS_DetectTouch,
|
||||
ft5336_TS_GetXY,
|
||||
|
||||
ft5336_TS_EnableIT,
|
||||
ft5336_TS_ClearIT,
|
||||
ft5336_TS_ITStatus,
|
||||
ft5336_TS_DisableIT
|
||||
|
||||
};
|
||||
|
||||
/* Global ft5336 handle */
|
||||
static ft5336_handle_TypeDef ft5336_handle = { FT5336_I2C_NOT_INITIALIZED, 0, 0};
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ft5336_Private_Function_Prototypes
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Private functions prototypes-----------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief Return the status of I2C was initialized or not.
|
||||
* @param None.
|
||||
* @retval : I2C initialization status.
|
||||
*/
|
||||
static uint8_t ft5336_Get_I2C_InitializedStatus(void);
|
||||
|
||||
/**
|
||||
* @brief I2C initialize if needed.
|
||||
* @param None.
|
||||
* @retval : None.
|
||||
*/
|
||||
static void ft5336_I2C_InitializeIfRequired(void);
|
||||
|
||||
/**
|
||||
* @brief Basic static configuration of TouchScreen
|
||||
* @param DeviceAddr: FT5336 Device address for communication on I2C Bus.
|
||||
* @retval Status FT5336_STATUS_OK or FT5336_STATUS_NOT_OK.
|
||||
*/
|
||||
static uint32_t ft5336_TS_Configure(uint16_t DeviceAddr);
|
||||
|
||||
/** @defgroup ft5336_Private_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup ft5336_Public_Function_Body
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Public functions bodies-----------------------------------------------*/
|
||||
|
||||
|
||||
/**
|
||||
* @brief Initialize the ft5336 communication bus
|
||||
* from MCU to FT5336 : ie I2C channel initialization (if required).
|
||||
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
|
||||
* @retval None
|
||||
*/
|
||||
void ft5336_Init(uint16_t DeviceAddr)
|
||||
{
|
||||
/* Wait at least 200ms after power up before accessing registers
|
||||
* Trsi timing (Time of starting to report point after resetting) from FT5336GQQ datasheet */
|
||||
TS_IO_Delay(200);
|
||||
|
||||
/* Initialize I2C link if needed */
|
||||
ft5336_I2C_InitializeIfRequired();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Software Reset the ft5336.
|
||||
* @note : Not applicable to FT5336.
|
||||
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
|
||||
* @retval None
|
||||
*/
|
||||
void ft5336_Reset(uint16_t DeviceAddr)
|
||||
{
|
||||
/* Do nothing */
|
||||
/* No software reset sequence available in FT5336 IC */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read the ft5336 device ID, pre initialize I2C in case of need to be
|
||||
* able to read the FT5336 device ID, and verify this is a FT5336.
|
||||
* @param DeviceAddr: I2C FT5336 Slave address.
|
||||
* @retval The Device ID (two bytes).
|
||||
*/
|
||||
uint16_t ft5336_ReadID(uint16_t DeviceAddr)
|
||||
{
|
||||
volatile uint8_t ucReadId = 0;
|
||||
uint8_t nbReadAttempts = 0;
|
||||
uint8_t bFoundDevice = 0; /* Device not found by default */
|
||||
|
||||
/* Initialize I2C link if needed */
|
||||
ft5336_I2C_InitializeIfRequired();
|
||||
|
||||
/* At maximum 4 attempts to read ID : exit at first finding of the searched device ID */
|
||||
for(nbReadAttempts = 0; ((nbReadAttempts < 3) && !(bFoundDevice)); nbReadAttempts++)
|
||||
{
|
||||
/* Read register FT5336_CHIP_ID_REG as DeviceID detection */
|
||||
ucReadId = TS_IO_Read(DeviceAddr, FT5336_CHIP_ID_REG);
|
||||
|
||||
/* Found the searched device ID ? */
|
||||
if(ucReadId == FT5336_ID_VALUE)
|
||||
{
|
||||
/* Set device as found */
|
||||
bFoundDevice = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Return the device ID value */
|
||||
return (ucReadId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configures the touch Screen IC device to start detecting touches
|
||||
* @param DeviceAddr: Device address on communication Bus (I2C slave address).
|
||||
* @retval None.
|
||||
*/
|
||||
void ft5336_TS_Start(uint16_t DeviceAddr)
|
||||
{
|
||||
/* Minimum static configuration of FT5336 */
|
||||
FT5336_ASSERT(ft5336_TS_Configure(DeviceAddr));
|
||||
|
||||
/* By default set FT5336 IC in Polling mode : no INT generation on FT5336 for new touch available */
|
||||
/* Note TS_INT is active low */
|
||||
ft5336_TS_DisableIT(DeviceAddr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return if there is touches detected or not.
|
||||
* Try to detect new touches and forget the old ones (reset internal global
|
||||
* variables).
|
||||
* @param DeviceAddr: Device address on communication Bus.
|
||||
* @retval : Number of active touches detected (can be 0, 1 or 2).
|
||||
*/
|
||||
uint8_t ft5336_TS_DetectTouch(uint16_t DeviceAddr)
|
||||
{
|
||||
volatile uint8_t nbTouch = 0;
|
||||
|
||||
/* Read register FT5336_TD_STAT_REG to check number of touches detection */
|
||||
nbTouch = TS_IO_Read(DeviceAddr, FT5336_TD_STAT_REG);
|
||||
nbTouch &= FT5336_TD_STAT_MASK;
|
||||
|
||||
if(nbTouch > FT5336_MAX_DETECTABLE_TOUCH)
|
||||
{
|
||||
/* If invalid number of touch detected, set it to zero */
|
||||
nbTouch = 0;
|
||||
}
|
||||
|
||||
/* Update ft5336 driver internal global : current number of active touches */
|
||||
ft5336_handle.currActiveTouchNb = nbTouch;
|
||||
|
||||
/* Reset current active touch index on which to work on */
|
||||
ft5336_handle.currActiveTouchIdx = 0;
|
||||
|
||||
return(nbTouch);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the touch screen X and Y positions values
|
||||
* Manage multi touch thanks to touch Index global
|
||||
* variable 'ft5336_handle.currActiveTouchIdx'.
|
||||
* @param DeviceAddr: Device address on communication Bus.
|
||||
* @param X: Pointer to X position value
|
||||
* @param Y: Pointer to Y position value
|
||||
* @retval None.
|
||||
*/
|
||||
void ft5336_TS_GetXY(uint16_t DeviceAddr, uint16_t *X, uint16_t *Y)
|
||||
{
|
||||
volatile uint8_t ucReadData = 0;
|
||||
static uint16_t coord;
|
||||
uint8_t regAddressXLow = 0;
|
||||
uint8_t regAddressXHigh = 0;
|
||||
uint8_t regAddressYLow = 0;
|
||||
uint8_t regAddressYHigh = 0;
|
||||
|
||||
if(ft5336_handle.currActiveTouchIdx < ft5336_handle.currActiveTouchNb)
|
||||
{
|
||||
switch(ft5336_handle.currActiveTouchIdx)
|
||||
{
|
||||
case 0 :
|
||||
regAddressXLow = FT5336_P1_XL_REG;
|
||||
regAddressXHigh = FT5336_P1_XH_REG;
|
||||
regAddressYLow = FT5336_P1_YL_REG;
|
||||
regAddressYHigh = FT5336_P1_YH_REG;
|
||||
break;
|
||||
|
||||
case 1 :
|
||||
regAddressXLow = FT5336_P2_XL_REG;
|
||||
regAddressXHigh = FT5336_P2_XH_REG;
|
||||
regAddressYLow = FT5336_P2_YL_REG;
|
||||
regAddressYHigh = FT5336_P2_YH_REG;
|
||||
break;
|
||||
|
||||
case 2 :
|
||||
regAddressXLow = FT5336_P3_XL_REG;
|
||||
regAddressXHigh = FT5336_P3_XH_REG;
|
||||
regAddressYLow = FT5336_P3_YL_REG;
|
||||
regAddressYHigh = FT5336_P3_YH_REG;
|
||||
break;
|
||||
|
||||
case 3 :
|
||||
regAddressXLow = FT5336_P4_XL_REG;
|
||||
regAddressXHigh = FT5336_P4_XH_REG;
|
||||
regAddressYLow = FT5336_P4_YL_REG;
|
||||
regAddressYHigh = FT5336_P4_YH_REG;
|
||||
break;
|
||||
|
||||
case 4 :
|
||||
regAddressXLow = FT5336_P5_XL_REG;
|
||||
regAddressXHigh = FT5336_P5_XH_REG;
|
||||
regAddressYLow = FT5336_P5_YL_REG;
|
||||
regAddressYHigh = FT5336_P5_YH_REG;
|
||||
break;
|
||||
|
||||
case 5 :
|
||||
regAddressXLow = FT5336_P6_XL_REG;
|
||||
regAddressXHigh = FT5336_P6_XH_REG;
|
||||
regAddressYLow = FT5336_P6_YL_REG;
|
||||
regAddressYHigh = FT5336_P6_YH_REG;
|
||||
break;
|
||||
|
||||
case 6 :
|
||||
regAddressXLow = FT5336_P7_XL_REG;
|
||||
regAddressXHigh = FT5336_P7_XH_REG;
|
||||
regAddressYLow = FT5336_P7_YL_REG;
|
||||
regAddressYHigh = FT5336_P7_YH_REG;
|
||||
break;
|
||||
|
||||
case 7 :
|
||||
regAddressXLow = FT5336_P8_XL_REG;
|
||||
regAddressXHigh = FT5336_P8_XH_REG;
|
||||
regAddressYLow = FT5336_P8_YL_REG;
|
||||
regAddressYHigh = FT5336_P8_YH_REG;
|
||||
break;
|
||||
|
||||
case 8 :
|
||||
regAddressXLow = FT5336_P9_XL_REG;
|
||||
regAddressXHigh = FT5336_P9_XH_REG;
|
||||
regAddressYLow = FT5336_P9_YL_REG;
|
||||
regAddressYHigh = FT5336_P9_YH_REG;
|
||||
break;
|
||||
|
||||
case 9 :
|
||||
regAddressXLow = FT5336_P10_XL_REG;
|
||||
regAddressXHigh = FT5336_P10_XH_REG;
|
||||
regAddressYLow = FT5336_P10_YL_REG;
|
||||
regAddressYHigh = FT5336_P10_YH_REG;
|
||||
break;
|
||||
|
||||
default :
|
||||
break;
|
||||
|
||||
} /* end switch(ft5336_handle.currActiveTouchIdx) */
|
||||
|
||||
/* Read low part of X position */
|
||||
ucReadData = TS_IO_Read(DeviceAddr, regAddressXLow);
|
||||
coord = (ucReadData & FT5336_TOUCH_POS_LSB_MASK) >> FT5336_TOUCH_POS_LSB_SHIFT;
|
||||
|
||||
/* Read high part of X position */
|
||||
ucReadData = TS_IO_Read(DeviceAddr, regAddressXHigh);
|
||||
coord |= ((ucReadData & FT5336_TOUCH_POS_MSB_MASK) >> FT5336_TOUCH_POS_MSB_SHIFT) << 8;
|
||||
|
||||
/* Send back ready X position to caller */
|
||||
*X = coord;
|
||||
|
||||
/* Read low part of Y position */
|
||||
ucReadData = TS_IO_Read(DeviceAddr, regAddressYLow);
|
||||
coord = (ucReadData & FT5336_TOUCH_POS_LSB_MASK) >> FT5336_TOUCH_POS_LSB_SHIFT;
|
||||
|
||||
/* Read high part of Y position */
|
||||
ucReadData = TS_IO_Read(DeviceAddr, regAddressYHigh);
|
||||
coord |= ((ucReadData & FT5336_TOUCH_POS_MSB_MASK) >> FT5336_TOUCH_POS_MSB_SHIFT) << 8;
|
||||
|
||||
/* Send back ready Y position to caller */
|
||||
*Y = coord;
|
||||
|
||||
ft5336_handle.currActiveTouchIdx++; /* next call will work on next touch */
|
||||
|
||||
} /* of if(ft5336_handle.currActiveTouchIdx < ft5336_handle.currActiveTouchNb) */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure the FT5336 device to generate IT on given INT pin
|
||||
* connected to MCU as EXTI.
|
||||
* @param DeviceAddr: Device address on communication Bus (Slave I2C address of FT5336).
|
||||
* @retval None
|
||||
*/
|
||||
void ft5336_TS_EnableIT(uint16_t DeviceAddr)
|
||||
{
|
||||
uint8_t regValue = 0;
|
||||
regValue = (FT5336_G_MODE_INTERRUPT_TRIGGER & (FT5336_G_MODE_INTERRUPT_MASK >> FT5336_G_MODE_INTERRUPT_SHIFT)) << FT5336_G_MODE_INTERRUPT_SHIFT;
|
||||
|
||||
/* Set interrupt trigger mode in FT5336_GMODE_REG */
|
||||
TS_IO_Write(DeviceAddr, FT5336_GMODE_REG, regValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure the FT5336 device to stop generating IT on the given INT pin
|
||||
* connected to MCU as EXTI.
|
||||
* @param DeviceAddr: Device address on communication Bus (Slave I2C address of FT5336).
|
||||
* @retval None
|
||||
*/
|
||||
void ft5336_TS_DisableIT(uint16_t DeviceAddr)
|
||||
{
|
||||
uint8_t regValue = 0;
|
||||
regValue = (FT5336_G_MODE_INTERRUPT_POLLING & (FT5336_G_MODE_INTERRUPT_MASK >> FT5336_G_MODE_INTERRUPT_SHIFT)) << FT5336_G_MODE_INTERRUPT_SHIFT;
|
||||
|
||||
/* Set interrupt polling mode in FT5336_GMODE_REG */
|
||||
TS_IO_Write(DeviceAddr, FT5336_GMODE_REG, regValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get IT status from FT5336 interrupt status registers
|
||||
* Should be called Following an EXTI coming to the MCU to know the detailed
|
||||
* reason of the interrupt.
|
||||
* @note : This feature is not applicable to FT5336.
|
||||
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
|
||||
* @retval TS interrupts status : always return 0 here
|
||||
*/
|
||||
uint8_t ft5336_TS_ITStatus(uint16_t DeviceAddr)
|
||||
{
|
||||
/* Always return 0 as feature not applicable to FT5336 */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear IT status in FT5336 interrupt status clear registers
|
||||
* Should be called Following an EXTI coming to the MCU.
|
||||
* @note : This feature is not applicable to FT5336.
|
||||
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
|
||||
* @retval None
|
||||
*/
|
||||
void ft5336_TS_ClearIT(uint16_t DeviceAddr)
|
||||
{
|
||||
/* Nothing to be done here for FT5336 */
|
||||
}
|
||||
|
||||
/**** NEW FEATURES enabled when Multi-touch support is enabled ****/
|
||||
|
||||
#if (TS_MULTI_TOUCH_SUPPORTED == 1)
|
||||
|
||||
/**
|
||||
* @brief Get the last touch gesture identification (zoom, move up/down...).
|
||||
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
|
||||
* @param pGestureId : Pointer to get last touch gesture Identification.
|
||||
* @retval None.
|
||||
*/
|
||||
void ft5336_TS_GetGestureID(uint16_t DeviceAddr, uint32_t * pGestureId)
|
||||
{
|
||||
volatile uint8_t ucReadData = 0;
|
||||
|
||||
ucReadData = TS_IO_Read(DeviceAddr, FT5336_GEST_ID_REG);
|
||||
|
||||
* pGestureId = ucReadData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the touch detailed informations on touch number 'touchIdx' (0..1)
|
||||
* This touch detailed information contains :
|
||||
* - weight that was applied to this touch
|
||||
* - sub-area of the touch in the touch panel
|
||||
* - event of linked to the touch (press down, lift up, ...)
|
||||
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
|
||||
* @param touchIdx : Passed index of the touch (0..1) on which we want to get the
|
||||
* detailed information.
|
||||
* @param pWeight : Pointer to to get the weight information of 'touchIdx'.
|
||||
* @param pArea : Pointer to to get the sub-area information of 'touchIdx'.
|
||||
* @param pEvent : Pointer to to get the event information of 'touchIdx'.
|
||||
|
||||
* @retval None.
|
||||
*/
|
||||
void ft5336_TS_GetTouchInfo(uint16_t DeviceAddr,
|
||||
uint32_t touchIdx,
|
||||
uint32_t * pWeight,
|
||||
uint32_t * pArea,
|
||||
uint32_t * pEvent)
|
||||
{
|
||||
volatile uint8_t ucReadData = 0;
|
||||
uint8_t regAddressXHigh = 0;
|
||||
uint8_t regAddressPWeight = 0;
|
||||
uint8_t regAddressPMisc = 0;
|
||||
|
||||
if(touchIdx < ft5336_handle.currActiveTouchNb)
|
||||
{
|
||||
switch(touchIdx)
|
||||
{
|
||||
case 0 :
|
||||
regAddressXHigh = FT5336_P1_XH_REG;
|
||||
regAddressPWeight = FT5336_P1_WEIGHT_REG;
|
||||
regAddressPMisc = FT5336_P1_MISC_REG;
|
||||
break;
|
||||
|
||||
case 1 :
|
||||
regAddressXHigh = FT5336_P2_XH_REG;
|
||||
regAddressPWeight = FT5336_P2_WEIGHT_REG;
|
||||
regAddressPMisc = FT5336_P2_MISC_REG;
|
||||
break;
|
||||
|
||||
case 2 :
|
||||
regAddressXHigh = FT5336_P3_XH_REG;
|
||||
regAddressPWeight = FT5336_P3_WEIGHT_REG;
|
||||
regAddressPMisc = FT5336_P3_MISC_REG;
|
||||
break;
|
||||
|
||||
case 3 :
|
||||
regAddressXHigh = FT5336_P4_XH_REG;
|
||||
regAddressPWeight = FT5336_P4_WEIGHT_REG;
|
||||
regAddressPMisc = FT5336_P4_MISC_REG;
|
||||
break;
|
||||
|
||||
case 4 :
|
||||
regAddressXHigh = FT5336_P5_XH_REG;
|
||||
regAddressPWeight = FT5336_P5_WEIGHT_REG;
|
||||
regAddressPMisc = FT5336_P5_MISC_REG;
|
||||
break;
|
||||
|
||||
case 5 :
|
||||
regAddressXHigh = FT5336_P6_XH_REG;
|
||||
regAddressPWeight = FT5336_P6_WEIGHT_REG;
|
||||
regAddressPMisc = FT5336_P6_MISC_REG;
|
||||
break;
|
||||
|
||||
case 6 :
|
||||
regAddressXHigh = FT5336_P7_XH_REG;
|
||||
regAddressPWeight = FT5336_P7_WEIGHT_REG;
|
||||
regAddressPMisc = FT5336_P7_MISC_REG;
|
||||
break;
|
||||
|
||||
case 7 :
|
||||
regAddressXHigh = FT5336_P8_XH_REG;
|
||||
regAddressPWeight = FT5336_P8_WEIGHT_REG;
|
||||
regAddressPMisc = FT5336_P8_MISC_REG;
|
||||
break;
|
||||
|
||||
case 8 :
|
||||
regAddressXHigh = FT5336_P9_XH_REG;
|
||||
regAddressPWeight = FT5336_P9_WEIGHT_REG;
|
||||
regAddressPMisc = FT5336_P9_MISC_REG;
|
||||
break;
|
||||
|
||||
case 9 :
|
||||
regAddressXHigh = FT5336_P10_XH_REG;
|
||||
regAddressPWeight = FT5336_P10_WEIGHT_REG;
|
||||
regAddressPMisc = FT5336_P10_MISC_REG;
|
||||
break;
|
||||
|
||||
default :
|
||||
break;
|
||||
|
||||
} /* end switch(touchIdx) */
|
||||
|
||||
/* Read Event Id of touch index */
|
||||
ucReadData = TS_IO_Read(DeviceAddr, regAddressXHigh);
|
||||
* pEvent = (ucReadData & FT5336_TOUCH_EVT_FLAG_MASK) >> FT5336_TOUCH_EVT_FLAG_SHIFT;
|
||||
|
||||
/* Read weight of touch index */
|
||||
ucReadData = TS_IO_Read(DeviceAddr, regAddressPWeight);
|
||||
* pWeight = (ucReadData & FT5336_TOUCH_WEIGHT_MASK) >> FT5336_TOUCH_WEIGHT_SHIFT;
|
||||
|
||||
/* Read area of touch index */
|
||||
ucReadData = TS_IO_Read(DeviceAddr, regAddressPMisc);
|
||||
* pArea = (ucReadData & FT5336_TOUCH_AREA_MASK) >> FT5336_TOUCH_AREA_SHIFT;
|
||||
|
||||
} /* of if(touchIdx < ft5336_handle.currActiveTouchNb) */
|
||||
}
|
||||
|
||||
#endif /* TS_MULTI_TOUCH_SUPPORTED == 1 */
|
||||
|
||||
/** @defgroup ft5336_Static_Function_Body
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Static functions bodies-----------------------------------------------*/
|
||||
|
||||
|
||||
/**
|
||||
* @brief Return the status of I2C was initialized or not.
|
||||
* @param None.
|
||||
* @retval : I2C initialization status.
|
||||
*/
|
||||
static uint8_t ft5336_Get_I2C_InitializedStatus(void)
|
||||
{
|
||||
return(ft5336_handle.i2cInitialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief I2C initialize if needed.
|
||||
* @param None.
|
||||
* @retval : None.
|
||||
*/
|
||||
static void ft5336_I2C_InitializeIfRequired(void)
|
||||
{
|
||||
if(ft5336_Get_I2C_InitializedStatus() == FT5336_I2C_NOT_INITIALIZED)
|
||||
{
|
||||
/* Initialize TS IO BUS layer (I2C) */
|
||||
TS_IO_Init();
|
||||
|
||||
/* Set state to initialized */
|
||||
ft5336_handle.i2cInitialized = FT5336_I2C_INITIALIZED;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Basic static configuration of TouchScreen
|
||||
* @param DeviceAddr: FT5336 Device address for communication on I2C Bus.
|
||||
* @retval Status FT5336_STATUS_OK or FT5336_STATUS_NOT_OK.
|
||||
*/
|
||||
static uint32_t ft5336_TS_Configure(uint16_t DeviceAddr)
|
||||
{
|
||||
uint32_t status = FT5336_STATUS_OK;
|
||||
|
||||
/* Nothing special to be done for FT5336 */
|
||||
|
||||
return(status);
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@@ -0,0 +1,538 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file ft5336.h
|
||||
* @author MCD Application Team
|
||||
* @brief This file contains all the functions prototypes for the
|
||||
* ft5336.c Touch screen driver.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
|
||||
*
|
||||
* 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 STMicroelectronics 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.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __FT5336_H
|
||||
#define __FT5336_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Set Multi-touch as supported */
|
||||
#if !defined(TS_MONO_TOUCH_SUPPORTED)
|
||||
#define TS_MULTI_TOUCH_SUPPORTED 1
|
||||
#endif /* TS_MONO_TOUCH_SUPPORTED */
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "../Common/ts.h"
|
||||
|
||||
/* Macros --------------------------------------------------------------------*/
|
||||
|
||||
#if defined(FT5336_ENABLE_ASSERT)
|
||||
/* Assert activated */
|
||||
#define FT5336_ASSERT(__condition__) do { if(__condition__) \
|
||||
{ \
|
||||
while(1); \
|
||||
} \
|
||||
}while(0)
|
||||
#else
|
||||
/* Assert not activated : macro has no effect */
|
||||
#define FT5336_ASSERT(__condition__) do { if(__condition__) \
|
||||
{ \
|
||||
; \
|
||||
} \
|
||||
}while(0)
|
||||
#endif /* FT5336_ENABLE_ASSERT == 1 */
|
||||
|
||||
/** @typedef ft5336_handle_TypeDef
|
||||
* ft5336 Handle definition.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t i2cInitialized;
|
||||
|
||||
/* field holding the current number of simultaneous active touches */
|
||||
uint8_t currActiveTouchNb;
|
||||
|
||||
/* field holding the touch index currently managed */
|
||||
uint8_t currActiveTouchIdx;
|
||||
|
||||
} ft5336_handle_TypeDef;
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup Component
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup FT5336
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
|
||||
/** @defgroup FT5336_Exported_Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
||||
/** @defgroup FT5336_Exported_Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* I2C Slave address of touchscreen FocalTech FT5336 */
|
||||
#define FT5336_I2C_SLAVE_ADDRESS ((uint8_t)0x70)
|
||||
|
||||
/* Maximum border values of the touchscreen pad */
|
||||
#define FT5336_MAX_WIDTH ((uint16_t)480) /* Touchscreen pad max width */
|
||||
#define FT5336_MAX_HEIGHT ((uint16_t)272) /* Touchscreen pad max height */
|
||||
|
||||
/* Possible values of driver functions return status */
|
||||
#define FT5336_STATUS_OK ((uint8_t)0x00)
|
||||
#define FT5336_STATUS_NOT_OK ((uint8_t)0x01)
|
||||
|
||||
/* Possible values of global variable 'TS_I2C_Initialized' */
|
||||
#define FT5336_I2C_NOT_INITIALIZED ((uint8_t)0x00)
|
||||
#define FT5336_I2C_INITIALIZED ((uint8_t)0x01)
|
||||
|
||||
/* Max detectable simultaneous touches */
|
||||
#define FT5336_MAX_DETECTABLE_TOUCH ((uint8_t)0x05)
|
||||
|
||||
/**
|
||||
* @brief : Definitions for FT5336 I2C register addresses on 8 bit
|
||||
**/
|
||||
|
||||
/* Current mode register of the FT5336 (R/W) */
|
||||
#define FT5336_DEV_MODE_REG ((uint8_t)0x00)
|
||||
|
||||
/* Possible values of FT5336_DEV_MODE_REG */
|
||||
#define FT5336_DEV_MODE_WORKING ((uint8_t)0x00)
|
||||
#define FT5336_DEV_MODE_FACTORY ((uint8_t)0x04)
|
||||
|
||||
#define FT5336_DEV_MODE_MASK ((uint8_t)0x07)
|
||||
#define FT5336_DEV_MODE_SHIFT ((uint8_t)0x04)
|
||||
|
||||
/* Gesture ID register */
|
||||
#define FT5336_GEST_ID_REG ((uint8_t)0x01)
|
||||
|
||||
/* Possible values of FT5336_GEST_ID_REG */
|
||||
#define FT5336_GEST_ID_NO_GESTURE ((uint8_t)0x00)
|
||||
#define FT5336_GEST_ID_MOVE_UP ((uint8_t)0x10)
|
||||
#define FT5336_GEST_ID_MOVE_RIGHT ((uint8_t)0x14)
|
||||
#define FT5336_GEST_ID_MOVE_DOWN ((uint8_t)0x18)
|
||||
#define FT5336_GEST_ID_MOVE_LEFT ((uint8_t)0x1C)
|
||||
#define FT5336_GEST_ID_SINGLE_CLICK ((uint8_t)0x20)
|
||||
#define FT5336_GEST_ID_DOUBLE_CLICK ((uint8_t)0x22)
|
||||
#define FT5336_GEST_ID_ROTATE_CLOCKWISE ((uint8_t)0x28)
|
||||
#define FT5336_GEST_ID_ROTATE_C_CLOCKWISE ((uint8_t)0x29)
|
||||
#define FT5336_GEST_ID_ZOOM_IN ((uint8_t)0x40)
|
||||
#define FT5336_GEST_ID_ZOOM_OUT ((uint8_t)0x49)
|
||||
|
||||
/* Touch Data Status register : gives number of active touch points (0..5) */
|
||||
#define FT5336_TD_STAT_REG ((uint8_t)0x02)
|
||||
|
||||
/* Values related to FT5336_TD_STAT_REG */
|
||||
#define FT5336_TD_STAT_MASK ((uint8_t)0x0F)
|
||||
#define FT5336_TD_STAT_SHIFT ((uint8_t)0x00)
|
||||
|
||||
/* Values Pn_XH and Pn_YH related */
|
||||
#define FT5336_TOUCH_EVT_FLAG_PRESS_DOWN ((uint8_t)0x00)
|
||||
#define FT5336_TOUCH_EVT_FLAG_LIFT_UP ((uint8_t)0x01)
|
||||
#define FT5336_TOUCH_EVT_FLAG_CONTACT ((uint8_t)0x02)
|
||||
#define FT5336_TOUCH_EVT_FLAG_NO_EVENT ((uint8_t)0x03)
|
||||
|
||||
#define FT5336_TOUCH_EVT_FLAG_SHIFT ((uint8_t)0x06)
|
||||
#define FT5336_TOUCH_EVT_FLAG_MASK ((uint8_t)(3 << FT5336_TOUCH_EVT_FLAG_SHIFT))
|
||||
|
||||
#define FT5336_TOUCH_POS_MSB_MASK ((uint8_t)0x0F)
|
||||
#define FT5336_TOUCH_POS_MSB_SHIFT ((uint8_t)0x00)
|
||||
|
||||
/* Values Pn_XL and Pn_YL related */
|
||||
#define FT5336_TOUCH_POS_LSB_MASK ((uint8_t)0xFF)
|
||||
#define FT5336_TOUCH_POS_LSB_SHIFT ((uint8_t)0x00)
|
||||
|
||||
#define FT5336_P1_XH_REG ((uint8_t)0x03)
|
||||
#define FT5336_P1_XL_REG ((uint8_t)0x04)
|
||||
#define FT5336_P1_YH_REG ((uint8_t)0x05)
|
||||
#define FT5336_P1_YL_REG ((uint8_t)0x06)
|
||||
|
||||
/* Touch Pressure register value (R) */
|
||||
#define FT5336_P1_WEIGHT_REG ((uint8_t)0x07)
|
||||
|
||||
/* Values Pn_WEIGHT related */
|
||||
#define FT5336_TOUCH_WEIGHT_MASK ((uint8_t)0xFF)
|
||||
#define FT5336_TOUCH_WEIGHT_SHIFT ((uint8_t)0x00)
|
||||
|
||||
/* Touch area register */
|
||||
#define FT5336_P1_MISC_REG ((uint8_t)0x08)
|
||||
|
||||
/* Values related to FT5336_Pn_MISC_REG */
|
||||
#define FT5336_TOUCH_AREA_MASK ((uint8_t)(0x04 << 4))
|
||||
#define FT5336_TOUCH_AREA_SHIFT ((uint8_t)0x04)
|
||||
|
||||
#define FT5336_P2_XH_REG ((uint8_t)0x09)
|
||||
#define FT5336_P2_XL_REG ((uint8_t)0x0A)
|
||||
#define FT5336_P2_YH_REG ((uint8_t)0x0B)
|
||||
#define FT5336_P2_YL_REG ((uint8_t)0x0C)
|
||||
#define FT5336_P2_WEIGHT_REG ((uint8_t)0x0D)
|
||||
#define FT5336_P2_MISC_REG ((uint8_t)0x0E)
|
||||
|
||||
#define FT5336_P3_XH_REG ((uint8_t)0x0F)
|
||||
#define FT5336_P3_XL_REG ((uint8_t)0x10)
|
||||
#define FT5336_P3_YH_REG ((uint8_t)0x11)
|
||||
#define FT5336_P3_YL_REG ((uint8_t)0x12)
|
||||
#define FT5336_P3_WEIGHT_REG ((uint8_t)0x13)
|
||||
#define FT5336_P3_MISC_REG ((uint8_t)0x14)
|
||||
|
||||
#define FT5336_P4_XH_REG ((uint8_t)0x15)
|
||||
#define FT5336_P4_XL_REG ((uint8_t)0x16)
|
||||
#define FT5336_P4_YH_REG ((uint8_t)0x17)
|
||||
#define FT5336_P4_YL_REG ((uint8_t)0x18)
|
||||
#define FT5336_P4_WEIGHT_REG ((uint8_t)0x19)
|
||||
#define FT5336_P4_MISC_REG ((uint8_t)0x1A)
|
||||
|
||||
#define FT5336_P5_XH_REG ((uint8_t)0x1B)
|
||||
#define FT5336_P5_XL_REG ((uint8_t)0x1C)
|
||||
#define FT5336_P5_YH_REG ((uint8_t)0x1D)
|
||||
#define FT5336_P5_YL_REG ((uint8_t)0x1E)
|
||||
#define FT5336_P5_WEIGHT_REG ((uint8_t)0x1F)
|
||||
#define FT5336_P5_MISC_REG ((uint8_t)0x20)
|
||||
|
||||
#define FT5336_P6_XH_REG ((uint8_t)0x21)
|
||||
#define FT5336_P6_XL_REG ((uint8_t)0x22)
|
||||
#define FT5336_P6_YH_REG ((uint8_t)0x23)
|
||||
#define FT5336_P6_YL_REG ((uint8_t)0x24)
|
||||
#define FT5336_P6_WEIGHT_REG ((uint8_t)0x25)
|
||||
#define FT5336_P6_MISC_REG ((uint8_t)0x26)
|
||||
|
||||
#define FT5336_P7_XH_REG ((uint8_t)0x27)
|
||||
#define FT5336_P7_XL_REG ((uint8_t)0x28)
|
||||
#define FT5336_P7_YH_REG ((uint8_t)0x29)
|
||||
#define FT5336_P7_YL_REG ((uint8_t)0x2A)
|
||||
#define FT5336_P7_WEIGHT_REG ((uint8_t)0x2B)
|
||||
#define FT5336_P7_MISC_REG ((uint8_t)0x2C)
|
||||
|
||||
#define FT5336_P8_XH_REG ((uint8_t)0x2D)
|
||||
#define FT5336_P8_XL_REG ((uint8_t)0x2E)
|
||||
#define FT5336_P8_YH_REG ((uint8_t)0x2F)
|
||||
#define FT5336_P8_YL_REG ((uint8_t)0x30)
|
||||
#define FT5336_P8_WEIGHT_REG ((uint8_t)0x31)
|
||||
#define FT5336_P8_MISC_REG ((uint8_t)0x32)
|
||||
|
||||
#define FT5336_P9_XH_REG ((uint8_t)0x33)
|
||||
#define FT5336_P9_XL_REG ((uint8_t)0x34)
|
||||
#define FT5336_P9_YH_REG ((uint8_t)0x35)
|
||||
#define FT5336_P9_YL_REG ((uint8_t)0x36)
|
||||
#define FT5336_P9_WEIGHT_REG ((uint8_t)0x37)
|
||||
#define FT5336_P9_MISC_REG ((uint8_t)0x38)
|
||||
|
||||
#define FT5336_P10_XH_REG ((uint8_t)0x39)
|
||||
#define FT5336_P10_XL_REG ((uint8_t)0x3A)
|
||||
#define FT5336_P10_YH_REG ((uint8_t)0x3B)
|
||||
#define FT5336_P10_YL_REG ((uint8_t)0x3C)
|
||||
#define FT5336_P10_WEIGHT_REG ((uint8_t)0x3D)
|
||||
#define FT5336_P10_MISC_REG ((uint8_t)0x3E)
|
||||
|
||||
/* Threshold for touch detection */
|
||||
#define FT5336_TH_GROUP_REG ((uint8_t)0x80)
|
||||
|
||||
/* Values FT5336_TH_GROUP_REG : threshold related */
|
||||
#define FT5336_THRESHOLD_MASK ((uint8_t)0xFF)
|
||||
#define FT5336_THRESHOLD_SHIFT ((uint8_t)0x00)
|
||||
|
||||
/* Filter function coefficients */
|
||||
#define FT5336_TH_DIFF_REG ((uint8_t)0x85)
|
||||
|
||||
/* Control register */
|
||||
#define FT5336_CTRL_REG ((uint8_t)0x86)
|
||||
|
||||
/* Values related to FT5336_CTRL_REG */
|
||||
|
||||
/* Will keep the Active mode when there is no touching */
|
||||
#define FT5336_CTRL_KEEP_ACTIVE_MODE ((uint8_t)0x00)
|
||||
|
||||
/* Switching from Active mode to Monitor mode automatically when there is no touching */
|
||||
#define FT5336_CTRL_KEEP_AUTO_SWITCH_MONITOR_MODE ((uint8_t)0x01
|
||||
|
||||
/* The time period of switching from Active mode to Monitor mode when there is no touching */
|
||||
#define FT5336_TIMEENTERMONITOR_REG ((uint8_t)0x87)
|
||||
|
||||
/* Report rate in Active mode */
|
||||
#define FT5336_PERIODACTIVE_REG ((uint8_t)0x88)
|
||||
|
||||
/* Report rate in Monitor mode */
|
||||
#define FT5336_PERIODMONITOR_REG ((uint8_t)0x89)
|
||||
|
||||
/* The value of the minimum allowed angle while Rotating gesture mode */
|
||||
#define FT5336_RADIAN_VALUE_REG ((uint8_t)0x91)
|
||||
|
||||
/* Maximum offset while Moving Left and Moving Right gesture */
|
||||
#define FT5336_OFFSET_LEFT_RIGHT_REG ((uint8_t)0x92)
|
||||
|
||||
/* Maximum offset while Moving Up and Moving Down gesture */
|
||||
#define FT5336_OFFSET_UP_DOWN_REG ((uint8_t)0x93)
|
||||
|
||||
/* Minimum distance while Moving Left and Moving Right gesture */
|
||||
#define FT5336_DISTANCE_LEFT_RIGHT_REG ((uint8_t)0x94)
|
||||
|
||||
/* Minimum distance while Moving Up and Moving Down gesture */
|
||||
#define FT5336_DISTANCE_UP_DOWN_REG ((uint8_t)0x95)
|
||||
|
||||
/* Maximum distance while Zoom In and Zoom Out gesture */
|
||||
#define FT5336_DISTANCE_ZOOM_REG ((uint8_t)0x96)
|
||||
|
||||
/* High 8-bit of LIB Version info */
|
||||
#define FT5336_LIB_VER_H_REG ((uint8_t)0xA1)
|
||||
|
||||
/* Low 8-bit of LIB Version info */
|
||||
#define FT5336_LIB_VER_L_REG ((uint8_t)0xA2)
|
||||
|
||||
/* Chip Selecting */
|
||||
#define FT5336_CIPHER_REG ((uint8_t)0xA3)
|
||||
|
||||
/* Interrupt mode register (used when in interrupt mode) */
|
||||
#define FT5336_GMODE_REG ((uint8_t)0xA4)
|
||||
|
||||
#define FT5336_G_MODE_INTERRUPT_MASK ((uint8_t)0x03)
|
||||
#define FT5336_G_MODE_INTERRUPT_SHIFT ((uint8_t)0x00)
|
||||
|
||||
/* Possible values of FT5336_GMODE_REG */
|
||||
#define FT5336_G_MODE_INTERRUPT_POLLING ((uint8_t)0x00)
|
||||
#define FT5336_G_MODE_INTERRUPT_TRIGGER ((uint8_t)0x01)
|
||||
|
||||
/* Current power mode the FT5336 system is in (R) */
|
||||
#define FT5336_PWR_MODE_REG ((uint8_t)0xA5)
|
||||
|
||||
/* FT5336 firmware version */
|
||||
#define FT5336_FIRMID_REG ((uint8_t)0xA6)
|
||||
|
||||
/* FT5336 Chip identification register */
|
||||
#define FT5336_CHIP_ID_REG ((uint8_t)0xA8)
|
||||
|
||||
/* Possible values of FT5336_CHIP_ID_REG */
|
||||
#define FT5336_ID_VALUE ((uint8_t)0x51)
|
||||
|
||||
/* Release code version */
|
||||
#define FT5336_RELEASE_CODE_ID_REG ((uint8_t)0xAF)
|
||||
|
||||
/* Current operating mode the FT5336 system is in (R) */
|
||||
#define FT5336_STATE_REG ((uint8_t)0xBC)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
|
||||
/** @defgroup ft5336_Exported_Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
|
||||
/** @defgroup ft5336_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief ft5336 Control functions
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @brief Initialize the ft5336 communication bus
|
||||
* from MCU to FT5336 : ie I2C channel initialization (if required).
|
||||
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
|
||||
* @retval None
|
||||
*/
|
||||
void ft5336_Init(uint16_t DeviceAddr);
|
||||
|
||||
/**
|
||||
* @brief Software Reset the ft5336.
|
||||
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
|
||||
* @retval None
|
||||
*/
|
||||
void ft5336_Reset(uint16_t DeviceAddr);
|
||||
|
||||
/**
|
||||
* @brief Read the ft5336 device ID, pre initialize I2C in case of need to be
|
||||
* able to read the FT5336 device ID, and verify this is a FT5336.
|
||||
* @param DeviceAddr: I2C FT5336 Slave address.
|
||||
* @retval The Device ID (two bytes).
|
||||
*/
|
||||
uint16_t ft5336_ReadID(uint16_t DeviceAddr);
|
||||
|
||||
/**
|
||||
* @brief Configures the touch Screen IC device to start detecting touches
|
||||
* @param DeviceAddr: Device address on communication Bus (I2C slave address).
|
||||
* @retval None.
|
||||
*/
|
||||
void ft5336_TS_Start(uint16_t DeviceAddr);
|
||||
|
||||
/**
|
||||
* @brief Return if there is touches detected or not.
|
||||
* Try to detect new touches and forget the old ones (reset internal global
|
||||
* variables).
|
||||
* @param DeviceAddr: Device address on communication Bus.
|
||||
* @retval : Number of active touches detected (can be 0, 1 or 2).
|
||||
*/
|
||||
uint8_t ft5336_TS_DetectTouch(uint16_t DeviceAddr);
|
||||
|
||||
/**
|
||||
* @brief Get the touch screen X and Y positions values
|
||||
* Manage multi touch thanks to touch Index global
|
||||
* variable 'ft5336_handle.currActiveTouchIdx'.
|
||||
* @param DeviceAddr: Device address on communication Bus.
|
||||
* @param X: Pointer to X position value
|
||||
* @param Y: Pointer to Y position value
|
||||
* @retval None.
|
||||
*/
|
||||
void ft5336_TS_GetXY(uint16_t DeviceAddr, uint16_t *X, uint16_t *Y);
|
||||
|
||||
/**
|
||||
* @brief Configure the FT5336 device to generate IT on given INT pin
|
||||
* connected to MCU as EXTI.
|
||||
* @param DeviceAddr: Device address on communication Bus (Slave I2C address of FT5336).
|
||||
* @retval None
|
||||
*/
|
||||
void ft5336_TS_EnableIT(uint16_t DeviceAddr);
|
||||
|
||||
/**
|
||||
* @brief Configure the FT5336 device to stop generating IT on the given INT pin
|
||||
* connected to MCU as EXTI.
|
||||
* @param DeviceAddr: Device address on communication Bus (Slave I2C address of FT5336).
|
||||
* @retval None
|
||||
*/
|
||||
void ft5336_TS_DisableIT(uint16_t DeviceAddr);
|
||||
|
||||
/**
|
||||
* @brief Get IT status from FT5336 interrupt status registers
|
||||
* Should be called Following an EXTI coming to the MCU to know the detailed
|
||||
* reason of the interrupt.
|
||||
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
|
||||
* @retval TS interrupts status
|
||||
*/
|
||||
uint8_t ft5336_TS_ITStatus (uint16_t DeviceAddr);
|
||||
|
||||
/**
|
||||
* @brief Clear IT status in FT5336 interrupt status clear registers
|
||||
* Should be called Following an EXTI coming to the MCU.
|
||||
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
|
||||
* @retval TS interrupts status
|
||||
*/
|
||||
void ft5336_TS_ClearIT (uint16_t DeviceAddr);
|
||||
|
||||
/**** NEW FEATURES enabled when Multi-touch support is enabled ****/
|
||||
|
||||
#if (TS_MULTI_TOUCH_SUPPORTED == 1)
|
||||
|
||||
/**
|
||||
* @brief Get the last touch gesture identification (zoom, move up/down...).
|
||||
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
|
||||
* @param pGestureId : Pointer to get last touch gesture Identification.
|
||||
* @retval None.
|
||||
*/
|
||||
void ft5336_TS_GetGestureID(uint16_t DeviceAddr, uint32_t * pGestureId);
|
||||
|
||||
/**
|
||||
* @brief Get the touch detailed informations on touch number 'touchIdx' (0..1)
|
||||
* This touch detailed information contains :
|
||||
* - weight that was applied to this touch
|
||||
* - sub-area of the touch in the touch panel
|
||||
* - event of linked to the touch (press down, lift up, ...)
|
||||
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT5336).
|
||||
* @param touchIdx : Passed index of the touch (0..1) on which we want to get the
|
||||
* detailed information.
|
||||
* @param pWeight : Pointer to to get the weight information of 'touchIdx'.
|
||||
* @param pArea : Pointer to to get the sub-area information of 'touchIdx'.
|
||||
* @param pEvent : Pointer to to get the event information of 'touchIdx'.
|
||||
|
||||
* @retval None.
|
||||
*/
|
||||
void ft5336_TS_GetTouchInfo(uint16_t DeviceAddr,
|
||||
uint32_t touchIdx,
|
||||
uint32_t * pWeight,
|
||||
uint32_t * pArea,
|
||||
uint32_t * pEvent);
|
||||
|
||||
#endif /* TS_MULTI_TOUCH_SUPPORTED == 1 */
|
||||
|
||||
/* Imported TS IO functions --------------------------------------------------------*/
|
||||
|
||||
/** @defgroup ft5336_Imported_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* TouchScreen (TS) external IO functions */
|
||||
extern void TS_IO_Init(void);
|
||||
extern void TS_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value);
|
||||
extern uint8_t TS_IO_Read(uint8_t Addr, uint8_t Reg);
|
||||
extern void TS_IO_Delay(uint32_t Delay);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Imported global variables --------------------------------------------------------*/
|
||||
|
||||
/** @defgroup ft5336_Imported_Globals
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/* Touch screen driver structure */
|
||||
extern TS_DrvTypeDef ft5336_ts_drv;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* __FT5336_H */
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@@ -0,0 +1,119 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file rk043fn48h.h
|
||||
* @author MCD Application Team
|
||||
* @brief This file contains all the constants parameters for the RK043FN48H-CT672B
|
||||
* LCD component.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
|
||||
*
|
||||
* 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 STMicroelectronics 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.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __RK043FN48H_H
|
||||
#define __RK043FN48H_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup Components
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup rk043fn48h
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup RK043FN48H_Exported_Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup RK043FN48H_Exported_Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief RK043FN48H Size
|
||||
*/
|
||||
#define RK043FN48H_WIDTH ((uint16_t)480) /* LCD PIXEL WIDTH */
|
||||
#define RK043FN48H_HEIGHT ((uint16_t)272) /* LCD PIXEL HEIGHT */
|
||||
|
||||
/**
|
||||
* @brief RK043FN48H Timing
|
||||
*/
|
||||
#define RK043FN48H_HSYNC ((uint16_t)41) /* Horizontal synchronization */
|
||||
#define RK043FN48H_HBP ((uint16_t)13) /* Horizontal back porch */
|
||||
#define RK043FN48H_HFP ((uint16_t)32) /* Horizontal front porch */
|
||||
#define RK043FN48H_VSYNC ((uint16_t)10) /* Vertical synchronization */
|
||||
#define RK043FN48H_VBP ((uint16_t)2) /* Vertical back porch */
|
||||
#define RK043FN48H_VFP ((uint16_t)2) /* Vertical front porch */
|
||||
|
||||
/**
|
||||
* @brief RK043FN48H frequency divider
|
||||
*/
|
||||
#define RK043FN48H_FREQUENCY_DIVIDER 5 /* LCD Frequency divider */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup RK043FN48H_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __RK043FN48H_H */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@@ -0,0 +1,902 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32746g_discovery.c
|
||||
* @author MCD Application Team
|
||||
* @brief This file provides a set of firmware functions to manage LEDs,
|
||||
* push-buttons and COM ports available on STM32746G-Discovery
|
||||
* board(MB1191) from STMicroelectronics.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
|
||||
*
|
||||
* 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 STMicroelectronics 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.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Dependencies
|
||||
- stm32f7xx_hal_cortex.c
|
||||
- stm32f7xx_hal_gpio.c
|
||||
- stm32f7xx_hal_uart.c
|
||||
- stm32f7xx_hal_i2c.c
|
||||
EndDependencies */
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32746g_discovery.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32746G_DISCOVERY
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32746G_DISCOVERY_LOW_LEVEL STM32746G_DISCOVERY_LOW_LEVEL
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32746G_DISCOVERY_LOW_LEVEL_Private_TypesDefinitions STM32746G_DISCOVERY_LOW_LEVEL Private Types Definitions
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32746G_DISCOVERY_LOW_LEVEL_Private_Defines STM32746G_DISCOVERY_LOW_LEVEL Private Defines
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief STM32746G DISCOVERY BSP Driver version number V2.0.2
|
||||
*/
|
||||
#define __STM32746G_DISCO_BSP_VERSION_MAIN (0x02) /*!< [31:24] main version */
|
||||
#define __STM32746G_DISCO_BSP_VERSION_SUB1 (0x00) /*!< [23:16] sub1 version */
|
||||
#define __STM32746G_DISCO_BSP_VERSION_SUB2 (0x02) /*!< [15:8] sub2 version */
|
||||
#define __STM32746G_DISCO_BSP_VERSION_RC (0x00) /*!< [7:0] release candidate */
|
||||
#define __STM32746G_DISCO_BSP_VERSION ((__STM32746G_DISCO_BSP_VERSION_MAIN << 24)\
|
||||
|(__STM32746G_DISCO_BSP_VERSION_SUB1 << 16)\
|
||||
|(__STM32746G_DISCO_BSP_VERSION_SUB2 << 8 )\
|
||||
|(__STM32746G_DISCO_BSP_VERSION_RC))
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32746G_DISCOVERY_LOW_LEVEL_Private_Macros STM32746G_DISCOVERY_LOW_LEVEL Private Macros
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32746G_DISCOVERY_LOW_LEVEL_Private_Variables STM32746G_DISCOVERY_LOW_LEVEL Private Variables
|
||||
* @{
|
||||
*/
|
||||
|
||||
const uint32_t GPIO_PIN[LEDn] = {LED1_PIN};
|
||||
|
||||
GPIO_TypeDef* BUTTON_PORT[BUTTONn] = {WAKEUP_BUTTON_GPIO_PORT,
|
||||
TAMPER_BUTTON_GPIO_PORT,
|
||||
KEY_BUTTON_GPIO_PORT};
|
||||
|
||||
const uint16_t BUTTON_PIN[BUTTONn] = {WAKEUP_BUTTON_PIN,
|
||||
TAMPER_BUTTON_PIN,
|
||||
KEY_BUTTON_PIN};
|
||||
|
||||
const uint16_t BUTTON_IRQn[BUTTONn] = {WAKEUP_BUTTON_EXTI_IRQn,
|
||||
TAMPER_BUTTON_EXTI_IRQn,
|
||||
KEY_BUTTON_EXTI_IRQn};
|
||||
|
||||
USART_TypeDef* COM_USART[COMn] = {DISCOVERY_COM1};
|
||||
|
||||
GPIO_TypeDef* COM_TX_PORT[COMn] = {DISCOVERY_COM1_TX_GPIO_PORT};
|
||||
|
||||
GPIO_TypeDef* COM_RX_PORT[COMn] = {DISCOVERY_COM1_RX_GPIO_PORT};
|
||||
|
||||
const uint16_t COM_TX_PIN[COMn] = {DISCOVERY_COM1_TX_PIN};
|
||||
|
||||
const uint16_t COM_RX_PIN[COMn] = {DISCOVERY_COM1_RX_PIN};
|
||||
|
||||
const uint16_t COM_TX_AF[COMn] = {DISCOVERY_COM1_TX_AF};
|
||||
|
||||
const uint16_t COM_RX_AF[COMn] = {DISCOVERY_COM1_RX_AF};
|
||||
|
||||
static I2C_HandleTypeDef hI2cAudioHandler = {0};
|
||||
static I2C_HandleTypeDef hI2cExtHandler = {0};
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32746G_DISCOVERY_LOW_LEVEL_Private_FunctionPrototypes STM32746G_DISCOVERY_LOW_LEVEL Private Function Prototypes
|
||||
* @{
|
||||
*/
|
||||
static void I2Cx_MspInit(I2C_HandleTypeDef *i2c_handler);
|
||||
static void I2Cx_Init(I2C_HandleTypeDef *i2c_handler);
|
||||
|
||||
static HAL_StatusTypeDef I2Cx_ReadMultiple(I2C_HandleTypeDef *i2c_handler, uint8_t Addr, uint16_t Reg, uint16_t MemAddSize, uint8_t *Buffer, uint16_t Length);
|
||||
static HAL_StatusTypeDef I2Cx_WriteMultiple(I2C_HandleTypeDef *i2c_handler, uint8_t Addr, uint16_t Reg, uint16_t MemAddSize, uint8_t *Buffer, uint16_t Length);
|
||||
static HAL_StatusTypeDef I2Cx_IsDeviceReady(I2C_HandleTypeDef *i2c_handler, uint16_t DevAddress, uint32_t Trials);
|
||||
static void I2Cx_Error(I2C_HandleTypeDef *i2c_handler, uint8_t Addr);
|
||||
|
||||
/* AUDIO IO functions */
|
||||
void AUDIO_IO_Init(void);
|
||||
void AUDIO_IO_DeInit(void);
|
||||
void AUDIO_IO_Write(uint8_t Addr, uint16_t Reg, uint16_t Value);
|
||||
uint16_t AUDIO_IO_Read(uint8_t Addr, uint16_t Reg);
|
||||
void AUDIO_IO_Delay(uint32_t Delay);
|
||||
|
||||
/* TOUCHSCREEN IO functions */
|
||||
void TS_IO_Init(void);
|
||||
void TS_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value);
|
||||
uint8_t TS_IO_Read(uint8_t Addr, uint8_t Reg);
|
||||
void TS_IO_Delay(uint32_t Delay);
|
||||
|
||||
/* CAMERA IO functions */
|
||||
void CAMERA_IO_Init(void);
|
||||
void CAMERA_Delay(uint32_t Delay);
|
||||
void CAMERA_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value);
|
||||
uint8_t CAMERA_IO_Read(uint8_t Addr, uint8_t Reg);
|
||||
|
||||
/* I2C EEPROM IO function */
|
||||
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);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32746G_DISCOVERY_LOW_LEVEL_Exported_Functions STM32746G_DISCOVERY_LOW_LEVELSTM32746G_DISCOVERY_LOW_LEVEL Exported Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief This method returns the STM32746G DISCOVERY BSP Driver revision
|
||||
* @retval version: 0xXYZR (8bits for each decimal, R for RC)
|
||||
*/
|
||||
uint32_t BSP_GetVersion(void)
|
||||
{
|
||||
return __STM32746G_DISCO_BSP_VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configures LED on GPIO.
|
||||
* @param Led: LED to be configured.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg LED1
|
||||
* @retval None
|
||||
*/
|
||||
void BSP_LED_Init(Led_TypeDef Led)
|
||||
{
|
||||
GPIO_InitTypeDef gpio_init_structure;
|
||||
GPIO_TypeDef* gpio_led;
|
||||
|
||||
if (Led == LED1)
|
||||
{
|
||||
gpio_led = LED1_GPIO_PORT;
|
||||
/* Enable the GPIO_LED clock */
|
||||
LED1_GPIO_CLK_ENABLE();
|
||||
|
||||
/* Configure the GPIO_LED pin */
|
||||
gpio_init_structure.Pin = GPIO_PIN[Led];
|
||||
gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
gpio_init_structure.Pull = GPIO_PULLUP;
|
||||
gpio_init_structure.Speed = GPIO_SPEED_HIGH;
|
||||
|
||||
HAL_GPIO_Init(gpio_led, &gpio_init_structure);
|
||||
|
||||
/* By default, turn off LED */
|
||||
HAL_GPIO_WritePin(gpio_led, GPIO_PIN[Led], GPIO_PIN_RESET);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DeInit LEDs.
|
||||
* @param Led: LED to be configured.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg LED1
|
||||
* @note Led DeInit does not disable the GPIO clock
|
||||
* @retval None
|
||||
*/
|
||||
void BSP_LED_DeInit(Led_TypeDef Led)
|
||||
{
|
||||
GPIO_InitTypeDef gpio_init_structure;
|
||||
GPIO_TypeDef* gpio_led;
|
||||
|
||||
if (Led == LED1)
|
||||
{
|
||||
gpio_led = LED1_GPIO_PORT;
|
||||
/* Turn off LED */
|
||||
HAL_GPIO_WritePin(gpio_led, GPIO_PIN[Led], GPIO_PIN_RESET);
|
||||
/* Configure the GPIO_LED pin */
|
||||
gpio_init_structure.Pin = GPIO_PIN[Led];
|
||||
HAL_GPIO_DeInit(gpio_led, gpio_init_structure.Pin);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Turns selected LED On.
|
||||
* @param Led: LED to be set on
|
||||
* This parameter can be one of the following values:
|
||||
* @arg LED1
|
||||
* @retval None
|
||||
*/
|
||||
void BSP_LED_On(Led_TypeDef Led)
|
||||
{
|
||||
GPIO_TypeDef* gpio_led;
|
||||
|
||||
if (Led == LED1) /* Switch On LED connected to GPIO */
|
||||
{
|
||||
gpio_led = LED1_GPIO_PORT;
|
||||
HAL_GPIO_WritePin(gpio_led, GPIO_PIN[Led], GPIO_PIN_SET);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Turns selected LED Off.
|
||||
* @param Led: LED to be set off
|
||||
* This parameter can be one of the following values:
|
||||
* @arg LED1
|
||||
* @retval None
|
||||
*/
|
||||
void BSP_LED_Off(Led_TypeDef Led)
|
||||
{
|
||||
GPIO_TypeDef* gpio_led;
|
||||
|
||||
if (Led == LED1) /* Switch Off LED connected to GPIO */
|
||||
{
|
||||
gpio_led = LED1_GPIO_PORT;
|
||||
HAL_GPIO_WritePin(gpio_led, GPIO_PIN[Led], GPIO_PIN_RESET);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Toggles the selected LED.
|
||||
* @param Led: LED to be toggled
|
||||
* This parameter can be one of the following values:
|
||||
* @arg LED1
|
||||
* @retval None
|
||||
*/
|
||||
void BSP_LED_Toggle(Led_TypeDef Led)
|
||||
{
|
||||
GPIO_TypeDef* gpio_led;
|
||||
|
||||
if (Led == LED1) /* Toggle LED connected to GPIO */
|
||||
{
|
||||
gpio_led = LED1_GPIO_PORT;
|
||||
HAL_GPIO_TogglePin(gpio_led, GPIO_PIN[Led]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configures button GPIO and EXTI Line.
|
||||
* @param Button: Button to be configured
|
||||
* This parameter can be one of the following values:
|
||||
* @arg BUTTON_WAKEUP: Wakeup Push Button
|
||||
* @arg BUTTON_TAMPER: Tamper Push Button
|
||||
* @arg BUTTON_KEY: Key Push Button
|
||||
* @param ButtonMode: Button mode
|
||||
* This parameter can be one of the following values:
|
||||
* @arg BUTTON_MODE_GPIO: Button will be used as simple IO
|
||||
* @arg BUTTON_MODE_EXTI: Button will be connected to EXTI line
|
||||
* with interrupt generation capability
|
||||
* @note On STM32746G-Discovery board, the three buttons (Wakeup, Tamper and key buttons)
|
||||
* are mapped on the same push button named "User"
|
||||
* on the board serigraphy.
|
||||
* @retval None
|
||||
*/
|
||||
void BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef ButtonMode)
|
||||
{
|
||||
GPIO_InitTypeDef gpio_init_structure;
|
||||
|
||||
/* Enable the BUTTON clock */
|
||||
BUTTONx_GPIO_CLK_ENABLE(Button);
|
||||
|
||||
if(ButtonMode == BUTTON_MODE_GPIO)
|
||||
{
|
||||
/* Configure Button pin as input */
|
||||
gpio_init_structure.Pin = BUTTON_PIN[Button];
|
||||
gpio_init_structure.Mode = GPIO_MODE_INPUT;
|
||||
gpio_init_structure.Pull = GPIO_NOPULL;
|
||||
gpio_init_structure.Speed = GPIO_SPEED_FAST;
|
||||
HAL_GPIO_Init(BUTTON_PORT[Button], &gpio_init_structure);
|
||||
}
|
||||
|
||||
if(ButtonMode == BUTTON_MODE_EXTI)
|
||||
{
|
||||
/* Configure Button pin as input with External interrupt */
|
||||
gpio_init_structure.Pin = BUTTON_PIN[Button];
|
||||
gpio_init_structure.Pull = GPIO_NOPULL;
|
||||
gpio_init_structure.Speed = GPIO_SPEED_FAST;
|
||||
|
||||
if(Button != BUTTON_WAKEUP)
|
||||
{
|
||||
gpio_init_structure.Mode = GPIO_MODE_IT_FALLING;
|
||||
}
|
||||
else
|
||||
{
|
||||
gpio_init_structure.Mode = GPIO_MODE_IT_RISING;
|
||||
}
|
||||
|
||||
HAL_GPIO_Init(BUTTON_PORT[Button], &gpio_init_structure);
|
||||
|
||||
/* Enable and set Button EXTI Interrupt to the lowest priority */
|
||||
HAL_NVIC_SetPriority((IRQn_Type)(BUTTON_IRQn[Button]), 0x0F, 0x00);
|
||||
HAL_NVIC_EnableIRQ((IRQn_Type)(BUTTON_IRQn[Button]));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Push Button DeInit.
|
||||
* @param Button: Button to be configured
|
||||
* This parameter can be one of the following values:
|
||||
* @arg BUTTON_WAKEUP: Wakeup Push Button
|
||||
* @arg BUTTON_TAMPER: Tamper Push Button
|
||||
* @arg BUTTON_KEY: Key Push Button
|
||||
* @note On STM32746G-Discovery board, the three buttons (Wakeup, Tamper and key buttons)
|
||||
* are mapped on the same push button named "User"
|
||||
* on the board serigraphy.
|
||||
* @note PB DeInit does not disable the GPIO clock
|
||||
* @retval None
|
||||
*/
|
||||
void BSP_PB_DeInit(Button_TypeDef Button)
|
||||
{
|
||||
GPIO_InitTypeDef gpio_init_structure;
|
||||
|
||||
gpio_init_structure.Pin = BUTTON_PIN[Button];
|
||||
HAL_NVIC_DisableIRQ((IRQn_Type)(BUTTON_IRQn[Button]));
|
||||
HAL_GPIO_DeInit(BUTTON_PORT[Button], gpio_init_structure.Pin);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Returns the selected button state.
|
||||
* @param Button: Button to be checked
|
||||
* This parameter can be one of the following values:
|
||||
* @arg BUTTON_WAKEUP: Wakeup Push Button
|
||||
* @arg BUTTON_TAMPER: Tamper Push Button
|
||||
* @arg BUTTON_KEY: Key Push Button
|
||||
* @note On STM32746G-Discovery board, the three buttons (Wakeup, Tamper and key buttons)
|
||||
* are mapped on the same push button named "User"
|
||||
* on the board serigraphy.
|
||||
* @retval The Button GPIO pin value
|
||||
*/
|
||||
uint32_t BSP_PB_GetState(Button_TypeDef Button)
|
||||
{
|
||||
return HAL_GPIO_ReadPin(BUTTON_PORT[Button], BUTTON_PIN[Button]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configures COM port.
|
||||
* @param COM: COM port to be configured.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg COM1
|
||||
* @arg COM2
|
||||
* @param huart: Pointer to a UART_HandleTypeDef structure that contains the
|
||||
* configuration information for the specified USART peripheral.
|
||||
* @retval None
|
||||
*/
|
||||
void BSP_COM_Init(COM_TypeDef COM, UART_HandleTypeDef *huart)
|
||||
{
|
||||
GPIO_InitTypeDef gpio_init_structure;
|
||||
|
||||
/* Enable GPIO clock */
|
||||
DISCOVERY_COMx_TX_GPIO_CLK_ENABLE(COM);
|
||||
DISCOVERY_COMx_RX_GPIO_CLK_ENABLE(COM);
|
||||
|
||||
/* Enable USART clock */
|
||||
DISCOVERY_COMx_CLK_ENABLE(COM);
|
||||
|
||||
/* Configure USART Tx as alternate function */
|
||||
gpio_init_structure.Pin = COM_TX_PIN[COM];
|
||||
gpio_init_structure.Mode = GPIO_MODE_AF_PP;
|
||||
gpio_init_structure.Speed = GPIO_SPEED_FAST;
|
||||
gpio_init_structure.Pull = GPIO_PULLUP;
|
||||
gpio_init_structure.Alternate = COM_TX_AF[COM];
|
||||
HAL_GPIO_Init(COM_TX_PORT[COM], &gpio_init_structure);
|
||||
|
||||
/* Configure USART Rx as alternate function */
|
||||
gpio_init_structure.Pin = COM_RX_PIN[COM];
|
||||
gpio_init_structure.Mode = GPIO_MODE_AF_PP;
|
||||
gpio_init_structure.Alternate = COM_RX_AF[COM];
|
||||
HAL_GPIO_Init(COM_RX_PORT[COM], &gpio_init_structure);
|
||||
|
||||
/* USART configuration */
|
||||
huart->Instance = COM_USART[COM];
|
||||
HAL_UART_Init(huart);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DeInit COM port.
|
||||
* @param COM: COM port to be configured.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg COM1
|
||||
* @arg COM2
|
||||
* @param huart: Pointer to a UART_HandleTypeDef structure that contains the
|
||||
* configuration information for the specified USART peripheral.
|
||||
* @retval None
|
||||
*/
|
||||
void BSP_COM_DeInit(COM_TypeDef COM, UART_HandleTypeDef *huart)
|
||||
{
|
||||
/* USART configuration */
|
||||
huart->Instance = COM_USART[COM];
|
||||
HAL_UART_DeInit(huart);
|
||||
|
||||
/* Enable USART clock */
|
||||
DISCOVERY_COMx_CLK_DISABLE(COM);
|
||||
|
||||
/* DeInit GPIO pins can be done in the application
|
||||
(by surcharging this __weak function) */
|
||||
|
||||
/* GPIO pins clock, DMA clock can be shut down in the application
|
||||
by surcharging this __weak function */
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
BUS OPERATIONS
|
||||
*******************************************************************************/
|
||||
|
||||
/******************************* I2C Routines *********************************/
|
||||
/**
|
||||
* @brief Initializes I2C MSP.
|
||||
* @param i2c_handler : I2C handler
|
||||
* @retval None
|
||||
*/
|
||||
static void I2Cx_MspInit(I2C_HandleTypeDef *i2c_handler)
|
||||
{
|
||||
GPIO_InitTypeDef gpio_init_structure;
|
||||
|
||||
if (i2c_handler == (I2C_HandleTypeDef*)(&hI2cAudioHandler))
|
||||
{
|
||||
/* AUDIO and LCD I2C MSP init */
|
||||
|
||||
/*** Configure the GPIOs ***/
|
||||
/* Enable GPIO clock */
|
||||
DISCOVERY_AUDIO_I2Cx_SCL_SDA_GPIO_CLK_ENABLE();
|
||||
|
||||
/* Configure I2C Tx as alternate function */
|
||||
gpio_init_structure.Pin = DISCOVERY_AUDIO_I2Cx_SCL_PIN;
|
||||
gpio_init_structure.Mode = GPIO_MODE_AF_OD;
|
||||
gpio_init_structure.Pull = GPIO_NOPULL;
|
||||
gpio_init_structure.Speed = GPIO_SPEED_FAST;
|
||||
gpio_init_structure.Alternate = DISCOVERY_AUDIO_I2Cx_SCL_SDA_AF;
|
||||
HAL_GPIO_Init(DISCOVERY_AUDIO_I2Cx_SCL_SDA_GPIO_PORT, &gpio_init_structure);
|
||||
|
||||
/* Configure I2C Rx as alternate function */
|
||||
gpio_init_structure.Pin = DISCOVERY_AUDIO_I2Cx_SDA_PIN;
|
||||
HAL_GPIO_Init(DISCOVERY_AUDIO_I2Cx_SCL_SDA_GPIO_PORT, &gpio_init_structure);
|
||||
|
||||
/*** Configure the I2C peripheral ***/
|
||||
/* Enable I2C clock */
|
||||
DISCOVERY_AUDIO_I2Cx_CLK_ENABLE();
|
||||
|
||||
/* Force the I2C peripheral clock reset */
|
||||
DISCOVERY_AUDIO_I2Cx_FORCE_RESET();
|
||||
|
||||
/* Release the I2C peripheral clock reset */
|
||||
DISCOVERY_AUDIO_I2Cx_RELEASE_RESET();
|
||||
|
||||
/* Enable and set I2Cx Interrupt to a lower priority */
|
||||
HAL_NVIC_SetPriority(DISCOVERY_AUDIO_I2Cx_EV_IRQn, 0x0F, 0);
|
||||
HAL_NVIC_EnableIRQ(DISCOVERY_AUDIO_I2Cx_EV_IRQn);
|
||||
|
||||
/* Enable and set I2Cx Interrupt to a lower priority */
|
||||
HAL_NVIC_SetPriority(DISCOVERY_AUDIO_I2Cx_ER_IRQn, 0x0F, 0);
|
||||
HAL_NVIC_EnableIRQ(DISCOVERY_AUDIO_I2Cx_ER_IRQn);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* External, camera and Arduino connector I2C MSP init */
|
||||
|
||||
/*** Configure the GPIOs ***/
|
||||
/* Enable GPIO clock */
|
||||
DISCOVERY_EXT_I2Cx_SCL_SDA_GPIO_CLK_ENABLE();
|
||||
|
||||
/* Configure I2C Tx as alternate function */
|
||||
gpio_init_structure.Pin = DISCOVERY_EXT_I2Cx_SCL_PIN;
|
||||
gpio_init_structure.Mode = GPIO_MODE_AF_OD;
|
||||
gpio_init_structure.Pull = GPIO_NOPULL;
|
||||
gpio_init_structure.Speed = GPIO_SPEED_FAST;
|
||||
gpio_init_structure.Alternate = DISCOVERY_EXT_I2Cx_SCL_SDA_AF;
|
||||
HAL_GPIO_Init(DISCOVERY_EXT_I2Cx_SCL_SDA_GPIO_PORT, &gpio_init_structure);
|
||||
|
||||
/* Configure I2C Rx as alternate function */
|
||||
gpio_init_structure.Pin = DISCOVERY_EXT_I2Cx_SDA_PIN;
|
||||
HAL_GPIO_Init(DISCOVERY_EXT_I2Cx_SCL_SDA_GPIO_PORT, &gpio_init_structure);
|
||||
|
||||
/*** Configure the I2C peripheral ***/
|
||||
/* Enable I2C clock */
|
||||
DISCOVERY_EXT_I2Cx_CLK_ENABLE();
|
||||
|
||||
/* Force the I2C peripheral clock reset */
|
||||
DISCOVERY_EXT_I2Cx_FORCE_RESET();
|
||||
|
||||
/* Release the I2C peripheral clock reset */
|
||||
DISCOVERY_EXT_I2Cx_RELEASE_RESET();
|
||||
|
||||
/* Enable and set I2Cx Interrupt to a lower priority */
|
||||
HAL_NVIC_SetPriority(DISCOVERY_EXT_I2Cx_EV_IRQn, 0x0F, 0);
|
||||
HAL_NVIC_EnableIRQ(DISCOVERY_EXT_I2Cx_EV_IRQn);
|
||||
|
||||
/* Enable and set I2Cx Interrupt to a lower priority */
|
||||
HAL_NVIC_SetPriority(DISCOVERY_EXT_I2Cx_ER_IRQn, 0x0F, 0);
|
||||
HAL_NVIC_EnableIRQ(DISCOVERY_EXT_I2Cx_ER_IRQn);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initializes I2C HAL.
|
||||
* @param i2c_handler : I2C handler
|
||||
* @retval None
|
||||
*/
|
||||
static void I2Cx_Init(I2C_HandleTypeDef *i2c_handler)
|
||||
{
|
||||
if(HAL_I2C_GetState(i2c_handler) == HAL_I2C_STATE_RESET)
|
||||
{
|
||||
if (i2c_handler == (I2C_HandleTypeDef*)(&hI2cAudioHandler))
|
||||
{
|
||||
/* Audio and LCD I2C configuration */
|
||||
i2c_handler->Instance = DISCOVERY_AUDIO_I2Cx;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* External, camera and Arduino connector I2C configuration */
|
||||
i2c_handler->Instance = DISCOVERY_EXT_I2Cx;
|
||||
}
|
||||
i2c_handler->Init.Timing = DISCOVERY_I2Cx_TIMING;
|
||||
i2c_handler->Init.OwnAddress1 = 0;
|
||||
i2c_handler->Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
|
||||
i2c_handler->Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
|
||||
i2c_handler->Init.OwnAddress2 = 0;
|
||||
i2c_handler->Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
|
||||
i2c_handler->Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
|
||||
|
||||
/* Init the I2C */
|
||||
I2Cx_MspInit(i2c_handler);
|
||||
HAL_I2C_Init(i2c_handler);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reads multiple data.
|
||||
* @param i2c_handler : I2C handler
|
||||
* @param Addr: I2C address
|
||||
* @param Reg: Reg address
|
||||
* @param MemAddress: Memory address
|
||||
* @param Buffer: Pointer to data buffer
|
||||
* @param Length: Length of the data
|
||||
* @retval Number of read data
|
||||
*/
|
||||
static HAL_StatusTypeDef I2Cx_ReadMultiple(I2C_HandleTypeDef *i2c_handler,
|
||||
uint8_t Addr,
|
||||
uint16_t Reg,
|
||||
uint16_t MemAddress,
|
||||
uint8_t *Buffer,
|
||||
uint16_t Length)
|
||||
{
|
||||
HAL_StatusTypeDef status = HAL_OK;
|
||||
|
||||
status = HAL_I2C_Mem_Read(i2c_handler, Addr, (uint16_t)Reg, MemAddress, Buffer, Length, 1000);
|
||||
|
||||
/* Check the communication status */
|
||||
if(status != HAL_OK)
|
||||
{
|
||||
/* I2C error occurred */
|
||||
I2Cx_Error(i2c_handler, Addr);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Writes a value in a register of the device through BUS in using DMA mode.
|
||||
* @param i2c_handler : I2C handler
|
||||
* @param Addr: Device address on BUS Bus.
|
||||
* @param Reg: The target register address to write
|
||||
* @param MemAddress: Memory address
|
||||
* @param Buffer: The target register value to be written
|
||||
* @param Length: buffer size to be written
|
||||
* @retval HAL status
|
||||
*/
|
||||
static HAL_StatusTypeDef I2Cx_WriteMultiple(I2C_HandleTypeDef *i2c_handler,
|
||||
uint8_t Addr,
|
||||
uint16_t Reg,
|
||||
uint16_t MemAddress,
|
||||
uint8_t *Buffer,
|
||||
uint16_t Length)
|
||||
{
|
||||
HAL_StatusTypeDef status = HAL_OK;
|
||||
|
||||
status = HAL_I2C_Mem_Write(i2c_handler, Addr, (uint16_t)Reg, MemAddress, Buffer, Length, 1000);
|
||||
|
||||
/* Check the communication status */
|
||||
if(status != HAL_OK)
|
||||
{
|
||||
/* Re-Initiaize the I2C Bus */
|
||||
I2Cx_Error(i2c_handler, Addr);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Checks if target device is ready for communication.
|
||||
* @note This function is used with Memory devices
|
||||
* @param i2c_handler : I2C handler
|
||||
* @param DevAddress: Target device address
|
||||
* @param Trials: Number of trials
|
||||
* @retval HAL status
|
||||
*/
|
||||
static HAL_StatusTypeDef I2Cx_IsDeviceReady(I2C_HandleTypeDef *i2c_handler, uint16_t DevAddress, uint32_t Trials)
|
||||
{
|
||||
return (HAL_I2C_IsDeviceReady(i2c_handler, DevAddress, Trials, 1000));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Manages error callback by re-initializing I2C.
|
||||
* @param i2c_handler : I2C handler
|
||||
* @param Addr: I2C Address
|
||||
* @retval None
|
||||
*/
|
||||
static void I2Cx_Error(I2C_HandleTypeDef *i2c_handler, uint8_t Addr)
|
||||
{
|
||||
/* De-initialize the I2C communication bus */
|
||||
HAL_I2C_DeInit(i2c_handler);
|
||||
|
||||
/* Re-Initialize the I2C communication bus */
|
||||
I2Cx_Init(i2c_handler);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
LINK OPERATIONS
|
||||
*******************************************************************************/
|
||||
|
||||
/********************************* LINK AUDIO *********************************/
|
||||
|
||||
/**
|
||||
* @brief Initializes Audio low level.
|
||||
* @retval None
|
||||
*/
|
||||
void AUDIO_IO_Init(void)
|
||||
{
|
||||
I2Cx_Init(&hI2cAudioHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Deinitializes Audio low level.
|
||||
* @retval None
|
||||
*/
|
||||
void AUDIO_IO_DeInit(void)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Writes a single data.
|
||||
* @param Addr: I2C address
|
||||
* @param Reg: Reg address
|
||||
* @param Value: Data to be written
|
||||
* @retval None
|
||||
*/
|
||||
void AUDIO_IO_Write(uint8_t Addr, uint16_t Reg, uint16_t Value)
|
||||
{
|
||||
uint16_t tmp = Value;
|
||||
|
||||
Value = ((uint16_t)(tmp >> 8) & 0x00FF);
|
||||
|
||||
Value |= ((uint16_t)(tmp << 8)& 0xFF00);
|
||||
|
||||
I2Cx_WriteMultiple(&hI2cAudioHandler, Addr, Reg, I2C_MEMADD_SIZE_16BIT,(uint8_t*)&Value, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reads a single data.
|
||||
* @param Addr: I2C address
|
||||
* @param Reg: Reg address
|
||||
* @retval Data to be read
|
||||
*/
|
||||
uint16_t AUDIO_IO_Read(uint8_t Addr, uint16_t Reg)
|
||||
{
|
||||
uint16_t read_value = 0, tmp = 0;
|
||||
|
||||
I2Cx_ReadMultiple(&hI2cAudioHandler, Addr, Reg, I2C_MEMADD_SIZE_16BIT, (uint8_t*)&read_value, 2);
|
||||
|
||||
tmp = ((uint16_t)(read_value >> 8) & 0x00FF);
|
||||
|
||||
tmp |= ((uint16_t)(read_value << 8)& 0xFF00);
|
||||
|
||||
read_value = tmp;
|
||||
|
||||
return read_value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief AUDIO Codec delay
|
||||
* @param Delay: Delay in ms
|
||||
* @retval None
|
||||
*/
|
||||
void AUDIO_IO_Delay(uint32_t Delay)
|
||||
{
|
||||
HAL_Delay(Delay);
|
||||
}
|
||||
|
||||
/********************************* LINK CAMERA ********************************/
|
||||
|
||||
/**
|
||||
* @brief Initializes Camera low level.
|
||||
* @retval None
|
||||
*/
|
||||
void CAMERA_IO_Init(void)
|
||||
{
|
||||
I2Cx_Init(&hI2cExtHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Camera writes single data.
|
||||
* @param Addr: I2C address
|
||||
* @param Reg: Register address
|
||||
* @param Value: Data to be written
|
||||
* @retval None
|
||||
*/
|
||||
void CAMERA_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value)
|
||||
{
|
||||
I2Cx_WriteMultiple(&hI2cExtHandler, Addr, (uint16_t)Reg, I2C_MEMADD_SIZE_8BIT,(uint8_t*)&Value, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Camera reads single data.
|
||||
* @param Addr: I2C address
|
||||
* @param Reg: Register address
|
||||
* @retval Read data
|
||||
*/
|
||||
uint8_t CAMERA_IO_Read(uint8_t Addr, uint8_t Reg)
|
||||
{
|
||||
uint8_t read_value = 0;
|
||||
|
||||
I2Cx_ReadMultiple(&hI2cExtHandler, Addr, Reg, I2C_MEMADD_SIZE_8BIT, (uint8_t*)&read_value, 1);
|
||||
|
||||
return read_value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Camera delay
|
||||
* @param Delay: Delay in ms
|
||||
* @retval None
|
||||
*/
|
||||
void CAMERA_Delay(uint32_t Delay)
|
||||
{
|
||||
HAL_Delay(Delay);
|
||||
}
|
||||
|
||||
/******************************** LINK I2C EEPROM *****************************/
|
||||
|
||||
/**
|
||||
* @brief Initializes peripherals used by the I2C EEPROM driver.
|
||||
* @retval None
|
||||
*/
|
||||
void EEPROM_IO_Init(void)
|
||||
{
|
||||
I2Cx_Init(&hI2cExtHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Write data to I2C EEPROM driver in using DMA channel.
|
||||
* @param DevAddress: Target device address
|
||||
* @param MemAddress: Internal memory address
|
||||
* @param pBuffer: Pointer to data buffer
|
||||
* @param BufferSize: Amount of data to be sent
|
||||
* @retval HAL status
|
||||
*/
|
||||
HAL_StatusTypeDef EEPROM_IO_WriteData(uint16_t DevAddress, uint16_t MemAddress, uint8_t* pBuffer, uint32_t BufferSize)
|
||||
{
|
||||
return (I2Cx_WriteMultiple(&hI2cExtHandler, DevAddress, MemAddress, I2C_MEMADD_SIZE_16BIT, pBuffer, BufferSize));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read data from I2C EEPROM driver in using DMA channel.
|
||||
* @param DevAddress: Target device address
|
||||
* @param MemAddress: Internal memory address
|
||||
* @param pBuffer: Pointer to data buffer
|
||||
* @param BufferSize: Amount of data to be read
|
||||
* @retval HAL status
|
||||
*/
|
||||
HAL_StatusTypeDef EEPROM_IO_ReadData(uint16_t DevAddress, uint16_t MemAddress, uint8_t* pBuffer, uint32_t BufferSize)
|
||||
{
|
||||
return (I2Cx_ReadMultiple(&hI2cExtHandler, DevAddress, MemAddress, I2C_MEMADD_SIZE_16BIT, pBuffer, BufferSize));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Checks if target device is ready for communication.
|
||||
* @note This function is used with Memory devices
|
||||
* @param DevAddress: Target device address
|
||||
* @param Trials: Number of trials
|
||||
* @retval HAL status
|
||||
*/
|
||||
HAL_StatusTypeDef EEPROM_IO_IsDeviceReady(uint16_t DevAddress, uint32_t Trials)
|
||||
{
|
||||
return (I2Cx_IsDeviceReady(&hI2cExtHandler, DevAddress, Trials));
|
||||
}
|
||||
|
||||
/********************************* LINK TOUCHSCREEN *********************************/
|
||||
|
||||
/**
|
||||
* @brief Initializes Touchscreen low level.
|
||||
* @retval None
|
||||
*/
|
||||
void TS_IO_Init(void)
|
||||
{
|
||||
I2Cx_Init(&hI2cAudioHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Writes a single data.
|
||||
* @param Addr: I2C address
|
||||
* @param Reg: Reg address
|
||||
* @param Value: Data to be written
|
||||
* @retval None
|
||||
*/
|
||||
void TS_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value)
|
||||
{
|
||||
I2Cx_WriteMultiple(&hI2cAudioHandler, Addr, (uint16_t)Reg, I2C_MEMADD_SIZE_8BIT,(uint8_t*)&Value, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reads a single data.
|
||||
* @param Addr: I2C address
|
||||
* @param Reg: Reg address
|
||||
* @retval Data to be read
|
||||
*/
|
||||
uint8_t TS_IO_Read(uint8_t Addr, uint8_t Reg)
|
||||
{
|
||||
uint8_t read_value = 0;
|
||||
|
||||
I2Cx_ReadMultiple(&hI2cAudioHandler, Addr, Reg, I2C_MEMADD_SIZE_8BIT, (uint8_t*)&read_value, 1);
|
||||
|
||||
return read_value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TS delay
|
||||
* @param Delay: Delay in ms
|
||||
* @retval None
|
||||
*/
|
||||
void TS_IO_Delay(uint32_t Delay)
|
||||
{
|
||||
HAL_Delay(Delay);
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@@ -0,0 +1,339 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32746g_discovery.h
|
||||
* @author MCD Application Team
|
||||
* @brief This file contains definitions for STM32746G_DISCOVERY's LEDs,
|
||||
* push-buttons and COM ports hardware resources.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
|
||||
*
|
||||
* 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 STMicroelectronics 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.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __STM32746G_DISCOVERY_H
|
||||
#define __STM32746G_DISCOVERY_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32f7xx_hal.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32746G_DISCOVERY
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32746G_DISCOVERY_LOW_LEVEL
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32746G_DISCOVERY_LOW_LEVEL_Exported_Types STM32746G_DISCOVERY_LOW_LEVEL Exported Types
|
||||
* @{
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
LED1 = 0,
|
||||
LED_GREEN = LED1,
|
||||
}Led_TypeDef;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
BUTTON_WAKEUP = 0,
|
||||
BUTTON_TAMPER = 1,
|
||||
BUTTON_KEY = 2
|
||||
}Button_TypeDef;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
BUTTON_MODE_GPIO = 0,
|
||||
BUTTON_MODE_EXTI = 1
|
||||
}ButtonMode_TypeDef;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
COM1 = 0,
|
||||
COM2 = 1
|
||||
}COM_TypeDef;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32746G_DISCOVERY_LOW_LEVEL_Exported_Constants STM32746G_DISCOVERY_LOW_LEVEL Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Define for STM32746G_DISCOVERY board
|
||||
*/
|
||||
#if !defined (USE_STM32746G_DISCO)
|
||||
#define USE_STM32746G_DISCO
|
||||
#endif
|
||||
|
||||
/** @addtogroup STM32746G_DISCOVERY_LOW_LEVEL_LED
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define LEDn ((uint8_t)1)
|
||||
|
||||
#define LED1_GPIO_PORT GPIOI
|
||||
#define LED1_GPIO_CLK_ENABLE() __HAL_RCC_GPIOI_CLK_ENABLE()
|
||||
#define LED1_GPIO_CLK_DISABLE() __HAL_RCC_GPIOI_CLK_DISABLE()
|
||||
#define LED1_PIN GPIO_PIN_1
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32746G_DISCOVERY_LOW_LEVEL_BUTTON
|
||||
* @{
|
||||
*/
|
||||
#define BUTTONn ((uint8_t)3)
|
||||
|
||||
/**
|
||||
* @brief Wakeup push-button
|
||||
*/
|
||||
#define WAKEUP_BUTTON_PIN GPIO_PIN_11
|
||||
#define WAKEUP_BUTTON_GPIO_PORT GPIOI
|
||||
#define WAKEUP_BUTTON_GPIO_CLK_ENABLE() __HAL_RCC_GPIOI_CLK_ENABLE()
|
||||
#define WAKEUP_BUTTON_GPIO_CLK_DISABLE() __HAL_RCC_GPIOI_CLK_DISABLE()
|
||||
#define WAKEUP_BUTTON_EXTI_IRQn EXTI15_10_IRQn
|
||||
|
||||
/**
|
||||
* @brief Tamper push-button
|
||||
*/
|
||||
#define TAMPER_BUTTON_PIN GPIO_PIN_11
|
||||
#define TAMPER_BUTTON_GPIO_PORT GPIOI
|
||||
#define TAMPER_BUTTON_GPIO_CLK_ENABLE() __HAL_RCC_GPIOI_CLK_ENABLE()
|
||||
#define TAMPER_BUTTON_GPIO_CLK_DISABLE() __HAL_RCC_GPIOI_CLK_DISABLE()
|
||||
#define TAMPER_BUTTON_EXTI_IRQn EXTI15_10_IRQn
|
||||
|
||||
/**
|
||||
* @brief Key push-button
|
||||
*/
|
||||
#define KEY_BUTTON_PIN GPIO_PIN_11
|
||||
#define KEY_BUTTON_GPIO_PORT GPIOI
|
||||
#define KEY_BUTTON_GPIO_CLK_ENABLE() __HAL_RCC_GPIOI_CLK_ENABLE()
|
||||
#define KEY_BUTTON_GPIO_CLK_DISABLE() __HAL_RCC_GPIOI_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())
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32746G_DISCOVERY_LOW_LEVEL_SIGNAL
|
||||
* @{
|
||||
*/
|
||||
#define SIGNALn ((uint8_t)1)
|
||||
|
||||
/**
|
||||
* @brief SD-detect signal
|
||||
*/
|
||||
#define SD_DETECT_PIN GPIO_PIN_13
|
||||
#define SD_DETECT_GPIO_PORT GPIOC
|
||||
#define SD_DETECT_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE()
|
||||
#define SD_DETECT_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE()
|
||||
#define SD_DETECT_EXTI_IRQn EXTI15_10_IRQn
|
||||
|
||||
/**
|
||||
* @brief Touch screen interrupt signal
|
||||
*/
|
||||
#define TS_INT_PIN GPIO_PIN_13
|
||||
#define TS_INT_GPIO_PORT GPIOI
|
||||
#define TS_INT_GPIO_CLK_ENABLE() __HAL_RCC_GPIOI_CLK_ENABLE()
|
||||
#define TS_INT_GPIO_CLK_DISABLE() __HAL_RCC_GPIOI_CLK_DISABLE()
|
||||
#define TS_INT_EXTI_IRQn EXTI15_10_IRQn
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32746G_DISCOVERY_LOW_LEVEL_COM
|
||||
* @{
|
||||
*/
|
||||
#define COMn ((uint8_t)1)
|
||||
|
||||
/**
|
||||
* @brief Definition for COM port1, connected to USART1
|
||||
*/
|
||||
#define DISCOVERY_COM1 USART1
|
||||
#define DISCOVERY_COM1_CLK_ENABLE() __HAL_RCC_USART1_CLK_ENABLE()
|
||||
#define DISCOVERY_COM1_CLK_DISABLE() __HAL_RCC_USART1_CLK_DISABLE()
|
||||
|
||||
#define DISCOVERY_COM1_TX_PIN GPIO_PIN_9
|
||||
#define DISCOVERY_COM1_TX_GPIO_PORT GPIOA
|
||||
#define DISCOVERY_COM1_TX_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
|
||||
#define DISCOVERY_COM1_TX_GPIO_CLK_DISABLE() __HAL_RCC_GPIOA_CLK_DISABLE()
|
||||
#define DISCOVERY_COM1_TX_AF GPIO_AF7_USART1
|
||||
|
||||
#define DISCOVERY_COM1_RX_PIN GPIO_PIN_7
|
||||
#define DISCOVERY_COM1_RX_GPIO_PORT GPIOB
|
||||
#define DISCOVERY_COM1_RX_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
|
||||
#define DISCOVERY_COM1_RX_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE()
|
||||
#define DISCOVERY_COM1_RX_AF GPIO_AF7_USART1
|
||||
|
||||
#define DISCOVERY_COM1_IRQn USART1_IRQn
|
||||
|
||||
#define DISCOVERY_COMx_CLK_ENABLE(__INDEX__) do { if((__INDEX__) == COM1) DISCOVERY_COM1_CLK_ENABLE(); } while(0)
|
||||
#define DISCOVERY_COMx_CLK_DISABLE(__INDEX__) (((__INDEX__) == 0) ? DISCOVERY_COM1_CLK_DISABLE() : 0)
|
||||
|
||||
#define DISCOVERY_COMx_TX_GPIO_CLK_ENABLE(__INDEX__) do { if((__INDEX__) == COM1) DISCOVERY_COM1_TX_GPIO_CLK_ENABLE(); } while(0)
|
||||
#define DISCOVERY_COMx_TX_GPIO_CLK_DISABLE(__INDEX__) (((__INDEX__) == 0) ? DISCOVERY_COM1_TX_GPIO_CLK_DISABLE() : 0)
|
||||
|
||||
#define DISCOVERY_COMx_RX_GPIO_CLK_ENABLE(__INDEX__) do { if((__INDEX__) == COM1) DISCOVERY_COM1_RX_GPIO_CLK_ENABLE(); } while(0)
|
||||
#define DISCOVERY_COMx_RX_GPIO_CLK_DISABLE(__INDEX__) (((__INDEX__) == 0) ? DISCOVERY_COM1_RX_GPIO_CLK_DISABLE() : 0)
|
||||
|
||||
/* Exported constant IO ------------------------------------------------------*/
|
||||
|
||||
#define LCD_I2C_ADDRESS ((uint16_t)0x70)
|
||||
#define CAMERA_I2C_ADDRESS ((uint16_t)0x60)
|
||||
#define AUDIO_I2C_ADDRESS ((uint16_t)0x34)
|
||||
#define EEPROM_I2C_ADDRESS_A01 ((uint16_t)0xA0)
|
||||
#define EEPROM_I2C_ADDRESS_A02 ((uint16_t)0xA6)
|
||||
#define TS_I2C_ADDRESS ((uint16_t)0x70)
|
||||
|
||||
/* I2C clock speed configuration (in Hz)
|
||||
WARNING:
|
||||
Make sure that this define is not already declared in other files (ie.
|
||||
stm32746g_discovery.h file). It can be used in parallel by other modules. */
|
||||
#ifndef I2C_SPEED
|
||||
#define I2C_SPEED ((uint32_t)100000)
|
||||
#endif /* I2C_SPEED */
|
||||
|
||||
/* User can use this section to tailor I2Cx/I2Cx instance used and associated
|
||||
resources */
|
||||
/* Definition for AUDIO and LCD I2Cx resources */
|
||||
#define DISCOVERY_AUDIO_I2Cx I2C3
|
||||
#define DISCOVERY_AUDIO_I2Cx_CLK_ENABLE() __HAL_RCC_I2C3_CLK_ENABLE()
|
||||
#define DISCOVERY_AUDIO_DMAx_CLK_ENABLE() __HAL_RCC_DMA1_CLK_ENABLE()
|
||||
#define DISCOVERY_AUDIO_I2Cx_SCL_SDA_GPIO_CLK_ENABLE() __HAL_RCC_GPIOH_CLK_ENABLE()
|
||||
|
||||
#define DISCOVERY_AUDIO_I2Cx_FORCE_RESET() __HAL_RCC_I2C3_FORCE_RESET()
|
||||
#define DISCOVERY_AUDIO_I2Cx_RELEASE_RESET() __HAL_RCC_I2C3_RELEASE_RESET()
|
||||
|
||||
/* Definition for I2Cx Pins */
|
||||
#define DISCOVERY_AUDIO_I2Cx_SCL_PIN GPIO_PIN_7
|
||||
#define DISCOVERY_AUDIO_I2Cx_SCL_SDA_GPIO_PORT GPIOH
|
||||
#define DISCOVERY_AUDIO_I2Cx_SCL_SDA_AF GPIO_AF4_I2C3
|
||||
#define DISCOVERY_AUDIO_I2Cx_SDA_PIN GPIO_PIN_8
|
||||
|
||||
/* I2C interrupt requests */
|
||||
#define DISCOVERY_AUDIO_I2Cx_EV_IRQn I2C3_EV_IRQn
|
||||
#define DISCOVERY_AUDIO_I2Cx_ER_IRQn I2C3_ER_IRQn
|
||||
|
||||
/* Definition for external, camera and Arduino connector I2Cx resources */
|
||||
#define DISCOVERY_EXT_I2Cx I2C1
|
||||
#define DISCOVERY_EXT_I2Cx_CLK_ENABLE() __HAL_RCC_I2C1_CLK_ENABLE()
|
||||
#define DISCOVERY_EXT_DMAx_CLK_ENABLE() __HAL_RCC_DMA1_CLK_ENABLE()
|
||||
#define DISCOVERY_EXT_I2Cx_SCL_SDA_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
|
||||
|
||||
#define DISCOVERY_EXT_I2Cx_FORCE_RESET() __HAL_RCC_I2C1_FORCE_RESET()
|
||||
#define DISCOVERY_EXT_I2Cx_RELEASE_RESET() __HAL_RCC_I2C1_RELEASE_RESET()
|
||||
|
||||
/* Definition for I2Cx Pins */
|
||||
#define DISCOVERY_EXT_I2Cx_SCL_PIN GPIO_PIN_8
|
||||
#define DISCOVERY_EXT_I2Cx_SCL_SDA_GPIO_PORT GPIOB
|
||||
#define DISCOVERY_EXT_I2Cx_SCL_SDA_AF GPIO_AF4_I2C1
|
||||
#define DISCOVERY_EXT_I2Cx_SDA_PIN GPIO_PIN_9
|
||||
|
||||
/* I2C interrupt requests */
|
||||
#define DISCOVERY_EXT_I2Cx_EV_IRQn I2C1_EV_IRQn
|
||||
#define DISCOVERY_EXT_I2Cx_ER_IRQn I2C1_ER_IRQn
|
||||
|
||||
/* I2C TIMING Register define when I2C clock source is SYSCLK */
|
||||
/* I2C TIMING is calculated from APB1 source clock = 50 MHz */
|
||||
/* Due to the big MOFSET capacity for adapting the camera level the rising time is very large (>1us) */
|
||||
/* 0x40912732 takes in account the big rising and aims a clock of 100khz */
|
||||
#ifndef DISCOVERY_I2Cx_TIMING
|
||||
#define DISCOVERY_I2Cx_TIMING ((uint32_t)0x40912732)
|
||||
#endif /* DISCOVERY_I2Cx_TIMING */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32746G_DISCOVERY_LOW_LEVEL_Exported_Macros STM32746G_DISCOVERY_LOW_LEVEL Exported Macros
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32746G_DISCOVERY_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 ButtonMode);
|
||||
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);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __STM32746G_DISCOVERY_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@@ -0,0 +1,497 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32746g_discovery_sdram.c
|
||||
* @author MCD Application Team
|
||||
* @brief This file includes the SDRAM driver for the MT48LC4M32B2B5-7 memory
|
||||
* device mounted on STM32746G-Discovery board.
|
||||
@verbatim
|
||||
1. How To use this driver:
|
||||
--------------------------
|
||||
- This driver is used to drive the MT48LC4M32B2B5-7 SDRAM external memory mounted
|
||||
on STM32746G-Discovery 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
|
||||
SDRAM_MspInit() static function).
|
||||
o User can implement his own functions for read/write access with his desired
|
||||
configurations.
|
||||
o If interrupt mode is used for 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.
|
||||
|
||||
@endverbatim
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
|
||||
*
|
||||
* 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 STMicroelectronics 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.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Dependencies
|
||||
- stm32f7xx_hal_sdram.c
|
||||
- stm32f7xx_ll_fmc.c
|
||||
- stm32f7xx_hal_dma.c
|
||||
- stm32f7xx_hal_gpio.c
|
||||
- stm32f7xx_hal_cortex.c
|
||||
- stm32f7xx_hal_rcc_ex.h
|
||||
EndDependencies */
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32746g_discovery_sdram.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32746G_DISCOVERY
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32746G_DISCOVERY_SDRAM STM32746G_DISCOVERY_SDRAM
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32746G_DISCOVERY_SDRAM_Private_Types_Definitions STM32746G_DISCOVERY_SDRAM Private Types Definitions
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32746G_DISCOVERY_SDRAM_Private_Defines STM32746G_DISCOVERY_SDRAM Private Defines
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32746G_DISCOVERY_SDRAM_Private_Macros STM32746G_DISCOVERY_SDRAM Private Macros
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32746G_DISCOVERY_SDRAM_Private_Variables STM32746G_DISCOVERY_SDRAM Private Variables
|
||||
* @{
|
||||
*/
|
||||
SDRAM_HandleTypeDef sdramHandle;
|
||||
static FMC_SDRAM_TimingTypeDef Timing;
|
||||
static FMC_SDRAM_CommandTypeDef Command;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32746G_DISCOVERY_SDRAM_Private_Function_Prototypes STM32746G_DISCOVERY_SDRAM Private Function Prototypes
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32746G_DISCOVERY_SDRAM_Exported_Functions STM32746G_DISCOVERY_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 100Mhz as SD clock frequency (System clock is up to 200Mhz) */
|
||||
Timing.LoadToActiveDelay = 2;
|
||||
Timing.ExitSelfRefreshDelay = 7;
|
||||
Timing.SelfRefreshTime = 4;
|
||||
Timing.RowCycleDelay = 7;
|
||||
Timing.WriteRecoveryTime = 2;
|
||||
Timing.RPDelay = 2;
|
||||
Timing.RCDDelay = 2;
|
||||
|
||||
sdramHandle.Init.SDBank = FMC_SDRAM_BANK1;
|
||||
sdramHandle.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_8;
|
||||
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_2;
|
||||
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 */
|
||||
|
||||
BSP_SDRAM_MspInit(&sdramHandle, NULL); /* __weak function can be rewritten by the application */
|
||||
|
||||
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
|
||||
*/
|
||||
uint8_t BSP_SDRAM_DeInit(void)
|
||||
{
|
||||
static uint8_t sdramstatus = SDRAM_ERROR;
|
||||
/* SDRAM device de-initialization */
|
||||
sdramHandle.Instance = FMC_SDRAM_DEVICE;
|
||||
|
||||
if(HAL_SDRAM_DeInit(&sdramHandle) != HAL_OK)
|
||||
{
|
||||
sdramstatus = SDRAM_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
sdramstatus = SDRAM_OK;
|
||||
}
|
||||
|
||||
/* SDRAM controller de-initialization */
|
||||
BSP_SDRAM_MspDeInit(&sdramHandle, NULL);
|
||||
|
||||
return sdramstatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Programs the SDRAM device.
|
||||
* @param RefreshCount: SDRAM refresh counter value
|
||||
* @retval None
|
||||
*/
|
||||
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_2 |\
|
||||
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 amount 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
|
||||
*/
|
||||
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 amount 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
|
||||
*/
|
||||
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 amount 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
|
||||
*/
|
||||
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 amount 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
|
||||
*/
|
||||
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 SDRAM status
|
||||
*/
|
||||
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 Initializes SDRAM MSP.
|
||||
* @param hsdram: SDRAM handle
|
||||
* @param Params
|
||||
* @retval None
|
||||
*/
|
||||
__weak void BSP_SDRAM_MspInit(SDRAM_HandleTypeDef *hsdram, void *Params)
|
||||
{
|
||||
static DMA_HandleTypeDef dma_handle;
|
||||
GPIO_InitTypeDef gpio_init_structure;
|
||||
|
||||
/* Enable FMC clock */
|
||||
__HAL_RCC_FMC_CLK_ENABLE();
|
||||
|
||||
/* Enable chosen DMAx clock */
|
||||
__DMAx_CLK_ENABLE();
|
||||
|
||||
/* Enable GPIOs clock */
|
||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOD_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOE_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOF_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOG_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOH_CLK_ENABLE();
|
||||
|
||||
/* Common GPIO configuration */
|
||||
gpio_init_structure.Mode = GPIO_MODE_AF_PP;
|
||||
gpio_init_structure.Pull = GPIO_PULLUP;
|
||||
gpio_init_structure.Speed = GPIO_SPEED_FAST;
|
||||
gpio_init_structure.Alternate = GPIO_AF12_FMC;
|
||||
|
||||
/* GPIOC configuration */
|
||||
gpio_init_structure.Pin = GPIO_PIN_3;
|
||||
HAL_GPIO_Init(GPIOC, &gpio_init_structure);
|
||||
|
||||
/* 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_3 | GPIO_PIN_5;
|
||||
HAL_GPIO_Init(GPIOH, &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, 0x0F, 0);
|
||||
HAL_NVIC_EnableIRQ(SDRAM_DMAx_IRQn);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DeInitializes SDRAM MSP.
|
||||
* @param hsdram: SDRAM handle
|
||||
* @param Params
|
||||
* @retval None
|
||||
*/
|
||||
__weak void BSP_SDRAM_MspDeInit(SDRAM_HandleTypeDef *hsdram, void *Params)
|
||||
{
|
||||
static DMA_HandleTypeDef dma_handle;
|
||||
|
||||
/* 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);
|
||||
|
||||
/* GPIO pins clock, FMC clock and DMA clock can be shut down in the applications
|
||||
by surcharging this __weak function */
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@@ -0,0 +1,162 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32746g_discovery_sdram.h
|
||||
* @author MCD Application Team
|
||||
* @brief This file contains the common defines and functions prototypes for
|
||||
* the stm32746g_discovery_sdram.c driver.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
|
||||
*
|
||||
* 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 STMicroelectronics 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.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __STM32746G_DISCOVERY_SDRAM_H
|
||||
#define __STM32746G_DISCOVERY_SDRAM_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32f7xx_hal.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32746G_DISCOVERY
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32746G_DISCOVERY_SDRAM
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32746G_DISCOVERY_SDRAM_Exported_Types STM32746G_DISCOVERY_SDRAM Exported Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief SDRAM status structure definition
|
||||
*/
|
||||
#define SDRAM_OK ((uint8_t)0x00)
|
||||
#define SDRAM_ERROR ((uint8_t)0x01)
|
||||
|
||||
/** @defgroup STM32746G_DISCOVERY_SDRAM_Exported_Constants STM32746G_DISCOVERY_SDRAM Exported Constants
|
||||
* @{
|
||||
*/
|
||||
#define SDRAM_DEVICE_ADDR ((uint32_t)0xC0000000)
|
||||
#define SDRAM_DEVICE_SIZE ((uint32_t)0x800000) /* SDRAM device size in MBytes */
|
||||
|
||||
/* #define SDRAM_MEMORY_WIDTH FMC_SDRAM_MEM_BUS_WIDTH_8 */
|
||||
#define SDRAM_MEMORY_WIDTH FMC_SDRAM_MEM_BUS_WIDTH_16
|
||||
|
||||
#define SDCLOCK_PERIOD FMC_SDRAM_CLOCK_PERIOD_2
|
||||
/* #define SDCLOCK_PERIOD FMC_SDRAM_CLOCK_PERIOD_3 */
|
||||
|
||||
#define REFRESH_COUNT ((uint32_t)0x0603) /* SDRAM refresh counter (100Mhz SD clock) */
|
||||
|
||||
#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 BSP_SDRAM_DMA_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 STM32746G_DISCOVERY_SDRAM_Exported_Macro STM32746G_DISCOVERY_SDRAM Exported Macro
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32746G_DISCOVERY_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);
|
||||
|
||||
/* These functions 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 /* __STM32746G_DISCOVERY_SDRAM_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@@ -0,0 +1,450 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32746g_discovery_ts.c
|
||||
* @author MCD Application Team
|
||||
* @brief This file provides a set of functions needed to manage the Touch
|
||||
* Screen on STM32746G-Discovery board.
|
||||
@verbatim
|
||||
1. How To use this driver:
|
||||
--------------------------
|
||||
- This driver is used to drive the touch screen module of the STM32746G-Discovery
|
||||
board on the RK043FN48H-CT672B 480x272 LCD screen with capacitive touch screen.
|
||||
- The FT5336 component driver must be included in project files according to
|
||||
the touch screen driver present on this board.
|
||||
|
||||
2. Driver description:
|
||||
---------------------
|
||||
+ Initialization steps:
|
||||
o Initialize the TS module using the BSP_TS_Init() function. This
|
||||
function includes the MSP layer hardware resources initialization and the
|
||||
communication layer configuration to start the TS use. The LCD size properties
|
||||
(x and y) are passed as parameters.
|
||||
o If TS interrupt mode is desired, you must configure the TS interrupt mode
|
||||
by calling the function BSP_TS_ITConfig(). The TS interrupt mode is generated
|
||||
as an external interrupt whenever a touch is detected.
|
||||
The interrupt mode internally uses the IO functionalities driver driven by
|
||||
the IO expander, to configure the IT line.
|
||||
|
||||
+ Touch screen use
|
||||
o The touch screen state is captured whenever the function BSP_TS_GetState() is
|
||||
used. This function returns information about the last LCD touch occurred
|
||||
in the TS_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.
|
||||
@endverbatim
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
|
||||
*
|
||||
* 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 STMicroelectronics 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.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Dependencies
|
||||
- stm32746g_discovery_lcd.c
|
||||
- ft5336.c
|
||||
EndDependencies */
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32746g_discovery_ts.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32746G_DISCOVERY
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32746G_DISCOVERY_TS STM32746G_DISCOVERY_TS
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32746G_DISCOVERY_TS_Private_Types_Definitions STM32746G_DISCOVERY_TS Types Definitions
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32746G_DISCOVERY_TS_Private_Defines STM32746G_DISCOVERY_TS Types Defines
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32746G_DISCOVERY_TS_Private_Macros STM32746G_DISCOVERY_TS Private Macros
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32746G_DISCOVERY_TS_Imported_Variables STM32746G_DISCOVERY_TS Imported Variables
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32746G_DISCOVERY_TS_Private_Variables STM32746G_DISCOVERY_TS Private Variables
|
||||
* @{
|
||||
*/
|
||||
static TS_DrvTypeDef *tsDriver;
|
||||
static uint16_t tsXBoundary, tsYBoundary;
|
||||
static uint8_t tsOrientation;
|
||||
static uint8_t I2cAddress;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32746G_DISCOVERY_TS_Private_Function_Prototypes STM32746G_DISCOVERY_TS Private Function Prototypes
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32746G_DISCOVERY_TS_Exported_Functions STM32746G_DISCOVERY_TS Exported 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 status = TS_OK;
|
||||
tsXBoundary = ts_SizeX;
|
||||
tsYBoundary = ts_SizeY;
|
||||
|
||||
/* Read ID and verify if the touch screen driver is ready */
|
||||
ft5336_ts_drv.Init(TS_I2C_ADDRESS);
|
||||
if(ft5336_ts_drv.ReadID(TS_I2C_ADDRESS) == FT5336_ID_VALUE)
|
||||
{
|
||||
/* Initialize the TS driver structure */
|
||||
tsDriver = &ft5336_ts_drv;
|
||||
I2cAddress = TS_I2C_ADDRESS;
|
||||
tsOrientation = TS_SWAP_XY;
|
||||
|
||||
/* Initialize the TS driver */
|
||||
tsDriver->Start(I2cAddress);
|
||||
}
|
||||
else
|
||||
{
|
||||
status = TS_DEVICE_NOT_FOUND;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DeInitializes the TouchScreen.
|
||||
* @retval TS state
|
||||
*/
|
||||
uint8_t BSP_TS_DeInit(void)
|
||||
{
|
||||
/* Actually ts_driver does not provide a DeInit function */
|
||||
return TS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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)
|
||||
{
|
||||
GPIO_InitTypeDef gpio_init_structure;
|
||||
|
||||
/* Configure Interrupt mode for SD detection pin */
|
||||
gpio_init_structure.Pin = TS_INT_PIN;
|
||||
gpio_init_structure.Pull = GPIO_NOPULL;
|
||||
gpio_init_structure.Speed = GPIO_SPEED_FAST;
|
||||
gpio_init_structure.Mode = GPIO_MODE_IT_RISING;
|
||||
HAL_GPIO_Init(TS_INT_GPIO_PORT, &gpio_init_structure);
|
||||
|
||||
/* Enable and set Touch screen EXTI Interrupt to the lowest priority */
|
||||
HAL_NVIC_SetPriority((IRQn_Type)(TS_INT_EXTI_IRQn), 0x0F, 0x00);
|
||||
HAL_NVIC_EnableIRQ((IRQn_Type)(TS_INT_EXTI_IRQn));
|
||||
|
||||
/* Enable the TS ITs */
|
||||
tsDriver->EnableIT(I2cAddress);
|
||||
|
||||
return TS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the touch screen interrupt status.
|
||||
* @retval TS_OK if all initializations are OK. Other value if error.
|
||||
*/
|
||||
uint8_t BSP_TS_ITGetStatus(void)
|
||||
{
|
||||
/* Return the TS IT status */
|
||||
return (tsDriver->GetITStatus(I2cAddress));
|
||||
}
|
||||
|
||||
/**
|
||||
* @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 x[TS_MAX_NB_TOUCH];
|
||||
uint16_t y[TS_MAX_NB_TOUCH];
|
||||
uint16_t brute_x[TS_MAX_NB_TOUCH];
|
||||
uint16_t brute_y[TS_MAX_NB_TOUCH];
|
||||
uint16_t x_diff;
|
||||
uint16_t y_diff;
|
||||
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 = tsDriver->DetectTouch(I2cAddress);
|
||||
|
||||
if(TS_State->touchDetected)
|
||||
{
|
||||
for(index=0; index < TS_State->touchDetected; index++)
|
||||
{
|
||||
/* Get each touch coordinates */
|
||||
tsDriver->GetXY(I2cAddress, &(brute_x[index]), &(brute_y[index]));
|
||||
|
||||
if(tsOrientation == TS_SWAP_NONE)
|
||||
{
|
||||
x[index] = brute_x[index];
|
||||
y[index] = brute_y[index];
|
||||
}
|
||||
|
||||
if(tsOrientation & TS_SWAP_X)
|
||||
{
|
||||
x[index] = 4096 - brute_x[index];
|
||||
}
|
||||
|
||||
if(tsOrientation & TS_SWAP_Y)
|
||||
{
|
||||
y[index] = 4096 - brute_y[index];
|
||||
}
|
||||
|
||||
if(tsOrientation & TS_SWAP_XY)
|
||||
{
|
||||
y[index] = brute_x[index];
|
||||
x[index] = brute_y[index];
|
||||
}
|
||||
|
||||
x_diff = x[index] > _x[index]? (x[index] - _x[index]): (_x[index] - x[index]);
|
||||
y_diff = y[index] > _y[index]? (y[index] - _y[index]): (_y[index] - y[index]);
|
||||
|
||||
if ((x_diff + y_diff) > 5)
|
||||
{
|
||||
_x[index] = x[index];
|
||||
_y[index] = y[index];
|
||||
}
|
||||
|
||||
if(I2cAddress == FT5336_I2C_SLAVE_ADDRESS)
|
||||
{
|
||||
TS_State->touchX[index] = x[index];
|
||||
TS_State->touchY[index] = y[index];
|
||||
}
|
||||
else
|
||||
{
|
||||
/* 2^12 = 4096 : indexes are expressed on a dynamic of 4096 */
|
||||
TS_State->touchX[index] = (tsXBoundary * _x[index]) >> 12;
|
||||
TS_State->touchY[index] = (tsYBoundary * _y[index]) >> 12;
|
||||
}
|
||||
|
||||
#if (TS_MULTI_TOUCH_SUPPORTED == 1)
|
||||
|
||||
/* Get touch info related to the current touch */
|
||||
ft5336_TS_GetTouchInfo(I2cAddress, index, &weight, &area, &event);
|
||||
|
||||
/* Update TS_State structure */
|
||||
TS_State->touchWeight[index] = weight;
|
||||
TS_State->touchArea[index] = area;
|
||||
|
||||
/* Remap touch event */
|
||||
switch(event)
|
||||
{
|
||||
case FT5336_TOUCH_EVT_FLAG_PRESS_DOWN :
|
||||
TS_State->touchEventId[index] = TOUCH_EVENT_PRESS_DOWN;
|
||||
break;
|
||||
case FT5336_TOUCH_EVT_FLAG_LIFT_UP :
|
||||
TS_State->touchEventId[index] = TOUCH_EVENT_LIFT_UP;
|
||||
break;
|
||||
case FT5336_TOUCH_EVT_FLAG_CONTACT :
|
||||
TS_State->touchEventId[index] = TOUCH_EVENT_CONTACT;
|
||||
break;
|
||||
case FT5336_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 */
|
||||
ft5336_TS_GetGestureID(I2cAddress, &gestureId);
|
||||
|
||||
/* Remap gesture Id to a TS_GestureIdTypeDef value */
|
||||
switch(gestureId)
|
||||
{
|
||||
case FT5336_GEST_ID_NO_GESTURE :
|
||||
TS_State->gestureId = GEST_ID_NO_GESTURE;
|
||||
break;
|
||||
case FT5336_GEST_ID_MOVE_UP :
|
||||
TS_State->gestureId = GEST_ID_MOVE_UP;
|
||||
break;
|
||||
case FT5336_GEST_ID_MOVE_RIGHT :
|
||||
TS_State->gestureId = GEST_ID_MOVE_RIGHT;
|
||||
break;
|
||||
case FT5336_GEST_ID_MOVE_DOWN :
|
||||
TS_State->gestureId = GEST_ID_MOVE_DOWN;
|
||||
break;
|
||||
case FT5336_GEST_ID_MOVE_LEFT :
|
||||
TS_State->gestureId = GEST_ID_MOVE_LEFT;
|
||||
break;
|
||||
case FT5336_GEST_ID_ZOOM_IN :
|
||||
TS_State->gestureId = GEST_ID_ZOOM_IN;
|
||||
break;
|
||||
case FT5336_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 IT pending bits */
|
||||
tsDriver->ClearIT(I2cAddress);
|
||||
}
|
||||
|
||||
|
||||
/** @defgroup STM32756G_DISCOVERY_TS_Private_Functions TS Private Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @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);
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
@@ -0,0 +1,212 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32746g_discovery_ts.h
|
||||
* @author MCD Application Team
|
||||
* @brief This file contains the common defines and functions prototypes for
|
||||
* the stm32746g_discovery_ts.c driver.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
|
||||
*
|
||||
* 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 STMicroelectronics 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.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __STM32746G_DISCOVERY_TS_H
|
||||
#define __STM32746G_DISCOVERY_TS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32746g_discovery.h"
|
||||
/* Include touch screen FT5336 component Driver */
|
||||
#include "../Components/ft5336/ft5336.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32746G_DISCOVERY
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32746G_DISCOVERY_TS
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32746G_DISCOVERY_TS_Exported_Constants STM32746G_DISCOVERY_TS Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @brief With FT5336 : maximum 5 touches detected simultaneously
|
||||
*/
|
||||
#define TS_MAX_NB_TOUCH ((uint32_t) FT5336_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 STM32746G_DISCOVERY_TS_Exported_Types STM32746G_DISCOVERY_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;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32746G_DISCOVERY_TS_Exported_Constants STM32746G_DISCOVERY_TS Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
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 STM32746G_DISCOVERY_TS_Imported_Variables STM32746G_DISCOVERY_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];
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32746G_DISCOVERY_TS_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
uint8_t BSP_TS_Init(uint16_t ts_SizeX, uint16_t ts_SizeY);
|
||||
uint8_t BSP_TS_DeInit(void);
|
||||
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);
|
||||
#endif /* TS_MULTI_TOUCH_SUPPORTED == 1 */
|
||||
|
||||
uint8_t BSP_TS_ITConfig(void);
|
||||
uint8_t BSP_TS_ITGetStatus(void);
|
||||
void BSP_TS_ITClear(void);
|
||||
uint8_t BSP_TS_ResetTouchData(TS_StateTypeDef *TS_State);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __STM32746G_DISCOVERY_TS_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
675
board/STM32F746NGH6_discovery/BSP/hal_stm_lvgl/tft/tft.c
Normal file
675
board/STM32F746NGH6_discovery/BSP/hal_stm_lvgl/tft/tft.c
Normal file
@@ -0,0 +1,675 @@
|
||||
/**
|
||||
* @file tft.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
#include "lvgl/lvgl.h"
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "tft.h"
|
||||
#include "stm32f7xx.h"
|
||||
#include "stm32746g_discovery.h"
|
||||
#include "stm32746g_discovery_sdram.h"
|
||||
#include "stm32746g_discovery_ts.h"
|
||||
#include "../Components/rk043fn48h/rk043fn48h.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
#if LV_COLOR_DEPTH != 16 && LV_COLOR_DEPTH != 24 && LV_COLOR_DEPTH != 32
|
||||
#error LV_COLOR_DEPTH must be 16, 24, or 32
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief LCD status structure definition
|
||||
*/
|
||||
#define LCD_OK ((uint8_t)0x00)
|
||||
#define LCD_ERROR ((uint8_t)0x01)
|
||||
#define LCD_TIMEOUT ((uint8_t)0x02)
|
||||
|
||||
/**
|
||||
* @brief LCD special pins
|
||||
*/
|
||||
/* Display enable pin */
|
||||
#define LCD_DISP_PIN GPIO_PIN_12
|
||||
#define LCD_DISP_GPIO_PORT GPIOI
|
||||
#define LCD_DISP_GPIO_CLK_ENABLE() __HAL_RCC_GPIOI_CLK_ENABLE()
|
||||
#define LCD_DISP_GPIO_CLK_DISABLE() __HAL_RCC_GPIOI_CLK_DISABLE()
|
||||
|
||||
/* Backlight control pin */
|
||||
#define LCD_BL_CTRL_PIN GPIO_PIN_3
|
||||
#define LCD_BL_CTRL_GPIO_PORT GPIOK
|
||||
#define LCD_BL_CTRL_GPIO_CLK_ENABLE() __HAL_RCC_GPIOK_CLK_ENABLE()
|
||||
#define LCD_BL_CTRL_GPIO_CLK_DISABLE() __HAL_RCC_GPIOK_CLK_DISABLE()
|
||||
|
||||
#define CPY_BUF_DMA_STREAM DMA2_Stream0
|
||||
#define CPY_BUF_DMA_CHANNEL DMA_CHANNEL_0
|
||||
#define CPY_BUF_DMA_STREAM_IRQ DMA2_Stream0_IRQn
|
||||
#define CPY_BUF_DMA_STREAM_IRQHANDLER DMA2_Stream0_IRQHandler
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/*These 3 functions are needed by LittlevGL*/
|
||||
static void ex_disp_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t * color_p);
|
||||
#if LV_USE_GPU
|
||||
static void gpu_mem_blend(lv_disp_drv_t *disp_drv, lv_color_t * dest, const lv_color_t * src, uint32_t length, lv_opa_t opa);
|
||||
static void gpu_mem_fill(lv_disp_drv_t *disp_drv, lv_color_t * dest_buf, lv_coord_t dest_width, const lv_area_t * fill_area, lv_color_t color);
|
||||
#endif
|
||||
|
||||
static uint8_t LCD_Init(void);
|
||||
static void LCD_LayerRgb565Init(uint32_t FB_Address);
|
||||
static void LCD_DisplayOn(void);
|
||||
|
||||
static void DMA_Config(void);
|
||||
static void DMA_TransferComplete(DMA_HandleTypeDef *han);
|
||||
static void DMA_TransferError(DMA_HandleTypeDef *han);
|
||||
|
||||
#if LV_USE_GPU
|
||||
static void DMA2D_Config(void);
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
#if LV_USE_GPU
|
||||
static DMA2D_HandleTypeDef Dma2dHandle;
|
||||
#endif
|
||||
static LTDC_HandleTypeDef hLtdcHandler;
|
||||
|
||||
#if LV_COLOR_DEPTH == 16
|
||||
typedef uint16_t uintpixel_t;
|
||||
#elif LV_COLOR_DEPTH == 24 || LV_COLOR_DEPTH == 32
|
||||
typedef uint32_t uintpixel_t;
|
||||
#endif
|
||||
|
||||
/* You can try to change buffer to internal ram by uncommenting line below and commenting
|
||||
* SDRAM one. */
|
||||
//static uintpixel_t my_fb[TFT_HOR_RES * TFT_VER_RES];
|
||||
|
||||
static __IO uintpixel_t * my_fb = (__IO uintpixel_t*) (SDRAM_DEVICE_ADDR);
|
||||
|
||||
static DMA_HandleTypeDef DmaHandle;
|
||||
static int32_t x1_flush;
|
||||
static int32_t y1_flush;
|
||||
static int32_t x2_flush;
|
||||
static int32_t y2_fill;
|
||||
static int32_t y_fill_act;
|
||||
static const lv_color_t * buf_to_flush;
|
||||
|
||||
static lv_disp_t *our_disp = NULL;
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize your display here
|
||||
*/
|
||||
|
||||
void tft_init(void)
|
||||
{
|
||||
/* There is only one display on STM32 */
|
||||
if(our_disp != NULL)
|
||||
abort();
|
||||
/* LCD Initialization */
|
||||
LCD_Init();
|
||||
|
||||
/* LCD Initialization */
|
||||
LCD_LayerRgb565Init((uint32_t)my_fb);
|
||||
|
||||
/* Enable the LCD */
|
||||
LCD_DisplayOn();
|
||||
|
||||
DMA_Config();
|
||||
|
||||
#if LV_USE_GPU != 0
|
||||
DMA2D_Config();
|
||||
#endif
|
||||
/*-----------------------------
|
||||
* Create a buffer for drawing
|
||||
*----------------------------*/
|
||||
|
||||
/* LittlevGL requires a buffer where it draws the objects. The buffer's has to be greater than 1 display row*/
|
||||
|
||||
static lv_disp_buf_t disp_buf_1;
|
||||
static lv_color_t buf1_1[LV_HOR_RES_MAX * 10]; /*A buffer for 10 rows*/
|
||||
lv_disp_buf_init(&disp_buf_1, buf1_1, NULL, LV_HOR_RES_MAX * 10); /*Initialize the display buffer*/
|
||||
|
||||
|
||||
/*-----------------------------------
|
||||
* Register the display in LittlevGL
|
||||
*----------------------------------*/
|
||||
|
||||
lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/
|
||||
lv_disp_drv_init(&disp_drv); /*Basic initialization*/
|
||||
|
||||
/*Set up the functions to access to your display*/
|
||||
|
||||
/*Set the resolution of the display*/
|
||||
disp_drv.hor_res = 480;
|
||||
disp_drv.ver_res = 272;
|
||||
|
||||
/*Used to copy the buffer's content to the display*/
|
||||
disp_drv.flush_cb = ex_disp_flush;
|
||||
|
||||
/*Set a display buffer*/
|
||||
disp_drv.buffer = &disp_buf_1;
|
||||
|
||||
#if LV_USE_GPU
|
||||
/*Optionally add functions to access the GPU. (Only in buffered mode, LV_VDB_SIZE != 0)*/
|
||||
|
||||
/*Blend two color array using opacity*/
|
||||
disp_drv.gpu_blend_cb = gpu_mem_blend;
|
||||
|
||||
/*Fill a memory array with a color*/
|
||||
disp_drv.gpu_fill_cb = gpu_mem_fill;
|
||||
#endif
|
||||
|
||||
/*Finally register the driver*/
|
||||
our_disp = lv_disp_drv_register(&disp_drv);
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/* Flush the content of the internal buffer the specific area on the display
|
||||
* You can use DMA or any hardware acceleration to do this operation in the background but
|
||||
* 'lv_flush_ready()' has to be called when finished
|
||||
* This function is required only when LV_VDB_SIZE != 0 in lv_conf.h*/
|
||||
static void ex_disp_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t * color_p)
|
||||
{
|
||||
int32_t x1 = area->x1;
|
||||
int32_t x2 = area->x2;
|
||||
int32_t y1 = area->y1;
|
||||
int32_t y2 = area->y2;
|
||||
/*Return if the area is out the screen*/
|
||||
|
||||
if(x2 < 0) return;
|
||||
if(y2 < 0) return;
|
||||
if(x1 > TFT_HOR_RES - 1) return;
|
||||
if(y1 > TFT_VER_RES - 1) return;
|
||||
|
||||
/*Truncate the area to the screen*/
|
||||
int32_t act_x1 = x1 < 0 ? 0 : x1;
|
||||
int32_t act_y1 = y1 < 0 ? 0 : y1;
|
||||
int32_t act_x2 = x2 > TFT_HOR_RES - 1 ? TFT_HOR_RES - 1 : x2;
|
||||
int32_t act_y2 = y2 > TFT_VER_RES - 1 ? TFT_VER_RES - 1 : y2;
|
||||
|
||||
x1_flush = act_x1;
|
||||
y1_flush = act_y1;
|
||||
x2_flush = act_x2;
|
||||
y2_fill = act_y2;
|
||||
y_fill_act = act_y1;
|
||||
buf_to_flush = color_p;
|
||||
|
||||
/*##-7- Start the DMA transfer using the interrupt mode #*/
|
||||
/* Configure the source, destination and buffer size DMA fields and Start DMA Stream transfer */
|
||||
/* Enable All the DMA interrupts */
|
||||
HAL_StatusTypeDef err;
|
||||
uint32_t length = (x2_flush - x1_flush + 1);
|
||||
#if LV_COLOR_DEPTH == 24 || LV_COLOR_DEPTH == 32
|
||||
length *= 2; /* STM32 DMA uses 16-bit chunks so multiply by 2 for 32-bit color */
|
||||
#endif
|
||||
err = HAL_DMA_Start_IT(&DmaHandle,(uint32_t)buf_to_flush, (uint32_t)&my_fb[y_fill_act * TFT_HOR_RES + x1_flush],
|
||||
length);
|
||||
if(err != HAL_OK)
|
||||
{
|
||||
while(1); /*Halt on error*/
|
||||
}
|
||||
}
|
||||
|
||||
#if LV_USE_GPU != 0
|
||||
|
||||
/**
|
||||
* Copy pixels to destination memory using opacity
|
||||
* @param dest a memory address. Copy 'src' here.
|
||||
* @param src pointer to pixel map. Copy it to 'dest'.
|
||||
* @param length number of pixels in 'src'
|
||||
* @param opa opacity (0, OPA_TRANSP: transparent ... 255, OPA_COVER, fully cover)
|
||||
*/
|
||||
static void gpu_mem_blend(lv_disp_drv_t *disp_drv, lv_color_t * dest, const lv_color_t * src, uint32_t length, lv_opa_t opa)
|
||||
{
|
||||
/*Wait for the previous operation*/
|
||||
HAL_DMA2D_PollForTransfer(&Dma2dHandle, 100);
|
||||
Dma2dHandle.Init.Mode = DMA2D_M2M_BLEND;
|
||||
/* DMA2D Initialization */
|
||||
if(HAL_DMA2D_Init(&Dma2dHandle) != HAL_OK)
|
||||
{
|
||||
/* Initialization Error */
|
||||
while(1);
|
||||
}
|
||||
|
||||
Dma2dHandle.LayerCfg[1].InputAlpha = opa;
|
||||
HAL_DMA2D_ConfigLayer(&Dma2dHandle, 1);
|
||||
HAL_DMA2D_BlendingStart(&Dma2dHandle, (uint32_t) src, (uint32_t) dest, (uint32_t)dest, length, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy pixels to destination memory using opacity
|
||||
* @param dest a memory address. Copy 'src' here.
|
||||
* @param src pointer to pixel map. Copy it to 'dest'.
|
||||
* @param length number of pixels in 'src'
|
||||
* @param opa opacity (0, OPA_TRANSP: transparent ... 255, OPA_COVER, fully cover)
|
||||
*/
|
||||
static void gpu_mem_fill(lv_disp_drv_t *disp_drv, lv_color_t * dest_buf, lv_coord_t dest_width,
|
||||
const lv_area_t * fill_area, lv_color_t color)
|
||||
{
|
||||
/*Wait for the previous operation*/
|
||||
HAL_DMA2D_PollForTransfer(&Dma2dHandle, 100);
|
||||
|
||||
Dma2dHandle.Init.Mode = DMA2D_R2M;
|
||||
/* DMA2D Initialization */
|
||||
if(HAL_DMA2D_Init(&Dma2dHandle) != HAL_OK)
|
||||
{
|
||||
/* Initialization Error */
|
||||
while(1);
|
||||
}
|
||||
|
||||
Dma2dHandle.LayerCfg[1].InputAlpha = 0xff;
|
||||
HAL_DMA2D_ConfigLayer(&Dma2dHandle, 1);
|
||||
|
||||
lv_color_t * dest_buf_ofs = dest_buf;
|
||||
|
||||
dest_buf_ofs += dest_width * fill_area->y1;
|
||||
dest_buf_ofs += fill_area->x1;
|
||||
lv_coord_t area_w = lv_area_get_width(fill_area);
|
||||
|
||||
uint32_t i;
|
||||
for(i = fill_area->y1; i <= fill_area->y2; i++) {
|
||||
/*Wait for the previous operation*/
|
||||
HAL_DMA2D_PollForTransfer(&Dma2dHandle, 100);
|
||||
HAL_DMA2D_BlendingStart(&Dma2dHandle, (uint32_t) lv_color_to32(color), (uint32_t) dest_buf_ofs, (uint32_t)dest_buf_ofs, area_w, 1);
|
||||
dest_buf_ofs += dest_width;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Configure LCD pins, and peripheral clocks.
|
||||
*/
|
||||
static void LCD_MspInit(void)
|
||||
{
|
||||
GPIO_InitTypeDef gpio_init_structure;
|
||||
|
||||
/* Enable the LTDC and DMA2D clocks */
|
||||
__HAL_RCC_LTDC_CLK_ENABLE();
|
||||
#if LV_USE_GPU != 0
|
||||
__HAL_RCC_DMA2D_CLK_ENABLE();
|
||||
#endif
|
||||
/* Enable GPIOs clock */
|
||||
__HAL_RCC_GPIOE_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOG_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOI_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOJ_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOK_CLK_ENABLE();
|
||||
LCD_DISP_GPIO_CLK_ENABLE();
|
||||
LCD_BL_CTRL_GPIO_CLK_ENABLE();
|
||||
|
||||
/*** LTDC Pins configuration ***/
|
||||
/* GPIOE configuration */
|
||||
gpio_init_structure.Pin = GPIO_PIN_4;
|
||||
gpio_init_structure.Mode = GPIO_MODE_AF_PP;
|
||||
gpio_init_structure.Pull = GPIO_NOPULL;
|
||||
gpio_init_structure.Speed = GPIO_SPEED_FAST;
|
||||
gpio_init_structure.Alternate = GPIO_AF14_LTDC;
|
||||
HAL_GPIO_Init(GPIOE, &gpio_init_structure);
|
||||
|
||||
/* GPIOG configuration */
|
||||
gpio_init_structure.Pin = GPIO_PIN_12;
|
||||
gpio_init_structure.Mode = GPIO_MODE_AF_PP;
|
||||
gpio_init_structure.Alternate = GPIO_AF9_LTDC;
|
||||
HAL_GPIO_Init(GPIOG, &gpio_init_structure);
|
||||
|
||||
/* GPIOI LTDC alternate configuration */
|
||||
gpio_init_structure.Pin = GPIO_PIN_9 | GPIO_PIN_10 | \
|
||||
GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15;
|
||||
gpio_init_structure.Mode = GPIO_MODE_AF_PP;
|
||||
gpio_init_structure.Alternate = GPIO_AF14_LTDC;
|
||||
HAL_GPIO_Init(GPIOI, &gpio_init_structure);
|
||||
|
||||
/* GPIOJ 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_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | \
|
||||
GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15;
|
||||
gpio_init_structure.Mode = GPIO_MODE_AF_PP;
|
||||
gpio_init_structure.Alternate = GPIO_AF14_LTDC;
|
||||
HAL_GPIO_Init(GPIOJ, &gpio_init_structure);
|
||||
|
||||
/* GPIOK configuration */
|
||||
gpio_init_structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_4 | \
|
||||
GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7;
|
||||
gpio_init_structure.Mode = GPIO_MODE_AF_PP;
|
||||
gpio_init_structure.Alternate = GPIO_AF14_LTDC;
|
||||
HAL_GPIO_Init(GPIOK, &gpio_init_structure);
|
||||
|
||||
/* LCD_DISP GPIO configuration */
|
||||
gpio_init_structure.Pin = LCD_DISP_PIN; /* LCD_DISP pin has to be manually controlled */
|
||||
gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
HAL_GPIO_Init(LCD_DISP_GPIO_PORT, &gpio_init_structure);
|
||||
|
||||
/* LCD_BL_CTRL GPIO configuration */
|
||||
gpio_init_structure.Pin = LCD_BL_CTRL_PIN; /* LCD_BL_CTRL pin has to be manually controlled */
|
||||
gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
HAL_GPIO_Init(LCD_BL_CTRL_GPIO_PORT, &gpio_init_structure);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure LTDC PLL.
|
||||
*/
|
||||
static void LCD_ClockConfig(void)
|
||||
{
|
||||
static RCC_PeriphCLKInitTypeDef periph_clk_init_struct;
|
||||
|
||||
/* RK043FN48H LCD clock configuration */
|
||||
/* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */
|
||||
/* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAIN = 192 Mhz */
|
||||
/* PLLLCDCLK = PLLSAI_VCO Output/PLLSAIR = 192/5 = 38.4 Mhz */
|
||||
/* LTDC clock frequency = PLLLCDCLK / LTDC_PLLSAI_DIVR_4 = 38.4/4 = 9.6Mhz */
|
||||
periph_clk_init_struct.PeriphClockSelection = RCC_PERIPHCLK_LTDC;
|
||||
periph_clk_init_struct.PLLSAI.PLLSAIN = 192;
|
||||
periph_clk_init_struct.PLLSAI.PLLSAIR = RK043FN48H_FREQUENCY_DIVIDER;
|
||||
periph_clk_init_struct.PLLSAIDivR = RCC_PLLSAIDIVR_4;
|
||||
HAL_RCCEx_PeriphCLKConfig(&periph_clk_init_struct);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initializes the LCD.
|
||||
* @retval LCD state
|
||||
*/
|
||||
static uint8_t LCD_Init(void)
|
||||
{
|
||||
/* Select the used LCD */
|
||||
|
||||
/* The RK043FN48H LCD 480x272 is selected */
|
||||
/* Timing Configuration */
|
||||
hLtdcHandler.Init.HorizontalSync = (RK043FN48H_HSYNC - 1);
|
||||
hLtdcHandler.Init.VerticalSync = (RK043FN48H_VSYNC - 1);
|
||||
hLtdcHandler.Init.AccumulatedHBP = (RK043FN48H_HSYNC + RK043FN48H_HBP - 1);
|
||||
hLtdcHandler.Init.AccumulatedVBP = (RK043FN48H_VSYNC + RK043FN48H_VBP - 1);
|
||||
hLtdcHandler.Init.AccumulatedActiveH = (RK043FN48H_HEIGHT + RK043FN48H_VSYNC + RK043FN48H_VBP - 1);
|
||||
hLtdcHandler.Init.AccumulatedActiveW = (RK043FN48H_WIDTH + RK043FN48H_HSYNC + RK043FN48H_HBP - 1);
|
||||
hLtdcHandler.Init.TotalHeigh = (RK043FN48H_HEIGHT + RK043FN48H_VSYNC + RK043FN48H_VBP + RK043FN48H_VFP - 1);
|
||||
hLtdcHandler.Init.TotalWidth = (RK043FN48H_WIDTH + RK043FN48H_HSYNC + RK043FN48H_HBP + RK043FN48H_HFP - 1);
|
||||
|
||||
/* LCD clock configuration */
|
||||
LCD_ClockConfig();
|
||||
|
||||
/* Initialize the LCD pixel width and pixel height */
|
||||
hLtdcHandler.LayerCfg->ImageWidth = RK043FN48H_WIDTH;
|
||||
hLtdcHandler.LayerCfg->ImageHeight = RK043FN48H_HEIGHT;
|
||||
|
||||
/* Background value */
|
||||
hLtdcHandler.Init.Backcolor.Blue = 0;
|
||||
hLtdcHandler.Init.Backcolor.Green = 0;
|
||||
hLtdcHandler.Init.Backcolor.Red = 0;
|
||||
|
||||
/* Polarity */
|
||||
hLtdcHandler.Init.HSPolarity = LTDC_HSPOLARITY_AL;
|
||||
hLtdcHandler.Init.VSPolarity = LTDC_VSPOLARITY_AL;
|
||||
hLtdcHandler.Init.DEPolarity = LTDC_DEPOLARITY_AL;
|
||||
hLtdcHandler.Init.PCPolarity = LTDC_PCPOLARITY_IPC;
|
||||
hLtdcHandler.Instance = LTDC;
|
||||
|
||||
if(HAL_LTDC_GetState(&hLtdcHandler) == HAL_LTDC_STATE_RESET)
|
||||
{
|
||||
/* Initialize the LCD Msp: this __weak function can be rewritten by the application */
|
||||
LCD_MspInit();
|
||||
}
|
||||
HAL_LTDC_Init(&hLtdcHandler);
|
||||
|
||||
/* Assert display enable LCD_DISP pin */
|
||||
HAL_GPIO_WritePin(LCD_DISP_GPIO_PORT, LCD_DISP_PIN, GPIO_PIN_SET);
|
||||
|
||||
/* Assert backlight LCD_BL_CTRL pin */
|
||||
HAL_GPIO_WritePin(LCD_BL_CTRL_GPIO_PORT, LCD_BL_CTRL_PIN, GPIO_PIN_SET);
|
||||
|
||||
BSP_SDRAM_Init();
|
||||
|
||||
uint32_t i;
|
||||
for(i = 0; i < (TFT_HOR_RES * TFT_VER_RES) ; i++)
|
||||
{
|
||||
my_fb[i] = 0;
|
||||
}
|
||||
|
||||
return LCD_OK;
|
||||
}
|
||||
|
||||
static void LCD_LayerRgb565Init(uint32_t FB_Address)
|
||||
{
|
||||
LTDC_LayerCfgTypeDef layer_cfg;
|
||||
|
||||
/* Layer Init */
|
||||
layer_cfg.WindowX0 = 0;
|
||||
layer_cfg.WindowX1 = TFT_HOR_RES;
|
||||
layer_cfg.WindowY0 = 0;
|
||||
layer_cfg.WindowY1 = TFT_VER_RES;
|
||||
|
||||
#if LV_COLOR_DEPTH == 16
|
||||
layer_cfg.PixelFormat = LTDC_PIXEL_FORMAT_RGB565;
|
||||
#elif LV_COLOR_DEPTH == 24 || LV_COLOR_DEPTH == 32
|
||||
layer_cfg.PixelFormat = LTDC_PIXEL_FORMAT_ARGB8888;
|
||||
#else
|
||||
#error Unsupported color depth (see tft.c)
|
||||
#endif
|
||||
layer_cfg.FBStartAdress = FB_Address;
|
||||
layer_cfg.Alpha = 255;
|
||||
layer_cfg.Alpha0 = 0;
|
||||
layer_cfg.Backcolor.Blue = 0;
|
||||
layer_cfg.Backcolor.Green = 0;
|
||||
layer_cfg.Backcolor.Red = 0;
|
||||
layer_cfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_PAxCA;
|
||||
layer_cfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_PAxCA;
|
||||
layer_cfg.ImageWidth = TFT_HOR_RES;
|
||||
layer_cfg.ImageHeight = TFT_VER_RES;
|
||||
|
||||
HAL_LTDC_ConfigLayer(&hLtdcHandler, &layer_cfg, 0);
|
||||
}
|
||||
|
||||
static void LCD_DisplayOn(void)
|
||||
{
|
||||
/* Display On */
|
||||
__HAL_LTDC_ENABLE(&hLtdcHandler);
|
||||
HAL_GPIO_WritePin(LCD_DISP_GPIO_PORT, LCD_DISP_PIN, GPIO_PIN_SET); /* Assert LCD_DISP pin */
|
||||
HAL_GPIO_WritePin(LCD_BL_CTRL_GPIO_PORT, LCD_BL_CTRL_PIN, GPIO_PIN_SET); /* Assert LCD_BL_CTRL pin */
|
||||
}
|
||||
|
||||
static void DMA_Config(void)
|
||||
{
|
||||
/*## -1- Enable DMA2 clock #################################################*/
|
||||
__HAL_RCC_DMA2_CLK_ENABLE();
|
||||
|
||||
/*##-2- Select the DMA functional Parameters ###############################*/
|
||||
DmaHandle.Init.Channel = CPY_BUF_DMA_CHANNEL; /* DMA_CHANNEL_0 */
|
||||
DmaHandle.Init.Direction = DMA_MEMORY_TO_MEMORY; /* M2M transfer mode */
|
||||
DmaHandle.Init.PeriphInc = DMA_PINC_ENABLE; /* Peripheral increment mode Enable */
|
||||
DmaHandle.Init.MemInc = DMA_MINC_ENABLE; /* Memory increment mode Enable */
|
||||
DmaHandle.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD; /* Peripheral data alignment : 16bit */
|
||||
DmaHandle.Init.MemDataAlignment = DMA_PDATAALIGN_HALFWORD; /* memory data alignment : 16bit */
|
||||
DmaHandle.Init.Mode = DMA_NORMAL; /* Normal DMA mode */
|
||||
DmaHandle.Init.Priority = DMA_PRIORITY_HIGH; /* priority level : high */
|
||||
DmaHandle.Init.FIFOMode = DMA_FIFOMODE_ENABLE; /* FIFO mode enabled */
|
||||
DmaHandle.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_1QUARTERFULL; /* FIFO threshold: 1/4 full */
|
||||
DmaHandle.Init.MemBurst = DMA_MBURST_SINGLE; /* Memory burst */
|
||||
DmaHandle.Init.PeriphBurst = DMA_PBURST_SINGLE; /* Peripheral burst */
|
||||
|
||||
/*##-3- Select the DMA instance to be used for the transfer : DMA2_Stream0 #*/
|
||||
DmaHandle.Instance = CPY_BUF_DMA_STREAM;
|
||||
|
||||
/*##-4- Initialize the DMA stream ##########################################*/
|
||||
if(HAL_DMA_Init(&DmaHandle) != HAL_OK)
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/*##-5- Select Callbacks functions called after Transfer complete and Transfer error */
|
||||
HAL_DMA_RegisterCallback(&DmaHandle, HAL_DMA_XFER_CPLT_CB_ID, DMA_TransferComplete);
|
||||
HAL_DMA_RegisterCallback(&DmaHandle, HAL_DMA_XFER_ERROR_CB_ID, DMA_TransferError);
|
||||
|
||||
/*##-6- Configure NVIC for DMA transfer complete/error interrupts ##########*/
|
||||
HAL_NVIC_SetPriority(CPY_BUF_DMA_STREAM_IRQ, 0, 0);
|
||||
HAL_NVIC_EnableIRQ(CPY_BUF_DMA_STREAM_IRQ);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DMA conversion complete callback
|
||||
* @note This function is executed when the transfer complete interrupt
|
||||
* is generated
|
||||
* @retval None
|
||||
*/
|
||||
static void DMA_TransferComplete(DMA_HandleTypeDef *han)
|
||||
{
|
||||
y_fill_act ++;
|
||||
|
||||
if(y_fill_act > y2_fill) {
|
||||
lv_disp_flush_ready(&our_disp->driver);
|
||||
} else {
|
||||
uint32_t length = (x2_flush - x1_flush + 1);
|
||||
buf_to_flush += x2_flush - x1_flush + 1;
|
||||
/*##-7- Start the DMA transfer using the interrupt mode ####################*/
|
||||
/* Configure the source, destination and buffer size DMA fields and Start DMA Stream transfer */
|
||||
/* Enable All the DMA interrupts */
|
||||
#if LV_COLOR_DEPTH == 24 || LV_COLOR_DEPTH == 32
|
||||
length *= 2; /* STM32 DMA uses 16-bit chunks so multiply by 2 for 32-bit color */
|
||||
#endif
|
||||
if(HAL_DMA_Start_IT(han,(uint32_t)buf_to_flush, (uint32_t)&my_fb[y_fill_act * TFT_HOR_RES + x1_flush],
|
||||
length) != HAL_OK)
|
||||
{
|
||||
while(1); /*Halt on error*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DMA conversion error callback
|
||||
* @note This function is executed when the transfer error interrupt
|
||||
* is generated during DMA transfer
|
||||
* @retval None
|
||||
*/
|
||||
static void DMA_TransferError(DMA_HandleTypeDef *han)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles DMA Stream interrupt request.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void CPY_BUF_DMA_STREAM_IRQHANDLER(void)
|
||||
{
|
||||
/* Check the interrupt and clear flag */
|
||||
HAL_DMA_IRQHandler(&DmaHandle);
|
||||
}
|
||||
|
||||
|
||||
#if LV_USE_GPU != 0
|
||||
|
||||
static void Error_Handler(void)
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @brief DMA2D Transfer completed callback
|
||||
* @param hdma2d: DMA2D handle.
|
||||
* @note This example shows a simple way to report end of DMA2D transfer, and
|
||||
* you can add your own implementation.
|
||||
* @retval None
|
||||
*/
|
||||
static void DMA2D_TransferComplete(DMA2D_HandleTypeDef *hdma2d)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DMA2D error callbacks
|
||||
* @param hdma2d: DMA2D handle
|
||||
* @note This example shows a simple way to report DMA2D transfer error, and you can
|
||||
* add your own implementation.
|
||||
* @retval None
|
||||
*/
|
||||
static void DMA2D_TransferError(DMA2D_HandleTypeDef *hdma2d)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DMA2D configuration.
|
||||
* @note This function Configure the DMA2D peripheral :
|
||||
* 1) Configure the Transfer mode as memory to memory with blending.
|
||||
* 2) Configure the output color mode as RGB565 pixel format.
|
||||
* 3) Configure the foreground
|
||||
* - first image loaded from FLASH memory
|
||||
* - constant alpha value (decreased to see the background)
|
||||
* - color mode as RGB565 pixel format
|
||||
* 4) Configure the background
|
||||
* - second image loaded from FLASH memory
|
||||
* - color mode as RGB565 pixel format
|
||||
* @retval None
|
||||
*/
|
||||
static void DMA2D_Config(void)
|
||||
{
|
||||
/* Configure the DMA2D Mode, Color Mode and output offset */
|
||||
Dma2dHandle.Init.Mode = DMA2D_M2M_BLEND;
|
||||
#if LV_COLOR_DEPTH == 16
|
||||
Dma2dHandle.Init.ColorMode = DMA2D_RGB565;
|
||||
#elif LV_COLOR_DEPTH == 24 || LV_COLOR_DEPTH == 32
|
||||
Dma2dHandle.Init.ColorMode = DMA2D_ARGB8888;
|
||||
#endif
|
||||
Dma2dHandle.Init.OutputOffset = 0x0;
|
||||
|
||||
/* DMA2D Callbacks Configuration */
|
||||
Dma2dHandle.XferCpltCallback = DMA2D_TransferComplete;
|
||||
Dma2dHandle.XferErrorCallback = DMA2D_TransferError;
|
||||
|
||||
/* Foreground Configuration */
|
||||
Dma2dHandle.LayerCfg[1].AlphaMode = DMA2D_REPLACE_ALPHA;
|
||||
Dma2dHandle.LayerCfg[1].InputAlpha = 0xFF;
|
||||
#if LV_COLOR_DEPTH == 16
|
||||
Dma2dHandle.LayerCfg[1].InputColorMode = DMA2D_INPUT_RGB565;
|
||||
#elif LV_COLOR_DEPTH == 24 || LV_COLOR_DEPTH == 32
|
||||
Dma2dHandle.LayerCfg[1].InputColorMode = DMA2D_INPUT_ARGB8888;
|
||||
#endif
|
||||
|
||||
Dma2dHandle.LayerCfg[1].InputOffset = 0x0;
|
||||
|
||||
/* Background Configuration */
|
||||
Dma2dHandle.LayerCfg[0].AlphaMode = DMA2D_REPLACE_ALPHA;
|
||||
Dma2dHandle.LayerCfg[0].InputAlpha = 0xFF;
|
||||
#if LV_COLOR_DEPTH == 16
|
||||
Dma2dHandle.LayerCfg[0].InputColorMode = DMA2D_INPUT_RGB565;
|
||||
#elif LV_COLOR_DEPTH == 24 || LV_COLOR_DEPTH == 32
|
||||
Dma2dHandle.LayerCfg[0].InputColorMode = DMA2D_INPUT_ARGB8888;
|
||||
#endif
|
||||
Dma2dHandle.LayerCfg[0].InputOffset = 0x0;
|
||||
|
||||
Dma2dHandle.Instance = DMA2D;
|
||||
|
||||
/* DMA2D Initialization */
|
||||
if(HAL_DMA2D_Init(&Dma2dHandle) != HAL_OK)
|
||||
{
|
||||
/* Initialization Error */
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
HAL_DMA2D_ConfigLayer(&Dma2dHandle, 0);
|
||||
HAL_DMA2D_ConfigLayer(&Dma2dHandle, 1);
|
||||
}
|
||||
#endif
|
35
board/STM32F746NGH6_discovery/BSP/hal_stm_lvgl/tft/tft.h
Normal file
35
board/STM32F746NGH6_discovery/BSP/hal_stm_lvgl/tft/tft.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* @file tft.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef DISP_H
|
||||
#define DISP_H
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include <stdint.h>
|
||||
#include "lvgl/src/lv_misc/lv_color.h"
|
||||
#include "lvgl/src/lv_misc/lv_area.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define TFT_HOR_RES 480
|
||||
#define TFT_VER_RES 272
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
void tft_init(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif
|
@@ -0,0 +1,88 @@
|
||||
/**
|
||||
* @file indev.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "tft.h"
|
||||
#include "lvgl/src/lv_hal/lv_hal.h"
|
||||
|
||||
#include "stm32746g_discovery.h"
|
||||
#include "stm32746g_discovery_ts.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static bool touchpad_read(lv_indev_drv_t *drv, lv_indev_data_t *data);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static TS_StateTypeDef TS_State;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize your input devices here
|
||||
*/
|
||||
void touchpad_init(void)
|
||||
{
|
||||
BSP_TS_Init(TFT_HOR_RES, TFT_VER_RES);
|
||||
|
||||
lv_indev_drv_t indev_drv; /*Descriptor of an input device driver*/
|
||||
lv_indev_drv_init(&indev_drv); /*Basic initialization*/
|
||||
indev_drv.type = LV_INDEV_TYPE_POINTER; /*The touchpad is pointer type device*/
|
||||
indev_drv.read_cb = touchpad_read;
|
||||
|
||||
lv_indev_drv_register(&indev_drv);
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Read an input device
|
||||
* @param indev_id id of the input device to read
|
||||
* @param x put the x coordinate here
|
||||
* @param y put the y coordinate here
|
||||
* @return true: the device is pressed, false: released
|
||||
*/
|
||||
static bool touchpad_read(lv_indev_drv_t *indev, lv_indev_data_t *data)
|
||||
{
|
||||
/* Read your touchpad */
|
||||
static int16_t last_x = 0;
|
||||
static int16_t last_y = 0;
|
||||
BSP_LED_Toggle(LED1);
|
||||
|
||||
BSP_TS_GetState(&TS_State);
|
||||
if(TS_State.touchDetected) {
|
||||
data->point.x = TS_State.touchX[0];
|
||||
data->point.y = TS_State.touchY[0];
|
||||
last_x = data->point.x;
|
||||
last_y = data->point.y;
|
||||
data->state = LV_INDEV_STATE_PR;
|
||||
} else {
|
||||
data->point.x = last_x;
|
||||
data->point.y = last_y;
|
||||
data->state = LV_INDEV_STATE_REL;
|
||||
}
|
||||
|
||||
return false; /*false: no more data to read because we are no buffering*/
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* @file indev.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef INDEV_H
|
||||
#define INDEV_H
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
void touchpad_init(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif
|
2124
board/STM32F746NGH6_discovery/KEIL/lvgl_demo/STM32F746NGH6.uvoptx
Normal file
2124
board/STM32F746NGH6_discovery/KEIL/lvgl_demo/STM32F746NGH6.uvoptx
Normal file
File diff suppressed because it is too large
Load Diff
1237
board/STM32F746NGH6_discovery/KEIL/lvgl_demo/STM32F746NGH6.uvprojx
Normal file
1237
board/STM32F746NGH6_discovery/KEIL/lvgl_demo/STM32F746NGH6.uvprojx
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,483 @@
|
||||
;******************** (C) COPYRIGHT 2016 STMicroelectronics ********************
|
||||
;* File Name : startup_stm32f746xx.s
|
||||
;* Author : MCD Application Team
|
||||
;* Description : STM32F746xx devices vector table for MDK-ARM toolchain.
|
||||
;* This module performs:
|
||||
;* - Set the initial SP
|
||||
;* - Set the initial PC == Reset_Handler
|
||||
;* - Set the vector table entries with the exceptions ISR address
|
||||
;* - Branches to __main in the C library (which eventually
|
||||
;* calls main()).
|
||||
;* After Reset the CortexM7 processor is in Thread mode,
|
||||
;* priority is Privileged, and the Stack is set to Main.
|
||||
;* <<< Use Configuration Wizard in Context Menu >>>
|
||||
;*******************************************************************************
|
||||
;
|
||||
;* 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 STMicroelectronics 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.
|
||||
;
|
||||
;*******************************************************************************
|
||||
|
||||
; Amount of memory (in bytes) allocated for Stack
|
||||
; Tailor this value to your application needs
|
||||
; <h> Stack Configuration
|
||||
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
||||
; </h>
|
||||
|
||||
Stack_Size EQU 0x400
|
||||
|
||||
AREA STACK, NOINIT, READWRITE, ALIGN=3
|
||||
Stack_Mem SPACE Stack_Size
|
||||
__initial_sp
|
||||
|
||||
|
||||
; <h> Heap Configuration
|
||||
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
||||
; </h>
|
||||
|
||||
Heap_Size EQU 0x200
|
||||
|
||||
AREA HEAP, NOINIT, READWRITE, ALIGN=3
|
||||
__heap_base
|
||||
Heap_Mem SPACE Heap_Size
|
||||
__heap_limit
|
||||
|
||||
PRESERVE8
|
||||
THUMB
|
||||
|
||||
|
||||
; Vector Table Mapped to Address 0 at Reset
|
||||
AREA RESET, DATA, READONLY
|
||||
EXPORT __Vectors
|
||||
EXPORT __Vectors_End
|
||||
EXPORT __Vectors_Size
|
||||
|
||||
__Vectors DCD __initial_sp ; Top of Stack
|
||||
DCD Reset_Handler ; Reset Handler
|
||||
DCD NMI_Handler ; NMI Handler
|
||||
DCD HardFault_Handler ; Hard Fault Handler
|
||||
DCD MemManage_Handler ; MPU Fault Handler
|
||||
DCD BusFault_Handler ; Bus Fault Handler
|
||||
DCD UsageFault_Handler ; Usage Fault Handler
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD SVC_Handler ; SVCall Handler
|
||||
DCD DebugMon_Handler ; Debug Monitor Handler
|
||||
DCD 0 ; Reserved
|
||||
DCD PendSV_Handler ; PendSV Handler
|
||||
DCD SysTick_Handler ; SysTick Handler
|
||||
|
||||
; External Interrupts
|
||||
DCD WWDG_IRQHandler ; Window WatchDog
|
||||
DCD PVD_IRQHandler ; PVD through EXTI Line detection
|
||||
DCD TAMP_STAMP_IRQHandler ; Tamper and TimeStamps through the EXTI line
|
||||
DCD RTC_WKUP_IRQHandler ; RTC Wakeup through the EXTI line
|
||||
DCD FLASH_IRQHandler ; FLASH
|
||||
DCD RCC_IRQHandler ; RCC
|
||||
DCD EXTI0_IRQHandler ; EXTI Line0
|
||||
DCD EXTI1_IRQHandler ; EXTI Line1
|
||||
DCD EXTI2_IRQHandler ; EXTI Line2
|
||||
DCD EXTI3_IRQHandler ; EXTI Line3
|
||||
DCD EXTI4_IRQHandler ; EXTI Line4
|
||||
DCD DMA1_Stream0_IRQHandler ; DMA1 Stream 0
|
||||
DCD DMA1_Stream1_IRQHandler ; DMA1 Stream 1
|
||||
DCD DMA1_Stream2_IRQHandler ; DMA1 Stream 2
|
||||
DCD DMA1_Stream3_IRQHandler ; DMA1 Stream 3
|
||||
DCD DMA1_Stream4_IRQHandler ; DMA1 Stream 4
|
||||
DCD DMA1_Stream5_IRQHandler ; DMA1 Stream 5
|
||||
DCD DMA1_Stream6_IRQHandler ; DMA1 Stream 6
|
||||
DCD ADC_IRQHandler ; ADC1, ADC2 and ADC3s
|
||||
DCD CAN1_TX_IRQHandler ; CAN1 TX
|
||||
DCD CAN1_RX0_IRQHandler ; CAN1 RX0
|
||||
DCD CAN1_RX1_IRQHandler ; CAN1 RX1
|
||||
DCD CAN1_SCE_IRQHandler ; CAN1 SCE
|
||||
DCD EXTI9_5_IRQHandler ; External Line[9:5]s
|
||||
DCD TIM1_BRK_TIM9_IRQHandler ; TIM1 Break and TIM9
|
||||
DCD TIM1_UP_TIM10_IRQHandler ; TIM1 Update and TIM10
|
||||
DCD TIM1_TRG_COM_TIM11_IRQHandler ; TIM1 Trigger and Commutation and TIM11
|
||||
DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare
|
||||
DCD TIM2_IRQHandler ; TIM2
|
||||
DCD TIM3_IRQHandler ; TIM3
|
||||
DCD TIM4_IRQHandler ; TIM4
|
||||
DCD I2C1_EV_IRQHandler ; I2C1 Event
|
||||
DCD I2C1_ER_IRQHandler ; I2C1 Error
|
||||
DCD I2C2_EV_IRQHandler ; I2C2 Event
|
||||
DCD I2C2_ER_IRQHandler ; I2C2 Error
|
||||
DCD SPI1_IRQHandler ; SPI1
|
||||
DCD SPI2_IRQHandler ; SPI2
|
||||
DCD USART1_IRQHandler ; USART1
|
||||
DCD USART2_IRQHandler ; USART2
|
||||
DCD USART3_IRQHandler ; USART3
|
||||
DCD EXTI15_10_IRQHandler ; External Line[15:10]s
|
||||
DCD RTC_Alarm_IRQHandler ; RTC Alarm (A and B) through EXTI Line
|
||||
DCD OTG_FS_WKUP_IRQHandler ; USB OTG FS Wakeup through EXTI line
|
||||
DCD TIM8_BRK_TIM12_IRQHandler ; TIM8 Break and TIM12
|
||||
DCD TIM8_UP_TIM13_IRQHandler ; TIM8 Update and TIM13
|
||||
DCD TIM8_TRG_COM_TIM14_IRQHandler ; TIM8 Trigger and Commutation and TIM14
|
||||
DCD TIM8_CC_IRQHandler ; TIM8 Capture Compare
|
||||
DCD DMA1_Stream7_IRQHandler ; DMA1 Stream7
|
||||
DCD FMC_IRQHandler ; FMC
|
||||
DCD SDMMC1_IRQHandler ; SDMMC1
|
||||
DCD TIM5_IRQHandler ; TIM5
|
||||
DCD SPI3_IRQHandler ; SPI3
|
||||
DCD UART4_IRQHandler ; UART4
|
||||
DCD UART5_IRQHandler ; UART5
|
||||
DCD TIM6_DAC_IRQHandler ; TIM6 and DAC1&2 underrun errors
|
||||
DCD TIM7_IRQHandler ; TIM7
|
||||
DCD DMA2_Stream0_IRQHandler ; DMA2 Stream 0
|
||||
DCD DMA2_Stream1_IRQHandler ; DMA2 Stream 1
|
||||
DCD DMA2_Stream2_IRQHandler ; DMA2 Stream 2
|
||||
DCD DMA2_Stream3_IRQHandler ; DMA2 Stream 3
|
||||
DCD DMA2_Stream4_IRQHandler ; DMA2 Stream 4
|
||||
DCD ETH_IRQHandler ; Ethernet
|
||||
DCD ETH_WKUP_IRQHandler ; Ethernet Wakeup through EXTI line
|
||||
DCD CAN2_TX_IRQHandler ; CAN2 TX
|
||||
DCD CAN2_RX0_IRQHandler ; CAN2 RX0
|
||||
DCD CAN2_RX1_IRQHandler ; CAN2 RX1
|
||||
DCD CAN2_SCE_IRQHandler ; CAN2 SCE
|
||||
DCD OTG_FS_IRQHandler ; USB OTG FS
|
||||
DCD DMA2_Stream5_IRQHandler ; DMA2 Stream 5
|
||||
DCD DMA2_Stream6_IRQHandler ; DMA2 Stream 6
|
||||
DCD DMA2_Stream7_IRQHandler ; DMA2 Stream 7
|
||||
DCD USART6_IRQHandler ; USART6
|
||||
DCD I2C3_EV_IRQHandler ; I2C3 event
|
||||
DCD I2C3_ER_IRQHandler ; I2C3 error
|
||||
DCD OTG_HS_EP1_OUT_IRQHandler ; USB OTG HS End Point 1 Out
|
||||
DCD OTG_HS_EP1_IN_IRQHandler ; USB OTG HS End Point 1 In
|
||||
DCD OTG_HS_WKUP_IRQHandler ; USB OTG HS Wakeup through EXTI
|
||||
DCD OTG_HS_IRQHandler ; USB OTG HS
|
||||
DCD DCMI_IRQHandler ; DCMI
|
||||
DCD 0 ; Reserved
|
||||
DCD RNG_IRQHandler ; Rng
|
||||
DCD FPU_IRQHandler ; FPU
|
||||
DCD UART7_IRQHandler ; UART7
|
||||
DCD UART8_IRQHandler ; UART8
|
||||
DCD SPI4_IRQHandler ; SPI4
|
||||
DCD SPI5_IRQHandler ; SPI5
|
||||
DCD SPI6_IRQHandler ; SPI6
|
||||
DCD SAI1_IRQHandler ; SAI1
|
||||
DCD LTDC_IRQHandler ; LTDC
|
||||
DCD LTDC_ER_IRQHandler ; LTDC error
|
||||
DCD DMA2D_IRQHandler ; DMA2D
|
||||
DCD SAI2_IRQHandler ; SAI2
|
||||
DCD QUADSPI_IRQHandler ; QUADSPI
|
||||
DCD LPTIM1_IRQHandler ; LPTIM1
|
||||
DCD CEC_IRQHandler ; HDMI_CEC
|
||||
DCD I2C4_EV_IRQHandler ; I2C4 Event
|
||||
DCD I2C4_ER_IRQHandler ; I2C4 Error
|
||||
DCD SPDIF_RX_IRQHandler ; SPDIF_RX
|
||||
__Vectors_End
|
||||
|
||||
__Vectors_Size EQU __Vectors_End - __Vectors
|
||||
|
||||
AREA |.text|, CODE, READONLY
|
||||
|
||||
; Reset handler
|
||||
Reset_Handler PROC
|
||||
EXPORT Reset_Handler [WEAK]
|
||||
IMPORT SystemInit
|
||||
IMPORT __main
|
||||
|
||||
LDR R0, =SystemInit
|
||||
BLX R0
|
||||
LDR R0, =__main
|
||||
BX R0
|
||||
ENDP
|
||||
|
||||
; Dummy Exception Handlers (infinite loops which can be modified)
|
||||
|
||||
NMI_Handler PROC
|
||||
EXPORT NMI_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
HardFault_Handler\
|
||||
PROC
|
||||
EXPORT HardFault_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
MemManage_Handler\
|
||||
PROC
|
||||
EXPORT MemManage_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
BusFault_Handler\
|
||||
PROC
|
||||
EXPORT BusFault_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
UsageFault_Handler\
|
||||
PROC
|
||||
EXPORT UsageFault_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
SVC_Handler PROC
|
||||
EXPORT SVC_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
DebugMon_Handler\
|
||||
PROC
|
||||
EXPORT DebugMon_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
PendSV_Handler PROC
|
||||
EXPORT PendSV_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
SysTick_Handler PROC
|
||||
EXPORT SysTick_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
|
||||
Default_Handler PROC
|
||||
|
||||
EXPORT WWDG_IRQHandler [WEAK]
|
||||
EXPORT PVD_IRQHandler [WEAK]
|
||||
EXPORT TAMP_STAMP_IRQHandler [WEAK]
|
||||
EXPORT RTC_WKUP_IRQHandler [WEAK]
|
||||
EXPORT FLASH_IRQHandler [WEAK]
|
||||
EXPORT RCC_IRQHandler [WEAK]
|
||||
EXPORT EXTI0_IRQHandler [WEAK]
|
||||
EXPORT EXTI1_IRQHandler [WEAK]
|
||||
EXPORT EXTI2_IRQHandler [WEAK]
|
||||
EXPORT EXTI3_IRQHandler [WEAK]
|
||||
EXPORT EXTI4_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Stream0_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Stream1_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Stream2_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Stream3_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Stream4_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Stream5_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Stream6_IRQHandler [WEAK]
|
||||
EXPORT ADC_IRQHandler [WEAK]
|
||||
EXPORT CAN1_TX_IRQHandler [WEAK]
|
||||
EXPORT CAN1_RX0_IRQHandler [WEAK]
|
||||
EXPORT CAN1_RX1_IRQHandler [WEAK]
|
||||
EXPORT CAN1_SCE_IRQHandler [WEAK]
|
||||
EXPORT EXTI9_5_IRQHandler [WEAK]
|
||||
EXPORT TIM1_BRK_TIM9_IRQHandler [WEAK]
|
||||
EXPORT TIM1_UP_TIM10_IRQHandler [WEAK]
|
||||
EXPORT TIM1_TRG_COM_TIM11_IRQHandler [WEAK]
|
||||
EXPORT TIM1_CC_IRQHandler [WEAK]
|
||||
EXPORT TIM2_IRQHandler [WEAK]
|
||||
EXPORT TIM3_IRQHandler [WEAK]
|
||||
EXPORT TIM4_IRQHandler [WEAK]
|
||||
EXPORT I2C1_EV_IRQHandler [WEAK]
|
||||
EXPORT I2C1_ER_IRQHandler [WEAK]
|
||||
EXPORT I2C2_EV_IRQHandler [WEAK]
|
||||
EXPORT I2C2_ER_IRQHandler [WEAK]
|
||||
EXPORT SPI1_IRQHandler [WEAK]
|
||||
EXPORT SPI2_IRQHandler [WEAK]
|
||||
EXPORT USART1_IRQHandler [WEAK]
|
||||
EXPORT USART2_IRQHandler [WEAK]
|
||||
EXPORT USART3_IRQHandler [WEAK]
|
||||
EXPORT EXTI15_10_IRQHandler [WEAK]
|
||||
EXPORT RTC_Alarm_IRQHandler [WEAK]
|
||||
EXPORT OTG_FS_WKUP_IRQHandler [WEAK]
|
||||
EXPORT TIM8_BRK_TIM12_IRQHandler [WEAK]
|
||||
EXPORT TIM8_UP_TIM13_IRQHandler [WEAK]
|
||||
EXPORT TIM8_TRG_COM_TIM14_IRQHandler [WEAK]
|
||||
EXPORT TIM8_CC_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Stream7_IRQHandler [WEAK]
|
||||
EXPORT FMC_IRQHandler [WEAK]
|
||||
EXPORT SDMMC1_IRQHandler [WEAK]
|
||||
EXPORT TIM5_IRQHandler [WEAK]
|
||||
EXPORT SPI3_IRQHandler [WEAK]
|
||||
EXPORT UART4_IRQHandler [WEAK]
|
||||
EXPORT UART5_IRQHandler [WEAK]
|
||||
EXPORT TIM6_DAC_IRQHandler [WEAK]
|
||||
EXPORT TIM7_IRQHandler [WEAK]
|
||||
EXPORT DMA2_Stream0_IRQHandler [WEAK]
|
||||
EXPORT DMA2_Stream1_IRQHandler [WEAK]
|
||||
EXPORT DMA2_Stream2_IRQHandler [WEAK]
|
||||
EXPORT DMA2_Stream3_IRQHandler [WEAK]
|
||||
EXPORT DMA2_Stream4_IRQHandler [WEAK]
|
||||
EXPORT ETH_IRQHandler [WEAK]
|
||||
EXPORT ETH_WKUP_IRQHandler [WEAK]
|
||||
EXPORT CAN2_TX_IRQHandler [WEAK]
|
||||
EXPORT CAN2_RX0_IRQHandler [WEAK]
|
||||
EXPORT CAN2_RX1_IRQHandler [WEAK]
|
||||
EXPORT CAN2_SCE_IRQHandler [WEAK]
|
||||
EXPORT OTG_FS_IRQHandler [WEAK]
|
||||
EXPORT DMA2_Stream5_IRQHandler [WEAK]
|
||||
EXPORT DMA2_Stream6_IRQHandler [WEAK]
|
||||
EXPORT DMA2_Stream7_IRQHandler [WEAK]
|
||||
EXPORT USART6_IRQHandler [WEAK]
|
||||
EXPORT I2C3_EV_IRQHandler [WEAK]
|
||||
EXPORT I2C3_ER_IRQHandler [WEAK]
|
||||
EXPORT OTG_HS_EP1_OUT_IRQHandler [WEAK]
|
||||
EXPORT OTG_HS_EP1_IN_IRQHandler [WEAK]
|
||||
EXPORT OTG_HS_WKUP_IRQHandler [WEAK]
|
||||
EXPORT OTG_HS_IRQHandler [WEAK]
|
||||
EXPORT DCMI_IRQHandler [WEAK]
|
||||
EXPORT RNG_IRQHandler [WEAK]
|
||||
EXPORT FPU_IRQHandler [WEAK]
|
||||
EXPORT UART7_IRQHandler [WEAK]
|
||||
EXPORT UART8_IRQHandler [WEAK]
|
||||
EXPORT SPI4_IRQHandler [WEAK]
|
||||
EXPORT SPI5_IRQHandler [WEAK]
|
||||
EXPORT SPI6_IRQHandler [WEAK]
|
||||
EXPORT SAI1_IRQHandler [WEAK]
|
||||
EXPORT LTDC_IRQHandler [WEAK]
|
||||
EXPORT LTDC_ER_IRQHandler [WEAK]
|
||||
EXPORT DMA2D_IRQHandler [WEAK]
|
||||
EXPORT SAI2_IRQHandler [WEAK]
|
||||
EXPORT QUADSPI_IRQHandler [WEAK]
|
||||
EXPORT LPTIM1_IRQHandler [WEAK]
|
||||
EXPORT CEC_IRQHandler [WEAK]
|
||||
EXPORT I2C4_EV_IRQHandler [WEAK]
|
||||
EXPORT I2C4_ER_IRQHandler [WEAK]
|
||||
EXPORT SPDIF_RX_IRQHandler [WEAK]
|
||||
|
||||
WWDG_IRQHandler
|
||||
PVD_IRQHandler
|
||||
TAMP_STAMP_IRQHandler
|
||||
RTC_WKUP_IRQHandler
|
||||
FLASH_IRQHandler
|
||||
RCC_IRQHandler
|
||||
EXTI0_IRQHandler
|
||||
EXTI1_IRQHandler
|
||||
EXTI2_IRQHandler
|
||||
EXTI3_IRQHandler
|
||||
EXTI4_IRQHandler
|
||||
DMA1_Stream0_IRQHandler
|
||||
DMA1_Stream1_IRQHandler
|
||||
DMA1_Stream2_IRQHandler
|
||||
DMA1_Stream3_IRQHandler
|
||||
DMA1_Stream4_IRQHandler
|
||||
DMA1_Stream5_IRQHandler
|
||||
DMA1_Stream6_IRQHandler
|
||||
ADC_IRQHandler
|
||||
CAN1_TX_IRQHandler
|
||||
CAN1_RX0_IRQHandler
|
||||
CAN1_RX1_IRQHandler
|
||||
CAN1_SCE_IRQHandler
|
||||
EXTI9_5_IRQHandler
|
||||
TIM1_BRK_TIM9_IRQHandler
|
||||
TIM1_UP_TIM10_IRQHandler
|
||||
TIM1_TRG_COM_TIM11_IRQHandler
|
||||
TIM1_CC_IRQHandler
|
||||
TIM2_IRQHandler
|
||||
TIM3_IRQHandler
|
||||
TIM4_IRQHandler
|
||||
I2C1_EV_IRQHandler
|
||||
I2C1_ER_IRQHandler
|
||||
I2C2_EV_IRQHandler
|
||||
I2C2_ER_IRQHandler
|
||||
SPI1_IRQHandler
|
||||
SPI2_IRQHandler
|
||||
USART1_IRQHandler
|
||||
USART2_IRQHandler
|
||||
USART3_IRQHandler
|
||||
EXTI15_10_IRQHandler
|
||||
RTC_Alarm_IRQHandler
|
||||
OTG_FS_WKUP_IRQHandler
|
||||
TIM8_BRK_TIM12_IRQHandler
|
||||
TIM8_UP_TIM13_IRQHandler
|
||||
TIM8_TRG_COM_TIM14_IRQHandler
|
||||
TIM8_CC_IRQHandler
|
||||
DMA1_Stream7_IRQHandler
|
||||
FMC_IRQHandler
|
||||
SDMMC1_IRQHandler
|
||||
TIM5_IRQHandler
|
||||
SPI3_IRQHandler
|
||||
UART4_IRQHandler
|
||||
UART5_IRQHandler
|
||||
TIM6_DAC_IRQHandler
|
||||
TIM7_IRQHandler
|
||||
DMA2_Stream0_IRQHandler
|
||||
DMA2_Stream1_IRQHandler
|
||||
DMA2_Stream2_IRQHandler
|
||||
DMA2_Stream3_IRQHandler
|
||||
DMA2_Stream4_IRQHandler
|
||||
ETH_IRQHandler
|
||||
ETH_WKUP_IRQHandler
|
||||
CAN2_TX_IRQHandler
|
||||
CAN2_RX0_IRQHandler
|
||||
CAN2_RX1_IRQHandler
|
||||
CAN2_SCE_IRQHandler
|
||||
OTG_FS_IRQHandler
|
||||
DMA2_Stream5_IRQHandler
|
||||
DMA2_Stream6_IRQHandler
|
||||
DMA2_Stream7_IRQHandler
|
||||
USART6_IRQHandler
|
||||
I2C3_EV_IRQHandler
|
||||
I2C3_ER_IRQHandler
|
||||
OTG_HS_EP1_OUT_IRQHandler
|
||||
OTG_HS_EP1_IN_IRQHandler
|
||||
OTG_HS_WKUP_IRQHandler
|
||||
OTG_HS_IRQHandler
|
||||
DCMI_IRQHandler
|
||||
RNG_IRQHandler
|
||||
FPU_IRQHandler
|
||||
UART7_IRQHandler
|
||||
UART8_IRQHandler
|
||||
SPI4_IRQHandler
|
||||
SPI5_IRQHandler
|
||||
SPI6_IRQHandler
|
||||
SAI1_IRQHandler
|
||||
LTDC_IRQHandler
|
||||
LTDC_ER_IRQHandler
|
||||
DMA2D_IRQHandler
|
||||
SAI2_IRQHandler
|
||||
QUADSPI_IRQHandler
|
||||
LPTIM1_IRQHandler
|
||||
CEC_IRQHandler
|
||||
I2C4_EV_IRQHandler
|
||||
I2C4_ER_IRQHandler
|
||||
SPDIF_RX_IRQHandler
|
||||
B .
|
||||
|
||||
ENDP
|
||||
|
||||
ALIGN
|
||||
|
||||
;*******************************************************************************
|
||||
; User Stack and Heap initialization
|
||||
;*******************************************************************************
|
||||
IF :DEF:__MICROLIB
|
||||
|
||||
EXPORT __initial_sp
|
||||
EXPORT __heap_base
|
||||
EXPORT __heap_limit
|
||||
|
||||
ELSE
|
||||
|
||||
IMPORT __use_two_region_memory
|
||||
EXPORT __user_initial_stackheap
|
||||
|
||||
__user_initial_stackheap
|
||||
|
||||
LDR R0, = Heap_Mem
|
||||
LDR R1, =(Stack_Mem + Stack_Size)
|
||||
LDR R2, = (Heap_Mem + Heap_Size)
|
||||
LDR R3, = Stack_Mem
|
||||
BX LR
|
||||
|
||||
ALIGN
|
||||
|
||||
ENDIF
|
||||
|
||||
END
|
||||
|
||||
;************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE*****
|
Reference in New Issue
Block a user