- Updated README.md to include new configuration options for native timing values, TX/RX polarity, power-down polling, and logging levels. - Introduced new default values for query response timeout and double-send delay in dali.c. - Implemented a function to drain stale RX frames from the queue to improve query handling. - Enhanced DALI HAL implementation in dali_hal_idf5.c with additional configuration options for timer resolution and bus power check intervals. - Added logging capabilities to track bus states and message transmissions in the DALI HAL. - Improved error handling and message response mechanisms in dali_domain.cpp and gateway_usb_setup.cpp for better communication reliability. - Refactored GPIO handling to support configurable TX/RX active states in dali_hal.h. - Introduced legacy query response handling for backward compatibility in the DALI domain. Signed-off-by: Tony <tonylu@tony-cloud.com>
DALI ESP-IDF Component
This component provides a DALI (IEC 62386) protocol stack and ESP-IDF HAL implementation that can be used directly in native FreeRTOS/ESP-IDF projects.
Features
- DALI forward and backward frame support.
- Multi-bus support (
DALI_PHY_COUNT, default 16). - Runtime baudrate control (
400..2400, default1200). - ESP-IDF GPTimer + GPIO interrupt driven HAL.
Public Headers
dali.h: high-level DALI helpers.dali_hal.h: HAL API and queue access.dali_define.h: DALI command definitions.
Quick Start
- Add this component to your project.
- Configure TX/RX pins and initialize at least one bus.
- Send a DALI frame.
#include "dali.h"
#include "dali_define.h"
#include "dali_hal.h"
void app_main(void) {
ESP_ERROR_CHECK(dali_hal_set_baudrate(1200));
ESP_ERROR_CHECK(dali_hal_init(0, 4, 5));
Dali_msg_t msg = dali_msg_new(0xFF, DALI_CMD_ON); // broadcast ON command
msg.id = 0;
dali_send(&msg);
}
Kconfig Options
Use menuconfig under DALI Component to configure:
- Bus count and default baudrate.
- Native timing values for development, including timer resolution, half-bit period, TX/RX stop conditions, query response timeout, and double-send delay.
- TX/RX active polarity. The native gateway default is TX active low and RX active high.
- Native bus power-down polling and legacy
FF FDbus-abnormal raw-frame reporting intervals. - Native DALI HAL log level for the
dali_halESP-IDF log tag. - Queue sizes.
- Task stack sizes and priorities.
- Optional debug task.
The native bus monitor uses CONFIG_DALI_BUS_POWER_CHECK_INTERVAL_MS to resample RX while
power-down and CONFIG_DALI_BUS_ABNORMAL_REPORT_INTERVAL_MS to publish legacy FF FD
raw frames while down. The report interval defaults to 1000 ms; set it to 0 to disable the
compatibility report.
Native timing defaults target standard 1200 bps DALI: a 416.67 us half-bit period is
generated by the default 3 MHz timer as 1250 ticks. CONFIG_DALI_CUSTOM_HALF_BIT_TIME_X100_US
can override the half-bit period for development; keep it at 0 for baudrate-derived timing.
Query no-response timeout defaults to 25 ms, which covers the 5.5-10.5 ms backward-frame
start window plus the approximately 9.95 ms backward frame duration.
API Note
The global TX response queue symbol was renamed:
- old:
dali_send_replay_queue - new:
dali_send_reply_queue
See MIGRATION.md for compatibility notes.
Examples
examples/dali_basicexamples/dali_multi_bus