NXP
/
rt1050_emwin_gui_demo
RT1050 GUI demo using emWin library
Diff: source/fsl_ft5406_rt.h
- Revision:
- 0:dd702039127a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/source/fsl_ft5406_rt.h Thu Sep 20 19:16:34 2018 +0000 @@ -0,0 +1,94 @@ +/* + * The Clear BSD License + * Copyright (c) 2016, Freescale Semiconductor, Inc. + * Copyright 2016-2017 NXP + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted (subject to the limitations in the disclaimer below) provided + * that the following conditions are met: + * + * o Redistributions of source code must retain the above copyright notice, this list + * of conditions and the following disclaimer. + * + * o 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. + * + * o 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. + * + * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. + * 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. + */ + +#ifndef _FSL_FT5406_RT_H_ +#define _FSL_FT5406_RT_H_ + +#include "fsl_common.h" + +/*! + * @addtogroup ft5406_rt + * @{ + */ + +/******************************************************************************* + * Definitions + ******************************************************************************/ + +/*! @brief FT5406_RT I2C address. */ +#define FT5406_RT_I2C_ADDRESS (0x38) + +/*! @brief FT5406_RT maximum number of simultaneously detected touches. */ +#define FT5406_RT_MAX_TOUCHES (5U) + +/*! @brief FT5406_RT register address where touch data begin. */ +#define FT5406_RT_TOUCH_DATA_SUBADDR (1) + +/*! @brief FT5406_RT raw touch data length. */ +#define FT5406_RT_TOUCH_DATA_LEN (0x20) + +typedef enum _touch_event +{ + kTouch_Down = 0, /*!< The state changed to touched. */ + kTouch_Up = 1, /*!< The state changed to not touched. */ + kTouch_Contact = 2, /*!< There is a continuous touch being detected. */ + kTouch_Reserved = 3 /*!< No touch information available. */ +} touch_event_t; + +typedef struct _touch_point +{ + touch_event_t TOUCH_EVENT; /*!< Indicates the state or event of the touch point. */ + uint8_t TOUCH_ID; /*!< Id of the touch point. This numeric value stays constant between down and up event. */ + uint16_t TOUCH_X; /*!< X coordinate of the touch point */ + uint16_t TOUCH_Y; /*!< Y coordinate of the touch point */ +} touch_point_t; + +typedef struct _ft5406_rt_handle +{ + LPI2C_Type *base; + lpi2c_master_transfer_t xfer; + uint8_t touch_buf[FT5406_RT_TOUCH_DATA_LEN]; +} ft5406_rt_handle_t; + +status_t FT5406_RT_Init(ft5406_rt_handle_t *handle, LPI2C_Type *base); + +status_t FT5406_RT_Denit(ft5406_rt_handle_t *handle); + +status_t FT5406_RT_GetSingleTouch(ft5406_rt_handle_t *handle, touch_event_t *touch_event, int *touch_x, int *touch_y); + +status_t FT5406_RT_GetMultiTouch(ft5406_rt_handle_t *handle, + int *touch_count, + touch_point_t touch_array[FT5406_RT_MAX_TOUCHES]); + +#endif