HAL SMBUS Use Cases

Prerequisite

@startuml
==Prerequisite==

participant App as "User application"
participant "HAL GENERIC" as GENERIC
participant "HAL RCC" as RCC

App -> GENERIC : HAL_Init
GENERIC --> App
App -> RCC : Configure system clock
RCC --> App
@enduml

Full SMBUS Initialization Sequence

@startuml

participant App as "User application"
participant "<font color=green><b>HAL SMBUS</b></font>" as SMBUS
participant "HAL CORTEX\n(NVIC)" as CORTEX
participant "HAL RCC" as RCC
participant "HAL GPIO" as GPIO

==SMBUS HAL Initialization  ==
App -> SMBUS : HAL_SMBUS_Init
alt#grey #lightgrey If USE_HAL_SMBUS_CLK_ENABLE_MODEL > HAL_CLK_ENABLE_NO
SMBUS->RCC : Enable the SMBUS clock
RCC-->SMBUS
end
App <-- SMBUS : HAL_OK

==SMBUS System Initialization==
Note over SMBUS : SMBUS System initialization can be called before\nSMBUS HAL initialization



alt#grey #lightgrey If Interrupt needed
App->CORTEX : Enable needed Interrupt
CORTEX-->App
end

alt#grey #lightgrey If GPIO(s) needed
App->GPIO : Initialization of GPIOs
GPIO-->App
end

alt#grey #lightgrey If USE_HAL_SMBUS_CLK_ENABLE_MODEL == HAL_CLK_ENABLE_NO
App->RCC : Enable the SMBUS clock
RCC --> App
end

==SMBUS Configuration==
App -> SMBUS : HAL_SMBUS_SetConfig
App <-- SMBUS :HAL_OK

note over App : Driver state is IDLE,\nUser can start any process or execute any configuration.
==Advanced SMBUS Configuration==
App -> SMBUS : HAL_SMBUS_SetConfigXXX
App <-- SMBUS :HAL_OK
App -> SMBUS : HAL_SMBUS_SetMode
App <-- SMBUS :HAL_OK
App -> SMBUS : HAL_SMBUS_EnableXXX
App <-- SMBUS :HAL_OK
@enduml

Called functions:

Full SMBUS Deinitialization Sequence

@startuml
participant App as "User application"
participant "<font color=green><b>HAL SMBUS</b></font>" as SMBUS
participant "HAL CORTEX\n(NVIC)" as CORTEX
participant "HAL RCC" as RCC
participant "HAL GPIO" as GPIO

==SMBUS DeInitialisation==
App->SMBUS : HAL_SMBUS_DeInit
App<--SMBUS

==SMBUS system DeInitalization==

alt#grey #lightgrey If Interrupt needed
App->CORTEX : Disable needed Interrupt
CORTEX-->App
end

alt#grey #lightgrey If GPIO(s) needed
App->GPIO : DeInitialization of GPIOs
GPIO-->App
end

App->RCC : Disable the SMBUS clock
RCC --> App
@enduml

Called functions:

Process Polling

@startuml
participant App as "User application"
participant "<font color=green><b>HAL SMBUS</b></font>" as SMBUS

==Process :  Master Transmit Polling==
App -> SMBUS : HAL_SMBUS_MASTER_PollForSlaveReady(...,uint32_t timeout_ms)

alt successful case
   App <-- SMBUS : HAL_OK
else invalid param
   App <-- SMBUS : HAL_INVALID_PARAM
else busy
   App <-- SMBUS : HAL_BUSY
   note over App : Another Process is running...\nPlease wait and retry.
else error case
   note over App : Process can timeout or run out of trials waiting Slave acknowledgement
   App <-- SMBUS : HAL_TIMEOUT
App -> SMBUS : \

alt#grey #lightgrey If USE_HAL_SMBUS_GET_LAST_ERRORS == 1
App->SMBUS : HAL_SMBUS_GetLastErrors()
App <-- SMBUS : \
(HAL_SMBUS_ERROR_XXX | HAL_SMBUS_ERROR_YYY)
end

end
note over App : Driver state is IDLE,\nUser can start any process or execute any configuration.
@enduml

Called functions:

Master Mode IT: First then Last Frame

@startuml
participant App as "User application"
participant "<font color=green><b>HAL SMBUS</b></font>" as SMBUS
==Process :  Master Mode. Send first frame then last frame ==
   App -> SMBUS : HAL_SMBUS_MASTER_SEQ_Transmit_IT(handle, addr, &buffer,\n size_in_byte = M, <font color=green><b>HAL_SMBUS_XFER_FIRST_FRAME</b></font>)
   App <-- SMBUS : HAL_OK
   ...
   loop while (size-- != 0)
      "SMBUSx_IRQHandler" <- : SMBUSx interrupt TXIS\nCMD Byte 1 ... CMD Byte M
      SMBUS <- "SMBUSx_IRQHandler" : HAL_SMBUS_EV_IRQHandler
      note over SMBUS : SMBUS_Master_ISR()
      alt if (size-- != 0)
         note over SMBUS : buffer++;\nTXDR = buffer[0];
      else else
         App <- SMBUS : HAL_SMBUS_MASTER_TxCpltCallback
         App --> SMBUS
      end

      SMBUS --> "SMBUSx_IRQHandler"
      "SMBUSx_IRQHandler" -->
   end

   App -> SMBUS : HAL_SMBUS_MASTER_SEQ_Receive_IT(handle, addr, &buffer,\n size_in_byte = N bytes, <font color=blue><b>HAL_SMBUS_XFER_LAST_FRAME_NO_PEC</b></font>)
   App <-- SMBUS : HAL_OK
   ...
   loop while (size-- != 0)
      "SMBUSx_IRQHandler" <- : SMBUSx interrupt RXNE\nByte 1 ...  Byte N
      SMBUS <- "SMBUSx_IRQHandler" : HAL_SMBUS_EV_IRQHandler
      note over SMBUS : SMBUS_Master_ISR()
      alt if (size-- != 0)
         note over SMBUS : buffer++;\nbuffer[0] = RXDR;
      end
      SMBUS --> "SMBUSx_IRQHandler"
      "SMBUSx_IRQHandler" -->
   end
   ...
   "SMBUSx_IRQHandler" <- : SMBUSx interrupt STOP
   "SMBUSx_IRQHandler" -> SMBUS : HAL_SMBUS_EV_IRQHandler
   note over SMBUS : Clear Flag STOP
   App <- SMBUS : HAL_SMBUS_MASTER_RxCpltCallback
   App --> SMBUS
   "SMBUSx_IRQHandler" <-- SMBUS
   "SMBUSx_IRQHandler" -->
note over App : Driver state is IDLE,\nUser can start any process or execute any configuration.
@enduml

Called functions:

Master Mode IT: First and Last Frame

@startuml
participant App as "User application"
participant "<font color=green><b>HAL SMBUS</b></font>" as SMBUS
==Process :  Master Mode. Send first and last frame ==
   App -> SMBUS : HAL_SMBUS_MASTER_SEQ_Transmit_IT(handle, addr, &buffer,\n size_in_byte = M, <font color=blue><b>HAL_SMBUS_XFER_FIRST_AND_LAST_FRAME_NO_PEC</b></font>)
   App <-- SMBUS : HAL_OK
   ...
   loop while (size-- != 0)
      "SMBUSx_IRQHandler" <- : SMBUSx interrupt TXIS\nCMD Byte 1 ... CMD Byte M
      SMBUS <- "SMBUSx_IRQHandler" : HAL_SMBUS_EV_IRQHandler
      note over SMBUS : SMBUS_Master_ISR()
      alt if (size-- != 0)
         note over SMBUS : buffer++;\nTXDR = buffer[0];
      end
   end
   "SMBUSx_IRQHandler" <- : SMBUSx interrupt STOP
   "SMBUSx_IRQHandler" -> SMBUS : HAL_SMBUS_EV_IRQHandler
   note over SMBUS : Clear Flag STOP
   App <- SMBUS : HAL_SMBUS_MASTER_TxCpltCallback
   App --> SMBUS
   "SMBUSx_IRQHandler" <-- SMBUS
   "SMBUSx_IRQHandler" -->
note over App : Driver state is IDLE,\nUser can start any process or execute any configuration.
@enduml

Called functions:

Master Mode IT: First then Other and Last Frame

@startuml
participant App as "User application"
participant "<font color=green><b>HAL SMBUS</b></font>" as SMBUS
==Process :  Master Mode. Send first then other and last frame ==
   App -> SMBUS : HAL_SMBUS_MASTER_SEQ_Transmit_IT(handle, addr, &buffer,\n size_in_byte = M, <font color=green><b>HAL_SMBUS_XFER_FIRST_FRAME</b></font>)
   App <-- SMBUS : HAL_OK
   ...
   loop while (size-- != 0)
      "SMBUSx_IRQHandler" <- : SMBUSx interrupt TXIS\nCMD Byte 1 ... CMD Byte M
      SMBUS <- "SMBUSx_IRQHandler" : HAL_SMBUS_EV_IRQHandler
      note over SMBUS : SMBUS_Master_ISR()
      alt if (size-- != 0)
         note over SMBUS : buffer++;\nTXDR = buffer[0];
      else else
         App <- SMBUS : HAL_SMBUS_MASTER_TxCpltCallback
         App --> SMBUS
      end

      SMBUS --> "SMBUSx_IRQHandler"
      "SMBUSx_IRQHandler" -->
   end

   note over SMBUS : OTHER option manage the restart condition no matter the direction
   App -> SMBUS : HAL_SMBUS_MASTER_SEQ_Transmit_IT(handle, addr, &buffer,\n size_in_byte = M, <font color=blue><b>HAL_SMBUS_XFER_OTHER_AND_LAST_FRAME_NO_PEC</b></font>)
   App <-- SMBUS : HAL_OK
   ...
   loop while (size-- != 0)
      "SMBUSx_IRQHandler" <- : SMBUSx interrupt TXIS\nCMD Byte 1 ... CMD Byte M
      SMBUS <- "SMBUSx_IRQHandler" : HAL_SMBUS_EV_IRQHandler
      note over SMBUS : SMBUS_Master_ISR()
      alt if (size-- != 0)
         note over SMBUS : buffer++;\nTXDR = buffer[0];
      end
   end
   "SMBUSx_IRQHandler" <- : SMBUSx interrupt STOP
   "SMBUSx_IRQHandler" -> SMBUS : HAL_SMBUS_EV_IRQHandler
   note over SMBUS : Clear Flag STOP
   App <- SMBUS : HAL_SMBUS_MASTER_TxCpltCallback
   App --> SMBUS
   "SMBUSx_IRQHandler" <-- SMBUS
   "SMBUSx_IRQHandler" -->
note over App : Driver state is IDLE,\nUser can start any process or execute any configuration.
@enduml

Called functions:

Master Mode IT: First, Next, Last Frame

@startuml
participant App as "User application"
participant "<font color=green><b>HAL SMBUS</b></font>" as SMBUS
==Process :  Master Mode. Send first, next, last frame ==
   App -> SMBUS : HAL_SMBUS_MASTER_SEQ_Transmit_IT(handle, addr, &buffer,\n size_in_byte = M, <font color=green><b>HAL_SMBUS_XFER_FIRST_FRAME</b></font>)
   App <-- SMBUS : HAL_OK
   ...
   loop while (size-- != 0)
      "SMBUSx_IRQHandler" <- : SMBUSx interrupt TXIS\nCMD Byte 1 ... CMD Byte M
      SMBUS <- "SMBUSx_IRQHandler" : HAL_SMBUS_EV_IRQHandler
      note over SMBUS : SMBUS_Master_ISR()
      alt if (size-- != 0)
         note over SMBUS : buffer++;\nTXDR = buffer[0];
      else elsif (size == 0 and STOPF flag)
         App <- SMBUS : HAL_SMBUS_MASTER_TxCpltCallback
         App --> SMBUS
      end

      SMBUS --> "SMBUSx_IRQHandler"
      "SMBUSx_IRQHandler" -->
   end
   App -> SMBUS : HAL_SMBUS_MASTER_SEQ_Transmit_IT(handle, addr, &buffer,\n size_in_byte = M, HAL_SMBUS_XFER_NEXT)
   App <-- SMBUS : HAL_OK
   loop while (size-- != 0)
      "SMBUSx_IRQHandler" <- : SMBUSx interrupt TXIS\nCMD Byte 1 ... CMD Byte M
      SMBUS <- "SMBUSx_IRQHandler" : HAL_SMBUS_EV_IRQHandler
      note over SMBUS : SMBUS_Master_ISR()
      alt if (size-- != 0)
         note over SMBUS : buffer++;\nTXDR = buffer[0];
      else elsif (size == 0 and STOPF flag)
         App <- SMBUS : HAL_SMBUS_MASTER_TxCpltCallback
         App --> SMBUS
      end

      SMBUS --> "SMBUSx_IRQHandler"
      "SMBUSx_IRQHandler" -->
   end
   App -> SMBUS : HAL_SMBUS_MASTER_SEQ_Receive_IT(handle, addr, &buffer,\n size_in_byte = N bytes, <font color=blue><b>HAL_SMBUS_XFER_LAST_FRAME_NO_PEC</b></font>)
   App <-- SMBUS : HAL_OK
   ...
   loop while (size-- != 0)
      "SMBUSx_IRQHandler" <- : SMBUSx interrupt RXNE\nByte 1 ...  Byte N
      SMBUS <- "SMBUSx_IRQHandler" : HAL_SMBUS_EV_IRQHandler
      note over SMBUS : SMBUS_Master_ISR()
      alt if (size-- != 0)
         note over SMBUS : buffer++;\nbuffer[0] = RXDR;
      end
      SMBUS --> "SMBUSx_IRQHandler"
      "SMBUSx_IRQHandler" -->
   end
   ...
   "SMBUSx_IRQHandler" <- : SMBUSx interrupt STOP
   "SMBUSx_IRQHandler" -> SMBUS : HAL_SMBUS_EV_IRQHandler
   note over SMBUS : Clear Flag STOP
   App <- SMBUS : HAL_SMBUS_MASTER_RxCpltCallback
   App --> SMBUS
   "SMBUSx_IRQHandler" <-- SMBUS
   "SMBUSx_IRQHandler" -->
note over App : Driver state is IDLE,\nUser can start any process or execute any configuration.

@enduml

Called functions:

Master Mode IT: Send CMD M bytes + Receive N bytes

@startuml
participant App as "User application"
participant "<font color=green><b>HAL SMBUS</b></font>" as SMBUS
==Process :  Master Mode. Send CMD M bytes + Receive N bytes ==
alt Option <font color=green><b>HAL_SMBUS_XFER_FIRST_FRAME</b></font>
   App -> SMBUS : HAL_SMBUS_MASTER_SEQ_Transmit_IT(handle, addr, &buffer,\n size_in_byte = M, <font color=green><b>HAL_SMBUS_XFER_FIRST_FRAME</b></font>)
   App <-- SMBUS : HAL_OK
   ...
   loop while (size-- != 0)
      "SMBUSx_IRQHandler" <- : SMBUSx interrupt TXIS\nCMD Byte 1 ... CMD Byte M
      SMBUS <- "SMBUSx_IRQHandler" : HAL_SMBUS_EV_IRQHandler
      note over SMBUS : SMBUS_Master_ISR()
      alt if (size-- != 0)
         note over SMBUS : buffer++;\nTXDR = buffer[0];
      else elsif (size == 0 and STOPF flag)
         App <- SMBUS : HAL_SMBUS_MASTER_TxCpltCallback
         App --> SMBUS
      end

      SMBUS --> "SMBUSx_IRQHandler"
      "SMBUSx_IRQHandler" -->
   end
   note over SMBUS : User can chose to continue to transmit bytes or end the transmission with LAST_FRAME option
end
...
alt Option HAL_SMBUS_XFER_OTHER_NO_PEC
   note over SMBUS : This option is used once FIRST_FRAME has already been sent
   note over SMBUS : OTHER option manage the restart condition no matter the direction
   App -> SMBUS : HAL_SMBUS_MASTER_SEQ_Transmit_IT(handle, addr, &buffer,\n size_in_byte = M, HAL_SMBUS_XFER_OTHER_NO_PEC)
   App <-- SMBUS : HAL_OK
   ...
   loop while (size-- != 0)
      "SMBUSx_IRQHandler" <- : SMBUSx interrupt TXIS\nCMD Byte 1 ... CMD Byte M
      SMBUS <- "SMBUSx_IRQHandler" : HAL_SMBUS_EV_IRQHandler
      note over SMBUS : SMBUS_Master_ISR()
      alt if (size-- != 0)
         note over SMBUS : buffer++;\nTXDR = buffer[0];
      else else
         App <- SMBUS : HAL_SMBUS_MASTER_TxCpltCallback
         App --> SMBUS
      end

      SMBUS --> "SMBUSx_IRQHandler"
      "SMBUSx_IRQHandler" -->
   end
      note over SMBUS : User can chose to continue to transmit bytes or end the transmission with LAST_FRAME option()
end
...
alt Option <font color=blue><b>HAL_SMBUS_XFER_LAST_FRAME_NO_PEC</b></font>
   App -> SMBUS : HAL_SMBUS_MASTER_SEQ_Receive_IT(handle, addr, &buffer,\n size_in_byte = N bytes, <font color=blue><b>HAL_SMBUS_XFER_LAST_FRAME_NO_PEC</b></font>)
   App <-- SMBUS : HAL_OK
   ...
   loop while (size-- != 0)
      "SMBUSx_IRQHandler" <- : SMBUSx interrupt RXNE\nByte 1 ...  Byte N
      SMBUS <- "SMBUSx_IRQHandler" : HAL_SMBUS_EV_IRQHandler
      note over SMBUS : SMBUS_Master_ISR()
      alt if (size-- != 0)
         note over SMBUS : buffer++;\nbuffer[0] = RXDR;
      end
      SMBUS --> "SMBUSx_IRQHandler"
      "SMBUSx_IRQHandler" -->
   end
   ...
   "SMBUSx_IRQHandler" <- : SMBUSx interrupt STOP
   "SMBUSx_IRQHandler" -> SMBUS : HAL_SMBUS_EV_IRQHandler
   note over SMBUS : Clear Flag STOP
   App <- SMBUS : HAL_SMBUS_MASTER_RxCpltCallback
   App --> SMBUS
   "SMBUSx_IRQHandler" <-- SMBUS
   "SMBUSx_IRQHandler" -->
note over App : Driver state is IDLE,\nUser can start any process or execute any configuration.
end
...
alt Option <font color=blue><b>HAL_SMBUS_XFER_FIRST_AND_LAST_FRAME_NO_PEC</b></font>
   App -> SMBUS : HAL_SMBUS_MASTER_SEQ_Transmit_IT(handle, addr, &buffer,\n size_in_byte = M, <font color=blue><b>HAL_SMBUS_XFER_FIRST_AND_LAST_FRAME_NO_PEC</b></font>)
   App <-- SMBUS : HAL_OK
   ...
   loop while (size-- != 0)
      "SMBUSx_IRQHandler" <- : SMBUSx interrupt TXIS\nCMD Byte 1 ... CMD Byte M
      SMBUS <- "SMBUSx_IRQHandler" : HAL_SMBUS_EV_IRQHandler
      note over SMBUS : SMBUS_Master_ISR()
      alt if (size-- != 0)
         note over SMBUS : buffer++;\nTXDR = buffer[0];
      end
   end
   "SMBUSx_IRQHandler" <- : SMBUSx interrupt STOP
   "SMBUSx_IRQHandler" -> SMBUS : HAL_SMBUS_EV_IRQHandler
   note over SMBUS : Clear Flag STOP
   App <- SMBUS : HAL_SMBUS_MASTER_TxCpltCallback
   App --> SMBUS
   "SMBUSx_IRQHandler" <-- SMBUS
   "SMBUSx_IRQHandler" -->
note over App : Driver state is IDLE,\nUser can start any process or execute any configuration.
end
...
alt Option <font color=blue><b>HAL_SMBUS_XFER_OTHER_AND_LAST_FRAME_NO_PEC</b></font>
   note over SMBUS : This option is used once FIRST_FRAME has already been sent
   note over SMBUS : OTHER option manage the restart condition no matter the direction
   App -> SMBUS : HAL_SMBUS_MASTER_SEQ_Transmit_IT(handle, addr, &buffer,\n size_in_byte = M, <font color=blue><b>HAL_SMBUS_XFER_OTHER_AND_LAST_FRAME_NO_PEC</b></font>)
   App <-- SMBUS : HAL_OK
   ...
   loop while (size-- != 0)
      "SMBUSx_IRQHandler" <- : SMBUSx interrupt TXIS\nCMD Byte 1 ... CMD Byte M
      SMBUS <- "SMBUSx_IRQHandler" : HAL_SMBUS_EV_IRQHandler
      note over SMBUS : SMBUS_Master_ISR()
      alt if (size-- != 0)
         note over SMBUS : buffer++;\nTXDR = buffer[0];
      end
   end
   "SMBUSx_IRQHandler" <- : SMBUSx interrupt STOP
   "SMBUSx_IRQHandler" -> SMBUS : HAL_SMBUS_EV_IRQHandler
   note over SMBUS : Clear Flag STOP
   App <- SMBUS : HAL_SMBUS_MASTER_TxCpltCallback
   App --> SMBUS
   "SMBUSx_IRQHandler" <-- SMBUS
   "SMBUSx_IRQHandler" -->
note over App : Driver state is IDLE,\nUser can start any process or execute any configuration.
end
...
@enduml

Called functions:

Slave Mode IT: Receive CMD M bytes + Send N bytes

@startuml
participant App as "User application"
participant "<font color=green><b>HAL SMBUS</b></font>" as SMBUS
==Process :  Slave Mode. Receive CMD M bytes + Send N bytes ==

App -> SMBUS : HAL_SMBUS_SLAVE_EnableListen_IT(handle)
note over SMBUS : Enable ADDRI, STOPI, NACKI, ERRI
App <-- SMBUS : HAL_OK
...
"SMBUSx_IRQHandler" <- : SMBUSx interrupt ADDR, DIR=Wr
"SMBUSx_IRQHandler" -> SMBUS : HAL_SMBUS_EV_IRQHandler
note over SMBUS : SMBUS_Slave_ISR()
App <- SMBUS : HAL_SMBUS_SLAVE_AddrCallback(handle,\nDirection=Write, Addr Match code)
App --> SMBUS
"SMBUSx_IRQHandler" <-- SMBUS
"SMBUSx_IRQHandler" -->
...
App -> SMBUS : HAL_SMBUS_SLAVE_SEQ_Receive_IT(handle, addr, &buffer,\n size_in_byte = M, <font color=green><b>HAL_SMBUS_XFER_FIRST_FRAME</b></font>)
App <-- SMBUS : HAL_OK
...
loop while (size-- != 0)
   "SMBUSx_IRQHandler" <- : SMBUSx interrupt RXNE, CMD Byte 1 ... CMD Byte M
   SMBUS <- "SMBUSx_IRQHandler" : HAL_SMBUS_EV_IRQHandler
   note over SMBUS : SMBUS_Slave_ISR()
   alt if (size-- != 0)
      note over SMBUS : buffer++;\nbuffer[0] = RXDR;
   else else
      App <- SMBUS : HAL_SMBUS_SLAVE_RxCpltCallback
      App --> SMBUS
   end
   SMBUS --> "SMBUSx_IRQHandler"
   "SMBUSx_IRQHandler" -->
end
...
"SMBUSx_IRQHandler" <- : SMBUSx interrupt ADDR, DIR=Rd
"SMBUSx_IRQHandler" -> SMBUS : HAL_SMBUS_EV_IRQHandler
note over SMBUS : SMBUS_Slave_ISR()
App <- SMBUS : HAL_SMBUS_SLAVE_AddrCallback(handle,\nDirection=Read, Addr Match Code)
App --> SMBUS
"SMBUSx_IRQHandler" <-- SMBUS
"SMBUSx_IRQHandler" -->
...
App -> SMBUS : HAL_SMBUS_SLAVE_SEQ_Transmit_IT(handle, addr, &buffer,\n size_in_byte = N, <font color=blue><b>HAL_SMBUS_XFER_LAST_FRAME_NO_PEC</b></font>)
App <-- SMBUS : HAL_OK
...
loop while (size-- != 0)
   "SMBUSx_IRQHandler" <- : SMBUSx interrupt TXIS, Byte 1 ... Byte N
   SMBUS <- "SMBUSx_IRQHandler" : HAL_SMBUS_EV_IRQHandler
   note over SMBUS : SMBUS_Slave_ISR()
   alt if (size-- != 0)
      note over SMBUS : buffer++;\nTXDR = buffer[0];
   else else
      App <- SMBUS : HAL_SMBUS_SLAVE_TxCpltCallback
      App --> SMBUS
   end
   SMBUS --> "SMBUSx_IRQHandler"
   "SMBUSx_IRQHandler" -->
end
...
"SMBUSx_IRQHandler" <- : SMBUSx interrupt STOP
"SMBUSx_IRQHandler" -> SMBUS : HAL_SMBUS_EV_IRQHandler
note over SMBUS : Clear Flag STOP
App <- SMBUS : HAL_SMBUS_SLAVE_ListenCpltCallback
App --> SMBUS
"SMBUSx_IRQHandler" <-- SMBUS
"SMBUSx_IRQHandler" -->

note over App : Driver state is IDLE,\nUser can start any process or execute any configuration.
@enduml

Called functions:

Process Master Abort IT

@startuml
participant App as "User application"
participant "<font color=green><b>HAL SMBUS</b></font>" as SMBUS
==Process abort : asynchronous Master Transmit (IT)\n==

App -> SMBUS : HAL_SMBUS_MASTER_SEQ_Transmit_IT
App <-- SMBUS : HAL_OK
...
App -> SMBUS : HAL_SMBUS_MASTER_Abort_IT
App <-- SMBUS : HAL_OK
...
"SMBUSx_IRQHandler" <- : SMBUSx Stop complete interrupt
"SMBUSx_IRQHandler" -> SMBUS : HAL_SMBUS_EV_IRQHandler
App <- SMBUS : HAL_SMBUS_AbortCpltCallback
App --> SMBUS
"SMBUSx_IRQHandler" <-- SMBUS
"SMBUSx_IRQHandler" -->


note over App : Driver state is IDLE,\nUser can start any process or execute any configuration.
@enduml

Called functions:

Process Slave Abort IT

@startuml
participant App as "User application"
participant "<font color=green><b>HAL SMBUS</b></font>" as SMBUS
==Process abort : asynchronous Slave Transmit (IT)\n==

App -> SMBUS : HAL_SMBUS_SLAVE_SEQ_Transmit_IT
App <-- SMBUS : HAL_OK
...
App -> SMBUS : HAL_SMBUS_SLAVE_Abort_IT
App <-- SMBUS : HAL_OK

note over SMBUS : No Acknowledge on the next data.
...
"SMBUSx_IRQHandler" <- : SMBUSx Stop complete interrupt
"SMBUSx_IRQHandler" -> SMBUS : HAL_SMBUS_EV_IRQHandler
App <- SMBUS : HAL_SMBUS_AbortCpltCallback
App --> SMBUS
"SMBUSx_IRQHandler" <-- SMBUS
"SMBUSx_IRQHandler" -->


note over App : Driver state is IDLE,\nUser can start any process or execute any configuration.
@enduml

Called functions:

Recoverable Blocking Error

@startuml
participant App as "User application"
participant "<font color=green><b>HAL SMBUS</b></font>" as SMBUS
==Process recoverable blocking error : asynchronous Master Transmit (IT)\n ==

App -> SMBUS : HAL_SMBUS_MASTER_SEQ_Transmit_IT
App <-- SMBUS : HAL_OK
...
SMBUS <- :  SMBUSx recoverable error interrupt
App <-[#Orange] SMBUS :\
<color #Orange> HAL_SMBUS_ErrorCallback(&hSMBUS) </color>

alt#grey #lightgrey If USE_HAL_SMBUS_GET_LAST_ERRORS == 1
App->SMBUS : HAL_SMBUS_GetLastErrors()
App <-- SMBUS : \
(HAL_SMBUS_ERROR_XXX | HAL_SMBUS_ERROR_YYY)
end

App [#Orange]--> SMBUS
SMBUS -->

note over App : Driver state is IDLE,\nUser can start any process or execute\n any configuration.
@enduml

Called functions: - HAL_SMBUS_MASTER_SEQ_Transmit_IT() - HAL_SMBUS_ErrorCallback() - HAL_SMBUS_GetLastErrorCodes()

Acquire/Release

@startuml

participant "User 1"
participant "User 2"
participant "<font color=green><b>HAL SMBUS</b></font>" as SMBUS
participant "HAL OS wrapper"

"User 1"-[#green]>SMBUS : <color #green>HAL_SMBUS_AcquireBus</color>
SMBUS-[#green]>"HAL OS wrapper" :<color #green>HAL_OS_SemaphoreTake</color>
SMBUS <-[#green]- "HAL OS wrapper"
"User 1" <-[#green]- SMBUS : <color #green>HAL_OK</color>

note over SMBUS : Bus acquired by user 1. Any Process can be executed.\nFor instance : Master Transmit

"User 2"-[#red]>SMBUS : <color #red>HAL_SMBUS_AcquireBus</color>
SMBUS-[#red]>"HAL OS wrapper" :<color #red>HAL_OS_SemaphoreTake</color>

"User 1"-[#green]>SMBUS : <color #green>HAL_SMBUS_ReleaseBus</color>
"User 1" <-[#green]- SMBUS : <color #green>HAL_OK</color>

SMBUS <-[#red]- "HAL OS wrapper"
"User 2" <-[#red]- SMBUS : <color #red>HAL_OK</color>

note over SMBUS : Bus acquired by user 2. Any Process can be executed.\nFor instance : Master Transmit
@enduml

Called functions: