6#define MPR121_I2CADDR_DEFAULT 0x5A
7#define MPR121_TOUCH_THRESHOLD_DEFAULT 12
8#define MPR121_RELEASE_THRESHOLD_DEFAULT 6
86template <
typename Transport>
169 return GetTransportErr();
234 SetTransportErr(transport_.Write(®, 1));
235 SetTransportErr(transport_.Read(&
buff, 1));
247 SetTransportErr(transport_.Write(®, 1));
248 SetTransportErr(transport_.Read((
uint8_t *)&
buff, 2));
266 SetTransportErr(transport_.Write(
buff, 1));
269 SetTransportErr(transport_.Read(&
ecr_backup, 1));
270 if((reg ==
MPR121_ECR) || ((0x73 <= reg) && (reg <= 0x7A)))
278 SetTransportErr(transport_.Write(
buff, 2));
283 SetTransportErr(transport_.Write(
buff, 2));
290 SetTransportErr(transport_.Write(
buff, 2));
340 bool transport_error_;
343 void SetTransportErr(
bool err) { transport_error_ |=
err; }
349 transport_error_ =
false;
Result Init(const Config &config)
Result ReceiveBlocking(uint16_t address, uint8_t *data, uint16_t size, uint32_t timeout)
Result TransmitBlocking(uint16_t address, uint8_t *data, uint16_t size, uint32_t timeout)
Definition leddriver.h:33
void Init(I2CHandle i2c, const uint8_t(&addresses)[numDrivers], DmaBuffer dma_buffer_a, DmaBuffer dma_buffer_b, Pin oe_pin=Pin(PORTX, 0))
Definition leddriver.h:65
Device support for MPR121 12x Capacitive Touch Sensor.
Definition mpr121.h:88
void WriteRegister(uint8_t reg, uint8_t value)
Definition mpr121.h:257
Mpr121()
Definition mpr121.h:90
~Mpr121()
Definition mpr121.h:91
uint16_t FilteredData(uint8_t t)
Definition mpr121.h:195
uint8_t ReadRegister8(uint8_t reg)
Definition mpr121.h:231
uint16_t BaselineData(uint8_t t)
Definition mpr121.h:208
void SetThresholds(uint8_t touch, uint8_t release)
Definition mpr121.h:177
Result
Definition mpr121.h:107
@ OK
Definition mpr121.h:108
@ ERR
Definition mpr121.h:109
uint16_t Touched()
Definition mpr121.h:221
Result Init(Config config)
Definition mpr121.h:115
RegMap
Definition mpr121.h:296
@ MPR121_NHDT
Definition mpr121.h:310
@ MPR121_DEBOUNCE
Definition mpr121.h:316
@ MPR121_MHDR
Definition mpr121.h:302
@ MPR121_GPIOCLR
Definition mpr121.h:331
@ MPR121_GPIODIR
Definition mpr121.h:328
@ MPR121_FDLF
Definition mpr121.h:309
@ MPR121_SOFTRESET
Definition mpr121.h:334
@ MPR121_FDLR
Definition mpr121.h:305
@ MPR121_NHDR
Definition mpr121.h:303
@ MPR121_TARGETLIMIT
Definition mpr121.h:326
@ MPR121_TOUCHTH_0
Definition mpr121.h:314
@ MPR121_NHDF
Definition mpr121.h:307
@ MPR121_NCLR
Definition mpr121.h:304
@ MPR121_TOUCHSTATUS_H
Definition mpr121.h:298
@ MPR121_AUTOCONFIG0
Definition mpr121.h:322
@ MPR121_FILTDATA_0L
Definition mpr121.h:299
@ MPR121_GPIOEN
Definition mpr121.h:329
@ MPR121_MHDF
Definition mpr121.h:306
@ MPR121_FDLT
Definition mpr121.h:312
@ MPR121_LOWLIMIT
Definition mpr121.h:325
@ MPR121_RELEASETH_0
Definition mpr121.h:315
@ MPR121_NCLF
Definition mpr121.h:308
@ MPR121_AUTOCONFIG1
Definition mpr121.h:323
@ MPR121_CHARGETIME_1
Definition mpr121.h:320
@ MPR121_BASELINE_0
Definition mpr121.h:301
@ MPR121_CONFIG2
Definition mpr121.h:318
@ MPR121_CONFIG1
Definition mpr121.h:317
@ MPR121_GPIOSET
Definition mpr121.h:330
@ MPR121_ECR
Definition mpr121.h:321
@ MPR121_UPLIMIT
Definition mpr121.h:324
@ MPR121_FILTDATA_0H
Definition mpr121.h:300
@ MPR121_TOUCHSTATUS_L
Definition mpr121.h:297
@ MPR121_GPIOTOGGLE
Definition mpr121.h:332
@ MPR121_NCLT
Definition mpr121.h:311
@ MPR121_CHARGECURR_0
Definition mpr121.h:319
uint16_t ReadRegister16(uint8_t reg)
Definition mpr121.h:244
Mpr121I2CTransport()
Definition mpr121.h:20
bool Init(Config config)
Definition mpr121.h:47
bool Read(uint8_t *data, uint16_t size)
Definition mpr121.h:70
~Mpr121I2CTransport()
Definition mpr121.h:21
bool Write(uint8_t *data, uint16_t size)
Definition mpr121.h:63
static void Delay(uint32_t delay_ms)
#define MPR121_TOUCH_THRESHOLD_DEFAULT
default touch threshold value
Definition mpr121.h:7
#define MPR121_I2CADDR_DEFAULT
default I2C address
Definition mpr121.h:6
#define MPR121_RELEASE_THRESHOLD_DEFAULT
default relese threshold value
Definition mpr121.h:8
Hardware defines and helpers for daisy field platform.
Definition index.h:2
@ PORTB
Definition daisy_core.h:178
Peripheral
Definition i2c.h:40
uint8_t release_threshold
Definition mpr121.h:97
Transport::Config transport_config
Definition mpr121.h:95
uint8_t touch_threshold
Definition mpr121.h:96
Config()
Definition mpr121.h:99
Pin sda
Definition mpr121.h:28
I2CHandle::Config::Peripheral periph
Definition mpr121.h:25
Pin scl
Definition mpr121.h:27
Config()
Definition mpr121.h:34
I2CHandle::Config::Mode mode
Definition mpr121.h:30
uint8_t dev_addr
Definition mpr121.h:32
I2CHandle::Config::Speed speed
Definition mpr121.h:26
representation of hardware port/pin combination
Definition daisy_core.h:193