initial working (stm32f4-discovery)

This commit is contained in:
2026-07-31 19:07:15 +03:00
commit ce6632f48c
2214 changed files with 1264937 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
---
name: 'Bug report'
about: 'Create a report to help us improve the quality of our software'
title: ''
labels: ''
assignees: ''
---
**Caution**
The Issues are strictly limited for the reporting of problem encountered with the software provided in this project.
For any other problem related to the STM32 product, the performance, the hardware characteristics and boards, the tools the environment in general, please post your report to the **ST Community** in the STM32 MCUs dedicated [page](https://community.st.com/s/group/0F90X000000AXsASAW/stm32-mcus).
**Describe the set-up**
* The board (either ST RPN reference or your custom board)
* IDE or at least the compiler and its version
**Describe the bug (skip if none)**
A clear and concise description of what the bug is.
**How to reproduce the bug (skip if none)**
1. Indicate the global behavior of your application project
2. List the modules that you suspect to be the cause of the problem (Drivers, BSP, MW...)
3. Describe the use case that generates the problem
4. How we can reproduce the problem
**Additional context**
If you have a first analysis, an enhancement, a fix or a patch, thank you to share your proposal.
**Screenshots**
If applicable, add screenshots to help explain your problem.
@@ -0,0 +1,3 @@
## IMPORTANT INFORMATION
Pull-requests are **not** accepted on this repository. Please use issues to report any bug or request.
@@ -0,0 +1,73 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team via this [link](https://www.st.com/content/st_com/en/contact-us.html).
All complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 1.4,
available [here](https://www.contributor-covenant.org/version/1/4/code-of-conduct.html).
For answers to common questions about this code of conduct, see the [FAQ section](https://www.contributor-covenant.org/faq).
@@ -0,0 +1,28 @@
## Contributing guide
This document serves as a checklist before contributing to this repository.
It includes links to read up on if topics are unclear to you.
This guide mainly focuses on steps to be followed to submit an issue or a pull-request.
### 1. Before opening an issue
To report a bug or a request please file an issue in the right repository
(example for [ft3x67](https://github.com/STMicroelectronics/ft3x67/issues/new/choose)).
Please check the following boxes before posting an issue:
- [ ] `Make sure you are using the latest commit (major releases are tagged, but corrections are available as new commits).`
- [ ] `Make sure your issue is a question/feedback/suggestions RELATED TO the software provided in this repository.` Otherwise, it should be submitted to the ST Community under the MCU topic [page](https://community.st.com/s/group/0F90X000000AXsASAW/stm32-mcus).
- [ ] `Make sure your issue is not already reported/fixed on GitHub or discussed on a previous issue.` Please refer to this [dashboard](https://github.com/orgs/STMicroelectronics/projects/2) for the list of issues and pull-requests. Do not forget to browse into the **closed** issues.
### 2. Posting the issue
When you have checked the previous boxes. You will find two templates (Bug Report or Other Issue) available in the **Issues** tab of the repository.
### 3. Pull Requests
Pull-requests are **not** accepted on this repository. Please use **issues** to report any bug or request.
### 4. How to proceed
* We recommend to engage first a communication thru an issue, in order to present your proposal. Just to confirm that it corresponds to STMicroelectronics domain or scope.
* Then fork the project to your GitHub account to further develop your contribution. Please use the latest commit version.
* Please, submit one Pull Request for one new feature or proposal. This will ease the analysis and the final merge if accepted.
+27
View File
@@ -0,0 +1,27 @@
Copyright 2017 STMicroelectronics.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+40
View File
@@ -0,0 +1,40 @@
# BSP FT3X67 Component
## Overview
**STM32Cube** is an STMicroelectronics original initiative to ease the developers life by reducing efforts, time and cost.
**STM32Cube** covers the overall STM32 products portfolio. It includes a comprehensive embedded software platform delivered for each STM32 series.
* The CMSIS modules (core and device) corresponding to the ARM(tm) core implemented in this STM32 product.
* The STM32 HAL-LL drivers, an abstraction layer offering a set of APIs ensuring maximized portability across the STM32 portfolio.
* The BSP drivers of each evaluation, demonstration or nucleo board provided for this STM32 series.
* A consistent set of middleware components such as RTOS, USB, FatFS, graphics, touch sensing library...
* A full set of software projects (basic examples, applications, and demonstrations) for each board provided for this STM32 series.
Two models of publication are proposed for the STM32Cube embedded software:
* The monolithic **MCU Package**: all STM32Cube software modules of one STM32 series are present (Drivers, Middleware, Projects, Utilities) in the repository (usual name **STM32Cubexx**, xx corresponding to the STM32 series).
* The **MCU component**: each STM32Cube software module being part of the STM32Cube MCU Package, is delivered as an individual repository, allowing the user to select and get only the required software functions.
## Description
This **ft3x67** MCU component repository is one element **common to all** STM32Cube MCU embedded software packages, providing the **FT3X67** BSP TOUCH SCREEN component part.
## License
Copyright (c) 2017 STMicroelectronics
This software component is licensed by STMicroelectronics under the **BSD-3-Clause** license. You may not use this software except in compliance with this license. You may obtain a copy of the license [here](https://opensource.org/licenses/BSD-3-Clause).
## Release note
Details about the content of this release are available in the release note [here](https://htmlpreview.github.io/?https://github.com/STMicroelectronics/ft3x67/blob/main/Release_Notes.html).
## Compatibility information
Please refer to the repository of the BSP **board** driver you are using to know which version of this BSP component driver to use. It is **crucial** that you use a consistent set of versions.
## Troubleshooting
If you have any issue with the **software content** of this repository, you can file an issue [here](https://github.com/STMicroelectronics/ft3x67/issues/new/choose).
For any other question related to the product, the tools, the environment, you can submit a topic to the [ST Community](https://community.st.com/s/).
+31
View File
@@ -0,0 +1,31 @@
# Report potential product security vulnerabilities
ST places a high priority on security, and our Product Security Incident
Response Team (PSIRT) is committed to rapidly addressing potential security
vulnerabilities affecting our products. PSIRT's long history and vast experience
in security allows ST to perform clear analyses and provide appropriate guidance
on mitigations and solutions when applicable.
If you wish to report potential security vulnerabilities regarding our products,
**please do not report them through public GitHub issues.** Instead, we
encourage you to report them to our ST PSIRT following the process described at:
**https://www.st.com/content/st_com/en/security/report-vulnerabilities.html**
### IMPORTANT - READ CAREFULLY:
STMicroelectronics International N.V., on behalf of itself, its affiliates and
subsidiaries, (collectively “ST”) takes all potential security vulnerability
reports or other related communications (“Report(s)”) seriously. In order to
review Your Report (the terms “You” and “Yours” include your employer, and all
affiliates, subsidiaries and related persons or entities) and take actions as
deemed appropriate, ST requires that we have the rights and Your permission to
do so.
As such, by submitting Your Report to ST, You agree that You have the right to
do so, and You grant to ST the rights to use the Report for purposes related to
security vulnerability analysis, testing, correction, patching, reporting and
any other related purpose or function.
By submitting Your Report, You agree that ST’s
[Privacy Policy](https://www.st.com/content/st_com/en/common/privacy-portal.html)
applies to all related communications.
+439
View File
@@ -0,0 +1,439 @@
/**
******************************************************************************
* @file ft3x67.c
* @author MCD Application Team
* @brief This file provides a set of functions needed to manage the FT3X67
* touch screen devices.
******************************************************************************
* @attention
*
* Copyright (c) 2017 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "ft3x67.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Component
* @{
*/
/** @addtogroup FT3X67
* @{
*/
/* Private typedef -----------------------------------------------------------*/
/** @defgroup FT3X67_Private_Types_Definitions
* @{
*/
/* ft3x67 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;
} ft3x67_handle_TypeDef;
/**
* @}
*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/** @defgroup FT3X67_Private_Variables
* @{
*/
/* Touch screen driver structure initialization */
TS_DrvTypeDef ft3x67_ts_drv =
{
ft3x67_Init,
ft3x67_ReadID,
ft3x67_Reset,
ft3x67_TS_Start,
ft3x67_TS_DetectTouch,
ft3x67_TS_GetXY,
ft3x67_TS_EnableIT,
ft3x67_TS_ClearIT,
ft3x67_TS_ITStatus,
ft3x67_TS_DisableIT
};
/* Global ft3x67 handle */
static ft3x67_handle_TypeDef ft3x67_handle = { FT3X67_I2C_NOT_INITIALIZED, 0U, 0U};
/**
* @}
*/
/* Private functions prototypes-----------------------------------------------*/
/** @defgroup FT3X67_Private_Functions
* @{
*/
static uint8_t ft3x67_Get_I2C_InitializedStatus(void);
static void ft3x67_I2C_InitializeIfRequired(void);
static uint32_t ft3x67_TS_Configure(uint16_t DeviceAddr);
/**
* @}
*/
/* Exported functions --------------------------------------------------------*/
/** @addtogroup FT3X67_Exported_Functions
* @{
*/
/**
* @brief Initialize the ft3x67 communication bus
* from MCU to FT3X67 : ie I2C channel initialization (if required).
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT3X67).
* @retval None
*/
void ft3x67_Init(uint16_t DeviceAddr)
{
/* Initialize I2C link if needed */
ft3x67_I2C_InitializeIfRequired();
}
/**
* @brief Software Reset the ft3x67.
* @note : Not applicable to FT3X67.
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT3X67).
* @retval None
*/
void ft3x67_Reset(uint16_t DeviceAddr)
{
/* Do nothing */
/* No software reset sequence available in FT3X67 IC */
}
/**
* @brief Read the ft3x67 device ID, pre initialize I2C in case of need to be
* able to read the FT3X67 device ID, and verify this is a FT3X67.
* @param DeviceAddr: I2C FT3X67 Slave address.
* @retval The Device ID (two bytes).
*/
uint16_t ft3x67_ReadID(uint16_t DeviceAddr)
{
/* Initialize I2C link if needed */
ft3x67_I2C_InitializeIfRequired();
/* Return the device ID value */
return(TS_IO_Read(DeviceAddr, FT3X67_CHIP_ID_REG));
}
/**
* @brief Configures the touch Screen IC device to start detecting touches
* @param DeviceAddr: Device address on communication Bus (I2C slave address).
* @retval None.
*/
void ft3x67_TS_Start(uint16_t DeviceAddr)
{
/* Minimum static configuration of FT3X67 */
ft3x67_TS_Configure(DeviceAddr);
/* By default set FT3X67 IC in Polling mode : no INT generation on FT3X67 for new touch available */
/* Note TS_INT is active low */
ft3x67_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 ft3x67_TS_DetectTouch(uint16_t DeviceAddr)
{
volatile uint8_t nbTouch = 0U;
/* Read register FT3X67_TD_STAT_REG to check number of touches detection */
nbTouch = TS_IO_Read(DeviceAddr, FT3X67_TD_STAT_REG);
nbTouch &= FT3X67_TD_STAT_MASK;
if(nbTouch > FT3X67_MAX_DETECTABLE_TOUCH)
{
/* If invalid number of touch detected, set it to zero */
nbTouch = 0U;
}
/* Update ft3x67 driver internal global : current number of active touches */
ft3x67_handle.currActiveTouchNb = nbTouch;
/* Reset current active touch index on which to work on */
ft3x67_handle.currActiveTouchIdx = 0U;
return(nbTouch);
}
/**
* @brief Get the touch screen X and Y positions values
* Manage multi touch thanks to touch Index global
* variable 'ft3x67_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 ft3x67_TS_GetXY(uint16_t DeviceAddr, uint16_t *X, uint16_t *Y)
{
uint8_t regAddress = 0U;
uint8_t dataxy[4U];
if(ft3x67_handle.currActiveTouchIdx < ft3x67_handle.currActiveTouchNb)
{
switch(ft3x67_handle.currActiveTouchIdx)
{
case 0U :
regAddress = FT3X67_P1_XH_REG;
break;
case 1U :
regAddress = FT3X67_P2_XH_REG;
break;
default :
break;
} /* end switch(ft3x67_handle.currActiveTouchIdx) */
/* Read X and Y positions */
TS_IO_ReadMultiple(DeviceAddr, regAddress, dataxy, sizeof(dataxy));
/* Send back ready X position to caller */
*X = ((dataxy[0U] & FT3X67_TOUCH_POS_MSB_MASK) << 8U) | dataxy[1U];
/* Send back ready Y position to caller */
*Y = ((dataxy[2U] & FT3X67_TOUCH_POS_MSB_MASK) << 8U) | dataxy[3U];
/* Increment current touch index */
ft3x67_handle.currActiveTouchIdx++;
}
}
/**
* @brief Configure the FT3X67 device to generate IT on given INT pin
* connected to MCU as EXTI.
* @param DeviceAddr: Device address on communication Bus (Slave I2C address of FT3X67).
* @retval None
*/
void ft3x67_TS_EnableIT(uint16_t DeviceAddr)
{
/* Set interrupt trigger mode in FT3X67_GMODE_REG */
TS_IO_Write(DeviceAddr, FT3X67_GMODE_REG, FT3X67_G_MODE_INTERRUPT_TRIGGER);
}
/**
* @brief Configure the FT3X67 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 FT3X67).
* @retval None
*/
void ft3x67_TS_DisableIT(uint16_t DeviceAddr)
{
/* Set interrupt polling mode in FT3X67_GMODE_REG */
TS_IO_Write(DeviceAddr, FT3X67_GMODE_REG, FT3X67_G_MODE_INTERRUPT_POLLING);
}
/**
* @brief Get IT status from FT3X67 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 FT3X67.
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT3X67).
* @retval TS interrupts status : always return 0 here
*/
uint8_t ft3x67_TS_ITStatus(uint16_t DeviceAddr)
{
/* Always return 0 as feature not applicable to FT3X67 */
return 0U;
}
/**
* @brief Clear IT status in FT3X67 interrupt status clear registers
* Should be called Following an EXTI coming to the MCU.
* @note : This feature is not applicable to FT3X67.
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT3X67).
* @retval None
*/
void ft3x67_TS_ClearIT(uint16_t DeviceAddr)
{
/* Nothing to be done here for FT3X67 */
}
/**
* @brief Configure gesture feature (enable/disable).
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT3X67).
* @param Activation : Enable or disable gesture feature. Possible values are
* FT3X67_GESTURE_DISABLE or FT3X67_GESTURE_ENABLE.
* @retval None.
*/
void ft3x67_TS_GestureConfig(uint16_t DeviceAddr, uint32_t Activation)
{
if(Activation == FT3X67_GESTURE_ENABLE)
{
/* Enable gesture feature. */
TS_IO_Write(DeviceAddr, FT3X67_GESTURE_FLAG_REG, FT3X67_GEST_ALL_FLAGS_ENABLE);
TS_IO_Write(DeviceAddr, FT3X67_GESTURE_ENABLE_REG, FT3X67_GESTURE_ENABLE);
}
else
{
/* Disable gesture feature. */
TS_IO_Write(DeviceAddr, FT3X67_GESTURE_FLAG_REG, FT3X67_GEST_ALL_FLAGS_DISABLE);
TS_IO_Write(DeviceAddr, FT3X67_GESTURE_ENABLE_REG, FT3X67_GESTURE_DISABLE);
}
}
/**
* @brief Get the last touch gesture identification (zoom, move up/down...).
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT3X67).
* @param pGestureId : Pointer to get last touch gesture Identification.
* @retval None.
*/
void ft3x67_TS_GetGestureID(uint16_t DeviceAddr, uint32_t * pGestureId)
{
volatile uint8_t ucReadData = 0U;
ucReadData = TS_IO_Read(DeviceAddr, FT3X67_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 FT3X67).
* @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'.
* @note Area and Weight features are not supported by FT3X67. Return always 0 value.
* @retval None.
*/
void ft3x67_TS_GetTouchInfo(uint16_t DeviceAddr,
uint32_t touchIdx,
uint32_t * pWeight,
uint32_t * pArea,
uint32_t * pEvent)
{
volatile uint8_t ucReadData = 0U;
uint8_t regAddressXHigh = 0U;
if(touchIdx < ft3x67_handle.currActiveTouchNb)
{
switch(touchIdx)
{
case 0U :
regAddressXHigh = FT3X67_P1_XH_REG;
break;
case 1U :
regAddressXHigh = FT3X67_P2_XH_REG;
break;
default :
break;
} /* end switch(touchIdx) */
/* Read Event Id of touch index */
ucReadData = TS_IO_Read(DeviceAddr, regAddressXHigh);
*pEvent = (ucReadData & FT3X67_TOUCH_EVT_FLAG_MASK) >> FT3X67_TOUCH_EVT_FLAG_SHIFT;
/* Weight and area of touch index not supported by FT3X67 */
*pWeight = 0;
*pArea = 0;
} /* of if(touchIdx < ft3x67_handle.currActiveTouchNb) */
}
/**
* @}
*/
/* Private functions bodies---------------------------------------------------*/
/** @addtogroup FT3X67_Private_Functions
* @{
*/
/**
* @brief Return the status of I2C was initialized or not.
* @param None.
* @retval : I2C initialization status.
*/
static uint8_t ft3x67_Get_I2C_InitializedStatus(void)
{
return(ft3x67_handle.i2cInitialized);
}
/**
* @brief I2C initialize if needed.
* @param None.
* @retval : None.
*/
static void ft3x67_I2C_InitializeIfRequired(void)
{
if(ft3x67_Get_I2C_InitializedStatus() == FT3X67_I2C_NOT_INITIALIZED)
{
/* Initialize TS IO BUS layer (I2C) */
TS_IO_Init();
/* Set state to initialized */
ft3x67_handle.i2cInitialized = FT3X67_I2C_INITIALIZED;
}
}
/**
* @brief Basic static configuration of TouchScreen
* @param DeviceAddr: FT3X67 Device address for communication on I2C Bus.
* @retval Status FT3X67_STATUS_OK or FT3X67_STATUS_NOT_OK.
*/
static uint32_t ft3x67_TS_Configure(uint16_t DeviceAddr)
{
uint32_t status = FT3X67_STATUS_OK;
/* Disable gesture feature */
TS_IO_Write(DeviceAddr, FT3X67_GESTURE_ENABLE_REG, FT3X67_GESTURE_DISABLE);
return(status);
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
+270
View File
@@ -0,0 +1,270 @@
/**
******************************************************************************
* @file ft3x67.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the
* ft3x67.c touch screen driver.
******************************************************************************
* @attention
*
* Copyright (c) 2017 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __FT3X67_H
#define __FT3X67_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "../Common/ts.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup Component
* @{
*/
/** @defgroup FT3X67
* @{
*/
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/** @defgroup FT3X67_Exported_Constants
* @{
*/
/* Maximum border values of the touchscreen pad */
#define FT3X67_MAX_WIDTH 390U /* Touchscreen pad max width */
#define FT3X67_MAX_HEIGHT 390U /* Touchscreen pad max height */
/* Possible values of driver functions return status */
#define FT3X67_STATUS_OK 0x00U
#define FT3X67_STATUS_NOT_OK 0x01U
/* Possible values of global variable 'TS_I2C_Initialized' */
#define FT3X67_I2C_NOT_INITIALIZED 0x00U
#define FT3X67_I2C_INITIALIZED 0x01U
/* Max detectable simultaneous touches */
#define FT3X67_MAX_DETECTABLE_TOUCH 0x02U
/* Definitions for FT3X67 registers */
/* Current mode register of the FT3X67 (R/W) */
#define FT3X67_DEV_MODE_REG 0x00U
/* Possible values of FT3X67_DEV_MODE_REG */
#define FT3X67_DEV_MODE_WORKING 0x00U
#define FT3X67_DEV_MODE_FACTORY 0x40U
/* Touch Data Status register : gives number of active touch points (0..2) */
#define FT3X67_TD_STAT_REG 0x02U
/* Values related to FT3X67_TD_STAT_REG */
#define FT3X67_TD_STAT_MASK 0x0FU
/* Values Pn_XH and Pn_YH related */
#define FT3X67_TOUCH_EVT_FLAG_PRESS_DOWN 0x00U
#define FT3X67_TOUCH_EVT_FLAG_LIFT_UP 0x01U
#define FT3X67_TOUCH_EVT_FLAG_CONTACT 0x02U
#define FT3X67_TOUCH_EVT_FLAG_NO_EVENT 0x03U
#define FT3X67_TOUCH_EVT_FLAG_SHIFT 0x06U
#define FT3X67_TOUCH_EVT_FLAG_MASK (3U << FT3X67_TOUCH_EVT_FLAG_SHIFT)
#define FT3X67_TOUCH_POS_MSB_MASK 0x0FU
/* Point 1 registers */
#define FT3X67_P1_XH_REG 0x03U
#define FT3X67_P1_XL_REG 0x04U
#define FT3X67_P1_YH_REG 0x05U
#define FT3X67_P1_YL_REG 0x06U
#define FT3X67_P1_WEIGHT_REG 0x07U
#define FT3X67_P1_MISC_REG 0x08U
/* Point 2 registers */
#define FT3X67_P2_XH_REG 0x09U
#define FT3X67_P2_XL_REG 0x0AU
#define FT3X67_P2_YH_REG 0x0BU
#define FT3X67_P2_YL_REG 0x0CU
#define FT3X67_P2_WEIGHT_REG 0x0DU
#define FT3X67_P2_MISC_REG 0x0EU
/* Values related to Pn_MISC register */
#define FT3X67_TOUCH_AREA_MASK (0xFU << FT3X67_TOUCH_AREA_SHIFT)
#define FT3X67_TOUCH_AREA_SHIFT 0x04U
/* Threshold for touch detection register */
#define FT3X67_TH_GROUP_REG 0x80U
/* Filter function coefficients register */
#define FT3X67_TH_DIFF_REG 0x85U
/* Control register */
#define FT3X67_CTRL_REG 0x86U
/* Values related to FT3X67_CTRL_REG */
#define FT3X67_CTRL_KEEP_ACTIVE_MODE 0x00U
#define FT3X67_CTRL_KEEP_AUTO_SWITCH_MONITOR_MODE 0x01U
/* The time period of switching from Active mode to Monitor mode when there is no touching */
#define FT3X67_TIMEENTERMONITOR_REG 0x87U
/* Report rate in Active mode */
#define FT3X67_PERIODACTIVE_REG 0x88U
/* Report rate in Monitor mode */
#define FT3X67_PERIODMONITOR_REG 0x89U
/* High 8-bit of LIB Version info */
#define FT3X67_LIB_VER_H_REG 0xA1U
/* Low 8-bit of LIB Version info */
#define FT3X67_LIB_VER_L_REG 0xA2U
/* Chip Selecting */
#define FT3X67_CIPHER_REG 0xA3U
/* Interrupt mode register (used when in interrupt mode) */
#define FT3X67_GMODE_REG 0xA4U
/* Possible values of FT3X67_GMODE_REG */
#define FT3X67_G_MODE_INTERRUPT_POLLING 0x00U
#define FT3X67_G_MODE_INTERRUPT_TRIGGER 0x01U
/* Current power mode */
#define FT3X67_PWR_MODE_REG 0xA5U
/* Firmware version */
#define FT3X67_FIRMID_REG 0xA6U
/* Chip identification register */
#define FT3X67_CHIP_ID_REG 0xA8U
/* Possible values of FT3X67_CHIP_ID_REG */
#define FT3X67_ID_VALUE 0x11U
/* Release code version */
#define FT3X67_RELEASE_CODE_ID_REG 0xAFU
/* Current operating mode register */
#define FT3X67_STATE_REG 0xBCU
/* Possible values of FT3X67_STATE_REG */
#define FT3X67_STATE_INFO_MODE 0x00U
#define FT3X67_STATE_NORMAL_MODE 0x01U
#define FT3X67_STATE_FACTORY_MODE 0x03U
#define FT3X67_STATE_AUTO_CALIB_MODE 0x04U
/* Gesture enable register */
#define FT3X67_GESTURE_ENABLE_REG 0xD0U
/* Possible values of FT3X67_GESTURE_ENABLE_REG */
#define FT3X67_GESTURE_DISABLE 0x00U
#define FT3X67_GESTURE_ENABLE 0x01U
/* Gesture flag register */
#define FT3X67_GESTURE_FLAG_REG 0xD1U
/* Possible values of FT3X67_GESTURE_FLAG_REG can be any combination of following values */
#define FT3X67_GEST_LINE_RIGHT_TO_LEFT_ENABLE 0x01U
#define FT3X67_GEST_LINE_LEFT_TO_RIGHT_ENABLE 0x02U
#define FT3X67_GEST_LINE_DOWN_TO_UP_ENABLE 0x04U
#define FT3X67_GEST_LINE_UP_TO_DOWN_ENABLE 0x08U
#define FT3X67_GEST_DOUBLE_TAP_ENABLE 0x10U
#define FT3X67_GEST_ALL_FLAGS_ENABLE 0x1FU
#define FT3X67_GEST_ALL_FLAGS_DISABLE 0x00U
/* Gesture ID register */
#define FT3X67_GEST_ID_REG 0xD3U
/* Possible values of FT3X67_GEST_ID_REG */
#define FT3X67_GEST_ID_NO_GESTURE 0x00U
#define FT3X67_GEST_ID_MOVE_UP 0x22U
#define FT3X67_GEST_ID_MOVE_RIGHT 0x21U
#define FT3X67_GEST_ID_MOVE_DOWN 0x23U
#define FT3X67_GEST_ID_MOVE_LEFT 0x20U
#define FT3X67_GEST_ID_DOUBLE_CLICK 0x24U
/**
* @}
*/
/* Exported macro ------------------------------------------------------------*/
/* Exported functions --------------------------------------------------------*/
/** @defgroup FT3X67_Exported_Functions
* @{
*/
void ft3x67_Init(uint16_t DeviceAddr);
void ft3x67_Reset(uint16_t DeviceAddr);
uint16_t ft3x67_ReadID(uint16_t DeviceAddr);
void ft3x67_TS_Start(uint16_t DeviceAddr);
uint8_t ft3x67_TS_DetectTouch(uint16_t DeviceAddr);
void ft3x67_TS_GetXY(uint16_t DeviceAddr, uint16_t *X, uint16_t *Y);
void ft3x67_TS_EnableIT(uint16_t DeviceAddr);
void ft3x67_TS_DisableIT(uint16_t DeviceAddr);
uint8_t ft3x67_TS_ITStatus (uint16_t DeviceAddr);
void ft3x67_TS_ClearIT (uint16_t DeviceAddr);
void ft3x67_TS_GestureConfig(uint16_t DeviceAddr, uint32_t Activation);
void ft3x67_TS_GetGestureID(uint16_t DeviceAddr, uint32_t * pGestureId);
void ft3x67_TS_GetTouchInfo(uint16_t DeviceAddr,
uint32_t touchIdx,
uint32_t * pWeight,
uint32_t * pArea,
uint32_t * pEvent);
/**
* @}
*/
/* Imported TS IO functions --------------------------------------------------------*/
/** @defgroup FT3X67_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 uint16_t TS_IO_ReadMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length);
extern void TS_IO_Delay(uint32_t Delay);
/**
* @}
*/
/* Imported global variables --------------------------------------------------------*/
/** @defgroup FT3X67_Imported_Globals
* @{
*/
/* Touch screen driver structure */
extern TS_DrvTypeDef ft3x67_ts_drv;
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __FT3X67_H */