HAL HSP How to Use

group HSP_How_To_Use

How to use the HSP HAL module driver

Usage

  1. Declare a hal_hsp_handle_t handle and initialize the HSP driver with an HSP instance by calling HAL_HSP_Init(). The HSP clock is enabled inside HAL_HSP_Init() if USE_HAL_HSP_CLK_ENABLE_MODEL > HAL_CLK_ENABLE_NO.

  2. Configure the low-level hardware (CLOCK, NVIC…):

  3. Load the Firmware Code part & Data part with HAL_HSP_LoadFirmware(). The Firmware is based on the Firmware Code Part version embedded in the CROM. The Firmwares are delivered through the Middleware HSP Engine.

  4. Load Plugin with HAL_HSP_LoadPlugin() (Optional) This step requires one call per Plugin. The Plugins are delivered through the Middleware HSP Engine.

  5. Boot the HSP with HAL_HSP_Boot() On success, the handle state is set to HAL_HSP_STATE_RUNNING. The HSP is ready to use.

  6. HSP Processing in Accelerator Mode

    • To process a processing function (Accelerator mode), call in order, the following APIs:

      Refer to the HSP Processing Functions User Manual(UM3360) to find all processing functions available for the Accelerator mode.

      The Middleware HSP Engine embeds API for each Processing Function available in Accelerator Mode.

  7. HSP Processing in Sequencer Mode

    • Record a processing list

      1. Start the recording:

      2. Record a processing function:

        • Prepare all parameters with HAL_HSP_WriteParameter() according to the Processing Function User Manual.

          Any buffer address set as parameter must be allocated in the “.HSP_DATA_BRAM” memory region defined in the linker file.

        • Send the Processing Function ID with HAL_HSP_MSGBOX_SendMessage().

      3. Iterate the previous step to record several processing functions.

      4. Stop the recording:

      The MSGBOX command identifiers are defined in the HSP Firmware definitions file provided by the MW HSP Engine.

    • Configure a trigger to run a processing list

      A trigger could be an HSP STREAM Buffer, a peripheral event(such as DMA Transfer Complete)… It must be attached to an HSP Event within the range [1..22].

      To attach a Processing List to an HSP Event, the Processing List ID must match the HSP Event ID.

      In polling mode, the HAL provides these APIs:

      In interrupt mode, the HAL provides these APIs:

    • Execute a Processing List

      For all Processing List attached to HSP Event (except for CSEG interface), the Hardware will trig the HSP Event and the execution of the Processing List will be scheduled by the Signal Processor Engine.

  8. HSP HAL Driver Performance & Monitoring

    • To synchronize the execution of a process list (attached to an event) by the end of another task:

      • When configuring the EVENT, configure the attribute “sync” and select one of the 4 Task Comparator (hal_hsp_event_hal_hsp_prc_task_sync_source_tsync_t)

      • Call HAL_HSP_TCU_StartComparator() to configure and Enable the selected Task Comparator Unit to start the monitoring of the end of a task

    • To reduce BRAM conflict access shared between CPU and HSP:

      • Call HAL_HSP_BRAM_EnableConflictAccessCounter() to enable the Conflict Access Counter

      • Run your processing sequence and call HAL_HSP_BRAM_GetConflictAccessCounter() to get the conflict counter value

      • Call HAL_HSP_BRAM_SetLatency() to change the BRAM Arbitration latency and try to reduce BRAM conflict access

      • Run again your processing sequence and get the conflict counter value

      • Check if the BRAM Arbitration changes reduce the number of conflict access

      • Iterate to find the best BRAM arbitration latency configuration for your application

    • To monitor the HSP with TimeStamp Capture feature:

      In polling mode:

      In interrupt mode:

      • Call HAL_HSP_TSC_Start() by specifying the capture mode and setting the interrupt parameters to HAL_HSP_TSC_IT_DATA_READY and HAL_HSP_TSC_ERR_IT_OVR to start the TimeStamp Capture in interrupt mode

      • Call HAL_HSP_TSC_Stop() to stop the TimeStamp Capture and stop all TSC interrupts

      • When a timestamp data is ready, the TimestampReadyCallback callback is called (either user callback if registered with HAL_HSP_RegisterTSC_TimestampReadyCallback(), otherwise the default weak function is called).

    • To monitor the Signal Processor Engine activity

      For this feature, HSP pins must be configured in Push-Pull mode. To do that:

      • Enable the clock for the HSP GPIOs

      • Configure HSP pins as alternate function

    • To manage the power consumption of HSP blocks call the following APIs:

    • To debug a processing list

    • To stop sensitive peripheral, call HAL_HSP_BREAK_SetMultiConfigOutput() to configure the HSP Break output (which is interconnected with this peripheral) and select HSP errors considered critical event for the application.

  9. Call HAL_HSP_DeInit() to deinitialize the HSP peripheral.

  10. Optionally Call HAL_HSP_GetInstance() to retrieve the HSP instance.

  11. Callback definition in Interrupt When the compilation define USE_HAL_HSP_REGISTER_CALLBACKS is set to 1, the user can dynamically configure the driver callbacks, via its own method:

To unregister a callback, re-register the corresponding default weak function via the registration function.

By default, after the HAL_HSP_Init() and when the state is HAL_HSP_STATE_INIT, all callbacks are set to the corresponding default weak functions.

Callbacks can be registered in handle global_state HAL_HSP_STATE_INIT, HAL_HSP_STATE_READY_TO_BOOT or HAL_HSP_STATE_RUNNING.

When the compilation define USE_HAL_HSP_REGISTER_CALLBACKS is set to 0 or not defined, the callback registration feature is not available and weak callbacks are used, represented by the default value in the table above.

Warning

On failure, the handle state is set to HAL_HSP_STATE_FAULT to prohibit any configuration or processing. HAL_HSP_DeInit() must be called and an HSP Hardware Reset is required with HAL_RCC_HSP<x>_Reset().

Warning

After the call of HAL_HSP_DeInit(), make an HSP Hardware reset with HAL_RCC_HSP<x>_Reset().