Driver(touch): fix touch sensor driver for esp32s2.

1.update touch sensor driver for esp32s2;
2.update unit test for touch sensor;
3.update register files about touch sensor;
This commit is contained in:
fuzhibo 2020-02-18 20:29:20 +08:00
parent c9f29e0b59
commit dfbb108ab4
6 changed files with 2746 additions and 0 deletions

View file

@ -0,0 +1,330 @@
/*
Tests for the touch sensor device driver
*/
#include "esp_system.h"
#include "driver/touch_pad.h"
#include "unity.h"
#include "esp_system.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_log.h"
#include "nvs_flash.h"
#include "test_utils.h"
#include "soc/rtc_cntl_reg.h"
#include "soc/rtc_cntl_struct.h"
#include "soc/sens_reg.h"
#include "soc/sens_struct.h"
#include "soc/rtc_cntl_reg.h"
#include "soc/rtc_cntl_struct.h"
#include "soc/rtc_io_reg.h"
#include "soc/rtc_io_struct.h"
static const char *TAG = "test_touch";
#define TOUCH_READ_INVALID_VAL (0)
#define TOUCHPAD_FILTER_TOUCH_PERIOD (10)
#define TOUCH_REG_BASE_TEST() ({ \
TEST_ASSERT_EQUAL_UINT32(RTC_CNTL_BROWN_OUT_REG, &RTCCNTL.brown_out.val); \
TEST_ASSERT_EQUAL_UINT32(REG_GET_FIELD(SENS_SARDATE_REG, SENS_SAR_DATE), SENS.sardate.sar_date); \
TEST_ASSERT_EQUAL_UINT32(REG_GET_FIELD(RTC_IO_DATE_REG, RTC_IO_IO_DATE), RTCIO.date.date); \
})
#define TOUCH_READ_ERROR (50)
#define TEST_TOUCH_COUNT_NUM (10)
#define TEST_TOUCH_CHANNEL (9)
static touch_pad_t touch_list[TEST_TOUCH_CHANNEL] = {
TOUCH_PAD_NUM0,
// TOUCH_PAD_NUM1 is GPIO0, for download.
TOUCH_PAD_NUM2,
TOUCH_PAD_NUM3,
TOUCH_PAD_NUM4,
TOUCH_PAD_NUM5,
TOUCH_PAD_NUM6,
TOUCH_PAD_NUM7,
TOUCH_PAD_NUM8,
TOUCH_PAD_NUM9,
};
static void printf_touch_hw_read(const char *str)
{
uint16_t touch_value;
printf("[%s] ", str);
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
while (!touch_pad_meas_is_done()) ;
touch_pad_read_raw_data(touch_list[i], &touch_value);
printf("[%d]%d ", touch_list[i], touch_value);
}
printf("\r\n");
}
/*
* Change the slope to get larger value from touch sensor.
*/
static void test_push_fake(touch_pad_t pad_num)
{
touch_pad_set_cnt_mode(pad_num, TOUCH_PAD_SLOPE_2, TOUCH_PAD_TIE_OPT_DEFAULT);
}
/*
* Change the slope to get larger value from touch sensor.
*/
static void test_release_fake(touch_pad_t pad_num)
{
touch_pad_set_cnt_mode(pad_num, TOUCH_PAD_SLOPE_7, TOUCH_PAD_TIE_OPT_DEFAULT);
}
static esp_err_t test_touch_sw_read(void)
{
ESP_LOGI(TAG, "%s", __func__);
uint16_t touch_value;
TEST_ESP_OK( touch_pad_init() );
TEST_ESP_OK( touch_pad_set_fsm_mode(TOUCH_FSM_MODE_SW) );
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
TEST_ESP_OK( touch_pad_config(touch_list[i], TOUCH_READ_INVALID_VAL) );
}
// Start task to read values sensed by pads
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
TEST_ESP_OK( touch_pad_read(touch_list[i], &touch_value) );
printf("T%d:[%4d] ", touch_list[i], touch_value);
TEST_ASSERT_NOT_EQUAL(TOUCH_READ_INVALID_VAL, touch_value);
}
printf("\n");
TEST_ESP_OK( touch_pad_deinit() );
return ESP_OK;
}
static esp_err_t test_touch_timer_read(void)
{
ESP_LOGI(TAG, "%s", __func__);
uint16_t touch_value[TEST_TOUCH_CHANNEL], touch_temp[TEST_TOUCH_CHANNEL];
int t_cnt = TEST_TOUCH_COUNT_NUM;
TEST_ESP_OK( touch_pad_init() );
TEST_ESP_OK( touch_pad_set_fsm_mode(TOUCH_FSM_MODE_TIMER) );
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
TEST_ESP_OK( touch_pad_config(touch_list[i], TOUCH_READ_INVALID_VAL) );
}
// Start task to read values sensed by pads
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
TEST_ESP_OK( touch_pad_read(touch_list[i], &touch_value[i]) );
printf("T%d:[%4d] ", touch_list[i], touch_value[i]);
TEST_ASSERT_NOT_EQUAL(TOUCH_READ_INVALID_VAL, touch_value[i]);
}
while (t_cnt--) {
// Start task to read values sensed by pads
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
TEST_ESP_OK( touch_pad_read(touch_list[i], &touch_temp[i]) );
TEST_ASSERT_NOT_EQUAL(TOUCH_READ_INVALID_VAL, touch_temp[i]);
TEST_ASSERT_UINT32_WITHIN(TOUCH_READ_ERROR, touch_temp[i], touch_value[i]);
}
vTaskDelay(50 / portTICK_PERIOD_MS);
}
TEST_ESP_OK( touch_pad_deinit() );
return ESP_OK;
}
static esp_err_t test_touch_filtered_read(void)
{
ESP_LOGI(TAG, "%s", __func__);
uint16_t touch_value, touch_temp;
int t_cnt = TEST_TOUCH_COUNT_NUM;
TEST_ESP_OK( touch_pad_init() );
TEST_ESP_OK( touch_pad_set_fsm_mode(TOUCH_FSM_MODE_TIMER) );
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
TEST_ESP_OK( touch_pad_config(touch_list[i], TOUCH_READ_INVALID_VAL) );
}
// Initialize and start a software filter to detect slight change of capacitance.
touch_pad_filter_start(TOUCHPAD_FILTER_TOUCH_PERIOD);
vTaskDelay(10 / portTICK_PERIOD_MS);
while (t_cnt--) {
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
TEST_ESP_OK( touch_pad_read(touch_list[i], &touch_value) );
TEST_ESP_OK( touch_pad_read_raw_data(touch_list[i], &touch_value) );
TEST_ASSERT_NOT_EQUAL(TOUCH_READ_INVALID_VAL, touch_value);
TEST_ESP_OK( touch_pad_read_filtered(touch_list[i], &touch_temp) );
TEST_ASSERT_NOT_EQUAL(TOUCH_READ_INVALID_VAL, touch_temp);
TEST_ASSERT_UINT32_WITHIN(TOUCH_READ_ERROR, touch_temp, touch_value);
printf("T%d:[%4d] ", touch_list[i], touch_value);
}
vTaskDelay(50 / portTICK_PERIOD_MS);
}
printf("\n");
TEST_ESP_OK( touch_pad_deinit() );
return ESP_OK;
}
// test the basic configuration function with right parameters and error parameters
TEST_CASE("Touch Sensor all channel read test", "[touch]")
{
TOUCH_REG_BASE_TEST();
TEST_ESP_OK( test_touch_sw_read() );
TEST_ESP_OK( test_touch_timer_read() );
TEST_ESP_OK( test_touch_filtered_read() );
}
static int test_touch_parameter(touch_pad_t pad_num, int meas_time, int slp_time, int vol_h, int vol_l, int vol_a, int slope)
{
ESP_LOGI(TAG, "%s", __func__);
uint16_t touch_value;
TEST_ESP_OK( touch_pad_init() );
TEST_ESP_OK( touch_pad_set_fsm_mode(TOUCH_FSM_MODE_TIMER) );
TEST_ESP_OK( touch_pad_config(pad_num, TOUCH_READ_INVALID_VAL) );
touch_pad_set_meas_time(slp_time, meas_time);
touch_pad_set_voltage(vol_h, vol_l, vol_a);
touch_pad_set_cnt_mode(pad_num, slope, TOUCH_PAD_TIE_OPT_DEFAULT);
// Initialize and start a software filter to detect slight change of capacitance.
touch_pad_filter_start(TOUCHPAD_FILTER_TOUCH_PERIOD);
vTaskDelay(500 / portTICK_PERIOD_MS);
// Start task to read values sensed by pads
TEST_ESP_OK( touch_pad_read(pad_num, &touch_value) );
TEST_ASSERT_NOT_EQUAL(TOUCH_READ_INVALID_VAL, touch_value);
printf("T%d:[%4d] ", pad_num, touch_value);
TEST_ESP_OK( touch_pad_read_raw_data(pad_num, &touch_value) );
TEST_ASSERT_NOT_EQUAL(TOUCH_READ_INVALID_VAL, touch_value);
printf("T%d:[%4d] ", pad_num, touch_value);
TEST_ESP_OK( touch_pad_read_filtered(pad_num, &touch_value) );
TEST_ASSERT_NOT_EQUAL(TOUCH_READ_INVALID_VAL, touch_value);
printf("T%d:[%4d] \n", pad_num, touch_value);
TEST_ESP_OK( touch_pad_deinit() );
return touch_value;
}
TEST_CASE("Touch Sensor parameters test", "[touch]")
{
int touch_val[5] = {0};
ESP_LOGI(TAG, "Charge / incharge voltage level test");
touch_val[0] = test_touch_parameter(touch_list[2], TOUCH_PAD_MEASURE_CYCLE_DEFAULT, TOUCH_PAD_SLEEP_CYCLE_DEFAULT,
TOUCH_HVOLT_2V7, TOUCH_LVOLT_0V5, TOUCH_HVOLT_ATTEN_0V,
TOUCH_PAD_SLOPE_DEFAULT);
touch_val[1] = test_touch_parameter(touch_list[2], TOUCH_PAD_MEASURE_CYCLE_DEFAULT, TOUCH_PAD_SLEEP_CYCLE_DEFAULT,
TOUCH_HVOLT_2V5, TOUCH_LVOLT_0V6, TOUCH_HVOLT_ATTEN_1V,
TOUCH_PAD_SLOPE_DEFAULT);
touch_val[2] = test_touch_parameter(touch_list[0], TOUCH_PAD_MEASURE_CYCLE_DEFAULT, TOUCH_PAD_SLEEP_CYCLE_DEFAULT,
TOUCH_HVOLT_2V4, TOUCH_LVOLT_0V8, TOUCH_HVOLT_ATTEN_1V5,
TOUCH_PAD_SLOPE_DEFAULT);
TEST_ASSERT_GREATER_OR_EQUAL(touch_val[0], touch_val[1]);
TEST_ASSERT_GREATER_OR_EQUAL(touch_val[1], touch_val[2]);
ESP_LOGI(TAG, "Measure time / sleep time test");
touch_val[0] = test_touch_parameter(touch_list[0], 0xff, 0xa,
TOUCH_PAD_HIGH_VOLTAGE_THRESHOLD, TOUCH_PAD_LOW_VOLTAGE_THRESHOLD, TOUCH_PAD_ATTEN_VOLTAGE_THRESHOLD, TOUCH_PAD_SLOPE_DEFAULT);
touch_val[1] = test_touch_parameter(touch_list[0], 0x1ff, 0xf,
TOUCH_PAD_HIGH_VOLTAGE_THRESHOLD, TOUCH_PAD_LOW_VOLTAGE_THRESHOLD, TOUCH_PAD_ATTEN_VOLTAGE_THRESHOLD, TOUCH_PAD_SLOPE_DEFAULT);
touch_val[2] = test_touch_parameter(touch_list[0], 0x2fff, 0x1f,
TOUCH_PAD_HIGH_VOLTAGE_THRESHOLD, TOUCH_PAD_LOW_VOLTAGE_THRESHOLD, TOUCH_PAD_ATTEN_VOLTAGE_THRESHOLD, TOUCH_PAD_SLOPE_DEFAULT);
TEST_ASSERT_GREATER_OR_EQUAL(touch_val[0], touch_val[1]);
TEST_ASSERT_GREATER_OR_EQUAL(touch_val[1], touch_val[2]);
ESP_LOGI(TAG, "Charge / incharge slope level test");
touch_val[0] = test_touch_parameter(touch_list[1], TOUCH_PAD_MEASURE_CYCLE_DEFAULT, TOUCH_PAD_SLEEP_CYCLE_DEFAULT,
TOUCH_PAD_HIGH_VOLTAGE_THRESHOLD, TOUCH_PAD_LOW_VOLTAGE_THRESHOLD, TOUCH_PAD_ATTEN_VOLTAGE_THRESHOLD, 1);
touch_val[1] = test_touch_parameter(touch_list[1], TOUCH_PAD_MEASURE_CYCLE_DEFAULT, TOUCH_PAD_SLEEP_CYCLE_DEFAULT,
TOUCH_PAD_HIGH_VOLTAGE_THRESHOLD, TOUCH_PAD_LOW_VOLTAGE_THRESHOLD, TOUCH_PAD_ATTEN_VOLTAGE_THRESHOLD, 3);
touch_val[2] = test_touch_parameter(touch_list[1], TOUCH_PAD_MEASURE_CYCLE_DEFAULT, TOUCH_PAD_SLEEP_CYCLE_DEFAULT,
TOUCH_PAD_HIGH_VOLTAGE_THRESHOLD, TOUCH_PAD_LOW_VOLTAGE_THRESHOLD, TOUCH_PAD_ATTEN_VOLTAGE_THRESHOLD, 7);
TEST_ASSERT_GREATER_OR_EQUAL(touch_val[0], touch_val[1]);
TEST_ASSERT_GREATER_OR_EQUAL(touch_val[1], touch_val[2]);
}
static bool s_pad_activated[TOUCH_PAD_MAX];
static void test_touch_intr_cb(void *arg)
{
uint32_t pad_intr = touch_pad_get_status();
ets_printf("T%x ", pad_intr);
//clear interrupt
touch_pad_clear_status();
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
if ((pad_intr >> touch_list[i]) & 0x1) {
s_pad_activated[touch_list[i]] = true;
}
}
}
static esp_err_t test_touch_interrupt(void)
{
ESP_LOGI(TAG, "%s", __func__);
uint16_t touch_value;
TEST_ESP_OK( touch_pad_init() );
TEST_ESP_OK( touch_pad_set_fsm_mode(TOUCH_FSM_MODE_TIMER) );
touch_pad_set_voltage(TOUCH_HVOLT_2V7, TOUCH_LVOLT_0V5, TOUCH_HVOLT_ATTEN_1V);
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
TEST_ESP_OK( touch_pad_config(touch_list[i], TOUCH_READ_INVALID_VAL) );
}
// Initialize and start a software filter to detect slight change of capacitance.
touch_pad_filter_start(TOUCHPAD_FILTER_TOUCH_PERIOD);
vTaskDelay(10 / portTICK_PERIOD_MS);
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
//read filtered value
TEST_ESP_OK( touch_pad_read_filtered(touch_list[i], &touch_value) );
ESP_LOGI(TAG, "test init: touch pad [%d] val is %d", touch_list[i], touch_value);
//set interrupt threshold.
TEST_ESP_OK( touch_pad_set_thresh(touch_list[i], touch_value * 2 / 3) );
}
// Register touch interrupt ISR
TEST_ESP_OK( touch_pad_isr_register(test_touch_intr_cb, NULL) );
TEST_ESP_OK( touch_pad_clear_status() );
TEST_ESP_OK( touch_pad_intr_enable() );
int test_cnt = TEST_TOUCH_COUNT_NUM;
while (test_cnt--) {
ESP_LOGI(TAG, "touch push");
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
test_push_fake(touch_list[i]);
}
vTaskDelay(100 / portTICK_PERIOD_MS);
printf_touch_hw_read("push");
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
if (s_pad_activated[touch_list[i]] == false) {
ESP_LOGE(TAG, "touch%d not active", touch_list[i]);
TEST_FAIL();
}
}
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
s_pad_activated[touch_list[i]] = 0;
}
ESP_LOGI(TAG, "touch release");
for (int i = 0; i < TEST_TOUCH_CHANNEL; i++) {
test_release_fake(touch_list[i]);
}
printf_touch_hw_read("release");
}
TEST_ESP_OK( touch_pad_deinit() );
return ESP_OK;
}
TEST_CASE("Touch Sensor interrupt test", "[touch]")
{
TEST_ESP_OK( test_touch_interrupt() );
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,186 @@
#include "esp_err.h"
#include "driver/uart.h"
#include "esp32s2/rom/uart.h"
#define ROM_UART_DRIVER_ENABLE 0
#if ROM_UART_DRIVER_ENABLE
static uint8_t scope_uart_num = 0;
static int8_t uart_used = 0;
#else
static uint8_t scope_uart_num = 255;
static int8_t uart_used = -1;
#endif
static int scope_tx_io_num = 0;
static int scope_rx_io_num = 0;
static int scope_debug_baud_rate = 256000;
static unsigned char datascope_output_buffer[42] = {0}; // Data buff.
/**
* @brief Translate a float data to four unsigned char data for uart TX.
* @param target target float data address.
* @param buf save translated data.
* @param offset the start position in buf.
* @return
* - void
*/
static void Float2Byte(float *target, unsigned char *buf, unsigned char offset)
{
unsigned char *point;
point = (unsigned char*)target; //Get the address of float.
buf[offset] = point[0];
buf[offset+1] = point[1];
buf[offset+2] = point[2];
buf[offset+3] = point[3];
}
/**
* @brief Add data to channal buff.
* @param Data target data.
* @param Channel target channel (1 - 10).
* @return
* - void
*/
static void datascope_get_channel_data(float data, unsigned char channel)
{
if ( (channel > 10) || (channel == 0) ) {
return;
} else {
switch (channel) {
case 1: Float2Byte(&data,datascope_output_buffer,1); break;
case 2: Float2Byte(&data,datascope_output_buffer,5); break;
case 3: Float2Byte(&data,datascope_output_buffer,9); break;
case 4: Float2Byte(&data,datascope_output_buffer,13); break;
case 5: Float2Byte(&data,datascope_output_buffer,17); break;
case 6: Float2Byte(&data,datascope_output_buffer,21); break;
case 7: Float2Byte(&data,datascope_output_buffer,25); break;
case 8: Float2Byte(&data,datascope_output_buffer,29); break;
case 9: Float2Byte(&data,datascope_output_buffer,33); break;
case 10: Float2Byte(&data,datascope_output_buffer,37); break;
}
}
}
/**
* @brief Transform float data to DataScopeV1.0 data format.
* @param channel_num the number of channel that wait to be translated.
* @return
* - The number of the UART TX data.
*/
static unsigned char datascope_data_generate(unsigned char channel_num)
{
if ( (channel_num > 10) || (channel_num == 0) ) {
return 0;
} else {
datascope_output_buffer[0] = '$'; //frame header
switch(channel_num) {
case 1: datascope_output_buffer[5] = 5; return 6; break;
case 2: datascope_output_buffer[9] = 9; return 10; break;
case 3: datascope_output_buffer[13] = 13; return 14; break;
case 4: datascope_output_buffer[17] = 17; return 18; break;
case 5: datascope_output_buffer[21] = 21; return 22; break;
case 6: datascope_output_buffer[25] = 25; return 26; break;
case 7: datascope_output_buffer[29] = 29; return 30; break;
case 8: datascope_output_buffer[33] = 33; return 34; break;
case 9: datascope_output_buffer[37] = 37; return 38; break;
case 10: datascope_output_buffer[41] = 41; return 42; break;
}
}
return 0;
}
/**
* @brief Send touch sensor data to HMI in PC via UART.
* @param uart_num Choose uart port (0, 1, 2).
* @param data The addr of the touch sensor data.
* @param channel_num The number of channel that wait to be translated.
* @return
* - ESP_FAIL Error
* - The number of the UART TX data.
*/
int test_tp_print_to_scope(float *data, unsigned char channel_num)
{
uint8_t uart_num = scope_uart_num;
if (uart_num >= UART_NUM_MAX) {
return ESP_FAIL;
}
if ( (channel_num > 10) || (channel_num == 0) || (NULL == data) ) {
return ESP_FAIL;
}
for(uint8_t i = 0 ; i < channel_num; i++) {
datascope_get_channel_data(data[i] , i+1); // write data x into channel 1~10.
}
unsigned char out_len = datascope_data_generate(channel_num); // Generate n number data.
unsigned char *out_data = datascope_output_buffer;
// Init uart.
if(uart_num != uart_used) {
return 0;
} else {
#if ROM_UART_DRIVER_ENABLE
uart_tx_wait_idle(uart_num); // Default print uart mumber is 0.
for(int i=0; i<out_len; i++) {
uart_tx_one_char(out_data[i]);
}
return out_len;
#else
uart_wait_tx_done(uart_num, portMAX_DELAY);
return uart_write_bytes(uart_num, (const char *)out_data, out_len);
#endif
}
}
/**
* @brief Enable scope debug function. Print the touch sensor raw data to "DataScope" tool via UART.
* "DataScope" tool is touch sensor tune tool. User can monitor the data of each touch channel,
* evaluate the touch system's touch performance (sensitivity, SNR, stability, channel coupling)
* and determine the threshold for each channel.
*
* @attention 1. Choose a UART port that will only be used for scope debug.
* @attention 2. Use this feature only during the testing phase.
* @attention 3. "DataScope" tool can be downloaded from Espressif's official website.
*
* @param uart_num The uart port to send touch sensor raw data.
* @param tx_io_num set UART TXD IO.
* @param rx_io_num set UART RXD IO.
* @param baud_rate set debug port baud rate.
*
* @return
* - ESP_OK: succeed
* - ESP_FAIL: the param uart_num is error
*/
esp_err_t test_tp_scope_debug_init(uint8_t uart_num, int tx_io_num, int rx_io_num, int baud_rate)
{
#if ROM_UART_DRIVER_ENABLE
uart_tx_wait_idle(0); // Default print uart mumber is 0.
if(uart_num != 0) {
uart_tx_switch(uart_num);
// uart_div_modify(uart_num, baud_rate); //DivLatchValue : (clock << 4)/baudrate.
}
#else
if(uart_used == uart_num) {
return ESP_FAIL;
}
if (uart_num >= UART_NUM_MAX) {
return ESP_FAIL;
}
scope_uart_num = uart_num;
scope_tx_io_num = tx_io_num;
scope_rx_io_num = rx_io_num;
scope_debug_baud_rate = baud_rate;
uart_config_t uart_config = {
.baud_rate = scope_debug_baud_rate,
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_DISABLE,
.stop_bits = UART_STOP_BITS_1,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
};
uart_param_config(uart_num, &uart_config);
// Set UART pins using UART0 default pins i.e. no changes
uart_set_pin(uart_num, scope_tx_io_num, scope_rx_io_num,
UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
uart_driver_install(uart_num, 1024, 2048, 0, NULL, 0);
uart_used = uart_num;
#endif
return ESP_OK;
}

View file

@ -0,0 +1,4 @@
#pragma once
int test_tp_print_to_scope(float *data, unsigned char channel_num);
esp_err_t test_tp_scope_debug_init(uint8_t uart_num, int tx_io_num, int rx_io_num, int baud_rate);

View file

@ -623,6 +623,12 @@ void touch_hal_sleep_channel_enable(touch_pad_t pad_num, bool enable);
*/
#define touch_hal_sleep_read_baseline(baseline) touch_ll_sleep_read_baseline(baseline)
#define touch_hal_sleep_read_smooth(smooth_data) touch_ll_sleep_read_smooth(smooth_data)
#define touch_hal_sleep_read_data(raw_data) touch_ll_sleep_read_data(raw_data)
#define touch_hal_sleep_reset_baseline() touch_ll_sleep_reset_baseline()
/**
* Read smooth data of touch sensor for sleep pad.
*/

View file

@ -231,6 +231,26 @@ static inline void touch_ll_get_fsm_mode(touch_fsm_mode_t *mode)
*mode = (touch_fsm_mode_t)RTCCNTL.touch_ctrl2.touch_start_force;
}
static inline void touch_ll_clk_enable(void)
{
RTCCNTL.touch_ctrl2.touch_clkgate_en = 1; //enable touch clock for FSM. or force enable.
}
static inline void touch_ll_clk_disable(void)
{
RTCCNTL.touch_ctrl2.touch_clkgate_en = 0; //enable touch clock for FSM. or force enable.
}
/**
* Touch timer trigger measurement and always wait measurement done.
* Force done for touch timer ensures that the timer always can get the measurement done signal.
*/
static inline void touch_ll_timer_force_done(void)
{
RTCCNTL.touch_ctrl2.touch_timer_force_done = TOUCH_LL_TIMER_FORCE_DONE;
RTCCNTL.touch_ctrl2.touch_timer_force_done = TOUCH_LL_TIMER_DONE;
}
/**
* Enable/disable clock gate of touch sensor.
*