Skip to content

File syn_dali.h

FileList > proto > syn_dali.h

Go to the source code of this file

Digital Addressable Lighting Interface (DALI / IEC 62386) Protocol Stack. More...

  • #include "../common/syn_defs.h"
  • #include <stdbool.h>
  • #include <stddef.h>
  • #include <stdint.h>

Classes

Type Name
struct SYN_DALI_BackwardFrame
DALI Backward Frame (Control Gear -> Master, 8-bit payload)
struct SYN_DALI_ForwardFrame
DALI Forward Frame (Master -> Control Gear, 16-bit payload)
struct SYN_DALI_SlaveConfig
DALI Slave Configuration.
struct SYN_DALI_SlaveState
DALI Slave Runtime State.

Public Types

Type Name
enum SYN_DALI_AddressType
DALI Address Types.

Public Functions

Type Name
bool syn_dali_decode_backward (uint8_t raw_8, SYN_DALI_BackwardFrame * frame)
Decode an 8-bit Slave Backward Frame.
bool syn_dali_decode_forward (uint16_t raw_16, SYN_DALI_ForwardFrame * frame)
Decode a 16-bit Master Forward Frame.
uint8_t syn_dali_encode_backward (uint8_t data)
Encode an 8-bit Slave Backward Frame.
uint16_t syn_dali_encode_forward (uint8_t addr, uint8_t data_cmd)
Encode a 16-bit Master Forward Frame.
bool syn_dali_manchester_decode_byte (const uint8_t * bit_in, uint8_t * val_out)
Decode Manchester bi-phase bit pairs into a byte value.
size_t syn_dali_manchester_encode_byte (uint8_t val, uint8_t * bit_out)
Encode a byte sequence into Manchester bi-phase bits.
SYN_Status syn_dali_slave_init (SYN_DALI_SlaveState * slave, const SYN_DALI_SlaveConfig * cfg)
Initialize a DALI Slave Control Gear instance.
SYN_Status syn_dali_slave_process (SYN_DALI_SlaveState * slave, const SYN_DALI_ForwardFrame * req, uint8_t * resp_data, bool * has_resp)
Process an incoming DALI Forward Frame on a Slave Control Gear node.

Macros

Type Name
define SYN_DALI_CMD_ADD_TO_GROUP_BASE 0x60U /\* 0x60..0x6F \*/
define SYN_DALI_CMD_DOWN 0x02U
define SYN_DALI_CMD_ENABLE_DAPC_SEQUENCE 0x09U
define SYN_DALI_CMD_ENABLE_WRITE_MEMORY 0x81U
define SYN_DALI_CMD_GO_TO_SCENE_BASE 0x10U /\* 0x10..0x1F \*/
define SYN_DALI_CMD_OFF 0x00U
define SYN_DALI_CMD_ON_AND_STEP_UP 0x08U
define SYN_DALI_CMD_QUERY_ACTUAL_LEVEL 0xA0U
define SYN_DALI_CMD_QUERY_CONTENT_DTR 0x98U
define SYN_DALI_CMD_QUERY_CONTENT_DTR1 0x9CU
define SYN_DALI_CMD_QUERY_CONTENT_DTR2 0x9DU
define SYN_DALI_CMD_QUERY_CONTROL_GEAR 0x91U
define SYN_DALI_CMD_QUERY_DEVICE_TYPE 0x99U
define SYN_DALI_CMD_QUERY_GROUPS_0_7 0xC0U
define SYN_DALI_CMD_QUERY_GROUPS_8_15 0xC1U
define SYN_DALI_CMD_QUERY_LAMP_FAILURE 0x92U
define SYN_DALI_CMD_QUERY_LAMP_POWER_ON 0x93U
define SYN_DALI_CMD_QUERY_MAX_LEVEL 0xA1U
define SYN_DALI_CMD_QUERY_MIN_LEVEL 0xA2U
define SYN_DALI_CMD_QUERY_PHYSICAL_MIN_LEVEL 0x9AU
define SYN_DALI_CMD_QUERY_POWER_ON_LEVEL 0xA3U
define SYN_DALI_CMD_QUERY_RANDOM_ADDR_H 0xC2U
define SYN_DALI_CMD_QUERY_RANDOM_ADDR_L 0xC4U
define SYN_DALI_CMD_QUERY_RANDOM_ADDR_M 0xC3U
define SYN_DALI_CMD_QUERY_STATUS 0x90U
define SYN_DALI_CMD_QUERY_SYS_FAIL_LEVEL 0xA4U
define SYN_DALI_CMD_RECALL_MAX 0x05U
define SYN_DALI_CMD_RECALL_MIN 0x06U
define SYN_DALI_CMD_REMOVE_FROM_GROUP_BASE 0x70U /\* 0x70..0x7F \*/
define SYN_DALI_CMD_REMOVE_FROM_SCENE_BASE 0x50U /\* 0x50..0x5F \*/
define SYN_DALI_CMD_RESET 0x20U
define SYN_DALI_CMD_STEP_DOWN 0x04U
define SYN_DALI_CMD_STEP_DOWN_AND_OFF 0x07U
define SYN_DALI_CMD_STEP_UP 0x03U
define SYN_DALI_CMD_STORE_ACTUAL_LEVEL_IN_DTR 0x21U
define SYN_DALI_CMD_STORE_DTR_AS_FADE_RATE 0x2FU
define SYN_DALI_CMD_STORE_DTR_AS_FADE_TIME 0x2EU
define SYN_DALI_CMD_STORE_DTR_AS_MAX_LEVEL 0x2AU
define SYN_DALI_CMD_STORE_DTR_AS_MIN_LEVEL 0x2BU
define SYN_DALI_CMD_STORE_DTR_AS_POWER_ON_LEVEL 0x2DU
define SYN_DALI_CMD_STORE_DTR_AS_SCENE_BASE 0x40U /\* 0x40..0x4F \*/
define SYN_DALI_CMD_STORE_DTR_AS_SHORT_ADDR 0x80U
define SYN_DALI_CMD_STORE_DTR_AS_SYS_FAIL_LEVEL 0x2CU
define SYN_DALI_CMD_UP 0x01U
define SYN_DALI_MASK_LEVEL 255U
define SYN_DALI_SHORT_ADDR_UNASSIGNED 0xFFU
define SYN_DALI_SPEC_COMPARE 0xA9U
define SYN_DALI_SPEC_DTR0 0xA3U
define SYN_DALI_SPEC_DTR1 0xC3U
define SYN_DALI_SPEC_DTR2 0xC5U
define SYN_DALI_SPEC_INITIALISE 0xA5U
define SYN_DALI_SPEC_PROGRAM_SHORT_ADDR 0xB7U
define SYN_DALI_SPEC_QUERY_SHORT_ADDR 0xBBU
define SYN_DALI_SPEC_RANDOMISE 0xA7U
define SYN_DALI_SPEC_SEARCHADDRH 0xB1U
define SYN_DALI_SPEC_SEARCHADDRL 0xB5U
define SYN_DALI_SPEC_SEARCHADDRM 0xB3U
define SYN_DALI_SPEC_TERMINATE 0xA1U
define SYN_DALI_SPEC_VERIFY_SHORT_ADDR 0xB9U
define SYN_DALI_SPEC_WITHDRAW 0xABU

Detailed Description

Implements non-blocking, zero-malloc DALI (IEC 62386-101/102) Manchester bi-phase frame encoding/decoding, address matching (Short, Group, Broadcast), Direct Arc Power control ($0..254$), standard commands, configuration commands, and query responses.

** **

static SYN_DALI_SlaveState dali_slave;
SYN_DALI_SlaveConfig cfg = {
    .short_address = 5,
    .min_level = 10,
    .max_level = 254,
    .power_on_level = 254,
    .system_failure_level = 254
};
syn_dali_slave_init(&dali_slave, &cfg);

SYN_DALI_ForwardFrame req;
if (syn_dali_decode_forward(raw_16, &req)) {
    uint8_t resp = 0;
    bool has_resp = false;
    syn_dali_slave_process(&dali_slave, &req, &resp, &has_resp);
}

Public Types Documentation

enum SYN_DALI_AddressType

DALI Address Types.

enum SYN_DALI_AddressType {
    SYN_DALI_ADDR_SHORT = 0,
    SYN_DALI_ADDR_GROUP,
    SYN_DALI_ADDR_BROADCAST,
    SYN_DALI_ADDR_SPECIAL
};


Public Functions Documentation

function syn_dali_decode_backward

Decode an 8-bit Slave Backward Frame.

bool syn_dali_decode_backward (
    uint8_t raw_8,
    SYN_DALI_BackwardFrame * frame
) 

Parameters:

  • raw_8 Raw 8-bit frame integer.
  • frame [out] Decoded frame structure.

Returns:

true on valid frame decoding.


function syn_dali_decode_forward

Decode a 16-bit Master Forward Frame.

bool syn_dali_decode_forward (
    uint16_t raw_16,
    SYN_DALI_ForwardFrame * frame
) 

Parameters:

  • raw_16 Raw 16-bit frame integer.
  • frame [out] Decoded frame structure.

Returns:

true on valid frame decoding.


function syn_dali_encode_backward

Encode an 8-bit Slave Backward Frame.

uint8_t syn_dali_encode_backward (
    uint8_t data
) 

Parameters:

  • data 8-bit response payload.

Returns:

Raw 8-bit frame integer.


function syn_dali_encode_forward

Encode a 16-bit Master Forward Frame.

uint16_t syn_dali_encode_forward (
    uint8_t addr,
    uint8_t data_cmd
) 

Parameters:

  • addr Address byte (Short, Group, Broadcast).
  • data_cmd Data / Command byte.

Returns:

Raw 16-bit frame integer.


function syn_dali_manchester_decode_byte

Decode Manchester bi-phase bit pairs into a byte value.

bool syn_dali_manchester_decode_byte (
    const uint8_t * bit_in,
    uint8_t * val_out
) 

Parameters:

  • bit_in Input uint8_t array containing bi-phase pairs.
  • val_out [out] Decoded byte.

Returns:

true on valid Manchester alignment.


function syn_dali_manchester_encode_byte

Encode a byte sequence into Manchester bi-phase bits.

size_t syn_dali_manchester_encode_byte (
    uint8_t val,
    uint8_t * bit_out
) 

Parameters:

  • val Input byte value.
  • bit_out Output uint16_t array (minimum 16 elements for bi-phase pairs).

Returns:

Number of bi-phase transitions written.


function syn_dali_slave_init

Initialize a DALI Slave Control Gear instance.

SYN_Status syn_dali_slave_init (
    SYN_DALI_SlaveState * slave,
    const SYN_DALI_SlaveConfig * cfg
) 

Parameters:

  • slave Slave state handle.
  • cfg Slave configuration pointer.

Returns:

SYN_OK on success, error code otherwise.


function syn_dali_slave_process

Process an incoming DALI Forward Frame on a Slave Control Gear node.

SYN_Status syn_dali_slave_process (
    SYN_DALI_SlaveState * slave,
    const SYN_DALI_ForwardFrame * req,
    uint8_t * resp_data,
    bool * has_resp
) 

Parameters:

  • slave Slave state handle.
  • req Incoming forward frame request.
  • resp_data [out] 8-bit response payload (if has_resp is set to true).
  • has_resp [out] Set to true if a backward response frame must be transmitted.

Returns:

SYN_OK on success, error code on invalid parameters.


Macro Definition Documentation

define SYN_DALI_CMD_ADD_TO_GROUP_BASE

#define SYN_DALI_CMD_ADD_TO_GROUP_BASE `0x60U       /* 0x60..0x6F */`

define SYN_DALI_CMD_DOWN

#define SYN_DALI_CMD_DOWN `0x02U`

define SYN_DALI_CMD_ENABLE_DAPC_SEQUENCE

#define SYN_DALI_CMD_ENABLE_DAPC_SEQUENCE `0x09U`

define SYN_DALI_CMD_ENABLE_WRITE_MEMORY

#define SYN_DALI_CMD_ENABLE_WRITE_MEMORY `0x81U`

define SYN_DALI_CMD_GO_TO_SCENE_BASE

#define SYN_DALI_CMD_GO_TO_SCENE_BASE `0x10U /* 0x10..0x1F */`

define SYN_DALI_CMD_OFF

#define SYN_DALI_CMD_OFF `0x00U`

define SYN_DALI_CMD_ON_AND_STEP_UP

#define SYN_DALI_CMD_ON_AND_STEP_UP `0x08U`

define SYN_DALI_CMD_QUERY_ACTUAL_LEVEL

#define SYN_DALI_CMD_QUERY_ACTUAL_LEVEL `0xA0U`

define SYN_DALI_CMD_QUERY_CONTENT_DTR

#define SYN_DALI_CMD_QUERY_CONTENT_DTR `0x98U`

define SYN_DALI_CMD_QUERY_CONTENT_DTR1

#define SYN_DALI_CMD_QUERY_CONTENT_DTR1 `0x9CU`

define SYN_DALI_CMD_QUERY_CONTENT_DTR2

#define SYN_DALI_CMD_QUERY_CONTENT_DTR2 `0x9DU`

define SYN_DALI_CMD_QUERY_CONTROL_GEAR

#define SYN_DALI_CMD_QUERY_CONTROL_GEAR `0x91U`

define SYN_DALI_CMD_QUERY_DEVICE_TYPE

#define SYN_DALI_CMD_QUERY_DEVICE_TYPE `0x99U`

define SYN_DALI_CMD_QUERY_GROUPS_0_7

#define SYN_DALI_CMD_QUERY_GROUPS_0_7 `0xC0U`

define SYN_DALI_CMD_QUERY_GROUPS_8_15

#define SYN_DALI_CMD_QUERY_GROUPS_8_15 `0xC1U`

define SYN_DALI_CMD_QUERY_LAMP_FAILURE

#define SYN_DALI_CMD_QUERY_LAMP_FAILURE `0x92U`

define SYN_DALI_CMD_QUERY_LAMP_POWER_ON

#define SYN_DALI_CMD_QUERY_LAMP_POWER_ON `0x93U`

define SYN_DALI_CMD_QUERY_MAX_LEVEL

#define SYN_DALI_CMD_QUERY_MAX_LEVEL `0xA1U`

define SYN_DALI_CMD_QUERY_MIN_LEVEL

#define SYN_DALI_CMD_QUERY_MIN_LEVEL `0xA2U`

define SYN_DALI_CMD_QUERY_PHYSICAL_MIN_LEVEL

#define SYN_DALI_CMD_QUERY_PHYSICAL_MIN_LEVEL `0x9AU`

define SYN_DALI_CMD_QUERY_POWER_ON_LEVEL

#define SYN_DALI_CMD_QUERY_POWER_ON_LEVEL `0xA3U`

define SYN_DALI_CMD_QUERY_RANDOM_ADDR_H

#define SYN_DALI_CMD_QUERY_RANDOM_ADDR_H `0xC2U`

define SYN_DALI_CMD_QUERY_RANDOM_ADDR_L

#define SYN_DALI_CMD_QUERY_RANDOM_ADDR_L `0xC4U`

define SYN_DALI_CMD_QUERY_RANDOM_ADDR_M

#define SYN_DALI_CMD_QUERY_RANDOM_ADDR_M `0xC3U`

define SYN_DALI_CMD_QUERY_STATUS

#define SYN_DALI_CMD_QUERY_STATUS `0x90U`

define SYN_DALI_CMD_QUERY_SYS_FAIL_LEVEL

#define SYN_DALI_CMD_QUERY_SYS_FAIL_LEVEL `0xA4U`

define SYN_DALI_CMD_RECALL_MAX

#define SYN_DALI_CMD_RECALL_MAX `0x05U`

define SYN_DALI_CMD_RECALL_MIN

#define SYN_DALI_CMD_RECALL_MIN `0x06U`

define SYN_DALI_CMD_REMOVE_FROM_GROUP_BASE

#define SYN_DALI_CMD_REMOVE_FROM_GROUP_BASE `0x70U  /* 0x70..0x7F */`

define SYN_DALI_CMD_REMOVE_FROM_SCENE_BASE

#define SYN_DALI_CMD_REMOVE_FROM_SCENE_BASE `0x50U  /* 0x50..0x5F */`

define SYN_DALI_CMD_RESET

#define SYN_DALI_CMD_RESET `0x20U`

define SYN_DALI_CMD_STEP_DOWN

#define SYN_DALI_CMD_STEP_DOWN `0x04U`

define SYN_DALI_CMD_STEP_DOWN_AND_OFF

#define SYN_DALI_CMD_STEP_DOWN_AND_OFF `0x07U`

define SYN_DALI_CMD_STEP_UP

#define SYN_DALI_CMD_STEP_UP `0x03U`

define SYN_DALI_CMD_STORE_ACTUAL_LEVEL_IN_DTR

#define SYN_DALI_CMD_STORE_ACTUAL_LEVEL_IN_DTR `0x21U`

define SYN_DALI_CMD_STORE_DTR_AS_FADE_RATE

#define SYN_DALI_CMD_STORE_DTR_AS_FADE_RATE `0x2FU`

define SYN_DALI_CMD_STORE_DTR_AS_FADE_TIME

#define SYN_DALI_CMD_STORE_DTR_AS_FADE_TIME `0x2EU`

define SYN_DALI_CMD_STORE_DTR_AS_MAX_LEVEL

#define SYN_DALI_CMD_STORE_DTR_AS_MAX_LEVEL `0x2AU`

define SYN_DALI_CMD_STORE_DTR_AS_MIN_LEVEL

#define SYN_DALI_CMD_STORE_DTR_AS_MIN_LEVEL `0x2BU`

define SYN_DALI_CMD_STORE_DTR_AS_POWER_ON_LEVEL

#define SYN_DALI_CMD_STORE_DTR_AS_POWER_ON_LEVEL `0x2DU`

define SYN_DALI_CMD_STORE_DTR_AS_SCENE_BASE

#define SYN_DALI_CMD_STORE_DTR_AS_SCENE_BASE `0x40U /* 0x40..0x4F */`

define SYN_DALI_CMD_STORE_DTR_AS_SHORT_ADDR

#define SYN_DALI_CMD_STORE_DTR_AS_SHORT_ADDR `0x80U`

define SYN_DALI_CMD_STORE_DTR_AS_SYS_FAIL_LEVEL

#define SYN_DALI_CMD_STORE_DTR_AS_SYS_FAIL_LEVEL `0x2CU`

define SYN_DALI_CMD_UP

#define SYN_DALI_CMD_UP `0x01U`

define SYN_DALI_MASK_LEVEL

#define SYN_DALI_MASK_LEVEL `255U`

MASK level (no change)


define SYN_DALI_SHORT_ADDR_UNASSIGNED

#define SYN_DALI_SHORT_ADDR_UNASSIGNED `0xFFU`

Unassigned Short Address


define SYN_DALI_SPEC_COMPARE

#define SYN_DALI_SPEC_COMPARE `0xA9U`

define SYN_DALI_SPEC_DTR0

#define SYN_DALI_SPEC_DTR0 `0xA3U`

define SYN_DALI_SPEC_DTR1

#define SYN_DALI_SPEC_DTR1 `0xC3U`

define SYN_DALI_SPEC_DTR2

#define SYN_DALI_SPEC_DTR2 `0xC5U`

define SYN_DALI_SPEC_INITIALISE

#define SYN_DALI_SPEC_INITIALISE `0xA5U`

define SYN_DALI_SPEC_PROGRAM_SHORT_ADDR

#define SYN_DALI_SPEC_PROGRAM_SHORT_ADDR `0xB7U`

define SYN_DALI_SPEC_QUERY_SHORT_ADDR

#define SYN_DALI_SPEC_QUERY_SHORT_ADDR `0xBBU`

define SYN_DALI_SPEC_RANDOMISE

#define SYN_DALI_SPEC_RANDOMISE `0xA7U`

define SYN_DALI_SPEC_SEARCHADDRH

#define SYN_DALI_SPEC_SEARCHADDRH `0xB1U`

define SYN_DALI_SPEC_SEARCHADDRL

#define SYN_DALI_SPEC_SEARCHADDRL `0xB5U`

define SYN_DALI_SPEC_SEARCHADDRM

#define SYN_DALI_SPEC_SEARCHADDRM `0xB3U`

define SYN_DALI_SPEC_TERMINATE

#define SYN_DALI_SPEC_TERMINATE `0xA1U`

define SYN_DALI_SPEC_VERIFY_SHORT_ADDR

#define SYN_DALI_SPEC_VERIFY_SHORT_ADDR `0xB9U`

define SYN_DALI_SPEC_WITHDRAW

#define SYN_DALI_SPEC_WITHDRAW `0xABU`


The documentation for this class was generated from the following file src/syntropic/proto/syn_dali.h