mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
fix(hal): replace assert with hal_assert
hal is a G0 component but assert may link in the symbols in the newlib component. we'd better not use assert in the hal but use the alternative HAL_ASSERT
This commit is contained in:
parent
ca1cd88e25
commit
0717729911
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -9,12 +9,11 @@
|
||||
#include "hal/emac_hal.h"
|
||||
#include "hal/emac_ll.h"
|
||||
#include "hal/gpio_ll.h"
|
||||
#include "hal/assert.h"
|
||||
|
||||
#define ETH_CRC_LENGTH (4)
|
||||
|
||||
#ifndef NDEBUG
|
||||
#define EMAC_HAL_BUF_MAGIC_ID 0x1E1C8416
|
||||
#endif // NDEBUG
|
||||
|
||||
typedef struct {
|
||||
#ifndef NDEBUG
|
||||
@ -629,7 +628,7 @@ uint32_t emac_hal_receive_frame(emac_hal_context_t *hal, uint8_t *buf, uint32_t
|
||||
emac_hal_auto_buf_info_t *buff_info = (emac_hal_auto_buf_info_t *)buf;
|
||||
#ifndef NDEBUG
|
||||
/* check that buffer was allocated by emac_hal_alloc_recv_buf */
|
||||
assert(buff_info->magic_id == EMAC_HAL_BUF_MAGIC_ID);
|
||||
HAL_ASSERT(buff_info->magic_id == EMAC_HAL_BUF_MAGIC_ID);
|
||||
#endif // NDEBUG
|
||||
copy_len = buff_info->copy_len;
|
||||
ret_len = copy_len;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -15,7 +15,7 @@
|
||||
#include "soc/clk_tree_defs.h"
|
||||
#include "hal/i2c_types.h"
|
||||
#include "esp_attr.h"
|
||||
#include "hal/misc.h"
|
||||
#include "hal/assert.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -97,7 +97,7 @@ static inline void i2c_ll_master_cal_bus_clk(uint32_t source_clk, uint32_t bus_f
|
||||
static inline void i2c_ll_master_set_bus_timing(i2c_dev_t *hw, i2c_hal_clk_config_t *bus_cfg)
|
||||
{
|
||||
/* SCL period. According to the TRM, we should always subtract 1 to SCL low period */
|
||||
assert(bus_cfg->scl_low > 0);
|
||||
HAL_ASSERT(bus_cfg->scl_low > 0);
|
||||
hw->scl_low_period.period = bus_cfg->scl_low - 1;
|
||||
/* Still according to the TRM, if filter is not enbled, we have to subtract 7,
|
||||
* if SCL filter is enabled, we have to subtract:
|
||||
@ -106,12 +106,12 @@ static inline void i2c_ll_master_set_bus_timing(i2c_dev_t *hw, i2c_hal_clk_confi
|
||||
* to SCL high period */
|
||||
uint16_t scl_high = bus_cfg->scl_high;
|
||||
/* In the "worst" case, we will subtract 13, make sure the result will still be correct */
|
||||
assert(scl_high > 13);
|
||||
HAL_ASSERT(scl_high > 13);
|
||||
if (hw->scl_filter_cfg.en) {
|
||||
if (hw->scl_filter_cfg.thres <= 2) {
|
||||
scl_high -= 8;
|
||||
} else {
|
||||
assert(hw->scl_filter_cfg.thres <= 7);
|
||||
HAL_ASSERT(hw->scl_filter_cfg.thres <= 7);
|
||||
scl_high -= hw->scl_filter_cfg.thres + 6;
|
||||
}
|
||||
} else {
|
||||
|
@ -105,7 +105,7 @@ static inline void mpi_ll_write_to_mem_block(mpi_param_t param, size_t offset, c
|
||||
*
|
||||
*/
|
||||
|
||||
//for (uint32_t i = copy_words; i < hw_words; i++) { assert(pbase[i] == 0); }
|
||||
//for (uint32_t i = copy_words; i < hw_words; i++) { HAL_ASSERT(pbase[i] == 0); }
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -131,7 +131,7 @@ static inline void mpi_ll_write_at_offset(mpi_param_t param, int offset, uint32_
|
||||
*/
|
||||
static inline void mpi_ll_read_from_mem_block(uint32_t* p, size_t n, size_t num_words)
|
||||
{
|
||||
assert(n >= num_words);
|
||||
HAL_ASSERT(n >= num_words);
|
||||
uint32_t mem_base = MPI_LL_BLOCK_BASES[MPI_PARAM_Z];
|
||||
/* Copy data from memory block registers */
|
||||
esp_dport_access_read_buffer(p, mem_base, num_words);
|
||||
|
@ -22,10 +22,11 @@ if [ $count -gt 0 ]; then
|
||||
fi
|
||||
|
||||
# ESP-IDF `hal` component shouldn't call "assert()" directlly
|
||||
files_to_search=$(git ls-files --full-name 'components/hal/*')
|
||||
files_to_search=$(git ls-files --full-name 'components/hal/*' | grep -v components/hal/test_apps/)
|
||||
found_libc_assert=$(grep -E '\W+assert\(' $files_to_search)
|
||||
if [ -n "$found_libc_assert" ]; then
|
||||
echo "hal assert violation"
|
||||
echo $found_libc_assert
|
||||
echo "Please use HAL_ASSERT() instead of assert() in hal component"
|
||||
exit 1
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user