p3 fin
This commit is contained in:
82
P3_SETR2/Components/ft6x06/Release_Notes.html
Normal file
82
P3_SETR2/Components/ft6x06/Release_Notes.html
Normal file
@@ -0,0 +1,82 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="generator" content="pandoc" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
|
||||
<title>Release Notes for FT6X06 Component Drivers</title>
|
||||
<style type="text/css">
|
||||
code{white-space: pre-wrap;}
|
||||
span.smallcaps{font-variant: small-caps;}
|
||||
span.underline{text-decoration: underline;}
|
||||
div.column{display: inline-block; vertical-align: top; width: 50%;}
|
||||
</style>
|
||||
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
|
||||
<![endif]-->
|
||||
</head>
|
||||
<body>
|
||||
<div class="row">
|
||||
<div class="col-sm-12 col-lg-4">
|
||||
<div class="card fluid">
|
||||
<div class="sectione dark">
|
||||
<center>
|
||||
<h1 id="release-notes-for-ft6x06-component-drivers"><small>Release Notes for</small> <mark>FT6X06 Component Drivers</mark></h1>
|
||||
<p>Copyright © 2016 STMicroelectronics<br />
|
||||
</p>
|
||||
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
|
||||
</center>
|
||||
</div>
|
||||
</div>
|
||||
<h1 id="license">License</h1>
|
||||
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
|
||||
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
|
||||
<h1 id="purpose">Purpose</h1>
|
||||
<p>This directory contains the FT6X06 component drivers.</p>
|
||||
</div>
|
||||
<div class="col-sm-12 col-lg-8">
|
||||
<h1 id="update-history">Update History</h1>
|
||||
<div class="collapse">
|
||||
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V1.0.3 / 03-April-2019</label>
|
||||
<div>
|
||||
<h2 id="main-changes">Main Changes</h2>
|
||||
<ul>
|
||||
<li>Update release notes format</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="collapse">
|
||||
<input type="checkbox" id="collapse-section20" aria-hidden="true"> <label for="collapse-section20" aria-hidden="true">V1.0.2 / 31-August-2018</label>
|
||||
<div>
|
||||
<h2 id="main-changes-1">Main Changes</h2>
|
||||
<ul>
|
||||
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="collapse">
|
||||
<input type="checkbox" id="collapse-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V1.0.1 / 03-May-2016</label>
|
||||
<div>
|
||||
<h2 id="main-changes-2">Main Changes</h2>
|
||||
<ul>
|
||||
<li>Add support of FT6x36 Touch controller</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="collapse">
|
||||
<input type="checkbox" id="collapse-section18" aria-hidden="true"> <label for="collapse-section18" aria-hidden="true">V1.0.0 / 03-August-2015</label>
|
||||
<div>
|
||||
<h2 id="main-changes-3">Main Changes</h2>
|
||||
<ul>
|
||||
<li>First official release</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<footer class="sticky">
|
||||
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
496
P3_SETR2/Components/ft6x06/ft6x06.c
Normal file
496
P3_SETR2/Components/ft6x06/ft6x06.c
Normal file
@@ -0,0 +1,496 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file ft6x06.c
|
||||
* @author MCD Application Team
|
||||
* @brief This file provides a set of functions needed to manage the FT6X06
|
||||
* IO Expander devices.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2016 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
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "ft6x06.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup Component
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup FT6X06
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
|
||||
/** @defgroup FT6X06_Private_Defines FT6X06 Private Defines
|
||||
* @{
|
||||
*/
|
||||
#define FT6x06_MAX_INSTANCE 2
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
|
||||
/** @defgroup FT6X06_Private_Variables FT6X06 Private Variables
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Touch screen driver structure initialization */
|
||||
TS_DrvTypeDef ft6x06_ts_drv =
|
||||
{
|
||||
ft6x06_Init,
|
||||
ft6x06_ReadID,
|
||||
ft6x06_Reset,
|
||||
|
||||
ft6x06_TS_Start,
|
||||
ft6x06_TS_DetectTouch,
|
||||
ft6x06_TS_GetXY,
|
||||
|
||||
ft6x06_TS_EnableIT,
|
||||
ft6x06_TS_ClearIT,
|
||||
ft6x06_TS_ITStatus,
|
||||
ft6x06_TS_DisableIT
|
||||
};
|
||||
|
||||
/* ft6x06 instances by address */
|
||||
uint8_t ft6x06[FT6x06_MAX_INSTANCE] = {0};
|
||||
|
||||
/* Global ft6x06 handle */
|
||||
static ft6x06_handle_TypeDef ft6x06_handle = { FT6206_I2C_NOT_INITIALIZED, 0, 0};
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ft6x06_Private_Function_Prototypes ft6x06 Private Function Prototypes
|
||||
* @{
|
||||
*/
|
||||
static uint8_t ft6x06_GetInstance(uint16_t DeviceAddr);
|
||||
/* Private functions prototypes-----------------------------------------------*/
|
||||
#if (TS_AUTO_CALIBRATION_SUPPORTED == 1)
|
||||
/**
|
||||
* @brief Start TouchScreen calibration phase
|
||||
* @param DeviceAddr: FT6206 Device address for communication on I2C Bus.
|
||||
* @retval Status FT6206_STATUS_OK or FT6206_STATUS_NOT_OK.
|
||||
*/
|
||||
static uint32_t ft6x06_TS_Calibration(uint16_t DeviceAddr);
|
||||
#endif /* TS_AUTO_CALIBRATION_SUPPORTED == 1 */
|
||||
|
||||
/**
|
||||
* @brief Basic static configuration of TouchScreen
|
||||
* @param DeviceAddr: FT6206 Device address for communication on I2C Bus.
|
||||
* @retval Status FT6206_STATUS_OK or FT6206_STATUS_NOT_OK.
|
||||
*/
|
||||
static uint32_t ft6x06_TS_Configure(uint16_t DeviceAddr);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ft6x06_Private_Functions ft6x06 Private Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Initialize the ft6x06 communication bus
|
||||
* from MCU to FT6206 : ie I2C channel initialization (if required).
|
||||
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6206).
|
||||
* @retval None
|
||||
*/
|
||||
void ft6x06_Init(uint16_t DeviceAddr)
|
||||
{
|
||||
uint8_t instance;
|
||||
uint8_t empty;
|
||||
|
||||
/* Check if device instance already exists */
|
||||
instance = ft6x06_GetInstance(DeviceAddr);
|
||||
|
||||
/* To prevent double initialization */
|
||||
if(instance == 0xFF)
|
||||
{
|
||||
/* Look for empty instance */
|
||||
empty = ft6x06_GetInstance(0);
|
||||
|
||||
if(empty < FT6x06_MAX_INSTANCE)
|
||||
{
|
||||
/* Register the current device instance */
|
||||
ft6x06[empty] = DeviceAddr;
|
||||
|
||||
/* Initialize IO BUS layer */
|
||||
TS_IO_Init();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Software Reset the ft6x06.
|
||||
* @note : Not applicable to FT6206.
|
||||
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6206).
|
||||
* @retval None
|
||||
*/
|
||||
void ft6x06_Reset(uint16_t DeviceAddr)
|
||||
{
|
||||
/* Do nothing */
|
||||
/* No software reset sequence available in FT6206 IC */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read the ft6x06 device ID, pre initialize I2C in case of need to be
|
||||
* able to read the FT6206 device ID, and verify this is a FT6206.
|
||||
* @param DeviceAddr: I2C FT6x06 Slave address.
|
||||
* @retval The Device ID (two bytes).
|
||||
*/
|
||||
uint16_t ft6x06_ReadID(uint16_t DeviceAddr)
|
||||
{
|
||||
/* Initialize I2C link if needed */
|
||||
TS_IO_Init();
|
||||
|
||||
/* Return the device ID value */
|
||||
return (TS_IO_Read(DeviceAddr, FT6206_CHIP_ID_REG));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configures the touch Screen IC device to start detecting touches
|
||||
* It goes through an internal calibration process (Hw calibration sequence of
|
||||
* the touch screen).
|
||||
* @param DeviceAddr: Device address on communication Bus (I2C slave address).
|
||||
* @retval None.
|
||||
*/
|
||||
void ft6x06_TS_Start(uint16_t DeviceAddr)
|
||||
{
|
||||
#if (TS_AUTO_CALIBRATION_SUPPORTED == 1)
|
||||
/* Hw Calibration sequence start : should be done once after each power up */
|
||||
/* This is called internal calibration of the touch screen */
|
||||
ft6x06_TS_Calibration(DeviceAddr);
|
||||
#endif
|
||||
/* Minimum static configuration of FT6206 */
|
||||
ft6x06_TS_Configure(DeviceAddr);
|
||||
|
||||
/* By default set FT6206 IC in Polling mode : no INT generation on FT6206 for new touch available */
|
||||
/* Note TS_INT is active low */
|
||||
ft6x06_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 ft6x06_TS_DetectTouch(uint16_t DeviceAddr)
|
||||
{
|
||||
volatile uint8_t nbTouch = 0;
|
||||
|
||||
/* Read register FT6206_TD_STAT_REG to check number of touches detection */
|
||||
nbTouch = TS_IO_Read(DeviceAddr, FT6206_TD_STAT_REG);
|
||||
nbTouch &= FT6206_TD_STAT_MASK;
|
||||
|
||||
if(nbTouch > FT6206_MAX_DETECTABLE_TOUCH)
|
||||
{
|
||||
/* If invalid number of touch detected, set it to zero */
|
||||
nbTouch = 0;
|
||||
}
|
||||
|
||||
/* Update ft6x06 driver internal global : current number of active touches */
|
||||
ft6x06_handle.currActiveTouchNb = nbTouch;
|
||||
|
||||
/* Reset current active touch index on which to work on */
|
||||
ft6x06_handle.currActiveTouchIdx = 0;
|
||||
|
||||
return(nbTouch);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the touch screen X and Y positions values
|
||||
* Manage multi touch thanks to touch Index global
|
||||
* variable 'ft6x06_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 ft6x06_TS_GetXY(uint16_t DeviceAddr, uint16_t *X, uint16_t *Y)
|
||||
{
|
||||
uint8_t regAddress = 0;
|
||||
uint8_t dataxy[4];
|
||||
|
||||
if(ft6x06_handle.currActiveTouchIdx < ft6x06_handle.currActiveTouchNb)
|
||||
{
|
||||
switch(ft6x06_handle.currActiveTouchIdx)
|
||||
{
|
||||
case 0 :
|
||||
regAddress = FT6206_P1_XH_REG;
|
||||
break;
|
||||
case 1 :
|
||||
regAddress = FT6206_P2_XH_REG;
|
||||
break;
|
||||
|
||||
default :
|
||||
break;
|
||||
}
|
||||
|
||||
/* Read X and Y positions */
|
||||
TS_IO_ReadMultiple(DeviceAddr, regAddress, dataxy, sizeof(dataxy));
|
||||
|
||||
/* Send back ready X position to caller */
|
||||
*X = ((dataxy[0] & FT6206_MSB_MASK) << 8) | (dataxy[1] & FT6206_LSB_MASK);
|
||||
|
||||
/* Send back ready Y position to caller */
|
||||
*Y = ((dataxy[2] & FT6206_MSB_MASK) << 8) | (dataxy[3] & FT6206_LSB_MASK);
|
||||
|
||||
ft6x06_handle.currActiveTouchIdx++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure the FT6206 device to generate IT on given INT pin
|
||||
* connected to MCU as EXTI.
|
||||
* @param DeviceAddr: Device address on communication Bus (Slave I2C address of FT6206).
|
||||
* @retval None
|
||||
*/
|
||||
void ft6x06_TS_EnableIT(uint16_t DeviceAddr)
|
||||
{
|
||||
uint8_t regValue = 0;
|
||||
regValue = (FT6206_G_MODE_INTERRUPT_TRIGGER & (FT6206_G_MODE_INTERRUPT_MASK >> FT6206_G_MODE_INTERRUPT_SHIFT)) << FT6206_G_MODE_INTERRUPT_SHIFT;
|
||||
|
||||
/* Set interrupt trigger mode in FT6206_GMODE_REG */
|
||||
TS_IO_Write(DeviceAddr, FT6206_GMODE_REG, regValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure the FT6206 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 FT6206).
|
||||
* @retval None
|
||||
*/
|
||||
void ft6x06_TS_DisableIT(uint16_t DeviceAddr)
|
||||
{
|
||||
uint8_t regValue = 0;
|
||||
regValue = (FT6206_G_MODE_INTERRUPT_POLLING & (FT6206_G_MODE_INTERRUPT_MASK >> FT6206_G_MODE_INTERRUPT_SHIFT)) << FT6206_G_MODE_INTERRUPT_SHIFT;
|
||||
|
||||
/* Set interrupt polling mode in FT6206_GMODE_REG */
|
||||
TS_IO_Write(DeviceAddr, FT6206_GMODE_REG, regValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get IT status from FT6206 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 FT6206.
|
||||
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6206).
|
||||
* @retval TS interrupts status : always return 0 here
|
||||
*/
|
||||
uint8_t ft6x06_TS_ITStatus(uint16_t DeviceAddr)
|
||||
{
|
||||
/* Always return 0 as feature not applicable to FT6206 */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear IT status in FT6206 interrupt status clear registers
|
||||
* Should be called Following an EXTI coming to the MCU.
|
||||
* @note : This feature is not applicable to FT6206.
|
||||
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6206).
|
||||
* @retval None
|
||||
*/
|
||||
void ft6x06_TS_ClearIT(uint16_t DeviceAddr)
|
||||
{
|
||||
/* Nothing to be done here for FT6206 */
|
||||
}
|
||||
|
||||
/**** 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 FT6x06).
|
||||
* @param pGestureId : Pointer to get last touch gesture Identification.
|
||||
* @retval None.
|
||||
*/
|
||||
void ft6x06_TS_GetGestureID(uint16_t DeviceAddr, uint32_t * pGestureId)
|
||||
{
|
||||
volatile uint8_t ucReadData = 0;
|
||||
|
||||
ucReadData = TS_IO_Read(DeviceAddr, FT6206_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 FT6x06).
|
||||
* @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 ft6x06_TS_GetTouchInfo(uint16_t DeviceAddr,
|
||||
uint32_t touchIdx,
|
||||
uint32_t * pWeight,
|
||||
uint32_t * pArea,
|
||||
uint32_t * pEvent)
|
||||
{
|
||||
uint8_t regAddress = 0;
|
||||
uint8_t dataxy[3];
|
||||
|
||||
if(touchIdx < ft6x06_handle.currActiveTouchNb)
|
||||
{
|
||||
switch(touchIdx)
|
||||
{
|
||||
case 0 :
|
||||
regAddress = FT6206_P1_WEIGHT_REG;
|
||||
break;
|
||||
|
||||
case 1 :
|
||||
regAddress = FT6206_P2_WEIGHT_REG;
|
||||
break;
|
||||
|
||||
default :
|
||||
break;
|
||||
|
||||
} /* end switch(touchIdx) */
|
||||
|
||||
/* Read weight, area and Event Id of touch index */
|
||||
TS_IO_ReadMultiple(DeviceAddr, regAddress, dataxy, sizeof(dataxy));
|
||||
|
||||
/* Return weight of touch index */
|
||||
* pWeight = (dataxy[0] & FT6206_TOUCH_WEIGHT_MASK) >> FT6206_TOUCH_WEIGHT_SHIFT;
|
||||
/* Return area of touch index */
|
||||
* pArea = (dataxy[1] & FT6206_TOUCH_AREA_MASK) >> FT6206_TOUCH_AREA_SHIFT;
|
||||
/* Return Event Id of touch index */
|
||||
* pEvent = (dataxy[2] & FT6206_TOUCH_EVT_FLAG_MASK) >> FT6206_TOUCH_EVT_FLAG_SHIFT;
|
||||
|
||||
} /* of if(touchIdx < ft6x06_handle.currActiveTouchNb) */
|
||||
}
|
||||
|
||||
#endif /* TS_MULTI_TOUCH_SUPPORTED == 1 */
|
||||
|
||||
#if (TS_AUTO_CALIBRATION_SUPPORTED == 1)
|
||||
/**
|
||||
* @brief Start TouchScreen calibration phase
|
||||
* @param DeviceAddr: FT6206 Device address for communication on I2C Bus.
|
||||
* @retval Status FT6206_STATUS_OK or FT6206_STATUS_NOT_OK.
|
||||
*/
|
||||
static uint32_t ft6x06_TS_Calibration(uint16_t DeviceAddr)
|
||||
{
|
||||
uint32_t nbAttempt = 0;
|
||||
volatile uint8_t ucReadData;
|
||||
volatile uint8_t regValue;
|
||||
uint32_t status = FT6206_STATUS_OK;
|
||||
uint8_t bEndCalibration = 0;
|
||||
|
||||
/* >> Calibration sequence start */
|
||||
|
||||
/* Switch FT6206 back to factory mode to calibrate */
|
||||
regValue = (FT6206_DEV_MODE_FACTORY & FT6206_DEV_MODE_MASK) << FT6206_DEV_MODE_SHIFT;
|
||||
TS_IO_Write(DeviceAddr, FT6206_DEV_MODE_REG, regValue); /* 0x40 */
|
||||
|
||||
/* Read back the same register FT6206_DEV_MODE_REG */
|
||||
ucReadData = TS_IO_Read(DeviceAddr, FT6206_DEV_MODE_REG);
|
||||
TS_IO_Delay(300); /* Wait 300 ms */
|
||||
|
||||
if(((ucReadData & (FT6206_DEV_MODE_MASK << FT6206_DEV_MODE_SHIFT)) >> FT6206_DEV_MODE_SHIFT) != FT6206_DEV_MODE_FACTORY )
|
||||
{
|
||||
/* Return error to caller */
|
||||
return(FT6206_STATUS_NOT_OK);
|
||||
}
|
||||
|
||||
/* Start calibration command */
|
||||
TS_IO_Write(DeviceAddr, FT6206_TD_STAT_REG, 0x04);
|
||||
TS_IO_Delay(300); /* Wait 300 ms */
|
||||
|
||||
/* 100 attempts to wait switch from factory mode (calibration) to working mode */
|
||||
for (nbAttempt=0; ((nbAttempt < 100) && (!bEndCalibration)) ; nbAttempt++)
|
||||
{
|
||||
ucReadData = TS_IO_Read(DeviceAddr, FT6206_DEV_MODE_REG);
|
||||
ucReadData = (ucReadData & (FT6206_DEV_MODE_MASK << FT6206_DEV_MODE_SHIFT)) >> FT6206_DEV_MODE_SHIFT;
|
||||
if(ucReadData == FT6206_DEV_MODE_WORKING)
|
||||
{
|
||||
/* Auto Switch to FT6206_DEV_MODE_WORKING : means calibration have ended */
|
||||
bEndCalibration = 1; /* exit for loop */
|
||||
}
|
||||
|
||||
TS_IO_Delay(200); /* Wait 200 ms */
|
||||
}
|
||||
|
||||
/* Calibration sequence end << */
|
||||
|
||||
return(status);
|
||||
}
|
||||
#endif /* TS_AUTO_CALIBRATION_SUPPORTED == 1 */
|
||||
|
||||
/**
|
||||
* @brief Basic static configuration of TouchScreen
|
||||
* @param DeviceAddr: FT6206 Device address for communication on I2C Bus.
|
||||
* @retval Status FT6206_STATUS_OK or FT6206_STATUS_NOT_OK.
|
||||
*/
|
||||
static uint32_t ft6x06_TS_Configure(uint16_t DeviceAddr)
|
||||
{
|
||||
uint32_t status = FT6206_STATUS_OK;
|
||||
|
||||
/* Nothing special to be done for FT6206 */
|
||||
|
||||
return(status);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if the device instance of the selected address is already registered
|
||||
* and return its index
|
||||
* @param DeviceAddr: Device address on communication Bus.
|
||||
* @retval Index of the device instance if registered, 0xFF if not.
|
||||
*/
|
||||
static uint8_t ft6x06_GetInstance(uint16_t DeviceAddr)
|
||||
{
|
||||
uint8_t idx = 0;
|
||||
|
||||
/* Check all the registered instances */
|
||||
for(idx = 0; idx < FT6x06_MAX_INSTANCE ; idx ++)
|
||||
{
|
||||
if(ft6x06[idx] == DeviceAddr)
|
||||
{
|
||||
return idx;
|
||||
}
|
||||
}
|
||||
|
||||
return 0xFF;
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
453
P3_SETR2/Components/ft6x06/ft6x06.h
Normal file
453
P3_SETR2/Components/ft6x06/ft6x06.h
Normal file
@@ -0,0 +1,453 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file ft6x06.h
|
||||
* @author MCD Application Team
|
||||
* @brief This file contains all the functions prototypes for the
|
||||
* ft6x06.c IO expander driver.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2016 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
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __FT6X06_H
|
||||
#define __FT6X06_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Set Multi-touch as non supported */
|
||||
#ifndef TS_MULTI_TOUCH_SUPPORTED
|
||||
#define TS_MULTI_TOUCH_SUPPORTED 0
|
||||
#endif
|
||||
|
||||
/* Set Auto-calibration as non supported */
|
||||
#ifndef TS_AUTO_CALIBRATION_SUPPORTED
|
||||
#define TS_AUTO_CALIBRATION_SUPPORTED 0
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "../Common/ts.h"
|
||||
|
||||
/* Macros --------------------------------------------------------------------*/
|
||||
|
||||
/** @typedef ft6x06_handle_TypeDef
|
||||
* ft6x06 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;
|
||||
|
||||
} ft6x06_handle_TypeDef;
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup Component
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup FT6X06
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
|
||||
/** @defgroup FT6X06_Exported_Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
||||
/** @defgroup FT6X06_Exported_Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Maximum border values of the touchscreen pad */
|
||||
#define FT_6206_MAX_WIDTH ((uint16_t)800) /* Touchscreen pad max width */
|
||||
#define FT_6206_MAX_HEIGHT ((uint16_t)480) /* Touchscreen pad max height */
|
||||
|
||||
/* Touchscreen pad max width and height values for FT6x36 Touch*/
|
||||
#define FT_6206_MAX_WIDTH_HEIGHT ((uint16_t)240)
|
||||
|
||||
/* Possible values of driver functions return status */
|
||||
#define FT6206_STATUS_OK 0
|
||||
#define FT6206_STATUS_NOT_OK 1
|
||||
|
||||
/* Possible values of global variable 'TS_I2C_Initialized' */
|
||||
#define FT6206_I2C_NOT_INITIALIZED 0
|
||||
#define FT6206_I2C_INITIALIZED 1
|
||||
|
||||
/* Max detectable simultaneous touches */
|
||||
#define FT6206_MAX_DETECTABLE_TOUCH 2
|
||||
|
||||
/**
|
||||
* @brief : Definitions for FT6206 I2C register addresses on 8 bit
|
||||
**/
|
||||
|
||||
/* Current mode register of the FT6206 (R/W) */
|
||||
#define FT6206_DEV_MODE_REG 0x00
|
||||
|
||||
/* Possible values of FT6206_DEV_MODE_REG */
|
||||
#define FT6206_DEV_MODE_WORKING 0x00
|
||||
#define FT6206_DEV_MODE_FACTORY 0x04
|
||||
|
||||
#define FT6206_DEV_MODE_MASK 0x7
|
||||
#define FT6206_DEV_MODE_SHIFT 4
|
||||
|
||||
/* Gesture ID register */
|
||||
#define FT6206_GEST_ID_REG 0x01
|
||||
|
||||
/* Possible values of FT6206_GEST_ID_REG */
|
||||
#define FT6206_GEST_ID_NO_GESTURE 0x00
|
||||
#define FT6206_GEST_ID_MOVE_UP 0x10
|
||||
#define FT6206_GEST_ID_MOVE_RIGHT 0x14
|
||||
#define FT6206_GEST_ID_MOVE_DOWN 0x18
|
||||
#define FT6206_GEST_ID_MOVE_LEFT 0x1C
|
||||
#define FT6206_GEST_ID_ZOOM_IN 0x48
|
||||
#define FT6206_GEST_ID_ZOOM_OUT 0x49
|
||||
|
||||
/* Touch Data Status register : gives number of active touch points (0..2) */
|
||||
#define FT6206_TD_STAT_REG 0x02
|
||||
|
||||
/* Values related to FT6206_TD_STAT_REG */
|
||||
#define FT6206_TD_STAT_MASK 0x0F
|
||||
#define FT6206_TD_STAT_SHIFT 0x00
|
||||
|
||||
/* Values Pn_XH and Pn_YH related */
|
||||
#define FT6206_TOUCH_EVT_FLAG_PRESS_DOWN 0x00
|
||||
#define FT6206_TOUCH_EVT_FLAG_LIFT_UP 0x01
|
||||
#define FT6206_TOUCH_EVT_FLAG_CONTACT 0x02
|
||||
#define FT6206_TOUCH_EVT_FLAG_NO_EVENT 0x03
|
||||
|
||||
#define FT6206_TOUCH_EVT_FLAG_SHIFT 6
|
||||
#define FT6206_TOUCH_EVT_FLAG_MASK (3 << FT6206_TOUCH_EVT_FLAG_SHIFT)
|
||||
|
||||
#define FT6206_MSB_MASK 0x0F
|
||||
#define FT6206_MSB_SHIFT 0
|
||||
|
||||
/* Values Pn_XL and Pn_YL related */
|
||||
#define FT6206_LSB_MASK 0xFF
|
||||
#define FT6206_LSB_SHIFT 0
|
||||
|
||||
#define FT6206_P1_XH_REG 0x03
|
||||
#define FT6206_P1_XL_REG 0x04
|
||||
#define FT6206_P1_YH_REG 0x05
|
||||
#define FT6206_P1_YL_REG 0x06
|
||||
|
||||
/* Touch Pressure register value (R) */
|
||||
#define FT6206_P1_WEIGHT_REG 0x07
|
||||
|
||||
/* Values Pn_WEIGHT related */
|
||||
#define FT6206_TOUCH_WEIGHT_MASK 0xFF
|
||||
#define FT6206_TOUCH_WEIGHT_SHIFT 0
|
||||
|
||||
/* Touch area register */
|
||||
#define FT6206_P1_MISC_REG 0x08
|
||||
|
||||
/* Values related to FT6206_Pn_MISC_REG */
|
||||
#define FT6206_TOUCH_AREA_MASK (0x04 << 4)
|
||||
#define FT6206_TOUCH_AREA_SHIFT 0x04
|
||||
|
||||
#define FT6206_P2_XH_REG 0x09
|
||||
#define FT6206_P2_XL_REG 0x0A
|
||||
#define FT6206_P2_YH_REG 0x0B
|
||||
#define FT6206_P2_YL_REG 0x0C
|
||||
#define FT6206_P2_WEIGHT_REG 0x0D
|
||||
#define FT6206_P2_MISC_REG 0x0E
|
||||
|
||||
/* Threshold for touch detection */
|
||||
#define FT6206_TH_GROUP_REG 0x80
|
||||
|
||||
/* Values FT6206_TH_GROUP_REG : threshold related */
|
||||
#define FT6206_THRESHOLD_MASK 0xFF
|
||||
#define FT6206_THRESHOLD_SHIFT 0
|
||||
|
||||
/* Filter function coefficients */
|
||||
#define FT6206_TH_DIFF_REG 0x85
|
||||
|
||||
/* Control register */
|
||||
#define FT6206_CTRL_REG 0x86
|
||||
|
||||
/* Values related to FT6206_CTRL_REG */
|
||||
|
||||
/* Will keep the Active mode when there is no touching */
|
||||
#define FT6206_CTRL_KEEP_ACTIVE_MODE 0x00
|
||||
|
||||
/* Switching from Active mode to Monitor mode automatically when there is no touching */
|
||||
#define FT6206_CTRL_KEEP_AUTO_SWITCH_MONITOR_MODE 0x01
|
||||
|
||||
/* The time period of switching from Active mode to Monitor mode when there is no touching */
|
||||
#define FT6206_TIMEENTERMONITOR_REG 0x87
|
||||
|
||||
/* Report rate in Active mode */
|
||||
#define FT6206_PERIODACTIVE_REG 0x88
|
||||
|
||||
/* Report rate in Monitor mode */
|
||||
#define FT6206_PERIODMONITOR_REG 0x89
|
||||
|
||||
/* The value of the minimum allowed angle while Rotating gesture mode */
|
||||
#define FT6206_RADIAN_VALUE_REG 0x91
|
||||
|
||||
/* Maximum offset while Moving Left and Moving Right gesture */
|
||||
#define FT6206_OFFSET_LEFT_RIGHT_REG 0x92
|
||||
|
||||
/* Maximum offset while Moving Up and Moving Down gesture */
|
||||
#define FT6206_OFFSET_UP_DOWN_REG 0x93
|
||||
|
||||
/* Minimum distance while Moving Left and Moving Right gesture */
|
||||
#define FT6206_DISTANCE_LEFT_RIGHT_REG 0x94
|
||||
|
||||
/* Minimum distance while Moving Up and Moving Down gesture */
|
||||
#define FT6206_DISTANCE_UP_DOWN_REG 0x95
|
||||
|
||||
/* Maximum distance while Zoom In and Zoom Out gesture */
|
||||
#define FT6206_DISTANCE_ZOOM_REG 0x96
|
||||
|
||||
/* High 8-bit of LIB Version info */
|
||||
#define FT6206_LIB_VER_H_REG 0xA1
|
||||
|
||||
/* Low 8-bit of LIB Version info */
|
||||
#define FT6206_LIB_VER_L_REG 0xA2
|
||||
|
||||
/* Chip Selecting */
|
||||
#define FT6206_CIPHER_REG 0xA3
|
||||
|
||||
/* Interrupt mode register (used when in interrupt mode) */
|
||||
#define FT6206_GMODE_REG 0xA4
|
||||
|
||||
#define FT6206_G_MODE_INTERRUPT_MASK 0x03
|
||||
#define FT6206_G_MODE_INTERRUPT_SHIFT 0x00
|
||||
|
||||
/* Possible values of FT6206_GMODE_REG */
|
||||
#define FT6206_G_MODE_INTERRUPT_POLLING 0x00
|
||||
#define FT6206_G_MODE_INTERRUPT_TRIGGER 0x01
|
||||
|
||||
/* Current power mode the FT6206 system is in (R) */
|
||||
#define FT6206_PWR_MODE_REG 0xA5
|
||||
|
||||
/* FT6206 firmware version */
|
||||
#define FT6206_FIRMID_REG 0xA6
|
||||
|
||||
/* FT6206 Chip identification register */
|
||||
#define FT6206_CHIP_ID_REG 0xA8
|
||||
|
||||
/* Possible values of FT6206_CHIP_ID_REG */
|
||||
#define FT6206_ID_VALUE 0x11
|
||||
#define FT6x36_ID_VALUE 0xCD
|
||||
|
||||
/* Release code version */
|
||||
#define FT6206_RELEASE_CODE_ID_REG 0xAF
|
||||
|
||||
/* Current operating mode the FT6206 system is in (R) */
|
||||
#define FT6206_STATE_REG 0xBC
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
|
||||
/** @defgroup ft6x06_Exported_Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
|
||||
/** @defgroup ft6x06_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief ft6x06 Control functions
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @brief Initialize the ft6x06 communication bus
|
||||
* from MCU to FT6206 : ie I2C channel initialization (if required).
|
||||
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6206).
|
||||
* @retval None
|
||||
*/
|
||||
void ft6x06_Init(uint16_t DeviceAddr);
|
||||
|
||||
/**
|
||||
* @brief Software Reset the ft6x06.
|
||||
* @param DeviceAddr: Device address on communication Bus (I2C slave address of FT6206).
|
||||
* @retval None
|
||||
*/
|
||||
void ft6x06_Reset(uint16_t DeviceAddr);
|
||||
|
||||
/**
|
||||
* @brief Read the ft6x06 device ID, pre intitalize I2C in case of need to be
|
||||
* able to read the FT6206 device ID, and verify this is a FT6206.
|
||||
* @param DeviceAddr: I2C FT6x06 Slave address.
|
||||
* @retval The Device ID (two bytes).
|
||||
*/
|
||||
uint16_t ft6x06_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 ft6x06_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 ft6x06_TS_DetectTouch(uint16_t DeviceAddr);
|
||||
|
||||
/**
|
||||
* @brief Get the touch screen X and Y positions values
|
||||
* Manage multi touch thanks to touch Index global
|
||||
* variable 'ft6x06_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 ft6x06_TS_GetXY(uint16_t DeviceAddr, uint16_t *X, uint16_t *Y);
|
||||
|
||||
/**
|
||||
* @brief Configure the FT6206 device to generate IT on given INT pin
|
||||
* connected to MCU as EXTI.
|
||||
* @param DeviceAddr: Device address on communication Bus (Slave I2C address of FT6206).
|
||||
* @retval None
|
||||
*/
|
||||
void ft6x06_TS_EnableIT(uint16_t DeviceAddr);
|
||||
|
||||
/**
|
||||
* @brief Configure the FT6206 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 FT6206).
|
||||
* @retval None
|
||||
*/
|
||||
void ft6x06_TS_DisableIT(uint16_t DeviceAddr);
|
||||
|
||||
/**
|
||||
* @brief Get IT status from FT6206 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 FT6206).
|
||||
* @retval TS interrupts status
|
||||
*/
|
||||
uint8_t ft6x06_TS_ITStatus (uint16_t DeviceAddr);
|
||||
|
||||
/**
|
||||
* @brief Clear IT status in FT6206 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 FT6206).
|
||||
* @retval TS interrupts status
|
||||
*/
|
||||
void ft6x06_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 FT6x06).
|
||||
* @param pGestureId : Pointer to get last touch gesture Identification.
|
||||
* @retval None.
|
||||
*/
|
||||
void ft6x06_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 FT6x06).
|
||||
* @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 ft6x06_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 ft6x06_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 ft6x06_Imported_Globals
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/* Touch screen driver structure */
|
||||
extern TS_DrvTypeDef ft6x06_ts_drv;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* __FT6X06_H */
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
Reference in New Issue
Block a user