mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/timer_group_intr_enable' into 'master'
Bugfix/timer group intr enable Closes IDFGH-3082 See merge request espressif/esp-idf!8340
This commit is contained in:
commit
77d5e4b4e2
@ -28,6 +28,10 @@ extern "C" {
|
||||
*
|
||||
* Clock for the module will be ungated, and reset de-asserted.
|
||||
*
|
||||
* @note If periph_module_enable is called a number of times,
|
||||
* periph_module_disable has to be called the same number of times
|
||||
* in order to put the peripheral into disabled state.
|
||||
*
|
||||
* @return NULL
|
||||
*
|
||||
*/
|
||||
@ -40,6 +44,10 @@ void periph_module_enable(periph_module_t periph);
|
||||
*
|
||||
* Clock for the module will be gated, reset asserted.
|
||||
*
|
||||
* @note If periph_module_enable is called a number of times,
|
||||
* periph_module_disable has to be called the same number of times
|
||||
* in order to put the peripheral into disabled state.
|
||||
*
|
||||
* @return NULL
|
||||
*
|
||||
*/
|
||||
|
@ -17,22 +17,33 @@
|
||||
|
||||
static portMUX_TYPE periph_spinlock = portMUX_INITIALIZER_UNLOCKED;
|
||||
|
||||
static uint8_t ref_counts[PERIPH_MODULE_MAX] = {0};
|
||||
|
||||
void periph_module_enable(periph_module_t periph)
|
||||
{
|
||||
assert(periph < PERIPH_MODULE_MAX);
|
||||
portENTER_CRITICAL_SAFE(&periph_spinlock);
|
||||
periph_ll_enable_clk_clear_rst(periph);
|
||||
if (ref_counts[periph] == 0) {
|
||||
periph_ll_enable_clk_clear_rst(periph);
|
||||
}
|
||||
ref_counts[periph]++;
|
||||
portEXIT_CRITICAL_SAFE(&periph_spinlock);
|
||||
}
|
||||
|
||||
void periph_module_disable(periph_module_t periph)
|
||||
{
|
||||
assert(periph < PERIPH_MODULE_MAX);
|
||||
portENTER_CRITICAL_SAFE(&periph_spinlock);
|
||||
periph_ll_disable_clk_set_rst(periph);
|
||||
ref_counts[periph]--;
|
||||
if (ref_counts[periph] == 0) {
|
||||
periph_ll_disable_clk_set_rst(periph);
|
||||
}
|
||||
portEXIT_CRITICAL_SAFE(&periph_spinlock);
|
||||
}
|
||||
|
||||
void periph_module_reset(periph_module_t periph)
|
||||
{
|
||||
assert(periph < PERIPH_MODULE_MAX);
|
||||
portENTER_CRITICAL_SAFE(&periph_spinlock);
|
||||
periph_ll_reset(periph);
|
||||
portEXIT_CRITICAL_SAFE(&periph_spinlock);
|
||||
|
@ -80,7 +80,7 @@ esp_err_t timer_get_counter_time_sec(timer_group_t group_num, timer_idx_t timer_
|
||||
uint64_t timer_val;
|
||||
esp_err_t err = timer_get_counter_value(group_num, timer_num, &timer_val);
|
||||
if (err == ESP_OK) {
|
||||
uint16_t div;
|
||||
uint32_t div;
|
||||
timer_hal_get_divider(&(p_timer_obj[group_num][timer_num]->hal), &div);
|
||||
*time = (double)timer_val * div / rtc_clk_apb_freq_get();
|
||||
#ifdef TIMER_GROUP_SUPPORTS_XTAL_CLOCK
|
||||
@ -262,7 +262,7 @@ esp_err_t timer_isr_register(timer_group_t group_num, timer_idx_t timer_num,
|
||||
|
||||
int intr_source = 0;
|
||||
uint32_t status_reg = 0;
|
||||
int mask = 0;
|
||||
uint32_t mask = 0;
|
||||
switch (group_num) {
|
||||
case TIMER_GROUP_0:
|
||||
default:
|
||||
@ -271,8 +271,7 @@ esp_err_t timer_isr_register(timer_group_t group_num, timer_idx_t timer_num,
|
||||
} else {
|
||||
intr_source = ETS_TG0_T0_EDGE_INTR_SOURCE + timer_num;
|
||||
}
|
||||
timer_hal_get_intr_status_reg(&(p_timer_obj[TIMER_GROUP_0][timer_num]->hal), &status_reg);
|
||||
mask = 1 << timer_num;
|
||||
timer_hal_get_status_reg_mask_bit(&(p_timer_obj[TIMER_GROUP_0][timer_num]->hal), &status_reg, &mask);
|
||||
break;
|
||||
case TIMER_GROUP_1:
|
||||
if ((intr_alloc_flags & ESP_INTR_FLAG_EDGE) == 0) {
|
||||
@ -280,8 +279,7 @@ esp_err_t timer_isr_register(timer_group_t group_num, timer_idx_t timer_num,
|
||||
} else {
|
||||
intr_source = ETS_TG1_T0_EDGE_INTR_SOURCE + timer_num;
|
||||
}
|
||||
timer_hal_get_intr_status_reg(&(p_timer_obj[TIMER_GROUP_1][timer_num]->hal), &status_reg);
|
||||
mask = 1 << timer_num;
|
||||
timer_hal_get_status_reg_mask_bit(&(p_timer_obj[TIMER_GROUP_1][timer_num]->hal), &status_reg, &mask);
|
||||
break;
|
||||
}
|
||||
return esp_intr_alloc_intrstatus(intr_source, intr_alloc_flags, status_reg, mask, fn, arg, handle);
|
||||
@ -363,13 +361,9 @@ esp_err_t timer_get_config(timer_group_t group_num, timer_idx_t timer_num, timer
|
||||
config->counter_dir = timer_hal_get_counter_increase(&(p_timer_obj[group_num][timer_num]->hal));
|
||||
config->counter_en = timer_hal_get_counter_enable(&(p_timer_obj[group_num][timer_num]->hal));
|
||||
|
||||
uint16_t div;
|
||||
uint32_t div;
|
||||
timer_hal_get_divider(&(p_timer_obj[group_num][timer_num]->hal), &div);
|
||||
if (div == 0) {
|
||||
config->divider = 65536;
|
||||
} else {
|
||||
config->divider = div;
|
||||
}
|
||||
config->divider = div;
|
||||
|
||||
if (timer_hal_get_level_int_enable(&(p_timer_obj[group_num][timer_num]->hal))) {
|
||||
config->intr_type = TIMER_INTR_LEVEL;
|
||||
|
@ -113,6 +113,7 @@ TEST_CASE("Scheduler disabled can handle a pending context switch on resume", "[
|
||||
// When we resume scheduler, we expect the counter task
|
||||
// will preempt and count at least one more item
|
||||
esp_intr_noniram_enable();
|
||||
timer_enable_intr(TIMER_GROUP_0, TIMER_0);
|
||||
xTaskResumeAll();
|
||||
|
||||
TEST_ASSERT_NOT_EQUAL(count_config.counter, no_sched_task);
|
||||
|
@ -50,6 +50,15 @@ typedef struct {
|
||||
*/
|
||||
void timer_hal_init(timer_hal_context_t *hal, timer_group_t group_num, timer_idx_t timer_num);
|
||||
|
||||
/**
|
||||
* @brief Get interrupt status register address and corresponding control bits mask
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param status_reg[out] interrupt status register address
|
||||
* @param mask_bit[out] control bits mask
|
||||
*/
|
||||
void timer_hal_get_status_reg_mask_bit(timer_hal_context_t *hal, uint32_t *status_reg, uint32_t *mask_bit);
|
||||
|
||||
/**
|
||||
* @brief Set timer clock prescale value
|
||||
*
|
||||
@ -288,13 +297,12 @@ void timer_hal_init(timer_hal_context_t *hal, timer_group_t group_num, timer_idx
|
||||
* @brief Get interrupt status register address.
|
||||
*
|
||||
* @param hal Context of the HAL layer
|
||||
* @param intr_status_reg Interrupt status register address
|
||||
*
|
||||
* @return None
|
||||
* @return Interrupt status register address
|
||||
*/
|
||||
#define timer_hal_get_intr_status_reg(hal, intr_status_reg) timer_ll_get_intr_status_reg((hal)->dev, intr_status_reg)
|
||||
#define timer_hal_get_intr_status_reg(hal) timer_ll_get_intr_status_reg((hal)->dev)
|
||||
|
||||
#ifdef TIMER_GROUP_SUPPORTS_XTAL_CLOCK
|
||||
#ifdef SOC_TIMER_GROUP_SUPPORT_XTAL
|
||||
/**
|
||||
* @brief Set clock source.
|
||||
*
|
||||
|
@ -98,7 +98,7 @@ typedef enum {
|
||||
TIMER_AUTORELOAD_MAX,
|
||||
} timer_autoreload_t;
|
||||
|
||||
#ifdef TIMER_GROUP_SUPPORTS_XTAL_CLOCK
|
||||
#ifdef SOC_TIMER_GROUP_SUPPORT_XTAL
|
||||
/**
|
||||
* @brief Select timer source clock.
|
||||
*/
|
||||
@ -118,7 +118,7 @@ typedef struct {
|
||||
timer_count_dir_t counter_dir; /*!< Counter direction */
|
||||
timer_autoreload_t auto_reload; /*!< Timer auto-reload */
|
||||
uint32_t divider; /*!< Counter clock divider. The divider's range is from from 2 to 65536. */
|
||||
#ifdef TIMER_GROUP_SUPPORTS_XTAL_CLOCK
|
||||
#ifdef SOC_TIMER_GROUP_SUPPORT_XTAL
|
||||
timer_src_clk_t clk_src; /*!< Use XTAL as source clock. */
|
||||
#endif
|
||||
} timer_config_t;
|
||||
|
@ -55,6 +55,7 @@ typedef enum {
|
||||
PERIPH_AES_MODULE,
|
||||
PERIPH_SHA_MODULE,
|
||||
PERIPH_RSA_MODULE,
|
||||
PERIPH_MODULE_MAX
|
||||
} periph_module_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -13,5 +13,3 @@
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#define WDT_SOURCE_CLK_FREQ_MHZ (80) // Watch Dog clock source comes from APB, which is 80MHz by default
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,462 +0,0 @@
|
||||
// Copyright 2015-2016 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.
|
||||
#ifndef _SOC_MCPWM_STRUCT_H__
|
||||
#define _SOC_MCPWM_STRUCT_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef volatile struct {
|
||||
union {
|
||||
struct {
|
||||
uint32_t prescale: 8; /*Period of PWM_clk = 6.25ns * (PWM_CLK_PRESCALE + 1)*/
|
||||
uint32_t reserved8: 24;
|
||||
};
|
||||
uint32_t val;
|
||||
}clk_cfg;
|
||||
struct {
|
||||
union {
|
||||
struct {
|
||||
uint32_t prescale: 8; /*period of PT0_clk = Period of PWM_clk * (PWM_TIMER0_PRESCALE + 1)*/
|
||||
uint32_t period: 16; /*period shadow reg of PWM timer0*/
|
||||
uint32_t upmethod: 2; /*Update method for active reg of PWM timer0 period 0: immediate 1: TEZ 2: sync 3: TEZ | sync. TEZ here and below means timer equal zero event*/
|
||||
uint32_t reserved26: 6;
|
||||
};
|
||||
uint32_t val;
|
||||
}period;
|
||||
union {
|
||||
struct {
|
||||
uint32_t start: 3; /*PWM timer0 start and stop control. 0: stop @ TEZ 1: stop @ TEP 2: free run 3: start and stop @ next TEZ 4: start and stop @ next TEP. TEP here and below means timer equal period event*/
|
||||
uint32_t mode: 2; /*PWM timer0 working mode 0: freeze 1: increase mod 2: decrease mod 3: up-down mod*/
|
||||
uint32_t reserved5: 27;
|
||||
};
|
||||
uint32_t val;
|
||||
}mode;
|
||||
union {
|
||||
struct {
|
||||
uint32_t in_en: 1; /*when set timer reload with phase on sync input event is enabled*/
|
||||
uint32_t sync_sw: 1; /*write the negate value will trigger a software sync*/
|
||||
uint32_t out_sel: 2; /*PWM timer0 synco selection 0: synci 1: TEZ 2: TEP else 0*/
|
||||
uint32_t timer_phase: 17; /*phase for timer reload on sync event*/
|
||||
uint32_t reserved21: 11;
|
||||
};
|
||||
uint32_t val;
|
||||
}sync;
|
||||
union {
|
||||
struct {
|
||||
uint32_t value: 16; /*current PWM timer0 counter value*/
|
||||
uint32_t direction: 1; /*current PWM timer0 counter direction 0: increment 1: decrement*/
|
||||
uint32_t reserved17: 15;
|
||||
};
|
||||
uint32_t val;
|
||||
}status;
|
||||
}timer[3];
|
||||
|
||||
|
||||
union {
|
||||
struct {
|
||||
uint32_t t0_in_sel: 3; /*select sync input for PWM timer0 1: PWM timer0 synco 2: PWM timer1 synco 3: PWM timer2 synco 4: SYNC0 from GPIO matrix 5: SYNC1 from GPIO matrix 6: SYNC2 from GPIO matrix else: none*/
|
||||
uint32_t t1_in_sel: 3; /*select sync input for PWM timer1 1: PWM timer0 synco 2: PWM timer1 synco 3: PWM timer2 synco 4: SYNC0 from GPIO matrix 5: SYNC1 from GPIO matrix 6: SYNC2 from GPIO matrix else: none*/
|
||||
uint32_t t2_in_sel: 3; /*select sync input for PWM timer2 1: PWM timer0 synco 2: PWM timer1 synco 3: PWM timer2 synco 4: SYNC0 from GPIO matrix 5: SYNC1 from GPIO matrix 6: SYNC2 from GPIO matrix else: none*/
|
||||
uint32_t ext_in0_inv: 1; /*invert SYNC0 from GPIO matrix*/
|
||||
uint32_t ext_in1_inv: 1; /*invert SYNC1 from GPIO matrix*/
|
||||
uint32_t ext_in2_inv: 1; /*invert SYNC2 from GPIO matrix*/
|
||||
uint32_t reserved12: 20;
|
||||
};
|
||||
uint32_t val;
|
||||
}timer_synci_cfg;
|
||||
union {
|
||||
struct {
|
||||
uint32_t operator0_sel: 2; /*Select which PWM timer's is the timing reference for PWM operator0 0: timer0 1: timer1 2: timer2*/
|
||||
uint32_t operator1_sel: 2; /*Select which PWM timer's is the timing reference for PWM operator1 0: timer0 1: timer1 2: timer2*/
|
||||
uint32_t operator2_sel: 2; /*Select which PWM timer's is the timing reference for PWM operator2 0: timer0 1: timer1 2: timer2*/
|
||||
uint32_t reserved6: 26;
|
||||
};
|
||||
uint32_t val;
|
||||
}timer_sel;
|
||||
|
||||
|
||||
struct {
|
||||
union {
|
||||
struct {
|
||||
uint32_t a_upmethod: 4; /*Update method for PWM compare0 A's active reg. 0: immediate bit0: TEZ bit1: TEP bit2: sync bit3: freeze*/
|
||||
uint32_t b_upmethod: 4; /*Update method for PWM compare0 B's active reg. 0: immediate bit0: TEZ bit1: TEP bit2: sync bit3: freeze*/
|
||||
uint32_t a_shdw_full: 1; /*Set and reset by hardware. If set PWM compare0 A's shadow reg is filled and waiting to be transferred to A's active reg. If cleared A's active reg has been updated with shadow reg latest value*/
|
||||
uint32_t b_shdw_full: 1; /*Set and reset by hardware. If set PWM compare0 B's shadow reg is filled and waiting to be transferred to B's active reg. If cleared B's active reg has been updated with shadow reg latest value*/
|
||||
uint32_t reserved10: 22;
|
||||
};
|
||||
uint32_t val;
|
||||
}cmpr_cfg;
|
||||
union {
|
||||
struct {
|
||||
uint32_t cmpr_val: 16; /*PWM compare0 A's shadow reg*/
|
||||
uint32_t reserved16:16;
|
||||
};
|
||||
uint32_t val;
|
||||
}cmpr_value[2];
|
||||
union {
|
||||
struct {
|
||||
uint32_t upmethod: 4; /*Update method for PWM generate0's active reg of configuration. 0: immediate bit0: TEZ bit1: TEP bit2: sync. bit3: freeze*/
|
||||
uint32_t t0_sel: 3; /*Source selection for PWM generate0 event_t0 take effect immediately 0: fault_event0 1: fault_event1 2: fault_event2 3: sync_taken 4: none*/
|
||||
uint32_t t1_sel: 3; /*Source selection for PWM generate0 event_t1 take effect immediately 0: fault_event0 1: fault_event1 2: fault_event2 3: sync_taken 4: none*/
|
||||
uint32_t reserved10: 22;
|
||||
};
|
||||
uint32_t val;
|
||||
}gen_cfg0;
|
||||
union {
|
||||
struct {
|
||||
uint32_t cntu_force_upmethod: 6; /*Update method for continuous software force of PWM generate0. 0: immediate bit0: TEZ bit1: TEP bit2: TEA bit3: TEB bit4: sync bit5: freeze. (TEA/B here and below means timer equals A/B event)*/
|
||||
uint32_t a_cntuforce_mode: 2; /*Continuous software force mode for PWM0A. 0: disabled 1: low 2: high 3: disabled*/
|
||||
uint32_t b_cntuforce_mode: 2; /*Continuous software force mode for PWM0B. 0: disabled 1: low 2: high 3: disabled*/
|
||||
uint32_t a_nciforce: 1; /*non-continuous immediate software force trigger for PWM0A a toggle will trigger a force event*/
|
||||
uint32_t a_nciforce_mode: 2; /*non-continuous immediate software force mode for PWM0A 0: disabled 1: low 2: high 3: disabled*/
|
||||
uint32_t b_nciforce: 1; /*non-continuous immediate software force trigger for PWM0B a toggle will trigger a force event*/
|
||||
uint32_t b_nciforce_mode: 2; /*non-continuous immediate software force mode for PWM0B 0: disabled 1: low 2: high 3: disabled*/
|
||||
uint32_t reserved16: 16;
|
||||
};
|
||||
uint32_t val;
|
||||
}gen_force;
|
||||
union {
|
||||
struct {
|
||||
uint32_t utez: 2; /*Action on PWM0A triggered by event TEZ when timer increasing*/
|
||||
uint32_t utep: 2; /*Action on PWM0A triggered by event TEP when timer increasing*/
|
||||
uint32_t utea: 2; /*Action on PWM0A triggered by event TEA when timer increasing*/
|
||||
uint32_t uteb: 2; /*Action on PWM0A triggered by event TEB when timer increasing*/
|
||||
uint32_t ut0: 2; /*Action on PWM0A triggered by event_t0 when timer increasing*/
|
||||
uint32_t ut1: 2; /*Action on PWM0A triggered by event_t1 when timer increasing*/
|
||||
uint32_t dtez: 2; /*Action on PWM0A triggered by event TEZ when timer decreasing*/
|
||||
uint32_t dtep: 2; /*Action on PWM0A triggered by event TEP when timer decreasing*/
|
||||
uint32_t dtea: 2; /*Action on PWM0A triggered by event TEA when timer decreasing*/
|
||||
uint32_t dteb: 2; /*Action on PWM0A triggered by event TEB when timer decreasing*/
|
||||
uint32_t dt0: 2; /*Action on PWM0A triggered by event_t0 when timer decreasing*/
|
||||
uint32_t dt1: 2; /*Action on PWM0A triggered by event_t1 when timer decreasing. 0: no change 1: low 2: high 3: toggle*/
|
||||
uint32_t reserved24: 8;
|
||||
};
|
||||
uint32_t val;
|
||||
}generator[2];
|
||||
union {
|
||||
struct {
|
||||
uint32_t fed_upmethod: 4; /*Update method for FED (falling edge delay) active reg. 0: immediate bit0: tez bit1: tep bit2: sync bit3: freeze*/
|
||||
uint32_t red_upmethod: 4; /*Update method for RED (rising edge delay) active reg. 0: immediate bit0: tez bit1: tep bit2: sync bit3: freeze*/
|
||||
uint32_t deb_mode: 1; /*S8 in documentation dual-edge B mode 0: fed/red take effect on different path separately 1: fed/red take effect on B path A out is in bypass or dulpB mode*/
|
||||
uint32_t a_outswap: 1; /*S6 in documentation*/
|
||||
uint32_t b_outswap: 1; /*S7 in documentation*/
|
||||
uint32_t red_insel: 1; /*S4 in documentation*/
|
||||
uint32_t fed_insel: 1; /*S5 in documentation*/
|
||||
uint32_t red_outinvert: 1; /*S2 in documentation*/
|
||||
uint32_t fed_outinvert: 1; /*S3 in documentation*/
|
||||
uint32_t a_outbypass: 1; /*S1 in documentation*/
|
||||
uint32_t b_outbypass: 1; /*S0 in documentation*/
|
||||
uint32_t clk_sel: 1; /*Dead band0 clock selection. 0: PWM_clk 1: PT_clk*/
|
||||
uint32_t reserved18: 14;
|
||||
};
|
||||
uint32_t val;
|
||||
}db_cfg;
|
||||
union {
|
||||
struct {
|
||||
uint32_t fed: 16; /*Shadow reg for FED*/
|
||||
uint32_t reserved16:16;
|
||||
};
|
||||
uint32_t val;
|
||||
}db_fed_cfg;
|
||||
union {
|
||||
struct {
|
||||
uint32_t red: 16; /*Shadow reg for RED*/
|
||||
uint32_t reserved16:16;
|
||||
};
|
||||
uint32_t val;
|
||||
}db_red_cfg;
|
||||
union {
|
||||
struct {
|
||||
uint32_t en: 1; /*When set carrier0 function is enabled. When reset carrier0 is bypassed*/
|
||||
uint32_t prescale: 4; /*carrier0 clk (CP_clk) prescale value. Period of CP_clk = period of PWM_clk * (PWM_CARRIER0_PRESCALE + 1)*/
|
||||
uint32_t duty: 3; /*carrier duty selection. Duty = PWM_CARRIER0_DUTY / 8*/
|
||||
uint32_t oshtwth: 4; /*width of the fist pulse in number of periods of the carrier*/
|
||||
uint32_t out_invert: 1; /*when set invert the output of PWM0A and PWM0B for this submodule*/
|
||||
uint32_t in_invert: 1; /*when set invert the input of PWM0A and PWM0B for this submodule*/
|
||||
uint32_t reserved14: 18;
|
||||
};
|
||||
uint32_t val;
|
||||
}carrier_cfg;
|
||||
union {
|
||||
struct {
|
||||
uint32_t sw_cbc: 1; /*Cycle-by-cycle tripping software force event will trigger cycle-by-cycle trip event. 0: disable 1: enable*/
|
||||
uint32_t f2_cbc: 1; /*event_f2 will trigger cycle-by-cycle trip event. 0: disable 1: enable*/
|
||||
uint32_t f1_cbc: 1; /*event_f1 will trigger cycle-by-cycle trip event. 0: disable 1: enable*/
|
||||
uint32_t f0_cbc: 1; /*event_f0 will trigger cycle-by-cycle trip event. 0: disable 1: enable*/
|
||||
uint32_t sw_ost: 1; /*one-shot tripping software force event will trigger one-shot trip event. 0: disable 1: enable*/
|
||||
uint32_t f2_ost: 1; /*event_f2 will trigger one-shot trip event. 0: disable 1: enable*/
|
||||
uint32_t f1_ost: 1; /*event_f1 will trigger one-shot trip event. 0: disable 1: enable*/
|
||||
uint32_t f0_ost: 1; /*event_f0 will trigger one-shot trip event. 0: disable 1: enable*/
|
||||
uint32_t a_cbc_d: 2; /*Action on PWM0A when cycle-by-cycle trip event occurs and timer is decreasing. 0: do nothing 1: force lo 2: force hi 3: toggle*/
|
||||
uint32_t a_cbc_u: 2; /*Action on PWM0A when cycle-by-cycle trip event occurs and timer is increasing. 0: do nothing 1: force lo 2: force hi 3: toggle*/
|
||||
uint32_t a_ost_d: 2; /*Action on PWM0A when one-shot trip event occurs and timer is decreasing. 0: do nothing 1: force lo 2: force hi 3: toggle*/
|
||||
uint32_t a_ost_u: 2; /*Action on PWM0A when one-shot trip event occurs and timer is increasing. 0: do nothing 1: force lo 2: force hi 3: toggle*/
|
||||
uint32_t b_cbc_d: 2; /*Action on PWM0B when cycle-by-cycle trip event occurs and timer is decreasing. 0: do nothing 1: force lo 2: force hi 3: toggle*/
|
||||
uint32_t b_cbc_u: 2; /*Action on PWM0B when cycle-by-cycle trip event occurs and timer is increasing. 0: do nothing 1: force lo 2: force hi 3: toggle*/
|
||||
uint32_t b_ost_d: 2; /*Action on PWM0B when one-shot trip event occurs and timer is decreasing. 0: do nothing 1: force lo 2: force hi 3: toggle*/
|
||||
uint32_t b_ost_u: 2; /*Action on PWM0B when one-shot trip event occurs and timer is increasing. 0: do nothing 1: force lo 2: force hi 3: toggle*/
|
||||
uint32_t reserved24: 8;
|
||||
};
|
||||
uint32_t val;
|
||||
}tz_cfg0;
|
||||
union {
|
||||
struct {
|
||||
uint32_t clr_ost: 1; /*a toggle will clear on going one-shot tripping*/
|
||||
uint32_t cbcpulse: 2; /*cycle-by-cycle tripping refresh moment selection. Bit0: TEZ bit1:TEP*/
|
||||
uint32_t force_cbc: 1; /*a toggle trigger a cycle-by-cycle tripping software force event*/
|
||||
uint32_t force_ost: 1; /*a toggle (software negate its value) trigger a one-shot tripping software force event*/
|
||||
uint32_t reserved5: 27;
|
||||
};
|
||||
uint32_t val;
|
||||
}tz_cfg1;
|
||||
union {
|
||||
struct {
|
||||
uint32_t cbc_on: 1; /*Set and reset by hardware. If set an cycle-by-cycle trip event is on going*/
|
||||
uint32_t ost_on: 1; /*Set and reset by hardware. If set an one-shot trip event is on going*/
|
||||
uint32_t reserved2: 30;
|
||||
};
|
||||
uint32_t val;
|
||||
}tz_status;
|
||||
}channel[3];
|
||||
|
||||
union {
|
||||
struct {
|
||||
uint32_t f0_en: 1; /*When set event_f0 generation is enabled*/
|
||||
uint32_t f1_en: 1; /*When set event_f1 generation is enabled*/
|
||||
uint32_t f2_en: 1; /*When set event_f2 generation is enabled*/
|
||||
uint32_t f0_pole: 1; /*Set event_f0 trigger polarity on FAULT2 source from GPIO matrix. 0: level low 1: level high*/
|
||||
uint32_t f1_pole: 1; /*Set event_f1 trigger polarity on FAULT2 source from GPIO matrix. 0: level low 1: level high*/
|
||||
uint32_t f2_pole: 1; /*Set event_f2 trigger polarity on FAULT2 source from GPIO matrix. 0: level low 1: level high*/
|
||||
uint32_t event_f0: 1; /*Set and reset by hardware. If set event_f0 is on going*/
|
||||
uint32_t event_f1: 1; /*Set and reset by hardware. If set event_f1 is on going*/
|
||||
uint32_t event_f2: 1; /*Set and reset by hardware. If set event_f2 is on going*/
|
||||
uint32_t reserved9: 23;
|
||||
};
|
||||
uint32_t val;
|
||||
}fault_detect;
|
||||
union {
|
||||
struct {
|
||||
uint32_t timer_en: 1; /*When set capture timer incrementing under APB_clk is enabled.*/
|
||||
uint32_t synci_en: 1; /*When set capture timer sync is enabled.*/
|
||||
uint32_t synci_sel: 3; /*capture module sync input selection. 0: none 1: timer0 synco 2: timer1 synco 3: timer2 synco 4: SYNC0 from GPIO matrix 5: SYNC1 from GPIO matrix 6: SYNC2 from GPIO matrix*/
|
||||
uint32_t sync_sw: 1; /*Write 1 will force a capture timer sync capture timer is loaded with value in phase register.*/
|
||||
uint32_t reserved6: 26;
|
||||
};
|
||||
uint32_t val;
|
||||
}cap_timer_cfg;
|
||||
uint32_t cap_timer_phase; /*Phase value for capture timer sync operation.*/
|
||||
union {
|
||||
struct {
|
||||
uint32_t en: 1; /*When set capture on channel 0 is enabled*/
|
||||
uint32_t mode: 2; /*Edge of capture on channel 0 after prescale. bit0: negedge cap en bit1: posedge cap en*/
|
||||
uint32_t prescale: 8; /*Value of prescale on possitive edge of CAP0. Prescale value = PWM_CAP0_PRESCALE + 1*/
|
||||
uint32_t in_invert: 1; /*when set CAP0 form GPIO matrix is inverted before prescale*/
|
||||
uint32_t sw: 1; /*Write 1 will trigger a software forced capture on channel 0*/
|
||||
uint32_t reserved13: 19;
|
||||
};
|
||||
uint32_t val;
|
||||
}cap_cfg_ch[3];
|
||||
uint32_t cap_val_ch[3]; /*Value of last capture on channel 0*/
|
||||
union {
|
||||
struct {
|
||||
uint32_t cap0_edge: 1; /*Edge of last capture trigger on channel 0 0: posedge 1: negedge*/
|
||||
uint32_t cap1_edge: 1; /*Edge of last capture trigger on channel 1 0: posedge 1: negedge*/
|
||||
uint32_t cap2_edge: 1; /*Edge of last capture trigger on channel 2 0: posedge 1: negedge*/
|
||||
uint32_t reserved3: 29;
|
||||
};
|
||||
uint32_t val;
|
||||
}cap_status;
|
||||
union {
|
||||
struct {
|
||||
uint32_t global_up_en: 1; /*The global enable of update of all active registers in MCPWM module*/
|
||||
uint32_t global_force_up: 1; /*a toggle (software invert its value) will trigger a forced update of all active registers in MCPWM module*/
|
||||
uint32_t op0_up_en: 1; /*When set and PWM_GLOBAL_UP_EN is set update of active registers in PWM operator 0 are enabled*/
|
||||
uint32_t op0_force_up: 1; /*a toggle (software invert its value) will trigger a forced update of active registers in PWM operator 0*/
|
||||
uint32_t op1_up_en: 1; /*When set and PWM_GLOBAL_UP_EN is set update of active registers in PWM operator 1 are enabled*/
|
||||
uint32_t op1_force_up: 1; /*a toggle (software invert its value) will trigger a forced update of active registers in PWM operator 1*/
|
||||
uint32_t op2_up_en: 1; /*When set and PWM_GLOBAL_UP_EN is set update of active registers in PWM operator 2 are enabled*/
|
||||
uint32_t op2_force_up: 1; /*a toggle (software invert its value) will trigger a forced update of active registers in PWM operator 2*/
|
||||
uint32_t reserved8: 24;
|
||||
};
|
||||
uint32_t val;
|
||||
}update_cfg;
|
||||
union {
|
||||
struct {
|
||||
uint32_t timer0_stop_int_ena: 1; /*Interrupt when timer 0 stops*/
|
||||
uint32_t timer1_stop_int_ena: 1; /*Interrupt when timer 1 stops*/
|
||||
uint32_t timer2_stop_int_ena: 1; /*Interrupt when timer 2 stops*/
|
||||
uint32_t timer0_tez_int_ena: 1; /*A PWM timer 0 TEZ event will trigger this interrupt*/
|
||||
uint32_t timer1_tez_int_ena: 1; /*A PWM timer 1 TEZ event will trigger this interrupt*/
|
||||
uint32_t timer2_tez_int_ena: 1; /*A PWM timer 2 TEZ event will trigger this interrupt*/
|
||||
uint32_t timer0_tep_int_ena: 1; /*A PWM timer 0 TEP event will trigger this interrupt*/
|
||||
uint32_t timer1_tep_int_ena: 1; /*A PWM timer 1 TEP event will trigger this interrupt*/
|
||||
uint32_t timer2_tep_int_ena: 1; /*A PWM timer 2 TEP event will trigger this interrupt*/
|
||||
uint32_t fault0_int_ena: 1; /*Interrupt when event_f0 starts*/
|
||||
uint32_t fault1_int_ena: 1; /*Interrupt when event_f1 starts*/
|
||||
uint32_t fault2_int_ena: 1; /*Interrupt when event_f2 starts*/
|
||||
uint32_t fault0_clr_int_ena: 1; /*Interrupt when event_f0 ends*/
|
||||
uint32_t fault1_clr_int_ena: 1; /*Interrupt when event_f1 ends*/
|
||||
uint32_t fault2_clr_int_ena: 1; /*Interrupt when event_f2 ends*/
|
||||
uint32_t cmpr0_tea_int_ena: 1; /*A PWM operator 0 TEA event will trigger this interrupt*/
|
||||
uint32_t cmpr1_tea_int_ena: 1; /*A PWM operator 1 TEA event will trigger this interrupt*/
|
||||
uint32_t cmpr2_tea_int_ena: 1; /*A PWM operator 2 TEA event will trigger this interrupt*/
|
||||
uint32_t cmpr0_teb_int_ena: 1; /*A PWM operator 0 TEB event will trigger this interrupt*/
|
||||
uint32_t cmpr1_teb_int_ena: 1; /*A PWM operator 1 TEB event will trigger this interrupt*/
|
||||
uint32_t cmpr2_teb_int_ena: 1; /*A PWM operator 2 TEB event will trigger this interrupt*/
|
||||
uint32_t tz0_cbc_int_ena: 1; /*An cycle-by-cycle trip event on PWM0 will trigger this interrupt*/
|
||||
uint32_t tz1_cbc_int_ena: 1; /*An cycle-by-cycle trip event on PWM1 will trigger this interrupt*/
|
||||
uint32_t tz2_cbc_int_ena: 1; /*An cycle-by-cycle trip event on PWM2 will trigger this interrupt*/
|
||||
uint32_t tz0_ost_int_ena: 1; /*An one-shot trip event on PWM0 will trigger this interrupt*/
|
||||
uint32_t tz1_ost_int_ena: 1; /*An one-shot trip event on PWM1 will trigger this interrupt*/
|
||||
uint32_t tz2_ost_int_ena: 1; /*An one-shot trip event on PWM2 will trigger this interrupt*/
|
||||
uint32_t cap0_int_ena: 1; /*A capture on channel 0 will trigger this interrupt*/
|
||||
uint32_t cap1_int_ena: 1; /*A capture on channel 1 will trigger this interrupt*/
|
||||
uint32_t cap2_int_ena: 1; /*A capture on channel 2 will trigger this interrupt*/
|
||||
uint32_t reserved30: 2;
|
||||
};
|
||||
uint32_t val;
|
||||
}int_ena;
|
||||
union {
|
||||
struct {
|
||||
uint32_t timer0_stop_int_raw: 1; /*Interrupt when timer 0 stops*/
|
||||
uint32_t timer1_stop_int_raw: 1; /*Interrupt when timer 1 stops*/
|
||||
uint32_t timer2_stop_int_raw: 1; /*Interrupt when timer 2 stops*/
|
||||
uint32_t timer0_tez_int_raw: 1; /*A PWM timer 0 TEZ event will trigger this interrupt*/
|
||||
uint32_t timer1_tez_int_raw: 1; /*A PWM timer 1 TEZ event will trigger this interrupt*/
|
||||
uint32_t timer2_tez_int_raw: 1; /*A PWM timer 2 TEZ event will trigger this interrupt*/
|
||||
uint32_t timer0_tep_int_raw: 1; /*A PWM timer 0 TEP event will trigger this interrupt*/
|
||||
uint32_t timer1_tep_int_raw: 1; /*A PWM timer 1 TEP event will trigger this interrupt*/
|
||||
uint32_t timer2_tep_int_raw: 1; /*A PWM timer 2 TEP event will trigger this interrupt*/
|
||||
uint32_t fault0_int_raw: 1; /*Interrupt when event_f0 starts*/
|
||||
uint32_t fault1_int_raw: 1; /*Interrupt when event_f1 starts*/
|
||||
uint32_t fault2_int_raw: 1; /*Interrupt when event_f2 starts*/
|
||||
uint32_t fault0_clr_int_raw: 1; /*Interrupt when event_f0 ends*/
|
||||
uint32_t fault1_clr_int_raw: 1; /*Interrupt when event_f1 ends*/
|
||||
uint32_t fault2_clr_int_raw: 1; /*Interrupt when event_f2 ends*/
|
||||
uint32_t cmpr0_tea_int_raw: 1; /*A PWM operator 0 TEA event will trigger this interrupt*/
|
||||
uint32_t cmpr1_tea_int_raw: 1; /*A PWM operator 1 TEA event will trigger this interrupt*/
|
||||
uint32_t cmpr2_tea_int_raw: 1; /*A PWM operator 2 TEA event will trigger this interrupt*/
|
||||
uint32_t cmpr0_teb_int_raw: 1; /*A PWM operator 0 TEB event will trigger this interrupt*/
|
||||
uint32_t cmpr1_teb_int_raw: 1; /*A PWM operator 1 TEB event will trigger this interrupt*/
|
||||
uint32_t cmpr2_teb_int_raw: 1; /*A PWM operator 2 TEB event will trigger this interrupt*/
|
||||
uint32_t tz0_cbc_int_raw: 1; /*An cycle-by-cycle trip event on PWM0 will trigger this interrupt*/
|
||||
uint32_t tz1_cbc_int_raw: 1; /*An cycle-by-cycle trip event on PWM1 will trigger this interrupt*/
|
||||
uint32_t tz2_cbc_int_raw: 1; /*An cycle-by-cycle trip event on PWM2 will trigger this interrupt*/
|
||||
uint32_t tz0_ost_int_raw: 1; /*An one-shot trip event on PWM0 will trigger this interrupt*/
|
||||
uint32_t tz1_ost_int_raw: 1; /*An one-shot trip event on PWM1 will trigger this interrupt*/
|
||||
uint32_t tz2_ost_int_raw: 1; /*An one-shot trip event on PWM2 will trigger this interrupt*/
|
||||
uint32_t cap0_int_raw: 1; /*A capture on channel 0 will trigger this interrupt*/
|
||||
uint32_t cap1_int_raw: 1; /*A capture on channel 1 will trigger this interrupt*/
|
||||
uint32_t cap2_int_raw: 1; /*A capture on channel 2 will trigger this interrupt*/
|
||||
uint32_t reserved30: 2;
|
||||
};
|
||||
uint32_t val;
|
||||
}int_raw;
|
||||
union {
|
||||
struct {
|
||||
uint32_t timer0_stop_int_st: 1; /*Interrupt when timer 0 stops*/
|
||||
uint32_t timer1_stop_int_st: 1; /*Interrupt when timer 1 stops*/
|
||||
uint32_t timer2_stop_int_st: 1; /*Interrupt when timer 2 stops*/
|
||||
uint32_t timer0_tez_int_st: 1; /*A PWM timer 0 TEZ event will trigger this interrupt*/
|
||||
uint32_t timer1_tez_int_st: 1; /*A PWM timer 1 TEZ event will trigger this interrupt*/
|
||||
uint32_t timer2_tez_int_st: 1; /*A PWM timer 2 TEZ event will trigger this interrupt*/
|
||||
uint32_t timer0_tep_int_st: 1; /*A PWM timer 0 TEP event will trigger this interrupt*/
|
||||
uint32_t timer1_tep_int_st: 1; /*A PWM timer 1 TEP event will trigger this interrupt*/
|
||||
uint32_t timer2_tep_int_st: 1; /*A PWM timer 2 TEP event will trigger this interrupt*/
|
||||
uint32_t fault0_int_st: 1; /*Interrupt when event_f0 starts*/
|
||||
uint32_t fault1_int_st: 1; /*Interrupt when event_f1 starts*/
|
||||
uint32_t fault2_int_st: 1; /*Interrupt when event_f2 starts*/
|
||||
uint32_t fault0_clr_int_st: 1; /*Interrupt when event_f0 ends*/
|
||||
uint32_t fault1_clr_int_st: 1; /*Interrupt when event_f1 ends*/
|
||||
uint32_t fault2_clr_int_st: 1; /*Interrupt when event_f2 ends*/
|
||||
uint32_t cmpr0_tea_int_st: 1; /*A PWM operator 0 TEA event will trigger this interrupt*/
|
||||
uint32_t cmpr1_tea_int_st: 1; /*A PWM operator 1 TEA event will trigger this interrupt*/
|
||||
uint32_t cmpr2_tea_int_st: 1; /*A PWM operator 2 TEA event will trigger this interrupt*/
|
||||
uint32_t cmpr0_teb_int_st: 1; /*A PWM operator 0 TEB event will trigger this interrupt*/
|
||||
uint32_t cmpr1_teb_int_st: 1; /*A PWM operator 1 TEB event will trigger this interrupt*/
|
||||
uint32_t cmpr2_teb_int_st: 1; /*A PWM operator 2 TEB event will trigger this interrupt*/
|
||||
uint32_t tz0_cbc_int_st: 1; /*An cycle-by-cycle trip event on PWM0 will trigger this interrupt*/
|
||||
uint32_t tz1_cbc_int_st: 1; /*An cycle-by-cycle trip event on PWM1 will trigger this interrupt*/
|
||||
uint32_t tz2_cbc_int_st: 1; /*An cycle-by-cycle trip event on PWM2 will trigger this interrupt*/
|
||||
uint32_t tz0_ost_int_st: 1; /*An one-shot trip event on PWM0 will trigger this interrupt*/
|
||||
uint32_t tz1_ost_int_st: 1; /*An one-shot trip event on PWM1 will trigger this interrupt*/
|
||||
uint32_t tz2_ost_int_st: 1; /*An one-shot trip event on PWM2 will trigger this interrupt*/
|
||||
uint32_t cap0_int_st: 1; /*A capture on channel 0 will trigger this interrupt*/
|
||||
uint32_t cap1_int_st: 1; /*A capture on channel 1 will trigger this interrupt*/
|
||||
uint32_t cap2_int_st: 1; /*A capture on channel 2 will trigger this interrupt*/
|
||||
uint32_t reserved30: 2;
|
||||
};
|
||||
uint32_t val;
|
||||
}int_st;
|
||||
union {
|
||||
struct {
|
||||
uint32_t timer0_stop_int_clr: 1; /*Interrupt when timer 0 stops*/
|
||||
uint32_t timer1_stop_int_clr: 1; /*Interrupt when timer 1 stops*/
|
||||
uint32_t timer2_stop_int_clr: 1; /*Interrupt when timer 2 stops*/
|
||||
uint32_t timer0_tez_int_clr: 1; /*A PWM timer 0 TEZ event will trigger this interrupt*/
|
||||
uint32_t timer1_tez_int_clr: 1; /*A PWM timer 1 TEZ event will trigger this interrupt*/
|
||||
uint32_t timer2_tez_int_clr: 1; /*A PWM timer 2 TEZ event will trigger this interrupt*/
|
||||
uint32_t timer0_tep_int_clr: 1; /*A PWM timer 0 TEP event will trigger this interrupt*/
|
||||
uint32_t timer1_tep_int_clr: 1; /*A PWM timer 1 TEP event will trigger this interrupt*/
|
||||
uint32_t timer2_tep_int_clr: 1; /*A PWM timer 2 TEP event will trigger this interrupt*/
|
||||
uint32_t fault0_int_clr: 1; /*Interrupt when event_f0 starts*/
|
||||
uint32_t fault1_int_clr: 1; /*Interrupt when event_f1 starts*/
|
||||
uint32_t fault2_int_clr: 1; /*Interrupt when event_f2 starts*/
|
||||
uint32_t fault0_clr_int_clr: 1; /*Interrupt when event_f0 ends*/
|
||||
uint32_t fault1_clr_int_clr: 1; /*Interrupt when event_f1 ends*/
|
||||
uint32_t fault2_clr_int_clr: 1; /*Interrupt when event_f2 ends*/
|
||||
uint32_t cmpr0_tea_int_clr: 1; /*A PWM operator 0 TEA event will trigger this interrupt*/
|
||||
uint32_t cmpr1_tea_int_clr: 1; /*A PWM operator 1 TEA event will trigger this interrupt*/
|
||||
uint32_t cmpr2_tea_int_clr: 1; /*A PWM operator 2 TEA event will trigger this interrupt*/
|
||||
uint32_t cmpr0_teb_int_clr: 1; /*A PWM operator 0 TEB event will trigger this interrupt*/
|
||||
uint32_t cmpr1_teb_int_clr: 1; /*A PWM operator 1 TEB event will trigger this interrupt*/
|
||||
uint32_t cmpr2_teb_int_clr: 1; /*A PWM operator 2 TEB event will trigger this interrupt*/
|
||||
uint32_t tz0_cbc_int_clr: 1; /*An cycle-by-cycle trip event on PWM0 will trigger this interrupt*/
|
||||
uint32_t tz1_cbc_int_clr: 1; /*An cycle-by-cycle trip event on PWM1 will trigger this interrupt*/
|
||||
uint32_t tz2_cbc_int_clr: 1; /*An cycle-by-cycle trip event on PWM2 will trigger this interrupt*/
|
||||
uint32_t tz0_ost_int_clr: 1; /*An one-shot trip event on PWM0 will trigger this interrupt*/
|
||||
uint32_t tz1_ost_int_clr: 1; /*An one-shot trip event on PWM1 will trigger this interrupt*/
|
||||
uint32_t tz2_ost_int_clr: 1; /*An one-shot trip event on PWM2 will trigger this interrupt*/
|
||||
uint32_t cap0_int_clr: 1; /*A capture on channel 0 will trigger this interrupt*/
|
||||
uint32_t cap1_int_clr: 1; /*A capture on channel 1 will trigger this interrupt*/
|
||||
uint32_t cap2_int_clr: 1; /*A capture on channel 2 will trigger this interrupt*/
|
||||
uint32_t reserved30: 2;
|
||||
};
|
||||
uint32_t val;
|
||||
}int_clr;
|
||||
union {
|
||||
struct {
|
||||
uint32_t clk_en: 1; /*Force clock on for this reg file*/
|
||||
uint32_t reserved1: 31;
|
||||
};
|
||||
uint32_t val;
|
||||
}reg_clk;
|
||||
union {
|
||||
struct {
|
||||
uint32_t date: 28; /*Version of this reg file*/
|
||||
uint32_t reserved28: 4;
|
||||
};
|
||||
uint32_t val;
|
||||
}version;
|
||||
} mcpwm_dev_t;
|
||||
extern mcpwm_dev_t MCPWM0;
|
||||
extern mcpwm_dev_t MCPWM1;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SOC_MCPWM_STRUCT_H__ */
|
@ -54,6 +54,7 @@ typedef enum {
|
||||
PERIPH_CRYPTO_DMA_MODULE, //this DMA is shared between AES and SHA
|
||||
PERIPH_AES_DMA_MODULE,
|
||||
PERIPH_SHA_DMA_MODULE,
|
||||
PERIPH_MODULE_MAX
|
||||
} periph_module_t;
|
||||
|
||||
typedef enum {
|
||||
|
@ -14,6 +14,4 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#define TIMER_GROUP_SUPPORTS_XTAL_CLOCK
|
||||
|
||||
#define WDT_SOURCE_CLK_FREQ_MHZ (80) // Watch Dog clock source comes from APB, which is 80MHz by default
|
||||
#define SOC_TIMER_GROUP_SUPPORT_XTAL
|
||||
|
@ -29,11 +29,6 @@ _Static_assert(TIMER_INTR_T0 == TIMG_T0_INT_CLR, "Add mapping to LL interrupt ha
|
||||
_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");
|
||||
_Static_assert(TIMER_INTR_WDT == TIMG_WDT_INT_CLR, "Add mapping to LL interrupt handling, since it's no longer naturally compatible with the timer_intr_t");
|
||||
|
||||
typedef struct {
|
||||
timg_dev_t *dev;
|
||||
timer_idx_t idx;
|
||||
} timer_ll_context_t;
|
||||
|
||||
// Get timer group instance with giving group number
|
||||
#define TIMER_LL_GET_HW(num) ((num == 0) ? (&TIMERG0) : (&TIMERG1))
|
||||
|
||||
@ -42,12 +37,18 @@ typedef struct {
|
||||
*
|
||||
* @param hw Beginning address of the peripheral registers.
|
||||
* @param timer_num The timer number
|
||||
* @param divider Prescale value
|
||||
* @param divider Prescale value (0 and 1 are not valid)
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
static inline void timer_ll_set_divider(timg_dev_t *hw, timer_idx_t timer_num, uint16_t divider)
|
||||
static inline void timer_ll_set_divider(timg_dev_t *hw, timer_idx_t timer_num, uint32_t divider)
|
||||
{
|
||||
// refer to TRM 18.2.1
|
||||
if (divider == 65536) {
|
||||
divider = 0;
|
||||
} else if (divider == 1) {
|
||||
divider = 2;
|
||||
}
|
||||
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;
|
||||
@ -63,9 +64,15 @@ static inline void timer_ll_set_divider(timg_dev_t *hw, timer_idx_t timer_num, u
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
static inline void timer_ll_get_divider(timg_dev_t *hw, timer_idx_t timer_num, uint16_t *divider)
|
||||
static inline void timer_ll_get_divider(timg_dev_t *hw, timer_idx_t timer_num, uint32_t *divider)
|
||||
{
|
||||
*divider = hw->hw_timer[timer_num].config.divider;
|
||||
uint32_t d = hw->hw_timer[timer_num].config.divider;
|
||||
if (d == 0) {
|
||||
d = 65536;
|
||||
} else if (d == 1) {
|
||||
d = 2;
|
||||
}
|
||||
*divider = d;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -255,6 +262,7 @@ static inline bool timer_ll_get_alarm_enable(timg_dev_t *hw, timer_idx_t timer_n
|
||||
FORCE_INLINE_ATTR void timer_ll_intr_enable(timg_dev_t *hw, timer_idx_t timer_num)
|
||||
{
|
||||
hw->int_ena.val |= BIT(timer_num);
|
||||
hw->hw_timer[timer_num].config.level_int_en = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -268,6 +276,7 @@ FORCE_INLINE_ATTR void timer_ll_intr_enable(timg_dev_t *hw, timer_idx_t timer_nu
|
||||
FORCE_INLINE_ATTR void timer_ll_intr_disable(timg_dev_t *hw, timer_idx_t timer_num)
|
||||
{
|
||||
hw->int_ena.val &= (~BIT(timer_num));
|
||||
hw->hw_timer[timer_num].config.level_int_en = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -372,13 +381,17 @@ static inline bool timer_ll_get_edge_int_enable(timg_dev_t *hw, timer_idx_t time
|
||||
* @brief Get interrupt status register address.
|
||||
*
|
||||
* @param hw Beginning address of the peripheral registers.
|
||||
* @param intr_status_reg Interrupt status register address
|
||||
*
|
||||
* @return None
|
||||
* @return Interrupt status register address
|
||||
*/
|
||||
static inline void timer_ll_get_intr_status_reg(timg_dev_t *hw, uint32_t *intr_status_reg)
|
||||
static inline uint32_t timer_ll_get_intr_status_reg(timg_dev_t *hw)
|
||||
{
|
||||
*intr_status_reg = (uint32_t)&(hw->int_st_timers.val);
|
||||
return (uint32_t) & (hw->int_st_timers.val);
|
||||
}
|
||||
|
||||
static inline uint32_t timer_ll_get_intr_mask_bit(timg_dev_t *hw, timer_idx_t timer_num)
|
||||
{
|
||||
return (1U << timer_num);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -29,11 +29,6 @@ _Static_assert(TIMER_INTR_T0 == TIMG_T0_INT_CLR, "Add mapping to LL interrupt ha
|
||||
_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");
|
||||
_Static_assert(TIMER_INTR_WDT == TIMG_WDT_INT_CLR, "Add mapping to LL interrupt handling, since it's no longer naturally compatible with the timer_intr_t");
|
||||
|
||||
typedef struct {
|
||||
timg_dev_t *dev;
|
||||
timer_idx_t idx;
|
||||
} timer_ll_context_t;
|
||||
|
||||
// Get timer group instance with giving group number
|
||||
#define TIMER_LL_GET_HW(num) ((num == 0) ? (&TIMERG0) : (&TIMERG1))
|
||||
|
||||
@ -42,12 +37,16 @@ typedef struct {
|
||||
*
|
||||
* @param hw Beginning address of the peripheral registers.
|
||||
* @param timer_num The timer number
|
||||
* @param divider Prescale value
|
||||
* @param divider Prescale value (0 is not valid)
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
static inline void timer_ll_set_divider(timg_dev_t *hw, timer_idx_t timer_num, uint16_t divider)
|
||||
static inline void timer_ll_set_divider(timg_dev_t *hw, timer_idx_t timer_num, uint32_t divider)
|
||||
{
|
||||
// refer to TRM 12.2.1
|
||||
if (divider == 65536) {
|
||||
divider = 0;
|
||||
}
|
||||
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;
|
||||
@ -63,9 +62,13 @@ static inline void timer_ll_set_divider(timg_dev_t *hw, timer_idx_t timer_num, u
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
static inline void timer_ll_get_divider(timg_dev_t *hw, timer_idx_t timer_num, uint16_t *divider)
|
||||
static inline void timer_ll_get_divider(timg_dev_t *hw, timer_idx_t timer_num, uint32_t *divider)
|
||||
{
|
||||
*divider = hw->hw_timer[timer_num].config.divider;
|
||||
uint32_t d = hw->hw_timer[timer_num].config.divider;
|
||||
if (d == 0) {
|
||||
d = 65536;
|
||||
}
|
||||
*divider = d;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -255,6 +258,7 @@ static inline bool timer_ll_get_alarm_enable(timg_dev_t *hw, timer_idx_t timer_n
|
||||
FORCE_INLINE_ATTR void timer_ll_intr_enable(timg_dev_t *hw, timer_idx_t timer_num)
|
||||
{
|
||||
hw->int_ena.val |= BIT(timer_num);
|
||||
hw->hw_timer[timer_num].config.level_int_en = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -268,6 +272,7 @@ FORCE_INLINE_ATTR void timer_ll_intr_enable(timg_dev_t *hw, timer_idx_t timer_nu
|
||||
FORCE_INLINE_ATTR void timer_ll_intr_disable(timg_dev_t *hw, timer_idx_t timer_num)
|
||||
{
|
||||
hw->int_ena.val &= (~BIT(timer_num));
|
||||
hw->hw_timer[timer_num].config.level_int_en = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -372,13 +377,17 @@ static inline bool timer_ll_get_edge_int_enable(timg_dev_t *hw, timer_idx_t time
|
||||
* @brief Get interrupt status register address.
|
||||
*
|
||||
* @param hw Beginning address of the peripheral registers.
|
||||
* @param intr_status_reg Interrupt status register address
|
||||
*
|
||||
* @return None
|
||||
* @return uint32_t Interrupt status register address
|
||||
*/
|
||||
static inline void timer_ll_get_intr_status_reg(timg_dev_t *hw, uint32_t *intr_status_reg)
|
||||
static inline uint32_t timer_ll_get_intr_status_reg(timg_dev_t *hw)
|
||||
{
|
||||
*intr_status_reg = (uint32_t)&(hw->int_st.val);
|
||||
return (uint32_t) & (hw->int_st.val);
|
||||
}
|
||||
|
||||
static inline uint32_t timer_ll_get_intr_mask_bit(timg_dev_t *hw, timer_idx_t timer_num)
|
||||
{
|
||||
return (1U << timer_num);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -20,3 +20,9 @@ void timer_hal_init(timer_hal_context_t *hal, timer_group_t group_num, timer_idx
|
||||
hal->dev = TIMER_LL_GET_HW(group_num);
|
||||
hal->idx = timer_num;
|
||||
}
|
||||
|
||||
void timer_hal_get_status_reg_mask_bit(timer_hal_context_t *hal, uint32_t *status_reg, uint32_t *mask_bit)
|
||||
{
|
||||
*status_reg = timer_ll_get_intr_status_reg(hal->dev);
|
||||
*mask_bit = timer_ll_get_intr_mask_bit(hal->dev, hal->idx);
|
||||
}
|
@ -41,7 +41,7 @@ xQueueHandle timer_queue;
|
||||
static void inline print_timer_counter(uint64_t counter_value)
|
||||
{
|
||||
printf("Counter: 0x%08x%08x\n", (uint32_t) (counter_value >> 32),
|
||||
(uint32_t) (counter_value));
|
||||
(uint32_t) (counter_value));
|
||||
printf("Time : %.8f s\n", (double) counter_value / TIMER_SCALE);
|
||||
}
|
||||
|
||||
@ -101,19 +101,16 @@ void IRAM_ATTR timer_group0_isr(void *para)
|
||||
* timer_interval_sec - the interval of alarm to set
|
||||
*/
|
||||
static void example_tg0_timer_init(int timer_idx,
|
||||
bool auto_reload, double timer_interval_sec)
|
||||
bool auto_reload, double timer_interval_sec)
|
||||
{
|
||||
/* Select and initialize basic parameters of the timer */
|
||||
timer_config_t config;
|
||||
config.divider = TIMER_DIVIDER;
|
||||
config.counter_dir = TIMER_COUNT_UP;
|
||||
config.counter_en = TIMER_PAUSE;
|
||||
config.alarm_en = TIMER_ALARM_EN;
|
||||
config.intr_type = TIMER_INTR_LEVEL;
|
||||
config.auto_reload = auto_reload;
|
||||
#ifdef TIMER_GROUP_SUPPORTS_XTAL_CLOCK
|
||||
config.clk_src = TIMER_SRC_CLK_APB;
|
||||
#endif
|
||||
timer_config_t config = {
|
||||
.divider = TIMER_DIVIDER,
|
||||
.counter_dir = TIMER_COUNT_UP,
|
||||
.counter_en = TIMER_PAUSE,
|
||||
.alarm_en = TIMER_ALARM_EN,
|
||||
.auto_reload = auto_reload,
|
||||
}; // default clock source is APB
|
||||
timer_init(TIMER_GROUP_0, timer_idx, &config);
|
||||
|
||||
/* Timer's counter will initially start from value below.
|
||||
@ -124,7 +121,7 @@ static void example_tg0_timer_init(int timer_idx,
|
||||
timer_set_alarm_value(TIMER_GROUP_0, timer_idx, timer_interval_sec * TIMER_SCALE);
|
||||
timer_enable_intr(TIMER_GROUP_0, timer_idx);
|
||||
timer_isr_register(TIMER_GROUP_0, timer_idx, timer_group0_isr,
|
||||
(void *) timer_idx, ESP_INTR_FLAG_IRAM, NULL);
|
||||
(void *) timer_idx, ESP_INTR_FLAG_IRAM, NULL);
|
||||
|
||||
timer_start(TIMER_GROUP_0, timer_idx);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user