stm32h7xx_hal_driver icon indicating copy to clipboard operation
stm32h7xx_hal_driver copied to clipboard

ospi: driver is more restrictive than necessary

Open sageve opened this issue 1 year ago • 0 comments

According to my tests the the OSPI supports not only instruction phase only, but also data phase only. However, the HAL driver does not allow this configuration.

I guess that the focus at the OSPI was on flash devices, where a single data phase is not intended, But there are other use cases.

I kindly ask for allowing single data phase instead of throwing an error. This won't break any software, but allows a broader usage of the OSPI. I am aware that this is an undocumented feature.

I can submit a pull request if you agree.

https://github.com/STMicroelectronics/stm32h7xx-hal-driver/blob/6f5e35e30ac09ba7bf44139a97b289d3df53cf9c/Src/stm32h7xx_hal_ospi.c#L3076C1-L3079C1

+      if (cmd->DataMode != HAL_OSPI_DATA_NONE)
+      {
+        /* ---- Command with data ---- */
+
+        /* Configure the CCR register with all communication parameters */
+        MODIFY_REG((*ccr_reg), (OCTOSPI_CCR_DMODE  | OCTOSPI_CCR_DDTR),
+                   (cmd->DataMode | cmd->DataDtrMode));
+      }
+      else
+      {
+        /* ---- invalid command configuration (no instruction, no address, no data) ---- */
+
+        status = HAL_ERROR;
+        hospi->ErrorCode = HAL_OSPI_ERROR_INVALID_PARAM;
+      }
+      /* MODIFIED */
+
       /* ---- Invalid command configuration (no instruction, no address) ---- */
-      status = HAL_ERROR;
-      hospi->ErrorCode = HAL_OSPI_ERROR_INVALID_PARAM;

sageve avatar Oct 31 '24 16:10 sageve