NXP Touch Cursor example for LPCXpresso54608, modified for use with Mbed OS.
Embed:
(wiki syntax)
Show/hide line numbers
fsl_ft5406.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_H_ 00036 #define _FSL_FT5406_H_ 00037 00038 #include "fsl_common.h" 00039 #include "fsl_i2c.h" 00040 00041 /*! 00042 * @addtogroup ft5406 00043 * @{ 00044 */ 00045 00046 /******************************************************************************* 00047 * Definitions 00048 ******************************************************************************/ 00049 00050 /*! @brief FT5406 I2C address. */ 00051 #define FT5406_I2C_ADDRESS (0x38) 00052 00053 /*! @brief FT5406 maximum number of simultaneously detected touches. */ 00054 #define FT5406_MAX_TOUCHES (5U) 00055 00056 /*! @brief FT5406 register address where touch data begin. */ 00057 #define FT5406_TOUCH_DATA_SUBADDR (1) 00058 00059 /*! @brief FT5406 raw touch data length. */ 00060 #define FT5406_TOUCH_DATA_LEN (0x20) 00061 00062 typedef enum _touch_event 00063 { 00064 kTouch_Down = 0, /*!< The state changed to touched. */ 00065 kTouch_Up = 1, /*!< The state changed to not touched. */ 00066 kTouch_Contact = 2, /*!< There is a continuous touch being detected. */ 00067 kTouch_Reserved = 3 /*!< No touch information available. */ 00068 } touch_event_t; 00069 00070 typedef struct _touch_point 00071 { 00072 touch_event_t TOUCH_EVENT; /*!< Indicates the state or event of the touch point. */ 00073 uint8_t TOUCH_ID ; /*!< Id of the touch point. This numeric value stays constant between down and up event. */ 00074 uint16_t TOUCH_X ; /*!< X coordinate of the touch point */ 00075 uint16_t TOUCH_Y ; /*!< Y coordinate of the touch point */ 00076 } touch_point_t; 00077 00078 typedef struct _ft5406_handle 00079 { 00080 I2C_Type *base; 00081 i2c_master_transfer_t xfer; 00082 uint8_t touch_buf[FT5406_TOUCH_DATA_LEN]; 00083 } ft5406_handle_t; 00084 00085 status_t FT5406_Init(ft5406_handle_t *handle, I2C_Type *base); 00086 00087 status_t FT5406_Denit(ft5406_handle_t *handle); 00088 00089 status_t FT5406_GetSingleTouch(ft5406_handle_t *handle, touch_event_t *touch_event, int *touch_x, int *touch_y); 00090 00091 status_t FT5406_GetMultiTouch(ft5406_handle_t *handle, int *touch_count, touch_point_t touch_array[FT5406_MAX_TOUCHES]); 00092 00093 #endif
Generated on Sun Jul 17 2022 23:10:29 by
1.7.2
Jenny Plunkett