mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-09 20:41:14 +00:00
hal: added HAL_ASSERT
This commit is contained in:
@@ -15,9 +15,9 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <assert.h>
|
||||
#include "soc/lcd_cam_reg.h"
|
||||
#include "soc/lcd_cam_struct.h"
|
||||
#include "hal/assert.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -45,7 +45,7 @@ static inline void lcd_ll_enable_clock(lcd_cam_dev_t *dev, bool en)
|
||||
static inline void lcd_ll_set_group_clock_src(lcd_cam_dev_t *dev, int src, int div_num, int div_a, int div_b)
|
||||
{
|
||||
// lcd_clk = module_clock_src / (div_num + div_b / div_a)
|
||||
assert(div_num >= 2);
|
||||
HAL_ASSERT(div_num >= 2);
|
||||
dev->lcd_clock.lcd_clk_sel = src;
|
||||
dev->lcd_clock.lcd_clkm_div_num = div_num;
|
||||
dev->lcd_clock.lcd_clkm_div_a = div_a;
|
||||
@@ -76,7 +76,7 @@ static inline void lcd_ll_enable_rgb_yuv_convert(lcd_cam_dev_t *dev, bool en)
|
||||
|
||||
static inline void lcd_ll_set_phase_cycles(lcd_cam_dev_t *dev, uint32_t cmd_cycles, uint32_t dummy_cycles, uint32_t data_cycles)
|
||||
{
|
||||
assert(cmd_cycles <= 2);
|
||||
HAL_ASSERT(cmd_cycles <= 2);
|
||||
dev->lcd_user.lcd_cmd = (cmd_cycles > 0);
|
||||
dev->lcd_user.lcd_dummy = (dummy_cycles > 0);
|
||||
dev->lcd_user.lcd_dout = (data_cycles > 0);
|
||||
|
@@ -14,6 +14,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "hal/assert.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -133,7 +135,7 @@ static inline uint32_t esp_memprot_iram0_get_lock_bit(void)
|
||||
//block 0-3
|
||||
static inline void esp_memprot_iram0_set_uni_block_perm(uint32_t block, bool write_perm, bool read_perm, bool exec_perm)
|
||||
{
|
||||
assert(block < IRAM0_TOTAL_UNI_BLOCKS);
|
||||
HAL_ASSERT(block < IRAM0_TOTAL_UNI_BLOCKS);
|
||||
|
||||
uint32_t write_bit, read_bit, exec_bit;
|
||||
switch ( block ) {
|
||||
@@ -182,7 +184,7 @@ static inline void esp_memprot_iram0_set_uni_block_perm(uint32_t block, bool wri
|
||||
|
||||
static inline uint32_t esp_memprot_iram0_get_uni_block_read_bit(uint32_t block)
|
||||
{
|
||||
assert(block < IRAM0_TOTAL_UNI_BLOCKS);
|
||||
HAL_ASSERT(block < IRAM0_TOTAL_UNI_BLOCKS);
|
||||
|
||||
switch ( block ) {
|
||||
case IRAM0_UNI_BLOCK_0:
|
||||
@@ -200,7 +202,7 @@ static inline uint32_t esp_memprot_iram0_get_uni_block_read_bit(uint32_t block)
|
||||
|
||||
static inline uint32_t esp_memprot_iram0_get_uni_block_write_bit(uint32_t block)
|
||||
{
|
||||
assert(block < IRAM0_TOTAL_UNI_BLOCKS);
|
||||
HAL_ASSERT(block < IRAM0_TOTAL_UNI_BLOCKS);
|
||||
|
||||
switch ( block ) {
|
||||
case IRAM0_UNI_BLOCK_0:
|
||||
@@ -218,7 +220,7 @@ static inline uint32_t esp_memprot_iram0_get_uni_block_write_bit(uint32_t block)
|
||||
|
||||
static inline uint32_t esp_memprot_iram0_get_uni_block_exec_bit(uint32_t block)
|
||||
{
|
||||
assert(block < IRAM0_TOTAL_UNI_BLOCKS);
|
||||
HAL_ASSERT(block < IRAM0_TOTAL_UNI_BLOCKS);
|
||||
|
||||
switch ( block ) {
|
||||
case IRAM0_UNI_BLOCK_0:
|
||||
@@ -236,7 +238,7 @@ static inline uint32_t esp_memprot_iram0_get_uni_block_exec_bit(uint32_t block)
|
||||
|
||||
static inline void esp_memprot_iram0_get_uni_block_sgnf_bits(uint32_t block, uint32_t *write_bit, uint32_t *read_bit, uint32_t *exec_bit)
|
||||
{
|
||||
assert(block < IRAM0_TOTAL_UNI_BLOCKS);
|
||||
HAL_ASSERT(block < IRAM0_TOTAL_UNI_BLOCKS);
|
||||
|
||||
switch ( block ) {
|
||||
case IRAM0_UNI_BLOCK_0:
|
||||
@@ -277,7 +279,7 @@ static inline uint32_t esp_memprot_iram0_get_perm_split_reg(void)
|
||||
static inline void esp_memprot_iram0_set_prot(uint32_t *split_addr, bool lw, bool lr, bool lx, bool hw, bool hr, bool hx)
|
||||
{
|
||||
uint32_t addr = (uint32_t)split_addr;
|
||||
assert( addr <= IRAM0_SPL_BLOCK_HIGH );
|
||||
HAL_ASSERT(addr <= IRAM0_SPL_BLOCK_HIGH);
|
||||
|
||||
//find possible split.address in low region blocks
|
||||
int uni_blocks_low = -1;
|
||||
@@ -330,7 +332,7 @@ static inline void esp_memprot_iram0_set_prot(uint32_t *split_addr, bool lw, boo
|
||||
|
||||
//split Address must be WORD aligned
|
||||
reg_split_addr = addr >> 2;
|
||||
assert(addr == (reg_split_addr << 2));
|
||||
HAL_ASSERT(addr == (reg_split_addr << 2));
|
||||
|
||||
//use only 17 signf.bits as the cropped parts are constant for whole section (bits [16:0])
|
||||
reg_split_addr = (reg_split_addr << DPORT_PMS_PRO_IRAM0_SRAM_4_SPLTADDR_S) & DPORT_PMS_PRO_IRAM0_SRAM_4_SPLTADDR_M;
|
||||
@@ -453,7 +455,7 @@ static inline uint32_t esp_memprot_dram0_get_lock_bit(void)
|
||||
|
||||
static inline void esp_memprot_dram0_get_uni_block_sgnf_bits(uint32_t block, uint32_t *write_bit, uint32_t *read_bit)
|
||||
{
|
||||
assert(block < DRAM0_TOTAL_UNI_BLOCKS);
|
||||
HAL_ASSERT(block < DRAM0_TOTAL_UNI_BLOCKS);
|
||||
|
||||
switch ( block ) {
|
||||
case DRAM0_UNI_BLOCK_0:
|
||||
@@ -479,7 +481,7 @@ static inline void esp_memprot_dram0_get_uni_block_sgnf_bits(uint32_t block, uin
|
||||
|
||||
static inline void esp_memprot_dram0_set_uni_block_perm(uint32_t block, bool write_perm, bool read_perm)
|
||||
{
|
||||
assert(block < DRAM0_TOTAL_UNI_BLOCKS);
|
||||
HAL_ASSERT(block < DRAM0_TOTAL_UNI_BLOCKS);
|
||||
|
||||
uint32_t write_bit, read_bit;
|
||||
esp_memprot_dram0_get_uni_block_sgnf_bits(block, &write_bit, &read_bit);
|
||||
@@ -499,7 +501,7 @@ static inline void esp_memprot_dram0_set_uni_block_perm(uint32_t block, bool wri
|
||||
|
||||
static inline uint32_t esp_memprot_dram0_get_uni_block_read_bit(uint32_t block)
|
||||
{
|
||||
assert(block < DRAM0_TOTAL_UNI_BLOCKS);
|
||||
HAL_ASSERT(block < DRAM0_TOTAL_UNI_BLOCKS);
|
||||
|
||||
switch ( block ) {
|
||||
case DRAM0_UNI_BLOCK_0:
|
||||
@@ -517,7 +519,7 @@ static inline uint32_t esp_memprot_dram0_get_uni_block_read_bit(uint32_t block)
|
||||
|
||||
static inline uint32_t esp_memprot_dram0_get_uni_block_write_bit(uint32_t block)
|
||||
{
|
||||
assert(block < DRAM0_TOTAL_UNI_BLOCKS);
|
||||
HAL_ASSERT(block < DRAM0_TOTAL_UNI_BLOCKS);
|
||||
|
||||
switch ( block ) {
|
||||
case DRAM0_UNI_BLOCK_0:
|
||||
@@ -575,7 +577,7 @@ static inline void esp_memprot_dram0_set_prot(uint32_t *split_addr, bool lw, boo
|
||||
uint32_t addr = (uint32_t)split_addr;
|
||||
|
||||
//low boundary check provided by LD script. see comment in esp_memprot_iram0_set_prot()
|
||||
assert( addr <= DRAM0_SPL_BLOCK_HIGH );
|
||||
HAL_ASSERT(addr <= DRAM0_SPL_BLOCK_HIGH);
|
||||
|
||||
//set low region
|
||||
int uni_blocks_low = -1;
|
||||
@@ -615,7 +617,7 @@ static inline void esp_memprot_dram0_set_prot(uint32_t *split_addr, bool lw, boo
|
||||
|
||||
//check split address is WORD aligned
|
||||
uint32_t reg_split_addr = addr >> 2;
|
||||
assert(addr == (reg_split_addr << 2));
|
||||
HAL_ASSERT(addr == (reg_split_addr << 2));
|
||||
|
||||
//shift aligned split address to proper bit offset
|
||||
reg_split_addr = (reg_split_addr << DPORT_PMS_PRO_DRAM0_SRAM_4_SPLTADDR_S) & DPORT_PMS_PRO_DRAM0_SRAM_4_SPLTADDR_M;
|
||||
|
@@ -20,12 +20,12 @@
|
||||
|
||||
// The Lowlevel layer for SPI Flash Encryption.
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include "soc/system_reg.h"
|
||||
#include "soc/hwcrypto_reg.h"
|
||||
#include "soc/soc.h"
|
||||
#include "string.h"
|
||||
#include "assert.h"
|
||||
#include <stdbool.h>
|
||||
#include "hal/assert.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -67,7 +67,7 @@ static inline void spi_flash_encrypt_ll_disable(void)
|
||||
static inline void spi_flash_encrypt_ll_type(flash_encrypt_ll_type_t type)
|
||||
{
|
||||
// Our hardware only support flash encryption
|
||||
assert(type == FLASH_ENCRYPTION_MANU);
|
||||
HAL_ASSERT(type == FLASH_ENCRYPTION_MANU);
|
||||
REG_WRITE(AES_XTS_DESTINATION_REG, type);
|
||||
}
|
||||
|
||||
|
@@ -24,11 +24,12 @@
|
||||
|
||||
#include <stdlib.h> //for abs()
|
||||
#include <string.h>
|
||||
#include "hal/hal_defs.h"
|
||||
#include "esp_attr.h"
|
||||
#include "esp_types.h"
|
||||
#include "soc/spi_periph.h"
|
||||
#include "esp32s3/rom/lldesc.h"
|
||||
#include "esp_attr.h"
|
||||
#include "soc/lldesc.h"
|
||||
#include "hal/assert.h"
|
||||
#include "hal/misc.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -37,7 +38,7 @@ extern "C" {
|
||||
/// Interrupt not used. Don't use in app.
|
||||
#define SPI_LL_UNUSED_INT_MASK (SPI_TRANS_DONE_INT_ENA | SPI_SLV_WR_DMA_DONE_INT_ENA | SPI_SLV_RD_DMA_DONE_INT_ENA | SPI_SLV_WR_BUF_DONE_INT_ENA | SPI_SLV_RD_BUF_DONE_INT_ENA)
|
||||
/// Swap the bit order to its correct place to send
|
||||
#define HAL_SPI_SWAP_DATA_TX(data, len) HAL_SWAP32((uint32_t)data<<(32-len))
|
||||
#define HAL_SPI_SWAP_DATA_TX(data, len) HAL_SWAP32((uint32_t)(data) << (32 - len))
|
||||
/// This is the expected clock frequency
|
||||
#define SPI_LL_PERIPH_CLK_FREQ (80 * 1000000)
|
||||
#define SPI_LL_GET_HW(ID) ((ID)==0? ({abort();NULL;}):((ID)==1? &GPSPI2 : &GPSPI3))
|
||||
@@ -351,9 +352,9 @@ static inline void spi_ll_write_buffer(spi_dev_t *hw, const uint8_t *buffer_to_s
|
||||
*/
|
||||
static inline void spi_ll_write_buffer_byte(spi_dev_t *hw, int byte_id, uint8_t *data, int len)
|
||||
{
|
||||
assert(byte_id+len <= 64);
|
||||
assert(len > 0);
|
||||
assert(byte_id >= 0);
|
||||
HAL_ASSERT(byte_id+len <= 64);
|
||||
HAL_ASSERT(len > 0);
|
||||
HAL_ASSERT(byte_id >= 0);
|
||||
|
||||
while (len > 0) {
|
||||
uint32_t word;
|
||||
|
@@ -15,8 +15,8 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <assert.h>
|
||||
#include "soc/systimer_struct.h"
|
||||
#include "hal/assert.h"
|
||||
|
||||
#define SYSTIMER_LL_COUNTER_CLOCK (0) // Counter used for "wallclock" time
|
||||
#define SYSTIMER_LL_COUNTER_OS_TICK (1) // Counter used for OS tick
|
||||
@@ -121,7 +121,7 @@ __attribute__((always_inline)) static inline void systimer_ll_enable_alarm_perio
|
||||
|
||||
__attribute__((always_inline)) static inline void systimer_ll_set_alarm_period(systimer_dev_t *dev, uint32_t alarm_id, uint32_t period)
|
||||
{
|
||||
assert(period < (1 << 26));
|
||||
HAL_ASSERT(period < (1 << 26));
|
||||
dev->target_conf[alarm_id].target_period = period;
|
||||
}
|
||||
|
||||
|
@@ -22,8 +22,9 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "hal/timer_types.h"
|
||||
#include "soc/timer_periph.h"
|
||||
#include "hal/timer_types.h"
|
||||
#include "hal/assert.h"
|
||||
|
||||
_Static_assert(TIMER_INTR_T0 == TIMG_T0_INT_CLR, "Add mapping to LL interrupt handling, since it's no longer naturally compatible with the timer_intr_t");
|
||||
_Static_assert(TIMER_INTR_T1 == TIMG_T1_INT_CLR, "Add mapping to LL interrupt handling, since it's no longer naturally compatible with the timer_intr_t");
|
||||
@@ -48,7 +49,7 @@ typedef struct {
|
||||
*/
|
||||
static inline void timer_ll_set_divider(timg_dev_t *hw, timer_idx_t timer_num, uint32_t divider)
|
||||
{
|
||||
assert(divider >= 2 && divider <= 65536);
|
||||
HAL_ASSERT(divider >= 2 && divider <= 65536);
|
||||
if (divider >= 65536) {
|
||||
divider = 0;
|
||||
}
|
||||
|
@@ -28,6 +28,7 @@ extern "C" {
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "hal/misc.h"
|
||||
#include "hal/twai_types.h"
|
||||
#include "soc/twai_periph.h"
|
||||
|
||||
@@ -482,8 +483,8 @@ static inline void twai_ll_set_tec(twai_dev_t *hw, uint32_t tec)
|
||||
*/
|
||||
static inline void twai_ll_set_acc_filter(twai_dev_t* hw, uint32_t code, uint32_t mask, bool single_filter)
|
||||
{
|
||||
uint32_t code_swapped = __builtin_bswap32(code);
|
||||
uint32_t mask_swapped = __builtin_bswap32(mask);
|
||||
uint32_t code_swapped = HAL_SWAP32(code);
|
||||
uint32_t mask_swapped = HAL_SWAP32(mask);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
hw->acceptance_filter.acr[i].byte = ((code_swapped >> (i * 8)) & 0xFF);
|
||||
hw->acceptance_filter.amr[i].byte = ((mask_swapped >> (i * 8)) & 0xFF);
|
||||
@@ -555,12 +556,12 @@ static inline void twai_ll_format_frame_buffer(uint32_t id, uint8_t dlc, const u
|
||||
|
||||
//Set ID. The ID registers are big endian and left aligned, therefore a bswap will be required
|
||||
if (is_extd) {
|
||||
uint32_t id_temp = __builtin_bswap32((id & TWAI_EXTD_ID_MASK) << 3); //((id << 3) >> 8*(3-i))
|
||||
uint32_t id_temp = HAL_SWAP32((id & TWAI_EXTD_ID_MASK) << 3); //((id << 3) >> 8*(3-i))
|
||||
for (int i = 0; i < 4; i++) {
|
||||
tx_frame->extended.id[i] = (id_temp >> (8 * i)) & 0xFF;
|
||||
}
|
||||
} else {
|
||||
uint32_t id_temp = __builtin_bswap16((id & TWAI_STD_ID_MASK) << 5); //((id << 5) >> 8*(1-i))
|
||||
uint32_t id_temp = HAL_SWAP16((id & TWAI_STD_ID_MASK) << 5); //((id << 5) >> 8*(1-i))
|
||||
for (int i = 0; i < 2; i++) {
|
||||
tx_frame->standard.id[i] = (id_temp >> (8 * i)) & 0xFF;
|
||||
}
|
||||
@@ -600,14 +601,14 @@ static inline void twai_ll_prase_frame_buffer(twai_ll_frame_buffer_t *rx_frame,
|
||||
for (int i = 0; i < 4; i++) {
|
||||
id_temp |= rx_frame->extended.id[i] << (8 * i);
|
||||
}
|
||||
id_temp = __builtin_bswap32(id_temp) >> 3; //((byte[i] << 8*(3-i)) >> 3)
|
||||
id_temp = HAL_SWAP32(id_temp) >> 3; //((byte[i] << 8*(3-i)) >> 3)
|
||||
*id = id_temp & TWAI_EXTD_ID_MASK;
|
||||
} else {
|
||||
uint32_t id_temp = 0;
|
||||
for (int i = 0; i < 2; i++) {
|
||||
id_temp |= rx_frame->standard.id[i] << (8 * i);
|
||||
}
|
||||
id_temp = __builtin_bswap16(id_temp) >> 5; //((byte[i] << 8*(1-i)) >> 5)
|
||||
id_temp = HAL_SWAP16(id_temp) >> 5; //((byte[i] << 8*(1-i)) >> 5)
|
||||
*id = id_temp & TWAI_STD_ID_MASK;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user