mirror of
https://github.com/micropython/micropython.git
synced 2025-12-16 09:50:15 +01:00
stm32/irq: Define IRQ priorities directly as encoded hardware values.
For a given IRQn (eg UART) there's no need to carry around both a PRI and SUBPRI value (eg IRQ_PRI_UART, IRQ_SUBPRI_UART). Instead, the IRQ_PRI_UART value has been changed in this patch to be the encoded hardware value, using NVIC_EncodePriority. This way the NVIC_SetPriority function can be used directly, instead of going through HAL_NVIC_SetPriority which must do extra processing to encode the PRI+SUBPRI. For a priority grouping of 4 (4 bits for preempt priority, 0 bits for the sub-priority), which is used in the stm32 port, the IRQ_PRI_xxx constants remain unchanged in their value. This patch also "fixes" the use of raise_irq_pri() which should be passed the encoded value (but as mentioned above the unencoded value is the same as the encoded value for priority grouping 4, so there was no bug from this error).
This commit is contained in:
@@ -55,7 +55,7 @@ void storage_init(void) {
|
||||
// Enable the flash IRQ, which is used to also call our storage IRQ handler
|
||||
// It needs to go at a higher priority than all those components that rely on
|
||||
// the flash storage (eg higher than USB MSC).
|
||||
HAL_NVIC_SetPriority(FLASH_IRQn, IRQ_PRI_FLASH, IRQ_SUBPRI_FLASH);
|
||||
NVIC_SetPriority(FLASH_IRQn, IRQ_PRI_FLASH);
|
||||
HAL_NVIC_EnableIRQ(FLASH_IRQn);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user