forked from espressif/arduino-esp32
IDF master d93887f9f (#5336)
* Update toolchain * Update package_esp32_index.template.json * add optional component dependencies after Kconfig options are known (#5404) Until this commit, Kconfig options (e.g. CONFIG_TINYUSB_ENABLED) were used in conditions preceding idf_component_register to determine which components need to be added to `arduino` component requirements. However the Kconfig options aren't known at the early expansion stage, when the component CMakeLists.txt files are expanded the first time and requirements are evaluated. So all the conditions evaluated as if the options were not set. This commit changes the logic to only add these components as dependencies when the Kconfig options are known. Dependencies become "weak", which means that if one of the components isn't included into the build for some reason, it is not added as a dependency. This may happen, for example, if the component is not present in the `components` directory or is excluded by setting `COMPONENTS` variable in the project CMakeLists.txt file. This also ensures that if the component is not present, it will not be added as a dependency, and this will allow the build to proceed. Follow-up to https://github.com/espressif/arduino-esp32/pull/5391. Closes https://github.com/espressif/arduino-esp32/issues/5319. * IDF master d93887f9f * PlatformIO updates for CI (#5387) * Update PlatformIO CI build script - Switch to the latest toolchains 8.4.0 for ESP32, ESP32S2, ESP32C3 - Use PlatformIO from master branch for better robustness * Update package.json for PlatformIO Co-authored-by: Ivan Grokhotkov <ivan@espressif.com> Co-authored-by: Valerii Koval <valeros@users.noreply.github.com>
This commit is contained in:
@ -16,6 +16,8 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "soc/soc_caps.h"
|
||||
#include "soc/dport_access.h"
|
||||
#include "soc/system_reg.h"
|
||||
#include "esp_bit_defs.h"
|
||||
#include "soc/assist_debug_reg.h"
|
||||
#include "esp_attr.h"
|
||||
@ -153,6 +155,11 @@ static inline void cpu_ll_set_vecbase(const void* vecbase)
|
||||
|
||||
static inline void cpu_ll_waiti(void)
|
||||
{
|
||||
if (cpu_ll_is_debugger_attached() && DPORT_REG_GET_BIT(SYSTEM_CPU_PER_CONF_REG, SYSTEM_CPU_WAIT_MODE_FORCE_ON) == 0) {
|
||||
/* when SYSTEM_CPU_WAIT_MODE_FORCE_ON is disabled in WFI mode SBA access to memory does not work for debugger,
|
||||
so do not enter that mode when debugger is connected */
|
||||
return;
|
||||
}
|
||||
asm volatile ("wfi\n");
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ extern "C" {
|
||||
#define I2C_LL_INTR_MASK (0x3fff) /*!< I2C all interrupt bitmap */
|
||||
|
||||
/**
|
||||
* @brief I2C hardware cmd register filed.
|
||||
* @brief I2C hardware cmd register fields.
|
||||
*/
|
||||
typedef union {
|
||||
struct {
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
#include "soc/sensitive_reg.h"
|
||||
#include "soc/cache_memory.h"
|
||||
#include "hal/assert.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -96,7 +97,7 @@ static inline uint32_t memprot_ll_iram0_get_intr_source_num(void)
|
||||
static inline void memprot_ll_set_iram0_split_line(const void *line_addr, uint32_t sensitive_reg)
|
||||
{
|
||||
uint32_t addr = (uint32_t)line_addr;
|
||||
assert( addr >= IRAM0_SRAM_LEVEL_1_LOW && addr <= IRAM0_SRAM_LEVEL_3_HIGH );
|
||||
HAL_ASSERT(addr >= IRAM0_SRAM_LEVEL_1_LOW && addr <= IRAM0_SRAM_LEVEL_3_HIGH);
|
||||
|
||||
uint32_t category[3] = {0};
|
||||
if (addr <= IRAM0_SRAM_LEVEL_1_HIGH) {
|
||||
@ -353,7 +354,7 @@ static inline uint32_t memprot_ll_dram0_get_intr_source_num(void)
|
||||
static inline void memprot_ll_set_dram0_split_line(const void *line_addr, uint32_t sensitive_reg)
|
||||
{
|
||||
uint32_t addr = (uint32_t)line_addr;
|
||||
assert( addr >= DRAM0_SRAM_LEVEL_1_LOW && addr <= DRAM0_SRAM_LEVEL_3_HIGH );
|
||||
HAL_ASSERT(addr >= DRAM0_SRAM_LEVEL_1_LOW && addr <= DRAM0_SRAM_LEVEL_3_HIGH);
|
||||
|
||||
uint32_t category[3] = {0};
|
||||
if (addr <= DRAM0_SRAM_LEVEL_1_HIGH) {
|
||||
|
@ -15,8 +15,8 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include "soc/rmt_struct.h"
|
||||
#include "soc/soc_caps.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -279,6 +279,15 @@ static inline uint32_t rmt_ll_rx_get_limit(rmt_dev_t *dev, uint32_t channel)
|
||||
return dev->rx_lim[channel].rx_lim;
|
||||
}
|
||||
|
||||
static inline void rmt_ll_enable_interrupt(rmt_dev_t *dev, uint32_t mask, bool enable)
|
||||
{
|
||||
if (enable) {
|
||||
dev->int_ena.val |= mask;
|
||||
} else {
|
||||
dev->int_ena.val &= ~mask;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void rmt_ll_enable_tx_end_interrupt(rmt_dev_t *dev, uint32_t channel, bool enable)
|
||||
{
|
||||
if (enable) {
|
||||
@ -469,12 +478,14 @@ static inline void rmt_ll_tx_set_carrier_always_on(rmt_dev_t *dev, uint32_t chan
|
||||
dev->tx_conf[channel].carrier_eff_en = !enable;
|
||||
}
|
||||
|
||||
//Writes items to the specified TX channel memory with the given offset and writen length.
|
||||
//Writes items to the specified TX channel memory with the given offset and length.
|
||||
//the caller should ensure that (length + off) <= (memory block * SOC_RMT_MEM_WORDS_PER_CHANNEL)
|
||||
static inline void rmt_ll_write_memory(rmt_mem_t *mem, uint32_t channel, const rmt_item32_t *data, uint32_t length, uint32_t off)
|
||||
static inline void rmt_ll_write_memory(rmt_mem_t *mem, uint32_t channel, const void *data, size_t length_in_words, size_t off)
|
||||
{
|
||||
for (uint32_t i = 0; i < length; i++) {
|
||||
mem->chan[channel].data32[i + off].val = data[i].val;
|
||||
volatile uint32_t *to = (volatile uint32_t *)&mem->chan[channel].data32[off];
|
||||
uint32_t *from = (uint32_t *)data;
|
||||
while (length_in_words--) {
|
||||
*to++ = *from++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -483,20 +494,6 @@ static inline void rmt_ll_rx_enable_pingpong(rmt_dev_t *dev, uint32_t channel, b
|
||||
dev->rx_conf[channel].conf1.mem_rx_wrap_en = enable;
|
||||
}
|
||||
|
||||
/************************************************************************************************
|
||||
* Following Low Level APIs only used for backward compatible, will be deprecated in the IDF v5.0
|
||||
***********************************************************************************************/
|
||||
|
||||
static inline void rmt_ll_set_intr_enable_mask(uint32_t mask)
|
||||
{
|
||||
RMT.int_ena.val |= mask;
|
||||
}
|
||||
|
||||
static inline void rmt_ll_clr_intr_enable_mask(uint32_t mask)
|
||||
{
|
||||
RMT.int_ena.val &= (~mask);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -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 "esp32c3/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;}):&GPSPI2)
|
||||
@ -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
|
||||
@ -120,7 +120,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_WDT == TIMG_WDT_INT_CLR, "Add mapping to LL interrupt handling, since it's no longer naturally compatible with the timer_intr_t");
|
||||
@ -47,7 +48,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;
|
||||
}
|
||||
|
||||
|
@ -921,7 +921,7 @@ static inline void uart_ll_force_xon(uart_port_t uart_num)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get UART final state machine status.
|
||||
* @brief Get UART finite-state machine status.
|
||||
*
|
||||
* @param uart_num UART port number, the max port number is (UART_NUM_MAX -1).
|
||||
*
|
||||
|
@ -37,7 +37,7 @@ typedef enum {
|
||||
USB_SERIAL_JTAG_INTR_TOKEN_REC_IN_EP1 = (1 << 8),
|
||||
USB_SERIAL_JTAG_INTR_BUS_RESET = (1 << 9),
|
||||
USB_SERIAL_JTAG_INTR_EP1_ZERO_PAYLOAD = (1 << 10),
|
||||
} usb_serial_jtag_intr_t;
|
||||
} usb_serial_jtag_ll_intr_t;
|
||||
|
||||
/**
|
||||
* @brief Enable the USB_SERIAL_JTAG interrupt based on the given mask.
|
||||
@ -51,6 +51,18 @@ static inline void usb_serial_jtag_ll_ena_intr_mask(uint32_t mask)
|
||||
USB_SERIAL_JTAG.int_ena.val |= mask;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear the USB_SERIAL_JTAG interrupt based on the given mask.
|
||||
*
|
||||
* @param mask The bitmap of the interrupts bits need to be cleared.
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
static inline void usb_serial_jtag_ll_clr_intr_sts_mask(uint32_t mask)
|
||||
{
|
||||
USB_SERIAL_JTAG.int_clr.val = mask;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable the USB_SERIAL_JTAG interrupt based on the given mask.
|
||||
*
|
||||
@ -156,6 +168,9 @@ static inline int usb_serial_jtag_ll_txfifo_writable(void)
|
||||
* @brief Flushes the TX buffer, that is, make it available for the
|
||||
* host to pick up.
|
||||
*
|
||||
* @note When fifo is full (with 64 byte), HW will flush the buffer automatically.
|
||||
* It won't be executed if there is nothing in the fifo.
|
||||
*
|
||||
* @return na
|
||||
*/
|
||||
static inline void usb_serial_jtag_ll_txfifo_flush(void)
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "hal/adc_ll.h"
|
||||
#include "esp_err.h"
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32C3
|
||||
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32H2
|
||||
#include "soc/gdma_struct.h"
|
||||
#include "hal/gdma_ll.h"
|
||||
#include "hal/dma_types.h"
|
||||
@ -75,7 +75,7 @@ void adc_hal_init(void);
|
||||
*/
|
||||
#define adc_hal_digi_set_clk_div(div) adc_ll_digi_set_clk_div(div)
|
||||
|
||||
#if !CONFIG_IDF_TARGET_ESP32C3
|
||||
#if !CONFIG_IDF_TARGET_ESP32C3 && !CONFIG_IDF_TARGET_ESP32H2
|
||||
/**
|
||||
* ADC SAR clock division factor setting. ADC SAR clock devided from `RTC_FAST_CLK`.
|
||||
*
|
||||
@ -94,7 +94,7 @@ void adc_hal_init(void);
|
||||
* @prarm ctrl ADC controller.
|
||||
*/
|
||||
#define adc_hal_set_controller(adc_n, ctrl) adc_ll_set_controller(adc_n, ctrl)
|
||||
#endif //#if !CONFIG_IDF_TARGET_ESP32C3
|
||||
#endif //#if !CONFIG_IDF_TARGET_ESP32C3 && !CONFIG_IDF_TARGET_ESP32H2
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
|
||||
/**
|
||||
@ -137,7 +137,7 @@ void adc_hal_init(void);
|
||||
/*---------------------------------------------------------------
|
||||
RTC controller setting
|
||||
---------------------------------------------------------------*/
|
||||
#if !CONFIG_IDF_TARGET_ESP32C3
|
||||
#if !CONFIG_IDF_TARGET_ESP32C3 && !CONFIG_IDF_TARGET_ESP32H2
|
||||
/**
|
||||
* Set adc output data format for RTC controller.
|
||||
*
|
||||
@ -152,7 +152,7 @@ void adc_hal_init(void);
|
||||
* @prarm adc_n ADC unit.
|
||||
*/
|
||||
#define adc_hal_rtc_output_invert(adc_n, inv_en) adc_ll_rtc_output_invert(adc_n, inv_en)
|
||||
#endif //#if !CONFIG_IDF_TARGET_ESP32C3
|
||||
#endif //#if !CONFIG_IDF_TARGET_ESP32C3 && !CONFIG_IDF_TARGET_ESP32H2
|
||||
|
||||
/**
|
||||
* Enable/disable the output of ADCn's internal reference voltage to one of ADC2's channels.
|
||||
@ -193,7 +193,7 @@ void adc_hal_digi_controller_config(const adc_digi_config_t *cfg);
|
||||
/*---------------------------------------------------------------
|
||||
ADC Single Read
|
||||
---------------------------------------------------------------*/
|
||||
#if !CONFIG_IDF_TARGET_ESP32C3
|
||||
#if !CONFIG_IDF_TARGET_ESP32C3 && !CONFIG_IDF_TARGET_ESP32H2
|
||||
/**
|
||||
* Set the attenuation of a particular channel on ADCn.
|
||||
*
|
||||
@ -229,7 +229,7 @@ void adc_hal_digi_controller_config(const adc_digi_config_t *cfg);
|
||||
*/
|
||||
#define adc_hal_set_atten(adc_n, channel, atten) adc_ll_set_atten(adc_n, channel, atten)
|
||||
|
||||
#else // CONFIG_IDF_TARGET_ESP32C3
|
||||
#else // CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32H2
|
||||
/**
|
||||
* Set the attenuation for ADC to single read
|
||||
*
|
||||
@ -261,7 +261,7 @@ esp_err_t adc_hal_convert(adc_ll_num_t adc_n, int channel, int *out_raw);
|
||||
ADC calibration setting
|
||||
---------------------------------------------------------------*/
|
||||
#if SOC_ADC_HW_CALIBRATION_V1
|
||||
// ESP32-S2 and C3 support HW offset calibration.
|
||||
// ESP32-S2, C3 and H2 support HW offset calibration.
|
||||
|
||||
/**
|
||||
* @brief Initialize default parameter for the calibration block.
|
||||
@ -298,7 +298,7 @@ uint32_t adc_hal_self_calibration(adc_ll_num_t adc_n, adc_channel_t channel, adc
|
||||
|
||||
#endif //SOC_ADC_HW_CALIBRATION_V1
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32C3
|
||||
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32H2
|
||||
/*---------------------------------------------------------------
|
||||
DMA setting
|
||||
---------------------------------------------------------------*/
|
||||
@ -380,4 +380,4 @@ void adc_hal_digi_dis_intr(adc_hal_context_t *hal, uint32_t mask);
|
||||
*/
|
||||
void adc_hal_digi_stop(adc_hal_context_t *hal);
|
||||
|
||||
#endif //#if CONFIG_IDF_TARGET_ESP32C3
|
||||
#endif //#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32H2
|
||||
|
@ -136,7 +136,7 @@ typedef struct {
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
|
||||
uint8_t reserved: 2; /*!< reserved0 */
|
||||
uint8_t channel: 4; /*!< ADC channel index. */
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32H2
|
||||
uint8_t channel: 3; /*!< ADC channel index. */
|
||||
uint8_t unit: 1; /*!< ADC unit index. */
|
||||
uint8_t reserved: 2; /*!< reserved0 */
|
||||
@ -184,7 +184,7 @@ typedef struct {
|
||||
};
|
||||
} adc_digi_output_data_t;
|
||||
#endif
|
||||
#if CONFIG_IDF_TARGET_ESP32C3
|
||||
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32H2
|
||||
/**
|
||||
* @brief ADC digital controller (DMA mode) output data format.
|
||||
* Used to analyze the acquired ADC (DMA) data.
|
||||
@ -269,7 +269,7 @@ typedef struct {
|
||||
adc_digi_pattern_table_t *adc2_pattern; /*!<Refer to `adc1_pattern` */
|
||||
adc_digi_convert_mode_t conv_mode; /*!<ADC conversion mode for digital controller. See ``adc_digi_convert_mode_t``. */
|
||||
adc_digi_output_format_t format; /*!<ADC output data format for digital controller. See ``adc_digi_output_format_t``. */
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32H2
|
||||
uint32_t adc_pattern_len; /*!<Pattern table length for digital controller. Range: 0 ~ 7 (0: Don't change the pattern table setting).
|
||||
The pattern table that defines the conversion rules for each SAR ADC. Each table has 7 items, in which channel selection,
|
||||
resolution and attenuation are stored. When the conversion is started, the controller reads conversion rules from the
|
||||
@ -286,7 +286,7 @@ typedef struct {
|
||||
uint32_t dma_eof_num; /*!<DMA eof num of adc digital controller.
|
||||
If the number of measurements reaches `dma_eof_num`, then `dma_in_suc_eof` signal is generated in DMA.
|
||||
Note: The converted data in the DMA in link buffer will be multiple of two bytes. */
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32H2
|
||||
uint32_t sample_freq_hz; /*!< The expected ADC sampling frequency in Hz. Range: 611Hz ~ 83333Hz
|
||||
Fs = Fd / interval / 2
|
||||
Fs: sampling frequency;
|
||||
@ -363,7 +363,7 @@ typedef enum {
|
||||
* Expression: filter_data = (k-1)/k * last_data + new_data / k.
|
||||
*/
|
||||
typedef enum {
|
||||
#if CONFIG_IDF_TARGET_ESP32C3
|
||||
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32H2
|
||||
ADC_DIGI_FILTER_DIS = -1, /*!< Disable filter */
|
||||
#endif
|
||||
ADC_DIGI_FILTER_IIR_2 = 0, /*!<The filter mode is first-order IIR filter. The coefficient is 2. */
|
||||
@ -407,7 +407,7 @@ typedef enum {
|
||||
* MONITOR_LOW: If ADC_OUT < threshold, Generates monitor interrupt.
|
||||
*/
|
||||
typedef enum {
|
||||
#if CONFIG_IDF_TARGET_ESP32C3
|
||||
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32H2
|
||||
ADC_DIGI_MONITOR_DIS = 0, /*!<Disable monitor. */
|
||||
ADC_DIGI_MONITOR_EN, /*!<If ADC_OUT < threshold, Generates monitor interrupt. */
|
||||
/*!<If ADC_OUT > threshold, Generates monitor interrupt. */
|
||||
@ -430,7 +430,7 @@ typedef struct {
|
||||
adc_channel_t channel; /*!<Set adc channel number for monitor.
|
||||
For ESP32-S2, it's always `ADC_CHANNEL_MAX` */
|
||||
adc_digi_monitor_mode_t mode; /*!<Set adc monitor mode. See ``adc_digi_monitor_mode_t``. */
|
||||
#if CONFIG_IDF_TARGET_ESP32C3
|
||||
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32H2
|
||||
uint32_t h_threshold; /*!<Set monitor threshold of adc digital controller. */
|
||||
uint32_t l_threshold; /*!<Set monitor threshold of adc digital controller. */
|
||||
#else
|
||||
|
@ -21,8 +21,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "hal/dac_ll.h"
|
||||
#include "hal/hal_defs.h"
|
||||
#include <esp_err.h>
|
||||
|
||||
/**
|
||||
* Power on dac module and start output voltage.
|
||||
|
245
tools/sdk/esp32c3/include/hal/include/hal/emac_hal.h
Normal file
245
tools/sdk/esp32c3/include/hal/include/hal/emac_hal.h
Normal file
@ -0,0 +1,245 @@
|
||||
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
#include "hal/eth_types.h"
|
||||
#include "soc/emac_dma_struct.h"
|
||||
#include "soc/emac_mac_struct.h"
|
||||
#include "soc/emac_ext_struct.h"
|
||||
|
||||
/**
|
||||
* @brief Ethernet DMA TX Descriptor
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
volatile union {
|
||||
struct {
|
||||
uint32_t Deferred : 1; /*!< MAC defers before transmission */
|
||||
uint32_t UnderflowErr : 1; /*!< DMA encountered an empty transmit buffer */
|
||||
uint32_t ExcessiveDeferral : 1; /*!< Excessive deferral of over 24,288 bit times */
|
||||
uint32_t CollisionCount : 4; /*!< Number of collisions occurred before transmitted */
|
||||
uint32_t VLanFrame : 1; /*!< Transmitted frame is a VLAN-type frame */
|
||||
uint32_t ExcessiveCollision : 1; /*!< Transmission aborted after 16 successive collisions */
|
||||
uint32_t LateCollision : 1; /*!< Collision occurred after the collision window */
|
||||
uint32_t NoCarrier : 1; /*!< Carrier Sense signal from the PHY was not asserted */
|
||||
uint32_t LossCarrier : 1; /*!< Loss of carrier occurred during transmission */
|
||||
uint32_t PayloadChecksumErr : 1; /*!< Checksum error in TCP/UDP/ICMP datagram payload */
|
||||
uint32_t FrameFlushed : 1; /*!< DMA or MTL flushed the frame */
|
||||
uint32_t JabberTimeout : 1; /*!< MAC transmitter has experienced a jabber timeout */
|
||||
uint32_t ErrSummary : 1; /*!< Error Summary */
|
||||
uint32_t IPHeadErr : 1; /*!< IP Header Error */
|
||||
uint32_t TxTimestampStatus : 1; /*!< Timestamp captured for the transmit frame */
|
||||
uint32_t VLANInsertControl : 2; /*!< VLAN tagging or untagging before transmitting */
|
||||
uint32_t SecondAddressChained : 1; /*!< Second address in the descriptor is Next Descriptor address */
|
||||
uint32_t TransmitEndRing : 1; /*!< Descriptor list reached its final descriptor */
|
||||
uint32_t ChecksumInsertControl : 2; /*!< Control checksum calculation and insertion */
|
||||
uint32_t CRCReplacementControl : 1; /*!< Control CRC replace */
|
||||
uint32_t TransmitTimestampEnable : 1; /*!< Enable IEEE1588 harware timestamping */
|
||||
uint32_t DisablePad : 1; /*!< Control add padding when frame short than 64 bytes */
|
||||
uint32_t DisableCRC : 1; /*!< Control append CRC to the end of frame */
|
||||
uint32_t FirstSegment : 1; /*!< Buffer contains the first segment of a frame */
|
||||
uint32_t LastSegment : 1; /*!< Buffer contains the last segment of a frame */
|
||||
uint32_t InterruptOnComplete : 1; /*!< Interrupt after frame transmitted */
|
||||
uint32_t Own : 1; /*!< Owner of this descriptor: DMA controller or host */
|
||||
};
|
||||
uint32_t Value;
|
||||
} TDES0;
|
||||
union {
|
||||
struct {
|
||||
uint32_t TransmitBuffer1Size : 13; /*!< First data buffer byte size */
|
||||
uint32_t Reserved : 3; /*!< Reserved */
|
||||
uint32_t TransmitBuffer2Size : 13; /*!< Second data buffer byte size */
|
||||
uint32_t SAInsertControl : 3; /*!< Control MAC add or replace Source Address field */
|
||||
};
|
||||
uint32_t Value;
|
||||
} TDES1;
|
||||
uint32_t Buffer1Addr; /*!< Buffer1 address pointer */
|
||||
uint32_t Buffer2NextDescAddr; /*!< Buffer2 or next descriptor address pointer */
|
||||
uint32_t Reserved1; /*!< Reserved */
|
||||
uint32_t Reserved2; /*!< Reserved */
|
||||
uint32_t TimeStampLow; /*!< Transmit Frame Timestamp Low */
|
||||
uint32_t TimeStampHigh; /*!< Transmit Frame Timestamp High */
|
||||
} eth_dma_tx_descriptor_t;
|
||||
#define EMAC_DMATXDESC_CHECKSUM_BYPASS 0 /*!< Checksum engine bypass */
|
||||
#define EMAC_DMATXDESC_CHECKSUM_IPV4HEADER 1 /*!< IPv4 header checksum insertion */
|
||||
#define EMAC_DMATXDESC_CHECKSUM_TCPUDPICMPSEGMENT 2 /*!< TCP/UDP/ICMP Checksum Insertion calculated over segment only */
|
||||
#define EMAC_DMATXDESC_CHECKSUM_TCPUDPICMPFULL 3 /*!< TCP/UDP/ICMP Checksum Insertion fully calculated */
|
||||
|
||||
_Static_assert(sizeof(eth_dma_tx_descriptor_t) == 32, "eth_dma_tx_descriptor_t should occupy 32 bytes in memory");
|
||||
|
||||
/**
|
||||
* @brief Ethernet DMA RX Descriptor
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
volatile union {
|
||||
struct {
|
||||
uint32_t ExtendStatusAvailable : 1; /*!< Extended statsu is available in RDES4 */
|
||||
uint32_t CRCErr : 1; /*!< CRC error occurred on frame */
|
||||
uint32_t DribbleBitErr : 1; /*!< frame contains non int multiple of 8 bits */
|
||||
uint32_t ReceiveErr : 1; /*!< Receive error */
|
||||
uint32_t ReceiveWatchdogTimeout : 1; /*!< Receive Watchdog timeout */
|
||||
uint32_t FrameType : 1; /*!< Ethernet type or IEEE802.3 */
|
||||
uint32_t LateCollision : 1; /*!< Late collision occurred during reception */
|
||||
uint32_t TSAvailIPChecksumErrGiantFrame : 1; /*!< Timestamp available or IP Checksum error or Giant frame */
|
||||
uint32_t LastDescriptor : 1; /*!< Last buffer of the frame */
|
||||
uint32_t FirstDescriptor : 1; /*!< First buffer of the frame */
|
||||
uint32_t VLANTag : 1; /*!< VLAN Tag: received frame is a VLAN frame */
|
||||
uint32_t OverflowErr : 1; /*!< Frame was damaged due to buffer overflow */
|
||||
uint32_t LengthErr : 1; /*!< Frame size not matching with length field */
|
||||
uint32_t SourceAddrFilterFail : 1; /*!< SA field of frame failed the SA filter */
|
||||
uint32_t DescriptorErr : 1; /*!< Frame truncated and DMA doesn't own next descriptor */
|
||||
uint32_t ErrSummary : 1; /*!< Error Summary, OR of all errors in RDES */
|
||||
uint32_t FrameLength : 14; /*!< Byte length of received frame */
|
||||
uint32_t DestinationAddrFilterFail : 1; /*!< Frame failed in the DA Filter in the MAC */
|
||||
uint32_t Own : 1; /*!< Owner of this descriptor: DMA controller or host */
|
||||
};
|
||||
uint32_t Value;
|
||||
} RDES0;
|
||||
union {
|
||||
struct {
|
||||
uint32_t ReceiveBuffer1Size : 13; /*!< First data buffer size in bytes */
|
||||
uint32_t Reserved1 : 1; /*!< Reserved */
|
||||
uint32_t SecondAddressChained : 1; /*!< Seconde address is the Next Descriptor address */
|
||||
uint32_t ReceiveEndOfRing : 1; /*!< Descriptor reached its final descriptor */
|
||||
uint32_t ReceiveBuffer2Size : 13; /*!< Second data buffer size in bytes */
|
||||
uint32_t Reserved : 2; /*!< Reserved */
|
||||
uint32_t DisableInterruptOnComplete : 1; /*!< Disable the assertion of interrupt to host */
|
||||
};
|
||||
uint32_t Value;
|
||||
} RDES1;
|
||||
uint32_t Buffer1Addr; /*!< Buffer1 address pointer */
|
||||
uint32_t Buffer2NextDescAddr; /*!< Buffer2 or next descriptor address pointer */
|
||||
volatile union {
|
||||
struct {
|
||||
uint32_t IPPayloadType : 3; /*!< Type of payload in the IP datagram */
|
||||
uint32_t IPHeadErr : 1; /*!< IP header error */
|
||||
uint32_t IPPayloadErr : 1; /*!< IP payload error */
|
||||
uint32_t IPChecksumBypass : 1; /*!< Checksum offload engine is bypassed */
|
||||
uint32_t IPv4PacketReceived : 1; /*!< Received packet is an IPv4 packet */
|
||||
uint32_t IPv6PacketReceived : 1; /*!< Received packet is an IPv6 packet */
|
||||
uint32_t MessageType : 4; /*!< PTP Message Type */
|
||||
uint32_t PTPFrameType : 1; /*!< PTP message is over Ethernet or IPv4/IPv6 */
|
||||
uint32_t PTPVersion : 1; /*!< Version of PTP protocol */
|
||||
uint32_t TimestampDropped : 1; /*!< Timestamp dropped because of overflow */
|
||||
uint32_t Reserved1 : 1; /*!< Reserved */
|
||||
uint32_t AVPacketReceived : 1; /*!< AV packet is received */
|
||||
uint32_t AVTaggedPacketReceived : 1; /*!< AV tagged packet is received */
|
||||
uint32_t VLANTagPrioVal : 3; /*!< VLAN tag's user value in the received packekt */
|
||||
uint32_t Reserved2 : 3; /*!< Reserved */
|
||||
uint32_t Layer3FilterMatch : 1; /*!< Received frame matches one of the enabled Layer3 IP */
|
||||
uint32_t Layer4FilterMatch : 1; /*!< Received frame matches one of the enabled Layer4 IP */
|
||||
uint32_t Layer3Layer4FilterNumberMatch : 2; /*!< Number of Layer3 and Layer4 Filter that matches the received frame */
|
||||
uint32_t Reserved3 : 4; /*!< Reserved */
|
||||
};
|
||||
uint32_t Value;
|
||||
} ExtendedStatus;
|
||||
uint32_t Reserved; /*!< Reserved */
|
||||
uint32_t TimeStampLow; /*!< Receive frame timestamp low */
|
||||
uint32_t TimeStampHigh; /*!< Receive frame timestamp high */
|
||||
} eth_dma_rx_descriptor_t;
|
||||
|
||||
_Static_assert(sizeof(eth_dma_rx_descriptor_t) == 32, "eth_dma_rx_descriptor_t should occupy 32 bytes in memory");
|
||||
|
||||
typedef struct {
|
||||
emac_mac_dev_t *mac_regs;
|
||||
emac_dma_dev_t *dma_regs;
|
||||
emac_ext_dev_t *ext_regs;
|
||||
uint8_t **rx_buf;
|
||||
uint8_t **tx_buf;
|
||||
void *descriptors;
|
||||
eth_dma_rx_descriptor_t *rx_desc;
|
||||
eth_dma_tx_descriptor_t *tx_desc;
|
||||
|
||||
} emac_hal_context_t;
|
||||
|
||||
void emac_hal_init(emac_hal_context_t *hal, void *descriptors,
|
||||
uint8_t **rx_buf, uint8_t **tx_buf);
|
||||
|
||||
void emac_hal_iomux_init_mii(void);
|
||||
|
||||
void emac_hal_iomux_init_rmii(void);
|
||||
|
||||
void emac_hal_iomux_rmii_clk_input(void);
|
||||
|
||||
void emac_hal_iomux_rmii_clk_ouput(int num);
|
||||
|
||||
void emac_hal_iomux_init_tx_er(void);
|
||||
|
||||
void emac_hal_iomux_init_rx_er(void);
|
||||
|
||||
void emac_hal_reset_desc_chain(emac_hal_context_t *hal);
|
||||
|
||||
void emac_hal_reset(emac_hal_context_t *hal);
|
||||
|
||||
bool emac_hal_is_reset_done(emac_hal_context_t *hal);
|
||||
|
||||
void emac_hal_set_csr_clock_range(emac_hal_context_t *hal, int freq);
|
||||
|
||||
void emac_hal_init_mac_default(emac_hal_context_t *hal);
|
||||
|
||||
void emac_hal_init_dma_default(emac_hal_context_t *hal);
|
||||
|
||||
void emac_hal_set_speed(emac_hal_context_t *hal, uint32_t speed);
|
||||
|
||||
void emac_hal_set_duplex(emac_hal_context_t *hal, eth_duplex_t duplex);
|
||||
|
||||
void emac_hal_set_promiscuous(emac_hal_context_t *hal, bool enable);
|
||||
|
||||
/**
|
||||
* @brief Send MAC-CTRL frames to peer (EtherType=0x8808, opcode=0x0001, dest_addr=MAC-specific-ctrl-proto-01 (01:80:c2:00:00:01))
|
||||
*/
|
||||
void emac_hal_send_pause_frame(emac_hal_context_t *hal, bool enable);
|
||||
|
||||
bool emac_hal_is_mii_busy(emac_hal_context_t *hal);
|
||||
|
||||
void emac_hal_set_phy_cmd(emac_hal_context_t *hal, uint32_t phy_addr, uint32_t phy_reg, bool write);
|
||||
|
||||
void emac_hal_set_phy_data(emac_hal_context_t *hal, uint32_t reg_value);
|
||||
|
||||
uint32_t emac_hal_get_phy_data(emac_hal_context_t *hal);
|
||||
|
||||
void emac_hal_set_address(emac_hal_context_t *hal, uint8_t *mac_addr);
|
||||
|
||||
void emac_hal_start(emac_hal_context_t *hal);
|
||||
|
||||
void emac_hal_stop(emac_hal_context_t *hal);
|
||||
|
||||
uint32_t emac_hal_get_tx_desc_owner(emac_hal_context_t *hal);
|
||||
|
||||
uint32_t emac_hal_transmit_frame(emac_hal_context_t *hal, uint8_t *buf, uint32_t length);
|
||||
|
||||
uint32_t emac_hal_receive_frame(emac_hal_context_t *hal, uint8_t *buf, uint32_t size, uint32_t *frames_remain, uint32_t *free_desc);
|
||||
|
||||
void emac_hal_enable_flow_ctrl(emac_hal_context_t *hal, bool enable);
|
||||
|
||||
uint32_t emac_hal_get_intr_enable_status(emac_hal_context_t *hal);
|
||||
|
||||
uint32_t emac_hal_get_intr_status(emac_hal_context_t *hal);
|
||||
|
||||
void emac_hal_clear_corresponding_intr(emac_hal_context_t *hal, uint32_t bits);
|
||||
|
||||
void emac_hal_clear_all_intr(emac_hal_context_t *hal);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
65
tools/sdk/esp32c3/include/hal/include/hal/eth_types.h
Normal file
65
tools/sdk/esp32c3/include/hal/include/hal/eth_types.h
Normal file
@ -0,0 +1,65 @@
|
||||
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @brief Ethernet frame CRC length
|
||||
*
|
||||
*/
|
||||
#define ETH_CRC_LEN (4)
|
||||
|
||||
/**
|
||||
* @brief Ethernet interface
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
EMAC_INTERFACE_MII, /*!< Media Independent Interface */
|
||||
EMAC_INTERFACE_RMII /*!< Reduced Media Independent Interface */
|
||||
} eth_data_interface_t;
|
||||
|
||||
/**
|
||||
* @brief Ethernet link status
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
ETH_LINK_UP, /*!< Ethernet link is up */
|
||||
ETH_LINK_DOWN /*!< Ethernet link is down */
|
||||
} eth_link_t;
|
||||
|
||||
/**
|
||||
* @brief Ethernet speed
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
ETH_SPEED_10M, /*!< Ethernet speed is 10Mbps */
|
||||
ETH_SPEED_100M, /*!< Ethernet speed is 100Mbps */
|
||||
ETH_SPEED_MAX /*!< Max speed mode (for checking purpose) */
|
||||
} eth_speed_t;
|
||||
|
||||
/**
|
||||
* @brief Ethernet duplex mode
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
ETH_DUPLEX_HALF, /*!< Ethernet is in half duplex */
|
||||
ETH_DUPLEX_FULL, /*!< Ethernet is in full duplex */
|
||||
} eth_duplex_t;
|
||||
|
||||
/**
|
||||
* @brief Ethernet Checksum
|
||||
*/
|
||||
typedef enum {
|
||||
ETH_CHECKSUM_SW, /*!< Ethernet checksum calculate by software */
|
||||
ETH_CHECKSUM_HW /*!< Ethernet checksum calculate by hardware */
|
||||
} eth_checksum_t;
|
@ -78,6 +78,7 @@ typedef enum {
|
||||
#define GPIO_SEL_46 ((uint64_t)(((uint64_t)1)<<46)) /*!< Pin 46 selected */
|
||||
#if CONFIG_IDF_TARGET_ESP32S3
|
||||
#define GPIO_SEL_47 ((uint64_t)(((uint64_t)1)<<47)) /*!< Pin 47 selected */
|
||||
#define GPIO_SEL_48 ((uint64_t)(((uint64_t)1)<<48)) /*!< Pin 48 selected */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -129,6 +130,7 @@ typedef enum {
|
||||
#define GPIO_PIN_REG_45 IO_MUX_GPIO45_REG
|
||||
#define GPIO_PIN_REG_46 IO_MUX_GPIO46_REG
|
||||
#define GPIO_PIN_REG_47 IO_MUX_GPIO47_REG
|
||||
#define GPIO_PIN_REG_48 IO_MUX_GPIO48_REG
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
typedef enum {
|
||||
@ -269,8 +271,9 @@ typedef enum {
|
||||
GPIO_NUM_43 = 43, /*!< GPIO43, input and output */
|
||||
GPIO_NUM_44 = 44, /*!< GPIO44, input and output */
|
||||
GPIO_NUM_45 = 45, /*!< GPIO45, input and output */
|
||||
GPIO_NUM_46 = 46, /*!< GPIO46, input mode only */
|
||||
GPIO_NUM_46 = 46, /*!< GPIO46, input and output */
|
||||
GPIO_NUM_47 = 47, /*!< GPIO47, input and output */
|
||||
GPIO_NUM_48 = 48, /*!< GPIO48, input and output */
|
||||
GPIO_NUM_MAX,
|
||||
/** @endcond */
|
||||
} gpio_num_t;
|
||||
@ -303,6 +306,50 @@ typedef enum {
|
||||
GPIO_NUM_MAX,
|
||||
/** @endcond */
|
||||
} gpio_num_t;
|
||||
#elif CONFIG_IDF_TARGET_ESP32H2
|
||||
typedef enum {
|
||||
GPIO_NUM_NC = -1, /*!< Use to signal not connected to S/W */
|
||||
GPIO_NUM_0 = 0, /*!< GPIO0, input and output */
|
||||
GPIO_NUM_1 = 1, /*!< GPIO1, input and output */
|
||||
GPIO_NUM_2 = 2, /*!< GPIO2, input and output */
|
||||
GPIO_NUM_3 = 3, /*!< GPIO3, input and output */
|
||||
GPIO_NUM_4 = 4, /*!< GPIO4, input and output */
|
||||
GPIO_NUM_5 = 5, /*!< GPIO5, input and output */
|
||||
GPIO_NUM_6 = 6, /*!< GPIO6, input and output */
|
||||
GPIO_NUM_7 = 7, /*!< GPIO7, input and output */
|
||||
GPIO_NUM_8 = 8, /*!< GPIO8, input and output */
|
||||
GPIO_NUM_9 = 9, /*!< GPIO9, input and output */
|
||||
GPIO_NUM_10 = 10, /*!< GPIO10, input and output */
|
||||
GPIO_NUM_11 = 11, /*!< GPIO11, input and output */
|
||||
GPIO_NUM_12 = 12, /*!< GPIO12, input and output */
|
||||
GPIO_NUM_13 = 13, /*!< GPIO13, input and output */
|
||||
GPIO_NUM_14 = 14, /*!< GPIO14, input and output */
|
||||
GPIO_NUM_15 = 15, /*!< GPIO15, input and output */
|
||||
GPIO_NUM_16 = 16, /*!< GPIO16, input and output */
|
||||
GPIO_NUM_17 = 17, /*!< GPIO17, input and output */
|
||||
GPIO_NUM_18 = 18, /*!< GPIO18, input and output */
|
||||
GPIO_NUM_19 = 19, /*!< GPIO19, input and output */
|
||||
GPIO_NUM_20 = 20, /*!< GPIO20, input and output */
|
||||
GPIO_NUM_21 = 21, /*!< GPIO21, input and output */
|
||||
GPIO_NUM_22 = 22, /*!< GPIO22, input and output */
|
||||
GPIO_NUM_26 = 26, /*!< GPIO26, input and output */
|
||||
GPIO_NUM_27 = 27, /*!< GPIO27, input and output */
|
||||
GPIO_NUM_28 = 28, /*!< GPIO28, input and output */
|
||||
GPIO_NUM_29 = 29, /*!< GPIO29, input and output */
|
||||
GPIO_NUM_30 = 30, /*!< GPIO30, input and output */
|
||||
GPIO_NUM_31 = 31, /*!< GPIO31, input and output */
|
||||
GPIO_NUM_32 = 32, /*!< GPIO32, input and output */
|
||||
GPIO_NUM_33 = 33, /*!< GPIO33, input and output */
|
||||
GPIO_NUM_34 = 34, /*!< GPIO34, input and output */
|
||||
GPIO_NUM_35 = 35, /*!< GPIO35, input and output */
|
||||
GPIO_NUM_36 = 36, /*!< GPIO36, input and output */
|
||||
GPIO_NUM_37 = 37, /*!< GPIO37, input and output */
|
||||
GPIO_NUM_38 = 38, /*!< GPIO38, input and output */
|
||||
GPIO_NUM_39 = 39, /*!< GPIO39, input and output */
|
||||
GPIO_NUM_40 = 40, /*!< GPIO40, input and output */
|
||||
GPIO_NUM_MAX,
|
||||
/** @endcond */
|
||||
} gpio_num_t;
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
|
@ -66,7 +66,7 @@ typedef struct {
|
||||
#define i2c_hal_write_cmd_reg(hal,cmd, cmd_idx) i2c_ll_write_cmd_reg((hal)->dev,cmd,cmd_idx)
|
||||
|
||||
/**
|
||||
* @brief Configure the I2C to triger a trasaction
|
||||
* @brief Configure the I2C to triger a transaction
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
|
||||
// Copyright 2015-2021 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
@ -20,309 +20,22 @@
|
||||
|
||||
// The HAL layer for MCPWM (common part)
|
||||
|
||||
/*
|
||||
* MCPWM HAL usages:
|
||||
*
|
||||
* Initialization:
|
||||
* 1. Fill the parameters in `mcpwm_hal_context_t`.
|
||||
* 2. Call `mcpwm_hal_init` to initialize the context.
|
||||
* 3. Call `mcpwm_hal_hw_init` to initialize the hardware.
|
||||
*
|
||||
* Basic PWM:
|
||||
* 1. Update parameters for the timers, comparators and generators.
|
||||
* 2. Call `mcpwm_hal_timer_update_basic` to update the timer used.
|
||||
* 3. Call `mcpwm_hal_operator_update_basic` to update all the parameters of a operator.
|
||||
*
|
||||
* Alternatively, if only the comparator is updated (duty rate), call
|
||||
* `mcpwm_hal_operator_update_comparator` to update the comparator parameters; if only the
|
||||
* generator is updated (output style), call `mcpwm_hal_operator_update_generator` to update the
|
||||
* generator parameters.
|
||||
*
|
||||
* 4. At any time, call `mcpwm_hal_timer_start` to start the timer (so that PWM output will toggle
|
||||
* according to settings), or call `mcpwm_hal_timer_stop` to stop the timer (so that the PWM output
|
||||
* will be kept as called).
|
||||
*
|
||||
* Timer settings:
|
||||
* - Sync: Call `mcpwm_hal_timer_enable_sync` to enable the sync for the timer, and call
|
||||
* `mcpwm_hal_timer_disable_sync` to disable it.
|
||||
*
|
||||
* Operator settings:
|
||||
* - Carrier: Call `mcpwm_hal_operator_enable_carrier` to enable carrier for an operator, and call
|
||||
* `mcpwm_hal_operator_disable_carrier` to disable it.
|
||||
*
|
||||
* - Deadzone: Call `mcpwm_hal_operator_update_deadzone` to update settings of deadzone for an operator.
|
||||
*
|
||||
* Fault handling settings:
|
||||
* 1. Call `mcpwm_hal_fault_init` to initialize an fault signal to be detected.
|
||||
* 2. Call `mcpwm_hal_operator_update_fault` to update the behavior of an operator when fault is
|
||||
* detected.
|
||||
* 3. If the operator selects oneshot mode to handle the fault event, call
|
||||
* `mcpwm_hal_fault_oneshot_clear` to clear that fault event after the fault is handled properly.
|
||||
* 4. Call `mcpwm_hal_fault_disable` to deinitialize the fault signal when it's no longer used.
|
||||
*
|
||||
* Capture:
|
||||
* 1. Call `mcpwm_hal_capture_enable` to enable the capture for one capture signal.
|
||||
* 2. Call `mcpwm_hal_capture_get_result` to get the last captured result.
|
||||
* 3. Call `mcpwm_hal_capture_disable` to disable the capture for a signal.
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <esp_err.h>
|
||||
#include "hal/mcpwm_ll.h"
|
||||
#include "soc/mcpwm_struct.h"
|
||||
|
||||
#define MCPWM_BASE_CLK (2 * APB_CLK_FREQ) //2*APB_CLK_FREQ 160Mhz
|
||||
|
||||
/// Configuration of HAL that used only once.
|
||||
typedef struct {
|
||||
int host_id; ///< Which MCPWM peripheral to use, 0-1.
|
||||
int host_id; ///< Which MCPWM peripheral to use, 0-1.
|
||||
} mcpwm_hal_init_config_t;
|
||||
|
||||
/// Configuration of each generator (output of operator)
|
||||
typedef struct {
|
||||
mcpwm_duty_type_t duty_type; ///< How the generator output
|
||||
int comparator; ///< for mode `MCPWM_DUTY_MODE_*`, which comparator it refers to.
|
||||
} mcpwm_hal_generator_config_t;
|
||||
|
||||
/// Configuration of each operator
|
||||
typedef struct {
|
||||
mcpwm_hal_generator_config_t gen[SOC_MCPWM_GENERATORS_PER_OPERATOR]; ///< Configuration of the generators
|
||||
float duty[SOC_MCPWM_COMPARATORS_PER_OPERATOR]; ///< Duty rate for each comparator, 10 means 10%.
|
||||
int timer; ///< The timer this operator is using
|
||||
} mcpwm_hal_operator_config_t;
|
||||
|
||||
/// Configuration of each timer
|
||||
typedef struct {
|
||||
uint32_t timer_prescale; ///< The prescale from the MCPWM main clock to the timer clock, TIMER_FREQ=(MCPWM_FREQ/(timer_prescale+1))
|
||||
uint32_t freq; ///< Frequency desired, will be updated to actual value after the `mcpwm_hal_timer_update_freq` is called.
|
||||
mcpwm_counter_type_t count_mode; ///< Counting mode
|
||||
} mcpwm_hal_timer_config_t;
|
||||
|
||||
typedef struct {
|
||||
mcpwm_dev_t *dev; ///< Beginning address of the MCPWM peripheral registers. Call `mcpwm_hal_init` to initialize it.
|
||||
uint32_t prescale; ///< Prescale from the 160M clock to MCPWM main clock.
|
||||
mcpwm_hal_timer_config_t timer[SOC_MCPWM_TIMERS_PER_GROUP]; ///< Configuration of the timers
|
||||
mcpwm_hal_operator_config_t op[SOC_MCPWM_OPERATORS_PER_GROUP]; ///< Configuration of the operators
|
||||
mcpwm_dev_t *dev; ///< Beginning address of the peripheral registers of a single MCPWM unit. Call `mcpwm_hal_init` to initialize it.
|
||||
} mcpwm_hal_context_t;
|
||||
|
||||
/// Configuration of the carrier
|
||||
typedef struct {
|
||||
bool inverted; ///< Whether to invert the output
|
||||
uint8_t duty; ///< Duty of the carrier, 0-7. Duty rate = duty/8.
|
||||
uint8_t oneshot_pulse_width; ///< oneshot pulse width, in carrier periods. 0 to disable. 0-15.
|
||||
uint32_t period; ///< Prescale from the MCPWM main clock to the carrier clock. CARRIER_FREQ=(MCPWM_FREQ/(period+1)/8.)
|
||||
} mcpwm_hal_carrier_conf_t;
|
||||
|
||||
/// Configuration of the deadzone
|
||||
typedef struct {
|
||||
mcpwm_deadtime_type_t mode; ///< Deadzone mode, `MCPWM_DEADTIME_BYPASS` to disable.
|
||||
uint32_t fed; ///< Delay on falling edge. By MCPWM main clock.
|
||||
uint32_t red; ///< Delay on rising edge. By MCPWM main clock.
|
||||
} mcpwm_hal_deadzone_conf_t;
|
||||
|
||||
/// Configuration of the fault handling for each operator
|
||||
typedef struct {
|
||||
uint32_t cbc_enabled_mask; ///< Whether the cycle-by-cycle fault handling is enabled on each fault signal. BIT(n) stands for signal n.
|
||||
uint32_t ost_enabled_mask; ///< Whether the oneshot fault handling is enabled on each on each fault signal. BIT(n) stands for signal n.
|
||||
mcpwm_output_action_t action_on_fault[SOC_MCPWM_GENERATORS_PER_OPERATOR]; ///< Action to perform on each generator when any one of the fault signal triggers.
|
||||
} mcpwm_hal_fault_conf_t;
|
||||
|
||||
/// Configuration of the synchronization of each clock
|
||||
typedef struct {
|
||||
mcpwm_sync_signal_t sync_sig; ///< Sync signal to use
|
||||
uint32_t reload_permillage; ///< Reload permillage when the sync is triggered. 100 means the timer will be reload to (period * 100)/1000=10% period value.
|
||||
} mcpwm_hal_sync_config_t;
|
||||
|
||||
/// Configuration of the capture feature on each capture signal
|
||||
typedef struct {
|
||||
mcpwm_capture_on_edge_t cap_edge; ///< Whether the edges is captured, bitwise.
|
||||
uint32_t prescale; ///< Prescale of the input signal.
|
||||
} mcpwm_hal_capture_config_t;
|
||||
|
||||
/**
|
||||
* @brief Initialize the internal state of the HAL. Call after settings are set and before other functions are called.
|
||||
*
|
||||
* @note Since There are several individual parts (timers + operators, captures), this funciton is
|
||||
* allowed to called several times.
|
||||
* @brief Initialize the internal state of the HAL.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param init_config Configuration for the HAL to be used only once.
|
||||
*/
|
||||
void mcpwm_hal_init(mcpwm_hal_context_t *hal, const mcpwm_hal_init_config_t *init_config);
|
||||
|
||||
/**
|
||||
* @brief Initialize the hardware, call after `mcpwm_hal_init` and before other functions.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
*/
|
||||
void mcpwm_hal_hw_init(mcpwm_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* @brief Start a timer
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param timer Timer to start, 0-2.
|
||||
*/
|
||||
void mcpwm_hal_timer_start(mcpwm_hal_context_t *hal, int timer);
|
||||
|
||||
/**
|
||||
* @brief Stop a timer.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param timer Timer to stop, 0-2.
|
||||
*/
|
||||
void mcpwm_hal_timer_stop(mcpwm_hal_context_t *hal, int timer);
|
||||
|
||||
/**
|
||||
* @brief Update the basic parameters of a timer.
|
||||
*
|
||||
* @note This will influence the duty rate and count mode of each operator relies on this timer.
|
||||
* Call `mcpwm_hal_operator_update_basic` for each of the operator that relies on this timer after
|
||||
* to update the duty rate and generator output.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param timer Timer to update, 0-2.
|
||||
*/
|
||||
void mcpwm_hal_timer_update_basic(mcpwm_hal_context_t *hal, int timer);
|
||||
|
||||
/**
|
||||
* @brief Start the synchronization for a timer.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param timer Timer to enable, 0-2.
|
||||
* @param sync_conf Configuration of the sync operation.
|
||||
*/
|
||||
void mcpwm_hal_timer_enable_sync(mcpwm_hal_context_t *hal, int timer, const mcpwm_hal_sync_config_t *sync_conf);
|
||||
|
||||
/**
|
||||
* @brief Stop the synchronization for a timer.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param timer Timer to disable sync, 0-2.
|
||||
*/
|
||||
void mcpwm_hal_timer_disable_sync(mcpwm_hal_context_t *hal, int timer);
|
||||
|
||||
/**
|
||||
* @brief Update the basic settings (duty, output mode) for an operator.
|
||||
*
|
||||
* Will call `mcpwm_hal_operator_update_comparator` and `mcpwm_hal_operator_update_generator`
|
||||
* recursively to update each of their duty and output mode.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param op Operator to update, 0-2.
|
||||
*/
|
||||
void mcpwm_hal_operator_update_basic(mcpwm_hal_context_t *hal, int op);
|
||||
|
||||
/**
|
||||
* @brief Update a comparator (duty) for an operator.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param op Operator to update, 0-2.
|
||||
* @param cmp Comparator to update, 0-1.
|
||||
*/
|
||||
void mcpwm_hal_operator_update_comparator(mcpwm_hal_context_t *hal, int op, int cmp);
|
||||
|
||||
/**
|
||||
* @brief Update a generator (output mode) for an operator.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param op Operator to update, 0-2.
|
||||
* @param cmp Comparator to update, 0-1.
|
||||
*/
|
||||
void mcpwm_hal_operator_update_generator(mcpwm_hal_context_t *hal, int op, int gen_num);
|
||||
|
||||
/**
|
||||
* @brief Enable the carrier for an operator.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param op Operator to enable carrier, 0-2.
|
||||
* @param carrier_conf Configuration of the carrier.
|
||||
*/
|
||||
void mcpwm_hal_operator_enable_carrier(mcpwm_hal_context_t *hal, int op, const mcpwm_hal_carrier_conf_t *carrier_conf);
|
||||
|
||||
/**
|
||||
* @brief Disable the carrier for an operator.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param op Operator to disable carrier, 0-2.
|
||||
*/
|
||||
void mcpwm_hal_operator_disable_carrier(mcpwm_hal_context_t *hal, int op);
|
||||
|
||||
/**
|
||||
* @brief Update the deadzone for an operator.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param op Operator to update the deadzone, 0-2.
|
||||
* @param deadzone Configuration of the deadzone. Set member `mode` to `MCPWM_DEADTIME_BYPASS` will bypass the deadzone.
|
||||
*/
|
||||
void mcpwm_hal_operator_update_deadzone(mcpwm_hal_context_t *hal, int op, const mcpwm_hal_deadzone_conf_t *deadzone);
|
||||
|
||||
/**
|
||||
* @brief Enable one of the fault signal.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param fault_sig The signal to enable, 0-2.
|
||||
* @param level The active level for the fault signal, true for high and false for low.
|
||||
*/
|
||||
void mcpwm_hal_fault_init(mcpwm_hal_context_t *hal, int fault_sig, bool level);
|
||||
|
||||
/**
|
||||
* @brief Configure how the operator behave to the fault signals.
|
||||
*
|
||||
* Call after the fault signal is enabled by `mcpwm_hal_fault_init`.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param op Operator to configure, 0-2.
|
||||
* @param fault_conf Configuration of the behavior of the operator when fault. Clear member `cbc_enabled_mask` and `ost_enabled_mask` will disable the fault detection of this operator.
|
||||
*/
|
||||
void mcpwm_hal_operator_update_fault(mcpwm_hal_context_t *hal, int op, const mcpwm_hal_fault_conf_t *fault_conf);
|
||||
|
||||
/**
|
||||
* @brief Clear the oneshot fault status for an operator.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param op The operator to clear oneshot fault status, 0-2.
|
||||
*/
|
||||
void mcpwm_hal_fault_oneshot_clear(mcpwm_hal_context_t *hal, int op);
|
||||
|
||||
/**
|
||||
* @brief Disable one of the fault signal.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param fault_sig The fault signal to disable, 0-2.
|
||||
*/
|
||||
void mcpwm_hal_fault_disable(mcpwm_hal_context_t *hal, int fault_sig);
|
||||
|
||||
/**
|
||||
* @brief Enable one of the capture signal.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param cap_sig Capture signal to enable, 0-2.
|
||||
* @param conf Configuration on how to capture the signal.
|
||||
*/
|
||||
void mcpwm_hal_capture_enable(mcpwm_hal_context_t *hal, int cap_sig, const mcpwm_hal_capture_config_t *conf);
|
||||
|
||||
/**
|
||||
* @brief Get the capture result.
|
||||
*
|
||||
* @note The output value will always be updated with the register value, no matter event triggered or not.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param cap_sig Signal to get capture result, 0-2.
|
||||
* @param out_count Output of the captured counter.
|
||||
* @param out_edge Output of the captured edge.
|
||||
* @return
|
||||
* - ESP_OK: if a signal is captured
|
||||
* - ESP_ERR_NOT_FOUND: if no capture event happened.
|
||||
*/
|
||||
esp_err_t mcpwm_hal_capture_get_result(mcpwm_hal_context_t *hal, int cap_sig, uint32_t *out_count,
|
||||
mcpwm_capture_on_edge_t *out_edge);
|
||||
|
||||
/**
|
||||
* @brief Disable one of the capture signal.
|
||||
*
|
||||
* @param hal Context of the HAL layer.
|
||||
* @param cap_sig The signal to capture, 0-2.
|
||||
*/
|
||||
void mcpwm_hal_capture_disable(mcpwm_hal_context_t *hal, int cap_sig);
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
|
||||
// Copyright 2015-2021 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
@ -14,74 +14,39 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
/// Interrupts for MCPWM
|
||||
typedef enum {
|
||||
MCPWM_LL_INTR_CAP0 = BIT(27), ///< Capture 0 happened
|
||||
MCPWM_LL_INTR_CAP1 = BIT(28), ///< Capture 1 happened
|
||||
MCPWM_LL_INTR_CAP2 = BIT(29), ///< Capture 2 happened
|
||||
} mcpwm_intr_t;
|
||||
MCPWM_TIMER_DIRECTION_UP, /*!< Counting direction: Increase */
|
||||
MCPWM_TIMER_DIRECTION_DOWN, /*!< Counting direction: Decrease */
|
||||
} mcpwm_timer_direction_t;
|
||||
|
||||
/**
|
||||
* @brief Select type of MCPWM counter
|
||||
*/
|
||||
typedef enum {
|
||||
MCPWM_UP_COUNTER = 1, /*!<For asymmetric MCPWM*/
|
||||
MCPWM_DOWN_COUNTER, /*!<For asymmetric MCPWM*/
|
||||
MCPWM_UP_DOWN_COUNTER, /*!<For symmetric MCPWM, frequency is half of MCPWM frequency set*/
|
||||
MCPWM_COUNTER_MAX, /*!<Maximum counter mode*/
|
||||
} mcpwm_counter_type_t;
|
||||
MCPWM_TIMER_EVENT_ZERO, /*!< MCPWM timer counts to zero */
|
||||
MCPWM_TIMER_EVENT_PEAK, /*!< MCPWM timer counts to peak */
|
||||
} mcpwm_timer_event_t;
|
||||
|
||||
/**
|
||||
* @brief Select type of MCPWM duty cycle mode
|
||||
*/
|
||||
typedef enum {
|
||||
MCPWM_DUTY_MODE_0 = 0, /*!<Active high duty, i.e. duty cycle proportional to high time for asymmetric MCPWM*/
|
||||
MCPWM_DUTY_MODE_1, /*!<Active low duty, i.e. duty cycle proportional to low time for asymmetric MCPWM, out of phase(inverted) MCPWM*/
|
||||
MCPWM_HAL_GENERATOR_MODE_FORCE_LOW,
|
||||
MCPWM_HAL_GENERATOR_MODE_FORCE_HIGH,
|
||||
MCPWM_DUTY_MODE_MAX, /*!<Num of duty cycle modes*/
|
||||
} mcpwm_duty_type_t;
|
||||
MCPWM_TIMER_COUNT_MODE_PAUSE, /*!< MCPWM timer paused */
|
||||
MCPWM_TIMER_COUNT_MODE_UP, /*!< MCPWM timer counting up */
|
||||
MCPWM_TIMER_COUNT_MODE_DOWN, /*!< MCPWM timer counting down */
|
||||
MCPWM_TIMER_COUNT_MODE_UP_DOWN, /*!< MCPWM timer counting up and down */
|
||||
} mcpwm_timer_count_mode_t;
|
||||
|
||||
/**
|
||||
* @brief MCPWM select action to be taken on the output when event happens
|
||||
*/
|
||||
typedef enum {
|
||||
MCPWM_ACTION_NO_CHANGE = 0, /*!<No change in the output*/
|
||||
MCPWM_ACTION_FORCE_LOW, /*!<Make output low*/
|
||||
MCPWM_ACTION_FORCE_HIGH, /*!<Make output high*/
|
||||
MCPWM_ACTION_TOGGLE, /*!<Make output toggle*/
|
||||
} mcpwm_output_action_t;
|
||||
MCPWM_TIMER_STOP_AT_ZERO, /*!< MCPWM timer stops when couting to zero */
|
||||
MCPWM_TIMER_STOP_AT_PEAK, /*!< MCPWM timer stops when counting to peak */
|
||||
MCPWM_TIMER_START_NO_STOP, /*!< MCPWM timer starts couting */
|
||||
MCPWM_TIMER_START_STOP_AT_ZERO, /*!< MCPWM timer starts counting and stops when couting to zero */
|
||||
MCPWM_TIMER_START_STOP_AT_PEAK, /*!< MCPWM timer starts counting and stops when counting to peak */
|
||||
} mcpwm_timer_operate_cmd_t;
|
||||
|
||||
/**
|
||||
* @brief MCPWM deadtime types, used to generate deadtime, RED refers to rising edge delay and FED refers to falling edge delay
|
||||
*/
|
||||
typedef enum {
|
||||
MCPWM_DEADTIME_BYPASS = 0, /*!<Bypass the deadtime*/
|
||||
MCPWM_BYPASS_RED, /*!<MCPWMXA = no change, MCPWMXB = falling edge delay*/
|
||||
MCPWM_BYPASS_FED, /*!<MCPWMXA = rising edge delay, MCPWMXB = no change*/
|
||||
MCPWM_ACTIVE_HIGH_MODE, /*!<MCPWMXA = rising edge delay, MCPWMXB = falling edge delay*/
|
||||
MCPWM_ACTIVE_LOW_MODE, /*!<MCPWMXA = compliment of rising edge delay, MCPWMXB = compliment of falling edge delay*/
|
||||
MCPWM_ACTIVE_HIGH_COMPLIMENT_MODE, /*!<MCPWMXA = rising edge delay, MCPWMXB = compliment of falling edge delay*/
|
||||
MCPWM_ACTIVE_LOW_COMPLIMENT_MODE, /*!<MCPWMXA = compliment of rising edge delay, MCPWMXB = falling edge delay*/
|
||||
MCPWM_ACTIVE_RED_FED_FROM_PWMXA, /*!<MCPWMXA = MCPWMXB = rising edge delay as well as falling edge delay, generated from MCPWMXA*/
|
||||
MCPWM_ACTIVE_RED_FED_FROM_PWMXB, /*!<MCPWMXA = MCPWMXB = rising edge delay as well as falling edge delay, generated from MCPWMXB*/
|
||||
MCPWM_DEADTIME_TYPE_MAX,
|
||||
} mcpwm_deadtime_type_t;
|
||||
MCPWM_GEN_ACTION_KEEP, /*!< Generator action: Keep the same level */
|
||||
MCPWM_GEN_ACTION_LOW, /*!< Generator action: Force to low level */
|
||||
MCPWM_GEN_ACTION_HIGH, /*!< Generator action: Force to high level */
|
||||
MCPWM_GEN_ACTION_TOGGLE, /*!< Generator action: Toggle level */
|
||||
} mcpwm_generator_action_t;
|
||||
|
||||
/**
|
||||
* @brief MCPWM select sync signal input
|
||||
*/
|
||||
typedef enum {
|
||||
MCPWM_SELECT_SYNC0 = 4, /*!<Select SYNC0 as input*/
|
||||
MCPWM_SELECT_SYNC1, /*!<Select SYNC1 as input*/
|
||||
MCPWM_SELECT_SYNC2, /*!<Select SYNC2 as input*/
|
||||
} mcpwm_sync_signal_t;
|
||||
|
||||
/**
|
||||
* @brief MCPWM select capture starts from which edge
|
||||
*/
|
||||
typedef enum {
|
||||
MCPWM_NEG_EDGE = BIT(0), /*!<Capture the negative edge*/
|
||||
MCPWM_POS_EDGE = BIT(1), /*!<Capture the positive edge*/
|
||||
MCPWM_BOTH_EDGE = BIT(1)|BIT(0), /*!<Capture both edges*/
|
||||
} mcpwm_capture_on_edge_t;
|
||||
MCPWM_FAULT_REACTION_CBC, /*!< Reaction on fault signal: recover cycle by cycle */
|
||||
MCPWM_FAULT_REACTION_OST, /*!< Reaction on fault signal: one shot trip */
|
||||
} mcpwm_fault_reaction_t;
|
||||
|
@ -14,12 +14,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "soc/soc_caps.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "soc/soc_caps.h"
|
||||
|
||||
/**
|
||||
* @brief RMT channel ID
|
||||
*
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
#include "hal/gpio_types.h"
|
||||
#include "hal/rtc_cntl_ll.h"
|
||||
#if !CONFIG_IDF_TARGET_ESP32C3
|
||||
#if !CONFIG_IDF_TARGET_ESP32C3 && !CONFIG_IDF_TARGET_ESP32H2
|
||||
#include "hal/rtc_io_ll.h"
|
||||
#endif
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <esp_err.h>
|
||||
#if !CONFIG_IDF_TARGET_ESP32C3
|
||||
#if !CONFIG_IDF_TARGET_ESP32C3 && !CONFIG_IDF_TARGET_ESP32H2
|
||||
#include "soc/soc_caps.h"
|
||||
#include "hal/rtc_io_ll.h"
|
||||
#endif
|
||||
|
@ -29,6 +29,9 @@ typedef SHA_TYPE esp_sha_type;
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/rom/sha.h"
|
||||
typedef SHA_TYPE esp_sha_type;
|
||||
#elif CONFIG_IDF_TARGET_ESP32H2
|
||||
#include "esp32h2/rom/sha.h"
|
||||
typedef SHA_TYPE esp_sha_type;
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -29,6 +29,7 @@ NOTE: Thread safety is the responsibility fo the HAL user. All USB Host HAL
|
||||
#include "soc/usb_wrap_struct.h"
|
||||
#include "hal/usbh_ll.h"
|
||||
#include "hal/usb_types_private.h"
|
||||
#include "hal/assert.h"
|
||||
|
||||
// ------------------------------------------------ Macros and Types ---------------------------------------------------
|
||||
|
||||
@ -322,7 +323,7 @@ static inline void usbh_hal_port_toggle_power(usbh_hal_context_t *hal, bool powe
|
||||
*/
|
||||
static inline void usbh_hal_port_toggle_reset(usbh_hal_context_t *hal, bool enable)
|
||||
{
|
||||
assert(hal->channels.num_allocd == 0); //Cannot reset if there are still allocated channels
|
||||
HAL_ASSERT(hal->channels.num_allocd == 0); //Cannot reset if there are still allocated channels
|
||||
usbh_ll_hprt_set_port_reset(hal->dev, enable);
|
||||
}
|
||||
|
||||
@ -410,7 +411,6 @@ static inline bool usbh_hal_port_check_resume(usbh_hal_context_t *hal)
|
||||
*/
|
||||
static inline void usbh_hal_port_set_frame_list(usbh_hal_context_t *hal, uint32_t *frame_list, usb_hal_frame_list_len_t len)
|
||||
{
|
||||
assert(!hal->flags.periodic_sched_enabled);
|
||||
//Clear and save frame list
|
||||
hal->periodic_frame_list = frame_list;
|
||||
hal->frame_list_len = len;
|
||||
@ -438,7 +438,7 @@ static inline uint32_t *usbh_hal_port_get_frame_list(usbh_hal_context_t *hal)
|
||||
*/
|
||||
static inline void usbh_hal_port_periodic_enable(usbh_hal_context_t *hal)
|
||||
{
|
||||
assert(hal->periodic_frame_list != NULL && !hal->flags.periodic_sched_enabled);
|
||||
HAL_ASSERT(hal->periodic_frame_list != NULL);
|
||||
usbh_ll_set_frame_list_base_addr(hal->dev, (uint32_t)hal->periodic_frame_list);
|
||||
usbh_ll_hcfg_set_num_frame_list_entries(hal->dev, hal->frame_list_len);
|
||||
usbh_ll_hcfg_en_perio_sched(hal->dev);
|
||||
@ -458,7 +458,7 @@ static inline void usbh_hal_port_periodic_enable(usbh_hal_context_t *hal)
|
||||
*/
|
||||
static inline void usbh_hal_port_periodic_disable(usbh_hal_context_t *hal)
|
||||
{
|
||||
assert(hal->flags.periodic_sched_enabled);
|
||||
HAL_ASSERT(hal->flags.periodic_sched_enabled);
|
||||
usbh_ll_hcfg_dis_perio_sched(hal->dev);
|
||||
hal->flags.periodic_sched_enabled = 0;
|
||||
}
|
||||
@ -602,7 +602,7 @@ void usbh_hal_chan_set_ep_char(usbh_hal_context_t *hal, usbh_hal_chan_t *chan_ob
|
||||
static inline void usbh_hal_chan_set_dir(usbh_hal_chan_t *chan_obj, bool is_in)
|
||||
{
|
||||
//Cannot change direction whilst channel is still active or in error
|
||||
assert(!chan_obj->flags.active && !chan_obj->flags.error_pending);
|
||||
HAL_ASSERT(!chan_obj->flags.active && !chan_obj->flags.error_pending);
|
||||
usbh_ll_chan_set_dir(chan_obj->regs, is_in);
|
||||
}
|
||||
|
||||
@ -621,7 +621,7 @@ static inline void usbh_hal_chan_set_dir(usbh_hal_chan_t *chan_obj, bool is_in)
|
||||
static inline void usbh_hal_chan_set_pid(usbh_hal_chan_t *chan_obj, int pid)
|
||||
{
|
||||
//Cannot change pid whilst channel is still active or in error
|
||||
assert(!chan_obj->flags.active && !chan_obj->flags.error_pending);
|
||||
HAL_ASSERT(!chan_obj->flags.active && !chan_obj->flags.error_pending);
|
||||
//Update channel object and set the register
|
||||
usbh_ll_chan_set_pid(chan_obj->regs, pid);
|
||||
}
|
||||
@ -638,7 +638,7 @@ static inline void usbh_hal_chan_set_pid(usbh_hal_chan_t *chan_obj, int pid)
|
||||
*/
|
||||
static inline uint32_t usbh_hal_chan_get_pid(usbh_hal_chan_t *chan_obj)
|
||||
{
|
||||
assert(!chan_obj->flags.active && !chan_obj->flags.error_pending);
|
||||
HAL_ASSERT(!chan_obj->flags.active && !chan_obj->flags.error_pending);
|
||||
return usbh_ll_chan_get_pid(chan_obj->regs);
|
||||
}
|
||||
|
||||
@ -695,7 +695,7 @@ bool usbh_hal_chan_request_halt(usbh_hal_chan_t *chan_obj);
|
||||
*/
|
||||
static inline usbh_hal_chan_error_t usbh_hal_chan_get_error(usbh_hal_chan_t *chan_obj)
|
||||
{
|
||||
assert(chan_obj->flags.error_pending);
|
||||
HAL_ASSERT(chan_obj->flags.error_pending);
|
||||
return chan_obj->error;
|
||||
}
|
||||
|
||||
@ -707,7 +707,7 @@ static inline usbh_hal_chan_error_t usbh_hal_chan_get_error(usbh_hal_chan_t *cha
|
||||
static inline void usbh_hal_chan_clear_error(usbh_hal_chan_t *chan_obj)
|
||||
{
|
||||
//Can only clear error when an error has occurred
|
||||
assert(chan_obj->flags.error_pending);
|
||||
HAL_ASSERT(chan_obj->flags.error_pending);
|
||||
chan_obj->flags.error_pending = 0;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,43 @@
|
||||
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#pragma once
|
||||
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void __assert_func(const char *file, int line, const char *func, const char *expr);
|
||||
extern void abort(void);
|
||||
|
||||
#ifndef __ASSERT_FUNC
|
||||
#ifdef __ASSERT_FUNCTION
|
||||
#define __ASSERT_FUNC __ASSERT_FUNCTION
|
||||
#else
|
||||
#define __ASSERT_FUNC "??"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if CONFIG_HAL_DEFAULT_ASSERTION_LEVEL == 1 // silent
|
||||
#define HAL_ASSERT(__e) (__builtin_expect(!!(__e), 1) ? (void)0 : abort())
|
||||
#elif CONFIG_HAL_DEFAULT_ASSERTION_LEVEL == 2 // full assertion
|
||||
#define HAL_ASSERT(__e) (__builtin_expect(!!(__e), 1) ? (void)0 : __assert_func(__FILE__, __LINE__, __ASSERT_FUNC, #__e))
|
||||
#else // no assert
|
||||
#define HAL_ASSERT(__e) ((void)(__e))
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,17 @@
|
||||
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#define STATIC_HAL_REG_CHECK(TAG, ENUM, VAL) _Static_assert((ENUM) == (VAL), #TAG": "#ENUM" definition no longer matches register value")
|
@ -1,9 +1,9 @@
|
||||
// Copyright 2010-2018 Espressif Systems (Shanghai) PTE LTD
|
||||
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
@ -16,15 +16,8 @@
|
||||
|
||||
#include "esp_log.h"
|
||||
|
||||
// platform related stuff
|
||||
|
||||
#define HAL_SWAP32(word) __builtin_bswap32(word)
|
||||
#define HAL_SWAP64(word) __builtin_bswap64(word)
|
||||
|
||||
#define HAL_LOGE(...) ESP_LOGE(__VA_ARGS__)
|
||||
#define HAL_LOGW(...) ESP_LOGW(__VA_ARGS__)
|
||||
#define HAL_LOGI(...) ESP_LOGI(__VA_ARGS__)
|
||||
#define HAL_LOGD(...) ESP_LOGD(__VA_ARGS__)
|
||||
#define HAL_LOGV(...) ESP_LOGV(__VA_ARGS__)
|
||||
|
||||
#define STATIC_HAL_REG_CHECK(TAG, ENUM, VAL) _Static_assert((ENUM) == (VAL), #TAG" "#ENUM" definition no longer matches register value")
|
@ -0,0 +1,18 @@
|
||||
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#pragma once
|
||||
|
||||
#define HAL_SWAP16(d) __builtin_bswap16((d))
|
||||
#define HAL_SWAP32(d) __builtin_bswap32((d))
|
||||
#define HAL_SWAP64(d) __builtin_bswap64((d))
|
Reference in New Issue
Block a user