hal_event_adapter
=================
HAL adapter converting hardware signals and interrupts into internal events and actions.
Inherited Component
-------------------
- :doc:`Platform_HAL `
Inherited Requirements
----------------------
- :doc:`REQ-IFC-001 `
- :doc:`REQ-IFC-005 `
Relationship Diagram
--------------------
.. image:: /_static/sw_unit_uml/hal_event_adapter_9629a78b-294f-4629-b709-fc03c058c26d_uml.svg
:alt: UML class diagram for hal_event_adapter
:class: dblclick-open-image
SW Unit Relations
-----------------
Incoming Relations
~~~~~~~~~~~~~~~~~~
.. list-table::
:header-rows: 1
* - Relation
- UML Type
- Visibility
- Source Unit
- Description
* - :doc:`SWR-017 `
- dependency
- private
- :doc:`ao_monitoring `
- Monitoring consumes hardware-adapted sensor events.
* - :doc:`SWR-018 `
- dependency
- private
- :doc:`ao_modbus_server `
- Modbus server uses hardware-adapted UART events.
* - :doc:`SWR-019 `
- dependency
- private
- :doc:`drv_rgb_led `
- LED driver uses hardware abstraction events.
Data Types
----------
.. _dt-4f524dae-327c-4f52-bba3-8bc87ee70a78:
.. raw:: html
hal_event_adapter_contextstruct
Internal runtime context for hal_event_adapter.
.. rubric:: Struct Members
.. list-table::
:header-rows: 1
* - Name
- Type
- Description
* - sensor_path_ready
- :ref:`bool `
- Sensor HAL path readiness.
* - uart_path_ready
- :ref:`bool `
- UART HAL path readiness.
* - led_path_ready
- :ref:`bool `
- LED HAL path readiness.
* - last_hal_tick
- :ref:`uint32_t `
- Last adaptation tick.
.. _dt-022a2389-eaf6-422a-b23c-37e842640e7e:
.. raw:: html
hal_event_adapter_eventstruct
Event payload handled by hal_event_adapter.
.. rubric:: Struct Members
.. list-table::
:header-rows: 1
* - Name
- Type
- Description
* - signal_id
- :ref:`uint16_t `
- HAL adapter event id.
* - source_channel
- :ref:`uint8_t `
- HAL source channel.
* - raw_code
- :ref:`uint16_t `
- Raw HAL code.
* - data_valid
- :ref:`bool `
- Raw data validation result.
.. _dt-4a899fb6-d425-4a89-9bfa-2bf4435addab:
.. raw:: html
hal_event_adapter_resultenum
Result code for hal_event_adapter operations.
.. rubric:: Enum Members
.. list-table::
:header-rows: 1
* - Name
- Value
- Description
* - OK
- 0
- HAL event normalized.
* - SOURCE_UNAVAILABLE
- 1
- Expected source unavailable.
* - NORMALIZATION_ERROR
- 2
- Payload normalization failed.
Attributes
----------
.. list-table::
:header-rows: 1
* - Attribute
- Type
- Visibility
- Description
* - ctx
- :ref:`hal_event_adapter_context `
- private
- Runtime context for hal_event_adapter state timing and error tracking.
Methods
-------
dispatch
~~~~~~~~
- **Return Type:** :ref:`hal_event_adapter_result `
- **Visibility:** public
- **Description:** Process one hal_event_adapter event and update runtime outputs.
.. rubric:: Parameters
.. list-table::
:header-rows: 1
* - Name
- Type
- Direction
- Description
* - event
- :ref:`hal_event_adapter_event `
- in
- Process one hal_event_adapter event and update runtime outputs.
init
~~~~
- **Return Type:** :ref:`hal_event_adapter_result `
- **Visibility:** public
- **Description:** Initialize hal_event_adapter runtime state and dependencies.
Dynamic Behaviour
-----------------
Activity Diagrams
~~~~~~~~~~~~~~~~~
hal_event_adapter_activity
^^^^^^^^^^^^^^^^^^^^^^^^^^
.. uml::
@startuml
start
:Receive raw HAL interrupt or poll data;
:Normalize hardware payload;
if (source == sensor) then (yes)
:Build monitoring event;
elseif (source == uart) then (yes)
:Build modbus RX or TX event;
elseif (source == led driver) then (yes)
:Build LED driver completion event;
endif
:Publish normalized event to dispatcher;
stop
@enduml
This activity diagram documents HAL adaptation flow from raw interrupt or polled hardware signals to normalized software events with source specific mapping for sensors communication and LED subsystems.
Timing Diagrams
~~~~~~~~~~~~~~~
hal_event_adapter_timing
^^^^^^^^^^^^^^^^^^^^^^^^
.. uml::
@startuml
robust "hal_event_adapter" as HAL
scale max 1200 width
concise "io event" as E
@0
E is irq_or_poll
HAL is normalize_event
@60
HAL is route_channel
@120
HAL is publish_upstream
@180
HAL is idle
@enduml
This timing diagram characterizes adapter latency from raw hardware event detection to normalized event publication and helps budget interrupt or polling integration delays.
Sequence Diagrams
~~~~~~~~~~~~~~~~~
SEQ-004_Modbus_Event_Servicing
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. uml::
@startuml
hide footbox
title Modbus Server Event Servicing
participant ao_runtime_supervisor
participant ao_modbus_server
participant hal_event_adapter
ao_runtime_supervisor -> ao_modbus_server : dispatch comms_event
ao_modbus_server -> hal_event_adapter : request UART I/O
hal_event_adapter --> ao_modbus_server : uart_rx/tx completion
ao_modbus_server -> hal_event_adapter : publish protocol response
@enduml
Runtime-driven communication events are processed by the Modbus server through hardware-adapted UART event exchange.