資源簡介
1、代碼為個人原創,基于MH1902通過GPIO模擬IIC獲取TP的坐標;
2、包含TP相關寄存器的詳細文檔資料;
3、TP先由AP端控制,當適用于特定用途時,由SP接管TP完成相對應的工作,最終再交給AP端控制;
代碼片段和文件信息
#define?EXT_CTP_GLOBALS
#include?“common.h“
#include?“mhscpu_exti.h“
#include?“mhscpu_gpio.h“
#include?“si2c_delay.h“
#include?“simulation_i2c.h“
#include?“softtimer.h“
#include?“ctp.h“
enum?pinkey_type?{
????PINKEY_NUMBER?=?1
????PINKEY_ENTER??=?3
????PINKEY_CANCEL?=?4
????PINKEY_CLEAR??=?7
};
enum?button_no?{
????BUTTON_CANCEL?=?10
????BUTTON_CLEAR??=?11
????BUTTON_ENTER??=?12
};
#define?isNumber(no)????((no)?<=?9)??//?unsigned?char?is?>=?0?so?compare?with?9?only
#define?isCancel(no)????((no)?==?BUTTON_CANCEL)
#define?isClear(no)?????((no)?==?BUTTON_CLEAR)
#define?isEnter(no)?????((no)?==?BUTTON_ENTER)
/*
?*?Note.
?*?Please?do?not?change?the?below?setting.
?*?there?are?13?buttons?accordding?to?the?pinblock?layout
?*?so?do?not?change?it.
?*/
#define?PIN_BUTTON_MAX??13
struct?button_info?{
????unsigned?char?b_no;
????
????unsigned?short?x1;
????unsigned?short?y1;
????unsigned?short?x2;
????unsigned?short?y2;??
};
/*?
?*?touch?screen?supports?2?points?at?most?
?*?but?here?use?one?point?only.
?*/
#define?TPD_SUPPORT_POINTS?2
struct?xy_info?{
????unsigned?short?x[TPD_SUPPORT_POINTS];
unsigned?short?y[TPD_SUPPORT_POINTS];
unsigned?char?p[TPD_SUPPORT_POINTS];
unsigned?char?id[TPD_SUPPORT_POINTS];
unsigned?short?count;
};
struct?ctp_dev?{
????unsigned?char?slave_addr;
????
????unsigned?int?touch_cnt;
????unsigned?int?b_cnt;
????unsigned?int?min_len;
????unsigned?int?max_len;?
????unsigned?short?timer_id;
????int??????????irq;
????unsigned?int?ext_int_line;
????unsigned?int?irq_gpio;
????unsigned?int?reset_gpio;
????GPIO_TypeDef?*port;
????unsigned?int?circ_size;
????struct?xy_info?t_info;
????struct?button_info?b_table[PIN_BUTTON_MAX];
????struct?_strRecvPack?pin_block_info;
????struct?circ_buf?circ;
???
????struct?__TIMER?timer;
????int?(*init)(struct?ctp_dev?*ctp);
????void?(*timerstart)(struct?ctp_dev?*ctp);
????
????void?(*timerstop)(struct?ctp_dev?*ctp);
????void?(*reset_circ_buf)(struct?ctp_dev?*ctp);
????void?(*release_button)(struct?ctp_dev?*ctp);
????int?(*get_xy)(struct?ctp_dev?*ctp);
};
static?unsigned?char?g_key_buf[32]?=?{0};
static?void?CTPINT_GPIO_Configuration(struct?ctp_dev?*ctp)
{
GPIO_InitTypeDef?GPIO_InitStruct;
NVIC_InitTypeDef?NVIC_InitStructure;
GPIO_InitStruct.GPIO_Pin?=?ctp->irq_gpio;
GPIO_InitStruct.GPIO_Mode?=?GPIO_Mode_IN_FLOATING;
GPIO_InitStruct.GPIO_Remap?=?GPIO_Remap_1;
GPIO_Init(ctp->port?&GPIO_InitStruct);?
GPIO_InitStruct.GPIO_Pin?=?ctp->reset_gpio;
GPIO_InitStruct.GPIO_Mode?=?GPIO_Mode_Out_PP;
GPIO_InitStruct.GPIO_Remap?=?GPIO_Remap_1;
GPIO_Init(ctp->port?&GPIO_InitStruct);??
????GPIO_SetBits(ctp->port?GPIO_InitStruct.GPIO_Pin);
NVIC_SetPriorityGrouping(NVIC_PriorityGroup_3);
EXTI_DeInit();
NVIC_InitStructure.NVIC_IRQChannel?=?ctp->irq;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority?=?3;
NVIC_InitStructure.NVIC_IRQChannelSubPriority?=
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????192907??2018-11-09?14:10??FT6336\AN_CTPM_Standard_eng——new.pdf
?????文件?????984619??2018-11-09?14:17??FT6336\FT5x46i_FT34x7_Firmware?外部寄存器?(20160123).pdf
?????文件??????25388??2018-11-09?11:34??FT6336\Ft6336GU_Firmware?外部寄存器_20151112.xlsx
?????文件????1172691??2018-11-09?14:09??FT6336\FTS?IC?上電時序要求.pdf
?????文件??????12517??2018-11-14?17:55??FT6336\i2c\ctp.c
?????文件????????531??2018-11-14?17:56??FT6336\i2c\ctp.h
?????文件???????3070??2018-11-14?17:57??FT6336\i2c\si2c_delay.c
?????文件????????942??2018-11-14?17:58??FT6336\i2c\si2c_delay.h
?????文件??????14319??2018-11-14?17:59??FT6336\i2c\simulation_i2c.c
?????文件???????1483??2018-11-14?18:00??FT6336\i2c\simulation_i2c.h
?????文件???????5365??2018-11-14?18:01??FT6336\i2c\SoftTimer.c
?????文件???????1049??2018-11-14?18:02??FT6336\i2c\SoftTimer.h
?????文件???????1477??2018-11-09?11:34??FT6336\TXDT500WYPA_ILI9881P_LD050HF1L02_Column_4lane_20170919.txt
?????目錄??????????0??2018-11-14?18:02??FT6336\i2c
?????目錄??????????0??2018-11-14?17:41??FT6336
-----------?---------??----------?-----??----
??????????????2416358????????????????????15
- 上一篇:科沃茲導航VK162 VK172模塊驅動.rar
- 下一篇:W-代數的伽利略收縮
評論
共有 條評論