mirror of
https://github.com/espressif/esp-idf.git
synced 2025-11-26 04:39:22 +00:00
soc/ll: workaround compiler bug that generate 8/16 bits inst instead of 32 bits one
update all struct headers to be more "standardized":
- bit fields are properly wrapped with struct
- bitwidth sum should be 32 within same struct, so that it's correctly padded with reserved bits
- bit field should be uint32_t
- typedef volatile struct xxx{} yyy;: xxx must exists. refer: https://github.com/espressif/esp-idf/pull/3199
added helper macros to force peripheral registers being accessed in 32 bitwidth
added a check script into ci
This commit is contained in:
@@ -24,8 +24,12 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include "hal/misc.h"
|
||||
#include "soc/touch_sensor_periph.h"
|
||||
#include "soc/soc_caps.h"
|
||||
#include "soc/sens_struct.h"
|
||||
#include "soc/rtc_cntl_struct.h"
|
||||
#include "soc/rtc_io_struct.h"
|
||||
#include "hal/touch_sensor_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -47,9 +51,9 @@ extern "C" {
|
||||
static inline void touch_ll_set_meas_times(uint16_t meas_time)
|
||||
{
|
||||
//The times of charge and discharge in each measure process of touch channels.
|
||||
RTCCNTL.touch_ctrl1.touch_meas_num = meas_time;
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(RTCCNTL.touch_ctrl1, touch_meas_num, meas_time);
|
||||
//the waiting cycles (in 8MHz) between TOUCH_START and TOUCH_XPD
|
||||
RTCCNTL.touch_ctrl2.touch_xpd_wait = SOC_TOUCH_PAD_MEASURE_WAIT_MAX; //wait volt stable
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(RTCCNTL.touch_ctrl2, touch_xpd_wait, SOC_TOUCH_PAD_MEASURE_WAIT_MAX); //wait volt stable
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,7 +63,7 @@ static inline void touch_ll_set_meas_times(uint16_t meas_time)
|
||||
*/
|
||||
static inline void touch_ll_get_measure_times(uint16_t *meas_time)
|
||||
{
|
||||
*meas_time = RTCCNTL.touch_ctrl1.touch_meas_num;
|
||||
*meas_time = HAL_FORCE_READ_U32_REG_FIELD(RTCCNTL.touch_ctrl1, touch_meas_num);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,7 +77,7 @@ static inline void touch_ll_get_measure_times(uint16_t *meas_time)
|
||||
static inline void touch_ll_set_sleep_time(uint16_t sleep_time)
|
||||
{
|
||||
// touch sensor sleep cycle Time = sleep_cycle / RTC_SLOW_CLK(90k)
|
||||
RTCCNTL.touch_ctrl1.touch_sleep_cycles = sleep_time;
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(RTCCNTL.touch_ctrl1, touch_sleep_cycles, sleep_time);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,7 +87,7 @@ static inline void touch_ll_set_sleep_time(uint16_t sleep_time)
|
||||
*/
|
||||
static inline void touch_ll_get_sleep_time(uint16_t *sleep_time)
|
||||
{
|
||||
*sleep_time = RTCCNTL.touch_ctrl1.touch_sleep_cycles;
|
||||
*sleep_time = HAL_FORCE_READ_U32_REG_FIELD(RTCCNTL.touch_ctrl1, touch_sleep_cycles);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -990,7 +994,7 @@ static inline void touch_ll_proximity_get_channel_num(touch_pad_t prox_pad[])
|
||||
*/
|
||||
static inline void touch_ll_proximity_set_meas_times(uint32_t times)
|
||||
{
|
||||
RTCCNTL.touch_approach.touch_approach_meas_time = times;
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(RTCCNTL.touch_approach, touch_approach_meas_time, times);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1000,7 +1004,7 @@ static inline void touch_ll_proximity_set_meas_times(uint32_t times)
|
||||
*/
|
||||
static inline void touch_ll_proximity_get_meas_times(uint32_t *times)
|
||||
{
|
||||
*times = RTCCNTL.touch_approach.touch_approach_meas_time;
|
||||
*times = HAL_FORCE_READ_U32_REG_FIELD(RTCCNTL.touch_approach, touch_approach_meas_time);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1011,11 +1015,11 @@ static inline void touch_ll_proximity_get_meas_times(uint32_t *times)
|
||||
static inline void touch_ll_proximity_read_meas_cnt(touch_pad_t touch_num, uint32_t *cnt)
|
||||
{
|
||||
if (SENS.sar_touch_conf.touch_approach_pad0 == touch_num) {
|
||||
*cnt = SENS.sar_touch_appr_status.touch_approach_pad0_cnt;
|
||||
*cnt = HAL_FORCE_READ_U32_REG_FIELD(SENS.sar_touch_appr_status, touch_approach_pad0_cnt);
|
||||
} else if (SENS.sar_touch_conf.touch_approach_pad1 == touch_num) {
|
||||
*cnt = SENS.sar_touch_appr_status.touch_approach_pad1_cnt;
|
||||
*cnt = HAL_FORCE_READ_U32_REG_FIELD(SENS.sar_touch_appr_status, touch_approach_pad1_cnt);
|
||||
} else if (SENS.sar_touch_conf.touch_approach_pad2 == touch_num) {
|
||||
*cnt = SENS.sar_touch_appr_status.touch_approach_pad2_cnt;
|
||||
*cnt = HAL_FORCE_READ_U32_REG_FIELD(SENS.sar_touch_appr_status, touch_approach_pad2_cnt);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1163,7 +1167,7 @@ static inline void touch_ll_sleep_read_debounce(uint32_t *debounce)
|
||||
*/
|
||||
static inline void touch_ll_sleep_read_proximity_cnt(uint32_t *approach_cnt)
|
||||
{
|
||||
*approach_cnt = SENS.sar_touch_appr_status.touch_slp_approach_cnt;
|
||||
*approach_cnt = HAL_FORCE_READ_U32_REG_FIELD(SENS.sar_touch_appr_status, touch_slp_approach_cnt);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user