forked from espressif/arduino-esp32
IDF master 3e370c4296
* Fix build compilation due to changes in the HW_TIMER's structs * Fix compilation warnings and errors with USB * Update USBCDC.cpp * Update CMakeLists.txt * Update HWCDC.cpp
This commit is contained in:
@ -3,7 +3,11 @@
|
||||
#include "soc/adc_periph.h"
|
||||
#include "hal/adc_types.h"
|
||||
#include "soc/rtc_io_struct.h"
|
||||
#include "soc/sens_struct.h"
|
||||
#include "soc/syscon_struct.h"
|
||||
#include "soc/rtc_cntl_struct.h"
|
||||
#include <stdbool.h>
|
||||
#include "hal/misc.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -52,11 +56,11 @@ typedef enum {
|
||||
static inline void adc_ll_digi_set_fsm_time(uint32_t rst_wait, uint32_t start_wait, uint32_t standby_wait)
|
||||
{
|
||||
// Internal FSM reset wait time
|
||||
SYSCON.saradc_fsm.rstb_wait = rst_wait;
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(SYSCON.saradc_fsm, rstb_wait, rst_wait);
|
||||
// Internal FSM start wait time
|
||||
SYSCON.saradc_fsm.start_wait = start_wait;
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(SYSCON.saradc_fsm, start_wait, start_wait);
|
||||
// Internal FSM standby wait time
|
||||
SYSCON.saradc_fsm.standby_wait = standby_wait;
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(SYSCON.saradc_fsm, standby_wait, standby_wait);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -67,7 +71,7 @@ static inline void adc_ll_digi_set_fsm_time(uint32_t rst_wait, uint32_t start_wa
|
||||
*/
|
||||
static inline void adc_ll_set_sample_cycle(uint32_t sample_cycle)
|
||||
{
|
||||
SYSCON.saradc_fsm.sample_cycle = sample_cycle;
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(SYSCON.saradc_fsm, sample_cycle, sample_cycle);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -78,7 +82,7 @@ static inline void adc_ll_set_sample_cycle(uint32_t sample_cycle)
|
||||
static inline void adc_ll_digi_set_clk_div(uint32_t div)
|
||||
{
|
||||
/* ADC clock divided from APB clk, e.g. 80 / 2 = 40Mhz, */
|
||||
SYSCON.saradc_ctrl.sar_clk_div = div;
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(SYSCON.saradc_ctrl, sar_clk_div, div);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -99,7 +103,7 @@ static inline void adc_ll_digi_set_output_format(adc_digi_output_format_t format
|
||||
*/
|
||||
static inline void adc_ll_digi_set_convert_limit_num(uint32_t meas_num)
|
||||
{
|
||||
SYSCON.saradc_ctrl2.max_meas_num = meas_num;
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(SYSCON.saradc_ctrl2, max_meas_num, meas_num);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -320,7 +324,7 @@ static inline void adc_ll_rtc_disable_channel(adc_ll_num_t adc_n)
|
||||
static inline void adc_ll_rtc_start_convert(adc_ll_num_t adc_n, int channel)
|
||||
{
|
||||
if (adc_n == ADC_NUM_1) {
|
||||
while (SENS.sar_slave_addr1.meas_status != 0);
|
||||
while (HAL_FORCE_READ_U32_REG_FIELD(SENS.sar_slave_addr1, meas_status) != 0) {}
|
||||
SENS.sar_meas_start1.meas1_start_sar = 0;
|
||||
SENS.sar_meas_start1.meas1_start_sar = 1;
|
||||
} else { // adc_n == ADC_NUM_2
|
||||
@ -359,9 +363,9 @@ static inline int adc_ll_rtc_get_convert_value(adc_ll_num_t adc_n)
|
||||
{
|
||||
int ret_val = 0;
|
||||
if (adc_n == ADC_NUM_1) {
|
||||
ret_val = SENS.sar_meas_start1.meas1_data_sar;
|
||||
ret_val = HAL_FORCE_READ_U32_REG_FIELD(SENS.sar_meas_start1, meas1_data_sar);
|
||||
} else { // adc_n == ADC_NUM_2
|
||||
ret_val = SENS.sar_meas_start2.meas2_data_sar;
|
||||
ret_val = HAL_FORCE_READ_U32_REG_FIELD(SENS.sar_meas_start2, meas2_data_sar);
|
||||
}
|
||||
return ret_val;
|
||||
}
|
||||
@ -444,9 +448,9 @@ static inline adc_ll_power_t adc_ll_get_power_manage(void)
|
||||
static inline void adc_ll_set_sar_clk_div(adc_ll_num_t adc_n, uint32_t div)
|
||||
{
|
||||
if (adc_n == ADC_NUM_1) {
|
||||
SENS.sar_read_ctrl.sar1_clk_div = div;
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(SENS.sar_read_ctrl, sar1_clk_div, div);
|
||||
} else { // adc_n == ADC_NUM_2
|
||||
SENS.sar_read_ctrl2.sar2_clk_div = div;
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(SENS.sar_read_ctrl2, sar2_clk_div, div);
|
||||
}
|
||||
}
|
||||
|
||||
@ -563,9 +567,9 @@ static inline void adc_ll_amp_disable(void)
|
||||
SENS.sar_meas_ctrl.amp_rst_fb_fsm = 0;
|
||||
SENS.sar_meas_ctrl.amp_short_ref_fsm = 0;
|
||||
SENS.sar_meas_ctrl.amp_short_ref_gnd_fsm = 0;
|
||||
SENS.sar_meas_wait1.sar_amp_wait1 = 1;
|
||||
SENS.sar_meas_wait1.sar_amp_wait2 = 1;
|
||||
SENS.sar_meas_wait2.sar_amp_wait3 = 1;
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(SENS.sar_meas_wait1, sar_amp_wait1, 1);
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(SENS.sar_meas_wait1, sar_amp_wait2, 1);
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(SENS.sar_meas_wait2, sar_amp_wait3, 1);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2020 Espressif Systems (Shanghai) PTE LTD
|
||||
// Copyright 2020-2021 Espressif Systems (Shanghai) CO LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
@ -17,6 +17,7 @@
|
||||
#include "soc/hwcrypto_reg.h"
|
||||
#include "soc/dport_access.h"
|
||||
#include "hal/aes_types.h"
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -46,10 +47,13 @@ static inline uint8_t aes_ll_write_key(const uint8_t *key, size_t key_word_len)
|
||||
{
|
||||
/* This variable is used for fault injection checks, so marked volatile to avoid optimisation */
|
||||
volatile uint8_t key_bytes_in_hardware = 0;
|
||||
uint32_t *key_words = (uint32_t *)key;
|
||||
|
||||
/* Memcpy to avoid potential unaligned access */
|
||||
uint32_t key_word;
|
||||
|
||||
for (int i = 0; i < key_word_len; i++) {
|
||||
DPORT_REG_WRITE(AES_KEY_BASE + i * 4, *(key_words + i));
|
||||
memcpy(&key_word, key + 4 * i, 4);
|
||||
DPORT_REG_WRITE(AES_KEY_BASE + i * 4, key_word);
|
||||
key_bytes_in_hardware += 4;
|
||||
}
|
||||
return key_bytes_in_hardware;
|
||||
|
@ -21,7 +21,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "hal/misc.h"
|
||||
#include "soc/dac_periph.h"
|
||||
#include "soc/rtc_io_struct.h"
|
||||
#include "soc/sens_struct.h"
|
||||
#include "hal/dac_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -62,10 +65,10 @@ static inline void dac_ll_update_output_value(dac_channel_t channel, uint8_t val
|
||||
{
|
||||
if (channel == DAC_CHANNEL_1) {
|
||||
SENS.sar_dac_ctrl2.dac_cw_en1 = 0;
|
||||
RTCIO.pad_dac[channel].dac = value;
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(RTCIO.pad_dac[channel], dac, value);
|
||||
} else if (channel == DAC_CHANNEL_2) {
|
||||
SENS.sar_dac_ctrl2.dac_cw_en2 = 0;
|
||||
RTCIO.pad_dac[channel].dac = value;
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(RTCIO.pad_dac[channel], dac, value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -124,7 +127,7 @@ static inline void dac_ll_cw_set_channel(dac_channel_t channel, bool enable)
|
||||
static inline void dac_ll_cw_set_freq(uint32_t freq)
|
||||
{
|
||||
uint32_t sw_freq = freq * 0xFFFF / RTC_FAST_CLK_FREQ_APPROX;
|
||||
SENS.sar_dac_ctrl1.sw_fstep = (sw_freq > 0xFFFF) ? 0xFFFF : sw_freq;
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(SENS.sar_dac_ctrl1, sw_fstep, (sw_freq > 0xFFFF) ? 0xFFFF : sw_freq);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -171,12 +174,12 @@ static inline void dac_ll_cw_set_dc_offset(dac_channel_t channel, int8_t offset)
|
||||
if (SENS.sar_dac_ctrl2.dac_inv1 == DAC_CW_PHASE_180) {
|
||||
offset = 0 - offset;
|
||||
}
|
||||
SENS.sar_dac_ctrl2.dac_dc1 = offset ? offset : (-128 - offset);
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(SENS.sar_dac_ctrl2, dac_dc1, offset ? offset : (-128 - offset));
|
||||
} else if (channel == DAC_CHANNEL_2) {
|
||||
if (SENS.sar_dac_ctrl2.dac_inv2 == DAC_CW_PHASE_180) {
|
||||
offset = 0 - offset;
|
||||
}
|
||||
SENS.sar_dac_ctrl2.dac_dc2 = offset ? offset : (-128 - offset);
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(SENS.sar_dac_ctrl2, dac_dc2, offset ? offset : (-128 - offset));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "hal/misc.h"
|
||||
#include "hal/eth_types.h"
|
||||
#include "soc/emac_dma_struct.h"
|
||||
#include "soc/emac_mac_struct.h"
|
||||
@ -136,7 +137,7 @@ extern "C" {
|
||||
#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_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
|
||||
@ -310,7 +311,7 @@ static inline void emac_ll_promiscuous_mode_enable(emac_mac_dev_t *mac_regs, boo
|
||||
/* gmacfc */
|
||||
static inline void emac_ll_set_pause_time(emac_mac_dev_t *mac_regs, uint32_t time)
|
||||
{
|
||||
mac_regs->gmacfc.pause_time = time;
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(mac_regs->gmacfc, pause_time, time);
|
||||
}
|
||||
|
||||
static inline void emac_ll_zero_quanta_pause_enable(emac_mac_dev_t *mac_regs, bool enable)
|
||||
@ -346,18 +347,18 @@ static inline void emac_ll_clear(emac_mac_dev_t *mac_regs)
|
||||
/* emacmiidata */
|
||||
static inline void emac_ll_set_phy_data(emac_mac_dev_t *mac_regs, uint32_t data)
|
||||
{
|
||||
mac_regs->emacmiidata.mii_data = data;
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(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;
|
||||
return HAL_FORCE_READ_U32_REG_FIELD(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];
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(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 *********************/
|
||||
@ -405,7 +406,7 @@ static inline void emac_ll_flush_recv_frame_enable(emac_dma_dev_t *dma_regs, boo
|
||||
|
||||
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;
|
||||
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)
|
||||
|
@ -25,9 +25,11 @@
|
||||
#include <stdbool.h>
|
||||
#include "soc/soc.h"
|
||||
#include "soc/gpio_periph.h"
|
||||
#include "soc/gpio_struct.h"
|
||||
#include "soc/rtc_cntl_reg.h"
|
||||
#include "soc/rtc_io_reg.h"
|
||||
#include "hal/gpio_types.h"
|
||||
#include "hal/misc.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -245,7 +247,7 @@ static inline void gpio_ll_get_intr_status(gpio_dev_t *hw, uint32_t core_id, uin
|
||||
*/
|
||||
static inline void gpio_ll_get_intr_status_high(gpio_dev_t *hw, uint32_t core_id, uint32_t *status)
|
||||
{
|
||||
*status = (core_id == 0) ? hw->pcpu_int1.intr : hw->acpu_int1.intr;
|
||||
*status = (core_id == 0) ? HAL_FORCE_READ_U32_REG_FIELD(hw->pcpu_int1, intr) : HAL_FORCE_READ_U32_REG_FIELD(hw->pcpu_int1, intr);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -267,7 +269,7 @@ static inline void gpio_ll_clear_intr_status(gpio_dev_t *hw, uint32_t mask)
|
||||
*/
|
||||
static inline void gpio_ll_clear_intr_status_high(gpio_dev_t *hw, uint32_t mask)
|
||||
{
|
||||
hw->status1_w1tc.intr_st = mask;
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(hw->status1_w1tc, intr_st, mask);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -330,7 +332,7 @@ static inline void gpio_ll_output_disable(gpio_dev_t *hw, gpio_num_t gpio_num)
|
||||
if (gpio_num < 32) {
|
||||
hw->enable_w1tc = (0x1 << gpio_num);
|
||||
} else {
|
||||
hw->enable1_w1tc.data = (0x1 << (gpio_num - 32));
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(hw->enable1_w1tc, data, (0x1 << (gpio_num - 32)));
|
||||
}
|
||||
|
||||
// Ensure no other output signal is routed via GPIO matrix to this pin
|
||||
@ -349,7 +351,7 @@ static inline void gpio_ll_output_enable(gpio_dev_t *hw, gpio_num_t gpio_num)
|
||||
if (gpio_num < 32) {
|
||||
hw->enable_w1ts = (0x1 << gpio_num);
|
||||
} else {
|
||||
hw->enable1_w1ts.data = (0x1 << (gpio_num - 32));
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(hw->enable1_w1ts, data, (0x1 << (gpio_num - 32)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -432,13 +434,13 @@ static inline void gpio_ll_set_level(gpio_dev_t *hw, gpio_num_t gpio_num, uint32
|
||||
if (gpio_num < 32) {
|
||||
hw->out_w1ts = (1 << gpio_num);
|
||||
} else {
|
||||
hw->out1_w1ts.data = (1 << (gpio_num - 32));
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(hw->out1_w1ts, data, (1 << (gpio_num - 32)));
|
||||
}
|
||||
} else {
|
||||
if (gpio_num < 32) {
|
||||
hw->out_w1tc = (1 << gpio_num);
|
||||
} else {
|
||||
hw->out1_w1tc.data = (1 << (gpio_num - 32));
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(hw->out1_w1tc, data, (1 << (gpio_num - 32)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -460,7 +462,7 @@ static inline int gpio_ll_get_level(gpio_dev_t *hw, gpio_num_t gpio_num)
|
||||
if (gpio_num < 32) {
|
||||
return (hw->in >> gpio_num) & 0x1;
|
||||
} else {
|
||||
return (hw->in1.data >> (gpio_num - 32)) & 0x1;
|
||||
return (HAL_FORCE_READ_U32_REG_FIELD(hw->in1, data) >> (gpio_num - 32)) & 0x1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,10 @@
|
||||
// The LL layer for I2C register operations
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "hal/misc.h"
|
||||
#include "soc/i2c_periph.h"
|
||||
#include "soc/i2c_struct.h"
|
||||
#include "hal/i2c_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -558,7 +561,7 @@ static inline void i2c_ll_write_txfifo(i2c_dev_t *hw, uint8_t *ptr, uint8_t len)
|
||||
static inline void i2c_ll_read_rxfifo(i2c_dev_t *hw, uint8_t *ptr, uint8_t len)
|
||||
{
|
||||
for(int i = 0; i < len; i++) {
|
||||
ptr[i] = hw->fifo_data.data;
|
||||
ptr[i] = HAL_FORCE_READ_U32_REG_FIELD(hw->fifo_data, data);
|
||||
}
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -19,6 +19,7 @@
|
||||
|
||||
#include "hal/ledc_types.h"
|
||||
#include "soc/ledc_periph.h"
|
||||
#include "soc/ledc_struct.h"
|
||||
|
||||
#define LEDC_LL_GET_HW() &LEDC
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -23,7 +23,9 @@ extern "C" {
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "hal/misc.h"
|
||||
#include "soc/timer_periph.h"
|
||||
#include "soc/timer_group_struct.h"
|
||||
#include "hal/wdt_types.h"
|
||||
#include "esp_attr.h"
|
||||
|
||||
@ -201,7 +203,7 @@ FORCE_INLINE_ATTR void mwdt_ll_set_flashboot_en(timg_dev_t* hw, bool enable)
|
||||
*/
|
||||
FORCE_INLINE_ATTR void mwdt_ll_set_prescaler(timg_dev_t *hw, uint32_t prescaler)
|
||||
{
|
||||
hw->wdt_config1.clk_prescale = prescaler;
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(hw->wdt_config1, clk_prescale, prescaler);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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.
|
||||
@ -22,75 +22,67 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "soc/pcnt_periph.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include "soc/pcnt_struct.h"
|
||||
#include "hal/pcnt_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Get PCNT hardware instance with giving pcnt num
|
||||
#define PCNT_LL_GET_HW(num) (((num) == 0) ? (&PCNT) : NULL)
|
||||
#define PCNT_LL_MAX_GLITCH_WIDTH 1023
|
||||
|
||||
typedef enum {
|
||||
PCNT_LL_EVENT_THRES1,
|
||||
PCNT_LL_EVENT_THRES0,
|
||||
PCNT_LL_EVENT_LOW_LIMIT,
|
||||
PCNT_LL_EVENT_HIGH_LIMIT,
|
||||
PCNT_LL_EVENT_ZERO_CROSS,
|
||||
PCNT_LL_EVENT_MAX
|
||||
} pcnt_ll_event_id_t;
|
||||
|
||||
#define PCNT_LL_EVENT_MASK ((1 << PCNT_LL_EVENT_MAX) - 1)
|
||||
|
||||
/**
|
||||
* @brief Set PCNT channel edge mode
|
||||
* @brief Set PCNT channel edge action
|
||||
*
|
||||
* @param hw Peripheral PCNT hardware instance address.
|
||||
* @param unit PCNT unit number
|
||||
* @param channel PCNT channel number
|
||||
* @param pos_mode Counter mode when detecting positive edge
|
||||
* @param neg_mode Counter mode when detecting negative edge
|
||||
* @param pos_act Counter action when detecting positive edge
|
||||
* @param neg_act Counter action when detecting negative edge
|
||||
*/
|
||||
static inline void pcnt_ll_set_edge_mode(pcnt_dev_t *hw, pcnt_unit_t unit, pcnt_channel_t channel, pcnt_count_mode_t pos_mode, pcnt_count_mode_t neg_mode)
|
||||
static inline void pcnt_ll_set_edge_action(pcnt_dev_t *hw, uint32_t unit, uint32_t channel, pcnt_channel_edge_action_t pos_act, pcnt_channel_edge_action_t neg_act)
|
||||
{
|
||||
typeof(hw->conf_unit[unit].conf0) conf0_reg = hw->conf_unit[unit].conf0;
|
||||
if (channel == 0) {
|
||||
conf0_reg.ch0_pos_mode = pos_mode;
|
||||
conf0_reg.ch0_neg_mode = neg_mode;
|
||||
hw->conf_unit[unit].conf0.ch0_pos_mode = pos_act;
|
||||
hw->conf_unit[unit].conf0.ch0_neg_mode = neg_act;
|
||||
} else {
|
||||
conf0_reg.ch1_pos_mode = pos_mode;
|
||||
conf0_reg.ch1_neg_mode = neg_mode;
|
||||
hw->conf_unit[unit].conf0.ch1_pos_mode = pos_act;
|
||||
hw->conf_unit[unit].conf0.ch1_neg_mode = neg_act;
|
||||
}
|
||||
hw->conf_unit[unit].conf0 = conf0_reg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set PCNT channel level mode
|
||||
* @brief Set PCNT channel level action
|
||||
*
|
||||
* @param hw Peripheral PCNT hardware instance address.
|
||||
* @param unit PCNT unit number
|
||||
* @param channel PCNT channel number
|
||||
* @param hctrl_mode Counter mode when control signal is high level
|
||||
* @param lctrl_mode Counter mode when control signal is low level
|
||||
* @param high_act Counter action when control signal is high level
|
||||
* @param low_act Counter action when control signal is low level
|
||||
*/
|
||||
static inline void pcnt_ll_set_level_mode(pcnt_dev_t *hw, pcnt_unit_t unit, pcnt_channel_t channel, pcnt_ctrl_mode_t hctrl_mode, pcnt_ctrl_mode_t lctrl_mode)
|
||||
static inline void pcnt_ll_set_level_action(pcnt_dev_t *hw, uint32_t unit, uint32_t channel, pcnt_channel_level_action_t high_act, pcnt_channel_level_action_t low_act)
|
||||
{
|
||||
typeof(hw->conf_unit[unit].conf0) conf0_reg = hw->conf_unit[unit].conf0;
|
||||
if (channel == 0) {
|
||||
conf0_reg.ch0_hctrl_mode = hctrl_mode;
|
||||
conf0_reg.ch0_lctrl_mode = lctrl_mode;
|
||||
hw->conf_unit[unit].conf0.ch0_hctrl_mode = high_act;
|
||||
hw->conf_unit[unit].conf0.ch0_lctrl_mode = low_act;
|
||||
} else {
|
||||
conf0_reg.ch1_hctrl_mode = hctrl_mode;
|
||||
conf0_reg.ch1_lctrl_mode = lctrl_mode;
|
||||
hw->conf_unit[unit].conf0.ch1_hctrl_mode = high_act;
|
||||
hw->conf_unit[unit].conf0.ch1_lctrl_mode = low_act;
|
||||
}
|
||||
hw->conf_unit[unit].conf0 = conf0_reg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set PCNT counter mode
|
||||
*
|
||||
* @param hw Peripheral PCNT hardware instance address.
|
||||
* @param unit PCNT unit number
|
||||
* @param channel PCNT channel number
|
||||
* @param pos_mode Counter mode when detecting positive edge
|
||||
* @param neg_mode Counter mode when detecting negative edge
|
||||
* @param hctrl_mode Counter mode when control signal is high level
|
||||
* @param lctrl_mode Counter mode when control signal is low level
|
||||
*/
|
||||
static inline void pcnt_ll_set_mode(pcnt_dev_t *hw, pcnt_unit_t unit, pcnt_channel_t channel, pcnt_count_mode_t pos_mode, pcnt_count_mode_t neg_mode, pcnt_ctrl_mode_t hctrl_mode, pcnt_ctrl_mode_t lctrl_mode)
|
||||
{
|
||||
pcnt_ll_set_edge_mode(hw, unit, channel, pos_mode, neg_mode);
|
||||
pcnt_ll_set_level_mode(hw, unit, channel, hctrl_mode, lctrl_mode);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -98,11 +90,13 @@ static inline void pcnt_ll_set_mode(pcnt_dev_t *hw, pcnt_unit_t unit, pcnt_chann
|
||||
*
|
||||
* @param hw Peripheral PCNT hardware instance address.
|
||||
* @param unit Pulse Counter unit number
|
||||
* @param count Pointer to accept counter value
|
||||
* @return PCNT count value (a signed integer)
|
||||
*/
|
||||
static inline void pcnt_ll_get_counter_value(pcnt_dev_t *hw, pcnt_unit_t unit, int16_t *count)
|
||||
static inline int pcnt_ll_get_count(pcnt_dev_t *hw, uint32_t unit)
|
||||
{
|
||||
*count = (int16_t) hw->cnt_unit[unit].cnt_val;
|
||||
typeof(hw->cnt_unit[unit]) cnt_reg = hw->cnt_unit[unit];
|
||||
int16_t value = cnt_reg.cnt_val;
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -111,69 +105,60 @@ static inline void pcnt_ll_get_counter_value(pcnt_dev_t *hw, pcnt_unit_t unit, i
|
||||
* @param hw Peripheral PCNT hardware instance address.
|
||||
* @param unit PCNT unit number
|
||||
*/
|
||||
static inline void pcnt_ll_counter_pause(pcnt_dev_t *hw, pcnt_unit_t unit)
|
||||
static inline void pcnt_ll_stop_count(pcnt_dev_t *hw, uint32_t unit)
|
||||
{
|
||||
hw->ctrl.val |= BIT(PCNT_CNT_PAUSE_U0_S + (unit * 2));
|
||||
hw->ctrl.val |= 1 << (2 * unit + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Resume counting for PCNT counter
|
||||
*
|
||||
* @param hw Peripheral PCNT hardware instance address.
|
||||
* @param unit PCNT unit number, select from pcnt_unit_t
|
||||
* @param unit PCNT unit number, select from uint32_t
|
||||
*/
|
||||
static inline void pcnt_ll_counter_resume(pcnt_dev_t *hw, pcnt_unit_t unit)
|
||||
static inline void pcnt_ll_start_count(pcnt_dev_t *hw, uint32_t unit)
|
||||
{
|
||||
hw->ctrl.val &= (~(BIT(PCNT_CNT_PAUSE_U0_S + (unit * 2))));
|
||||
hw->ctrl.val &= ~(1 << (2 * unit + 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear and reset PCNT counter value to zero
|
||||
* @brief Clear PCNT counter value to zero
|
||||
*
|
||||
* @param hw Peripheral PCNT hardware instance address.
|
||||
* @param unit PCNT unit number, select from pcnt_unit_t
|
||||
* @param unit PCNT unit number, select from uint32_t
|
||||
*/
|
||||
static inline void pcnt_ll_counter_clear(pcnt_dev_t *hw, pcnt_unit_t unit)
|
||||
static inline void pcnt_ll_clear_count(pcnt_dev_t *hw, uint32_t unit)
|
||||
{
|
||||
uint32_t reset_bit = BIT(PCNT_PLUS_CNT_RST_U0_S + (unit * 2));
|
||||
hw->ctrl.val |= reset_bit;
|
||||
hw->ctrl.val &= ~reset_bit;
|
||||
hw->ctrl.val |= 1 << (2 * unit);
|
||||
hw->ctrl.val &= ~(1 << (2 * unit));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable PCNT interrupt for PCNT unit
|
||||
* @note
|
||||
* Each Pulse counter unit has five watch point events that share the same interrupt.
|
||||
* Configure events with pcnt_event_enable() and pcnt_event_disable()
|
||||
* @note Each PCNT unit has five watch point events that share the same interrupt bit.
|
||||
*
|
||||
* @param hw Peripheral PCNT hardware instance address.
|
||||
* @param unit PCNT unit number
|
||||
* @param unit_mask PCNT units mask
|
||||
* @param enable True to enable interrupt, False to disable interrupt
|
||||
*/
|
||||
static inline void pcnt_ll_intr_enable(pcnt_dev_t *hw, pcnt_unit_t unit)
|
||||
static inline void pcnt_ll_enable_intr(pcnt_dev_t *hw, uint32_t unit_mask, bool enable)
|
||||
{
|
||||
hw->int_ena.val |= BIT(PCNT_CNT_THR_EVENT_U0_INT_ENA_S + unit);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable PCNT interrupt for PCNT unit
|
||||
*
|
||||
* @param hw Peripheral PCNT hardware instance address.
|
||||
* @param unit PCNT unit number
|
||||
*/
|
||||
static inline void pcnt_ll_intr_disable(pcnt_dev_t *hw, pcnt_unit_t unit)
|
||||
{
|
||||
hw->int_ena.val &= (~(BIT(PCNT_CNT_THR_EVENT_U0_INT_ENA_S + unit)));
|
||||
if (enable) {
|
||||
hw->int_ena.val |= unit_mask;
|
||||
} else {
|
||||
hw->int_ena.val &= ~unit_mask;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get PCNT interrupt status
|
||||
*
|
||||
* @param hw Peripheral PCNT hardware instance address.
|
||||
* @param status Pointer to accept value
|
||||
* @return Interrupt status word
|
||||
*/
|
||||
static inline void pcnt_ll_get_intr_status(pcnt_dev_t *hw, uint32_t *status)
|
||||
__attribute__((always_inline)) static inline uint32_t pcnt_ll_get_intr_status(pcnt_dev_t *hw)
|
||||
{
|
||||
*status = hw->int_st.val;
|
||||
return hw->int_st.val;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -182,163 +167,241 @@ static inline void pcnt_ll_get_intr_status(pcnt_dev_t *hw, uint32_t *status)
|
||||
* @param hw Peripheral PCNT hardware instance address.
|
||||
* @param status value to clear interrupt status
|
||||
*/
|
||||
static inline void pcnt_ll_clear_intr_status(pcnt_dev_t *hw, uint32_t status)
|
||||
__attribute__((always_inline)) static inline void pcnt_ll_clear_intr_status(pcnt_dev_t *hw, uint32_t status)
|
||||
{
|
||||
hw->int_clr.val = status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable PCNT event of PCNT unit
|
||||
* @brief Enable PCNT high limit event
|
||||
*
|
||||
* @param hw Peripheral PCNT hardware instance address.
|
||||
* @param unit PCNT unit number
|
||||
* @param evt_type Watch point event type.
|
||||
* All enabled events share the same interrupt (one interrupt per pulse counter unit).
|
||||
* @param enable true to enable, false to disable
|
||||
*/
|
||||
static inline void pcnt_ll_event_enable(pcnt_dev_t *hw, pcnt_unit_t unit, pcnt_evt_type_t evt_type)
|
||||
static inline void pcnt_ll_enable_high_limit_event(pcnt_dev_t *hw, uint32_t unit, bool enable)
|
||||
{
|
||||
if (evt_type == PCNT_EVT_L_LIM) {
|
||||
hw->conf_unit[unit].conf0.thr_l_lim_en = 1;
|
||||
} else if (evt_type == PCNT_EVT_H_LIM) {
|
||||
hw->conf_unit[unit].conf0.thr_h_lim_en = 1;
|
||||
} else if (evt_type == PCNT_EVT_THRES_0) {
|
||||
hw->conf_unit[unit].conf0.thr_thres0_en = 1;
|
||||
} else if (evt_type == PCNT_EVT_THRES_1) {
|
||||
hw->conf_unit[unit].conf0.thr_thres1_en = 1;
|
||||
} else if (evt_type == PCNT_EVT_ZERO) {
|
||||
hw->conf_unit[unit].conf0.thr_zero_en = 1;
|
||||
}
|
||||
hw->conf_unit[unit].conf0.thr_h_lim_en = enable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable PCNT event of PCNT unit
|
||||
* @brief Enable PCNT low limit event
|
||||
*
|
||||
* @param hw Peripheral PCNT hardware instance address.
|
||||
* @param unit PCNT unit number
|
||||
* @param evt_type Watch point event type.
|
||||
* All enabled events share the same interrupt (one interrupt per pulse counter unit).
|
||||
* @param enable true to enable, false to disable
|
||||
*/
|
||||
static inline void pcnt_ll_event_disable(pcnt_dev_t *hw, pcnt_unit_t unit, pcnt_evt_type_t evt_type)
|
||||
static inline void pcnt_ll_enable_low_limit_event(pcnt_dev_t *hw, uint32_t unit, bool enable)
|
||||
{
|
||||
if (evt_type == PCNT_EVT_L_LIM) {
|
||||
hw->conf_unit[unit].conf0.thr_l_lim_en = 0;
|
||||
} else if (evt_type == PCNT_EVT_H_LIM) {
|
||||
hw->conf_unit[unit].conf0.thr_h_lim_en = 0;
|
||||
} else if (evt_type == PCNT_EVT_THRES_0) {
|
||||
hw->conf_unit[unit].conf0.thr_thres0_en = 0;
|
||||
} else if (evt_type == PCNT_EVT_THRES_1) {
|
||||
hw->conf_unit[unit].conf0.thr_thres1_en = 0;
|
||||
} else if (evt_type == PCNT_EVT_ZERO) {
|
||||
hw->conf_unit[unit].conf0.thr_zero_en = 0;
|
||||
}
|
||||
hw->conf_unit[unit].conf0.thr_l_lim_en = enable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set PCNT event value of PCNT unit
|
||||
* @brief Enable PCNT zero cross event
|
||||
*
|
||||
* @param hw Peripheral PCNT hardware instance address.
|
||||
* @param unit PCNT unit number
|
||||
* @param evt_type Watch point event type.
|
||||
* All enabled events share the same interrupt (one interrupt per pulse counter unit).
|
||||
*
|
||||
* @param value Counter value for PCNT event
|
||||
* @param enable true to enable, false to disable
|
||||
*/
|
||||
static inline void pcnt_ll_set_event_value(pcnt_dev_t *hw, pcnt_unit_t unit, pcnt_evt_type_t evt_type, int16_t value)
|
||||
static inline void pcnt_ll_enable_zero_cross_event(pcnt_dev_t *hw, uint32_t unit, bool enable)
|
||||
{
|
||||
if (evt_type == PCNT_EVT_L_LIM) {
|
||||
hw->conf_unit[unit].conf2.cnt_l_lim = value;
|
||||
} else if (evt_type == PCNT_EVT_H_LIM) {
|
||||
hw->conf_unit[unit].conf2.cnt_h_lim = value;
|
||||
} else if (evt_type == PCNT_EVT_THRES_0) {
|
||||
hw->conf_unit[unit].conf1.cnt_thres0 = value;
|
||||
} else if (evt_type == PCNT_EVT_THRES_1) {
|
||||
hw->conf_unit[unit].conf1.cnt_thres1 = value;
|
||||
}
|
||||
hw->conf_unit[unit].conf0.thr_zero_en = enable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get PCNT event value of PCNT unit
|
||||
* @brief Enable PCNT threshold event
|
||||
*
|
||||
* @param hw Peripheral PCNT hardware instance address.
|
||||
* @param unit PCNT unit number
|
||||
* @param evt_type Watch point event type.
|
||||
* All enabled events share the same interrupt (one interrupt per pulse counter unit).
|
||||
* @param value Pointer to accept counter value for PCNT event
|
||||
* @param thres Threshold ID
|
||||
* @param enable true to enable, false to disable
|
||||
*/
|
||||
static inline void pcnt_ll_get_event_value(pcnt_dev_t *hw, pcnt_unit_t unit, pcnt_evt_type_t evt_type, int16_t *value)
|
||||
static inline void pcnt_ll_enable_thres_event(pcnt_dev_t *hw, uint32_t unit, uint32_t thres, bool enable)
|
||||
{
|
||||
if (evt_type == PCNT_EVT_L_LIM) {
|
||||
*value = (int16_t) hw->conf_unit[unit].conf2.cnt_l_lim;
|
||||
} else if (evt_type == PCNT_EVT_H_LIM) {
|
||||
*value = (int16_t) hw->conf_unit[unit].conf2.cnt_h_lim;
|
||||
} else if (evt_type == PCNT_EVT_THRES_0) {
|
||||
*value = (int16_t) hw->conf_unit[unit].conf1.cnt_thres0;
|
||||
} else if (evt_type == PCNT_EVT_THRES_1) {
|
||||
*value = (int16_t) hw->conf_unit[unit].conf1.cnt_thres1;
|
||||
if (thres == 0) {
|
||||
hw->conf_unit[unit].conf0.thr_thres0_en = enable;
|
||||
} else {
|
||||
*value = 0;
|
||||
hw->conf_unit[unit].conf0.thr_thres1_en = enable;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable all PCNT threshold events
|
||||
*
|
||||
* @param hw Peripheral PCNT hardware instance address.
|
||||
* @param unit unit number
|
||||
*/
|
||||
static inline void pcnt_ll_disable_all_events(pcnt_dev_t *hw, uint32_t unit)
|
||||
{
|
||||
hw->conf_unit[unit].conf0.val &= ~(PCNT_LL_EVENT_MASK << 11);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set PCNT high limit value
|
||||
*
|
||||
* @param hw Peripheral PCNT hardware instance address.
|
||||
* @param unit PCNT unit number
|
||||
* @param value PCNT high limit value
|
||||
*/
|
||||
static inline void pcnt_ll_set_high_limit_value(pcnt_dev_t *hw, uint32_t unit, int value)
|
||||
{
|
||||
typeof(hw->conf_unit[unit].conf2) conf2_reg = hw->conf_unit[unit].conf2;
|
||||
conf2_reg.cnt_h_lim = value;
|
||||
hw->conf_unit[unit].conf2 = conf2_reg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set PCNT low limit value
|
||||
*
|
||||
* @param hw Peripheral PCNT hardware instance address.
|
||||
* @param unit PCNT unit number
|
||||
* @param value PCNT low limit value
|
||||
*/
|
||||
static inline void pcnt_ll_set_low_limit_value(pcnt_dev_t *hw, uint32_t unit, int value)
|
||||
{
|
||||
typeof(hw->conf_unit[unit].conf2) conf2_reg = hw->conf_unit[unit].conf2;
|
||||
conf2_reg.cnt_l_lim = value;
|
||||
hw->conf_unit[unit].conf2 = conf2_reg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set PCNT threshold value
|
||||
*
|
||||
* @param hw Peripheral PCNT hardware instance address.
|
||||
* @param unit PCNT unit number
|
||||
* @param thres Threshold ID
|
||||
* @param value PCNT threshold value
|
||||
*/
|
||||
static inline void pcnt_ll_set_thres_value(pcnt_dev_t *hw, uint32_t unit, uint32_t thres, int value)
|
||||
{
|
||||
typeof(hw->conf_unit[unit].conf1) conf1_reg = hw->conf_unit[unit].conf1;
|
||||
if (thres == 0) {
|
||||
conf1_reg.cnt_thres0 = value;
|
||||
} else {
|
||||
conf1_reg.cnt_thres1 = value;
|
||||
}
|
||||
hw->conf_unit[unit].conf1 = conf1_reg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get PCNT high limit value
|
||||
*
|
||||
* @param hw Peripheral PCNT hardware instance address.
|
||||
* @param unit PCNT unit number
|
||||
* @return PCNT high limit value
|
||||
*/
|
||||
static inline int pcnt_ll_get_high_limit_value(pcnt_dev_t *hw, uint32_t unit)
|
||||
{
|
||||
typeof(hw->conf_unit[unit].conf2) conf2_reg = hw->conf_unit[unit].conf2;
|
||||
int16_t value = conf2_reg.cnt_h_lim;
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get PCNT low limit value
|
||||
*
|
||||
* @param hw Peripheral PCNT hardware instance address.
|
||||
* @param unit PCNT unit number
|
||||
* @return PCNT high limit value
|
||||
*/
|
||||
static inline int pcnt_ll_get_low_limit_value(pcnt_dev_t *hw, uint32_t unit)
|
||||
{
|
||||
typeof(hw->conf_unit[unit].conf2) conf2_reg = hw->conf_unit[unit].conf2;
|
||||
int16_t value = conf2_reg.cnt_l_lim;
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get PCNT threshold value
|
||||
*
|
||||
* @param hw Peripheral PCNT hardware instance address.
|
||||
* @param unit PCNT unit number
|
||||
* @param thres Threshold ID
|
||||
* @return PCNT threshold value
|
||||
*/
|
||||
static inline int pcnt_ll_get_thres_value(pcnt_dev_t *hw, uint32_t unit, uint32_t thres)
|
||||
{
|
||||
int16_t value;
|
||||
typeof(hw->conf_unit[unit].conf1) conf1_reg = hw->conf_unit[unit].conf1;
|
||||
if (thres == 0) {
|
||||
value = conf1_reg.cnt_thres0;
|
||||
} else {
|
||||
value = conf1_reg.cnt_thres1;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get PCNT unit runtime status
|
||||
*
|
||||
* @param hw Peripheral PCNT hardware instance address.
|
||||
* @param unit PCNT unit number
|
||||
* @return PCNT unit runtime status
|
||||
*/
|
||||
static inline uint32_t pcnt_ll_get_unit_status(pcnt_dev_t *hw, uint32_t unit)
|
||||
{
|
||||
return hw->status_unit[unit].val;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get PCNT count sign
|
||||
*
|
||||
* @param hw Peripheral PCNT hardware instance address.
|
||||
* @param unit PCNT unit number
|
||||
* @return Count sign
|
||||
*/
|
||||
static inline pcnt_unit_count_sign_t pcnt_ll_get_count_sign(pcnt_dev_t *hw, uint32_t unit)
|
||||
{
|
||||
return hw->status_unit[unit].val & 0x03;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get PCNT event status
|
||||
*
|
||||
* @param hw Peripheral PCNT hardware instance address.
|
||||
* @param unit PCNT unit number
|
||||
* @return event status word
|
||||
* @return Event status word
|
||||
*/
|
||||
static inline uint32_t pcnt_ll_get_event_status(pcnt_dev_t *hw, pcnt_unit_t unit)
|
||||
static inline uint32_t pcnt_ll_get_event_status(pcnt_dev_t *hw, uint32_t unit)
|
||||
{
|
||||
return hw->status_unit[unit].val;
|
||||
return hw->status_unit[unit].val >> 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set PCNT filter value
|
||||
* @brief Set PCNT glitch filter threshold
|
||||
*
|
||||
* @param hw Peripheral PCNT hardware instance address.
|
||||
* @param unit PCNT unit number
|
||||
* @param filter_val PCNT signal filter value, counter in APB_CLK cycles.
|
||||
* Any pulses lasting shorter than this will be ignored when the filter is enabled.
|
||||
* @note
|
||||
* filter_val is a 10-bit value, so the maximum filter_val should be limited to 1023.
|
||||
*/
|
||||
static inline void pcnt_ll_set_filter_value(pcnt_dev_t *hw, pcnt_unit_t unit, uint16_t filter_val)
|
||||
static inline void pcnt_ll_set_glitch_filter_thres(pcnt_dev_t *hw, uint32_t unit, uint32_t filter_val)
|
||||
{
|
||||
hw->conf_unit[unit].conf0.filter_thres = filter_val;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get PCNT filter value
|
||||
* @brief Get PCNT glitch filter threshold
|
||||
*
|
||||
* @param hw Peripheral PCNT hardware instance address.
|
||||
* @param unit PCNT unit number
|
||||
* @param filter_val Pointer to accept PCNT filter value.
|
||||
* @return glitch filter threshold
|
||||
*/
|
||||
static inline void pcnt_ll_get_filter_value(pcnt_dev_t *hw, pcnt_unit_t unit, uint16_t *filter_val)
|
||||
static inline uint32_t pcnt_ll_get_glitch_filter_thres(pcnt_dev_t *hw, uint32_t unit)
|
||||
{
|
||||
*filter_val = hw->conf_unit[unit].conf0.filter_thres;
|
||||
return hw->conf_unit[unit].conf0.filter_thres;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable PCNT input filter
|
||||
* @brief Enable PCNT glitch filter
|
||||
*
|
||||
* @param hw Peripheral PCNT hardware instance address.
|
||||
* @param unit PCNT unit number
|
||||
* @param enable True to enable the filter, False to disable the filter
|
||||
*/
|
||||
static inline void pcnt_ll_filter_enable(pcnt_dev_t *hw, pcnt_unit_t unit)
|
||||
static inline void pcnt_ll_enable_glitch_filter(pcnt_dev_t *hw, uint32_t unit, bool enable)
|
||||
{
|
||||
hw->conf_unit[unit].conf0.filter_en = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable PCNT input filter
|
||||
*
|
||||
* @param hw Peripheral PCNT hardware instance address.
|
||||
* @param unit PCNT unit number
|
||||
*/
|
||||
static inline void pcnt_ll_filter_disable(pcnt_dev_t *hw, pcnt_unit_t unit)
|
||||
{
|
||||
hw->conf_unit[unit].conf0.filter_en = 0;
|
||||
hw->conf_unit[unit].conf0.filter_en = enable;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include "hal/misc.h"
|
||||
#include "soc/rmt_struct.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -119,23 +120,23 @@ static inline uint32_t rmt_ll_rx_get_mem_blocks(rmt_dev_t *dev, uint32_t channel
|
||||
|
||||
static inline void rmt_ll_tx_set_channel_clock_div(rmt_dev_t *dev, uint32_t channel, uint32_t div)
|
||||
{
|
||||
dev->conf_ch[channel].conf0.div_cnt = div;
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(dev->conf_ch[channel].conf0, div_cnt, div);
|
||||
}
|
||||
|
||||
static inline void rmt_ll_rx_set_channel_clock_div(rmt_dev_t *dev, uint32_t channel, uint32_t div)
|
||||
{
|
||||
dev->conf_ch[channel].conf0.div_cnt = div;
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(dev->conf_ch[channel].conf0, div_cnt, div);
|
||||
}
|
||||
|
||||
static inline uint32_t rmt_ll_tx_get_channel_clock_div(rmt_dev_t *dev, uint32_t channel)
|
||||
{
|
||||
uint32_t div = dev->conf_ch[channel].conf0.div_cnt;
|
||||
uint32_t div = HAL_FORCE_READ_U32_REG_FIELD(dev->conf_ch[channel].conf0, div_cnt);
|
||||
return div == 0 ? 256 : div;
|
||||
}
|
||||
|
||||
static inline uint32_t rmt_ll_rx_get_channel_clock_div(rmt_dev_t *dev, uint32_t channel)
|
||||
{
|
||||
uint32_t div = dev->conf_ch[channel].conf0.div_cnt;
|
||||
uint32_t div = HAL_FORCE_READ_U32_REG_FIELD(dev->conf_ch[channel].conf0, div_cnt);
|
||||
return div == 0 ? 256 : div;
|
||||
}
|
||||
|
||||
@ -146,12 +147,12 @@ static inline void rmt_ll_tx_enable_pingpong(rmt_dev_t *dev, uint32_t channel, b
|
||||
|
||||
static inline void rmt_ll_rx_set_idle_thres(rmt_dev_t *dev, uint32_t channel, uint32_t thres)
|
||||
{
|
||||
dev->conf_ch[channel].conf0.idle_thres = thres;
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(dev->conf_ch[channel].conf0, idle_thres, thres);
|
||||
}
|
||||
|
||||
static inline uint32_t rmt_ll_rx_get_idle_thres(rmt_dev_t *dev, uint32_t channel)
|
||||
{
|
||||
return dev->conf_ch[channel].conf0.idle_thres;
|
||||
return HAL_FORCE_READ_U32_REG_FIELD(dev->conf_ch[channel].conf0, idle_thres);
|
||||
}
|
||||
|
||||
static inline void rmt_ll_rx_set_mem_owner(rmt_dev_t *dev, uint32_t channel, uint8_t owner)
|
||||
@ -186,7 +187,7 @@ static inline void rmt_ll_rx_enable_filter(rmt_dev_t *dev, uint32_t channel, boo
|
||||
|
||||
static inline void rmt_ll_rx_set_filter_thres(rmt_dev_t *dev, uint32_t channel, uint32_t thres)
|
||||
{
|
||||
dev->conf_ch[channel].conf1.rx_filter_thres = thres;
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(dev->conf_ch[channel].conf1, rx_filter_thres, thres);
|
||||
}
|
||||
|
||||
static inline void rmt_ll_tx_enable_idle(rmt_dev_t *dev, uint32_t channel, bool enable)
|
||||
@ -324,14 +325,14 @@ static inline uint32_t rmt_ll_get_tx_thres_interrupt_status(rmt_dev_t *dev)
|
||||
|
||||
static inline void rmt_ll_tx_set_carrier_high_low_ticks(rmt_dev_t *dev, uint32_t channel, uint32_t high_ticks, uint32_t low_ticks)
|
||||
{
|
||||
dev->carrier_duty_ch[channel].high = high_ticks;
|
||||
dev->carrier_duty_ch[channel].low = low_ticks;
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(dev->carrier_duty_ch[channel], high, high_ticks);
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(dev->carrier_duty_ch[channel], low, low_ticks);
|
||||
}
|
||||
|
||||
static inline void rmt_ll_tx_get_carrier_high_low_ticks(rmt_dev_t *dev, uint32_t channel, uint32_t *high_ticks, uint32_t *low_ticks)
|
||||
{
|
||||
*high_ticks = dev->carrier_duty_ch[channel].high;
|
||||
*low_ticks = dev->carrier_duty_ch[channel].low;
|
||||
*high_ticks = HAL_FORCE_READ_U32_REG_FIELD(dev->carrier_duty_ch[channel], high);
|
||||
*low_ticks = HAL_FORCE_READ_U32_REG_FIELD(dev->carrier_duty_ch[channel], low);
|
||||
}
|
||||
|
||||
static inline void rmt_ll_tx_enable_carrier_modulation(rmt_dev_t *dev, uint32_t channel, bool enable)
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "soc/rtc_io_periph.h"
|
||||
#include "soc/rtc_io_struct.h"
|
||||
#include "hal/rtc_io_types.h"
|
||||
#include "hal/gpio_types.h"
|
||||
|
||||
|
@ -25,6 +25,7 @@ extern "C" {
|
||||
#include <stdbool.h>
|
||||
#include "hal/wdt_types.h"
|
||||
#include "soc/rtc_cntl_periph.h"
|
||||
#include "soc/rtc_cntl_struct.h"
|
||||
#include "esp_attr.h"
|
||||
|
||||
//Type check wdt_stage_action_t
|
||||
|
@ -22,7 +22,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "hal/misc.h"
|
||||
#include "soc/sigmadelta_periph.h"
|
||||
#include "soc/gpio_sd_struct.h"
|
||||
#include "hal/sigmadelta_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -53,7 +55,7 @@ static inline void sigmadelta_ll_set_en(gpio_sd_dev_t *hw, bool en)
|
||||
*/
|
||||
static inline void sigmadelta_ll_set_duty(gpio_sd_dev_t *hw, sigmadelta_channel_t channel, int8_t duty)
|
||||
{
|
||||
hw->channel[channel].duty = duty;
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(hw->channel[channel], duty, (uint32_t)duty);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -65,7 +67,7 @@ static inline void sigmadelta_ll_set_duty(gpio_sd_dev_t *hw, sigmadelta_channel_
|
||||
*/
|
||||
static inline void sigmadelta_ll_set_prescale(gpio_sd_dev_t *hw, sigmadelta_channel_t channel, uint8_t prescale)
|
||||
{
|
||||
hw->channel[channel].prescale = prescale;
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(hw->channel[channel], prescale, prescale);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -24,11 +24,13 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "soc/spi_periph.h"
|
||||
#include "soc/spi_struct.h"
|
||||
#include "hal/spi_types.h"
|
||||
#include "hal/spi_flash_types.h"
|
||||
#include <sys/param.h> // For MIN/MAX
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include "hal/misc.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -393,7 +395,7 @@ static inline void spi_flash_ll_set_address(spi_dev_t *dev, uint32_t addr)
|
||||
static inline void spi_flash_ll_set_dummy(spi_dev_t *dev, uint32_t dummy_n)
|
||||
{
|
||||
dev->user.usr_dummy = dummy_n ? 1 : 0;
|
||||
dev->user1.usr_dummy_cyclelen = dummy_n - 1;
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(dev->user1, usr_dummy_cyclelen, dummy_n - 1);
|
||||
}
|
||||
|
||||
static inline void spi_flash_ll_set_hold(spi_dev_t *dev, uint32_t hold_n)
|
||||
|
@ -27,7 +27,10 @@
|
||||
#include "esp_types.h"
|
||||
#include "esp32/rom/lldesc.h"
|
||||
#include "soc/spi_periph.h"
|
||||
#include "soc/spi_struct.h"
|
||||
#include "hal/misc.h"
|
||||
#include "hal/spi_types.h"
|
||||
#include "hal/assert.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -37,6 +40,9 @@ extern "C" {
|
||||
#define SPI_LL_DMA_FIFO_RST_MASK (SPI_AHBM_RST | SPI_AHBM_FIFO_RST)
|
||||
/// 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)
|
||||
/// These 2 masks together will set SPI transaction to one line mode
|
||||
#define SPI_LL_ONE_LINE_CTRL_MASK (SPI_FREAD_DUAL | SPI_FREAD_QUAD | SPI_FREAD_DIO | SPI_FREAD_QIO)
|
||||
#define SPI_LL_ONE_LINE_USER_MASK (SPI_FWRITE_DUAL | SPI_FWRITE_QUAD | SPI_FWRITE_DIO | SPI_FWRITE_QIO)
|
||||
/// 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))
|
||||
/// This is the expected clock frequency
|
||||
@ -53,16 +59,6 @@ typedef uint32_t spi_ll_clock_val_t;
|
||||
//On ESP32-S2 and earlier chips, DMA registers are part of SPI registers. So set the registers of SPI peripheral to control DMA.
|
||||
typedef spi_dev_t spi_dma_dev_t;
|
||||
|
||||
/** IO modes supported by the master. */
|
||||
typedef enum {
|
||||
SPI_LL_IO_MODE_NORMAL = 0, ///< 1-bit mode for all phases
|
||||
SPI_LL_IO_MODE_DIO, ///< 2-bit mode for address and data phases, 1-bit mode for command phase
|
||||
SPI_LL_IO_MODE_DUAL, ///< 2-bit mode for data phases only, 1-bit mode for command and address phases
|
||||
SPI_LL_IO_MODE_QIO, ///< 4-bit mode for address and data phases, 1-bit mode for command phase
|
||||
SPI_LL_IO_MODE_QUAD, ///< 4-bit mode for data phases only, 1-bit mode for command and address phases
|
||||
} spi_ll_io_mode_t;
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Control
|
||||
*----------------------------------------------------------------------------*/
|
||||
@ -449,37 +445,50 @@ static inline void spi_ll_set_sio_mode(spi_dev_t *hw, int sio_mode)
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the io mode for the master to work at.
|
||||
* Configure the SPI transaction line mode for the master to use.
|
||||
*
|
||||
* @param hw Beginning address of the peripheral registers.
|
||||
* @param io_mode IO mode to work at, see ``spi_ll_io_mode_t``.
|
||||
* @param hw Beginning address of the peripheral registers.
|
||||
* @param line_mode SPI transaction line mode to use, see ``spi_line_mode_t``.
|
||||
*/
|
||||
static inline void spi_ll_master_set_io_mode(spi_dev_t *hw, spi_ll_io_mode_t io_mode)
|
||||
static inline void spi_ll_master_set_line_mode(spi_dev_t *hw, spi_line_mode_t line_mode)
|
||||
{
|
||||
hw->ctrl.val &= ~(SPI_FREAD_DUAL | SPI_FREAD_QUAD | SPI_FREAD_DIO | SPI_FREAD_QIO);
|
||||
hw->user.val &= ~(SPI_FWRITE_DUAL | SPI_FWRITE_QUAD | SPI_FWRITE_DIO | SPI_FWRITE_QIO);
|
||||
switch (io_mode) {
|
||||
case SPI_LL_IO_MODE_DIO:
|
||||
hw->ctrl.fread_dio = 1;
|
||||
hw->user.fwrite_dio = 1;
|
||||
hw->ctrl.val &= ~SPI_LL_ONE_LINE_CTRL_MASK;
|
||||
hw->user.val &= ~SPI_LL_ONE_LINE_USER_MASK;
|
||||
if (line_mode.cmd_lines > 1) {
|
||||
HAL_ASSERT(false);
|
||||
}
|
||||
switch (line_mode.data_lines) {
|
||||
case 2:
|
||||
if (line_mode.addr_lines == 1) {
|
||||
// 1-line-cmd + 1-line-addr + 2-line-data
|
||||
hw->ctrl.fread_dual = 1;
|
||||
hw->user.fwrite_dual = 1;
|
||||
} else if (line_mode.addr_lines == 2) {
|
||||
// 1-line-cmd + 2-line-addr + 2-line-data
|
||||
hw->ctrl.fread_dio = 1;
|
||||
hw->user.fwrite_dio = 1;
|
||||
} else {
|
||||
HAL_ASSERT(false);
|
||||
}
|
||||
hw->ctrl.fastrd_mode = 1;
|
||||
break;
|
||||
case SPI_LL_IO_MODE_DUAL:
|
||||
hw->ctrl.fread_dual = 1;
|
||||
hw->user.fwrite_dual = 1;
|
||||
break;
|
||||
case SPI_LL_IO_MODE_QIO:
|
||||
hw->ctrl.fread_qio = 1;
|
||||
hw->user.fwrite_qio = 1;
|
||||
break;
|
||||
case SPI_LL_IO_MODE_QUAD:
|
||||
hw->ctrl.fread_quad = 1;
|
||||
hw->user.fwrite_quad = 1;
|
||||
case 4:
|
||||
if (line_mode.addr_lines == 1) {
|
||||
// 1-line-cmd + 1-line-addr + 4-line-data
|
||||
hw->ctrl.fread_quad = 1;
|
||||
hw->user.fwrite_quad = 1;
|
||||
} else if (line_mode.addr_lines == 4) {
|
||||
// 1-line-cmd + 4-line-addr + 4-line-data
|
||||
hw->ctrl.fread_qio = 1;
|
||||
hw->user.fwrite_qio = 1;
|
||||
} else {
|
||||
HAL_ASSERT(false);
|
||||
}
|
||||
hw->ctrl.fastrd_mode = 1;
|
||||
break;
|
||||
default:
|
||||
// 1-line-cmd + 1-line-addr + 1-line-data
|
||||
break;
|
||||
};
|
||||
if (io_mode != SPI_LL_IO_MODE_NORMAL) {
|
||||
hw->ctrl.fastrd_mode = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -502,7 +511,8 @@ static inline void spi_ll_master_select_cs(spi_dev_t *hw, int cs_id)
|
||||
* @param hw Beginning address of the peripheral registers.
|
||||
* @param keep_active if 0 don't keep CS activated, else keep CS activated
|
||||
*/
|
||||
static inline void spi_ll_master_keep_cs(spi_dev_t *hw, int keep_active) {
|
||||
static inline void spi_ll_master_keep_cs(spi_dev_t *hw, int keep_active)
|
||||
{
|
||||
hw->pin.cs_keep_active = (keep_active != 0) ? 1 : 0;
|
||||
}
|
||||
|
||||
@ -691,7 +701,7 @@ static inline void spi_ll_set_miso_delay(spi_dev_t *hw, int delay_mode, int dela
|
||||
static inline void spi_ll_set_dummy(spi_dev_t *hw, int dummy_n)
|
||||
{
|
||||
hw->user.usr_dummy = dummy_n ? 1 : 0;
|
||||
hw->user1.usr_dummy_cyclelen = dummy_n - 1;
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(hw->user1, usr_dummy_cyclelen, dummy_n - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -849,13 +859,13 @@ static inline void spi_ll_set_command(spi_dev_t *hw, uint16_t cmd, int cmdlen, b
|
||||
{
|
||||
if (lsbfirst) {
|
||||
// The output command start from bit0 to bit 15, kept as is.
|
||||
hw->user2.usr_command_value = cmd;
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(hw->user2, usr_command_value, cmd);
|
||||
} else {
|
||||
/* Output command will be sent from bit 7 to 0 of command_value, and
|
||||
* then bit 15 to 8 of the same register field. Shift and swap to send
|
||||
* more straightly.
|
||||
*/
|
||||
hw->user2.usr_command_value = HAL_SPI_SWAP_DATA_TX(cmd, cmdlen);
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(hw->user2, usr_command_value, HAL_SPI_SWAP_DATA_TX(cmd, cmdlen));
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -22,9 +22,11 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "hal/misc.h"
|
||||
#include "hal/assert.h"
|
||||
#include "hal/timer_types.h"
|
||||
#include "soc/timer_periph.h"
|
||||
#include "soc/timer_group_struct.h"
|
||||
|
||||
_Static_assert(TIMER_INTR_T0 == TIMG_T0_INT_CLR, "Add mapping to LL interrupt handling, since it's no longer naturally compatible with the timer_intr_t");
|
||||
_Static_assert(TIMER_INTR_T1 == TIMG_T1_INT_CLR, "Add mapping to LL interrupt handling, since it's no longer naturally compatible with the timer_intr_t");
|
||||
@ -50,7 +52,7 @@ static inline void timer_ll_set_divider(timg_dev_t *hw, timer_idx_t timer_num, u
|
||||
}
|
||||
int timer_en = hw->hw_timer[timer_num].config.enable;
|
||||
hw->hw_timer[timer_num].config.enable = 0;
|
||||
hw->hw_timer[timer_num].config.divider = divider;
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(hw->hw_timer[timer_num].config, divider, divider);
|
||||
hw->hw_timer[timer_num].config.enable = timer_en;
|
||||
}
|
||||
|
||||
@ -65,7 +67,7 @@ static inline void timer_ll_set_divider(timg_dev_t *hw, timer_idx_t timer_num, u
|
||||
*/
|
||||
static inline void timer_ll_get_divider(timg_dev_t *hw, timer_idx_t timer_num, uint32_t *divider)
|
||||
{
|
||||
uint32_t d = hw->hw_timer[timer_num].config.divider;
|
||||
uint32_t d = HAL_FORCE_READ_U32_REG_FIELD(hw->hw_timer[timer_num].config, divider);
|
||||
if (d == 0) {
|
||||
d = 65536;
|
||||
} else if (d == 1) {
|
||||
|
@ -24,7 +24,11 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include "hal/misc.h"
|
||||
#include "soc/touch_sensor_periph.h"
|
||||
#include "soc/sens_struct.h"
|
||||
#include "soc/rtc_io_struct.h"
|
||||
#include "soc/rtc_cntl_struct.h"
|
||||
#include "hal/touch_sensor_types.h"
|
||||
|
||||
|
||||
@ -60,9 +64,9 @@ static inline touch_pad_t touch_ll_num_wrap(touch_pad_t touch_num)
|
||||
static inline void touch_ll_set_meas_time(uint16_t meas_time)
|
||||
{
|
||||
//touch sensor measure time= meas_cycle / 8Mhz
|
||||
SENS.sar_touch_ctrl1.touch_meas_delay = meas_time;
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(SENS.sar_touch_ctrl1, touch_meas_delay, meas_time);
|
||||
//the waiting cycles (in 8MHz) between TOUCH_START and TOUCH_XPD
|
||||
SENS.sar_touch_ctrl1.touch_xpd_wait = SOC_TOUCH_PAD_MEASURE_WAIT_MAX;
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(SENS.sar_touch_ctrl1, touch_xpd_wait, SOC_TOUCH_PAD_MEASURE_WAIT_MAX);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -72,7 +76,7 @@ static inline void touch_ll_set_meas_time(uint16_t meas_time)
|
||||
*/
|
||||
static inline void touch_ll_get_meas_time(uint16_t *meas_time)
|
||||
{
|
||||
*meas_time = SENS.sar_touch_ctrl1.touch_meas_delay;
|
||||
*meas_time = HAL_FORCE_READ_U32_REG_FIELD(SENS.sar_touch_ctrl1, touch_meas_delay);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -86,7 +90,7 @@ static inline void touch_ll_get_meas_time(uint16_t *meas_time)
|
||||
static inline void touch_ll_set_sleep_time(uint16_t sleep_time)
|
||||
{
|
||||
//touch sensor sleep cycle Time = sleep_cycle / RTC_SLOW_CLK( can be 150k or 32k depending on the options)
|
||||
SENS.sar_touch_ctrl2.touch_sleep_cycles = sleep_time;
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(SENS.sar_touch_ctrl2, touch_sleep_cycles, sleep_time);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -96,7 +100,7 @@ static inline void touch_ll_set_sleep_time(uint16_t sleep_time)
|
||||
*/
|
||||
static inline void touch_ll_get_sleep_time(uint16_t *sleep_time)
|
||||
{
|
||||
*sleep_time = SENS.sar_touch_ctrl2.touch_sleep_cycles;
|
||||
*sleep_time = HAL_FORCE_READ_U32_REG_FIELD(SENS.sar_touch_ctrl2, touch_sleep_cycles);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -291,9 +295,9 @@ static inline void touch_ll_set_threshold(touch_pad_t touch_num, uint16_t thresh
|
||||
{
|
||||
touch_pad_t tp_wrap = touch_ll_num_wrap(touch_num);
|
||||
if (tp_wrap & 0x1) {
|
||||
SENS.touch_thresh[tp_wrap / 2].l_thresh = threshold;
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(SENS.touch_thresh[tp_wrap / 2], l_thresh, threshold);
|
||||
} else {
|
||||
SENS.touch_thresh[tp_wrap / 2].h_thresh = threshold;
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(SENS.touch_thresh[tp_wrap / 2], h_thresh, threshold);
|
||||
}
|
||||
}
|
||||
|
||||
@ -308,8 +312,8 @@ static inline void touch_ll_get_threshold(touch_pad_t touch_num, uint16_t *thres
|
||||
touch_pad_t tp_wrap = touch_ll_num_wrap(touch_num);
|
||||
if (threshold) {
|
||||
*threshold = (tp_wrap & 0x1 ) ?
|
||||
SENS.touch_thresh[tp_wrap / 2].l_thresh :
|
||||
SENS.touch_thresh[tp_wrap / 2].h_thresh;
|
||||
HAL_FORCE_READ_U32_REG_FIELD(SENS.touch_thresh[tp_wrap / 2], l_thresh) :
|
||||
HAL_FORCE_READ_U32_REG_FIELD(SENS.touch_thresh[tp_wrap / 2], h_thresh);
|
||||
}
|
||||
}
|
||||
|
||||
@ -489,7 +493,8 @@ static inline void touch_ll_intr_clear(void)
|
||||
static inline uint32_t touch_ll_read_raw_data(touch_pad_t touch_num)
|
||||
{
|
||||
touch_pad_t tp_wrap = touch_ll_num_wrap(touch_num);
|
||||
return ((tp_wrap & 0x1) ? SENS.touch_meas[tp_wrap / 2].l_val : SENS.touch_meas[tp_wrap / 2].h_val);
|
||||
return ((tp_wrap & 0x1) ? HAL_FORCE_READ_U32_REG_FIELD(SENS.touch_meas[tp_wrap / 2], l_val) :
|
||||
HAL_FORCE_READ_U32_REG_FIELD(SENS.touch_meas[tp_wrap / 2], h_val));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -32,6 +32,7 @@ extern "C" {
|
||||
#include "hal/misc.h"
|
||||
#include "hal/twai_types.h"
|
||||
#include "soc/twai_periph.h"
|
||||
#include "soc/twai_struct.h"
|
||||
|
||||
/* ------------------------- Defines and Typedefs --------------------------- */
|
||||
|
||||
@ -491,7 +492,7 @@ static inline void twai_ll_parse_err_code_cap(twai_dev_t *hw,
|
||||
*/
|
||||
static inline void twai_ll_set_err_warn_lim(twai_dev_t *hw, uint32_t ewl)
|
||||
{
|
||||
hw->error_warning_limit_reg.ewl = ewl;
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(hw->error_warning_limit_reg, ewl, ewl);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -531,7 +532,7 @@ static inline uint32_t twai_ll_get_rec(twai_dev_t *hw)
|
||||
*/
|
||||
static inline void twai_ll_set_rec(twai_dev_t *hw, uint32_t rec)
|
||||
{
|
||||
hw->rx_error_counter_reg.rxerr = rec;
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(hw->rx_error_counter_reg, rxerr, rec);
|
||||
}
|
||||
|
||||
/* ------------------------ TX Error Count Register ------------------------- */
|
||||
@ -559,7 +560,7 @@ static inline uint32_t twai_ll_get_tec(twai_dev_t *hw)
|
||||
*/
|
||||
static inline void twai_ll_set_tec(twai_dev_t *hw, uint32_t tec)
|
||||
{
|
||||
hw->tx_error_counter_reg.txerr = tec;
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(hw->tx_error_counter_reg, txerr, tec);
|
||||
}
|
||||
|
||||
/* ---------------------- Acceptance Filter Registers ----------------------- */
|
||||
@ -578,8 +579,8 @@ static inline void twai_ll_set_acc_filter(twai_dev_t* hw, uint32_t code, uint32_
|
||||
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);
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(hw->acceptance_filter.acr[i], byte, ((code_swapped >> (i * 8)) & 0xFF));
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(hw->acceptance_filter.amr[i], byte, ((mask_swapped >> (i * 8)) & 0xFF));
|
||||
}
|
||||
hw->mode_reg.afm = single_filter;
|
||||
}
|
||||
@ -614,7 +615,7 @@ static inline void twai_ll_get_rx_buffer(twai_dev_t *hw, twai_ll_frame_buffer_t
|
||||
{
|
||||
//Copy RX buffer registers into frame
|
||||
for (int i = 0; i < 13; i++) {
|
||||
rx_frame->bytes[i] = hw->tx_rx_buffer[i].byte;
|
||||
rx_frame->bytes[i] = HAL_FORCE_READ_U32_REG_FIELD(hw->tx_rx_buffer[i], byte);
|
||||
}
|
||||
}
|
||||
|
||||
@ -794,8 +795,8 @@ static inline void twai_ll_save_reg(twai_dev_t *hw, twai_ll_reg_save_t *reg_save
|
||||
reg_save->bus_timing_1_reg = (uint8_t) hw->bus_timing_1_reg.val;
|
||||
reg_save->error_warning_limit_reg = (uint8_t) hw->error_warning_limit_reg.val;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
reg_save->acr_reg[i] = hw->acceptance_filter.acr[i].byte;
|
||||
reg_save->amr_reg[i] = hw->acceptance_filter.amr[i].byte;
|
||||
reg_save->acr_reg[i] = HAL_FORCE_READ_U32_REG_FIELD(hw->acceptance_filter.acr[i], byte);
|
||||
reg_save->amr_reg[i] = HAL_FORCE_READ_U32_REG_FIELD(hw->acceptance_filter.amr[i], byte);
|
||||
}
|
||||
reg_save->rx_error_counter_reg = (uint8_t) hw->rx_error_counter_reg.val;
|
||||
reg_save->tx_error_counter_reg = (uint8_t) hw->tx_error_counter_reg.val;
|
||||
@ -821,8 +822,8 @@ static inline void twai_ll_restore_reg(twai_dev_t *hw, twai_ll_reg_save_t *reg_s
|
||||
hw->bus_timing_1_reg.val = reg_save->bus_timing_1_reg;
|
||||
hw->error_warning_limit_reg.val = reg_save->error_warning_limit_reg;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
hw->acceptance_filter.acr[i].byte = reg_save->acr_reg[i];
|
||||
hw->acceptance_filter.amr[i].byte = reg_save->amr_reg[i];
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(hw->acceptance_filter.acr[i], byte, reg_save->acr_reg[i]);
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(hw->acceptance_filter.amr[i], byte, reg_save->amr_reg[i]);
|
||||
}
|
||||
hw->rx_error_counter_reg.val = reg_save->rx_error_counter_reg;
|
||||
hw->tx_error_counter_reg.val = reg_save->tx_error_counter_reg;
|
||||
|
@ -17,8 +17,11 @@
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "hal/misc.h"
|
||||
#include "esp_attr.h"
|
||||
#include "soc/uart_periph.h"
|
||||
#include "soc/uart_struct.h"
|
||||
#include "hal/uart_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -249,7 +252,7 @@ FORCE_INLINE_ATTR void uart_ll_rxfifo_rst(uart_dev_t *hw)
|
||||
//Get the UART APB fifo addr
|
||||
uint32_t fifo_addr = (hw == &UART0) ? UART_FIFO_REG(0) : (hw == &UART1) ? UART_FIFO_REG(1) : UART_FIFO_REG(2);
|
||||
do {
|
||||
fifo_cnt = hw->status.rxfifo_cnt;
|
||||
fifo_cnt = HAL_FORCE_READ_U32_REG_FIELD(hw->status, rxfifo_cnt);
|
||||
rxmem_sta.val = hw->mem_rx_status.val;
|
||||
if(fifo_cnt != 0 || (rxmem_sta.rd_addr != rxmem_sta.wr_addr)) {
|
||||
READ_PERI_REG(fifo_addr);
|
||||
@ -287,7 +290,7 @@ FORCE_INLINE_ATTR void uart_ll_txfifo_rst(uart_dev_t *hw)
|
||||
*/
|
||||
FORCE_INLINE_ATTR uint32_t uart_ll_get_rxfifo_len(uart_dev_t *hw)
|
||||
{
|
||||
uint32_t fifo_cnt = hw->status.rxfifo_cnt;
|
||||
uint32_t fifo_cnt = HAL_FORCE_READ_U32_REG_FIELD(hw->status, rxfifo_cnt);
|
||||
typeof(hw->mem_rx_status) rx_status = hw->mem_rx_status;
|
||||
uint32_t len = 0;
|
||||
|
||||
@ -313,7 +316,7 @@ FORCE_INLINE_ATTR uint32_t uart_ll_get_rxfifo_len(uart_dev_t *hw)
|
||||
*/
|
||||
FORCE_INLINE_ATTR uint32_t uart_ll_get_txfifo_len(uart_dev_t *hw)
|
||||
{
|
||||
return UART_LL_FIFO_DEF_LEN - hw->status.txfifo_cnt;
|
||||
return UART_LL_FIFO_DEF_LEN - HAL_FORCE_READ_U32_REG_FIELD(hw->status, txfifo_cnt);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -453,7 +456,7 @@ FORCE_INLINE_ATTR void uart_ll_set_tx_idle_num(uart_dev_t *hw, uint32_t idle_num
|
||||
FORCE_INLINE_ATTR void uart_ll_tx_break(uart_dev_t *hw, uint32_t break_num)
|
||||
{
|
||||
if(break_num > 0) {
|
||||
hw->idle_conf.tx_brk_num = break_num;
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(hw->idle_conf, tx_brk_num, break_num);
|
||||
hw->conf0.txd_brk = 1;
|
||||
} else {
|
||||
hw->conf0.txd_brk = 0;
|
||||
@ -518,10 +521,10 @@ FORCE_INLINE_ATTR void uart_ll_set_sw_flow_ctrl(uart_dev_t *hw, uart_sw_flowctrl
|
||||
if(sw_flow_ctrl_en) {
|
||||
hw->flow_conf.xonoff_del = 1;
|
||||
hw->flow_conf.sw_flow_con_en = 1;
|
||||
hw->swfc_conf.xon_threshold = flow_ctrl->xon_thrd;
|
||||
hw->swfc_conf.xoff_threshold = flow_ctrl->xoff_thrd;
|
||||
hw->swfc_conf.xon_char = flow_ctrl->xon_char;
|
||||
hw->swfc_conf.xoff_char = flow_ctrl->xoff_char;
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(hw->swfc_conf, xon_threshold, flow_ctrl->xon_thrd);
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(hw->swfc_conf, xoff_threshold, flow_ctrl->xoff_thrd);
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(hw->swfc_conf, xon_char, flow_ctrl->xon_char);
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(hw->swfc_conf, xoff_char, flow_ctrl->xoff_char);
|
||||
} else {
|
||||
hw->flow_conf.sw_flow_con_en = 0;
|
||||
hw->flow_conf.xonoff_del = 0;
|
||||
@ -543,8 +546,8 @@ FORCE_INLINE_ATTR void uart_ll_set_sw_flow_ctrl(uart_dev_t *hw, uart_sw_flowctrl
|
||||
*/
|
||||
FORCE_INLINE_ATTR void uart_ll_set_at_cmd_char(uart_dev_t *hw, uart_at_cmd_t *cmd_char)
|
||||
{
|
||||
hw->at_cmd_char.data = cmd_char->cmd_char;
|
||||
hw->at_cmd_char.char_num = cmd_char->char_num;
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(hw->at_cmd_char, data, cmd_char->cmd_char);
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(hw->at_cmd_char, char_num, cmd_char->char_num);
|
||||
hw->at_cmd_postcnt.post_idle_num = cmd_char->post_idle;
|
||||
hw->at_cmd_precnt.pre_idle_num = cmd_char->pre_idle;
|
||||
hw->at_cmd_gaptout.rx_gap_tout = cmd_char->gap_tout;
|
||||
@ -729,8 +732,8 @@ FORCE_INLINE_ATTR void uart_ll_set_mode(uart_dev_t *hw, uart_mode_t mode)
|
||||
*/
|
||||
FORCE_INLINE_ATTR void uart_ll_get_at_cmd_char(uart_dev_t *hw, uint8_t *cmd_char, uint8_t *char_num)
|
||||
{
|
||||
*cmd_char = hw->at_cmd_char.data;
|
||||
*char_num = hw->at_cmd_char.char_num;
|
||||
*cmd_char = HAL_FORCE_READ_U32_REG_FIELD(hw->at_cmd_char, data);
|
||||
*char_num = HAL_FORCE_READ_U32_REG_FIELD(hw->at_cmd_char, char_num);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -895,6 +898,67 @@ FORCE_INLINE_ATTR uint16_t uart_ll_max_tout_thrd(uart_dev_t *hw)
|
||||
return tout_thrd;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure the auto baudrate.
|
||||
*
|
||||
* @param hw Beginning address of the peripheral registers.
|
||||
* @param enable Boolean marking whether the auto baudrate should be enabled or not.
|
||||
*/
|
||||
FORCE_INLINE_ATTR void uart_ll_set_autobaud_en(uart_dev_t *hw, bool enable)
|
||||
{
|
||||
hw->auto_baud.en = enable ? 1 : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the RXD edge count.
|
||||
*
|
||||
* @param hw Beginning address of the peripheral registers.
|
||||
*/
|
||||
FORCE_INLINE_ATTR uint32_t uart_ll_get_rxd_edge_cnt(uart_dev_t *hw)
|
||||
{
|
||||
return hw->rxd_cnt.edge_cnt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the positive pulse minimum count.
|
||||
*
|
||||
* @param hw Beginning address of the peripheral registers.
|
||||
*/
|
||||
FORCE_INLINE_ATTR uint32_t uart_ll_get_pos_pulse_cnt(uart_dev_t *hw)
|
||||
{
|
||||
return hw->pospulse.min_cnt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the negative pulse minimum count.
|
||||
*
|
||||
* @param hw Beginning address of the peripheral registers.
|
||||
*/
|
||||
FORCE_INLINE_ATTR uint32_t uart_ll_get_neg_pulse_cnt(uart_dev_t *hw)
|
||||
{
|
||||
return hw->negpulse.min_cnt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the high pulse minimum count.
|
||||
*
|
||||
* @param hw Beginning address of the peripheral registers.
|
||||
*/
|
||||
FORCE_INLINE_ATTR uint32_t uart_ll_get_high_pulse_cnt(uart_dev_t *hw)
|
||||
{
|
||||
return hw->highpulse.min_cnt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the low pulse minimum count.
|
||||
*
|
||||
* @param hw Beginning address of the peripheral registers.
|
||||
*/
|
||||
FORCE_INLINE_ATTR uint32_t uart_ll_get_low_pulse_cnt(uart_dev_t *hw)
|
||||
{
|
||||
return hw->lowpulse.min_cnt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Force UART xoff.
|
||||
*
|
||||
|
@ -114,6 +114,22 @@ void adc_hal_init(void);
|
||||
#define adc_hal_amp_disable() adc_ll_amp_disable()
|
||||
#endif
|
||||
|
||||
#if SOC_ADC_ARBITER_SUPPORTED
|
||||
//No ADC2 controller arbiter on ESP32
|
||||
/**
|
||||
* Config ADC2 module arbiter.
|
||||
* The arbiter is to improve the use efficiency of ADC2. After the control right is robbed by the high priority,
|
||||
* the low priority controller will read the invalid ADC2 data, and the validity of the data can be judged by the flag bit in the data.
|
||||
*
|
||||
* @note Only ADC2 support arbiter.
|
||||
* @note The arbiter's working clock is APB_CLK. When the APB_CLK clock drops below 8 MHz, the arbiter must be in shield mode.
|
||||
* @note Default priority: Wi-Fi > RTC > Digital;
|
||||
*
|
||||
* @param config Refer to ``adc_arbiter_t``.
|
||||
*/
|
||||
void adc_hal_arbiter_config(adc_arbiter_t *config);
|
||||
#endif //#if SOC_ADC_ARBITER_SUPPORTED
|
||||
|
||||
/*---------------------------------------------------------------
|
||||
PWDET(Power detect) controller setting
|
||||
---------------------------------------------------------------*/
|
||||
@ -260,7 +276,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
|
||||
#if SOC_ADC_CALIBRATION_V1_SUPPORTED
|
||||
// ESP32-S2, C3 and H2 support HW offset calibration.
|
||||
|
||||
/**
|
||||
@ -296,7 +312,7 @@ void adc_hal_set_calibration_param(adc_ll_num_t adc_n, uint32_t param);
|
||||
*/
|
||||
uint32_t adc_hal_self_calibration(adc_ll_num_t adc_n, adc_channel_t channel, adc_atten_t atten, bool internal_gnd);
|
||||
|
||||
#endif //SOC_ADC_HW_CALIBRATION_V1
|
||||
#endif //SOC_ADC_CALIBRATION_V1_SUPPORTED
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32H2
|
||||
/*---------------------------------------------------------------
|
||||
|
@ -21,7 +21,7 @@
|
||||
#pragma once
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
#error "ESP32 doesn't have a DS peripheral"
|
||||
#error "ESP32 doesn't have a DS peripheral"
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
|
||||
// Copyright 2020 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.
|
||||
@ -25,13 +25,47 @@
|
||||
|
||||
#include "soc/i2s_periph.h"
|
||||
#include "soc/soc_caps.h"
|
||||
#include "hal/i2s_ll.h"
|
||||
#include "hal/i2s_types.h"
|
||||
#include "hal/i2s_ll.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief I2S clock configuration
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t sclk; /*!< I2S module clock */
|
||||
uint32_t mclk; /*!< I2S master clock */
|
||||
uint32_t bclk; /*!< I2S bit clock */
|
||||
uint16_t mclk_div; /*!< I2S master clock division */
|
||||
uint16_t bclk_div; /*!< I2S bit clock division*/
|
||||
} i2s_hal_clock_cfg_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief I2S HAL configurations
|
||||
*/
|
||||
typedef struct {
|
||||
i2s_mode_t mode; /*!< I2S work mode, using ored mask of `i2s_mode_t`*/
|
||||
uint32_t sample_rate; /*!< I2S sample rate*/
|
||||
i2s_comm_format_t comm_fmt; /*!< I2S communication format */
|
||||
i2s_channel_fmt_t chan_fmt; /*!< I2S channel format, there are total 16 channels in TDM mode.*/
|
||||
uint32_t sample_bits; /*!< I2S sample bits in one channel */
|
||||
uint32_t chan_bits; /*!< I2S total bits in one channel. Should not be smaller than 'sample_bits', default '0' means equal to 'sample_bits' */
|
||||
uint32_t active_chan; /*!< I2S active channel number */
|
||||
uint32_t total_chan; /*!< Total number of I2S channels */
|
||||
|
||||
#if SOC_I2S_SUPPORTS_TDM
|
||||
uint32_t chan_mask; /*!< Active channel bit mask, set value in `i2s_channel_t` to enable specific channel, the bit map of active channel can not exceed (0x1<<total_chan_num). */
|
||||
bool left_align; /*!< Set to enable left aligment */
|
||||
bool big_edin; /*!< Set to enable big edin */
|
||||
bool bit_order_msb; /*!< Set to enable msb order */
|
||||
bool skip_msk; /*!< Set to enable skip mask. If it is enabled, only the data of the enabled channels will be sent, otherwise all data stored in DMA TX buffer will be sent */
|
||||
#endif
|
||||
} i2s_hal_config_t;
|
||||
|
||||
/**
|
||||
* Context that should be maintained by both the driver and the HAL
|
||||
*/
|
||||
@ -41,258 +75,476 @@ typedef struct {
|
||||
} i2s_hal_context_t;
|
||||
|
||||
/**
|
||||
* @brief Get I2S interrupt status
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param status interrupt status
|
||||
*/
|
||||
#define i2s_hal_get_intr_status(hal, status) i2s_ll_get_intr_status((hal)->dev, status)
|
||||
|
||||
/**
|
||||
* @brief Clear I2S interrupt status
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param mask interrupt status mask
|
||||
*/
|
||||
#define i2s_hal_clear_intr_status(hal, mask) i2s_ll_clear_intr_status((hal)->dev, mask)
|
||||
|
||||
/**
|
||||
* @brief Get I2S out eof des address
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param addr out eof des address
|
||||
*/
|
||||
#define i2s_hal_get_out_eof_des_addr(hal, addr) i2s_ll_get_out_eof_des_addr((hal)->dev, addr)
|
||||
|
||||
/**
|
||||
* @brief Get I2S in eof des address
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param addr in eof des address
|
||||
*/
|
||||
#define i2s_hal_get_in_eof_des_addr(hal, addr) i2s_ll_get_in_eof_des_addr((hal)->dev, addr)
|
||||
|
||||
/**
|
||||
* @brief Enable I2S rx interrupt
|
||||
* @brief Enable I2S module clock
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
#define i2s_hal_enable_rx_intr(hal) i2s_ll_enable_rx_intr((hal)->dev)
|
||||
#define i2s_hal_enable_module_clock(hal) i2s_ll_enable_clock((hal)->dev);
|
||||
|
||||
/**
|
||||
* @brief Disable I2S rx interrupt
|
||||
* @brief Disable I2S module clock
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
#define i2s_hal_disable_rx_intr(hal) i2s_ll_disable_rx_intr((hal)->dev)
|
||||
#define i2s_hal_disable_module_clock(hal) i2s_ll_disable_clock((hal)->dev);
|
||||
|
||||
/**
|
||||
* @brief Disable I2S tx interrupt
|
||||
* @brief Reset I2S TX channel
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
#define i2s_hal_disable_tx_intr(hal) i2s_ll_disable_tx_intr((hal)->dev)
|
||||
#define i2s_hal_reset_tx(hal) i2s_ll_tx_reset((hal)->dev)
|
||||
|
||||
/**
|
||||
* @brief Enable I2S tx interrupt
|
||||
* @brief Reset I2S TX fifo
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
#define i2s_hal_enable_tx_intr(hal) i2s_ll_enable_tx_intr((hal)->dev)
|
||||
#define i2s_hal_reset_tx_fifo(hal) i2s_ll_tx_reset_fifo((hal)->dev)
|
||||
|
||||
/**
|
||||
* @brief Set I2S tx mode
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param ch i2s channel
|
||||
* @param bits bits per sample
|
||||
*/
|
||||
void i2s_hal_set_tx_mode(i2s_hal_context_t *hal, i2s_channel_t ch, i2s_bits_per_sample_t bits);
|
||||
|
||||
/**
|
||||
* @brief Set I2S rx mode
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param ch i2s channel
|
||||
* @param bits bits per sample
|
||||
*/
|
||||
void i2s_hal_set_rx_mode(i2s_hal_context_t *hal, i2s_channel_t ch, i2s_bits_per_sample_t bits);
|
||||
|
||||
/**
|
||||
* @brief Set I2S out link address
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param addr out link address
|
||||
*/
|
||||
#define i2s_hal_set_out_link_addr(hal, addr) i2s_ll_set_out_link_addr((hal)->dev, addr)
|
||||
|
||||
/**
|
||||
* @brief Set I2S out link address
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param addr out link address
|
||||
*/
|
||||
#define i2s_hal_set_out_link_addr(hal, addr) i2s_ll_set_out_link_addr((hal)->dev, addr)
|
||||
|
||||
/**
|
||||
* @brief Set I2S out link address
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param addr out link address
|
||||
*/
|
||||
#define i2s_hal_set_out_link_addr(hal, addr) i2s_ll_set_out_link_addr((hal)->dev, addr)
|
||||
|
||||
/**
|
||||
* @brief Set I2S in link
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param rx_eof_num in link eof num
|
||||
* @param addr in link address
|
||||
*/
|
||||
void i2s_hal_set_in_link(i2s_hal_context_t *hal, uint32_t rx_eof_num, uint32_t addr);
|
||||
|
||||
/**
|
||||
* @brief Set I2S clk div
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param div_num i2s clkm div num
|
||||
* @param div_a i2s clkm div a
|
||||
* @param div_b i2s clkm div b
|
||||
* @param tx_bck_div tx bck div num
|
||||
* @param rx_bck_div rx bck div num
|
||||
*/
|
||||
void i2s_hal_set_clk_div(i2s_hal_context_t *hal, int div_num, int div_a, int div_b, int tx_bck_div, int rx_bck_div);
|
||||
|
||||
/**
|
||||
* @brief Set I2S clock sel
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param sel clock sel
|
||||
*/
|
||||
#define i2s_hal_set_clock_sel(hal, sel) i2s_ll_set_clk_sel((hal)->dev, sel)
|
||||
|
||||
/**
|
||||
* @brief Set I2S tx bits mod
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param bits bit width per sample.
|
||||
*/
|
||||
void i2s_hal_set_tx_bits_mod(i2s_hal_context_t *hal, i2s_bits_per_sample_t bits);
|
||||
|
||||
/**
|
||||
* @brief Set I2S rx bits mod
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param bits bit width per sample.
|
||||
*/
|
||||
void i2s_hal_set_rx_bits_mod(i2s_hal_context_t *hal, i2s_bits_per_sample_t bits);
|
||||
|
||||
/**
|
||||
* @brief Reset I2S TX & RX module, including DMA and FIFO
|
||||
* @brief Reset I2S RX channel
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
void i2s_hal_reset(i2s_hal_context_t *hal);
|
||||
#define i2s_hal_reset_rx(hal) i2s_ll_rx_reset((hal)->dev)
|
||||
|
||||
/**
|
||||
* @brief Start I2S tx
|
||||
* @brief Reset I2S RX fifo
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
void i2s_hal_start_tx(i2s_hal_context_t *hal);
|
||||
#define i2s_hal_reset_rx_fifo(hal) i2s_ll_rx_reset_fifo((hal)->dev)
|
||||
|
||||
/**
|
||||
* @brief Start I2S rx
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
void i2s_hal_start_rx(i2s_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* @brief Stop I2S tx
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
void i2s_hal_stop_tx(i2s_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* @brief Stop I2S rx
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
void i2s_hal_stop_rx(i2s_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* @brief Config I2S param
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param i2s_config I2S configurations - see i2s_config_t struct
|
||||
*/
|
||||
void i2s_hal_config_param(i2s_hal_context_t *hal, const i2s_config_t *i2s_config);
|
||||
|
||||
/**
|
||||
* @brief Enable I2S sig loopback
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
#define i2s_hal_enable_sig_loopback(hal) i2s_ll_set_sig_loopback((hal)->dev, 1)
|
||||
|
||||
/**
|
||||
* @brief Enable I2S master mode
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
void i2s_hal_enable_master_mode(i2s_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* @brief Enable I2S slave mode
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
void i2s_hal_enable_slave_mode(i2s_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* @brief Init the I2S hal and set the I2S to the default configuration. This function should be called first before other hal layer function is called
|
||||
* @brief Get I2S hardware instance and enable I2S module clock
|
||||
* @note This function should be called first before other hal layer function is called
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param i2s_num The uart port number, the max port number is (I2S_NUM_MAX -1)
|
||||
*/
|
||||
void i2s_hal_init(i2s_hal_context_t *hal, int i2s_num);
|
||||
|
||||
#if SOC_I2S_SUPPORTS_PDM
|
||||
/**
|
||||
* @brief Set I2S tx pdm
|
||||
* @brief Configure I2S source clock
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param fp tx pdm fp
|
||||
* @param fs tx pdm fs
|
||||
* @param sel The source clock index
|
||||
*/
|
||||
void i2s_hal_tx_pdm_cfg(i2s_hal_context_t *hal, uint32_t fp, uint32_t fs);
|
||||
void i2s_hal_set_clock_src(i2s_hal_context_t *hal, i2s_clock_src_t sel);
|
||||
|
||||
/**
|
||||
* @brief Get I2S tx pdm
|
||||
* @brief Set Tx channel style
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param dsr rx pdm dsr
|
||||
* @param hal_cfg I2S hal configuration structer, refer to `i2s_hal_config_t`
|
||||
*/
|
||||
void i2s_hal_rx_pdm_cfg(i2s_hal_context_t *hal, uint32_t dsr);
|
||||
void i2s_hal_tx_set_channel_style(i2s_hal_context_t *hal, const i2s_hal_config_t *hal_cfg);
|
||||
|
||||
/**
|
||||
* @brief Get I2S tx pdm configuration
|
||||
* @brief Set Rx channel style
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param fp Pointer to receive tx PDM fp configuration
|
||||
* @param fs Pointer to receive tx PDM fs configuration
|
||||
* @param hal_cfg I2S hal configuration structer, refer to `i2s_hal_config_t`
|
||||
*/
|
||||
void i2s_hal_get_tx_pdm(i2s_hal_context_t *hal, uint32_t *fp, uint32_t *fs);
|
||||
void i2s_hal_rx_set_channel_style(i2s_hal_context_t *hal, const i2s_hal_config_t *hal_cfg);
|
||||
|
||||
/**
|
||||
* @brief Get I2S rx pdm configuration
|
||||
* @brief Initialize I2S hardware
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param dsr rx pdm dsr
|
||||
* @param hal_cfg I2S hal configuration structer, refer to `i2s_hal_config_t`
|
||||
*/
|
||||
void i2s_hal_get_rx_pdm(i2s_hal_context_t *hal, uint32_t *dsr);
|
||||
void i2s_hal_config_param(i2s_hal_context_t *hal, const i2s_hal_config_t *hal_cfg);
|
||||
|
||||
/**
|
||||
* @brief Enable I2S master full-duplex mode
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
void i2s_hal_enable_master_fd_mode(i2s_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* @brief Enable I2S slave full-duplex mode
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
void i2s_hal_enable_slave_fd_mode(i2s_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* @brief Start I2S tx
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
#define i2s_hal_start_tx(hal) i2s_ll_tx_start((hal)->dev)
|
||||
|
||||
/**
|
||||
* @brief Start I2S rx
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
#define i2s_hal_start_rx(hal) i2s_ll_rx_start((hal)->dev)
|
||||
|
||||
/**
|
||||
* @brief Stop I2S tx
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
#define i2s_hal_stop_tx(hal) i2s_ll_tx_stop((hal)->dev)
|
||||
|
||||
/**
|
||||
* @brief Stop I2S rx
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
#define i2s_hal_stop_rx(hal) i2s_ll_rx_stop((hal)->dev)
|
||||
|
||||
/**
|
||||
* @brief Set the received data length to trigger `in_suc_eof` interrupt.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param eof_byte The byte length that trigger in_suc_eof interrupt.
|
||||
*/
|
||||
#define i2s_hal_set_rx_eof_num(hal, eof_byte) i2s_ll_rx_set_eof_num((hal)->dev, eof_byte)
|
||||
|
||||
/**
|
||||
* @brief Set I2S TX sample bit
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param chan_bit I2S TX chan bit
|
||||
* @param data_bit The sample data bit length.
|
||||
*/
|
||||
#define i2s_hal_set_tx_sample_bit(hal, chan_bit, data_bit) i2s_ll_tx_set_sample_bit((hal)->dev, chan_bit, data_bit)
|
||||
|
||||
/**
|
||||
* @brief Set I2S RX sample bit
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param chan_bit I2S RX chan bit
|
||||
* @param data_bit The sample data bit length.
|
||||
*/
|
||||
#define i2s_hal_set_rx_sample_bit(hal, chan_bit, data_bit) i2s_ll_rx_set_sample_bit((hal)->dev, chan_bit, data_bit)
|
||||
|
||||
/**
|
||||
* @brief Configure I2S TX module clock devider
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param clk_cfg I2S clock configuration
|
||||
*/
|
||||
void i2s_hal_tx_clock_config(i2s_hal_context_t *hal, i2s_hal_clock_cfg_t *clk_cfg);
|
||||
|
||||
/**
|
||||
* @brief Configure I2S RX module clock devider
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param clk_cfg I2S clock configuration
|
||||
*/
|
||||
void i2s_hal_rx_clock_config(i2s_hal_context_t *hal, i2s_hal_clock_cfg_t *clk_cfg);
|
||||
|
||||
/**
|
||||
* @brief Set I2S tx clock source
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param clk_src i2s tx clock source (see 'i2s_clock_src_t')
|
||||
*/
|
||||
#define i2s_hal_tx_set_clock_source(hal, clk_src) i2s_ll_tx_clk_set_src((hal)->dev, clk_src)
|
||||
|
||||
/**
|
||||
* @brief Set I2S rx clock source
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param clk_src i2s rx clock source (see 'i2s_clock_src_t')
|
||||
*/
|
||||
#define i2s_hal_rx_set_clock_source(hal, clk_src) i2s_ll_rx_clk_set_src((hal)->dev, clk_src)
|
||||
|
||||
/**
|
||||
* @brief Enable I2S tx slave mode
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param enable set 'true' to enable tx slave mode
|
||||
*/
|
||||
#define i2s_hal_tx_enable_slave_mode(hal, enable) i2s_ll_tx_set_slave_mod((hal)->dev, enable)
|
||||
|
||||
/**
|
||||
* @brief Enable I2S rx slave mode
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param enable set 'true' to enable rx slave mode
|
||||
*/
|
||||
#define i2s_hal_rx_enable_slave_mode(hal, enable) i2s_ll_rx_set_slave_mod((hal)->dev, enable)
|
||||
|
||||
/**
|
||||
* @brief Enable loopback mode
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
#define i2s_hal_enable_sig_loopback(hal) i2s_ll_share_bck_ws((hal)->dev, true)
|
||||
|
||||
/**
|
||||
* @brief Set I2S configuration for common TX mode
|
||||
* @note Common mode is for non-PDM mode like philip/MSB/PCM
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param hal_cfg hal configuration structure
|
||||
*/
|
||||
void i2s_hal_tx_set_common_mode(i2s_hal_context_t *hal, const i2s_hal_config_t *hal_cfg);
|
||||
|
||||
/**
|
||||
* @brief Set I2S configuration for common RX mode
|
||||
* @note Common mode is for non-PDM mode like philip/MSB/PCM
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param hal_cfg hal configuration structure
|
||||
*/
|
||||
void i2s_hal_rx_set_common_mode(i2s_hal_context_t *hal, const i2s_hal_config_t *hal_cfg);
|
||||
|
||||
#if SOC_I2S_SUPPORTS_PCM
|
||||
/**
|
||||
* @brief Configure I2S TX PCM encoder or decoder.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param cfg PCM configure paramater, refer to `i2s_pcm_compress_t`
|
||||
*/
|
||||
#define i2s_hal_tx_pcm_cfg(hal, cfg) i2s_ll_tx_set_pcm_type((hal)->dev, cfg)
|
||||
|
||||
/**
|
||||
* @brief Configure I2S RX PCM encoder or decoder.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param cfg PCM configure paramater, refer to `i2s_pcm_compress_t`
|
||||
*/
|
||||
#define i2s_hal_rx_pcm_cfg(hal, cfg) i2s_ll_rx_set_pcm_type((hal)->dev, cfg)
|
||||
#endif
|
||||
|
||||
#if SOC_I2S_SUPPORTS_PDM_TX
|
||||
/**
|
||||
* @brief Configure I2S TX PDM sample rate
|
||||
* Fpdm = 64*Fpcm*fp/fs
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param fp TX PDM fp paramater configuration
|
||||
* @param fs TX PDM fs paramater configuration
|
||||
*/
|
||||
#define i2s_hal_set_tx_pdm_fpfs(hal, fp, fs) i2s_ll_tx_set_pdm_fpfs((hal)->dev, fp, fs)
|
||||
|
||||
/**
|
||||
* @brief Get I2S TX PDM fp
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @return
|
||||
* - fp configuration paramater
|
||||
*/
|
||||
#define i2s_hal_get_tx_pdm_fp(hal) i2s_ll_tx_get_pdm_fp((hal)->dev)
|
||||
|
||||
/**
|
||||
* @brief Get I2S TX PDM fs
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @return
|
||||
* - fs configuration paramater
|
||||
*/
|
||||
#define i2s_hal_get_tx_pdm_fs(hal) i2s_ll_tx_get_pdm_fs((hal)->dev)
|
||||
|
||||
/**
|
||||
* @brief Set I2S default configuration for PDM TX mode
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param sample_rate PDM sample rate
|
||||
*/
|
||||
void i2s_hal_tx_set_pdm_mode_default(i2s_hal_context_t *hal, uint32_t sample_rate);
|
||||
#endif
|
||||
|
||||
#if SOC_I2S_SUPPORTS_PDM_RX
|
||||
|
||||
/**
|
||||
* @brief Configure RX PDM downsample
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param dsr PDM downsample configuration paramater
|
||||
*/
|
||||
#define i2s_hal_set_rx_pdm_dsr(hal, dsr) i2s_ll_rx_set_pdm_dsr((hal)->dev, dsr)
|
||||
|
||||
/**
|
||||
* @brief Get RX PDM downsample configuration
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param dsr Pointer to accept PDM downsample configuration
|
||||
*/
|
||||
#define i2s_hal_get_rx_pdm_dsr(hal, dsr) i2s_ll_rx_get_pdm_dsr((hal)->dev, dsr)
|
||||
|
||||
/**
|
||||
* @brief Set I2S default configuration for PDM R mode
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
void i2s_hal_rx_set_pdm_mode_default(i2s_hal_context_t *hal);
|
||||
#endif
|
||||
|
||||
#if !SOC_GDMA_SUPPORTED
|
||||
/**
|
||||
* @brief Enable I2S TX DMA
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
#define i2s_hal_enable_tx_dma(hal) i2s_ll_enable_dma((hal)->dev,true)
|
||||
|
||||
/**
|
||||
* @brief Enable I2S RX DMA
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
#define i2s_hal_enable_rx_dma(hal) i2s_ll_enable_dma((hal)->dev,true)
|
||||
|
||||
/**
|
||||
* @brief Disable I2S TX DMA
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
#define i2s_hal_disable_tx_dma(hal) i2s_ll_enable_dma((hal)->dev,false)
|
||||
|
||||
/**
|
||||
* @brief Disable I2S RX DMA
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
#define i2s_hal_disable_rx_dma(hal) i2s_ll_enable_dma((hal)->dev,false)
|
||||
|
||||
/**
|
||||
* @brief Get I2S interrupt status
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @return
|
||||
* - module interrupt status
|
||||
*/
|
||||
#define i2s_hal_get_intr_status(hal) i2s_ll_get_intr_status((hal)->dev)
|
||||
|
||||
/**
|
||||
* @brief Get I2S interrupt status
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param mask Interrupt mask to be cleared.
|
||||
*/
|
||||
#define i2s_hal_clear_intr_status(hal, mask) i2s_ll_clear_intr_status((hal)->dev, mask)
|
||||
|
||||
/**
|
||||
* @brief Enable I2S RX interrupt
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
#define i2s_hal_enable_rx_intr(hal) i2s_ll_rx_enable_intr((hal)->dev)
|
||||
|
||||
/**
|
||||
* @brief Disable I2S RX interrupt
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
#define i2s_hal_disable_rx_intr(hal) i2s_ll_rx_disable_intr((hal)->dev)
|
||||
|
||||
/**
|
||||
* @brief Disable I2S TX interrupt
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
#define i2s_hal_disable_tx_intr(hal) i2s_ll_tx_disable_intr((hal)->dev)
|
||||
|
||||
/**
|
||||
* @brief Enable I2S TX interrupt
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
#define i2s_hal_enable_tx_intr(hal) i2s_ll_tx_enable_intr((hal)->dev)
|
||||
|
||||
/**
|
||||
* @brief Configure TX DMA descriptor address and start TX DMA
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param link_addr DMA descriptor link address.
|
||||
*/
|
||||
#define i2s_hal_start_tx_link(hal, link_addr) i2s_ll_tx_start_link((hal)->dev, link_addr)
|
||||
|
||||
/**
|
||||
* @brief Configure RX DMA descriptor address and start RX DMA
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param link_addr DMA descriptor link address.
|
||||
*/
|
||||
#define i2s_hal_start_rx_link(hal, link_addr) i2s_ll_rx_start_link((hal)->dev, link_addr)
|
||||
|
||||
/**
|
||||
* @brief Stop TX DMA link
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
#define i2s_hal_stop_tx_link(hal) i2s_ll_tx_stop_link((hal)->dev)
|
||||
|
||||
/**
|
||||
* @brief Stop RX DMA link
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
#define i2s_hal_stop_rx_link(hal) i2s_ll_rx_stop_link((hal)->dev)
|
||||
|
||||
/**
|
||||
* @brief Reset RX DMA
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
#define i2s_hal_reset_rxdma(hal) i2s_ll_rx_reset_dma((hal)->dev)
|
||||
|
||||
/**
|
||||
* @brief Reset TX DMA
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
#define i2s_hal_reset_txdma(hal) i2s_ll_tx_reset_dma((hal)->dev)
|
||||
|
||||
/**
|
||||
* @brief Get I2S out eof descriptor address
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param addr Pointer to accept out eof des address
|
||||
*/
|
||||
#define i2s_hal_get_out_eof_des_addr(hal, addr) i2s_ll_tx_get_eof_des_addr((hal)->dev, addr)
|
||||
|
||||
/**
|
||||
* @brief Get I2S in suc eof descriptor address
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param addr Pointer to accept in suc eof des address
|
||||
*/
|
||||
#define i2s_hal_get_in_eof_des_addr(hal, addr) i2s_ll_rx_get_eof_des_addr((hal)->dev, addr)
|
||||
#endif
|
||||
|
||||
#if SOC_I2S_SUPPORTS_ADC
|
||||
/**
|
||||
* @brief Enable Builtin DAC
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
#define i2s_hal_enable_builtin_dac(hal) i2s_ll_enable_builtin_dac((hal)->dev, true);
|
||||
|
||||
/**
|
||||
* @brief Enable Builtin ADC
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
#define i2s_hal_enable_builtin_adc(hal) i2s_ll_enable_builtin_adc((hal)->dev, true);
|
||||
|
||||
/**
|
||||
* @brief Disable Builtin ADC
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
#define i2s_hal_disable_builtin_adc(hal) i2s_ll_enable_builtin_adc((hal)->dev, false);
|
||||
#endif
|
||||
|
||||
#if SOC_I2S_SUPPORTS_DAC
|
||||
/**
|
||||
* @brief Disable Builtin DAC
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
#define i2s_hal_disable_builtin_dac(hal) i2s_ll_enable_builtin_dac((hal)->dev, false);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD
|
||||
// Copyright 2020 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.
|
||||
@ -16,6 +16,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include "soc/soc_caps.h"
|
||||
|
||||
@ -23,35 +24,60 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief I2S port number, the max port number is (I2S_NUM_MAX -1).
|
||||
*/
|
||||
typedef enum {
|
||||
I2S_NUM_0 = 0, /*!< I2S port 0 */
|
||||
#if SOC_I2S_NUM > 1
|
||||
I2S_NUM_1 = 1, /*!< I2S port 1 */
|
||||
#endif
|
||||
I2S_NUM_MAX, /*!< I2S port max */
|
||||
} i2s_port_t;
|
||||
|
||||
/**
|
||||
* @brief I2S bit width per sample.
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
I2S_BITS_PER_SAMPLE_8BIT = 8, /*!< I2S bits per sample: 8-bits*/
|
||||
I2S_BITS_PER_SAMPLE_16BIT = 16, /*!< I2S bits per sample: 16-bits*/
|
||||
I2S_BITS_PER_SAMPLE_24BIT = 24, /*!< I2S bits per sample: 24-bits*/
|
||||
I2S_BITS_PER_SAMPLE_32BIT = 32, /*!< I2S bits per sample: 32-bits*/
|
||||
I2S_BITS_PER_SAMPLE_8BIT = 8, /*!< data bit-width: 8 */
|
||||
I2S_BITS_PER_SAMPLE_16BIT = 16, /*!< data bit-width: 16 */
|
||||
I2S_BITS_PER_SAMPLE_24BIT = 24, /*!< data bit-width: 24 */
|
||||
I2S_BITS_PER_SAMPLE_32BIT = 32, /*!< data bit-width: 32 */
|
||||
} i2s_bits_per_sample_t;
|
||||
|
||||
/**
|
||||
* @brief I2S bit width per chan.
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
I2S_BITS_PER_CHAN_DEFAULT = (0), /*!< channel bit-width equals to data bit-width */
|
||||
I2S_BITS_PER_CHAN_8BIT = (8), /*!< channel bit-width: 8 */
|
||||
I2S_BITS_PER_CHAN_16BIT = (16), /*!< channel bit-width: 16 */
|
||||
I2S_BITS_PER_CHAN_24BIT = (24), /*!< channel bit-width: 24 */
|
||||
I2S_BITS_PER_CHAN_32BIT = (32), /*!< channel bit-width: 32 */
|
||||
} i2s_bits_per_chan_t;
|
||||
|
||||
/**
|
||||
* @brief I2S channel.
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
I2S_CHANNEL_MONO = 1, /*!< I2S 1 channel (mono)*/
|
||||
I2S_CHANNEL_STEREO = 2 /*!< I2S 2 channel (stereo)*/
|
||||
I2S_CHANNEL_MONO = (0x01 << 31) | 0x03, /*!< I2S channel (mono), two channel enabled. In this mode, you only need to send one channel data but the fifo will copy same data for another channel automatically, then both channels will transmit same data. The highest bit is for differentiating I2S_CHANNEL_STEREO since they both use two channels */
|
||||
I2S_CHANNEL_STEREO = 0x03, /*!< I2S channel (stereo), two channel enabled. In this mode, two channels will transmit different data. */
|
||||
#if SOC_I2S_SUPPORTS_TDM
|
||||
// Bit map of active chan.
|
||||
// There are 16 channels in TDM mode.
|
||||
// For TX module, only the active channel send the audio data, the inactive channel send a constant(configurable) or will be skiped if 'skip_msk' is set.
|
||||
// For RX module, only receive the audio data in active channels, the data in inactive channels will be ignored.
|
||||
// the bit map of active channel can not exceed (0x1<<total_chan_num).
|
||||
// e.g: active_chan_mask = (I2S_TDM_ACTIVE_CH0 | I2S_TDM_ACTIVE_CH3), here the active_chan_number is 2 and total_chan_num is not supposed to be smaller than 4.
|
||||
I2S_TDM_ACTIVE_CH0 = (0x1 << 0), /*!< I2S channel 0 enabled */
|
||||
I2S_TDM_ACTIVE_CH1 = (0x1 << 1), /*!< I2S channel 1 enabled */
|
||||
I2S_TDM_ACTIVE_CH2 = (0x1 << 2), /*!< I2S channel 2 enabled */
|
||||
I2S_TDM_ACTIVE_CH3 = (0x1 << 3), /*!< I2S channel 3 enabled */
|
||||
I2S_TDM_ACTIVE_CH4 = (0x1 << 4), /*!< I2S channel 4 enabled */
|
||||
I2S_TDM_ACTIVE_CH5 = (0x1 << 5), /*!< I2S channel 5 enabled */
|
||||
I2S_TDM_ACTIVE_CH6 = (0x1 << 6), /*!< I2S channel 6 enabled */
|
||||
I2S_TDM_ACTIVE_CH7 = (0x1 << 7), /*!< I2S channel 7 enabled */
|
||||
I2S_TDM_ACTIVE_CH8 = (0x1 << 8), /*!< I2S channel 8 enabled */
|
||||
I2S_TDM_ACTIVE_CH9 = (0x1 << 9), /*!< I2S channel 9 enabled */
|
||||
I2S_TDM_ACTIVE_CH10 = (0x1 << 10), /*!< I2S channel 10 enabled */
|
||||
I2S_TDM_ACTIVE_CH11 = (0x1 << 11), /*!< I2S channel 11 enabled */
|
||||
I2S_TDM_ACTIVE_CH12 = (0x1 << 12), /*!< I2S channel 12 enabled */
|
||||
I2S_TDM_ACTIVE_CH13 = (0x1 << 13), /*!< I2S channel 13 enabled */
|
||||
I2S_TDM_ACTIVE_CH14 = (0x1 << 14), /*!< I2S channel 14 enabled */
|
||||
I2S_TDM_ACTIVE_CH15 = (0x1 << 15), /*!< I2S channel 15 enabled */
|
||||
#endif
|
||||
} i2s_channel_t;
|
||||
|
||||
/**
|
||||
@ -59,12 +85,11 @@ typedef enum {
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
// In order to keep compatibility, remain the old definitions and introduce new definitions,
|
||||
I2S_COMM_FORMAT_STAND_I2S = 0X01, /*!< I2S communication I2S Philips standard, data launch at second BCK*/
|
||||
I2S_COMM_FORMAT_STAND_MSB = 0X03, /*!< I2S communication MSB alignment standard, data launch at first BCK*/
|
||||
I2S_COMM_FORMAT_STAND_I2S = 0X01, /*!< I2S communication I2S Philips standard, data launch at second BCK*/
|
||||
I2S_COMM_FORMAT_STAND_MSB = 0X02, /*!< I2S communication MSB alignment standard, data launch at first BCK*/
|
||||
I2S_COMM_FORMAT_STAND_PCM_SHORT = 0x04, /*!< PCM Short standard, also known as DSP mode. The period of synchronization signal (WS) is 1 bck cycle.*/
|
||||
I2S_COMM_FORMAT_STAND_PCM_LONG = 0x0C, /*!< PCM Long standard. The period of synchronization signal (WS) is channel_bit*bck cycles.*/
|
||||
I2S_COMM_FORMAT_STAND_MAX, /*!< standard max*/
|
||||
I2S_COMM_FORMAT_STAND_MAX, /*!< standard max*/
|
||||
|
||||
//old definition will be removed in the future.
|
||||
I2S_COMM_FORMAT_I2S __attribute__((deprecated)) = 0x01, /*!< I2S communication format I2S, correspond to `I2S_COMM_FORMAT_STAND_I2S`*/
|
||||
@ -79,76 +104,61 @@ typedef enum {
|
||||
* @brief I2S channel format type
|
||||
*/
|
||||
typedef enum {
|
||||
I2S_CHANNEL_FMT_RIGHT_LEFT = 0x00,
|
||||
I2S_CHANNEL_FMT_ALL_RIGHT,
|
||||
I2S_CHANNEL_FMT_ALL_LEFT,
|
||||
I2S_CHANNEL_FMT_ONLY_RIGHT,
|
||||
I2S_CHANNEL_FMT_ONLY_LEFT,
|
||||
} i2s_channel_fmt_t;
|
||||
I2S_CHANNEL_FMT_RIGHT_LEFT, /*!< Separated left and right channel */
|
||||
I2S_CHANNEL_FMT_ALL_RIGHT, /*!< Load right channel data in both two channels */
|
||||
I2S_CHANNEL_FMT_ALL_LEFT, /*!< Load left channel data in both two channels */
|
||||
I2S_CHANNEL_FMT_ONLY_RIGHT, /*!< Only load data in right channel (mono mode) */
|
||||
I2S_CHANNEL_FMT_ONLY_LEFT, /*!< Only load data in left channel (mono mode) */
|
||||
#if SOC_I2S_SUPPORTS_TDM
|
||||
// Multiple channels are available with TDM feature
|
||||
I2S_CHANNEL_FMT_MULTIPLE, /*!< More than two channels are used */
|
||||
#endif
|
||||
} i2s_channel_fmt_t;
|
||||
|
||||
/**
|
||||
* @brief I2S Mode, defaut is I2S_MODE_MASTER | I2S_MODE_TX
|
||||
*
|
||||
* @note PDM and built-in DAC functions are only supported on I2S0 for current ESP32 chip.
|
||||
*
|
||||
* @brief I2S Mode
|
||||
*/
|
||||
typedef enum {
|
||||
I2S_MODE_MASTER = 1, /*!< Master mode*/
|
||||
I2S_MODE_SLAVE = 2, /*!< Slave mode*/
|
||||
I2S_MODE_TX = 4, /*!< TX mode*/
|
||||
I2S_MODE_RX = 8, /*!< RX mode*/
|
||||
#if SOC_I2S_SUPPORTS_ADC_DAC
|
||||
I2S_MODE_DAC_BUILT_IN = 16, /*!< Output I2S data to built-in DAC, no matter the data format is 16bit or 32 bit, the DAC module will only take the 8bits from MSB*/
|
||||
I2S_MODE_ADC_BUILT_IN = 32, /*!< Input I2S data from built-in ADC, each data can be 12-bit width at most*/
|
||||
#endif
|
||||
#if SOC_I2S_SUPPORTS_PDM
|
||||
I2S_MODE_PDM = 64, /*!< PDM mode*/
|
||||
#endif
|
||||
I2S_MODE_MASTER = (0x1 << 0), /*!< Master mode*/
|
||||
I2S_MODE_SLAVE = (0x1 << 1), /*!< Slave mode*/
|
||||
I2S_MODE_TX = (0x1 << 2), /*!< TX mode*/
|
||||
I2S_MODE_RX = (0x1 << 3), /*!< RX mode*/
|
||||
#if SOC_I2S_SUPPORTS_DAC
|
||||
//built-in DAC functions are only supported on I2S0 for ESP32 chip.
|
||||
I2S_MODE_DAC_BUILT_IN = (0x1 << 4), /*!< Output I2S data to built-in DAC, no matter the data format is 16bit or 32 bit, the DAC module will only take the 8bits from MSB*/
|
||||
#endif // SOC_I2S_SUPPORTS_DAC
|
||||
#if SOC_I2S_SUPPORTS_ADC
|
||||
I2S_MODE_ADC_BUILT_IN = (0x1 << 5), /*!< Input I2S data from built-in ADC, each data can be 12-bit width at most*/
|
||||
#endif // SOC_I2S_SUPPORTS_ADC
|
||||
// PDM functions are only supported on I2S0 (all chips).
|
||||
I2S_MODE_PDM = (0x1 << 6), /*!< I2S PDM mode*/
|
||||
} i2s_mode_t;
|
||||
|
||||
/**
|
||||
* @brief I2S source clock
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
I2S_CLK_D2CLK = 0, /*!< Clock from PLL_D2_CLK(160M)*/
|
||||
#if SOC_I2S_SUPPORTS_APLL
|
||||
I2S_CLK_APLL, /*!< Clock from APLL*/
|
||||
#endif
|
||||
} i2s_clock_src_t;
|
||||
|
||||
/**
|
||||
* @brief I2S configuration parameters for i2s_param_config function
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
i2s_mode_t mode; /*!< I2S work mode*/
|
||||
int sample_rate; /*!< I2S sample rate*/
|
||||
i2s_bits_per_sample_t bits_per_sample; /*!< I2S bits per sample*/
|
||||
i2s_channel_fmt_t channel_format; /*!< I2S channel format */
|
||||
i2s_comm_format_t communication_format; /*!< I2S communication format */
|
||||
int intr_alloc_flags; /*!< Flags used to allocate the interrupt. One or multiple (ORred) ESP_INTR_FLAG_* values. See esp_intr_alloc.h for more info */
|
||||
int dma_buf_count; /*!< I2S DMA Buffer Count */
|
||||
int dma_buf_len; /*!< I2S DMA Buffer Length */
|
||||
bool use_apll; /*!< I2S using APLL as main I2S clock, enable it to get accurate clock */
|
||||
bool tx_desc_auto_clear; /*!< I2S auto clear tx descriptor if there is underflow condition (helps in avoiding noise in case of data unavailability) */
|
||||
int fixed_mclk; /*!< I2S using fixed MCLK output. If use_apll = true and fixed_mclk > 0, then the clock output for i2s is fixed and equal to the fixed_mclk value.*/
|
||||
} i2s_config_t;
|
||||
|
||||
/**
|
||||
* @brief I2S event types
|
||||
*
|
||||
* @brief The multiple of mclk to sample rate
|
||||
*/
|
||||
typedef enum {
|
||||
I2S_EVENT_DMA_ERROR,
|
||||
I2S_EVENT_TX_DONE, /*!< I2S DMA finish sent 1 buffer*/
|
||||
I2S_EVENT_RX_DONE, /*!< I2S DMA finish received 1 buffer*/
|
||||
I2S_EVENT_MAX, /*!< I2S event max index*/
|
||||
} i2s_event_type_t;
|
||||
I2S_MCLK_MULTIPLE_DEFAULT = 0, /*!< Default value. mclk = sample_rate * 256 */
|
||||
I2S_MCLK_MULTIPLE_128 = 128, /*!< mclk = sample_rate * 128 */
|
||||
I2S_MCLK_MULTIPLE_256 = 256, /*!< mclk = sample_rate * 256 */
|
||||
I2S_MCLK_MULTIPLE_384 = 384, /*!< mclk = sample_rate * 384 */
|
||||
} i2s_mclk_multiple_t;
|
||||
|
||||
#if SOC_I2S_SUPPORTS_ADC_DAC
|
||||
#if SOC_I2S_SUPPORTS_DAC
|
||||
/**
|
||||
* @brief I2S DAC mode for i2s_set_dac_mode.
|
||||
*
|
||||
* @note PDM and built-in DAC functions are only supported on I2S0 for current ESP32 chip.
|
||||
* @note Built-in DAC functions are only supported on I2S0 for current ESP32 chip.
|
||||
*/
|
||||
typedef enum {
|
||||
I2S_DAC_CHANNEL_DISABLE = 0, /*!< Disable I2S built-in DAC signals*/
|
||||
@ -157,29 +167,23 @@ typedef enum {
|
||||
I2S_DAC_CHANNEL_BOTH_EN = 0x3, /*!< Enable both of the I2S built-in DAC channels.*/
|
||||
I2S_DAC_CHANNEL_MAX = 0x4, /*!< I2S built-in DAC mode max index*/
|
||||
} i2s_dac_mode_t;
|
||||
#endif //SOC_I2S_SUPPORTS_ADC_DAC
|
||||
#endif //SOC_I2S_SUPPORTS_DAC
|
||||
|
||||
#if SOC_I2S_SUPPORTS_PCM
|
||||
/**
|
||||
* @brief Event structure used in I2S event queue
|
||||
* @brief A/U-law decompress or compress configuration.
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
i2s_event_type_t type; /*!< I2S event type */
|
||||
size_t size; /*!< I2S data size for I2S_DATA event*/
|
||||
} i2s_event_t;
|
||||
typedef enum {
|
||||
I2S_PCM_DISABLE = 0, /*!< Disable A/U law decopress or compress*/
|
||||
I2S_PCM_A_DECOMPRESS, /*!< A-law decompress*/
|
||||
I2S_PCM_A_COMPRESS, /*!< A-law compress*/
|
||||
I2S_PCM_U_DECOMPRESS, /*!< U-law decompress*/
|
||||
I2S_PCM_U_COMPRESS, /*!< U-law compress*/
|
||||
} i2s_pcm_compress_t;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief I2S pin number for i2s_set_pin
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
int bck_io_num; /*!< BCK in out pin*/
|
||||
int ws_io_num; /*!< WS in out pin*/
|
||||
int data_out_num; /*!< DATA out pin*/
|
||||
int data_in_num; /*!< DATA in pin*/
|
||||
} i2s_pin_config_t;
|
||||
|
||||
#if SOC_I2S_SUPPORTS_PDM
|
||||
#if SOC_I2S_SUPPORTS_PDM_RX
|
||||
/**
|
||||
* @brief I2S PDM RX downsample mode
|
||||
*/
|
||||
@ -188,17 +192,16 @@ typedef enum {
|
||||
I2S_PDM_DSR_16S, /*!< downsampling number is 16 for PDM RX mode*/
|
||||
I2S_PDM_DSR_MAX,
|
||||
} i2s_pdm_dsr_t;
|
||||
|
||||
/**
|
||||
* @brief PDM PCM convter enable/disable.
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
PDM_PCM_CONV_ENABLE, /*!< Enable PDM PCM convert*/
|
||||
PDM_PCM_CONV_DISABLE, /*!< Disable PDM PCM convert*/
|
||||
} pdm_pcm_conv_t;
|
||||
#endif
|
||||
|
||||
#if SOC_I2S_SUPPORTS_PDM_TX
|
||||
typedef enum {
|
||||
I2S_PDM_SIG_SCALING_DIV_2 = 0, /*!< I2S TX PDM sigmadelta signal scaling: /2 */
|
||||
I2S_PDM_SIG_SCALING_MUL_1 = 1, /*!< I2S TX PDM sigmadelta signal scaling: x1 */
|
||||
I2S_PDM_SIG_SCALING_MUL_2 = 2, /*!< I2S TX PDM sigmadelta signal scaling: x2 */
|
||||
I2S_PDM_SIG_SCALING_MUL_4 = 3, /*!< I2S TX PDM sigmadelta signal scaling: x4 */
|
||||
} i2s_pdm_sig_scale_t;
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -24,10 +24,10 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "soc/lcd_cam_struct.h"
|
||||
typedef struct lcd_cam_dev_t *lcd_soc_handle_t;
|
||||
|
||||
typedef struct {
|
||||
lcd_cam_dev_t *dev;
|
||||
lcd_soc_handle_t dev;
|
||||
} lcd_hal_context_t;
|
||||
|
||||
void lcd_hal_init(lcd_hal_context_t *hal, int id);
|
||||
|
42
tools/sdk/esp32/include/hal/include/hal/lcd_types.h
Normal file
42
tools/sdk/esp32/include/hal/include/hal/lcd_types.h
Normal file
@ -0,0 +1,42 @@
|
||||
// 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
|
||||
|
||||
/**
|
||||
* @brief LCD clock source
|
||||
* @note User should select the clock source based on the real requirement:
|
||||
* ╔═════════════════════╦══════════════════════════╦════════════════════════════╗
|
||||
* ║ LCD clock source ║ Features ║ Power Management ║
|
||||
* ╠═════════════════════╬══════════════════════════╬════════════════════════════╣
|
||||
* ║ LCD_CLK_SRC_PLL160M ║ High resolution, fixed ║ ESP_PM_APB_FREQ_MAX lock ║
|
||||
* ╠═════════════════════╬══════════════════════════╬════════════════════════════╣
|
||||
* ║ LCD_CLK_SRC_APLL ║ Configurable resolution ║ ESP_PM_NO_LIGHT_SLEEP lock ║
|
||||
* ╠═════════════════════╬══════════════════════════╬════════════════════════════╣
|
||||
* ║ LCD_CLK_SRC_XTAL ║ Medium resolution, fixed ║ No PM lock ║
|
||||
* ╚═════════════════════╩══════════════════════════╩════════════════════════════╝
|
||||
*/
|
||||
typedef enum {
|
||||
LCD_CLK_SRC_PLL160M, /*!< Select PLL160M as the source clock */
|
||||
LCD_CLK_SRC_APLL, /*!< Select APLL as the source clock */
|
||||
LCD_CLK_SRC_XTAL, /*!< Select XTAL as the source clock */
|
||||
} lcd_clock_source_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -37,7 +37,7 @@ typedef enum {
|
||||
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;
|
||||
} mcpwm_timer_execute_cmd_t;
|
||||
|
||||
typedef enum {
|
||||
MCPWM_GEN_ACTION_KEEP, /*!< Generator action: Keep the same level */
|
||||
@ -47,6 +47,6 @@ typedef enum {
|
||||
} mcpwm_generator_action_t;
|
||||
|
||||
typedef enum {
|
||||
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;
|
||||
MCPWM_TRIP_TYPE_CBC, /*!< CBC trip type, shut down the operator cycle by cycle*/
|
||||
MCPWM_TRIP_TYPE_OST, /*!< OST trip type, shut down the operator in one shot */
|
||||
} mcpwm_trip_type_t;
|
||||
|
35
tools/sdk/esp32/include/hal/include/hal/memprot_types.h
Normal file
35
tools/sdk/esp32/include/hal/include/hal/memprot_types.h
Normal file
@ -0,0 +1,35 @@
|
||||
// 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.
|
||||
// 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
|
||||
|
||||
/**
|
||||
* @brief Memprot LL error codes
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
MEMP_LL_OK = 0,
|
||||
MEMP_LL_FAIL = 1,
|
||||
MEMP_LL_ERR_SPLIT_ADDR_INVALID = 2,
|
||||
MEMP_LL_ERR_SPLIT_ADDR_UNALIGNED = 3,
|
||||
MEMP_LL_ERR_UNI_BLOCK_INVALID = 4
|
||||
} memprot_ll_err_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -23,10 +23,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdio.h>
|
||||
#include "soc/pcnt_periph.h"
|
||||
#include "hal/pcnt_types.h"
|
||||
#include "hal/pcnt_ll.h"
|
||||
#include "soc/pcnt_struct.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -35,188 +32,18 @@ extern "C" {
|
||||
/**
|
||||
* Context that should be maintained by both the driver and the HAL
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
pcnt_dev_t *dev;
|
||||
pcnt_dev_t *dev; /*!< PCNT peripheral register base address */
|
||||
} pcnt_hal_context_t;
|
||||
|
||||
/**
|
||||
* @brief Set PCNT counter mode
|
||||
* @brief Init the PCNT hal and set the PCNT to the default configuration.
|
||||
* @note This function should be called first before other hal layer function is called.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param unit PCNT unit number
|
||||
* @param channel PCNT channel number
|
||||
* @param pos_mode Counter mode when detecting positive edge
|
||||
* @param neg_mode Counter mode when detecting negative edge
|
||||
* @param hctrl_mode Counter mode when control signal is high level
|
||||
* @param lctrl_mode Counter mode when control signal is low level
|
||||
* @param group_id PCNT group ID
|
||||
*/
|
||||
#define pcnt_hal_set_mode(hal, unit, channel, pos_mode, neg_mode, hctrl_mode, lctrl_mode) pcnt_ll_set_mode((hal)->dev, unit, channel, pos_mode, neg_mode, hctrl_mode, lctrl_mode)
|
||||
|
||||
/**
|
||||
* @brief Get pulse counter value
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param unit Pulse Counter unit number
|
||||
* @param count Pointer to accept counter value
|
||||
*/
|
||||
#define pcnt_hal_get_counter_value(hal, unit, count) pcnt_ll_get_counter_value((hal)->dev, unit, count)
|
||||
|
||||
/**
|
||||
* @brief Pause PCNT counter of PCNT unit
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param unit PCNT unit number
|
||||
*/
|
||||
#define pcnt_hal_counter_pause(hal, unit) pcnt_ll_counter_pause((hal)->dev, unit)
|
||||
|
||||
/**
|
||||
* @brief Resume counting for PCNT counter
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param unit PCNT unit number, select from unit_t
|
||||
*/
|
||||
#define pcnt_hal_counter_resume(hal, unit) pcnt_ll_counter_resume((hal)->dev, unit)
|
||||
|
||||
/**
|
||||
* @brief Clear and reset PCNT counter value to zero
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param unit PCNT unit number, select from unit_t
|
||||
*/
|
||||
#define pcnt_hal_counter_clear(hal, unit) pcnt_ll_counter_clear((hal)->dev, unit)
|
||||
|
||||
/**
|
||||
* @brief Enable PCNT interrupt for PCNT unit
|
||||
* @note
|
||||
* Each Pulse counter unit has five watch point events that share the same interrupt.
|
||||
* Configure events with pcnt_event_enable() and pcnt_event_disable()
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param unit PCNT unit number
|
||||
*/
|
||||
#define pcnt_hal_intr_enable(hal, unit) pcnt_ll_intr_enable((hal)->dev, unit)
|
||||
|
||||
/**
|
||||
* @brief Disable PCNT interrupt for PCNT unit
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param unit PCNT unit number
|
||||
*/
|
||||
#define pcnt_hal_intr_disable(hal, unit) pcnt_ll_intr_disable((hal)->dev, unit)
|
||||
|
||||
/**
|
||||
* @brief Get PCNT interrupt status
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param mask The interrupt status mask to be cleared. Pointer to accept value interrupt status mask.
|
||||
*/
|
||||
#define pcnt_hal_get_intr_status(hal, mask) pcnt_ll_get_intr_status((hal)->dev, mask)
|
||||
|
||||
/**
|
||||
* @brief Clear PCNT interrupt status
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param mask The interrupt status mask to be cleared.
|
||||
*/
|
||||
#define pcnt_hal_clear_intr_status(hal, mask) pcnt_ll_clear_intr_status((hal)->dev, mask)
|
||||
|
||||
/**
|
||||
* @brief Enable PCNT event of PCNT unit
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param unit PCNT unit number
|
||||
* @param evt_type Watch point event type.
|
||||
* All enabled events share the same interrupt (one interrupt per pulse counter unit).
|
||||
*/
|
||||
#define pcnt_hal_event_enable(hal, unit, evt_type) pcnt_ll_event_enable((hal)->dev, unit, evt_type)
|
||||
|
||||
/**
|
||||
* @brief Disable PCNT event of PCNT unit
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param unit PCNT unit number
|
||||
* @param evt_type Watch point event type.
|
||||
* All enabled events share the same interrupt (one interrupt per pulse counter unit).
|
||||
*/
|
||||
#define pcnt_hal_event_disable(hal, unit, evt_type) pcnt_ll_event_disable((hal)->dev, unit, evt_type)
|
||||
|
||||
/**
|
||||
* @brief Set PCNT event value of PCNT unit
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param unit PCNT unit number
|
||||
* @param evt_type Watch point event type.
|
||||
* All enabled events share the same interrupt (one interrupt per pulse counter unit).
|
||||
*
|
||||
* @param value Counter value for PCNT event
|
||||
*/
|
||||
#define pcnt_hal_set_event_value(hal, unit, evt_type, value) pcnt_ll_set_event_value((hal)->dev, unit, evt_type, value)
|
||||
|
||||
/**
|
||||
* @brief Get PCNT event value of PCNT unit
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param unit PCNT unit number
|
||||
* @param evt_type Watch point event type.
|
||||
* All enabled events share the same interrupt (one interrupt per pulse counter unit).
|
||||
* @param value Pointer to accept counter value for PCNT event
|
||||
*/
|
||||
#define pcnt_hal_get_event_value(hal, unit, evt_type, value) pcnt_ll_get_event_value((hal)->dev, unit, evt_type, value)
|
||||
|
||||
/**
|
||||
* @brief Get PCNT event status
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param unit PCNT unit number
|
||||
* @return event status word
|
||||
*/
|
||||
#define pcnt_hal_get_event_status(hal, unit) pcnt_ll_get_event_status((hal)->dev, unit)
|
||||
|
||||
/**
|
||||
* @brief Set PCNT filter value
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param unit PCNT unit number
|
||||
* @param filter_val PCNT signal filter value, counter in APB_CLK cycles.
|
||||
* Any pulses lasting shorter than this will be ignored when the filter is enabled.
|
||||
* @note
|
||||
* filter_val is a 10-bit value, so the maximum filter_val should be limited to 1023.
|
||||
*/
|
||||
#define pcnt_hal_set_filter_value(hal, unit, filter_val) pcnt_ll_set_filter_value((hal)->dev, unit, filter_val)
|
||||
|
||||
/**
|
||||
* @brief Get PCNT filter value
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param unit PCNT unit number
|
||||
* @param filter_val Pointer to accept PCNT filter value.
|
||||
*/
|
||||
#define pcnt_hal_get_filter_value(hal, unit, filter_val) pcnt_ll_get_filter_value((hal)->dev, unit, filter_val)
|
||||
|
||||
/**
|
||||
* @brief Enable PCNT input filter
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param unit PCNT unit number
|
||||
*/
|
||||
#define pcnt_hal_filter_enable(hal, unit) pcnt_ll_filter_enable((hal)->dev, unit)
|
||||
|
||||
/**
|
||||
* @brief Disable PCNT input filter
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param unit PCNT unit number
|
||||
*/
|
||||
#define pcnt_hal_filter_disable(hal, unit) pcnt_ll_filter_disable((hal)->dev, unit)
|
||||
|
||||
/**
|
||||
* @brief Init the PCNT hal and set the PCNT to the default configuration. This function should be called first before other hal layer function is called
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param pcnt_num The uart port number, the max port number is (PCNT_NUM_MAX -1)
|
||||
*/
|
||||
void pcnt_hal_init(pcnt_hal_context_t *hal, int pcnt_num);
|
||||
void pcnt_hal_init(pcnt_hal_context_t *hal, int group_id);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -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.
|
||||
@ -18,93 +18,36 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "soc/soc_caps.h"
|
||||
|
||||
#define PCNT_PIN_NOT_USED (-1) /*!< When selected for a pin, this pin will not be used */
|
||||
|
||||
/**
|
||||
* @brief PCNT port number, the max port number is (PCNT_PORT_MAX - 1).
|
||||
* @brief PCNT channel action on control level
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
PCNT_PORT_0 = 0, /*!< PCNT port 0 */
|
||||
PCNT_PORT_MAX, /*!< PCNT port max */
|
||||
} pcnt_port_t;
|
||||
PCNT_CHANNEL_LEVEL_ACTION_KEEP, /*!< Keep current count mode */
|
||||
PCNT_CHANNEL_LEVEL_ACTION_INVERSE, /*!< Invert current count mode (increase -> decrease, decrease -> increase) */
|
||||
PCNT_CHANNEL_LEVEL_ACTION_HOLD, /*!< Hold current count value */
|
||||
} pcnt_channel_level_action_t;
|
||||
|
||||
/**
|
||||
* @brief Selection of all available PCNT units
|
||||
* @brief PCNT channel action on signal edge
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
PCNT_UNIT_0 = 0, /*!< PCNT unit 0 */
|
||||
PCNT_UNIT_1 = 1, /*!< PCNT unit 1 */
|
||||
PCNT_UNIT_2 = 2, /*!< PCNT unit 2 */
|
||||
PCNT_UNIT_3 = 3, /*!< PCNT unit 3 */
|
||||
#if SOC_PCNT_UNIT_NUM > 4
|
||||
PCNT_UNIT_4 = 4, /*!< PCNT unit 4 */
|
||||
PCNT_UNIT_5 = 5, /*!< PCNT unit 5 */
|
||||
PCNT_UNIT_6 = 6, /*!< PCNT unit 6 */
|
||||
PCNT_UNIT_7 = 7, /*!< PCNT unit 7 */
|
||||
#endif
|
||||
PCNT_UNIT_MAX,
|
||||
} pcnt_unit_t;
|
||||
PCNT_CHANNEL_EDGE_ACTION_HOLD, /*!< Hold current count value */
|
||||
PCNT_CHANNEL_EDGE_ACTION_INCREASE, /*!< Increase count value */
|
||||
PCNT_CHANNEL_EDGE_ACTION_DECREASE, /*!< Decrease count value */
|
||||
} pcnt_channel_edge_action_t;
|
||||
|
||||
/**
|
||||
* @brief Selection of available modes that determine the counter's action depending on the state of the control signal's input GPIO
|
||||
* @note Configuration covers two actions, one for high, and one for low level on the control input
|
||||
* @brief PCNT unit counter value's sign
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
PCNT_MODE_KEEP = 0, /*!< Control mode: won't change counter mode*/
|
||||
PCNT_MODE_REVERSE = 1, /*!< Control mode: invert counter mode(increase -> decrease, decrease -> increase) */
|
||||
PCNT_MODE_DISABLE = 2, /*!< Control mode: Inhibit counter(counter value will not change in this condition) */
|
||||
PCNT_MODE_MAX
|
||||
} pcnt_ctrl_mode_t;
|
||||
|
||||
/**
|
||||
* @brief Selection of available modes that determine the counter's action on the edge of the pulse signal's input GPIO
|
||||
* @note Configuration covers two actions, one for positive, and one for negative edge on the pulse input
|
||||
*/
|
||||
typedef enum {
|
||||
PCNT_COUNT_DIS = 0, /*!< Counter mode: Inhibit counter(counter value will not change in this condition) */
|
||||
PCNT_COUNT_INC = 1, /*!< Counter mode: Increase counter value */
|
||||
PCNT_COUNT_DEC = 2, /*!< Counter mode: Decrease counter value */
|
||||
PCNT_COUNT_MAX
|
||||
} pcnt_count_mode_t;
|
||||
|
||||
/**
|
||||
* @brief Selection of channels available for a single PCNT unit
|
||||
*/
|
||||
typedef enum {
|
||||
PCNT_CHANNEL_0 = 0x00, /*!< PCNT channel 0 */
|
||||
PCNT_CHANNEL_1 = 0x01, /*!< PCNT channel 1 */
|
||||
PCNT_CHANNEL_MAX,
|
||||
} pcnt_channel_t;
|
||||
|
||||
/**
|
||||
* @brief Selection of counter's events the may trigger an interrupt
|
||||
*/
|
||||
typedef enum {
|
||||
PCNT_EVT_THRES_1 = BIT(2), /*!< PCNT watch point event: threshold1 value event */
|
||||
PCNT_EVT_THRES_0 = BIT(3), /*!< PCNT watch point event: threshold0 value event */
|
||||
PCNT_EVT_L_LIM = BIT(4), /*!< PCNT watch point event: Minimum counter value */
|
||||
PCNT_EVT_H_LIM = BIT(5), /*!< PCNT watch point event: Maximum counter value */
|
||||
PCNT_EVT_ZERO = BIT(6), /*!< PCNT watch point event: counter value zero event */
|
||||
PCNT_EVT_MAX
|
||||
} pcnt_evt_type_t;
|
||||
|
||||
/**
|
||||
* @brief Pulse Counter configuration for a single channel
|
||||
*/
|
||||
typedef struct {
|
||||
int pulse_gpio_num; /*!< Pulse input GPIO number, if you want to use GPIO16, enter pulse_gpio_num = 16, a negative value will be ignored */
|
||||
int ctrl_gpio_num; /*!< Control signal input GPIO number, a negative value will be ignored */
|
||||
pcnt_ctrl_mode_t lctrl_mode; /*!< PCNT low control mode */
|
||||
pcnt_ctrl_mode_t hctrl_mode; /*!< PCNT high control mode */
|
||||
pcnt_count_mode_t pos_mode; /*!< PCNT positive edge count mode */
|
||||
pcnt_count_mode_t neg_mode; /*!< PCNT negative edge count mode */
|
||||
int16_t counter_h_lim; /*!< Maximum counter value */
|
||||
int16_t counter_l_lim; /*!< Minimum counter value */
|
||||
pcnt_unit_t unit; /*!< PCNT unit number */
|
||||
pcnt_channel_t channel; /*!< the PCNT channel */
|
||||
} pcnt_config_t;
|
||||
PCNT_UNIT_COUNT_SIGN_ZERO_POS, /*!< positive value to zero */
|
||||
PCNT_UNIT_COUNT_SIGN_ZERO_NEG, /*!< negative value to zero */
|
||||
PCNT_UNIT_COUNT_SIGN_NEG, /*!< counter value negative */
|
||||
PCNT_UNIT_COUNT_SIGN_POS, /*!< counter value positive */
|
||||
} pcnt_unit_count_sign_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -14,12 +14,36 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "soc/soc_caps.h"
|
||||
#include "hal/gpio_types.h"
|
||||
#include "hal/rtc_cntl_ll.h"
|
||||
#if !CONFIG_IDF_TARGET_ESP32C3 && !CONFIG_IDF_TARGET_ESP32H2
|
||||
#include "hal/rtc_io_ll.h"
|
||||
#endif
|
||||
|
||||
typedef struct rtc_cntl_sleep_retent {
|
||||
#if SOC_PM_SUPPORT_CPU_PD
|
||||
void *cpu_pd_mem; /* Internal ram address for cpu retention */
|
||||
#endif // SOC_PM_SUPPORT_CPU_PD
|
||||
#if SOC_PM_SUPPORT_TAGMEM_PD
|
||||
struct {
|
||||
void *link_addr; /* Internal ram address for tagmem retention */
|
||||
struct {
|
||||
uint32_t start_point: 8, /* the row of start for i-cache tag memory */
|
||||
vld_size: 8, /* valid size of i-cache tag memory, unit: 4 i-cache tagmem blocks */
|
||||
size: 8, /* i-cache tag memory size, unit: 4 i-cache tagmem blocks */
|
||||
enable: 1; /* enable or disable i-cache tagmem retention */
|
||||
} icache;
|
||||
struct {
|
||||
uint32_t start_point: 9, /* the row of start for d-cache tag memory */
|
||||
vld_size: 9, /* valid size of d-cache tag memory, unit: 4 d-cache tagmem blocks */
|
||||
size: 9, /* d-cache tag memory size, unit: 4 d-cache tagmem blocks */
|
||||
enable: 1; /* enable or disable d-cache tagmem retention */
|
||||
} dcache;
|
||||
} tagmem;
|
||||
#endif // SOC_PM_SUPPORT_TAGMEM_PD
|
||||
} rtc_cntl_sleep_retent_t;
|
||||
|
||||
#define RTC_HAL_DMA_LINK_NODE_SIZE (16)
|
||||
|
||||
#if SOC_PM_SUPPORT_EXT_WAKEUP
|
||||
@ -46,9 +70,21 @@
|
||||
|
||||
void * rtc_cntl_hal_dma_link_init(void *elem, void *buff, int size, void *next);
|
||||
|
||||
#if SOC_PM_SUPPORT_CPU_PD
|
||||
|
||||
void rtc_cntl_hal_enable_cpu_retention(void *addr);
|
||||
|
||||
#define rtc_cntl_hal_disable_cpu_retention() rtc_cntl_ll_disable_cpu_retention()
|
||||
void rtc_cntl_hal_disable_cpu_retention(void *addr);
|
||||
|
||||
#endif
|
||||
|
||||
#if SOC_PM_SUPPORT_TAGMEM_PD
|
||||
|
||||
void rtc_cntl_hal_enable_tagmem_retention(void *addr);
|
||||
|
||||
void rtc_cntl_hal_disable_tagmem_retention(void *addr);
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Enable wakeup from ULP coprocessor.
|
||||
|
@ -51,20 +51,41 @@ typedef struct {
|
||||
uint32_t flags; ///< Flags for configurations with one set of driver code. (e.g. QPI mode, auto-suspend mode, 64-bit address mode, etc.)
|
||||
#define SPI_FLASH_HOST_CONTEXT_FLAG_AUTO_SUSPEND BIT(0) ///< When the auto-suspend is setup in configuration.
|
||||
#define SPI_FLASH_HOST_CONTEXT_FLAG_AUTO_RESUME BIT(1) ///< Setup auto-resume feature.
|
||||
#define SPI_FLASH_HOST_CONTEXT_FLAG_OCTAL_MODE BIT(2) ///< Flash works under octal spi mode.
|
||||
spi_flash_sus_cmd_conf sus_cfg; ///< To store suspend command/mask information.
|
||||
uint32_t slicer_flags; /// Slicer flags for configuring how to slice data correctly while reading or writing.
|
||||
#define SPI_FLASH_HOST_CONTEXT_SLICER_FLAG_DTR BIT(0) ///< Slice data according to DTR mode, the address and length must be even (A0=0).
|
||||
} spi_flash_hal_context_t;
|
||||
_Static_assert(sizeof(spi_flash_hal_context_t) == 36, "size of spi_flash_hal_context_t incorrect. Please check data compatibility with the ROM");
|
||||
_Static_assert(sizeof(spi_flash_hal_context_t) == 40, "size of spi_flash_hal_context_t incorrect. Please check data compatibility with the ROM");
|
||||
|
||||
/// This struct provide MSPI Flash necessary timing related config, should be consistent with that in union in `spi_flash_hal_config_t`.
|
||||
typedef struct {
|
||||
uint32_t extra_dummy;
|
||||
uint32_t cs_hold;
|
||||
uint8_t cs_setup;
|
||||
spi_flash_ll_clock_reg_t clock_config;
|
||||
} spi_flash_hal_timing_config_t;
|
||||
|
||||
/// Configuration structure for the SPI driver.
|
||||
typedef struct {
|
||||
spi_host_device_t host_id; ///< SPI peripheral ID.
|
||||
int cs_num; ///< Which cs pin is used, 0-(SOC_SPI_PERIPH_CS_NUM-1).
|
||||
union {
|
||||
struct {
|
||||
uint32_t extra_dummy; ///< extra dummy for timing compensation.
|
||||
uint32_t cs_hold; ///< CS hold time config used by the host
|
||||
uint8_t cs_setup; ///< (cycles-1) of prepare phase by spi clock
|
||||
spi_flash_ll_clock_reg_t clock_config; ///< (optional) Clock configuration for Octal flash.
|
||||
};
|
||||
spi_flash_hal_timing_config_t timing_reg; ///< Reconfigure timing tuning regs.
|
||||
};
|
||||
bool iomux; ///< Whether the IOMUX is used, used for timing compensation.
|
||||
int input_delay_ns; ///< Input delay on the MISO pin after the launch clock, used for timing compensation.
|
||||
esp_flash_speed_t speed;///< SPI flash clock speed to work at.
|
||||
uint32_t cs_hold; ///< CS hold time config used by the host
|
||||
uint8_t cs_setup; ///< (cycles-1) of prepare phase by spi clock
|
||||
spi_host_device_t host_id; ///< SPI peripheral ID.
|
||||
int cs_num; ///< Which cs pin is used, 0-(SOC_SPI_PERIPH_CS_NUM-1).
|
||||
bool auto_sus_en; ///< Auto suspend feature enable bit 1: enable, 0: disable.
|
||||
bool octal_mode_en; ///< Octal spi flash mode enable bit 1: enable, 0: disable.
|
||||
bool using_timing_tuning; ///< System exist SPI0/1 timing tuning, using value from system directely if set to 1.
|
||||
esp_flash_io_mode_t default_io_mode; ///< Default flash io mode.
|
||||
} spi_flash_hal_config_t;
|
||||
|
||||
/**
|
||||
|
@ -37,6 +37,7 @@ typedef struct {
|
||||
#define SPI_FLASH_TRANS_FLAG_BYTE_SWAP BIT(2) ///< Used for DTR mode, to swap the bytes of a pair of rising/falling edge
|
||||
uint16_t command; ///< Command to send
|
||||
uint8_t dummy_bitlen; ///< Basic dummy bits to use
|
||||
uint32_t io_mode; ///< Flash working mode when `SPI_FLASH_IGNORE_BASEIO` is specified.
|
||||
} spi_flash_trans_t;
|
||||
|
||||
/**
|
||||
@ -54,6 +55,7 @@ typedef enum {
|
||||
ESP_FLASH_26MHZ, ///< The flash runs under 26MHz
|
||||
ESP_FLASH_40MHZ, ///< The flash runs under 40MHz
|
||||
ESP_FLASH_80MHZ, ///< The flash runs under 80MHz
|
||||
ESP_FLASH_120MHZ, ///< The flash runs under 120MHz, 120MHZ can only be used by main flash after timing tuning in system. Do not use this directely in any API.
|
||||
ESP_FLASH_SPEED_MAX, ///< The maximum frequency supported by the host is ``ESP_FLASH_SPEED_MAX-1``.
|
||||
} esp_flash_speed_t;
|
||||
|
||||
@ -71,7 +73,9 @@ typedef enum {
|
||||
SPI_FLASH_DIO, ///< Both address & data transferred using dual I/O
|
||||
SPI_FLASH_QOUT, ///< Data read using quad I/O
|
||||
SPI_FLASH_QIO, ///< Both address & data transferred using quad I/O
|
||||
|
||||
#define SPI_FLASH_OPI_FLAG 16 ///< A flag for flash work in opi mode, the io mode below are opi, above are SPI/QSPI mode. DO NOT use this value in any API.
|
||||
SPI_FLASH_OPI_STR = SPI_FLASH_OPI_FLAG,///< Only support on OPI flash, flash read and write under STR mode
|
||||
SPI_FLASH_OPI_DTR,///< Only support on OPI flash, flash read and write under DTR mode
|
||||
SPI_FLASH_READ_MODE_MAX, ///< The fastest io mode supported by the host is ``ESP_FLASH_READ_MODE_MAX-1``.
|
||||
} esp_flash_io_mode_t;
|
||||
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include <esp_err.h>
|
||||
#include "soc/lldesc.h"
|
||||
#include "soc/soc_caps.h"
|
||||
#include "hal/spi_types.h"
|
||||
|
||||
/**
|
||||
* Input parameters to the ``spi_hal_cal_clock_conf`` to calculate the timing configuration
|
||||
@ -100,7 +101,7 @@ typedef struct {
|
||||
uint64_t addr; ///< Address value to be sent
|
||||
uint8_t *send_buffer; ///< Data to be sent
|
||||
uint8_t *rcv_buffer; ///< Buffer to hold the receive data.
|
||||
spi_ll_io_mode_t io_mode; ///< IO mode of the master
|
||||
spi_line_mode_t line_mode; ///< SPI line mode of this transaction
|
||||
int cs_keep_active; ///< Keep CS active after transaction
|
||||
} spi_hal_trans_config_t;
|
||||
|
||||
|
@ -14,8 +14,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "esp_attr.h"
|
||||
#include <esp_bit_defs.h>
|
||||
#include "esp_bit_defs.h"
|
||||
#include "soc/soc_caps.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
@ -45,6 +46,15 @@ typedef enum {
|
||||
} spi_event_t;
|
||||
FLAG_ATTR(spi_event_t)
|
||||
|
||||
/**
|
||||
* @brief Line mode of SPI transaction phases: CMD, ADDR, DOUT/DIN.
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t cmd_lines; ///< The line width of command phase, e.g. 2-line-cmd-phase.
|
||||
uint8_t addr_lines; ///< The line width of address phase, e.g. 1-line-addr-phase.
|
||||
uint8_t data_lines; ///< The line width of data phase, e.g. 4-line-data-phase.
|
||||
} spi_line_mode_t;
|
||||
|
||||
|
||||
/** @cond */ //Doxy command to hide preprocessor definitions from docs */
|
||||
|
||||
|
@ -59,6 +59,15 @@ void timer_hal_init(timer_hal_context_t *hal, timer_group_t group_num, timer_idx
|
||||
*/
|
||||
void timer_hal_get_status_reg_mask_bit(timer_hal_context_t *hal, uint32_t *status_reg, uint32_t *mask_bit);
|
||||
|
||||
/**
|
||||
* @brief Reset timer peripheral
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void timer_hal_reset_periph(timer_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* @brief Set timer clock prescale value
|
||||
*
|
||||
|
54
tools/sdk/esp32/include/hal/include/hal/uhci_types.h
Normal file
54
tools/sdk/esp32/include/hal/include/hal/uhci_types.h
Normal file
@ -0,0 +1,54 @@
|
||||
// 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.
|
||||
|
||||
|
||||
|
||||
// Though the UHCI driver hasn't been published, some types are defined here
|
||||
// for users to develop over the HAL. See example: controller_hci_uart_esp32c3
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief UHCI escape sequence
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t seper_chr; /*!< escape sequence character */
|
||||
uint8_t sub_chr1; /*!< escape sequence sub-character 1 */
|
||||
uint8_t sub_chr2; /*!< escape sequence sub-character 2 */
|
||||
bool sub_chr_en; /*!< enable use of sub-chaacter of escape sequence */
|
||||
} uhci_seper_chr_t;
|
||||
|
||||
/**
|
||||
* @brief UHCI software flow control
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t xon_chr; /*!< character for XON */
|
||||
uint8_t xon_sub1; /*!< sub-character 1 for XON */
|
||||
uint8_t xon_sub2; /*!< sub-character 2 for XON */
|
||||
uint8_t xoff_chr; /*!< character 2 for XOFF */
|
||||
uint8_t xoff_sub1; /*!< sub-character 1 for XOFF */
|
||||
uint8_t xoff_sub2; /*!< sub-character 2 for XOFF */
|
||||
uint8_t flow_en; /*!< enable use of software flow control */
|
||||
} uhci_swflow_ctrl_sub_chr_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
81
tools/sdk/esp32/include/hal/include/hal/usb_phy_hal.h
Normal file
81
tools/sdk/esp32/include/hal/include/hal/usb_phy_hal.h
Normal file
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "usb_types_private.h"
|
||||
#include "usb_phy_types.h"
|
||||
#include "soc/soc_caps.h"
|
||||
#include "soc/usb_wrap_struct.h"
|
||||
#if SOC_USB_SERIAL_JTAG_SUPPORTED
|
||||
#include "soc/usb_serial_jtag_struct.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Context that should be maintained by both the driver and the HAL
|
||||
*/
|
||||
typedef struct {
|
||||
usb_wrap_dev_t *wrap_dev; /**< Pointer to base address of USB Wrapper registers */
|
||||
#if SOC_USB_SERIAL_JTAG_SUPPORTED
|
||||
usb_serial_jtag_dev_t *jtag_dev; /**< Pointer to base address of USB Serial JTAG registers */
|
||||
#endif
|
||||
} usb_phy_hal_context_t;
|
||||
|
||||
/**
|
||||
* @brief Init the USB PHY hal. This function should be called first before other hal layer function is called
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
void usb_phy_hal_init(usb_phy_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* @brief Configure internal/external PHY for USB_OTG
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param phy_target USB PHY target
|
||||
*/
|
||||
void usb_phy_hal_otg_conf(usb_phy_hal_context_t *hal, usb_phy_target_t phy_target);
|
||||
|
||||
#if SOC_USB_SERIAL_JTAG_SUPPORTED
|
||||
/**
|
||||
* @brief Configure internal/external PHY for USB_Serial_JTAG
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param phy_target USB PHY target
|
||||
*/
|
||||
void usb_phy_hal_jtag_conf(usb_phy_hal_context_t *hal, usb_phy_target_t phy_target);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Configure pullup/pulldown loads for the D+/D- as a host
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
*/
|
||||
void usb_phy_hal_int_load_conf_host(usb_phy_hal_context_t *hal);
|
||||
|
||||
/**
|
||||
* @brief Configure pullup/pulldown loads for the D+/D- as a device
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param speed USB speed
|
||||
*/
|
||||
void usb_phy_hal_int_load_conf_dev(usb_phy_hal_context_t *hal, usb_priv_speed_t speed);
|
||||
|
||||
/**
|
||||
* @brief Enable/Disable test mode for internal PHY to mimick host-device disconnection
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param disconn Whether to disconnect
|
||||
*/
|
||||
void usb_phy_hal_int_mimick_disconn(usb_phy_hal_context_t *hal, bool disconn);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
63
tools/sdk/esp32/include/hal/include/hal/usb_phy_types.h
Normal file
63
tools/sdk/esp32/include/hal/include/hal/usb_phy_types.h
Normal file
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
Note: This header file contains USB2.0 related types and macros that can be used by code specific to the DWC_OTG
|
||||
controller (i.e., the HW specific layers of the USB host stack). Thus, this header is only meant to be used below (and
|
||||
including) the HAL layer. For types and macros that are HW implementation agnostic (i.e., HCD layer and above), add them
|
||||
to the "usb/usb_types_ch9.h" header instead.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief USB PHY target
|
||||
*/
|
||||
typedef enum {
|
||||
USB_PHY_TARGET_INT, /**< USB target is internal PHY */
|
||||
USB_PHY_TARGET_EXT, /**< USB target is external PHY */
|
||||
USB_PHY_TARGET_MAX,
|
||||
} usb_phy_target_t;
|
||||
|
||||
/**
|
||||
* @brief USB PHY source
|
||||
*/
|
||||
typedef enum {
|
||||
USB_PHY_CTRL_OTG, /**< PHY controller is USB OTG */
|
||||
#if SOC_USB_SERIAL_JTAG_SUPPORTED
|
||||
USB_PHY_CTRL_SERIAL_JTAG, /**< PHY controller is USB Serial JTAG */
|
||||
#endif
|
||||
USB_PHY_CTRL_MAX,
|
||||
} usb_phy_controller_t;
|
||||
|
||||
/**
|
||||
* @brief USB OTG mode
|
||||
*/
|
||||
typedef enum {
|
||||
USB_PHY_MODE_DEFAULT, /**< USB OTG default mode */
|
||||
USB_OTG_MODE_HOST, /**< USB OTG host mode */
|
||||
USB_OTG_MODE_DEVICE, /**< USB OTG device mode */
|
||||
USB_OTG_MODE_MAX,
|
||||
} usb_otg_mode_t;
|
||||
|
||||
/**
|
||||
* @brief USB speed
|
||||
*/
|
||||
typedef enum {
|
||||
USB_PHY_SPEED_UNDEFINED,
|
||||
USB_PHY_SPEED_LOW, /**< USB Low Speed (1.5 Mbit/s) */
|
||||
USB_PHY_SPEED_FULL, /**< USB Full Speed (12 Mbit/s) */
|
||||
USB_PHY_SPEED_MAX,
|
||||
} usb_phy_speed_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -16,7 +16,7 @@
|
||||
Note: This header file contains USB2.0 related types and macros that can be used by code specific to the DWC_OTG
|
||||
controller (i.e., the HW specific layers of the USB host stack). Thus, this header is only meant to be used below (and
|
||||
including) the HAL layer. For types and macros that are HW implementation agnostic (i.e., HCD layer and above), add them
|
||||
to the "usb.h" header instead.
|
||||
to the "usb/usb_types_ch9.h" header instead.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
@ -151,7 +151,7 @@ typedef struct {
|
||||
//Channel control, status, and information
|
||||
union {
|
||||
struct {
|
||||
uint32_t active: 1; /**< The channel is enabled */
|
||||
uint32_t active: 1; /**< Debugging bit to indicate whether channel is enabled */
|
||||
uint32_t halt_requested: 1; /**< A halt has been requested */
|
||||
uint32_t error_pending: 1; /**< The channel is waiting for the error to be handled */
|
||||
uint32_t reserved: 1;
|
||||
@ -811,6 +811,8 @@ usbh_hal_chan_t *usbh_hal_get_chan_pending_intr(usbh_hal_context_t *hal);
|
||||
* - Returns the corresponding event for that channel
|
||||
*
|
||||
* @param chan_obj Channel object
|
||||
* @note If the host port has an error (e.g., a sudden disconnect or an port error), any active channels will not
|
||||
* receive an interrupt. Each active channel must be manually halted.
|
||||
* @return usbh_hal_chan_event_t Channel event
|
||||
*/
|
||||
usbh_hal_chan_event_t usbh_hal_chan_decode_intr(usbh_hal_chan_t *chan_obj);
|
||||
|
61
tools/sdk/esp32/include/hal/include/hal/xt_wdt_hal.h
Normal file
61
tools/sdk/esp32/include/hal/include/hal/xt_wdt_hal.h
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "hal/xt_wdt_ll.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
rtc_cntl_dev_t *dev; /* Pointer to the RTC register struct */
|
||||
} xt_wdt_hal_context_t; /* HAL context struct */
|
||||
|
||||
typedef struct {
|
||||
uint32_t timeout; /* Watchdog timer timeout in RTC_CLK cycles*/
|
||||
} xt_wdt_hal_config_t; /* HAL config parameter struct */
|
||||
|
||||
/* ---------------------------- Init and Config ----------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Initialize the WDTs associated HAL context
|
||||
*
|
||||
* Prepares the register for enabling the WDT and sets the timeout value
|
||||
*
|
||||
* @param hal Pointer to the HAL layer context
|
||||
* @param config Pointer to config struct
|
||||
*/
|
||||
void xt_wdt_hal_init(xt_wdt_hal_context_t *hal, const xt_wdt_hal_config_t *config);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Enable or disable the WDT
|
||||
*
|
||||
* @param hal Pointer to the HAL layer context
|
||||
* @param enable true for enable WDT, false for disable
|
||||
*/
|
||||
void xt_wdt_hal_enable(xt_wdt_hal_context_t *hal, bool enable);
|
||||
|
||||
/**
|
||||
* @brief Enable the automatic RTC backup clock with the given frequency
|
||||
*
|
||||
* Calculates and sets the necessary hardware parameters to meet the desired
|
||||
* backup clock frequency
|
||||
*
|
||||
* @param hal Pointer to the HAL layer context
|
||||
* @param rtc_clk_frequency_khz desired frequency for the backup clock
|
||||
* @return uint32_t the calculated clock factor value
|
||||
*/
|
||||
uint32_t xt_wdt_hal_enable_backup_clk(xt_wdt_hal_context_t *hal, uint32_t rtc_clk_frequency_khz);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -21,3 +21,9 @@
|
||||
#define HAL_LOGI(...) ESP_LOGI(__VA_ARGS__)
|
||||
#define HAL_LOGD(...) ESP_LOGD(__VA_ARGS__)
|
||||
#define HAL_LOGV(...) ESP_LOGV(__VA_ARGS__)
|
||||
|
||||
#define HAL_EARLY_LOGE(...) ESP_EARLY_LOGE(__VA_ARGS__)
|
||||
#define HAL_EARLY_LOGW(...) ESP_EARLY_LOGW(__VA_ARGS__)
|
||||
#define HAL_EARLY_LOGI(...) ESP_EARLY_LOGI(__VA_ARGS__)
|
||||
#define HAL_EARLY_LOGD(...) ESP_EARLY_LOGD(__VA_ARGS__)
|
||||
#define HAL_EARLY_LOGV(...) ESP_EARLY_LOGV(__VA_ARGS__)
|
||||
|
@ -16,3 +16,44 @@
|
||||
#define HAL_SWAP16(d) __builtin_bswap16((d))
|
||||
#define HAL_SWAP32(d) __builtin_bswap32((d))
|
||||
#define HAL_SWAP64(d) __builtin_bswap64((d))
|
||||
|
||||
/** @cond */ //Doxy command to hide preprocessor definitions from docs */
|
||||
|
||||
/**
|
||||
* @brief Macro to force a 32-bit read, modify, then write on a peripheral register
|
||||
*
|
||||
* Due to a GCC bug, the compiler may still try to optimize read/writes to peripheral register fields by using 8/16 bit
|
||||
* access, even if they are marked volatile (i.e., -fstrict-volatile-bitfields has no effect).
|
||||
*
|
||||
* For ESP chips, the peripheral bus only allows 32-bit read/writes. The following macro works around the compiler issue
|
||||
* by forcing a 32-bit read/modify/write.
|
||||
*
|
||||
* @note This macro should only be called on register fields of xxx_struct.h type headers, as it depends on the presence
|
||||
* of a 'val' field of the register union.
|
||||
* @note Current implementation reads into a uint32_t instead of copy base_reg direclty to temp_reg. The reason being
|
||||
* that C++ does not create a copy constructor for volatile structs.
|
||||
*/
|
||||
#define HAL_FORCE_MODIFY_U32_REG_FIELD(base_reg, reg_field, field_val) \
|
||||
{ \
|
||||
uint32_t temp_val = base_reg.val; \
|
||||
typeof(base_reg) temp_reg; \
|
||||
temp_reg.val = temp_val; \
|
||||
temp_reg.reg_field = (field_val); \
|
||||
(base_reg).val = temp_reg.val; \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Macro to force a 32-bit read on a peripheral register
|
||||
*
|
||||
* @note This macro should only be called on register fields of xxx_struct.h type headers. See description above for
|
||||
* more details.
|
||||
* @note Current implementation reads into a uint32_t. See description above for more details.
|
||||
*/
|
||||
#define HAL_FORCE_READ_U32_REG_FIELD(base_reg, reg_field) ({ \
|
||||
uint32_t temp_val = base_reg.val; \
|
||||
typeof(base_reg) temp_reg; \
|
||||
temp_reg.val = temp_val; \
|
||||
temp_reg.reg_field; \
|
||||
})
|
||||
|
||||
/** @endcond */
|
||||
|
Reference in New Issue
Block a user