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:
596
tools/sdk/esp32/include/hal/esp32/include/hal/emac_ll.h
Normal file
596
tools/sdk/esp32/include/hal/esp32/include/hal/emac_ll.h
Normal file
@ -0,0 +1,596 @@
|
||||
// Copyright 2015-2019 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.
|
||||
|
||||
/*******************************************************************************
|
||||
* NOTICE
|
||||
* The hal is not public api, don't use in application code.
|
||||
* See readme.md in hal/include/hal/readme.md
|
||||
******************************************************************************/
|
||||
|
||||
// The LL layer for ESP32 eMAC register operations
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "hal/eth_types.h"
|
||||
#include "soc/emac_dma_struct.h"
|
||||
#include "soc/emac_mac_struct.h"
|
||||
#include "soc/emac_ext_struct.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Register configuration */
|
||||
#define EMAC_LL_INTERFRAME_GAP_96BIT (0)
|
||||
#define EMAC_LL_INTERFRAME_GAP_88BIT (1)
|
||||
#define EMAC_LL_INTERFRAME_GAP_80BIT (2)
|
||||
#define EMAC_LL_INTERFRAME_GAP_72BIT (3)
|
||||
#define EMAC_LL_INTERFRAME_GAP_64BIT (4)
|
||||
#define EMAC_LL_INTERFRAME_GAP_56BIT (5)
|
||||
#define EMAC_LL_INTERFRAME_GAP_48BIT (6)
|
||||
#define EMAC_LL_INTERFRAME_GAP_40BIT (7)
|
||||
|
||||
#define EMAC_LL_BACKOFF_LIMIT_10 (0)
|
||||
#define EMAC_LL_BACKOFF_LIMIT_8 (1)
|
||||
#define EMAC_LL_BACKOFF_LIMIT_4 (2)
|
||||
#define EMAC_LL_BACKOFF_LIMIT_1 (3)
|
||||
|
||||
#define EMAC_LL_PREAMBLE_LENGTH_7 (0)
|
||||
#define EMAC_LL_PREAMBLE_LENGTH_5 (1)
|
||||
#define EMAC_LL_PREAMBLE_LENGTH_3 (2)
|
||||
|
||||
#define EMAC_LL_SOURCE_ADDR_FILTER_DISABLE (0)
|
||||
#define EMAC_LL_SOURCE_ADDR_FILTER_NORMAL (2)
|
||||
#define EMAC_LL_SOURCE_ADDR_FILTER_INVERSE (3)
|
||||
|
||||
#define EMAC_LL_CONTROL_FRAME_BLOCKALL (0)
|
||||
#define EMAC_LL_CONTROL_FRAME_FORWARDALL_PAUSE (1)
|
||||
#define EMAC_LL_CONTROL_FRAME_FORWARDALL (2)
|
||||
#define EMAC_LL_CONTROL_FRAME_FORWARDFILT (3)
|
||||
|
||||
#define EMAC_LL_PAUSE_TIME 0x1648
|
||||
|
||||
#define EMAC_LL_PAUSE_LOW_THRESHOLD_MINUS_4 (0)
|
||||
#define EMAC_LL_PAUSE_LOW_THRESHOLD_MINUS_28 (1)
|
||||
#define EMAC_LL_PAUSE_LOW_THRESHOLD_MINUS_144 (2)
|
||||
#define EMAC_LL_PAUSE_LOW_THRESHOLD_MINUS_256 (3)
|
||||
|
||||
#define EMAC_LL_TRANSMIT_THRESHOLD_CONTROL_64 (0)
|
||||
#define EMAC_LL_TRANSMIT_THRESHOLD_CONTROL_128 (1)
|
||||
#define EMAC_LL_TRANSMIT_THRESHOLD_CONTROL_192 (2)
|
||||
#define EMAC_LL_TRANSMIT_THRESHOLD_CONTROL_256 (3)
|
||||
#define EMAC_LL_TRANSMIT_THRESHOLD_CONTROL_40 (4)
|
||||
#define EMAC_LL_TRANSMIT_THRESHOLD_CONTROL_32 (5)
|
||||
#define EMAC_LL_TRANSMIT_THRESHOLD_CONTROL_24 (6)
|
||||
#define EMAC_LL_TRANSMIT_THRESHOLD_CONTROL_16 (7)
|
||||
|
||||
#define EMAC_LL_RECEIVE_THRESHOLD_CONTROL_64 (0)
|
||||
#define EMAC_LL_RECEIVE_THRESHOLD_CONTROL_32 (1)
|
||||
#define EMAC_LL_RECEIVE_THRESHOLD_CONTROL_96 (2)
|
||||
#define EMAC_LL_RECEIVE_THRESHOLD_CONTROL_128 (3)
|
||||
|
||||
#define EMAC_LL_DMA_BURST_LENGTH_1BEAT (1)
|
||||
#define EMAC_LL_DMA_BURST_LENGTH_2BEAT (2)
|
||||
#define EMAC_LL_DMA_BURST_LENGTH_4BEAT (4)
|
||||
#define EMAC_LL_DMA_BURST_LENGTH_8BEAT (8)
|
||||
#define EMAC_LL_DMA_BURST_LENGTH_16BEAT (16)
|
||||
#define EMAC_LL_DMA_BURST_LENGTH_32BEAT (32)
|
||||
|
||||
#define EMAC_LL_DMA_ARBITRATION_ROUNDROBIN_RXTX_1_1 (0)
|
||||
#define EMAC_LL_DMA_ARBITRATION_ROUNDROBIN_RXTX_2_1 (1)
|
||||
#define EMAC_LL_DMA_ARBITRATION_ROUNDROBIN_RXTX_3_1 (2)
|
||||
#define EMAC_LL_DMA_ARBITRATION_ROUNDROBIN_RXTX_4_1 (3)
|
||||
|
||||
/* PTP register bits */
|
||||
#define EMAC_LL_DMAPTPRXDESC_PTPMT_SYNC 0x00000100U /* SYNC message (all clock types) */
|
||||
#define EMAC_LL_DMAPTPRXDESC_PTPMT_FOLLOWUP 0x00000200U /* FollowUp message (all clock types) */
|
||||
#define EMAC_LL_DMAPTPRXDESC_PTPMT_DELAYREQ 0x00000300U /* DelayReq message (all clock types) */
|
||||
#define EMAC_LL_DMAPTPRXDESC_PTPMT_DELAYRESP 0x00000400U /* DelayResp message (all clock types) */
|
||||
#define EMAC_LL_DMAPTPRXDESC_PTPMT_PDELAYREQ_ANNOUNCE 0x00000500U /* PdelayReq message (peer-to-peer transparent clock) or Announce message (Ordinary or Boundary clock) */
|
||||
#define EMAC_LL_DMAPTPRXDESC_PTPMT_PDELAYRESP_MANAG 0x00000600U /* PdelayResp message (peer-to-peer transparent clock) or Management message (Ordinary or Boundary clock) */
|
||||
#define EMAC_LL_DMAPTPRXDESC_PTPMT_PDELAYRESPFOLLOWUP_SIGNAL 0x00000700U /* PdelayRespFollowUp message (peer-to-peer transparent clock) or Signaling message (Ordinary or Boundary clock) */
|
||||
|
||||
#define EMAC_LL_DMAPTPRXDESC_IPPT_UDP 0x00000001U /* UDP payload encapsulated in the IP datagram */
|
||||
#define EMAC_LL_DMAPTPRXDESC_IPPT_TCP 0x00000002U /* TCP payload encapsulated in the IP datagram */
|
||||
#define EMAC_LL_DMAPTPRXDESC_IPPT_ICMP 0x00000003U /* ICMP payload encapsulated in the IP datagram */
|
||||
|
||||
#define EMAC_LL_DMADESC_OWNER_CPU (0)
|
||||
#define EMAC_LL_DMADESC_OWNER_DMA (1)
|
||||
|
||||
/* Interrupt flags (referring to dmastatus register in emac_dma_struct.h) */
|
||||
#define EMAC_LL_DMA_TRANSMIT_FINISH_INTR 0x00000001U
|
||||
#define EMAC_LL_DMA_TRANSMIT_STOP_INTR 0x00000002U
|
||||
#define EMAC_LL_DMA_TRANSMIT_BUFF_UNAVAILABLE_INTR 0x00000004U
|
||||
#define EMAC_LL_DMA_TRANSMIT_TIMEOUT_INTR 0x00000008U
|
||||
#define EMAC_LL_DMA_RECEIVE_OVERFLOW_INTR 0x00000010U
|
||||
#define EMAC_LL_DMA_TRANSMIT_UNDERFLOW_INTR 0x00000020U
|
||||
#define EMAC_LL_DMA_RECEIVE_FINISH_INTR 0x00000040U
|
||||
#define EMAC_LL_DMA_RECEIVE_BUFF_UNAVAILABLE_INTR 0x00000080U
|
||||
#define EMAC_LL_DMA_RECEIVE_STOP_INTR 0x00000100U
|
||||
#define EMAC_LL_DMA_RECEIVE_TIMEOUT_INTR 0x00000200U
|
||||
#define EMAC_LL_DMA_TRANSMIT_FIRST_BYTE_INTR 0x00000400U
|
||||
#define EMAC_LL_DMA_FATAL_BUS_ERROR_INRT 0x00001000U
|
||||
#define EMAC_LL_DMA_RECEIVE_FIRST_BYTE_INTR 0x00002000U
|
||||
#define EMAC_LL_DMA_ABNORMAL_INTR_SUMMARY 0x00004000U
|
||||
#define EMAC_LL_DMA_NORMAL_INTR_SUMMARY 0x00008000U
|
||||
#define EMAC_LL_DMA_POWER_MANAGE_INTR 0x10000000U
|
||||
#define EMAC_LL_DMA_TIMESTAMP_TRIGGER_INTR 0x20000000U
|
||||
|
||||
/* Interrupt enable (referring to dmain_en register in emac_dma_struct.h) */
|
||||
#define EMAC_LL_INTR_TRANSMIT_ENABLE 0x00000001U
|
||||
#define EMAC_LL_INTR_TRANSMIT_STOP_ENABLE 0x00000002U
|
||||
#define EMAC_LL_INTR_TRANSMIT_BUFF_UNAVAILABLE_ENABLE 0x00000004U
|
||||
#define EMAC_LL_INTR_TRANSMIT_TIMEOUT_ENABLE 0x00000008U
|
||||
#define EMAC_LL_INTR_OVERFLOW_ENABLE 0x00000010U
|
||||
#define EMAC_LL_INTR_UNDERFLOW_ENABLE 0x00000020U
|
||||
#define EMAC_LL_INTR_RECEIVE_ENABLE 0x00000040U
|
||||
#define EMAC_LL_INTR_REVEIVE_BUFF_UNAVAILABLE_ENABLE 0x00000080U
|
||||
#define EMAC_LL_INTR_RECEIVE_STOP_ENABLE 0x00000100U
|
||||
#define EMAC_LL_INTR_RECEIVE_TIMEOUT_ENABLE 0x00000200U
|
||||
#define EMAC_LL_INTR_TRANSMIT_FIRST_BYTE_ENABLE 0x00000400U
|
||||
#define EMAC_LL_INTR_FATAL_BUS_ERR_ENABLE 0x00002000U
|
||||
#define EMAC_LL_INTR_RECEIVE_FIRST_BYTE_ENABLE 0x00004000U
|
||||
#define EMAC_LL_INTR_ABNORMAL_SUMMARY_ENABLE 0x00008000U
|
||||
#define EMAC_LL_INTR_NORMAL_SUMMARY_ENABLE 0x00010000U
|
||||
|
||||
/* Enable needed interrupts (recv/recv_buf_unavailabal/normal must be enabled to make eth work) */
|
||||
#define EMAC_LL_CONFIG_ENABLE_INTR_MASK (EMAC_LL_INTR_RECEIVE_ENABLE | EMAC_LL_INTR_NORMAL_SUMMARY_ENABLE)
|
||||
|
||||
/************** Start of mac regs operation ********************/
|
||||
/* emacgmiiaddr */
|
||||
static inline void emac_ll_set_csr_clock_division(emac_mac_dev_t *mac_regs, uint32_t div_mode)
|
||||
{
|
||||
mac_regs->emacgmiiaddr.miicsrclk = div_mode;
|
||||
}
|
||||
|
||||
static inline bool emac_ll_is_mii_busy(emac_mac_dev_t *mac_regs)
|
||||
{
|
||||
return mac_regs->emacgmiiaddr.miibusy ? true : false;
|
||||
}
|
||||
|
||||
static inline void emac_ll_set_phy_addr(emac_mac_dev_t *mac_regs, uint32_t addr)
|
||||
{
|
||||
mac_regs->emacgmiiaddr.miidev = addr;
|
||||
}
|
||||
|
||||
static inline void emac_ll_set_phy_reg(emac_mac_dev_t *mac_regs, uint32_t reg)
|
||||
{
|
||||
mac_regs->emacgmiiaddr.miireg = reg;
|
||||
}
|
||||
|
||||
static inline void emac_ll_write_enable(emac_mac_dev_t *mac_regs, bool enable)
|
||||
{
|
||||
mac_regs->emacgmiiaddr.miiwrite = enable;
|
||||
}
|
||||
|
||||
static inline void emac_ll_set_busy(emac_mac_dev_t *mac_regs, bool busy)
|
||||
{
|
||||
mac_regs->emacgmiiaddr.miibusy = busy ? 1 : 0;
|
||||
}
|
||||
|
||||
/* gmacconfig */
|
||||
static inline void emac_ll_watchdog_enable(emac_mac_dev_t *mac_regs, bool enable)
|
||||
{
|
||||
mac_regs->gmacconfig.watchdog = !enable;
|
||||
}
|
||||
|
||||
static inline void emac_ll_jabber_enable(emac_mac_dev_t *mac_regs, bool enable)
|
||||
{
|
||||
mac_regs->gmacconfig.jabber = !enable;
|
||||
}
|
||||
|
||||
static inline void emac_ll_set_inter_frame_gap(emac_mac_dev_t *mac_regs, uint32_t gap)
|
||||
{
|
||||
mac_regs->gmacconfig.interframegap = gap;
|
||||
}
|
||||
|
||||
static inline void emac_ll_carrier_sense_enable(emac_mac_dev_t *mac_regs, bool enable)
|
||||
{
|
||||
mac_regs->gmacconfig.disablecrs = !enable;
|
||||
}
|
||||
|
||||
static inline void emac_ll_set_port_speed(emac_mac_dev_t *mac_regs, eth_speed_t speed)
|
||||
{
|
||||
if (speed == ETH_SPEED_10M || speed == ETH_SPEED_100M) {
|
||||
mac_regs->gmacconfig.mii = 1; // 10_100MBPS
|
||||
mac_regs->gmacconfig.fespeed = speed;
|
||||
} else {
|
||||
mac_regs->gmacconfig.mii = 0; // 1000MBPS
|
||||
}
|
||||
}
|
||||
|
||||
static inline void emac_ll_recv_own_enable(emac_mac_dev_t *mac_regs, bool enable)
|
||||
{
|
||||
mac_regs->gmacconfig.rxown = !enable;
|
||||
}
|
||||
|
||||
static inline void emac_ll_loopback_enable(emac_mac_dev_t *mac_regs, bool enable)
|
||||
{
|
||||
mac_regs->gmacconfig.loopback = enable;
|
||||
}
|
||||
|
||||
static inline void emac_ll_set_duplex(emac_mac_dev_t *mac_regs, eth_duplex_t duplex)
|
||||
{
|
||||
mac_regs->gmacconfig.duplex = duplex;
|
||||
}
|
||||
|
||||
static inline void emac_ll_checksum_offload_mode(emac_mac_dev_t *mac_regs, eth_checksum_t mode)
|
||||
{
|
||||
mac_regs->gmacconfig.rxipcoffload = mode;
|
||||
}
|
||||
|
||||
static inline void emac_ll_retry_enable(emac_mac_dev_t *mac_regs, bool enable)
|
||||
{
|
||||
mac_regs->gmacconfig.retry = !enable;
|
||||
}
|
||||
|
||||
static inline void emac_ll_auto_pad_crc_strip_enable(emac_mac_dev_t *mac_regs, bool enable)
|
||||
{
|
||||
mac_regs->gmacconfig.padcrcstrip = enable;
|
||||
}
|
||||
|
||||
static inline void emac_ll_set_back_off_limit(emac_mac_dev_t *mac_regs, uint32_t limit)
|
||||
{
|
||||
mac_regs->gmacconfig.backofflimit = limit;
|
||||
}
|
||||
|
||||
static inline void emac_ll_deferral_check_enable(emac_mac_dev_t *mac_regs, bool enable)
|
||||
{
|
||||
mac_regs->gmacconfig.padcrcstrip = enable;
|
||||
}
|
||||
|
||||
static inline void emac_ll_set_preamble_length(emac_mac_dev_t *mac_regs, uint32_t len)
|
||||
{
|
||||
mac_regs->gmacconfig.pltf = len;
|
||||
}
|
||||
|
||||
static inline void emac_ll_transmit_enable(emac_mac_dev_t *mac_regs, bool enable)
|
||||
{
|
||||
mac_regs->gmacconfig.tx = enable;
|
||||
}
|
||||
|
||||
static inline void emac_ll_receive_enable(emac_mac_dev_t *mac_regs, bool enable)
|
||||
{
|
||||
mac_regs->gmacconfig.rx = enable;
|
||||
}
|
||||
|
||||
/* gmacff */
|
||||
static inline void emac_ll_receive_all_enable(emac_mac_dev_t *mac_regs, bool enable)
|
||||
{
|
||||
mac_regs->gmacff.receive_all = enable;
|
||||
}
|
||||
|
||||
static inline void emac_ll_set_src_addr_filter(emac_mac_dev_t *mac_regs, uint32_t filter)
|
||||
{
|
||||
mac_regs->gmacff.safe = filter;
|
||||
}
|
||||
|
||||
static inline void emac_ll_sa_inverse_filter_enable(emac_mac_dev_t *mac_regs, bool enable)
|
||||
{
|
||||
mac_regs->gmacff.saif = enable;
|
||||
}
|
||||
|
||||
static inline void emac_ll_set_pass_ctrl_frame_mode(emac_mac_dev_t *mac_regs, uint32_t mode)
|
||||
{
|
||||
mac_regs->gmacff.pcf = mode;
|
||||
}
|
||||
|
||||
static inline void emac_ll_broadcast_frame_enable(emac_mac_dev_t *mac_regs, bool enable)
|
||||
{
|
||||
mac_regs->gmacff.dbf = !enable;
|
||||
}
|
||||
|
||||
static inline void emac_ll_pass_all_multicast_enable(emac_mac_dev_t *mac_regs, bool enable)
|
||||
{
|
||||
mac_regs->gmacff.pam = enable;
|
||||
}
|
||||
|
||||
static inline void emac_ll_da_inverse_filter_enable(emac_mac_dev_t *mac_regs, bool enable)
|
||||
{
|
||||
mac_regs->gmacff.daif = enable;
|
||||
}
|
||||
|
||||
static inline void emac_ll_promiscuous_mode_enable(emac_mac_dev_t *mac_regs, bool enable)
|
||||
{
|
||||
mac_regs->gmacff.pmode = enable;
|
||||
}
|
||||
|
||||
/* gmacfc */
|
||||
static inline void emac_ll_set_pause_time(emac_mac_dev_t *mac_regs, uint32_t time)
|
||||
{
|
||||
mac_regs->gmacfc.pause_time = time;
|
||||
}
|
||||
|
||||
static inline void emac_ll_zero_quanta_pause_enable(emac_mac_dev_t *mac_regs, bool enable)
|
||||
{
|
||||
mac_regs->gmacfc.dzpq = !enable;
|
||||
}
|
||||
|
||||
static inline void emac_ll_set_pause_low_threshold(emac_mac_dev_t *mac_regs, uint32_t threshold)
|
||||
{
|
||||
mac_regs->gmacfc.plt = threshold;
|
||||
}
|
||||
|
||||
static inline void emac_ll_unicast_pause_frame_detect_enable(emac_mac_dev_t *mac_regs, bool enable)
|
||||
{
|
||||
mac_regs->gmacfc.upfd = enable;
|
||||
}
|
||||
|
||||
static inline void emac_ll_receive_flow_ctrl_enable(emac_mac_dev_t *mac_regs, bool enable)
|
||||
{
|
||||
mac_regs->gmacfc.rfce = enable;
|
||||
}
|
||||
|
||||
static inline void emac_ll_transmit_flow_ctrl_enable(emac_mac_dev_t *mac_regs, bool enable)
|
||||
{
|
||||
mac_regs->gmacfc.tfce = enable;
|
||||
}
|
||||
|
||||
static inline void emac_ll_clear(emac_mac_dev_t *mac_regs)
|
||||
{
|
||||
mac_regs->gmacfc.val = 0;
|
||||
}
|
||||
|
||||
/* emacmiidata */
|
||||
static inline void emac_ll_set_phy_data(emac_mac_dev_t *mac_regs, uint32_t data)
|
||||
{
|
||||
mac_regs->emacmiidata.mii_data = data;
|
||||
}
|
||||
|
||||
static inline uint32_t emac_ll_get_phy_data(emac_mac_dev_t *mac_regs)
|
||||
{
|
||||
return mac_regs->emacmiidata.mii_data;
|
||||
}
|
||||
|
||||
/* emacaddr0 */
|
||||
static inline void emac_ll_set_addr(emac_mac_dev_t *mac_regs, const uint8_t *addr)
|
||||
{
|
||||
mac_regs->emacaddr0high.address0_hi = (addr[5] << 8) | addr[4];
|
||||
mac_regs->emacaddr0low = (addr[3] << 24) | (addr[2] << 16) | (addr[1] << 8) | (addr[0]);
|
||||
}
|
||||
/*************** End of mac regs operation *********************/
|
||||
|
||||
|
||||
|
||||
/************** Start of dma regs operation ********************/
|
||||
/* dmabusmode */
|
||||
static inline void emac_ll_reset(emac_dma_dev_t *dma_regs)
|
||||
{
|
||||
dma_regs->dmabusmode.sw_rst = 1;
|
||||
}
|
||||
|
||||
static inline bool emac_ll_is_reset_done(emac_dma_dev_t *dma_regs)
|
||||
{
|
||||
return dma_regs->dmabusmode.sw_rst ? false : true;
|
||||
}
|
||||
|
||||
/* dmarxbaseaddr / dmatxbaseaddr */
|
||||
static inline void emac_ll_set_rx_desc_addr(emac_dma_dev_t *dma_regs, uint32_t addr)
|
||||
{
|
||||
dma_regs->dmarxbaseaddr = addr;
|
||||
}
|
||||
|
||||
static inline void emac_ll_set_tx_desc_addr(emac_dma_dev_t *dma_regs, uint32_t addr)
|
||||
{
|
||||
dma_regs->dmatxbaseaddr = addr;
|
||||
}
|
||||
|
||||
/* dmaoperation_mode */
|
||||
static inline void emac_ll_drop_tcp_err_frame_enable(emac_dma_dev_t *dma_regs, bool enable)
|
||||
{
|
||||
dma_regs->dmaoperation_mode.dis_drop_tcpip_err_fram = !enable;
|
||||
}
|
||||
|
||||
static inline void emac_ll_recv_store_forward_enable(emac_dma_dev_t *dma_regs, bool enable)
|
||||
{
|
||||
dma_regs->dmaoperation_mode.rx_store_forward = enable;
|
||||
}
|
||||
|
||||
static inline void emac_ll_flush_recv_frame_enable(emac_dma_dev_t *dma_regs, bool enable)
|
||||
{
|
||||
dma_regs->dmaoperation_mode.dis_flush_recv_frames = !enable;
|
||||
}
|
||||
|
||||
static inline void emac_ll_trans_store_forward_enable(emac_dma_dev_t *dma_regs, bool enable)
|
||||
{
|
||||
dma_regs->dmaoperation_mode.tx_str_fwd = !enable;
|
||||
}
|
||||
|
||||
static inline void emac_ll_flush_trans_fifo_enable(emac_dma_dev_t *dma_regs, bool enable)
|
||||
{
|
||||
dma_regs->dmaoperation_mode.flush_tx_fifo = enable;
|
||||
}
|
||||
|
||||
static inline void emac_ll_set_transmit_threshold(emac_dma_dev_t *dma_regs, uint32_t threshold)
|
||||
{
|
||||
dma_regs->dmaoperation_mode.tx_thresh_ctrl = threshold;
|
||||
}
|
||||
|
||||
static inline void emac_ll_start_stop_dma_transmit(emac_dma_dev_t *dma_regs, bool enable)
|
||||
{
|
||||
dma_regs->dmaoperation_mode.start_stop_transmission_command = enable;
|
||||
}
|
||||
|
||||
static inline void emac_ll_forward_err_frame_enable(emac_dma_dev_t *dma_regs, bool enable)
|
||||
{
|
||||
dma_regs->dmaoperation_mode.fwd_err_frame = enable;
|
||||
}
|
||||
|
||||
static inline void emac_ll_forward_undersized_good_frame_enable(emac_dma_dev_t *dma_regs, bool enable)
|
||||
{
|
||||
dma_regs->dmaoperation_mode.fwd_under_gf = enable;
|
||||
}
|
||||
|
||||
static inline void emac_ll_set_recv_threshold(emac_dma_dev_t *dma_regs, uint32_t threshold)
|
||||
{
|
||||
dma_regs->dmaoperation_mode.rx_thresh_ctrl = threshold;
|
||||
}
|
||||
|
||||
static inline void emac_ll_opt_second_frame_enable(emac_dma_dev_t *dma_regs, bool enable)
|
||||
{
|
||||
dma_regs->dmaoperation_mode.opt_second_frame = enable;
|
||||
}
|
||||
|
||||
static inline void emac_ll_start_stop_dma_receive(emac_dma_dev_t *dma_regs, bool enable)
|
||||
{
|
||||
dma_regs->dmaoperation_mode.start_stop_rx = enable;
|
||||
}
|
||||
|
||||
/* dmabusmode */
|
||||
static inline void emac_ll_mixed_burst_enable(emac_dma_dev_t *dma_regs, bool enable)
|
||||
{
|
||||
dma_regs->dmabusmode.dmamixedburst = enable;
|
||||
}
|
||||
|
||||
static inline void emac_ll_addr_align_enable(emac_dma_dev_t *dma_regs, bool enable)
|
||||
{
|
||||
dma_regs->dmabusmode.dmaaddralibea = enable;
|
||||
}
|
||||
|
||||
static inline void emac_ll_use_separate_pbl_enable(emac_dma_dev_t *dma_regs, bool enable)
|
||||
{
|
||||
dma_regs->dmabusmode.use_sep_pbl = enable;
|
||||
}
|
||||
|
||||
static inline void emac_ll_set_rx_dma_pbl(emac_dma_dev_t *dma_regs, uint32_t pbl)
|
||||
{
|
||||
dma_regs->dmabusmode.rx_dma_pbl = pbl;
|
||||
}
|
||||
|
||||
static inline void emac_ll_set_prog_burst_len(emac_dma_dev_t *dma_regs, uint32_t len)
|
||||
{
|
||||
dma_regs->dmabusmode.prog_burst_len = len;
|
||||
}
|
||||
|
||||
static inline void emac_ll_enhance_desc_enable(emac_dma_dev_t *dma_regs, bool enable)
|
||||
{
|
||||
dma_regs->dmabusmode.alt_desc_size = enable;
|
||||
}
|
||||
|
||||
static inline void emac_ll_set_desc_skip_len(emac_dma_dev_t *dma_regs, uint32_t len)
|
||||
{
|
||||
dma_regs->dmabusmode.desc_skip_len = len;
|
||||
}
|
||||
|
||||
static inline void emac_ll_fixed_arbitration_enable(emac_dma_dev_t *dma_regs, bool enable)
|
||||
{
|
||||
dma_regs->dmabusmode.dma_arb_sch = enable;
|
||||
}
|
||||
|
||||
static inline void emac_ll_set_priority_ratio(emac_dma_dev_t *dma_regs, uint32_t ratio)
|
||||
{
|
||||
dma_regs->dmabusmode.pri_ratio = ratio;
|
||||
}
|
||||
|
||||
/* dmain_en */
|
||||
static inline void emac_ll_enable_all_intr(emac_dma_dev_t *dma_regs)
|
||||
{
|
||||
dma_regs->dmain_en.val = 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
static inline void emac_ll_disable_all_intr(emac_dma_dev_t *dma_regs)
|
||||
{
|
||||
dma_regs->dmain_en.val = 0x00000000;
|
||||
}
|
||||
|
||||
static inline void emac_ll_enable_corresponding_intr(emac_dma_dev_t *dma_regs, uint32_t mask)
|
||||
{
|
||||
dma_regs->dmain_en.val |= mask;
|
||||
}
|
||||
|
||||
static inline void emac_ll_disable_corresponding_intr(emac_dma_dev_t *dma_regs, uint32_t mask)
|
||||
{
|
||||
dma_regs->dmain_en.val &= ~mask;
|
||||
}
|
||||
|
||||
static inline uint32_t emac_ll_get_intr_enable_status(emac_dma_dev_t *dma_regs)
|
||||
{
|
||||
return dma_regs->dmain_en.val;
|
||||
}
|
||||
|
||||
/* dmastatus */
|
||||
__attribute__((always_inline)) static inline uint32_t emac_ll_get_intr_status(emac_dma_dev_t *dma_regs)
|
||||
{
|
||||
return dma_regs->dmastatus.val;
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline void emac_ll_clear_corresponding_intr(emac_dma_dev_t *dma_regs, uint32_t bits)
|
||||
{
|
||||
dma_regs->dmastatus.val = bits;
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline void emac_ll_clear_all_pending_intr(emac_dma_dev_t *dma_regs)
|
||||
{
|
||||
dma_regs->dmastatus.val = 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
|
||||
/* dmatxpolldemand / dmarxpolldemand */
|
||||
static inline void emac_ll_transmit_poll_demand(emac_dma_dev_t *dma_regs, uint32_t val)
|
||||
{
|
||||
dma_regs->dmatxpolldemand = val;
|
||||
}
|
||||
static inline void emac_ll_receive_poll_demand(emac_dma_dev_t *dma_regs, uint32_t val)
|
||||
{
|
||||
dma_regs->dmarxpolldemand = val;
|
||||
}
|
||||
|
||||
/*************** End of dma regs operation *********************/
|
||||
|
||||
|
||||
|
||||
/************** Start of ext regs operation ********************/
|
||||
static inline void emac_ll_clock_enable_mii(emac_ext_dev_t *ext_regs)
|
||||
{
|
||||
/* 0 for mii mode */
|
||||
ext_regs->ex_phyinf_conf.phy_intf_sel = 0;
|
||||
ext_regs->ex_clk_ctrl.mii_clk_rx_en = 1;
|
||||
ext_regs->ex_clk_ctrl.mii_clk_tx_en = 1;
|
||||
}
|
||||
|
||||
static inline void emac_ll_clock_enable_rmii_input(emac_ext_dev_t *ext_regs)
|
||||
{
|
||||
/* 4 for rmii mode */
|
||||
ext_regs->ex_phyinf_conf.phy_intf_sel = 4;
|
||||
/* ref clk for phy is input in rmii mode, the clk can be offered by mac layer or external crystal.
|
||||
config pin as output to generate ref clk by esp32 mac layer or input to obtain the clock from external crystal */
|
||||
ext_regs->ex_clk_ctrl.ext_en = 1;
|
||||
ext_regs->ex_clk_ctrl.int_en = 0;
|
||||
ext_regs->ex_oscclk_conf.clk_sel = 1;
|
||||
}
|
||||
|
||||
static inline void emac_ll_clock_enable_rmii_output(emac_ext_dev_t *ext_regs)
|
||||
{
|
||||
/* 4 for rmii mode */
|
||||
ext_regs->ex_phyinf_conf.phy_intf_sel = 4;
|
||||
/* ref clk for phy is input in rmii mode, the clk can be offered by mac layer or external crystal.
|
||||
config pin as output to generate ref clk by esp32 mac layer or input to obtain the clock from external crystal */
|
||||
ext_regs->ex_clk_ctrl.ext_en = 0;
|
||||
ext_regs->ex_clk_ctrl.int_en = 1;
|
||||
ext_regs->ex_oscclk_conf.clk_sel = 0;
|
||||
ext_regs->ex_clkout_conf.div_num = 0;
|
||||
ext_regs->ex_clkout_conf.h_div_num = 0;
|
||||
}
|
||||
|
||||
|
||||
static inline void emac_ll_pause_frame_enable(emac_ext_dev_t *ext_regs, bool enable)
|
||||
{
|
||||
ext_regs->ex_phyinf_conf.sbd_flowctrl = enable;
|
||||
}
|
||||
/*************** End of ext regs operation *********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -25,7 +25,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 {
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -14,8 +14,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include "soc/rmt_struct.h"
|
||||
#include "soc/soc_caps.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -174,6 +174,11 @@ static inline bool rmt_ll_is_tx_loop_enabled(rmt_dev_t *dev, uint32_t channel)
|
||||
return dev->conf_ch[channel].conf1.tx_conti_mode;
|
||||
}
|
||||
|
||||
static inline void rmt_ll_tx_reset_loop(rmt_dev_t *dev, uint32_t channel)
|
||||
{
|
||||
// RMT on esp32 doesn't support loop count, adding this only for HAL API consistency
|
||||
}
|
||||
|
||||
static inline void rmt_ll_rx_enable_filter(rmt_dev_t *dev, uint32_t channel, bool enable)
|
||||
{
|
||||
dev->conf_ch[channel].conf1.rx_filter_en = enable;
|
||||
@ -219,6 +224,15 @@ static inline void rmt_ll_tx_set_limit(rmt_dev_t *dev, uint32_t channel, uint32_
|
||||
dev->tx_lim_ch[channel].limit = limit;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
dev->int_ena.val &= ~(1 << (channel * 3));
|
||||
@ -330,33 +344,17 @@ static inline void rmt_ll_tx_set_carrier_level(rmt_dev_t *dev, uint32_t channel,
|
||||
dev->conf_ch[channel].conf0.carrier_out_lv = level;
|
||||
}
|
||||
|
||||
//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++;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void rmt_ll_config_update(rmt_dev_t *dev, uint32_t channel)
|
||||
{
|
||||
}
|
||||
|
||||
/************************************************************************************************
|
||||
* 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
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "hal/sha_types.h"
|
||||
#include "soc/hwcrypto_reg.h"
|
||||
#include "soc/dport_access.h"
|
||||
#include "hal/misc.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -123,7 +124,7 @@ static inline void sha_ll_fill_text_block(const void *input_text, size_t block_w
|
||||
reg_addr_buf = (uint32_t *)(SHA_TEXT_BASE);
|
||||
data_words = (uint32_t *)input_text;
|
||||
for (size_t i = 0; i < block_word_len; i++) {
|
||||
reg_addr_buf[i] = __builtin_bswap32(data_words[i]);
|
||||
reg_addr_buf[i] = HAL_SWAP32(data_words[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,12 +22,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "hal/hal_defs.h"
|
||||
#include "soc/spi_periph.h"
|
||||
#include "esp32/rom/lldesc.h"
|
||||
#include <string.h>
|
||||
#include <esp_types.h>
|
||||
#include <stdlib.h> //for abs()
|
||||
#include "esp_types.h"
|
||||
#include "esp32/rom/lldesc.h"
|
||||
#include "soc/spi_periph.h"
|
||||
#include "hal/misc.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -38,7 +38,7 @@ extern "C" {
|
||||
/// Interrupt not used. Don't use in app.
|
||||
#define SPI_LL_UNUSED_INT_MASK (SPI_INT_EN | SPI_SLV_WR_STA_DONE | SPI_SLV_RD_STA_DONE | SPI_SLV_WR_BUF_DONE | SPI_SLV_RD_BUF_DONE)
|
||||
/// 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? &SPI1:((ID)==1? &SPI2 : &SPI3))
|
||||
|
@ -22,6 +22,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "hal/assert.h"
|
||||
#include "hal/timer_types.h"
|
||||
#include "soc/timer_periph.h"
|
||||
|
||||
@ -43,7 +44,7 @@ _Static_assert(TIMER_INTR_WDT == TIMG_WDT_INT_CLR, "Add mapping to LL interrupt
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ extern "C" {
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "sdkconfig.h"
|
||||
#include "hal/misc.h"
|
||||
#include "hal/twai_types.h"
|
||||
#include "soc/twai_periph.h"
|
||||
|
||||
@ -574,8 +575,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);
|
||||
@ -647,12 +648,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;
|
||||
}
|
||||
@ -692,14 +693,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;
|
||||
}
|
||||
|
||||
|
@ -923,7 +923,7 @@ FORCE_INLINE_ATTR 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).
|
||||
*
|
||||
|
@ -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.
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2019 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.
|
||||
@ -21,169 +21,11 @@ extern "C" {
|
||||
#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"
|
||||
|
||||
#define EMAC_MEDIA_INTERFACE_MII (0)
|
||||
#define EMAC_MEDIA_INTERFACE_RMII (1)
|
||||
|
||||
#define EMAC_WATCHDOG_ENABLE (0)
|
||||
#define EMAC_WATCHDOG_DISABLE (1)
|
||||
|
||||
#define EMAC_JABBER_ENABLE (0)
|
||||
#define EMAC_JABBER_DISABLE (1)
|
||||
|
||||
#define EMAC_INTERFRAME_GAP_96BIT (0)
|
||||
#define EMAC_INTERFRAME_GAP_88BIT (1)
|
||||
#define EMAC_INTERFRAME_GAP_80BIT (2)
|
||||
#define EMAC_INTERFRAME_GAP_72BIT (3)
|
||||
#define EMAC_INTERFRAME_GAP_64BIT (4)
|
||||
#define EMAC_INTERFRAME_GAP_56BIT (5)
|
||||
#define EMAC_INTERFRAME_GAP_48BIT (6)
|
||||
#define EMAC_INTERFRAME_GAP_40BIT (7)
|
||||
|
||||
#define EMAC_CARRIERSENSE_ENABLE (0)
|
||||
#define EMAC_CARRIERSENSE_DISABLE (1)
|
||||
|
||||
#define EMAC_PORT_1000MBPS (0)
|
||||
#define EMAC_PORT_10_100MBPS (1)
|
||||
|
||||
#define EMAC_SPEED_10M (0)
|
||||
#define EMAC_SPEED_100M (1)
|
||||
|
||||
#define EMAC_RECEIVE_OWN_ENABLE (0)
|
||||
#define EMAC_RECEIVE_OWN_DISABLE (1)
|
||||
|
||||
#define EMAC_LOOPBACK_DISABLE (0)
|
||||
#define EMAC_LOOPBACK_ENABLE (1)
|
||||
|
||||
#define EMAC_DUPLEX_HALF (0)
|
||||
#define EMAC_DUPLEX_FULL (1)
|
||||
|
||||
#define EMAC_CHECKSUM_SW (0)
|
||||
#define EMAC_CHECKSUM_HW (1)
|
||||
|
||||
#define EMAC_RETRY_TRANSMISSION_ENABLE (0)
|
||||
#define EMAC_RETRY_TRANSMISSION_DISABLE (1)
|
||||
|
||||
#define EMAC_AUTO_PAD_CRC_STRIP_DISABLE (0)
|
||||
#define EMAC_AUTO_PAD_CRC_STRIP_ENABLE (1)
|
||||
|
||||
#define EMAC_BACKOFF_LIMIT_10 (0)
|
||||
#define EMAC_BACKOFF_LIMIT_8 (1)
|
||||
#define EMAC_BACKOFF_LIMIT_4 (2)
|
||||
#define EMAC_BACKOFF_LIMIT_1 (3)
|
||||
|
||||
#define EMAC_DEFERRAL_CHECK_DISABLE (0)
|
||||
#define EMAC_DEFERRAL_CHECK_ENABLE (1)
|
||||
|
||||
#define EMAC_PREAMBLE_LENGTH_7 (0)
|
||||
#define EMAC_PREAMBLE_LENGTH_5 (1)
|
||||
#define EMAC_PREAMBLE_LENGTH_3 (2)
|
||||
|
||||
#define EMAC_RECEIVE_ALL_DISABLE (0)
|
||||
#define EMAC_RECEIVE_ALL_ENABLE (1)
|
||||
|
||||
#define EMAC_SOURCE_ADDR_FILTER_DISABLE (0)
|
||||
#define EMAC_SOURCE_ADDR_FILTER_NORMAL (2)
|
||||
#define EMAC_SOURCE_ADDR_FILTER_INVERSE (3)
|
||||
|
||||
#define EMAC_CONTROL_FRAME_BLOCKALL (0)
|
||||
#define EMAC_CONTROL_FRAME_FORWARDALL_PAUSE (1)
|
||||
#define EMAC_CONTROL_FRAME_FORWARDALL (2)
|
||||
#define EMAC_CONTROL_FRAME_FORWARDFILT (3)
|
||||
|
||||
#define EMAC_RECEPT_BROADCAST_ENABLE (0)
|
||||
#define EMAC_RECEPT_BROADCAST_DISABLE (1)
|
||||
|
||||
#define EMAC_DEST_ADDR_FILTER_NORMAL (0)
|
||||
#define EMAC_DEST_ADDR_FILTER_INVERSE (1)
|
||||
|
||||
#define EMAC_PROMISCUOUS_DISABLE (0)
|
||||
#define EMAC_PROMISCUOUS_ENABLE (1)
|
||||
|
||||
#define EMAC_PAUSE_TIME 0x1648
|
||||
|
||||
#define EMAC_ZERO_QUANTA_PAUSE_ENABLE (0)
|
||||
#define EMAC_ZERO_QUANTA_PAUSE_DISABLE (1)
|
||||
|
||||
#define EMAC_PAUSE_LOW_THRESHOLD_MINUS_4 (0)
|
||||
#define EMAC_PAUSE_LOW_THRESHOLD_MINUS_28 (1)
|
||||
#define EMAC_PAUSE_LOW_THRESHOLD_MINUS_144 (2)
|
||||
#define EMAC_PAUSE_LOW_THRESHOLD_MINUS_256
|
||||
|
||||
#define EMAC_UNICAST_PAUSE_DETECT_DISABLE (0)
|
||||
#define EMAC_UNICAST_PAUSE_DETECT_ENABLE (1)
|
||||
|
||||
#define EMAC_RECEIVE_FLOW_CONTROL_DISABLE (0)
|
||||
#define EMAC_RECEIVE_FLOW_CONTROL_ENABLE (1)
|
||||
|
||||
#define EMAC_TRANSMIT_FLOW_CONTROL_DISABLE (0)
|
||||
#define EMAC_TRANSMIT_FLOW_CONTROL_ENABLE (1)
|
||||
|
||||
#define EMAC_DROP_TCPIP_CHECKSUM_ERROR_ENABLE (0)
|
||||
#define EMAC_DROP_TCPIP_CHECKSUM_ERROR_DISABLE (1)
|
||||
|
||||
#define EMAC_RECEIVE_STORE_FORWARD_DISABLE (0)
|
||||
#define EMAC_RECEIVE_STORE_FORWARD_ENABLE (1)
|
||||
|
||||
#define EMAC_FLUSH_RECEIVED_FRAME_ENABLE (0)
|
||||
#define EMAC_FLUSH_RECEIVED_FRAME_DISABLE (1)
|
||||
|
||||
#define EMAC_TRANSMIT_STORE_FORWARD_DISABLE (0)
|
||||
#define EMAC_TRANSMIT_STORE_FORWARD_ENABLE (1)
|
||||
|
||||
#define EMAC_TRANSMIT_THRESHOLD_CONTROL_64 (0)
|
||||
#define EMAC_TRANSMIT_THRESHOLD_CONTROL_128 (1)
|
||||
#define EMAC_TRANSMIT_THRESHOLD_CONTROL_192 (2)
|
||||
#define EMAC_TRANSMIT_THRESHOLD_CONTROL_256 (3)
|
||||
#define EMAC_TRANSMIT_THRESHOLD_CONTROL_40 (4)
|
||||
#define EMAC_TRANSMIT_THRESHOLD_CONTROL_32 (5)
|
||||
#define EMAC_TRANSMIT_THRESHOLD_CONTROL_24 (6)
|
||||
#define EMAC_TRANSMIT_THRESHOLD_CONTROL_16 (7)
|
||||
|
||||
#define EMAC_FORWARD_ERROR_FRAME_DISABLE (0)
|
||||
#define EMAC_FORWARD_ERROR_FRAME_ENABLE (1)
|
||||
|
||||
#define EMAC_FORWARD_UNDERSIZED_GOOD_FRAME_DISABLE (0)
|
||||
#define EMAC_FORWARD_UNDERSIZED_GOOD_FRAME_ENABLE (1)
|
||||
|
||||
#define EMAC_RECEIVE_THRESHOLD_CONTROL_64 (0)
|
||||
#define EMAC_RECEIVE_THRESHOLD_CONTROL_32 (1)
|
||||
#define EMAC_RECEIVE_THRESHOLD_CONTROL_96 (2)
|
||||
#define EMAC_RECEIVE_THRESHOLD_CONTROL_128 (3)
|
||||
|
||||
#define EMAC_OPERATE_SECOND_FRAME_DISABLE (0)
|
||||
#define EMAC_OPERATE_SECOND_FRAME_ENABLE (1)
|
||||
|
||||
#define EMAC_MIXED_BURST_DISABLE (0)
|
||||
#define EMAC_MIXED_BURST_ENABLE (1)
|
||||
|
||||
#define EMAC_ADDR_ALIGN_BEATS_DISABLE (0)
|
||||
#define EMAC_ADDR_ALIGN_BEATS_ENABLE (1)
|
||||
|
||||
#define EMAC_UNUSE_SEPARATE_PBL (0)
|
||||
#define EMAC_USE_SEPARATE_PBL (1)
|
||||
|
||||
#define EMAC_DMA_BURST_LENGTH_1BEAT (1)
|
||||
#define EMAC_DMA_BURST_LENGTH_2BEAT (2)
|
||||
#define EMAC_DMA_BURST_LENGTH_4BEAT (4)
|
||||
#define EMAC_DMA_BURST_LENGTH_8BEAT (8)
|
||||
#define EMAC_DMA_BURST_LENGTH_16BEAT (16)
|
||||
#define EMAC_DMA_BURST_LENGTH_32BEAT (32)
|
||||
|
||||
#define EMAC_ENHANCED_DESCRIPTOR_DISABLE (0)
|
||||
#define EMAC_ENHANCED_DESCRIPTOR_ENABLE (1)
|
||||
|
||||
#define EMAC_DMA_ARBITRATION_SCHEME_ROUNDROBIN (0)
|
||||
#define EMAC_DMA_ARBITRATION_SCHEME_FIXEDPRIO (1)
|
||||
|
||||
#define EMAC_DMA_ARBITRATION_ROUNDROBIN_RXTX_1_1 (0)
|
||||
#define EMAC_DMA_ARBITRATION_ROUNDROBIN_RXTX_2_1 (1)
|
||||
#define EMAC_DMA_ARBITRATION_ROUNDROBIN_RXTX_3_1 (2)
|
||||
#define EMAC_DMA_ARBITRATION_ROUNDROBIN_RXTX_4_1 (3)
|
||||
|
||||
/**
|
||||
* @brief Ethernet DMA TX Descriptor
|
||||
*
|
||||
@ -315,20 +157,6 @@ typedef struct {
|
||||
uint32_t TimeStampLow; /*!< Receive frame timestamp low */
|
||||
uint32_t TimeStampHigh; /*!< Receive frame timestamp high */
|
||||
} eth_dma_rx_descriptor_t;
|
||||
#define EMAC_DMAPTPRXDESC_PTPMT_SYNC 0x00000100U /* SYNC message (all clock types) */
|
||||
#define EMAC_DMAPTPRXDESC_PTPMT_FOLLOWUP 0x00000200U /* FollowUp message (all clock types) */
|
||||
#define EMAC_DMAPTPRXDESC_PTPMT_DELAYREQ 0x00000300U /* DelayReq message (all clock types) */
|
||||
#define EMAC_DMAPTPRXDESC_PTPMT_DELAYRESP 0x00000400U /* DelayResp message (all clock types) */
|
||||
#define EMAC_DMAPTPRXDESC_PTPMT_PDELAYREQ_ANNOUNCE 0x00000500U /* PdelayReq message (peer-to-peer transparent clock) or Announce message (Ordinary or Boundary clock) */
|
||||
#define EMAC_DMAPTPRXDESC_PTPMT_PDELAYRESP_MANAG 0x00000600U /* PdelayResp message (peer-to-peer transparent clock) or Management message (Ordinary or Boundary clock) */
|
||||
#define EMAC_DMAPTPRXDESC_PTPMT_PDELAYRESPFOLLOWUP_SIGNAL 0x00000700U /* PdelayRespFollowUp message (peer-to-peer transparent clock) or Signaling message (Ordinary or Boundary clock) */
|
||||
|
||||
#define EMAC_DMAPTPRXDESC_IPPT_UDP 0x00000001U /* UDP payload encapsulated in the IP datagram */
|
||||
#define EMAC_DMAPTPRXDESC_IPPT_TCP 0x00000002U /* TCP payload encapsulated in the IP datagram */
|
||||
#define EMAC_DMAPTPRXDESC_IPPT_ICMP 0x00000003U /* ICMP payload encapsulated in the IP datagram */
|
||||
|
||||
#define EMAC_DMADESC_OWNER_CPU (0)
|
||||
#define EMAC_DMADESC_OWNER_DMA (1)
|
||||
|
||||
_Static_assert(sizeof(eth_dma_rx_descriptor_t) == 32, "eth_dma_rx_descriptor_t should occupy 32 bytes in memory");
|
||||
|
||||
@ -341,20 +169,31 @@ typedef struct {
|
||||
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_reset_desc_chain(emac_hal_context_t *hal);
|
||||
void emac_hal_iomux_init_mii(void);
|
||||
|
||||
void emac_hal_lowlevel_init(emac_hal_context_t *hal);
|
||||
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);
|
||||
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);
|
||||
|
||||
@ -362,7 +201,7 @@ 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, uint32_t duplex);
|
||||
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);
|
||||
|
||||
@ -393,17 +232,13 @@ uint32_t emac_hal_receive_frame(emac_hal_context_t *hal, uint8_t *buf, uint32_t
|
||||
|
||||
void emac_hal_enable_flow_ctrl(emac_hal_context_t *hal, bool enable);
|
||||
|
||||
void emac_hal_isr(void *arg);
|
||||
uint32_t emac_hal_get_intr_enable_status(emac_hal_context_t *hal);
|
||||
|
||||
void emac_hal_tx_complete_cb(void *arg);
|
||||
uint32_t emac_hal_get_intr_status(emac_hal_context_t *hal);
|
||||
|
||||
void emac_hal_tx_unavail_cb (void *arg);
|
||||
void emac_hal_clear_corresponding_intr(emac_hal_context_t *hal, uint32_t bits);
|
||||
|
||||
void emac_hal_rx_complete_cb (void *arg);
|
||||
|
||||
void emac_hal_rx_early_cb(void *arg);
|
||||
|
||||
void emac_hal_rx_unavail_cb(void *arg);
|
||||
void emac_hal_clear_all_intr(emac_hal_context_t *hal);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
65
tools/sdk/esp32/include/hal/include/hal/eth_types.h
Normal file
65
tools/sdk/esp32/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")
|
18
tools/sdk/esp32/include/hal/platform_port/include/hal/misc.h
Normal file
18
tools/sdk/esp32/include/hal/platform_port/include/hal/misc.h
Normal file
@ -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