Skip to content

Commit

Permalink
Merge branch 'bugfix/u32_reg_tsens_v5.0' into 'release/v5.0'
Browse files Browse the repository at this point in the history
fix(tempertuer_sensor): Fix regs on temperature sensor is not volatile due to GCC bug(backport v5.0)

See merge request espressif/esp-idf!27949
  • Loading branch information
suda-morris committed Dec 20, 2023
2 parents 97acb47 + c7b7f15 commit a20d0b2
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 20 deletions.
9 changes: 5 additions & 4 deletions components/hal/esp32c2/include/hal/temperature_sensor_ll.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand All @@ -23,6 +23,7 @@
#include "soc/soc_caps.h"
#include "hal/temperature_sensor_types.h"
#include "hal/assert.h"
#include "hal/misc.h"

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -92,7 +93,7 @@ static inline void temperature_sensor_ll_set_range(uint32_t range)
*/
static inline uint32_t temperature_sensor_ll_get_raw_value(void)
{
return APB_SARADC.saradc_apb_tsens_ctrl.saradc_reg_tsens_out;
return HAL_FORCE_READ_U32_REG_FIELD(APB_SARADC.saradc_apb_tsens_ctrl, saradc_reg_tsens_out);
}

/**
Expand All @@ -116,7 +117,7 @@ static inline uint32_t temperature_sensor_ll_get_offset(void)
*/
static inline uint32_t temperature_sensor_ll_get_clk_div(void)
{
return APB_SARADC.saradc_apb_tsens_ctrl.saradc_reg_tsens_clk_div;
return HAL_FORCE_READ_U32_REG_FIELD(APB_SARADC.saradc_apb_tsens_ctrl, saradc_reg_tsens_clk_div);
}

/**
Expand All @@ -129,7 +130,7 @@ static inline uint32_t temperature_sensor_ll_get_clk_div(void)
*/
static inline void temperature_sensor_ll_set_clk_div(uint8_t clk_div)
{
APB_SARADC.saradc_apb_tsens_ctrl.saradc_reg_tsens_clk_div = clk_div;
HAL_FORCE_MODIFY_U32_REG_FIELD(APB_SARADC.saradc_apb_tsens_ctrl, saradc_reg_tsens_clk_div, clk_div);
}

#ifdef __cplusplus
Expand Down
9 changes: 5 additions & 4 deletions components/hal/esp32c3/include/hal/temperature_sensor_ll.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand All @@ -23,6 +23,7 @@
#include "soc/soc_caps.h"
#include "hal/temperature_sensor_types.h"
#include "hal/assert.h"
#include "hal/misc.h"

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -92,7 +93,7 @@ static inline void temperature_sensor_ll_set_range(uint32_t range)
*/
static inline uint32_t temperature_sensor_ll_get_raw_value(void)
{
return APB_SARADC.apb_tsens_ctrl.tsens_out;
return HAL_FORCE_READ_U32_REG_FIELD(APB_SARADC.apb_tsens_ctrl, tsens_out);
}

/**
Expand All @@ -116,7 +117,7 @@ static inline uint32_t temperature_sensor_ll_get_offset(void)
*/
static inline uint32_t temperature_sensor_ll_get_clk_div(void)
{
return APB_SARADC.apb_tsens_ctrl.tsens_clk_div;
return HAL_FORCE_READ_U32_REG_FIELD(APB_SARADC.apb_tsens_ctrl, tsens_clk_div);
}

/**
Expand All @@ -129,7 +130,7 @@ static inline uint32_t temperature_sensor_ll_get_clk_div(void)
*/
static inline void temperature_sensor_ll_set_clk_div(uint8_t clk_div)
{
APB_SARADC.apb_tsens_ctrl.tsens_clk_div = clk_div;
HAL_FORCE_MODIFY_U32_REG_FIELD(APB_SARADC.apb_tsens_ctrl, tsens_clk_div, clk_div);
}

#ifdef __cplusplus
Expand Down
9 changes: 5 additions & 4 deletions components/hal/esp32h2/include/hal/temperature_sensor_ll.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand All @@ -23,6 +23,7 @@
#include "soc/soc_caps.h"
#include "hal/temperature_sensor_types.h"
#include "hal/assert.h"
#include "hal/misc.h"

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -92,7 +93,7 @@ static inline void temperature_sensor_ll_set_range(uint32_t range)
*/
static inline uint32_t temperature_sensor_ll_get_raw_value(void)
{
return APB_SARADC.apb_tsens_ctrl.tsens_out;
return HAL_FORCE_READ_U32_REG_FIELD(APB_SARADC.apb_tsens_ctrl, tsens_out);
}

/**
Expand All @@ -116,7 +117,7 @@ static inline uint32_t temperature_sensor_ll_get_offset(void)
*/
static inline uint32_t temperature_sensor_ll_get_clk_div(void)
{
return APB_SARADC.apb_tsens_ctrl.tsens_clk_div;
return HAL_FORCE_READ_U32_REG_FIELD(APB_SARADC.apb_tsens_ctrl, tsens_clk_div);
}

/**
Expand All @@ -129,7 +130,7 @@ static inline uint32_t temperature_sensor_ll_get_clk_div(void)
*/
static inline void temperature_sensor_ll_set_clk_div(uint8_t clk_div)
{
APB_SARADC.apb_tsens_ctrl.tsens_clk_div = clk_div;
HAL_FORCE_MODIFY_U32_REG_FIELD(APB_SARADC.apb_tsens_ctrl, tsens_clk_div, clk_div);
}

#ifdef __cplusplus
Expand Down
9 changes: 5 additions & 4 deletions components/hal/esp32s2/include/hal/temperature_sensor_ll.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand All @@ -21,6 +21,7 @@
#include "soc/rtc_cntl_reg.h"
#include "soc/sens_struct.h"
#include "hal/temperature_sensor_types.h"
#include "hal/misc.h"

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -82,7 +83,7 @@ static inline uint32_t temperature_sensor_ll_get_raw_value(void)
while (!SENS.sar_tctrl.tsens_ready) {
}
SENS.sar_tctrl.tsens_dump_out = 0;
return SENS.sar_tctrl.tsens_out;
return HAL_FORCE_READ_U32_REG_FIELD(SENS.sar_tctrl, tsens_out);
}

/**
Expand All @@ -106,7 +107,7 @@ static inline uint32_t temperature_sensor_ll_get_offset(void)
*/
static inline uint32_t temperature_sensor_ll_get_clk_div(void)
{
return SENS.sar_tctrl.tsens_clk_div;
return HAL_FORCE_READ_U32_REG_FIELD(SENS.sar_tctrl, tsens_clk_div);
}

/**
Expand All @@ -119,7 +120,7 @@ static inline uint32_t temperature_sensor_ll_get_clk_div(void)
*/
static inline void temperature_sensor_ll_set_clk_div(uint8_t clk_div)
{
SENS.sar_tctrl.tsens_clk_div = clk_div;
HAL_FORCE_MODIFY_U32_REG_FIELD(SENS.sar_tctrl, tsens_clk_div, clk_div);
}

#ifdef __cplusplus
Expand Down
9 changes: 5 additions & 4 deletions components/hal/esp32s3/include/hal/temperature_sensor_ll.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand All @@ -21,6 +21,7 @@
#include "soc/rtc_cntl_reg.h"
#include "soc/sens_struct.h"
#include "hal/temperature_sensor_types.h"
#include "hal/misc.h"

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -82,7 +83,7 @@ static inline uint32_t temperature_sensor_ll_get_raw_value(void)
while (!SENS.sar_tctrl.tsens_ready) {
}
SENS.sar_tctrl.tsens_dump_out = 0;
return SENS.sar_tctrl.tsens_out;
return HAL_FORCE_READ_U32_REG_FIELD(SENS.sar_tctrl, tsens_out);
}

/**
Expand All @@ -106,7 +107,7 @@ static inline uint32_t temperature_sensor_ll_get_offset(void)
*/
static inline uint32_t temperature_sensor_ll_get_clk_div(void)
{
return SENS.sar_tctrl.tsens_clk_div;
return HAL_FORCE_READ_U32_REG_FIELD(SENS.sar_tctrl, tsens_clk_div);
}

/**
Expand All @@ -119,7 +120,7 @@ static inline uint32_t temperature_sensor_ll_get_clk_div(void)
*/
static inline void temperature_sensor_ll_set_clk_div(uint8_t clk_div)
{
SENS.sar_tctrl.tsens_clk_div = clk_div;
HAL_FORCE_MODIFY_U32_REG_FIELD(SENS.sar_tctrl, tsens_clk_div, clk_div);
}

#ifdef __cplusplus
Expand Down

0 comments on commit a20d0b2

Please sign in to comment.