RT1050 GUI demo using emWin library

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers fsl_ft5406_rt.h Source File

fsl_ft5406_rt.h

00001 /*
00002  * The Clear BSD License
00003  * Copyright (c) 2016, Freescale Semiconductor, Inc.
00004  * Copyright 2016-2017 NXP
00005  * All rights reserved.
00006  * 
00007  * Redistribution and use in source and binary forms, with or without modification,
00008  * are permitted (subject to the limitations in the disclaimer below) provided
00009  *  that the following conditions are met:
00010  *
00011  * o Redistributions of source code must retain the above copyright notice, this list
00012  *   of conditions and the following disclaimer.
00013  *
00014  * o Redistributions in binary form must reproduce the above copyright notice, this
00015  *   list of conditions and the following disclaimer in the documentation and/or
00016  *   other materials provided with the distribution.
00017  *
00018  * o Neither the name of the copyright holder nor the names of its
00019  *   contributors may be used to endorse or promote products derived from this
00020  *   software without specific prior written permission.
00021  *
00022  * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE.
00023  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00024  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00025  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00026  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
00027  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00028  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00029  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
00030  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00031  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00032  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00033  */
00034 
00035 #ifndef _FSL_FT5406_RT_H_
00036 #define _FSL_FT5406_RT_H_
00037 
00038 #include "fsl_common.h"
00039 
00040 /*!
00041  * @addtogroup ft5406_rt
00042  * @{
00043  */
00044 
00045 /*******************************************************************************
00046  * Definitions
00047  ******************************************************************************/
00048 
00049 /*! @brief FT5406_RT I2C address. */
00050 #define FT5406_RT_I2C_ADDRESS (0x38)
00051 
00052 /*! @brief FT5406_RT maximum number of simultaneously detected touches. */
00053 #define FT5406_RT_MAX_TOUCHES (5U)
00054 
00055 /*! @brief FT5406_RT register address where touch data begin. */
00056 #define FT5406_RT_TOUCH_DATA_SUBADDR (1)
00057 
00058 /*! @brief FT5406_RT raw touch data length. */
00059 #define FT5406_RT_TOUCH_DATA_LEN (0x20)
00060 
00061 typedef enum _touch_event 
00062 {
00063     kTouch_Down  = 0,    /*!< The state changed to touched. */
00064     kTouch_Up  = 1,      /*!< The state changed to not touched. */
00065     kTouch_Contact  = 2, /*!< There is a continuous touch being detected. */
00066     kTouch_Reserved  = 3 /*!< No touch information available. */
00067 } touch_event_t;
00068 
00069 typedef struct _touch_point
00070 {
00071     touch_event_t TOUCH_EVENT; /*!< Indicates the state or event of the touch point. */
00072     uint8_t TOUCH_ID ; /*!< Id of the touch point. This numeric value stays constant between down and up event. */
00073     uint16_t TOUCH_X ; /*!< X coordinate of the touch point */
00074     uint16_t TOUCH_Y ; /*!< Y coordinate of the touch point */
00075 } touch_point_t;
00076 
00077 typedef struct _ft5406_rt_handle
00078 {
00079     LPI2C_Type *base;
00080     lpi2c_master_transfer_t xfer;
00081     uint8_t touch_buf[FT5406_RT_TOUCH_DATA_LEN];
00082 } ft5406_rt_handle_t;
00083 
00084 status_t FT5406_RT_Init(ft5406_rt_handle_t *handle, LPI2C_Type *base);
00085 
00086 status_t FT5406_RT_Denit(ft5406_rt_handle_t *handle);
00087 
00088 status_t FT5406_RT_GetSingleTouch(ft5406_rt_handle_t *handle, touch_event_t *touch_event, int *touch_x, int *touch_y);
00089 
00090 status_t FT5406_RT_GetMultiTouch(ft5406_rt_handle_t *handle,
00091                                  int *touch_count,
00092                                  touch_point_t touch_array[FT5406_RT_MAX_TOUCHES]);
00093 
00094 #endif