触摸功能换成MPR121芯片,飞思卡尔(freescale)的产品。 又是网上搜资料,又是看官方的AN,又是对别人的产品上抓IIC包。终于有效果了。
网络上找到的值与官方AN上的demo都有错或不合理。综合手上资料及的样机:折腾出一个合理的初始配置,记录一下备忘。
1. MPR121使用前要初始化:各地址及其对应值如下:
{0x80, 0x63}, //soft reset{0x80, 0x63}, //soft reset
{0x73, 0xff},
{0x74, 0xff},
{0x76, 0xff},
{0x77, 0xff},
{0x75, 0xff},
{0x81, 0x00},
{0x82, 0x00},
{0x83, 0x00},
{0x84, 0x00},
// Section A touchpd baseline, filter rising. This group controls filtering when data is > baseline.
{0x2b, 0x01}, //0xff//max half delta rising
{0x2c, 0x01}, //0xff//noise half delta rising
{0x2d, 0x00}, //0 noise count limit rising
{0x2e, 0x00}, //delay limit rising
// Section B failing This group controls filtering when data is < baseline.
{0x2f, 0x01},
{0x30, 0x01},
{0x31, 0xFF},
{0x32, 0x00},
//...touched
{0x33, 0x00}, //Noise half delta touched
{0x34, 0x00}, //Noise counts touched
{0x35, 0x00}, //Filter delay touched
{0x36, 0x0f},
{0x37, 0x0f},
{0x38, 0x00},
{0x39, 0x00},
{0x3a, 0x01},
{0x3b, 0x01},
{0x3c, 0xff},
{0x3d, 0xff},
{0x3e, 0x00},
{0x3f, 0x00},
{0x40, 0x00},
// Section C
// This group sets touch and release thresholds for each electrode
#define ELE0_T 0x41
#define ELE0_R 0x42
#define ELE1_T 0x43
#define ELE1_R 0x44
#define ELE2_T 0x45
#define ELE2_R 0x46
#define ELE3_T 0x47
#define ELE3_R 0x48
#define ELE4_T 0x49
#define ELE4_R 0x4A
#define ELE5_T 0x4B
#define ELE5_R 0x4C
#define ELE6_T 0x4D
#define ELE6_R 0x4E
#define ELE7_T 0x4F
#define ELE7_R 0x50
#define ELE8_T 0x51
#define ELE8_R 0x52
#define ELE9_T 0x53
#define ELE9_R 0x54
#define ELE10_T 0x55
#define ELE10_R 0x56
#define ELE11_T 0x57
#define ELE11_R 0x58
#define TOU_THRESH 3
//#define REL_THRESH 0x07
#define REL_THRESH 2
{ELE0_T, TOU_THRESH},
{ELE0_R, REL_THRESH},
{ELE1_T, TOU_THRESH},
{ELE1_R, REL_THRESH},
{ELE2_T, TOU_THRESH},
{ELE2_R, REL_THRESH},
{ELE3_T, TOU_THRESH},
{ELE3_R, REL_THRESH},
{ELE4_T, TOU_THRESH},
{ELE4_R, REL_THRESH},
{ELE5_T, TOU_THRESH},
{ELE5_R, REL_THRESH},
{ELE6_T, TOU_THRESH},
{ELE6_R, REL_THRESH},
{ELE7_T, TOU_THRESH},
{ELE7_R, REL_THRESH},
{ELE8_T, TOU_THRESH},
{ELE8_R, REL_THRESH},
{ELE9_T, TOU_THRESH},
{ELE9_R, REL_THRESH},
{ELE10_T, TOU_THRESH},
{ELE10_R, REL_THRESH},
{ELE11_T, TOU_THRESH},
{ELE11_R, REL_THRESH},
{0x59, 0x02},
{0x5a, 0x01},
{0x5b, 0x00},
{0x5c, 0x10},
{0x5d, 0x24},
// Enable Auto Config and auto Reconfig
{0x7B, 0x0B},
{0x7D, 0xc8},
{0x7E, 0x82},
{0x7F, 0xb4},
{0x5E, 0xbc},
其顺序不能随意变动。{0x5E, 0xbc}必须在最一步写入。
2. 读数据
触摸状态对应地址0. 读数据前要先写入地址0, 然后再读出2个字节。也就是读出地址0和地址1的内容。
阅读(2935) | 评论(0) | 转发(0) |