i2ccaptouch.c File Reference
I2C touch support on Touch Display.
License
Copyright 2018 Silicon Laboratories Inc. www.silabs.com
The licensor of this software is Silicon Laboratories Inc. Your use of this software is governed by the terms of Silicon Labs Master Software License Agreement (MSLA) available at www.silabs.com/about-us/legal/master-software-license-agreement. This software is distributed to you in Source Code format and is governed by the sections of the MSLA applicable to Source Code.
Definition in file
i2ccaptouch.c
.
#include "
i2ccaptouch.h
"
#include "captouchconfig.h"
#include "i2cspmconfig.h"
#include "
i2cspm.h
"
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include "em_device.h"
#include "
em_cmu.h
"
#include "
em_core.h
"
#include "
em_gpio.h
"
#include "
em_i2c.h
"
#include "
emstatus.h
"
#include "
ustimer.h
"
Functions |
|
uint32_t | CAPT_enable (bool enable, bool wait) |
Enable touch controller. When enabling this function will wait until the controller is started before returning.
|
|
uint32_t | CAPT_getTouches ( CAPT_Touch *touchBuffer, uint8_t len, uint8_t *nTouches) |
Update the list of registered touches This function also updates the list of new touches since last time CAPT_update was called.
|
|
uint32_t | CAPT_init (void) |
Initialize capacitive touch controller.
|
|
static I2C_TransferReturn_TypeDef | controllerRead (void) |
Read contents of all registers in the touch controller.
|
|
static uint32_t | gpioInit (void) |
Initialize all GPIO pins.
|
|
static uint32_t | i2cInit (void) |
Initialize I2C peripheral.
|
|
static uint32_t | parseData ( CAPT_Touch *buffer, uint8_t len, uint8_t *nTouches) |
Parse data from i2cReadBuffer into buffer.
|
|
Variables |
|
static I2C_TypeDef * | i2c = CAPT_CONFIG_I2C |
static uint8_t | i2cReadBuffer [CAPT_I2C_BUFFER_SIZE] |
static volatile uint8_t | samplesSinceLastUpdate = 0 |
Function Documentation
uint32_t CAPT_enable | ( | bool |
enable,
|
bool |
wait
|
||
) |
Enable touch controller. When enabling this function will wait until the controller is started before returning.
- Parameters
-
enable
If true the controller will be enabled, otherwise it will be disabled. wait
If true when enabling controller, wait for the touch controller to boot after enabling it. Has no effect when disabling the touch controller.
- Returns
- CAPT_OK on success.
Definition at line
116
of file
i2ccaptouch.c
.
References GPIO_PinOutClear() , GPIO_PinOutSet() , USTIMER_DeInit() , USTIMER_DelayIntSafe() , and USTIMER_Init() .
uint32_t CAPT_getTouches | ( | CAPT_Touch * |
touchBuffer,
|
uint8_t |
len,
|
||
uint8_t * |
nTouches
|
||
) |
Update the list of registered touches This function also updates the list of new touches since last time CAPT_update was called.
- Parameters
-
*buffer
Pointer to a buffer in which to store the CAPT_Touch structs len
Length (in number of CAPT_Touch elements) of the buffer *nTouches
Number of touches read out
- Returns
- CAPT_OK on success. CAPT_ERROR_PARSE_ERROR if data is invalid. CAPT_ERROR_BUFFER_TOO_SMALL if the buffer is too short. In this case as much data as possible is stored in the buffer. CAPT_ERROR_I2C_ERROR on I2C transfer error
Definition at line
164
of file
i2ccaptouch.c
.
References controllerRead() , and parseData() .
uint32_t CAPT_init | ( | void |
|
) |
Initialize capacitive touch controller.
- Returns
- CAPT_OK on success
Definition at line
84
of file
i2ccaptouch.c
.
References gpioInit() , and i2cInit() .
|
static |
Read contents of all registers in the touch controller.
- Returns
- i2cTransferDone on success.
Definition at line
259
of file
i2ccaptouch.c
.
References I2C_TransferSeq_TypeDef::addr , I2C_TransferSeq_TypeDef::buf , I2C_TransferSeq_TypeDef::data , I2C_TransferSeq_TypeDef::flags , I2C_FLAG_READ , I2C_FLAG_WRITE , I2CSPM_Transfer() , i2cTransferDone , and I2C_TransferSeq_TypeDef::len .
Referenced by
CAPT_getTouches()
.
|
static |
Initialize all GPIO pins.
- Returns
- CAPT_OK on success
Definition at line
204
of file
i2ccaptouch.c
.
References CMU_ClockEnable() , cmuClock_GPIO , GPIO_PinModeSet() , gpioModeInput , gpioModePushPull , and gpioModeWiredAnd .
Referenced by
CAPT_init()
.
|
static |
Initialize I2C peripheral.
- Returns
- CAPT_OK on success
Definition at line
238
of file
i2ccaptouch.c
.
References I2CSPM_Init() .
Referenced by
BOARD_init()
,
BSP_initBoard()
,
CAPT_init()
, and
I2CSPM_Init()
.
|
static |
Parse data from i2cReadBuffer into buffer.
- Parameters
-
*buffer
Pointer to a buffer in which to store the CAPT_Touch structs len
Length (in number of CAPT_Touch elements) of the buffer *nTouches
Number of touches read out
- Returns
- CAPT_OK on success. CAPT_ERROR_PARSE_ERROR if data is invalid. CAPT_ERROR_BUFFER_TOO_SMALL if the buffer is too short. In this case as much data as possible is stored in the buffer.
Definition at line
319
of file
i2ccaptouch.c
.
Referenced by
CAPT_getTouches()
.