-
Notifications
You must be signed in to change notification settings - Fork 0
/
drv_captouch_i2c.h
98 lines (72 loc) · 4.01 KB
/
drv_captouch_i2c.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/****************************************************************************************
I2C Capacitive Touch Driver: API Functions Header File
File Name:
drv_captouch_i2c.h
Summary:
This header file provides the API function prototypes for the I2C Capacitive Touch
controller.
Description:
API function prototypes for the I2C Capacitive Touch controller like the FT5xxx.
***************************************************************************************/
#ifndef DRV_CAPTOUCH_I2C_LIBRARY_H
#define DRV_CAPTOUCH_I2C_LIBRARY_H
// *****************************************************************************
// *****************************************************************************
// Section: Included Files
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
#include "drv_captouch_i2c_defines.h"
// *****************************************************************************
// *****************************************************************************
// Section: Defines
#define TWOTOUCH
#define I2C_BASEADDR I2C3
#define INT_GPIO GPIO5
#define INT_PIN 4
#define I2C_CLK_FREQ (CLOCK_GetPllFreq(kCLOCK_SystemPll1Ctrl) / (CLOCK_GetRootPreDivider(kCLOCK_RootI2c3)) / (CLOCK_GetRootPostDivider(kCLOCK_RootI2c3)) / 5) /* SYSTEM PLL1 DIV5 */
#define I2C_SLAVE_ADDR 0x38U
#define I2C_BAUDRATE 100000U // 100kHz
#define I2C_BAUDRATE_MAX 400000U // 400kHz
#define I2C_BUFFER_LENGTH 30
#define MAX_X_PIXEL 800
#define MAX_Y_PIXEL 480
#define WIDTH 154 // 153.6 mm
#define HEIGHT 86 // 86.64 mm
#define ORIENTATION 0 // 0� also supported 90�, 180�, 270�
// *****************************************************************************
// *****************************************************************************
// Section: Init Function
void DRV_CAPTOUCH_I2C_Init(void);
// *****************************************************************************
// *****************************************************************************
// Section: I2C Access Functions
int8_t DRV_CAPTOUCH_I2C_ReadByte(uint8_t reg, uint8_t *rxd);
int8_t DRV_CAPTOUCH_I2C_ReadHalfWord(uint8_t start_reg, uint16_t *rxd);
int8_t DRV_CAPTOUCH_I2C_ReadWord(uint8_t start_reg, uint32_t *rxd);
int8_t DRV_CAPTOUCH_I2C_ReadArray(uint8_t start_reg, uint8_t *rxd, uint8_t len);
inline int8_t DRV_CAPTOUCH_I2C_ReadRawData(uint8_t *rxd, uint8_t len){
return DRV_CAPTOUCH_I2C_ReadArray(0x00, rxd, len);
}
int8_t DRV_CAPTOUCH_I2C_WriteByte(uint8_t reg, uint8_t data);
int8_t DRV_CAPTOUCH_I2C_WriteHalfWord(uint8_t start_reg, uint16_t data);
int8_t DRV_CAPTOUCH_I2C_WriteWord(uint8_t start_reg, uint32_t data);
int8_t DRV_CAPTOUCH_I2C_WriteArray(uint8_t start_reg, uint8_t *txd, uint8_t len);
// *****************************************************************************
// *****************************************************************************
// Section: Get Functions
int8_t DRV_CAPTOUCH_I2C_GetSinglePixelPoint(POINT_OBJ* point);
int8_t DRV_CAPTOUCH_I2C_GetMultiPixelPoint(POINT_OBJ* point, uint8_t n);
int8_t DRV_CAPTOUCH_I2C_GetTouch(bool *touch);
int8_t DRV_CAPTOUCH_I2C_GetNumberOfTouch(uint8_t *n);
int8_t DRV_CAPTOUCH_I2C_GetDeviceMode(uint8_t *rxd);
int8_t DRV_CAPTOUCH_I2C_GetGestureID(uint8_t *rxd);
int8_t DRV_CAPTOUCH_I2C_GetState(uint8_t *rxd);
int8_t DRV_CAPTOUCH_I2C_GetThresholdObject(THRESHOLD_OBJ *th);
// *****************************************************************************
// *****************************************************************************
// Section: Set Functions
int8_t DRV_CAPTOUCH_I2C_SetDeviceMode(DEVICE_MODE mode);
int8_t DRV_CAPTOUCH_I2C_SetThresholdObject(THRESHOLD_OBJ *th);
int8_t DRV_CAPTOUCH_I2C_SetThresholdDefault(void);
#endif //DRV_CAPTOUCH_I2C_LIBRARY_H