зеркало из https://github.com/microsoft/jacdac-c.git
use new cap-touch interface; don't limit number of touches
This commit is contained in:
Родитель
4654b4efcf
Коммит
1d5ec9d2f5
|
@ -15,6 +15,7 @@
|
||||||
#define GEN_STATUS_ADDR 0x2
|
#define GEN_STATUS_ADDR 0x2
|
||||||
#define SEN_STATUS_ADDR 0x3
|
#define SEN_STATUS_ADDR 0x3
|
||||||
|
|
||||||
|
#define REPEAT_ENABLE_ADDR 0x28
|
||||||
#define MULTI_TOUCH_CFG_ADDR 0x2a
|
#define MULTI_TOUCH_CFG_ADDR 0x2a
|
||||||
|
|
||||||
static void writeReg(uint8_t reg, uint8_t val) {
|
static void writeReg(uint8_t reg, uint8_t val) {
|
||||||
|
@ -31,25 +32,28 @@ static int readReg(uint8_t reg) {
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void clear_int(void) {
|
||||||
|
writeReg(MAIN_CONTROL_ADDR, 0b00000000); // no multi-touch processing; we let app do that
|
||||||
|
writeReg(REPEAT_ENABLE_ADDR, 0);
|
||||||
|
}
|
||||||
|
|
||||||
void *cap1298_read(void) {
|
void *cap1298_read(void) {
|
||||||
|
clear_int();
|
||||||
uint8_t gen_status;
|
uint8_t gen_status;
|
||||||
uint8_t sen_status;
|
uint8_t sen_status;
|
||||||
static uint32_t sample[1];
|
static uint16_t sample[8];
|
||||||
readData(GEN_STATUS_ADDR, &gen_status, 1);
|
readData(GEN_STATUS_ADDR, &gen_status, 1);
|
||||||
readData(SEN_STATUS_ADDR, &sen_status, 1);
|
readData(SEN_STATUS_ADDR, &sen_status, 1);
|
||||||
writeReg(MAIN_CONTROL_ADDR, 0b00000000);
|
writeReg(MAIN_CONTROL_ADDR, 0b00000000);
|
||||||
// DMESG("G: %x S: %x", gen_status, sen_status);
|
// DMESG("G: %x S: %x", gen_status, sen_status);
|
||||||
sample[0] = sen_status;
|
for (int i = 0; i < 8; ++i)
|
||||||
|
sample[i] = sen_status & (1 << i) ? 0xffff : 0x0000;
|
||||||
return sample;
|
return sample;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cap1298_cfg(void) {
|
void cap1298_cfg(void) {
|
||||||
#ifdef PIN_INT
|
clear_int();
|
||||||
writeReg(INT_EN_ADDR, 0xff);
|
writeReg(MULTI_TOUCH_CFG_ADDR, 0b00000000);
|
||||||
#endif
|
|
||||||
writeReg(MAIN_CONTROL_ADDR, 0b00000000);
|
|
||||||
|
|
||||||
writeReg(MULTI_TOUCH_CFG_ADDR, 0b10001100);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cap1298_init(void) {
|
void cap1298_init(void) {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче