drv_rgb_led
===========
Driver unit applying LED command events to RGB hardware channels.
Inherited Component
-------------------
- :doc:`RGB_LED_Driver `
Inherited Requirements
----------------------
- :doc:`REQ-IFC-005 `
Relationship Diagram
--------------------
.. image:: /_static/sw_unit_uml/drv_rgb_led_fe18dd0c-8b06-4e18-8db9-3fb3b85538a0_uml.svg
:alt: UML class diagram for drv_rgb_led
:class: dblclick-open-image
SW Unit Relations
-----------------
Outgoing Relations
~~~~~~~~~~~~~~~~~~
.. list-table::
:header-rows: 1
* - Relation
- UML Type
- Visibility
- Target Unit
- Description
* - :doc:`SWR-019 `
- dependency
- private
- :doc:`hal_event_adapter `
- LED driver uses hardware abstraction events.
Incoming Relations
~~~~~~~~~~~~~~~~~~
.. list-table::
:header-rows: 1
* - Relation
- UML Type
- Visibility
- Source Unit
- Description
* - :doc:`SWR-016 `
- dependency
- public
- :doc:`ao_status_indication `
- Status indication commands LED driver outputs.
Data Types
----------
.. _dt-9db8dabb-85e9-4db8-97f9-380da0d77cf3:
.. raw:: html
drv_rgb_led_contextstruct
Internal runtime context for drv_rgb_led.
.. rubric:: Struct Members
.. list-table::
:header-rows: 1
* - Name
- Type
- Description
* - driver_state
- :ref:`uint8_t `
- Driver state.
* - color_code
- :ref:`uint8_t `
- Applied color code.
* - blink_period_ms
- :ref:`uint16_t `
- Applied blink period.
* - hw_ready
- :ref:`bool `
- Hardware readiness.
.. _dt-aeba28c0-cc05-4eba-b881-6492d5254856:
.. raw:: html
drv_rgb_led_eventstruct
Event payload handled by drv_rgb_led.
.. rubric:: Struct Members
.. list-table::
:header-rows: 1
* - Name
- Type
- Description
* - signal_id
- :ref:`uint16_t `
- LED driver event id.
* - requested_color
- :ref:`uint8_t `
- Requested color code.
* - blink_enable
- :ref:`bool `
- Blink command.
* - intensity_pct
- :ref:`uint8_t `
- Requested intensity percent.
.. _dt-ba5209b1-fcad-4a52-bfc1-48eee3923525:
.. raw:: html
drv_rgb_led_resultenum
Result code for drv_rgb_led operations.
.. rubric:: Enum Members
.. list-table::
:header-rows: 1
* - Name
- Value
- Description
* - OK
- 0
- LED command applied.
* - HAL_WRITE_ERROR
- 1
- HAL write failed.
* - UNSUPPORTED_PATTERN
- 2
- Pattern not supported.
Attributes
----------
.. list-table::
:header-rows: 1
* - Attribute
- Type
- Visibility
- Description
* - ctx
- :ref:`drv_rgb_led_context `
- private
- Runtime context for drv_rgb_led state timing and error tracking.
Methods
-------
dispatch
~~~~~~~~
- **Return Type:** :ref:`drv_rgb_led_result `
- **Visibility:** public
- **Description:** Process one drv_rgb_led event and update runtime outputs.
.. rubric:: Parameters
.. list-table::
:header-rows: 1
* - Name
- Type
- Direction
- Description
* - event
- :ref:`drv_rgb_led_event `
- in
- Process one drv_rgb_led event and update runtime outputs.
init
~~~~
- **Return Type:** :ref:`drv_rgb_led_result `
- **Visibility:** public
- **Description:** Initialize drv_rgb_led runtime state and dependencies.
Dynamic Behaviour
-----------------
Activity Diagrams
~~~~~~~~~~~~~~~~~
drv_rgb_led_activity
^^^^^^^^^^^^^^^^^^^^
.. uml::
@startuml
start
:Receive IF_StatusLedCommand;
:Decode requested color or pattern;
:Map to hardware channel values;
:Write PWM or GPIO outputs via HAL;
if (write failed?) then (yes)
:Emit driver error event;
else (no)
:Confirm applied output;
endif
stop
@enduml
This activity diagram defines driver level translation from abstract LED intents into hardware channel writes including failure handling behavior when output programming does not complete as requested.
Timing Diagrams
~~~~~~~~~~~~~~~
drv_rgb_led_timing
^^^^^^^^^^^^^^^^^^
.. uml::
@startuml
robust "drv_rgb_led" as LED
scale max 1200 width
concise "led command" as C
@0
C is rx
LED is decode
@40
LED is map_hw_values
@90
LED is write_hw
@150
LED is applied
@enduml
This timing diagram shows driver execution from command reception through hardware mapping and write completion to validate tight actuation timing in the LED indication chain.
Sequence Diagrams
~~~~~~~~~~~~~~~~~
SEQ-003_Status_To_LED_Indication
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. uml::
@startuml
hide footbox
title Diagnostic Status To LED Indication
participant ao_diagnostics
participant ao_status_indication
participant sm_led_indication
participant drv_rgb_led
ao_diagnostics -> ao_status_indication : IF_OperatingStatus(system_status)
ao_status_indication -> sm_led_indication : evaluate indication pattern
sm_led_indication -> ao_status_indication : resolved LED intent
ao_status_indication -> drv_rgb_led : IF_StatusLedCommand(led_command)
@enduml
Diagnostics status outputs are transformed by status indication logic into concrete LED driver commands.