esp32c3: Fix IRQ initialization, it was crashing on DEBUG_ASSERTIONS

Co-author: Alan C. Assis <alan.carvalho@espressif.com>
This commit is contained in:
Gustavo Henrique Nihei 2023-01-24 10:16:43 -03:00 committed by Xiang Xiao
parent adba1e5e19
commit 80bbb0f24c
3 changed files with 8 additions and 21 deletions

View File

@ -116,10 +116,8 @@
* The ESP32-C3 CPU interrupt controller accepts 31 asynchronous interrupts.
*/
#define ESP32C3_CPUINT_MIN 1
#define ESP32C3_CPUINT_MAX 31
#define ESP32C3_NCPUINTS 32
#define ESP32C3_CPUINT_MAX (ESP32C3_NCPUINTS - 1)
#define ESP32C3_CPUINT_MAC 0
#define ESP32C3_CPUINT_MAC_NMI 1

View File

@ -189,8 +189,6 @@ static int esp32c3_getcpuint(void)
void up_irqinitialize(void)
{
int periphid;
/* Indicate that no peripheral interrupts are assigned to CPU interrupts */
for (int i = 0; i < NR_IRQS; i++)
@ -213,16 +211,9 @@ void up_irqinitialize(void)
g_cpu_intmap[ESP32C3_CPUINT_RWBLE] = CPUINT_ASSIGN(ESP32C3_IRQ_RWBLE);
#endif
/* Clear all peripheral interrupts from "bootloader" */
/* Initialize CPU interrupts */
for (periphid = 0; periphid < ESP32C3_NPERIPHERALS; periphid++)
{
putreg32(0, DR_REG_INTERRUPT_BASE + periphid * 4);
}
/* Set CPU interrupt threshold level */
putreg32(ESP32C3_DEFAULT_INT_THRESHOLD, INTERRUPT_CPU_INT_THRESH_REG);
esp32c3_cpuint_initialize();
/* Attach the common interrupt handler */
@ -257,7 +248,7 @@ void up_enable_irq(int irq)
irqinfo("irq=%d | cpuint=%d \n", irq, cpuint);
DEBUGASSERT(cpuint >= ESP32C3_CPUINT_MIN && cpuint <= ESP32C3_CPUINT_MAX);
DEBUGASSERT(cpuint >= 0 && cpuint <= ESP32C3_CPUINT_MAX);
irqstate = enter_critical_section();
setbits(1 << cpuint, INTERRUPT_CPU_INT_ENABLE_REG);
@ -379,6 +370,10 @@ int esp32c3_cpuint_initialize(void)
putreg32(0, DR_REG_INTERRUPT_BASE + i * 4);
}
/* Set CPU interrupt threshold level */
putreg32(ESP32C3_DEFAULT_INT_THRESHOLD, INTERRUPT_CPU_INT_THRESH_REG);
/* Indicate that no peripheral interrupts are assigned to CPU interrupts */
memset(g_cpu_intmap, CPUINT_UNASSIGNED, ESP32C3_NCPUINTS);

View File

@ -253,12 +253,6 @@ void __esp32c3_start(void)
esp32c3_region_protection();
#endif
#ifndef CONFIG_SUPPRESS_INTERRUPTS
/* Put the CPU Interrupts in initial state */
esp32c3_cpuint_initialize();
#endif
/* Initialize RTC parameters */
esp32c3_rtc_init();