HAL NOR Overview

Introducing NOR

group NOR_Introduction

  • The NOR hardware abstraction layer provides a set of APIs to interface with NOR flash memory devices via the STM32 Flexible Memory Controller (FMC) peripheral.

  • The NOR HAL driver simplifies the implementation of memory operations such as reading, writing, and erasing by managing peripheral initialization, configuration, and data handling.

  • This abstraction layer ensures portability and ease of use across different STM32 series.

Module and files

The following diagram illustrates the NOR module and its associated files.

Module and files diagram

Component diagram

The following diagram illustrates the software components involved in the NOR module. It shows the interactions between the user application, HAL drivers, low-level drivers, and the hardware components.

@startuml
!$use_nor_core = 1

!$use_hal_service = 1
!$use_hal_rcc = 1
!$use_hal_dma = 0

!$use_ll_rcc = 0

!$core = "FMC" + "_CORE"
!$nor = "NOR"
!$NOR = "FMC"
!$hal_api_itf = "HAL " + $nor + " API"
!$nor_name = "HAL_"+$nor
!$ll_nor = "LL_"+$nor

!$hal_dma_itf = "HAL_DMA_StartDirectXfer_IT_Opt()\nHAL_DMA_Abort_IT"
!$hal_rcc_itf = "\t\t\tHAL_RCC_GetSYSCLKFreq()\n\t\t\tHAL_RCC_"+$nor+"_GetClockFreq()\n\t\t\tHAL_RCC_"+$NOR+"_EnableClock()"
!$hal_nor_itf = "Half transfer complete\nTransfer complete\nError callback\nAbort callback"
!$ll_nor_itf = "LL " + $nor +" API"

<style>
componentDiagram {
arrow {
FontSize 8
}
interface {
FontSize 8
}
}
</style>

title $nor Software Component Diagram

Package "Application Layer" {

component [Appli]
}

package "HAL" {
[$nor_name]
!if ($use_hal_dma == 1)
interface "$hal_nor_itf" as HAL_NOR_Interface
[$nor_name] -d- HAL_NOR_Interface
!endif
interface "$hal_api_itf" as HAL_NOR_APPLI_Interface
[$nor_name] -u- HAL_NOR_APPLI_Interface

!if ($use_hal_dma == 1)
  [HAL_DMA]
  interface "$hal_dma_itf" as HAL_DMA_Interface
  [HAL_DMA] -u- HAL_DMA_Interface
  [HAL_DMA] -u-( HAL_NOR_Interface
  [$nor_name] --( HAL_DMA_Interface
!endif
!if ($use_hal_rcc == 1)
  [HAL_RCC]
  interface "$hal_rcc_itf" as HAL_RCC_Interface
  [HAL_RCC] -l- HAL_RCC_Interface
  [$nor_name] -r-( HAL_RCC_Interface
!endif
}

[Appli] -d-( HAL_NOR_APPLI_Interface

!if ($use_nor_core ==1)
Package "Core Layer" {
[$core]
interface "core API" as Core_api_itf
[$core] -u- Core_api_itf
}
[$nor_name] -d-( Core_api_itf
!endif
package "Low Layer" {

!if ($use_nor_ll == 1)
  [$ll_nor]
  interface "$ll_nor_itf" as LL_NOR_Interface
  [$ll_nor]  -u- LL_NOR_Interface
!endif

[CMSIS-Devices]
!if ($use_ll_rcc == 1)
  [LL_RCC]
  interface "LL RCC API" as LL_RCC_API
  [LL_RCC] -u- LL_RCC_API
  [HAL_RCC] -d-(LL_RCC_API
!endif

!if ($use_hal_dma == 1)
  [DMA ISR]
  interface "DMA ISR" as DMA_ISR
  [DMA ISR] -u- DMA_ISR
!endif
}

package "HW"  {
[STM32_HW]
!if ($use_hal_dma == 1)
interface "DMAx_IRQ_Ch" as DMA_IRQ_CH
[STM32_HW] -u- DMA_IRQ_CH
[DMA ISR] -d-( DMA_IRQ_CH
[HAL_DMA] --( DMA_ISR
!endif
}
!if ($use_nor_ll == 1)
[$nor_name] -d-( LL_NOR_Interface
[$ll_nor] .r.> [CMSIS-Devices]: $nor register def
[STM32_HW] <.u. [$ll_nor] : $nor registers R/W
!else
!if ($use_nor_core == 1)
[$core] .d.> [CMSIS-Devices]: $nor register def
[STM32_HW] <.l. [$core] : $nor registers R/W
!else
[$nor_name] .d.> [CMSIS-Devices]: $nor register def
[STM32_HW] <.l. [$nor_name] : $nor registers R/W
!endif
!endif
!if ($use_ll_rcc == 1)
[STM32_HW] <.u. [LL_RCC] : RCC registers R/W
!endif

@enduml

Configuration table

The following table lists the configuration defines for the HAL NOR module, specifying their locations, default values, and descriptions:

group NOR_Configuration_Table

Configuration inside the NOR driver

Config defines

Description

Default value

Note

USE_ASSERT_DBG_PARAM

from IDE

NA

Allows to use the assert check parameters.

USE_ASSERT_DBG_STATE

from IDE

NA

Allows to use the assert check states.

USE_HAL_CHECK_PARAM

from hal_conf.h

0U

Allows to use the run-time check parameters.

USE_HAL_CHECK_PROCESS_STATE

from hal_conf.h

0U

Allows to ensure a safe state transition.

USE_HAL_NOR_MODULE

from hal_conf.h

1U

Allows to use the HAL NOR module.

USE_HAL_NOR_PROTECTION

from hal_conf.h

0U

Allows to enable program protection register.

USE_FMC_CLK_ENABLE_MODEL

from hal_conf.h

HAL_CLK_ENABLE_NO

Allows to enable the FMC clock.

USE_HAL_NOR_USER_DATA

from hal_conf.h

0U

Allows to use user data.