mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-10-07 00:59:00 +08:00
[imxrt 1060] support touchpad
Signed-off-by: Ting Liu <ting.liu@nxp.com>
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -68,11 +68,32 @@ menu "Onboard Peripheral Drivers"
|
||||
default 2
|
||||
endif
|
||||
|
||||
menuconfig BSP_USING_TOUCHPAD
|
||||
bool "Enable TOUCHPAD"
|
||||
select BSP_USING_PXP
|
||||
select BSP_USING_CACHE
|
||||
select BSP_USING_I2C
|
||||
select BSP_USING_LCD
|
||||
default n
|
||||
if BSP_USING_TOUCHPAD
|
||||
choice
|
||||
prompt "Select panel"
|
||||
default DEMO_PANEL_RK043FN02H
|
||||
|
||||
config DEMO_PANEL_RK043FN02H
|
||||
bool "RK043FN02H-CT"
|
||||
|
||||
config DEMO_PANEL_RK043FN66HS
|
||||
bool "RK043FN66HS-CTG"
|
||||
endchoice
|
||||
endif
|
||||
|
||||
config BSP_USING_LVGL
|
||||
bool "Enable LVGL for LCD"
|
||||
select BSP_USING_PXP
|
||||
select BSP_USING_CACHE
|
||||
select BSP_USING_LCD
|
||||
select BSP_USING_TOUCHPAD
|
||||
select PKG_USING_LVGL
|
||||
default n
|
||||
|
||||
@@ -100,6 +121,26 @@ menu "On-chip Peripheral Drivers"
|
||||
select RT_USING_PIN
|
||||
default y
|
||||
|
||||
menuconfig BSP_USING_I2C
|
||||
bool "Enable I2C"
|
||||
select RT_USING_I2C
|
||||
default y
|
||||
if BSP_USING_I2C
|
||||
config BSP_USING_I2C1
|
||||
bool
|
||||
default y
|
||||
choice
|
||||
prompt "Select I2C1 badurate"
|
||||
default HW_I2C1_BADURATE_100kHZ
|
||||
|
||||
config HW_I2C1_BADURATE_100kHZ
|
||||
bool "Badurate 100kHZ"
|
||||
|
||||
config HW_I2C1_BADURATE_400kHZ
|
||||
bool "Badurate 400kHZ"
|
||||
endchoice
|
||||
endif
|
||||
|
||||
menuconfig BSP_USING_LPUART
|
||||
bool "Enable UART"
|
||||
select RT_USING_SERIAL
|
||||
|
||||
@@ -12,6 +12,9 @@ MCUX_Config/pin_mux.c
|
||||
MCUX_Config/dcd.c
|
||||
""")
|
||||
|
||||
if GetDepend(['BSP_USING_TOUCHPAD']):
|
||||
src += ['ports/touchpad.c']
|
||||
|
||||
CPPPATH = [cwd,cwd + '/MCUX_Config',cwd + '/ports']
|
||||
|
||||
CPPDEFINES = ['CPU_MIMXRT1062DVL6A', 'SKIP_SYSCLK_INIT', 'EVK_MCIMXRM', 'FSL_SDK_ENABLE_DRIVER_CACHE_CONTROL=1','XIP_EXTERNAL_FLASH=1', 'XIP_BOOT_HEADER_ENABLE=1', 'FSL_SDK_DRIVER_QUICK_ACCESS_ENABLE=1', 'XIP_BOOT_HEADER_DCD_ENABLE=1', 'DATA_SECTION_IS_CACHEABLE=1']
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
* Copyright 2022 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#include "touchpad.h"
|
||||
|
||||
void BOARD_LPI2C_Init(LPI2C_Type *base, uint32_t clkSrc_Hz)
|
||||
{
|
||||
lpi2c_master_config_t lpi2cConfig = {0};
|
||||
|
||||
/*
|
||||
* lpi2cConfig.debugEnable = false;
|
||||
* lpi2cConfig.ignoreAck = false;
|
||||
* lpi2cConfig.pinConfig = kLPI2C_2PinOpenDrain;
|
||||
* lpi2cConfig.baudRate_Hz = 100000U;
|
||||
* lpi2cConfig.busIdleTimeout_ns = 0;
|
||||
* lpi2cConfig.pinLowTimeout_ns = 0;
|
||||
* lpi2cConfig.sdaGlitchFilterWidth_ns = 0;
|
||||
* lpi2cConfig.sclGlitchFilterWidth_ns = 0;
|
||||
*/
|
||||
LPI2C_MasterGetDefaultConfig(&lpi2cConfig);
|
||||
LPI2C_MasterInit(base, &lpi2cConfig, clkSrc_Hz);
|
||||
}
|
||||
|
||||
status_t BOARD_LPI2C_Send(LPI2C_Type *base,
|
||||
uint8_t deviceAddress,
|
||||
uint32_t subAddress,
|
||||
uint8_t subAddressSize,
|
||||
uint8_t *txBuff,
|
||||
uint8_t txBuffSize)
|
||||
{
|
||||
lpi2c_master_transfer_t xfer;
|
||||
|
||||
xfer.flags = kLPI2C_TransferDefaultFlag;
|
||||
xfer.slaveAddress = deviceAddress;
|
||||
xfer.direction = kLPI2C_Write;
|
||||
xfer.subaddress = subAddress;
|
||||
xfer.subaddressSize = subAddressSize;
|
||||
xfer.data = txBuff;
|
||||
xfer.dataSize = txBuffSize;
|
||||
|
||||
return LPI2C_MasterTransferBlocking(base, &xfer);
|
||||
}
|
||||
|
||||
status_t BOARD_LPI2C_Receive(LPI2C_Type *base,
|
||||
uint8_t deviceAddress,
|
||||
uint32_t subAddress,
|
||||
uint8_t subAddressSize,
|
||||
uint8_t *rxBuff,
|
||||
uint8_t rxBuffSize)
|
||||
{
|
||||
lpi2c_master_transfer_t xfer;
|
||||
|
||||
xfer.flags = kLPI2C_TransferDefaultFlag;
|
||||
xfer.slaveAddress = deviceAddress;
|
||||
xfer.direction = kLPI2C_Read;
|
||||
xfer.subaddress = subAddress;
|
||||
xfer.subaddressSize = subAddressSize;
|
||||
xfer.data = rxBuff;
|
||||
xfer.dataSize = rxBuffSize;
|
||||
|
||||
return LPI2C_MasterTransferBlocking(base, &xfer);
|
||||
}
|
||||
|
||||
status_t BOARD_LPI2C_SendSCCB(LPI2C_Type *base,
|
||||
uint8_t deviceAddress,
|
||||
uint32_t subAddress,
|
||||
uint8_t subAddressSize,
|
||||
uint8_t *txBuff,
|
||||
uint8_t txBuffSize)
|
||||
{
|
||||
lpi2c_master_transfer_t xfer;
|
||||
|
||||
xfer.flags = kLPI2C_TransferDefaultFlag;
|
||||
xfer.slaveAddress = deviceAddress;
|
||||
xfer.direction = kLPI2C_Write;
|
||||
xfer.subaddress = subAddress;
|
||||
xfer.subaddressSize = subAddressSize;
|
||||
xfer.data = txBuff;
|
||||
xfer.dataSize = txBuffSize;
|
||||
|
||||
return LPI2C_MasterTransferBlocking(base, &xfer);
|
||||
}
|
||||
|
||||
status_t BOARD_LPI2C_ReceiveSCCB(LPI2C_Type *base,
|
||||
uint8_t deviceAddress,
|
||||
uint32_t subAddress,
|
||||
uint8_t subAddressSize,
|
||||
uint8_t *rxBuff,
|
||||
uint8_t rxBuffSize)
|
||||
{
|
||||
status_t status;
|
||||
lpi2c_master_transfer_t xfer;
|
||||
|
||||
xfer.flags = kLPI2C_TransferDefaultFlag;
|
||||
xfer.slaveAddress = deviceAddress;
|
||||
xfer.direction = kLPI2C_Write;
|
||||
xfer.subaddress = subAddress;
|
||||
xfer.subaddressSize = subAddressSize;
|
||||
xfer.data = NULL;
|
||||
xfer.dataSize = 0;
|
||||
|
||||
status = LPI2C_MasterTransferBlocking(base, &xfer);
|
||||
|
||||
if (kStatus_Success == status)
|
||||
{
|
||||
xfer.subaddressSize = 0;
|
||||
xfer.direction = kLPI2C_Read;
|
||||
xfer.data = rxBuff;
|
||||
xfer.dataSize = rxBuffSize;
|
||||
|
||||
status = LPI2C_MasterTransferBlocking(base, &xfer);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
status_t BOARD_Touch_I2C_Send(
|
||||
uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, const uint8_t *txBuff, uint8_t txBuffSize)
|
||||
{
|
||||
return BOARD_LPI2C_Send(BOARD_TOUCH_I2C_BASEADDR, deviceAddress, subAddress, subAddressSize, (uint8_t *)txBuff,
|
||||
txBuffSize);
|
||||
}
|
||||
|
||||
status_t BOARD_Touch_I2C_Receive(
|
||||
uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, uint8_t *rxBuff, uint8_t rxBuffSize)
|
||||
{
|
||||
return BOARD_LPI2C_Receive(BOARD_TOUCH_I2C_BASEADDR, deviceAddress, subAddress, subAddressSize, rxBuff, rxBuffSize);
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright 2022 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef __TOUCHPAD_PORT_H__
|
||||
#define __TOUCHPAD_PORT_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "fsl_common.h"
|
||||
#include "clock_config.h"
|
||||
#include "fsl_lpi2c.h"
|
||||
#include "fsl_gpio.h"
|
||||
|
||||
/* @Brief Board touch panel configuration */
|
||||
#define BOARD_TOUCH_I2C_BASEADDR LPI2C1
|
||||
#define BOARD_TOUCH_RST_GPIO GPIO1
|
||||
#define BOARD_TOUCH_RST_PIN 2
|
||||
#define BOARD_TOUCH_INT_GPIO GPIO1
|
||||
#define BOARD_TOUCH_INT_PIN 11
|
||||
|
||||
void BOARD_LPI2C_Init(LPI2C_Type *base, uint32_t clkSrc_Hz);
|
||||
status_t BOARD_LPI2C_Send(LPI2C_Type *base,
|
||||
uint8_t deviceAddress,
|
||||
uint32_t subAddress,
|
||||
uint8_t subaddressSize,
|
||||
uint8_t *txBuff,
|
||||
uint8_t txBuffSize);
|
||||
status_t BOARD_LPI2C_Receive(LPI2C_Type *base,
|
||||
uint8_t deviceAddress,
|
||||
uint32_t subAddress,
|
||||
uint8_t subaddressSize,
|
||||
uint8_t *rxBuff,
|
||||
uint8_t rxBuffSize);
|
||||
status_t BOARD_LPI2C_SendSCCB(LPI2C_Type *base,
|
||||
uint8_t deviceAddress,
|
||||
uint32_t subAddress,
|
||||
uint8_t subaddressSize,
|
||||
uint8_t *txBuff,
|
||||
uint8_t txBuffSize);
|
||||
status_t BOARD_LPI2C_ReceiveSCCB(LPI2C_Type *base,
|
||||
uint8_t deviceAddress,
|
||||
uint32_t subAddress,
|
||||
uint8_t subaddressSize,
|
||||
uint8_t *rxBuff,
|
||||
uint8_t rxBuffSize);
|
||||
status_t BOARD_Touch_I2C_Send(
|
||||
uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, const uint8_t *txBuff, uint8_t txBuffSize);
|
||||
status_t BOARD_Touch_I2C_Receive(
|
||||
uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, uint8_t *rxBuff, uint8_t rxBuffSize);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,182 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2019 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#include "fsl_common.h"
|
||||
#include "fsl_lpi2c.h"
|
||||
#include "fsl_ft5406_rt.h"
|
||||
|
||||
typedef struct _ft5406_rt_touch_point
|
||||
{
|
||||
uint8_t XH;
|
||||
uint8_t XL;
|
||||
uint8_t YH;
|
||||
uint8_t YL;
|
||||
uint8_t RESERVED[2];
|
||||
} ft5406_rt_touch_point_t;
|
||||
|
||||
typedef struct _ft5406_rt_touch_data
|
||||
{
|
||||
uint8_t GEST_ID;
|
||||
uint8_t TD_STATUS;
|
||||
ft5406_rt_touch_point_t TOUCH[FT5406_RT_MAX_TOUCHES];
|
||||
} ft5406_rt_touch_data_t;
|
||||
|
||||
#define TOUCH_POINT_GET_EVENT(T) ((touch_event_t)((T).XH >> 6))
|
||||
#define TOUCH_POINT_GET_ID(T) ((T).YH >> 4)
|
||||
#define TOUCH_POINT_GET_X(T) ((((T).XH & 0x0f) << 8) | (T).XL)
|
||||
#define TOUCH_POINT_GET_Y(T) ((((T).YH & 0x0f) << 8) | (T).YL)
|
||||
|
||||
status_t FT5406_RT_Init(ft5406_rt_handle_t *handle, LPI2C_Type *base)
|
||||
{
|
||||
lpi2c_master_transfer_t *xfer = &(handle->xfer);
|
||||
status_t status;
|
||||
uint8_t mode;
|
||||
|
||||
assert(handle);
|
||||
assert(base);
|
||||
|
||||
if (!handle || !base)
|
||||
{
|
||||
return kStatus_InvalidArgument;
|
||||
}
|
||||
|
||||
handle->base = base;
|
||||
|
||||
/* clear transfer structure and buffer */
|
||||
memset(xfer, 0, sizeof(*xfer));
|
||||
memset(handle->touch_buf, 0, FT5406_RT_TOUCH_DATA_LEN);
|
||||
|
||||
/* set device mode to normal operation */
|
||||
mode = 0;
|
||||
xfer->slaveAddress = FT5406_RT_I2C_ADDRESS;
|
||||
xfer->direction = kLPI2C_Write;
|
||||
xfer->subaddress = 0;
|
||||
xfer->subaddressSize = 1;
|
||||
xfer->data = &mode;
|
||||
xfer->dataSize = 1;
|
||||
xfer->flags = kLPI2C_TransferDefaultFlag;
|
||||
|
||||
status = LPI2C_MasterTransferBlocking(handle->base, &handle->xfer);
|
||||
|
||||
/* prepare transfer structure for reading touch data */
|
||||
xfer->slaveAddress = FT5406_RT_I2C_ADDRESS;
|
||||
xfer->direction = kLPI2C_Read;
|
||||
xfer->subaddress = 1;
|
||||
xfer->subaddressSize = 1;
|
||||
xfer->data = handle->touch_buf;
|
||||
xfer->dataSize = FT5406_RT_TOUCH_DATA_LEN;
|
||||
xfer->flags = kLPI2C_TransferDefaultFlag;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
status_t FT5406_RT_Denit(ft5406_rt_handle_t *handle)
|
||||
{
|
||||
assert(handle);
|
||||
|
||||
if (!handle)
|
||||
{
|
||||
return kStatus_InvalidArgument;
|
||||
}
|
||||
|
||||
handle->base = NULL;
|
||||
return kStatus_Success;
|
||||
}
|
||||
|
||||
status_t FT5406_RT_ReadTouchData(ft5406_rt_handle_t *handle)
|
||||
{
|
||||
assert(handle);
|
||||
|
||||
if (!handle)
|
||||
{
|
||||
return kStatus_InvalidArgument;
|
||||
}
|
||||
|
||||
return LPI2C_MasterTransferBlocking(handle->base, &handle->xfer);
|
||||
}
|
||||
|
||||
status_t FT5406_RT_GetSingleTouch(ft5406_rt_handle_t *handle, touch_event_t *touch_event, int *touch_x, int *touch_y)
|
||||
{
|
||||
status_t status;
|
||||
touch_event_t touch_event_local;
|
||||
|
||||
status = FT5406_RT_ReadTouchData(handle);
|
||||
|
||||
if (status == kStatus_Success)
|
||||
{
|
||||
ft5406_rt_touch_data_t *touch_data = (ft5406_rt_touch_data_t *)(void *)(handle->touch_buf);
|
||||
|
||||
if (touch_event == NULL)
|
||||
{
|
||||
touch_event = &touch_event_local;
|
||||
}
|
||||
*touch_event = TOUCH_POINT_GET_EVENT(touch_data->TOUCH[0]);
|
||||
|
||||
/* Update coordinates only if there is touch detected */
|
||||
if ((*touch_event == kTouch_Down) || (*touch_event == kTouch_Contact))
|
||||
{
|
||||
if (touch_x)
|
||||
{
|
||||
*touch_x = TOUCH_POINT_GET_X(touch_data->TOUCH[0]);
|
||||
}
|
||||
if (touch_y)
|
||||
{
|
||||
*touch_y = TOUCH_POINT_GET_Y(touch_data->TOUCH[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
status_t FT5406_RT_GetMultiTouch(ft5406_rt_handle_t *handle,
|
||||
int *touch_count,
|
||||
touch_point_t touch_array[FT5406_RT_MAX_TOUCHES])
|
||||
{
|
||||
status_t status;
|
||||
|
||||
status = FT5406_RT_ReadTouchData(handle);
|
||||
|
||||
if (status == kStatus_Success)
|
||||
{
|
||||
ft5406_rt_touch_data_t *touch_data = (ft5406_rt_touch_data_t *)(void *)(handle->touch_buf);
|
||||
int i;
|
||||
|
||||
/* Check for valid number of touches - otherwise ignore touch information */
|
||||
if (touch_data->TD_STATUS > FT5406_RT_MAX_TOUCHES)
|
||||
{
|
||||
touch_data->TD_STATUS = 0;
|
||||
}
|
||||
|
||||
/* Decode number of touches */
|
||||
if (touch_count)
|
||||
{
|
||||
*touch_count = touch_data->TD_STATUS;
|
||||
}
|
||||
|
||||
/* Decode valid touch points */
|
||||
for (i = 0; i < touch_data->TD_STATUS; i++)
|
||||
{
|
||||
touch_array[i].TOUCH_ID = TOUCH_POINT_GET_ID(touch_data->TOUCH[i]);
|
||||
touch_array[i].TOUCH_EVENT = TOUCH_POINT_GET_EVENT(touch_data->TOUCH[i]);
|
||||
touch_array[i].TOUCH_X = TOUCH_POINT_GET_X(touch_data->TOUCH[i]);
|
||||
touch_array[i].TOUCH_Y = TOUCH_POINT_GET_Y(touch_data->TOUCH[i]);
|
||||
}
|
||||
|
||||
/* Clear vacant elements of touch_array */
|
||||
for (; i < FT5406_RT_MAX_TOUCHES; i++)
|
||||
{
|
||||
touch_array[i].TOUCH_ID = 0;
|
||||
touch_array[i].TOUCH_EVENT = kTouch_Reserved;
|
||||
touch_array[i].TOUCH_X = 0;
|
||||
touch_array[i].TOUCH_Y = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2017 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#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
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,198 @@
|
||||
/*
|
||||
* Copyright 2019-2020 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef _FSL_GT911_H_
|
||||
#define _FSL_GT911_H_
|
||||
|
||||
#include "fsl_common.h"
|
||||
|
||||
/*
|
||||
* Change Log:
|
||||
*
|
||||
* 1.0.3:
|
||||
* - Fixed MISRA 2012 issues.
|
||||
*
|
||||
* 1.0.2:
|
||||
* - Fixed the issue that INT pin is output low when using kGT911_I2cAddrAny.
|
||||
*
|
||||
* 1.0.1:
|
||||
* - Update GT911_GetMultiTouch and GT911_GetSingleTouch to return
|
||||
* kStatus_TOUCHPANEL_NotTouched when no touch happens.
|
||||
*
|
||||
* 1.0.0:
|
||||
* - Initial version.
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @addtogroup gt911
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
/*! @brief GT911 maximum number of simultaneously detected touches. */
|
||||
#define GT911_MAX_TOUCHES (10U)
|
||||
|
||||
/*! @brief Error code definition. */
|
||||
enum _touch_status
|
||||
{
|
||||
kStatus_TOUCHPANEL_NotTouched = MAKE_STATUS(kStatusGroup_TOUCH_PANEL, 0) /*!< No touch happen. */
|
||||
};
|
||||
|
||||
/*! @brief Touch point definition. */
|
||||
typedef struct
|
||||
{
|
||||
bool valid; /*!< Whether the touch point coordinate value is valid. */
|
||||
uint8_t touchID; /*!< Id of the touch point. This numeric value stays constant between down and up event. */
|
||||
uint16_t x; /*!< X coordinate of the touch point */
|
||||
uint16_t y; /*!< Y coordinate of the touch point */
|
||||
} touch_point_t;
|
||||
|
||||
/*! @brief gt911 I2C address mode.*/
|
||||
typedef enum _gt911_i2c_addr_mode
|
||||
{
|
||||
kGT911_I2cAddrMode0, /*!< 7-bit address 0x5D, or 8-bit 0xBA/0xBB */
|
||||
kGT911_I2cAddrMode1, /*!< 7-bit address 0x14, or 8-bit 0x28/0x29 */
|
||||
kGT911_I2cAddrAny, /*!< Use 0x5D or 0x14, driver selects the right one to use,
|
||||
this is used for the case that MCU could not pull
|
||||
the INT pin level.
|
||||
*/
|
||||
} gt911_i2c_addr_mode_t;
|
||||
|
||||
/*! @brief gt911 interrupt pin mode.*/
|
||||
typedef enum _gt911_int_pin_mode
|
||||
{
|
||||
kGT911_IntPinPullDown, /*!< Interrupt pin output pull down. */
|
||||
kGT911_IntPinPullUp, /*!< Interrupt pin output pull up. */
|
||||
kGT911_IntPinInput, /*!< Interrupt pin set to input mode. */
|
||||
} gt911_int_pin_mode_t;
|
||||
|
||||
/*! @brief gt911 interrupt trigger mode.*/
|
||||
typedef enum _gt911_int_trig_mode
|
||||
{
|
||||
kGT911_IntRisingEdge, /*!< Rising edge. */
|
||||
kGT911_IntFallingEdge, /*!< Falling edge. */
|
||||
kGT911_IntLowLevel, /*!< Low level. */
|
||||
kGT911_IntHighLevel, /*!< High edge. */
|
||||
} gt911_int_trig_mode_t;
|
||||
|
||||
typedef status_t (*gt911_i2c_send_func_t)(
|
||||
uint8_t deviceAddress, uint32_t subAddress, uint8_t subaddressSize, const uint8_t *txBuff, uint8_t txBuffSize);
|
||||
typedef status_t (*gt911_i2c_receive_func_t)(
|
||||
uint8_t deviceAddress, uint32_t subAddress, uint8_t subaddressSize, uint8_t *rxBuff, uint8_t rxBuffSize);
|
||||
typedef void (*gt911_int_pin_func_t)(gt911_int_pin_mode_t mode);
|
||||
typedef void (*gt911_reset_pin_func_t)(bool pullUp);
|
||||
|
||||
/*! @brief gt911 configure structure.*/
|
||||
typedef struct _gt911_point_reg
|
||||
{
|
||||
uint8_t id; /*!< Track ID. */
|
||||
uint8_t lowX; /*!< Low byte of x coordinate. */
|
||||
uint8_t highX; /*!< High byte of x coordinate. */
|
||||
uint8_t lowY; /*!< Low byte of y coordinate. */
|
||||
uint8_t highY; /*!< High byte of x coordinate. */
|
||||
uint8_t lowSize; /*!< Low byte of point size. */
|
||||
uint8_t highSize; /*!< High byte of point size. */
|
||||
uint8_t reserved; /*!< Reserved. */
|
||||
} gt911_point_reg_t;
|
||||
|
||||
/*! @brief gt911 configure structure.*/
|
||||
typedef struct _gt911_config
|
||||
{
|
||||
gt911_i2c_send_func_t I2C_SendFunc; /*!< Function to send I2C data. */
|
||||
gt911_i2c_receive_func_t I2C_ReceiveFunc; /*!< Function to receive I2C data. */
|
||||
void (*timeDelayMsFunc)(uint32_t delayMs); /*!< Function to delay some MS. */
|
||||
gt911_int_pin_func_t intPinFunc; /*!< Function to set interrupt pin to different mode. */
|
||||
gt911_reset_pin_func_t pullResetPinFunc; /*!< Function to pull reset pin high or low. */
|
||||
uint8_t touchPointNum; /*!< How many touch points to enable. */
|
||||
gt911_i2c_addr_mode_t i2cAddrMode; /*!< I2C address mode. */
|
||||
gt911_int_trig_mode_t intTrigMode; /*!< Interrupt trigger mode. */
|
||||
} gt911_config_t;
|
||||
|
||||
/*! @brief gt911 driver structure.*/
|
||||
typedef struct _gt911_handle
|
||||
{
|
||||
gt911_i2c_send_func_t I2C_SendFunc; /*!< Function to send I2C data. */
|
||||
gt911_i2c_receive_func_t I2C_ReceiveFunc; /*!< Function to receive I2C data. */
|
||||
void (*timeDelayMsFunc)(uint32_t delayMs); /*!< Function to delay some MS. */
|
||||
gt911_reset_pin_func_t pullResetPinFunc; /*!< Function to pull reset pin high or low. */
|
||||
gt911_point_reg_t pointReg[GT911_MAX_TOUCHES]; /*!< Buffer to receive touch point raw data. */
|
||||
uint8_t touchPointNum; /*!< How many touch points to enable. */
|
||||
uint8_t i2cAddr; /*!< I2C address. */
|
||||
uint16_t resolutionX; /*!< Resolution. */
|
||||
uint16_t resolutionY; /*!< Resolution. */
|
||||
} gt911_handle_t;
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @brief Initialize the driver.
|
||||
*
|
||||
* @param[in] handle Pointer to the GT911 driver.
|
||||
* @param[in] config Pointer to the configuration.
|
||||
* @return Returns @ref kStatus_Success if succeeded, otherwise return error code.
|
||||
*/
|
||||
status_t GT911_Init(gt911_handle_t *handle, const gt911_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief De-initialize the driver.
|
||||
*
|
||||
* @param[in] handle Pointer to the GT911 driver.
|
||||
* @return Returns @ref kStatus_Success if succeeded, otherwise return error code.
|
||||
*/
|
||||
status_t GT911_Deinit(gt911_handle_t *handle);
|
||||
|
||||
/*!
|
||||
* @brief Get single touch point coordinate.
|
||||
*
|
||||
* @param[in] handle Pointer to the GT911 driver.
|
||||
* @param[out] touch_x X coordinate of the touch point.
|
||||
* @param[out] touch_y Y coordinate of the touch point.
|
||||
* @return Returns @ref kStatus_Success if succeeded, otherwise return error code.
|
||||
*/
|
||||
status_t GT911_GetSingleTouch(gt911_handle_t *handle, int *touch_x, int *touch_y);
|
||||
|
||||
/*!
|
||||
* @brief Get multiple touch points coordinate.
|
||||
*
|
||||
* When calling this function, parameter @ref touch_count means the array size
|
||||
* of @p touch_array. After the function returns, the @p touch_count means how
|
||||
* many valid touch points there are in the @p touch_array.
|
||||
*
|
||||
* @param[in] handle Pointer to the GT911 driver.
|
||||
* @param[in, out] touch_count The touch point number.
|
||||
* @param[out] touch_array Array of touch points coordinate.
|
||||
* @return Returns @ref kStatus_Success if succeeded, otherwise return error code.
|
||||
*/
|
||||
status_t GT911_GetMultiTouch(gt911_handle_t *handle, uint8_t *touch_count, touch_point_t touch_array[]);
|
||||
|
||||
/*!
|
||||
* @brief Get touch IC resolution.
|
||||
*
|
||||
* Note the touch resolution might be different with display resolution.
|
||||
*
|
||||
* @param handle Pointer to the driver.
|
||||
* @param touch_x X resolution.
|
||||
* @param touch_y Y resolution.
|
||||
* @return Returns @ref kStatus_Success if succeeded, otherwise return error code.
|
||||
*/
|
||||
status_t GT911_GetResolution(gt911_handle_t *handle, int *resolutionX, int *resolutionY);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*! @} */
|
||||
|
||||
#endif /* _FSL_GT911_H_ */
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -6,6 +6,7 @@ path = [cwd + '/CMSIS/Include',cwd + '/MIMXRT1060', cwd + '/MIMXRT1060/drivers']
|
||||
src = Split('''
|
||||
MIMXRT1060/system_MIMXRT1062.c
|
||||
MIMXRT1060/drivers/fsl_common.c
|
||||
MIMXRT1060/drivers/fsl_common_arm.c
|
||||
MIMXRT1060/drivers/fsl_clock.c
|
||||
MIMXRT1060/drivers/fsl_cache.c
|
||||
''')
|
||||
@@ -53,6 +54,12 @@ if GetDepend(['BSP_USING_SDRAM']):
|
||||
if GetDepend(['BSP_USING_LCD']):
|
||||
src += ['MIMXRT1060/drivers/fsl_elcdif.c']
|
||||
|
||||
if GetDepend(['DEMO_PANEL_RK043FN02H']):
|
||||
src += ['MIMXRT1060/drivers/fsl_ft5406_rt.c']
|
||||
|
||||
if GetDepend(['DEMO_PANEL_RK043FN66HS']):
|
||||
src += ['MIMXRT1060/drivers/fsl_video_common.c', 'MIMXRT1060/drivers/fsl_gt911.c']
|
||||
|
||||
if GetDepend(['BSP_USING_CACHE']):
|
||||
src += ['MIMXRT1060/drivers/fsl_cache.c']
|
||||
|
||||
|
||||
Reference in New Issue
Block a user