197 lines
5.3 KiB
C
197 lines
5.3 KiB
C
/*
|
|
* Copyright (c) 2022, Shenzhen CVA Innovation CO.,LTD
|
|
* All rights reserved.
|
|
*
|
|
* Shenzhen CVA Innovation CO.,LTD (CVA chip) is supplying this file for use
|
|
* exclusively with CVA's microcontroller products. This file can be freely
|
|
* distributed within development tools that are supporting such microcontroller
|
|
* products.
|
|
*
|
|
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
|
|
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
|
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
|
|
* CVA SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
|
|
* OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
|
*/
|
|
|
|
#ifndef _TOUCH_TRX_H_
|
|
#define _TOUCH_TRX_H_
|
|
|
|
/*! \brief Contains public interface to various functions related
|
|
* to the driver of TOUCH TRX module
|
|
*/
|
|
|
|
/******************************************************************************
|
|
* the includes
|
|
*****************************************************************************/
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
#include <string.h>
|
|
#include "touch_drv.h"
|
|
|
|
/*! \addtogroup touch_trx
|
|
* @{
|
|
*/
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/******************************************************************************
|
|
* the defines
|
|
*****************************************************************************/
|
|
|
|
/******************************************************************************
|
|
* the typedefs
|
|
*****************************************************************************/
|
|
typedef void (*widget_set_cfg)(void *obj, uint8_t *cfg, uint32_t var);
|
|
|
|
typedef void (*widget_get_cfg)(void *obj, uint8_t *cfg, uint32_t var);
|
|
|
|
/*! \brief Touch communication interface function pointer prototype
|
|
*/
|
|
typedef int8_t(*touchIfTx)(uint8_t *packet, uint16_t len);
|
|
|
|
typedef struct
|
|
{
|
|
widget_set_cfg widget_set_cfg_func;
|
|
|
|
widget_get_cfg widget_get_cfg_func;
|
|
} Trx_Widget_FuncType;
|
|
|
|
/*! \brief Touch communication command
|
|
*/
|
|
typedef enum
|
|
{
|
|
TOUCH_TRX_CMD_MODE = 0X00,
|
|
TOUCH_TRX_CMD_MODE_ACK = 0X01,
|
|
|
|
TOUCH_TRX_CMD_REG_RD = 0X50,
|
|
TOUCH_TRX_CMD_I2C_RD_ACK = 0X51,
|
|
|
|
TOUCH_TRX_CMD_REG_WR = 0X52,
|
|
TOUCH_TRX_CMD_I2C_WR_ACK = 0X53,
|
|
|
|
TOUCH_TRX_CMD_GET_VER = 0X56,
|
|
TOUCH_TRX_CMD_GET_VER_ACK = 0X57,
|
|
|
|
TOUCH_TRX_CMD_HOST_CMD = 0X58,
|
|
TOUCH_TRX_CMD_HOST_CMD_ACK = 0X59,
|
|
|
|
TOUCH_TRX_CMD_GET_EVENT = 0X5C,
|
|
TOUCH_TRX_CMD_GET_EVENT_ACK = 0X5D,
|
|
|
|
TOUCH_TRX_CMD_SET_FLASH = 0X7a,
|
|
TOUCH_TRX_CMD_SET_FLASH_ACK = 0X7b,
|
|
|
|
TOUCH_TRX_CMD_GET_FLASH = 0X80,
|
|
TOUCH_TRX_CMD_GET_FLASH_ACK = 0X81,
|
|
|
|
TOUCH_TRX_CMD_GET_KEY_VAR = 0X82,
|
|
TOUCH_TRX_CMD_GET_KEY_VAR_ACK = 0X83,
|
|
|
|
TOUCH_TRX_CMD_GET_INFO = 0X84,
|
|
TOUCH_TRX_CMD_GET_INFO_ACK = 0X85,
|
|
|
|
TOUCH_TRX_CMD_SET_CFG = 0X86,
|
|
TOUCH_TRX_CMD_SET_CFG_ACK = 0X87,
|
|
|
|
TOUCH_TRX_CMD_GET_CFG = 0X88,
|
|
TOUCH_TRX_CMD_GET_CFG_ACK = 0X89,
|
|
|
|
TOUCH_TRX_CMD_GET_MISC = 0X90,
|
|
TOUCH_TRX_CMD_GET_MISC_ACK = 0X91,
|
|
} TouchTrx_CmdType;
|
|
|
|
/*! \brief Touch communication error code
|
|
*/
|
|
typedef enum
|
|
{
|
|
TOUCH_TRX_PACK_ERR_HEAD = 0x01,
|
|
TOUCH_TRX_PACK_ERR_SIZE = 0x02,
|
|
TOUCH_TRX_PACK_ERR_CRC = 0x03,
|
|
TOUCH_TRX_PACK_ERR_BSY = 0x04,
|
|
TOUCH_TRX_PACK_PASS = 0x55,
|
|
} TouchTrx_PackStatusType;
|
|
|
|
/*! \brief Touch communication mode
|
|
*/
|
|
typedef enum
|
|
{
|
|
TOUCH_TRX_SHOW_EN = 2,
|
|
TOUCH_TRX_SHOW_DIS = 3,
|
|
} TouchTrx_ModeType;
|
|
|
|
/*! \brief Touch communication information type
|
|
*/
|
|
typedef enum
|
|
{
|
|
TouchTrx_InfoNone = 0x00,
|
|
TouchTrx_InfoDiff = 0x01,
|
|
TouchTrx_InfoRaw = 0x02,
|
|
TouchTrx_InfoBase = 0x04,
|
|
TouchTrx_InfoProx = 0x08,
|
|
TouchTrx_InfoGesture = 0x40,
|
|
} TouchTrx_InfoType;
|
|
|
|
|
|
/******************************************************************************
|
|
* the globals
|
|
******************************************************************************/
|
|
|
|
/******************************************************************************
|
|
* the function prototypes
|
|
******************************************************************************/
|
|
|
|
/*! \brief Parse touch communication stream
|
|
*
|
|
* This function parse communication stream
|
|
*
|
|
* \param[in] data : communication stream data
|
|
*/
|
|
void TouchTrx_Parse(uint8_t data);
|
|
|
|
/*! \brief Handle touch communication package
|
|
*
|
|
* This function handle touch communication package
|
|
*
|
|
*/
|
|
void TouchTrx_Handler(void);
|
|
|
|
/*! \brief Send touch event
|
|
*
|
|
* This function for sending touch event
|
|
*
|
|
* \param[in] event : touch event
|
|
*/
|
|
void TouchTrx_SendEvent(uint8_t event);
|
|
|
|
/*! \brief Send touch information
|
|
*
|
|
* This function for sending touch information, like raw-data/base-data/diff-data etc.
|
|
*
|
|
* \param[in] event : touch event buffer
|
|
* \param[in] len : touch event buffer length in byte
|
|
*/
|
|
void TouchTrx_SendInfo(TouchDrv_InfoType *info, uint8_t extInfo[], uint16_t extLen);
|
|
|
|
/*! \brief regist widget func to touch trx
|
|
*
|
|
* This function for registing widget func to touch trx.
|
|
*
|
|
* \param[in] widget_func : point to func struct for registing
|
|
*/
|
|
void TouchTrx_RegistFuncCallback(Trx_Widget_FuncType *widget_func);
|
|
|
|
void TouchTrx_RegisterTxFun(touchIfTx prt);
|
|
|
|
void TouchTrx_SetVersion(char *version, uint8_t len);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif /* extern "C" */
|
|
|
|
/*! @}*/
|
|
|
|
#endif
|