DALI StackAPI Description
1. DALI 2.0 Stack Concept . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.2 Terms and definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.3 Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41.4 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.4.1 Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41.4.2 Information flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41.4.3 Function types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51.4.4 Stack timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61.4.5 Stack instances . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.5 API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61.5.1 Common . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71.5.2 Frame format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101.5.3 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121.5.4 Action . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261.5.5 Reaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
1.6 Implementation examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 561.6.1 Control gear example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 561.6.2 Control device example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
www.cslab.de 1
DALI 2.0 Stack ConceptContents
IntroductionTerms and definitionsRequirementsGeneralAPIImplementation examplesStack unit testdeprecated
Changes History
1 1.0 28.03.2017
Initiale HOE draft
Introduction
The DALI-Stack offers the possibility of a comfortable communication with the DALI units. The application that integrates this stack can communicate with the other DALI units via the stack API functions.
The application therefore does not have to deal with the DALI standard.The DALI frames are en-/decoded in the stack.
When the DALI frames are received, this is forwarded to the stack via the HAL driver, and the stack is passed on to the application via thereaction callback function.
DALI-Stack was developed with the programming language ANSI-C
Terms and definitionsContains
HAL-Driveractionreactionactual leveltarget levelshort addressgroup addressdevice groupbroadcastbroadcast unaddressedDAPC (direct arc power control)GTIN (global trade item number)DALI_MASKNVMPHMscene
For the purposes of this document.
HAL-Driver
Hardware Abstraction Layer to send and to receive the DALI frames
action
the API function "dalilib_action" is meant
reaction
the callback function "dalilib_reaction" is meant
actual level
www.cslab.de 2
value representing the current light output
target level
the target light output expected after completion of the current level command
short address
type of address used to address an individual control gear/device in the system
group address
type of address used to address a group of control gear/device in the system all at once
device group
type of address used to address a group of control devices in the system at once
broadcast
type of address used to address all control gear/device in the system at once
broadcast unaddressed
type of address used to address all control gear/devices in the system that have no short address at once
DAPC (direct arc power control)
a method to directly control the light output
GTIN (global trade item number)
number used for the unique identification of trade items worldwide
DALI_MASK
the value 0xFF
NVM
non-volatile read/write memory, the content of which can be changed and will not be lost due to a power cycle
PHM
physical minimum level corresponding to the minimum light output the control gear can operate at
scene
configurable preset level
www.cslab.de 3
Requirements
Hardware Requirements
Memory requirements of DALI-Stack: 64KB Flash.
Software Requirements
The stack needs a HAL-Driver to send and receive the DALI-frames
General
Contents
ArchitectureInformation flowFunction typesStack timingStack instances
ArchitectureTo include the stack in an application, a header file "libdali.h" is available, where all necessary data types, functions, structures,
constants, action and reaction codes are defined. And DALI stack available as a binary file "liblibdali.a".
The steps to be performed to include the stack are described in detail in the chapter .API - Initiliaze
The follow figur describes the architecture.
www.cslab.de 4
Information flowThis figur describes information flow
Function typesContains
action functionreaction function
DALI stack provides various types of API functions for communicating with the application.
directly accessible functions
dalilib_createinstancedalilib_initdalilib_startdalilib_actiondalilib_receivedalilib_timingHelperdalilib_infoGetdalilib_versionGetdalilib_stop
callback functionsfAppReadyfAppSendfAppReActionfAppLoadMemfAppSaveMemfAppLog
The functions are described in detail in chapter API
For communication between the application and the stack, the following functions are decisive.
actionreaction
action function
With this function the application can communicate with the DALI participants on the bus. Different action codes are defined for the actions that are to be executed by an application. ( )see chapter API
www.cslab.de 5
Depending on how the stack is initialized by the application, different action codes are available.
If the stack is initialized as a control gear, only internal action codes are available. Because a control gear can only react to therequirements.
If the stack is initialized as a control device, the other DALI participant can also manage it. Therefore, more action codes areavailable.
reaction function
With this function, the stack can notify the application of the events. ( )See detail chapter API
E.g. If the application is to turn off the lamp. Or adjust the light intensity.
Stack timing
DALI-Stack provides a dalilib_helptimer function.This function is to be called every 10 to 30 ms.The call parameter should have a resolution of 100 microseconds.
This call must be guaranteed by the application, otherwise the stack can not run correctly.
Stack instances
DALI-Stack can be started with several instances.Each instance runs independently.
For this reason, the Instance must be passed along with all API functions.
Currently, a maximum of 2 instances are supported
APIContents
CommonFrame formatConfigurationActionReaction
In section ,common
the generally valid structures and enumerations aredescribed
In section ,frame format
expected frame structure is described
In section ,initialize
stack configuration structurestack instance specific enumerationsthe functions offered by the stackhow to initialize and create the stack instance for differentmodes.
The section describes the function as anaction dalilib_actionapplication of this stack function can call.
which structures and enumerations can be used for thisfunction.sample codes for a control gear, control device and input
www.cslab.de 6
device.
The section describes the callback function reaction fAppReAction
which structures and lists of the stack are used for thisfunction.sample codes for a control gear, control device and inputdevice.
CommonContains
Control gear/device address typeInstance address typeControl gear address structControl device address structDALI result codes
The generally valid structures and enumerations are described here
Control gear/device address typeName:
DALI_ADRTYPE
Description:
describes the address of a DALI unittypedef enum _DALI_ADRTYPE{ DALI_ADRTYPE_SHORT = 0, // short address DALI_ADRTYPE_GRP, // group address DALI_ADRTYPE_NBROADCAST, // broadcast notaddressed DALI_ADRTYPE_BROADCAST, // broadcast DALI_ADRTYPE_SPEC, // special command DALI_ADRTYPE_RESERVED // reserved}DALI_ADRTYPE;
Instance address typeName:
DALI_INSTANCE_ADRTYPE
Description:
for standard instance commands, the method of instanceaddressing used by the transmitter
typedef enum _DALI_INSTANCE_ADRTYPE{ DALI_INSTANCE_ADRTYPE_NONE = 0, // notinstance addressing DALI_INSTANCE_ADRTYPE_NUMBER, //Addressing Instance number DALI_INSTANCE_ADRTYPE_GRP, //Addressing Instance group DALI_INSTANCE_ADRTYPE_TYPE, //Addressing Instance type DALI_INSTANCE_ADRTYPE_NUMBER_LEVEL, //Addressing Feature on instance number level DALI_INSTANCE_ADRTYPE_GRP_LEVEL, //Addressing Feature on instance group level DALI_INSTANCE_ADRTYPE_TYPE_LEVEL, //Addressing Feature on instance type level DALI_INSTANCE_ADRTYPE_BROADCAST_LEVEL, //Addressing Feature on instance broadcast level DALI_INSTANCE_ADRTYPE_BROADCAST, //Addressing Instance broadcast DALI_INSTANCE_ADRTYPE_DEVICE_LEVEL, //Addressing Feature on device level DALI_INSTANCE_ADRTYPE_DEVICE, //Addressing Device DALI_INSTANCE_ADRTYPE_RESERVED //reserved}DALI_INSTANCE_ADRTYPE;
www.cslab.de 7
Control gear address structName:
gear_adr_t
Description:
gear address struct contains informationaddress typethe variable dependent from adr adrType
typedef struct _gear_adr_t{ DALI_ADRTYPE adrType; uint8_t adr; // adrType ==DALI_ADRTYPE_SHORT [0..63] // adrType ==DALI_ADRTYPE_GRP [1..16] // adrType ==DALI_ADRTYPE_BROADCAST not used}gear_adr_t;
Control device address structName:
device_adr_t
Description:
device address struct contains informationaddress typethe variable dependent from adr adrTypeinstance address typethe variable dependent from instance instanceAdrType
typedef struct _device_adr_t{ DALI_ADRTYPE adrType; uint8_t adr; // adrType ==DALI_ADRTYPE_SHORT [0..63] // adrType ==DALI_ADRTYPE_GRP [1..32] // adrType ==DALI_ADRTYPE_BROADCAST not used
DALI_INSTANCE_ADRTYPE instanceAdrType; uint8_t instance; / /[instancenumber,instancegroup, instancetype]}device_adr_t;
DALI result codesName:
R_DALILIB_RESULT
Description:
defined between 0..127advanced result codes only for stack internal between128..255
R_DALILIB_OKsuccessfull
R_DALILIB_NOT_STARTEDstack instance not started
R_DALILIB_INVALID_INSTANCEinvalid stack instance
R_DALILIB_INTERFACE_NOT_READYnot connected with HAL-Driver
R_DALILIB_NOT_INITIALISEDstack instance not initialized
R_DALILIB_CALLBACK_FAILEDone or more required callback function notdefined
R_DALILIB_MODE_FAILUREstack mode not yet set
R_DALILIB_BUSYstack is busy
R_DALILIB_NOT_SUPPORTED_ACTIONnot supported action codeor invalid action code for the stack mode
R_DALILIB_FRAME_NOT_SUPPORTEDinvalid DALI stack frame receivednot correct converted from HAL-Driver frame to
#define R_DALILIB_OK #defineR_DALILIB_NOT_STARTED #defineR_DALILIB_INVALID_INSTANCE #defineR_DALILIB_INTERFACE_NOT_READY #defineR_DALILIB_NOT_INITIALISED #defineR_DALILIB_CALLBACK_FAILED #defineR_DALILIB_MODE_FAILURE #define R_DALILIB_BUSY #defineR_DALILIB_NOT_SUPPORTED_ACTION #defineR_DALILIB_FRAMING_ERROR
www.cslab.de 8
DALI-Stack frameR_DALILIB_FRAME_NOT_SEND
frame not yet sendR_DALILIB_RESPONSE_TIMEOUT
response time outcontrol gear/device not connected orresponse is NO
R_DALILIB_RESPONSE_FRAME_NOT_ACCEPTEDunexpected response frame received
R_DALILIB_CTRL_GEAR_CMD_NOT_SUPPORTEDreceived control gear command not supported
R_DALILIB_CTRL_GEAR_INVALID_ADDRESScontrol gear address is invalid
R_DALILIB_CTRL_GEAR_INVALID_FFreceived control gear forward frame is invalid
R_DALILIB_CTRL_GEAR_ACTION_NOT_SUPPORTEDcontrol gear action code not supported
R_DALILIB_APPLICATION_CONTROLLER_DISABLEDreserved
R_DALILIB_CTRL_DEVICE_CMD_NOT_SUPPORTEDreceived control device command not supported
R_DALILIB_CTRL_DEVICE_INVALID_ADDRESScontrol device address is invalid
R_DALILIB_CTRL_DEVICE_INVALID_INSTANCE_ADDRESS
control device instance address is invalidR_DALILIB_INSTANCE_DISABLED
event can not triggered because instance is notactive
R_DALILIB_CTRL_DEVICE_INVALID_SCHEMEinvalid event scheme
R_DALILIB_CTRL_DEVICE_INVALID_EVENT_MESSAGE
received event message is invalidR_DALILIB_CTRL_DEVICE_IGNORE_EVENT
event filter is not set for this eventR_DALILIB_CTRL_DEVICE_EVENT_UNKNOWN
received unknown eventR_DALILIB_STACK_TERMINATED
stack instance stoppedR_DALILIB_GEAR_DEVICE_TYPE_NOT_SUPPORTED
control gear device type not supportedR_DALILIB_INPUT_DEVICE_TYPE_NOT_SUPPORTED
input device type not supported
#defineR_DALILIB_FRAME_NOT_SUPPORTED #defineR_DALILIB_FRAME_NOT_SEND #defineR_DALILIB_RESPONSE_TIMEOUT #defineR_DALILIB_RESPONSE_FRAME_NOT_ACCEPTED #defineR_DALILIB_CTRL_GEAR_CMD_NOT_SUPPORTED #defineR_DALILIB_CTRL_GEAR_INVALID_ADDRESS #defineR_DALILIB_CTRL_GEAR_INVALID_FF #defineR_DALILIB_CTRL_GEAR_ACTION_NOT_SUPPORTED #defineR_DALILIB_APPLICATION_CONTROLLER_DISABLED #defineR_DALILIB_CTRL_DEVICE_CMD_NOT_SUPPORTED #defineR_DALILIB_CTRL_DEVICE_INVALID_ADDRESS #defineR_DALILIB_CTRL_DEVICE_INVALID_INSTANCE_ADDRESS #defineR_DALILIB_INSTANCE_DISABLED #defineR_DALILIB_CTRL_DEVICE_INVALID_SCHEME #defineR_DALILIB_CTRL_DEVICE_INVALID_EVENT_MESSAGE #defineR_DALILIB_CTRL_DEVICE_IGNORE_EVENT #defineR_DALILIB_CTRL_DEVICE_EVENT_UNKNOWN #defineR_DALILIB_STACK_TERMINATED #defineR_DALILIB_GEAR_DEVICE_TYPE_NOT_SUPPORTED #defineR_DALILIB_INPUT_DEVICE_TYPE_NOT_SUPPORTED
01234567891011121314151617181920212223242526272829
127
www.cslab.de 9
#define R_DALILIB_MAX
Frame formatContains
Frame structTimestampFrame-Flags (uint8_t)Status information (uint32_t)
Frame struct
The DALI-Stack expects the frames in the format defined here.The frame format can be different from the HAL-Driver than the DALI-Stack expects.
The frame is constructed as follows in both directions
Frame
Timestamp // uint32_t, timestamp of lastreceived bit in frame in 100usec ticks Frame-Flags // uint8_tData-Length // uint8_t, length of data in Bits(0..32) Data // unt32_t, always 32 Bit, onlylowest 'Data-Length' Bits used.
typedef struct _dalilib_status_t{ uint32_t bus_bower_off; // 1 if DALI bus off is detected uint32_t interface_open; // 1 if interface is open uint32_t transmit_pending; // 1 if a frame is waiting to betransmitted uint32_t status_reserved; // unused status bits}dalilib_status_t;
// Frame structure between stack and HAL-Drivertypedef struct _dalilib_frame_t{ // timestamp of last received bit in frame in 100usec ticks // will be set from low-level-driver // resolution [100us] uint32_t timestamp; union { uint8_t frameflags; struct { uint8_t priority; // priority of frame, 0=backwardframe, 1..5=forward frame uint8_t sendtwice; // 1 for frames that should be sendtwice uint8_t tx; // 1 for frames that were transmitted uint8_t error; // 1 if received or transmitted framehas error uint8_t type; // 0=data is DALI frame data, 1=data is status information uint8_t reserved; }; }; uint8_t datalength; union { uint32_t data; // DALI data, valid if type =0 dalilib_status_t status; // DALI status, valid if type= 1 };}dalilib_frame_t;
www.cslab.de 10
e.g.
Forward-Frame for the control gear ( DALI-Stack --> HAL-Driver )00000000011000000B91
Backward-Frame ( DALI-Stack --> HAL-Driver)0000000000080000000A
Forward-Frame for the control gear ( HAL-Driver --> DALI-Stack)23456789 41100000000B91
Backward-Frame ( HAL-Driver --> DALI-Stack )2345678940080000000A
Timestamp
absolute frame timestampresolution [100s]
Frame-Flags (uint8_t)
Name Bit Description
Priority 0..2 0=backward framepriority, 1..5=forward framepriority (see DALIspec.)
Twice 3 0= send frameonce, 1= sendframe twice
Rx/Tx 4 0= frame wasreceived from DALIbus, 1= frame wassend to DALI bus
Error 5 0= no error, 1=error
Type 6 0= Data is DALIframe, 1= Data isdriver statusinformation
Reserved 7 Reserved
Status information (uint32_t)
If the 'Type' of a frame is '1', the 'data'-field is the DALI interfacestatus.
Name Bit Description
Bus Power Off 0 1 = DALI bus off isdetected
Interface Open 1 1 = Interface isopen
www.cslab.de 11
Transmit pending 2 1 = a frame iswaiting to betransmitted,no further framecan be scheduledfor transmitting.A coll to 'write' willfail.
0 = a new framecan be scheduledfor transmission
Reserved 3..31
ConfigurationContents
1 Structs1.1 DALI stack configuration1.2 DALI stack callback functions1.3 DALI stack vendor parameters1.4 DALI stack vendor parameters for LED module1.5 DALI stack vendor parameters for push button
2 Enumerations2.1 DALI stack modes2.2 Control device modes2.3 Control gear device types2.4 Input device instance types
3 Functions3.1 Create a new instance of DALI stack3.2 Initialize a DALI stack instance3.3 Start a DALI stack instance3.4 Receive a DALI frame3.5 Timer function3.6 Stop a DALI stack instance3.7 Get DALI stack info3.8 Get DALI stack version3.9 Callback function - ready3.10 Callback function - send3.11 Callback function - load persistent data3.12 Callback function - save persistent data3.13 Callback function - reaction3.14 Callback function - to log
4 Initialization steps4.1 Create stack instance4.2 Initialize stack configuration
4.2.1 Initialize stack as control gear4.2.2 Initialize stack as single-master application controller4.2.3 Initialize stack as multi-master application controller4.2.4 Initialize stack as input device
4.3 Start stack instance4.4 Timing helper function4.5 DALI frame received from HAL-Driver
This section describes the API function of the DALI stack.The structures and the enumerations are described for stack initialize.In the section "functions", the individual functions and the specified parameters are described.In the section "initialization steps", the steps to create the possible stack instance are explained using the example codes.
Structs
DALI stack configuration Name:
dalilib_cfg_t
Description:
www.cslab.de 12
some stack configuration parameters musst betransmitted to DALI-Stackcontext
this is passed with the send callback function, sothat the application can access HAL driverinstance.
typedef struct _dalilib_cfg_t{ STACK_MODE mode; // stack mode dalilib_callbacks_t callbacks; // callback functionspointer dalilib_vendor_params_t vendor; // manufacturerinformation void* context; // application contextparam }dalilib_cfg_t;
DALI stack callback functions Name:
dalilib_callbacks_t
Description:
the stack communicates with the application via the.callback functions
callback functions are triggered by the stack.the mandatory callback functions must be set before thestack start.
typedef struct _dalilib_callbacks_t{ fAppReady fPAppReady; // is called when thestack is successfully started and ready. [optional] fAppSend fPAppSend; // is called when thestack DALI frame wants to send HAL-Driver. [mandatory] fAppReAction fPAppReAction; // is called when thestack wants to notify the application of the events. [mandatory] fAppLoadMem fPAppLoadMem; // the application will betriggered to load the persistent data. [mandatory] fAppSaveMem fPAppSaveMem; // the application willbe triggered to save the persistent data. [mandatory] fAppLog fPAppLog; // log function for thedeveloper. [optional]}dalilib_callbacks_t;
DALI stack vendor parameters Name:
dalilib_vendor_params_t
Description:
vendor params struct contains information about themanufacturerfirmware version, identify number, hardwareversion.It contains the control gear/device parameters.
www.cslab.de 13
typedef struct _dalilib_vendor_params_t
{
// The bytes “GTIN” shall contain the Global Trade Item Number (GTIN), // e.g. the EAN, in binary. // The bytes shall be stored most significant first and filledwith leading zeroes. uint8_t gtin[6]; // Unique identificationnumber
// The bytes (“firmware version”) shall contain the firmwareversion of the bus unit. uint8_t firmware_ver_major; uint8_t firmware_ver_minor;
// The bytes shall contain 64 bits of an identification numberof the bus unit, // prefereably the serial number. // The identification number shall be stored with leastsignificant byte in “identification // number byte 7” and unused bits shall be filled with 0. uint8_t identify_number[8];
// The 2-bytes (“hardware version”) shall contain thehardware version of the bus unit. uint8_t hw_ver_major; uint8_t hw_ver_minor;
//---------------------------------------------------------------------------- // parameter for the control gear //---------------------------------------------------------------------------- // physical minimum level of the control gear uint8_t control_gear_phm;
// control gear device type CTRL_GEAR_DEVICE_TYPE control_gear_device_type;
union { dalilib_vendor_led_params_t led_params; };
//---------------------------------------------------------------------------- // parameter for the control device //---------------------------------------------------------------------------- // control device mode,set 0 if not used CTRL_DEVICE_MODE control_device_mode;
// used, if control_device_mode =CTRL_DEV_MODE_INPUT INPUT_DEVICE_INSTANCE_TYPE control_device_instance_type; uint8_t control_device_instance_number;
union { dalilib_vendor_input_dev_push_button_params_tpush_btn; };
uint8_t shortAddress; // if not used:DALI_MASK (0xFF)}dalilib_vendor_params_t;
DALI stack vendor parameters for LED module Name:
dalilib_vendor_led_params_t
Description:
persistent parameter for control gear device type LEDmodules (IEC 62386-207:2009)
www.cslab.de 14
typedef struct _dalilib_vendor_led_params{ uint8_t min_fast_fade_time; // [1..27] // gear type params uint8_t integrated_power_supply; //[FALSE|TRUE] uint8_t integrated_led_module; //[FALSE|TRUE] uint8_t ac_supply; //[FALSE|TRUE] uint8_t dc_supply; //[FALSE|TRUE]
// possible operating modes uint8_t pwm_possible; //[FALSE|TRUE] uint8_t am_possible; //[FALSE|TRUE] uint8_t regulated_output; //[FALSE|TRUE] uint8_t high_current_pulse; //[FALSE|TRUE]
// features // if a feature set to true, it can be query uint8_t short_circuit; // [FALSE|TRUE] uint8_t open_circuit; // [FALSE|TRUE] uint8_t load_decrease; // [FALSE|TRUE] uint8_t load_increase; // [FALSE|TRUE] uint8_t overcurrent_protection; // [FALSE|TRUE] uint8_t thermal_shutdown; // [FALSE|TRUE] uint8_t thermal_overload; // [FALSE|TRUE]
// reference measurement option uint8_t referencing; // [FALSE|TRUE]}dalilib_vendor_led_params_t;
DALI stack vendor parameters for push button Name:
dalilib_vendor_input_dev_push_button_params_t
Description:
persistent parameter for input device push buttons (IEC62386-301:2016)
typedef struct _dalilib_vendor_input_dev_push_button_params{ uint8_t pushButtonShortMin; [10..255, ms] uint8_t pushButtonDoubleMin; [10..100, ms]}dalilib_vendor_input_dev_push_button_params_t;
Enumerations
DALI stack modes
Description:
mode of a stack instanceSTACK_MODE_CONTROL_GEAR
control gear mode (E.g. LED module)STACK_MODE_CONTROL_DEVICE
as single master application controller ormulti master application controller or
www.cslab.de 15
input deviceSTACK_MODE_GATEWAY
reserved
typedef enum _STACK_MODE{ STACK_MODE_UNKNOWN = 0x00,
// stack will be start as control gear STACK_MODE_CONTROL_GEAR,
// stack will be start as application controller/input device STACK_MODE_CONTROL_DEVICE,
// stack will be start as gateway STACK_MODE_GATEWAY
}STACK_MODE;
Control device modes
Description:
mode for a control deviceis applied when the stack mode is set as the controldevice
typedef enum _CTRL_DEVICE_MODE{ CTRL_DEV_MODE_NONE = 0,
// Single-master application controller // A single-master application controller is not intended toshare // the bus with other control devices. CTRL_DEV_MODE_SINGLE,
// Multi-master application controller CTRL_DEV_MODE_MULTI,
// Input device CTRL_DEV_MODE_INPUT
}CTRL_DEVICE_MODE;
Control gear device types
Description:
enumeration for control gear device typesupported control gear device types
GEAR_TYPE_FLUORESCENT_LAMPSGEAR_TYPE_LED_MODULES
www.cslab.de 16
typedef enum _CTRL_GEAR_DEVICE_TYPE{ // IEC 62386-201 - Fluorescent lamps GEAR_TYPE_FLUORESCENT_LAMPS = 0x00,
// IEC 62386-202 - Self-contained emergency lighting GEAR_TYPE_SELF_CONTAINED_EMERGENCY_LIGHTING= 0x01,
// IEC 62386-203 - Dischage lamps (excluding fluorescentlamps) GEAR_TYPE_DISCHARGE_LAMPS = 0x02,
// IEC 62386-204 - Low voltage halogen lamps GEAR_TYPE_LOW_VOLTAGE_HALOGEN_LAMPS = 0x03,
// IEC 62386-205 - Supply Voltage controller forincandescent lamps GEAR_TYPE_SUPPLY_VOLTAGE_CONTROLLER_FOR_INCANDESCENT_LAMPS = 0x04,
// IEC 62386-206 - Conversion from digital into D.C. voltage GEAR_TYPE_CONVERSION_FROM_DIGITAL_INTO_D_C_VOLTAGE = 0x05,
// IEC 62386-207 - LED modules GEAR_TYPE_LED_MODULES = 0x06,
// IEC 62386-208 - Switching function GEAR_TYPE_SWITCHING_FUNCTION = 0x07,
// IEC 62386-209 - Colour control GEAR_TYPE_COLOUR_CONTROL = 0x08,
// IEC 62386-210 - Control Gear sequencer GEAR_TYPE_CONTROL_GEAR_SEQUENCER = 0x09,
// No further device type/feature implemented GEAR_TYPE_NO_FURTHER_DEVICE_TYPE = 0xFE,
// Control gear supporting more than one device type/feature GEAR_TYPE_SUPPORT_MORE_ONE_DEVICE_TYPE =0xFF
}CTRL_GEAR_DEVICE_TYPE;
Input device instance types
Description:
enumeration for control device instance typesupported input device types
INPUT_DEVICE_INST_0INPUT_DEVICE_INST_PUSH_BUTTONS
typedef enum _INPUT_INSTANCE_TYPE{ INPUT_DEVICE_INST_0 = 0, //IEC-62386-103 INPUT_DEVICE_INST_PUSH_BUTTONS = 1, // IEC-62386-301 INPUT_DEVICE_INST_ABSOLUTE_INPUT_DEVICE = 2, // IEC-62386-302 INPUT_DEVICE_INST_OCCUPANCY_SENSOR = 3, // IEC-62386-303 INPUT_DEVICE_INST_LIGHT_SENSOR = 4, // IEC-62386-304 INPUT_DEVICE_INST_COLOR_SENSOR = 5 // IEC-62386-305}INPUT_DEVICE_INSTANCE_TYPE;
Functions
www.cslab.de 17
Create a new instance of DALI stack Name:
dalilib_createinstance
Description:
DALI-Stack will be create new instancemax. DALI stack instance at the moment 2
Parameter:
void
Result:
dalilib_instance_t // successNULL // error
Initialize a DALI stack instance Name:
dalilib_init
Description:
DALI-Stack will be create new instance
Parameter:
dalilib_instance_t // <in-param> pointer of a stackinstancedalilib_cfg_t* // <in-param> pointer of a stackconfiguration struct
Result:
R_DALILIB_OK // 0: result success> 0 // error no
Start a DALI stack instance Name:
dalilib_start
Description:
starts the created DALI instance
Parameter:
dalilib_instance_t // <in-param> pointer of a stackinstance
Result:
R_DALILIB_OK // 0: result success> 0 // error no
Receive a DALI frame Name:
dalilib_receive
Description:
will be called, if the application dali-frame received
Parameter:
dalilib_instance_t // <in-param> pointer of a stackinstancedali_frame_t // <in-param> DALI frame in stackformat
Result:
void
Timer function Name:
dalilib_timingHelper
Description:
shall be called ever ca.10ms
Parameter:
dalilib_instance_t // <in-param> pointer of a stack
www.cslab.de 18
resolution [100us] instancedalilib_time // <in-param> ticker
Result:
void
Stop a DALI stack instance Name:
dalilib_stop
Description:
stop the stack instance
Parameter:
dalilib_instance_t // <in-param> pointer of a stackinstance
Result:
R_DALILIB_OK // 0: result success> 0 // error no
Get DALI stack info Name:
dalilib_infoGet
Description:
not finished yetget the vendor id at the moment
Parameter:
dalilib_instance_t // <in-param> pointer of a stackinstancedalilib_info_t* // <out-param> pointer of infostruct
Result:
R_DALILIB_OK // 0: result success> 0 // error no
Get DALI stack version Name:
dalilib_versionGet
Description:
get DALI stack code and API versions
Parameter:
dalilib_instance_t // <in-param> pointer of a stackinstancedalilib_version_t* // <out-param> pointer of versionstruct
Result:
R_DALILIB_OK // 0: result success> 0 // error no
Callback function - ready Name:
(*fAppReady)
Description:
is called when the stack is successfully started and ready
Parameter:
void
Result:
www.cslab.de 19
void
Callback function - send Name:
(*fAppSend)
Description:
mandatory callback function must be set before the stackstartstack send a DALI frame
Parameter:
void* // <in-param> user contextparameterdali_frame_t // <in-param> DALI frame in stackformat
Result:
R_DALILIB_RESULT
Callback function - load persistent data Name:
(*fAppLoadMem)
Description:
mandatory callback function must be set before the stackstartthe application will be triggered to load the persistent data
Parameter:
void* // <out-param> buffer pointeruint8_t // <in-param> size of persistentdata
Result:
R_DALILIB_RESULT
Callback function - save persistent data Name:
(*fAppSaveMem)
Description:
mandatory callback function must be set before the stackstartthe application will be triggered to save the persistentdata
Parameter:
void* // <in-param> buffer pointeruint8_t // <in-param> size of persistentdata
Result:
R_DALILIB_RESULT
Callback function - reaction Name:
(*fAppReAction)
Description:
mandatory callback function must be set before the stackstartis called when the stack wants to notify the application ofthe events
Parameter:
dalilib_action_t // <in-param> DALI stack actionstruct pointer
Result:
R_DALILIB_RESULT
Callback function - to log Name:
www.cslab.de 20
(*fAppLog)
Description:
the application will be triggered to log
Parameter:
char* // <in-param> log textuint8_t // <in-param> log text length
Result:
void
Initialization steps
Create stack instance
Description:
first must create a new DALI stack instance
Example:
dalilib_instance_t pDaliStackInstance = NULL;
pDaliStackInstance = dalilib_createinstance();
Initialize stack configuration
Description:
initialize the DALI stack configuration "dalilib_cfg_t"
Initialize stack as control gear
Description:
initialize the DALI stack configuration "dalilib_cfg_t" ascontrol gear
Example:
www.cslab.de 21
dalilib_cfg_t ctrl_gear_config;
memset(ctrl_gear_config, 0, sizeof(ctrl_gear_config));
// stack modectrl_gear_config.mode = STACK_MODE_CONTROL_GEAR;ctrl_gear_config.vendor.control_device_mode =CTRL_DEV_MODE_NONE;
// vendor informationctrl_gear_config.vendor.control_gear_phm = 85;ctrl_gear_config.vendor.control_gear_device_type =GEAR_TYPE_LED_MODULES;ctrl_gear_config.vendor.gtin[0] = 'M';ctrl_gear_config.vendor.gtin[1] = 'B';ctrl_gear_config.vendor.gtin[2] = 'S';ctrl_gear_config.vendor.gtin[3] = '0';ctrl_gear_config.vendor.gtin[4] = '1';ctrl_gear_config.vendor.gtin[5] = '7';
ctrl_gear_config.vendor.firmware_ver_major = 0x01;ctrl_gear_config.vendor.firmware_ver_minor = 0x02;
ctrl_gear_config.vendor.identify_number[0] = 0x01;ctrl_gear_config.vendor.identify_number[1] = 0x02;ctrl_gear_config.vendor.identify_number[2] = 0x03;ctrl_gear_config.vendor.identify_number[3] = 0x04;ctrl_gear_config.vendor.identify_number[4] = 0x08;ctrl_gear_config.vendor.identify_number[5] = 0x0A;ctrl_gear_config.vendor.identify_number[6] = 0x12;ctrl_gear_config.vendor.identify_number[7] = 0x12;
ctrl_gear_config.vendor.hw_ver_major = 0x10;ctrl_gear_config.vendor.hw_ver_minor = 0x33;
// callbacksctrl_gear_config.callbacks.fPAppReady =daliwrapper_ready_callback;ctrl_gear_config.callbacks.fPAppSend =daliwrapper_send_callback;ctrl_gear_config.callbacks.fPAppLoadMem =daliwrapper_loadmemory_callback;ctrl_gear_config.callbacks.fPAppSaveMem =daliwrapper_savememory_callback;ctrl_gear_config.callbacks.fPAppReAction =daliwrapper_reaction_callback;ctrl_gear_config.callbacks.fPAppLog = NULL;
/* LED vendor parameters */ctrl_gear_config.vendor.led_params.min_fast_fade_time = 1;
// no address, shall be set to 0xFFctrl_gear_config.vendor.shortAddress = 0x01;
dalilib_init(pDaliStackInstance , &ctrl_gear_config);
Initialize stack as single-master application controller
Description:
initialize the DALI stack configuration "dalilib_cfg_t" assingle control deviceA single-master application controller is not intended toshare the bus with other control devices.A single-master application controller may try to configureother control devices on the bus, and/or change thebehaviour of control gear in the system,
Example:
www.cslab.de 22
dalilib_cfg_t ctrl_device_config;
memset(ctrl_device_config, 0, sizeof(ctrl_device_config));
// stack modectrl_device_config.mode =STACK_MODE_CONTROL_DEVICE;ctrl_device_config.vendor.control_device_mode =CTRL_DEV_MODE_SINGLE;
// control device informationctrl_device_config.vendor.control_device_instance_type =INPUT_DEVICE_INST_0;ctrl_device_config.vendor.control_device_instance_number = 0;
// vendor informationctrl_device_config.vendor.gtin[0] = 'M';ctrl_device_config.vendor.gtin[1] = 'B';ctrl_device_config.vendor.gtin[2] = 'S';ctrl_device_config.vendor.gtin[3] = '0';ctrl_device_config.vendor.gtin[4] = '1';ctrl_device_config.vendor.gtin[5] = '7';
ctrl_device_config.vendor.firmware_ver_major = 0x01;ctrl_device_config.vendor.firmware_ver_minor = 0x02;
ctrl_device_config.vendor.identify_number[0] = 0x01;ctrl_device_config.vendor.identify_number[1] = 0x02;ctrl_device_config.vendor.identify_number[2] = 0x03;ctrl_device_config.vendor.identify_number[3] = 0x04;ctrl_device_config.vendor.identify_number[4] = 0x08;ctrl_device_config.vendor.identify_number[5] = 0x0A;ctrl_device_config.vendor.identify_number[6] = 0x12;ctrl_device_config.vendor.identify_number[7] = 0x12;
ctrl_device_config.vendor.hw_ver_major = 0x10;ctrl_device_config.vendor.hw_ver_minor = 0x33;
// callbacksctrl_device_config.callbacks.fPAppReady =daliwrapper_ready_callback;ctrl_device_config.callbacks.fPAppSend =daliwrapper_send_callback;ctrl_device_config.callbacks.fPAppLoadMem =daliwrapper_loadmemory_callback;ctrl_device_config.callbacks.fPAppSaveMem =daliwrapper_savememory_callback;ctrl_device_config.callbacks.fPAppReAction =daliwrapper_reaction_callback;ctrl_device_config.callbacks.fPAppLog = NULL;
// no address, shall be set to 0xFFctrl_device_config.vendor.shortAddress = 0x02;
Initialize stack as multi-master application controller
Description:
initialize the DALI stack configuration "dalilib_cfg_t" asmulti-master control device
Example:
www.cslab.de 23
dalilib_cfg_t ctrl_device_config;
memset(ctrl_device_config, 0, sizeof(ctrl_device_config));
// stack modectrl_device_config.mode =STACK_MODE_CONTROL_DEVICE;ctrl_device_config.vendor.control_device_mode =CTRL_DEV_MODE_MULTI;
// control device informationctrl_device_config.vendor.control_device_instance_type =INPUT_DEVICE_INST_0;ctrl_device_config.vendor.control_device_instance_number = 0;
// vendor informationctrl_device_config.vendor.gtin[0] = 'M';ctrl_device_config.vendor.gtin[1] = 'B';ctrl_device_config.vendor.gtin[2] = 'S';ctrl_device_config.vendor.gtin[3] = '0';ctrl_device_config.vendor.gtin[4] = '1';ctrl_device_config.vendor.gtin[5] = '7';
ctrl_device_config.vendor.firmware_ver_major = 0x01;ctrl_device_config.vendor.firmware_ver_minor = 0x02;
ctrl_device_config.vendor.identify_number[0] = 0x01;ctrl_device_config.vendor.identify_number[1] = 0x02;ctrl_device_config.vendor.identify_number[2] = 0x03;ctrl_device_config.vendor.identify_number[3] = 0x04;ctrl_device_config.vendor.identify_number[4] = 0x08;ctrl_device_config.vendor.identify_number[5] = 0x0A;ctrl_device_config.vendor.identify_number[6] = 0x12;ctrl_device_config.vendor.identify_number[7] = 0x12;
ctrl_device_config.vendor.hw_ver_major = 0x10;ctrl_device_config.vendor.hw_ver_minor = 0x33;
// callbacksctrl_device_config.callbacks.fPAppReady =daliwrapper_ready_callback;ctrl_device_config.callbacks.fPAppSend =daliwrapper_send_callback;ctrl_device_config.callbacks.fPAppLoadMem =daliwrapper_loadmemory_callback;ctrl_device_config.callbacks.fPAppSaveMem =daliwrapper_savememory_callback;ctrl_device_config.callbacks.fPAppReAction =daliwrapper_reaction_callback;ctrl_device_config.callbacks.fPAppLog = NULL;
// no address, shall be set to 0xFFctrl_device_config.vendor.shortAddress = 0x03;
Initialize stack as input device
Description:
initialize the DALI stack configuration "dalilib_cfg_t" asinput control device
Example:
www.cslab.de 24
dalilib_cfg_t ctrl_device_config;
memset(ctrl_device_config, 0, sizeof(ctrl_device_config));
// stack modectrl_device_config.mode =STACK_MODE_CONTROL_DEVICE;ctrl_device_config.vendor.control_device_mode =CTRL_DEV_MODE_MULTI;
// control device informationctrl_device_config.vendor.control_device_instance_type =INPUT_DEVICE_INST_PUSH_BUTTONS;ctrl_device_config.vendor.control_device_instance_number = 1;
// vendor informationctrl_device_config.vendor.gtin[0] = 'M';ctrl_device_config.vendor.gtin[1] = 'B';ctrl_device_config.vendor.gtin[2] = 'S';ctrl_device_config.vendor.gtin[3] = '0';ctrl_device_config.vendor.gtin[4] = '1';ctrl_device_config.vendor.gtin[5] = '7';
ctrl_device_config.vendor.firmware_ver_major = 0x01;ctrl_device_config.vendor.firmware_ver_minor = 0x02;
ctrl_device_config.vendor.identify_number[0] = 0x01;ctrl_device_config.vendor.identify_number[1] = 0x02;ctrl_device_config.vendor.identify_number[2] = 0x03;ctrl_device_config.vendor.identify_number[3] = 0x04;ctrl_device_config.vendor.identify_number[4] = 0x08;ctrl_device_config.vendor.identify_number[5] = 0x0A;ctrl_device_config.vendor.identify_number[6] = 0x12;ctrl_device_config.vendor.identify_number[7] = 0x12;
ctrl_device_config.vendor.hw_ver_major = 0x10;ctrl_device_config.vendor.hw_ver_minor = 0x33;
// callbacksctrl_device_config.callbacks.fPAppReady =daliwrapper_ready_callback;ctrl_device_config.callbacks.fPAppSend =daliwrapper_send_callback;ctrl_device_config.callbacks.fPAppLoadMem =daliwrapper_loadmemory_callback;ctrl_device_config.callbacks.fPAppSaveMem =daliwrapper_savememory_callback;ctrl_device_config.callbacks.fPAppReAction =daliwrapper_reaction_callback;ctrl_device_config.callbacks.fPAppLog = NULL;
/* push button vendor parameters */ctrl_gear_config.vendor.push_btn.pushButtonShortMin = 15;ctrl_gear_config.vendor.push_btn.pushButtonDoubleMin = 10;
// no address, shall be set to 0xFFctrl_device_config.vendor.shortAddress = 0x04;
Start stack instance
Description:
initialize the DALI stack configuration "dalilib_cfg_t" asinput control device
Example:
dalilib_start(pDaliStackInstance);
Timing helper function
Description:
periodic call of the DALI stack timer function
Example:
www.cslab.de 25
dali_time_t dali_timeTicker;
...
dalilib_timingHelper(pDaliStackInstance, dali_timeTicker);
DALI frame received from HAL-Driver
Description:
received DALI frame must be convert to dalilib_frame_t
Example:
dalilib_frame_t dalilib_frame;daliframe frame; // DALI frame
// convert to dalilib_frame
...
dalilib_receive(pDaliStackInstance, &dalilib_frame);
ActionContents
1 Structs1.1 DALI stack action struct1.2 DALI stack control gear action structs
1.2.1 Control gear action struct1.2.2 Control gear action value1.2.3 Control gear scene action struct1.2.4 Control gear memory action struct
1.3 DALI stack control device action structs1.3.1 Control device action structs1.3.2 Control device memory action struct
1.4 DALI stack event action structs1.4.1 Event action structs
2 Enumerations2.1 DALI stack action type enumerations2.2 DALI stack control gear action enumerations
2.2.1 Control gear action type enumaration2.2.2 Control gear internal action type enumaration2.2.3 Control gear level action type enumaration2.2.4 Control gear scene action type enumaration2.2.5 Control gear group action type enumaration2.2.6 Control gear status action type2.2.7 Control gear queries action type enumaration2.2.8 Control gear vendor action type enumaration2.2.9 Control gear config action type enumaration2.2.10 Control gear initialize action type enumaration2.2.11 Control gear initialize action value type enumaration2.2.12 Control gear memory bank action type enumaration2.2.13 Control gear fluorescent modules action type enumaration2.2.14 Control gear LED modules action type enumaration
2.3 DALI stack control device action enumerations2.3.1 Control device action type enumaration2.3.2 Control device internal action type enumaration2.3.3 Control device controller action type enumaration2.3.4 Input device action type enumaration2.3.5 Push buttons action type enumaration
2.4 DALI stack event action enumerations2.4.1 Input device event type enumaration2.4.2 Push buttons event action type enumaration
3 Examples3.1 DALI stack control gear action examples
3.1.1 Control gear set actual level3.2 DALI stack control device action examples
3.2.1 Control device set event filter3.3 DALI stack event action examples
3.3.1 Push button pressed event action
www.cslab.de 26
This section describes the API-function R_DALILIB_RESULT dalilib_action(dalilib_instance_t pInstance, dalilib_action_t* pAction)
The structures and the enumerations are described the communication between an application and stack, between stack andHAL-Driver of DALI.Action API-function is set
to inform the stack about the events of the operating devices (control gear/device)to manage the other participants on the bus (control gear/device)to query the status of the other participant on the bus (control gear/device)
Communication from an application to the DALI stack runs over this function.Different actions are defined via the action type "DALILIB_ACTION_TYPE" and enumerations. The action enumerations alwaysstart with prefix "DALILIB_ACT_xxxxxxx"The following structures will be used for the action
dalilib_act_ctrl_gear_tdalilib_act_ctrl_device_tdalilib_act_event_t
Structs
DALI stack action structName:
dalilib_action_t
Description:
action struct contains information action typesub action typeaction valuecontrol gear/device address
typedef struct _dalilib_action_t{ DALILIB_ACTION_TYPE actionType; union{ dalilib_act_ctrl_gear_t gearAct; dalilib_react_ctrl_gear_t gearReact; // used forreaction function dalilib_act_ctrl_device_t deviceAct; dalilib_react_ctrl_device_t deviceReact; // used forreaction function dalilib_act_event_t eventAct; dalilib_react_event_t eventReact; // used forreaction function };}dalilib_action_t;
DALI stack control gear action structs
Control gear action struct Name:
dalilib_act_ctrl_gear_t
Description:
action struct contains informationcontrol gear action typecontrol gear addresscontrol gear actioncontrol gear action value
www.cslab.de 27
typedef struct _dalilib_act_ctrl_gear_t{ DALILIB_CTRL_GEAR_ACTION_CODE_TYPE gearActionType; gear_adr_t adr;
union { uint8_t reserved; DALILIB_ACT_INTERNAL_CTRL_GEAR internalAction; DALILIB_ACT_CTRL_GEAR_CONFIG configAction; DALILIB_ACT_CTRL_GEAR_QUERIES queriesAction; DALILIB_ACT_CTRL_GEAR_LEVEL levelAction; DALILIB_ACT_CTRL_GEAR_SCENE sceneAction; DALILIB_ACT_CTRL_GEAR_GROUP groupAction; DALILIB_ACT_CTRL_GEAR_INITIALISE initAction; DALILIB_ACT_CTRL_GEAR_VENDOR vendorAction; DALILIB_ACT_CTRL_GEAR_MEMORY memoryAction; DALILIB_ACT_CTRL_GEAR_LED ledAction; DALILIB_ACT_CTRL_GEAR_FLUORESCENT fluorescentAction; }action; union { uint32_t actionValue; dalilib_act_ctrl_gear_scene_t sceneParams; dalilib_act_ctrl_gear_memory_t memoryParams; }value;}dalilib_act_ctrl_gear_t;
Control gear action value Name:
actionValue
Description:
action value is depends on the action typeif a light level value [0%..100%]light level value is multiplied by the factor 1000 torepresent the decimal places
e.g. 2,521% => 2,521 * 1000 = 2521
Control gear scene action struct Name:
dalilib_act_ctrl_gear_scene_t
Description:
scene action struct contains informationscene index [0..15]scene value [0%..100%]scene value is multiplied by the factor 1000 torepresent the decimal places
e.g. 2,521% => 2,521 * 1000 = 2521
typedef struct _dalilib_act_ctrl_gear_scene_t{ uint8_t sceneIndex; // index start 0 uint32_t sceneLevel;}dalilib_act_ctrl_gear_scene_t;
Control gear memory action struct Name:
dalilib_act_ctrl_gear_memory_t
Description:
www.cslab.de 28
memory action struct contains informationmemory bank numbermemory cell indexvalue for the selected cell, used for write memoryaction
typedef struct _dalilib_act_ctrl_gear_memory_t{ uint8_t memoryBankNr; uint8_t memoryCellIdx; uint8_t value;}dalilib_act_ctrl_gear_memory_t;
DALI stack control device action structs
Control device action structs Name:
dalilib_act_ctrl_device_t
Description:
action struct contains informationcontrol device action typecontrol device addresscontrol device actioncontrol device action value
typedef struct{ DALILIB_CTRL_DEVICE_ACTION_CODE_TYPE deviceActionType; device_adr_t adr; union { uint8_t reserved; DALILIB_ACT_INTERNAL_CTRL_DEVICE internalAction; DALILIB_ACT_CTRL_DEVICE_CONTROLLER controllerAction; DALILIB_ACT_INPUT_DEVICE inputDeviceAction; DALILIB_ACT_PUSH_BUTTON pushButtonAction; }; union { uint32_t actionValue; // use if action codes equal "memory action codes" dalilib_act_ctrl_device_memory_t memoryParams; };}dalilib_act_ctrl_device_t;
Control device memory action struct Name:
dalilib_act_ctrl_device_memory_t
Description:
memory action struct contains informationmemory bank numbermemory cell indexvalue for the selected cell, used for write memoryaction
typedef struct _dalilib_act_ctrl_device_memory_t{ uint8_t memoryBankNr; uint8_t memoryCellIdx; uint8_t value;}dalilib_act_ctrl_device_memory_t;
DALI stack event action structs
Event action structs Name:
dalilib_act_event_t
Description:
This structure must be filled in if an input device triggersan event and wants to send this event.At the moment, only pushbuttons are supported, but thisstructure can be extended for other input devices.event action struct contains information
www.cslab.de 29
event typedevice short addressinput device event action codes
typedef struct{ DALILIB_EVENT_TYPE type; device_adr_t adr; union { DALILIB_ACT_EVENT_PUSH_BUTTON pushButtonEvent; };}dalilib_act_event_t;
Enumerations
DALI stack action type enumerationsName:
DALILIB_ACTION_TYPE
Description:
To use the " " function, this parameter mustdalilib_action be set. This will determine the action the stack will
perform.
typedef enum _DALILIB_ACTION_TYPE{ DALILIB_ACTION_NONE = 0, DALILIB_CTRL_GEAR_ACTION, // control gearactions DALILIB_CTRL_GEAR_REACTION, // control gearreactions DALILIB_CTRL_DEVICE_ACTION, // control deviceactions DALILIB_CTRL_DEVICE_REACTION, // control devicereactions DALILIB_EVENT_ACTION, // input device eventactions DALILIB_GW_ACTION, // gatewayactions/reactions DALILIB_ACTION_MAX}DALILIB_ACTION_TYPE;
DALI stack control gear action enumerations
Control gear action type enumaration Name:
DALILIB_CTRL_GEAR_ACTION_CODE_TYPE
Description:
To use the " " function, this parameter mustdalilib_action be set. This will determine the control gear action the
stack will perform.
www.cslab.de 30
typedef enum _DALILIB_CTRL_GEAR_ACTION_CODE_TYPE{ //---------------------------------------------------------------------- // action codes, if stack mode equalSTACK_MODE_CONTROL_GEAR // internal action codes between application and DALI-Library //----------------------------------------------------------------------
DALILIB_ACT_TYPE_INTERNAL_CTRL_GEAR, //----------------------------------------------------------------------
//---------------------------------------------------------------------- // action codes, if stack mode equalSTACK_MODE_CONTROL_DEVICE //----------------------------------------------------------------------
DALILIB_ACT_TYPE_CTRL_GEAR_LEVEL, DALILIB_ACT_TYPE_CTRL_GEAR_SCENE, DALILIB_ACT_TYPE_CTRL_GEAR_GROUP, DALILIB_ACT_TYPE_CTRL_GEAR_QUERY_STATUS, DALILIB_ACT_TYPE_CTRL_GEAR_QUERIES,
// get information about the manufacturer of the control gear DALILIB_ACT_TYPE_CTRL_GEAR_VENDOR, DALILIB_ACT_TYPE_CTRL_GEAR_CONFIG, DALILIB_ACT_TYPE_CTRL_GEAR_INITIALISE, DALILIB_ACT_TYPE_CTRL_GEAR_MEMORY,
// action code for Fluorescent lamps DALILIB_ACT_TYPE_CTRL_GEAR_FLUORESCENT,
// action codes for LED-Modules DALILIB_ACT_TYPE_CTRL_GEAR_LED,
DALILIB_ACT_TYPE_CTRL_GEAR_LAST}DALILIB_CTRL_GEAR_ACTION_CODE_TYPE;
Control gear internal action type enumaration Name:
DALILIB_ACT_TYPE_INTERNAL_CTRL_GEAR
Description:
If a control gear detects status changes, the action codescan transfer the status to stack.No DALI forward frames are sent with the internal action
codes. Only the internal status is changed.
typedef enum _DALILIB_ACT_CTRL_GEAR_INTERNAL{ // application can set the lamp failure variable of the library DALILIB_ACT_INTERNAL_CTRL_GEAR_SET_LAMPFAILURE = 0,
// application transmit the actual level to the library DALILIB_ACT_INTERNAL_CTRL_GEAR_SET_ACTUAL_LEVEL,
// application can set the gear failure variable of the library DALILIB_ACT_INTERNAL_CTRL_GEAR_SET_GEAR_FAILURE,
// application can set the LED-reference value aftermeasurement DALILIB_ACT_INTERNAL_CTRL_GEAR_LED_REFERENCE_VALUE,}DALILIB_ACT_INTERNAL_CTRL_GEAR;
Control gear level action type enumaration Name:
DALILIB_ACT_CTRL_GEAR_LEVEL
Description:
If a application controller (control device) wants to control
www.cslab.de 31
the level of a control gear, it can perform these actioncodes. So the stack will generate DALI forward frames and passthem on to HAL-Driver.
typedef enum _DALILIB_ACT_CTRL_GEAR_LEVEL{ // direct arc power control DALILIB_ACT_CTRL_GEAR_LEVEL_DAPC = 0, DALILIB_ACT_CTRL_GEAR_LEVEL_OFF, DALILIB_ACT_CTRL_GEAR_LEVEL_UP, DALILIB_ACT_CTRL_GEAR_LEVEL_DOWN, DALILIB_ACT_CTRL_GEAR_LEVEL_STEP_UP, DALILIB_ACT_CTRL_GEAR_LEVEL_STEP_DOWN, DALILIB_ACT_CTRL_GEAR_LEVEL_RECALL_MAX_LEVEL, DALILIB_ACT_CTRL_GEAR_LEVEL_RECALL_MIN_LEVEL, DALILIB_ACT_CTRL_GEAR_LEVEL_STEP_DOWN_AND_OFF, DALILIB_ACT_CTRL_GEAR_LEVEL_ON_STEP_UP, DALILIB_ACT_CTRL_GEAR_LEVEL_GOTO_LAST_ACTIVE_LEVEL}DALILIB_ACT_CTRL_GEAR_LEVEL;
Control gear scene action type enumaration Name:
DALILIB_ACT_CTRL_GEAR_SCENE
Description:
If a application controller (control device) wants tomanage the scene of a control gear, it can perform theseaction codes. So the stack will generate DALI forward frames and passthem on to HAL-Driver.
typedef enum _DALILIB_ACT_CTRL_GEAR_SCENE{ DALILIB_ACT_CTRL_GEAR_SCENE_GOTO_SCENE = 0, DALILIB_ACT_CTRL_GEAR_SCENE_SET_SCENE, DALILIB_ACT_CTRL_GEAR_SCENE_REMOVE_FROM_SCENE}DALILIB_ACT_CTRL_GEAR_SCENE;
Control gear group action type enumaration Name:
DALILIB_ACT_CTRL_GEAR_GROUP
Description:
If a application controller (control device) wants tomanage the groups of a control gear, it can perform theseaction codes. So the stack will generate DALI forward frames and passthem on to HAL-Driver.
typedef enum _DALILIB_ACT_CTRL_GEAR_GROUP{ DALILIB_ACT_CTRL_GEAR_GROUP_ADD_TO_GROUP =0, DALILIB_ACT_CTRL_GEAR_GROUP_REMOVE_FROM_GROUP}DALILIB_ACT_CTRL_GEAR_GROUP;
Control gear status action type Name:
DALILIB_ACT_TYPE_CTRL_GEAR_QUERY_STATUS
Description:
Each control gear shall expose its status as acombination of device properties.The control gear statuscan be queried using this action code.So the stack will generate DALI forward frames and passthem on to HAL-Driver.The answer will be the status, which is formed by acombination of control gear properties. seectrl_gear_status_t.
www.cslab.de 32
Control gear queries action type enumaration Name:
DALILIB_ACT_CTRL_GEAR_QUERIES
Description:
Queries are used to retrieve property values from acontrol gear. The addressed control gear returns the queried property value in a backward frame. So the stack will generate DALI forward frames and passthem on to HAL-Driver.
typedef enum _DALILIB_ACT_CTRL_GEAR_QUERIES{ DALILIB_ACT_CTRL_GEAR_QUERY_CTRL_GEAR_PRESENT = 0, DALILIB_ACT_CTRL_GEAR_QUERY_CTRL_GEAR_VERSION_NR, DALILIB_ACT_CTRL_GEAR_QUERY_CTRL_GEAR_DEVICE_TYPE, DALILIB_ACT_CTRL_GEAR_QUERY_CTRL_GEAR_PHYSICAL_MINIMUM, DALILIB_ACT_CTRL_GEAR_QUERY_OPERATING_MODE, DALILIB_ACT_CTRL_GEAR_QUERY_LIGHT_SOURCE_TYPE, DALILIB_ACT_CTRL_GEAR_QUERY_FADE_TIME_RATE, DALILIB_ACT_CTRL_GEAR_QUERY_EXT_FADE_TIME, DALILIB_ACT_CTRL_GEAR_QUERY_ACTUAL_LEVEL, DALILIB_ACT_CTRL_GEAR_QUERY_MAX_LEVEL, DALILIB_ACT_CTRL_GEAR_QUERY_MIN_LEVEL, DALILIB_ACT_CTRL_GEAR_QUERY_POWER_ON_LEVEL, DALILIB_ACT_CTRL_GEAR_QUERY_SYSTEM_FAILURE_LEVEL, DALILIB_ACT_CTRL_GEAR_QUERY_SCENE_LEVEL, DALILIB_ACT_CTRL_GEAR_QUERY_GROUP, DALILIB_ACT_CTRL_GEAR_QUERY_RANDOM_ADDRESS_H, DALILIB_ACT_CTRL_GEAR_QUERY_RANDOM_ADDRESS_M, DALILIB_ACT_CTRL_GEAR_QUERY_RANDOM_ADDRESS_L}DALILIB_ACT_CTRL_GEAR_QUERIES;
Control gear vendor action type enumaration Name:
DALILIB_ACT_CTRL_GEAR_VENDOR
Description:
With these action codes, information about themanufacturer can be requested from a control gear.So the stack will generate DALI forward frames and passthem on to HAL-Driver.
typedef enum _DALILIB_ACT_CTRL_GEAR_VENDOR{ DALILIB_ACT_CTRL_GEAR_VENDOR_GTIN = 0, DALILIB_ACT_CTRL_GEAR_VENDOR_FW_VER_MAJOR, DALILIB_ACT_CTRL_GEAR_VENDOR_FW_VER_MINOR, DALILIB_ACT_CTRL_GEAR_VENDOR_IDENTIFY_NR, DALILIB_ACT_CTRL_GEAR_VENDOR_HW_VER_MAJOR, DALILIB_ACT_CTRL_GEAR_VENDOR_HW_VER_MINOR, DALILIB_ACT_CTRL_GEAR_VENDOR_DALI_NORM_VERSION}DALILIB_ACT_CTRL_GEAR_VENDOR;
Control gear config action type enumaration Name:
DALILIB_ACT_CTRL_GEAR_CONFIG
Description:
www.cslab.de 33
Device configuration instructions are used to change theconfiguration and/or the mode of operation of the controlgear.So the stack will generate DALI forward frames and passthem on to HAL-Driver.
typedef enum _DALILIB_ACT_CTRL_GEAR_CONFIG{ DALILIB_ACT_CTRL_GEAR_CONFIG_RESET = 0, DALILIB_ACT_CTRL_GEAR_CONFIG_SAVE_PERS_VARIABLES, DALILIB_ACT_CTRL_GEAR_CONFIG_SET_OPERATING_MODE, DALILIB_ACT_CTRL_GEAR_CONFIG_SET_MAX_LEVEL, DALILIB_ACT_CTRL_GEAR_CONFIG_SET_MIN_LEVEL, DALILIB_ACT_CTRL_GEAR_CONFIG_SET_SYSTEM_FAILURE_LEVEL, DALILIB_ACT_CTRL_GEAR_CONFIG_SET_POWER_ON_LEVEL, DALILIB_ACT_CTRL_GEAR_CONFIG_SET_FADE_TIME, DALILIB_ACT_CTRL_GEAR_CONFIG_SET_FADE_RATE, DALILIB_ACT_CTRL_GEAR_CONFIG_SET_EXT_FADE_TIME, DALILIB_ACT_CTRL_GEAR_RESET_MEMORY_BANK}DALILIB_ACT_CTRL_GEAR_CONFIG;
Control gear initialize action type enumaration Name:
DALILIB_ACT_CTRL_GEAR_INITIALISE
Description:
Device initiliaze instructions are used to change theconfiguration and/or the mode of operation of the controlgear.So the stack will generate DALI forward frames and passthem on to HAL-Driver.
typedef enum _DALILIB_ACT_CTRL_GEAR_INITIALISE{ DALILIB_ACT_CTRL_GEAR_INIT_TERMINATE = 0, DALILIB_ACT_CTRL_GEAR_INIT_INITIALISE, DALILIB_ACT_CTRL_GEAR_INIT_RANDOMISE, DALILIB_ACT_CTRL_GEAR_INIT_WITHDRAW, DALILIB_ACT_CTRL_GEAR_INIT_SEARCHADDR_H, DALILIB_ACT_CTRL_GEAR_INIT_SEARCHADDR_M, DALILIB_ACT_CTRL_GEAR_INIT_SEARCHADDR_L, DALILIB_ACT_CTRL_GEAR_INIT_SET_SHORT_ADDRESS, DALILIB_ACT_CTRL_GEAR_INIT_PROG_SHORT_ADDRESS, DALILIB_ACT_CTRL_GEAR_INIT_ENABLE_DEVICE_TYPE, DALILIB_ACT_CTRL_GEAR_INIT_IDENTIFY_DEVICE,
// reaction code for next actionsDALILIB_REACT_CTRL_GEAR_INITIALISE DALILIB_ACT_CTRL_GEAR_INIT_COMPARE, DALILIB_ACT_CTRL_GEAR_INIT_VERIFY_SHORT_ADDRESS, DALILIB_ACT_CTRL_GEAR_INIT_QUERY_SHORT_ADDRESS}DALILIB_ACT_CTRL_GEAR_INITIALISE;
Control gear initialize action value type enumaration Name:
DALILIB_CTRL_GEAR_INITIALISE_VALUE
Description:
This determines which control gear must be initialized.
www.cslab.de 34
typedef enum _DALILIB_CTRL_GEAR_INITIALISE_VALUE{ DALILIB_CTRL_GEAR_INIT_WITH_SHORTADDRESS = 0, DALILIB_CTRL_GEAR_INIT_WITHOUT_SHORTADDRESS, DALILIB_CTRL_GEAR_INIT_ALL, DALILIB_CTRL_GEAR_NONE}DALILIB_CTRL_GEAR_INITIALISE_VALUE;
Control gear memory bank action type enumaration Name:
DALILIB_ACT_CTRL_GEAR_MEMORY
Description:
This is used to specify which storage action is to be.performed
So the stack will generate DALI forward frames and passthem on to HAL-Driver.
typedef enum _DALILIB_ACT_CTRL_GEAR_MEMORY{ DALILIB_ACT_CTRL_GEAR_READ_MEMORY_CELL = 0, DALILIB_ACT_CTRL_GEAR_WRITE_MEMORY_CELL}DALILIB_ACT_CTRL_GEAR_MEMORY;
Control gear fluorescent modules action type
enumaration
Name:
DALILIB_ACT_CTRL_GEAR_FLUORESCENT
Description:
The fluorescent actions are defined here.So the stack will generate DALI forward frames for the flu
and pass them on to HAL-Driver.orescent
typedef enum _DALILIB_ACT_CTRL_GEAR_FLUORESCENT{ // reaction code for this actionDALILIB_REACT_CTRL_GEAR_FLUORESCENT DALILIB_ACT_CTRL_GEAR_FLUORESCENT_QUERY_EXT_VERSION_NUMBER,}DALILIB_ACT_CTRL_GEAR_FLUORESCENT;
Control gear LED modules action type enumaration Name:
DALILIB_ACT_CTRL_GEAR_LED
Description:
The LED actions are defined here.So the stack will generate DALI forward frames for theLED modules and pass them on to HAL-Driver.
www.cslab.de 35
typedef enum _DALILIB_ACT_CTRL_GEAR_LED{ DALILIB_ACT_CTRL_GEAR_LED_REFERENCE_SYSTEM_POWER, DALILIB_ACT_CTRL_GEAR_LED_ENABLE_CURRENT_PROTECTOR, DALILIB_ACT_CTRL_GEAR_LED_DISABLE_CURRENT_PROTECTOR, DALILIB_ACT_CTRL_GEAR_LED_SELECT_DIMMING_CURVE, DALILIB_ACT_CTRL_GEAR_LED_SET_FAST_FADE_TIME,
// reaction code for next actionsDALILIB_REACT_CTRL_GEAR_LED DALILIB_ACT_CTRL_GEAR_LED_QUERY_GEAR_TYPE, DALILIB_ACT_CTRL_GEAR_LED_QUERY_DIMMING_CURVE, DALILIB_ACT_CTRL_GEAR_LED_QUERY_POSSIBLE_OPERATING_MODES, DALILIB_ACT_CTRL_GEAR_LED_QUERY_FEATURES, DALILIB_ACT_CTRL_GEAR_LED_QUERY_FAILURE_STATUS, DALILIB_ACT_CTRL_GEAR_LED_QUERY_REFERENCE_RUNNING, DALILIB_ACT_CTRL_GEAR_LED_QUERY_PROTECTOR_ENABLED, DALILIB_ACT_CTRL_GEAR_LED_QUERY_OPERATING_MODE, DALILIB_ACT_CTRL_GEAR_LED_QUERY_FAST_FADE_TIME, DALILIB_ACT_CTRL_GEAR_LED_QUERY_MIN_FAST_FADE_TIME, DALILIB_ACT_CTRL_GEAR_LED_QUERY_EXT_VERSION_NUMBER,}DALILIB_ACT_CTRL_GEAR_LED;
DALI stack control device action
enumerations
Control device action type enumaration Name:
DALILIB_CTRL_DEVICE_ACTION_CODE_TYPE
Description:
To use the " " function, this parameter mustdalilib_action be set. This will determine the control device action the
stack will perform.
www.cslab.de 36
typedef enum_DALILIB_CTRL_DEVICE_ACTION_CODE_TYPE{ // action codes only between an application and DALI-Stack DALILIB_ACT_TYPE_INTERNAL_CTRL_DEVICE = 0,
// action codes for the other application controller devices DALILIB_ACT_TYPE_CTRL_DEVICE_CONTROLLER,
// action codes for the input devices DALILIB_ACT_TYPE_INPUT_DEVICE,
// input device actions for particular device push button DALILIB_ACT_TYPE_PUSH_BUTTON,
DALILIB_ACT_TYPE_CTRL_DEV_LAST}DALILIB_CTRL_DEVICE_ACTION_CODE_TYPE;
Control device internal action type enumaration Name:
DALILIB_ACT_INTERNAL_CTRL_DEVICE
Description:
If a control device detects status changes, the actioncodes can transfer the status to stack.No DALI forward frames are sent with the internal action
codes. Only the internal status is changed.
typedef enum _DALILIB_ACT_CTRL_DEVICE_INTERNAL{ // action codes for a input device (Push Buttons) DALILIB_ACT_INTERNAL_PUSH_BUTTON_GET_SHORT_TIMER = 0, DALILIB_ACT_INTERNAL_PUSH_BUTTON_GET_DOUBLE_TIMER, DALILIB_ACT_INTERNAL_PUSH_BUTTON_GET_REPEAT_TIMER, DALILIB_ACT_INTERNAL_PUSH_BUTTON_GET_STUCK_TIMER,}DALILIB_ACT_INTERNAL_CTRL_DEVICE;
Control device controller action type enumaration Name:
DALILIB_ACT_CTRL_DEVICE_CONTROLLER
Description:
With these action codes other control devices can be managed. To implement these action codes, the stack
multi-master applicationshould be configured as controller (CTRL_DEV_MODE_MULTI). So the stack will generate DALI forward frames and passthem on to HAL-Driver.
typedef enum _DALILIB_ACT_CTRL_DEVICE_CONTROLLER{ // initialise action codes DALILIB_ACT_CTRL_DEVICE_INIT_TERMINATE = 0, DALILIB_ACT_CTRL_DEVICE_INIT_INITIALISE, DALILIB_ACT_CTRL_DEVICE_INIT_RANDOMISE, DALILIB_ACT_CTRL_DEVICE_INIT_WITHDRAW, DALILIB_ACT_CTRL_DEVICE_INIT_SEARCHADDR_H, DALILIB_ACT_CTRL_DEVICE_INIT_SEARCHADDR_M, DALILIB_ACT_CTRL_DEVICE_INIT_SEARCHADDR_L, DALILIB_ACT_CTRL_DEVICE_INIT_PROG_SHORT_ADDRESS,
// reaction code for next actionsDALILIB_REACT_CTRL_DEVICE_INITIALISE DALILIB_ACT_CTRL_DEVICE_INIT_COMPARE, DALILIB_ACT_CTRL_DEVICE_INIT_VERIFY_SHORT_ADDRESS, DALILIB_ACT_CTRL_DEVICE_INIT_QUERY_SHORT_ADDRESS,
www.cslab.de 37
// configuration action codes DALILIB_ACT_CTRL_DEVICE_RESET, DALILIB_ACT_CTRL_DEVICE_RESET_MEM_BANK, DALILIB_ACT_CTRL_DEVICE_RESET_POWER_CYCLE_SEEN, DALILIB_ACT_CTRL_DEVICE_SET_SHORT_ADDRESS, DALILIB_ACT_CTRL_DEVICE_ENABLE_APPLICATION_CONTROLLER, DALILIB_ACT_CTRL_DEVICE_DISABLE_APPLICATION_CONTROLLER, DALILIB_ACT_CTRL_DEVICE_SET_OPERATING_MODE, DALILIB_ACT_CTRL_DEVICE_ADD_TO_DEVICE_GROUPS, DALILIB_ACT_CTRL_DEVICE_REMOVE_FROM_DEVICE_GROUPS, DALILIB_ACT_CTRL_DEVICE_START_QUIESCENT_MODE, DALILIB_ACT_CTRL_DEVICE_STOP_QUIESCENT_MODE, DALILIB_ACT_CTRL_DEVICE_ENABLE_POWER_CYCLE_NOTIFICATION, DALILIB_ACT_CTRL_DEVICE_DISABLE_POWER_CYCLE_NOTIFICATION, DALILIB_ACT_CTRL_DEVICE_SAVE_PERS_VARIABLES,
// device queries // reaction code:DALILIB_REACT_CTRL_DEVICE_QUERIES DALILIB_ACT_CTRL_DEVICE_QUERY_STATUS, DALILIB_ACT_CTRL_DEVICE_QUERY_VERSION_NUMBER, DALILIB_ACT_CTRL_DEVICE_QUERY_NUMBER_OF_INSTANCES, DALILIB_ACT_CTRL_DEVICE_QUERY_RANDOM_H, DALILIB_ACT_CTRL_DEVICE_QUERY_RANDOM_M, DALILIB_ACT_CTRL_DEVICE_QUERY_RANDOM_L, DALILIB_ACT_CTRL_DEVICE_QUERY_OPERATING_MODE, DALILIB_ACT_CTRL_DEVICE_QUERY_DEVICE_GROUPS, DALILIB_ACT_CTRL_DEVICE_QUERY_POWER_CYCLE_NOTIFICATION, DALILIB_ACT_CTRL_DEVICE_QUERY_DEVICE_CAPABILITIES,
// vendor information action codes (memory bank 0) // reaction code:DALILIB_REACT_CTRL_DEVICE_VENDOR DALILIB_ACT_CTRL_DEVICE_VENDOR_GTIN, DALILIB_ACT_CTRL_DEVICE_VENDOR_FW_VER_MAJOR, DALILIB_ACT_CTRL_DEVICE_VENDOR_FW_VER_MINOR, DALILIB_ACT_CTRL_DEVICE_VENDOR_IDENTIFY_NR, DALILIB_ACT_CTRL_DEVICE_VENDOR_HW_VER_MAJOR, DALILIB_ACT_CTRL_DEVICE_VENDOR_HW_VER_MINOR, DALILIB_ACT_CTRL_DEVICE_VENDOR_DALI_NORM_VERSION,
// memory action codes // reaction code:DALILIB_REACT_CTRL_DEVICE_MEMORY DALILIB_ACT_CTRL_DEVICE_MEMORY_READ, DALILIB_ACT_CTRL_DEVICE_MEMORY_WRITE,}DALILIB_ACT_CTRL_DEVICE_CONTROLLER;
www.cslab.de 38
Input device action type enumaration Name:
DALILIB_ACT_INPUT_DEVICE
Description:
The input device can be managed with these actioncodes. To implement these action codes, the stack should be
multi-master application controllerconfigured as (CTRL_DEV_MODE_MULTI). So the stack will generate DALI forward frames and passthem on to HAL-Driver.
typedef enum _DALILIB_ACT_INPUT_DEVICE{ // instance control instructions DALILIB_ACT_INPUT_DEVICE_SET_EVENT_PRIORITY =0, DALILIB_ACT_INPUT_DEVICE_ENABLE_INSTANCE, DALILIB_ACT_INPUT_DEVICE_DISABLE_INSTANCE, DALILIB_ACT_INPUT_DEVICE_SET_PRIMARY_GROUP, DALILIB_ACT_INPUT_DEVICE_SET_GROUP_1, DALILIB_ACT_INPUT_DEVICE_SET_GROUP_2, DALILIB_ACT_INPUT_DEVICE_SET_EVENT_SCHEME, DALILIB_ACT_INPUT_DEVICE_SET_EVENT_FILTER,
// instance queries // reaction code:DALILIB_REACT_CTRL_DEVICE_QUERIES DALILIB_ACT_INPUT_DEVICE_QUERY_INSTANCE_TYPE, DALILIB_ACT_INPUT_DEVICE_QUERY_RESOLUTION, DALILIB_ACT_INPUT_DEVICE_QUERY_INSTANCE_STATUS, DALILIB_ACT_INPUT_DEVICE_QUERY_EVENT_PRIORITY, DALILIB_ACT_INPUT_DEVICE_QUERY_INSTANCE_PRIMARY_GROUP, DALILIB_ACT_INPUT_DEVICE_QUERY_INSTANCE_GROUP_1, DALILIB_ACT_INPUT_DEVICE_QUERY_INSTANCE_GROUP_2, DALILIB_ACT_INPUT_DEVICE_QUERY_EVENT_SCHEME, DALILIB_ACT_INPUT_DEVICE_QUERY_INPUT_VALUE, DALILIB_ACT_INPUT_DEVICE_QUERY_INPUT_VALUE_LATCH, DALILIB_ACT_INPUT_DEVICE_QUERY_FEATURE_TYPE, DALILIB_ACT_INPUT_DEVICE_QUERY_EVENT_FILTER_1, DALILIB_ACT_INPUT_DEVICE_QUERY_EVENT_FILTER_2, DALILIB_ACT_INPUT_DEVICE_QUERY_EVENT_FILTER_3,}DALILIB_ACT_INPUT_DEVICE;
Push buttons action type enumaration Name:
DALILIB_ACT_INPUT_DEVICE
Description:
The push buttons can be managed with these actioncodes. To implement these action codes, the stack should be
multi-master application controllerconfigured as (CTRL_DEV_MODE_MULTI). So the stack will generate DALI forward frames and passthem on to HAL-Driver.
www.cslab.de 39
typedef enum _DALILIB_ACT_PUSH_BUTTON{ // Set short timer DALILIB_ACT_PUSH_BUTTON_SET_SHORT_TIMER = 0,
// Set short double timer DALILIB_ACT_PUSH_BUTTON_SET_DOUBLE_TIMER,
// Set repeat timer DALILIB_ACT_PUSH_BUTTON_SET_REPEAT_TIMER,
// Set stuck timer DALILIB_ACT_PUSH_BUTTON_SET_STUCK_TIMER,
// Query short timer DALILIB_ACT_PUSH_BUTTON_QUERY_SHORT_TIMER,
// Query short timer min DALILIB_ACT_PUSH_BUTTON_QUERY_SHORT_TIMER_MIN,
// Query short double timer DALILIB_ACT_PUSH_BUTTON_QUERY_DOUBLE_TIMER,
// Query short double timer min DALILIB_ACT_PUSH_BUTTON_QUERY_DOUBLE_TIMER_MIN,
// Query repeat timer DALILIB_ACT_PUSH_BUTTON_QUERY_REPEAT_TIMER,
// Query stuck timer DALILIB_ACT_PUSH_BUTTON_QUERY_STUCK_TIMER,}DALILIB_ACT_PUSH_BUTTON;
DALI stack event action enumerations
Input device event type enumaration Name:
DALILIB_EVENT_TYPE
Description:
The input device events are triggered by these actioncodes.At the moment, only pushbuttons are supported, but thisenumerations can be extended for other input devices.So the stack will generate DALI forward frames and passthem on to HAL-Driver.
typedef enum _DALILIB_EVENT_TYPE{ DALILIB_EVENT_TYPE_PUSH_BUTTON}DALILIB_EVENT_TYPE;
Push buttons event action type enumaration Name:
DALILIB_ACT_EVENT_PUSH_BUTTON
Description:
The push buttons events are triggered by these actioncodes. So the stack will generate DALI forward frames and passthem on to HAL-Driver.
www.cslab.de 40
typedef enum _DALILIB_ACT_EVENT_PUSH_BUTTON{ // The button is released DALILIB_ACT_EVENT_PUSH_BUTTON_RELEASED,
// The button is pressed DALILIB_ACT_EVENT_PUSH_BUTTON_PRESSED,
// The button is pressed and released DALILIB_ACT_EVENT_PUSH_BUTTON_SHORT_PRESSED,
// The button is double pressed DALILIB_ACT_EVENT_PUSH_BUTTON_DOUBLE_PRESSED,
// The button is pressed without releasing it DALILIB_ACT_EVENT_PUSH_BUTTON_LONG_PRESS_START,
// The button is still pressed DALILIB_ACT_EVENT_PUSH_BUTTON_LONG_PRESS_REPEAT,
// Following a long press start condition, the button isreleased DALILIB_ACT_EVENT_PUSH_BUTTON_LONG_PRESS_STOP,
// The button has been stuck and is now released DALILIB_ACT_EVENT_PUSH_BUTTON_FREE,
// The button has been pressed for a very long time and isassumed stuck DALILIB_ACT_EVENT_PUSH_BUTTON_STUCK,}DALILIB_ACT_EVENT_PUSH_BUTTON;
Examples
DALI stack control gear action examples
Control gear set actual level
Description:
A application controller (control device) can be set thelevel of a control gear with action code "DALILIB_ACT_C
"TRL_GEAR_LEVEL_DAPC
Example:
www.cslab.de 41
dalilib_action_t daliAction;
// set action typedaliAction.actionType = DALILIB_ACT_GEAR_ACTION;
// set control gear action typedaliAction.gearAct.gearActionType =DALILIB_ACT_TYPE_CTRL_GEAR_LEVEL;
// fill address struct for target conrtol geardaliAction.gearAct.adr.adrType = DALI_ADRTYPE_SHORT;daliAction.gearAct.adr.adr = 0x05; // short address 5
// set control gear level action codedaliAction.gearAct.action.levelAction =DALILIB_ACT_CTRL_GEAR_LEVEL_DAPC;
// set control gear action value// new level value for the target control geardaliAction.gearAct.value.actionValue = 85500; // 85,5%
dalilib_action(pDaliStackInstance, &daliAction);
DALI stack control device action examples
Control device set event filter
Description:
The event message filter can be used to enable anddisable specific events. "DALILIB_ACT_INPUT_DEVICE
"_SET_EVENT_FILTERAs an example, a application controller (control device)will set the event filter for the input device.
Example:
dalilib_action_t daliAction;
// set action typedaliAction.actionType = DALILIB_CTRL_DEVICE_ACTION;
// set control device action typedaliAction.deviceAct.deviceActionType =DALILIB_ACT_TYPE_INPUT_DEVICE;
// fill address struct for target conrtol devicedaliAction.deviceAct.adr.adrType = DALI_ADRTYPE_SHORT;daliAction.deviceAct.adr.adr = 0x07; // short address 7
// set input device action codedaliAction.deviceAct.inputDeviceAction =DALILIB_ACT_INPUT_DEVICE_SET_EVENT_FILTER;
// set input device "eventFilter" valuedaliAction.deviceAct.actionValue = 0x03;
dalilib_action(pDaliStackInstance, &daliAction);
DALI stack event action examples
Push button pressed event action
Description:
If an input device triggers an event, this event istransmitted to the stack with the action codes.As an example, a button pressed event will be triggeredand this event will be transmitted to stack.
Example:
www.cslab.de 42
dalilib_action_t daliAction;
// set action typedaliAction.actionType = DALILIB_EVENT_ACTION;
// set event action typedaliAction.eventAct.type =DALILIB_EVENT_TYPE_PUSH_BUTTON;
// fill address struct for target control devicedaliAction.eventAct.adr.adrType = DALI_ADRTYPE_SHORT;daliAction.eventAct.adr.adr = 0x07; // short address 7
// set push button event action codedaliAction.eventAct.pushButtonEvent =DALILIB_ACT_EVENT_PUSH_BUTTON_PRESSED;
dalilib_action(pDaliStackInstance, &daliAction);
ReactionContents
1 Structs1.1 DALI stack reaction struct1.2 DALI stack control gear reaction structs
1.2.1 Control gear reaction struct1.2.2 Control gear reaction value1.2.3 Control gear reaction global trade item number1.2.4 Control gear reaction firmware version major1.2.5 Control gear reaction firmware version minor1.2.6 Control gear reaction identification number1.2.7 Control gear reaction hardware version major1.2.8 Control gear reaction hardware version minor1.2.9 Control gear reaction IEC 62386-102 version number1.2.10 Control gear reaction status struct
1.3 DALI stack control device reaction structs1.3.1 Control device reaction struct1.3.2 Control device reaction value1.3.3 Control device reaction global trade item number1.3.4 Control device reaction firmware version major1.3.5 Control device reaction firmware version minor1.3.6 Control device reaction identification number1.3.7 Control device reaction hardware version major1.3.8 Control device reaction hardware version minor1.3.9 Control device reaction IEC 62386-103 version number1.3.10 Control device reaction status struct1.3.11 Control device reaction capabilities struct1.3.12 Input device reaction instance status struct
1.4 DALI stack event reaction structs1.4.1 Event reaction struct1.4.2 Event message reaction struct
2 Enumerations2.1 DALI stack reaction value valid flag2.2 DALI stack reaction type enumerations2.3 DALI stack control gear reaction enumerations2.4 DALI stack control device reaction enumerations2.5 DALI stack event enumerations
2.5.1 Event scheme3 Examples
3.1 DALI stack control gear reaction examples3.1.1 Control gear off
3.2 DALI stack control device reaction examples3.2.1 Control gear query status
3.3 DALI stack event reaction examples3.3.1 Push button pressed event
This section describes the callback function R_DALILIB_RESULT (*fAppReAction)(dalilib_action_t* pAction)
The structures and the enumerations are described the communication between stack and an application.Callback function is set
www.cslab.de 43
to inform the application of the eventsto check the status of the hardwareto redirect the responses to the application that the application requested
Communication from stack to an application runs over this function.Different actions are defined via the reaction type "DALILIB_REACTION_TYPE" and enumerations. The reaction enumerationsalways start with prefix "DALILIB_REACT_xxxxxxx"The following structures will be used for the action
dalilib_react_ctrl_gear_tdalilib_react_ctrl_device_tdalilib_react_event_t
Structs
DALI stack reaction structName:
dalilib_action_t
Description:
For the response code is set to either "DALILIB_CTRL_" , "GEAR_REACTION DALILIB_CTRL_DEVICE_REAC
" or " " lawTION DALILIB_EVENT_ACTIONaction struct contains information
reaction typesub reaction typereaction valuecontrol gear/device address
typedef struct _dalilib_action_t{ DALILIB_ACTION_TYPE actionType; union{ dalilib_act_ctrl_gear_t gearAct; dalilib_react_ctrl_gear_t gearReact; // used forreaction function dalilib_act_ctrl_device_t deviceAct; dalilib_react_ctrl_device_t deviceReact; // used forreaction function dalilib_act_event_t eventAct; dalilib_react_event_t eventReact; // used forreaction function };}dalilib_action_t;
DALI stack control gear reaction structs
Control gear reaction struct Name:
dalilib_react_ctrl_gear_t
Description:
reaction struct contains informationcontrol gear reaction coderesponse value typecontrol gear reactioncontrol gear reaction value
typedef struct _dalilib_react_ctrl_gear_t{ DALILIB_CTRL_GEAR_REACTION_CODES reactionCode; DALILIB_RESPONSE_VALUE_TYPE valueType; union { uint32_t reactValue; uint8_t gtin[6]; uint8_t firmware_ver_major; uint8_t firmware_ver_minor; uint8_t identify_number[8]; uint8_t hardware_ver_major; uint8_t hardware_ver_minor; uint8_t dali_norm_version; ctrl_gear_status_t gearStatus; };}dalilib_react_ctrl_gear_t;
Control gear reaction value Name:
reactValue
www.cslab.de 44
Description:
reaction value is depends on the reaction typeif a light level value [0%..100%]light level value is multiplied by the factor 1000 torepresent the decimal places
e.g. 2,521% => 2,521 * 1000 = 2521
Control gear reaction global trade item number Name:
gtin
Description:
the manufacturer's global trade item number is returnedby a control gear.to request this information, the action function with theaction code
gearActionType: DALILIB_ACT_TYPE_CTRL_GEAR_VENDORvendorAction: DALILIB_ACT_CTRL_GEAR_VENDOR_GTIN
will be executed.
Control gear reaction firmware version major Name:
firmware_ver_major
Description:
the manufacturer's is returned by a firmware versioncontrol gear.to request this information, the action function with theaction code
gearActionType: DALILIB_ACT_TYPE_CTRL_GEAR_VENDORvendorAction: DALILIB_ACT_CTRL_GEAR_VENDOR_FW_VER_MAJOR
will be executed.
Control gear reaction firmware version minor Name:
firmware_ver_minor
Description:
the manufacturer's firmware version is returned by acontrol gear.to request this information, the action function with theaction code
gearActionType: DALILIB_ACT_TYPE_CTRL_GEAR_VENDORvendorAction: DALILIB_ACT_CTRL_GEAR_VENDOR_FW_VER_MINOR
will be executed.
Control gear reaction identification number Name:
identify_number
Description:
the manufacturer's identification number is returned by acontrol gear.to request this information, the action function with theaction code
gearActionType: DALILIB_ACT_TYPE_CTRL_
www.cslab.de 45
GEAR_VENDORvendorAction: DALILIB_ACT_CTRL_GEAR_VENDOR_IDENTIFY_NR
will be executed.
Control gear reaction hardware version major Name:
hardware_ver_major
Description:
the manufacturer's hardware version is returned by acontrol gear.to request this information, the action function with theaction code
gearActionType: DALILIB_ACT_TYPE_CTRL_GEAR_VENDORvendorAction: DALILIB_ACT_CTRL_GEAR_VENDOR_HW_VER_MAJOR
will be executed.
Control gear reaction hardware version minor Name:
hardware_ver_minor
Description:
the manufacturer's is returned by ahardware versioncontrol gear.to request this information, the action function with theaction code
gearActionType: DALILIB_ACT_TYPE_CTRL_GEAR_VENDORvendorAction: DALILIB_ACT_CTRL_GEAR_VENDOR_HW_VER_MINOR
will be executed.
Control gear reaction IEC 62386-102 version number Name:
dali_norm_version
Description:
by a control gear.the is returned DALI versionto request this information, the action function with theaction code
gearActionType: DALILIB_ACT_TYPE_CTRL_GEAR_VENDORvendorAction: DALILIB_ACT_CTRL_GEAR_VENDOR_DALI_NORM_VERSION
will be executed.
Control gear reaction status struct Name:
ctrl_gear_status_t
Description:
the control gear status is returned by a requested controlgear.to request this information, the action function with theaction code
gearActionType: DALILIB_ACT_TYPE_CTRL_GEAR_QUERY_STATUS
will be executed.
www.cslab.de 46
typedef struct _ctrl_gear_status_t{ uint8_t controlGearFailure; //[FALSE|TRUE] uint8_t lampFailure; //[FALSE|TRUE] uint8_t lampOn; //[FALSE|TRUE] uint8_t limitError; //[FALSE|TRUE] uint8_t fadeRunning; //[FALSE|TRUE] uint8_t resetState; //[FALSE|TRUE] uint8_t shortAddress; //[FALSE|TRUE] uint8_t powerCycleSeen; //[FALSE|TRUE]}ctrl_gear_status_t;
DALI stack control device reaction structs
Control device reaction struct Name:
dalilib_react_ctrl_device_t
Description:
reaction struct contains informationcontrol device reaction coderesponse value typecontrol device reactioncontrol device addresscontrol device reaction value
typedef struct{ DALILIB_CTRL_DEVICE_REACTION_CODES reactionCode; device_adr_t adr; DALILIB_RESPONSE_VALUE_TYPE valueType; union { uint32_t reactValue; uint8_t gtin[6]; uint8_t firmware_ver_major; uint8_t firmware_ver_minor; uint8_t identify_number[8]; uint8_t hardware_ver_major; uint8_t hardware_ver_minor; uint8_t dali_norm_version; ctrl_device_status_t deviceStatus; ctrl_device_capabilities_t deviceCapabilities; ctrl_device_instance_status_t deviceInstanceStatus; };}dalilib_react_ctrl_device_t;
Control device reaction value Name:
reactValue
Description:
reaction value is depends on the reaction type
Control device reaction global trade item number Name:
gtin
Description:
see control gear reaction global trade item number
www.cslab.de 47
Control device reaction firmware version major Name:
firmware_ver_major
Description:
see control gear reaction firmware version major
Control device reaction firmware version minor Name:
firmware_ver_minor
Description:
see control gear reaction firmware version minor
Control device reaction identification number Name:
identify_number
Description:
see control gear reaction identification number
Control device reaction hardware version major Name:
hardware_ver_major
Description:
see control gear reaction hardware version major
Control device reaction hardware version minor Name:
hardware_ver_minor
Description:
see control gear reaction hardware version minor
Control device reaction IEC 62386-103 version
number
Name:
dali_norm_version
Description:
the is returned by a control device.DALI versionto request this information, the action function with theaction code
deviceActionType: DALILIB_ACT_TYPE_CTRL_DEVICE_CONTROLLERcontrollerAction: DALILIB_ACT_CTRL_GEAR_VENDOR_DALI_NORM_VERSION
will be executed.
Control device reaction status struct Name:
ctrl_device_status_t
Description:
the control device status is returned by a requestedcontrol device.to request this information, the action function with the
www.cslab.de 48
action code deviceActionType: DALILIB_ACT_TYPE_CTRL_DEVICE_CONTROLLER
: controllerAction DALILIB_ACT_CTRL_DEVICE _QUERY_STATUS
will be executed.
typedef struct _ctrl_device_status_t{ uint8_t inputDeviceError; //[FALSE|TRUE] uint8_t quiescentMode; //[FALSE|TRUE] uint8_t shortAddress; //[FALSE|TRUE] uint8_t applicationActive; //[FALSE|TRUE] uint8_t applicationCtrlErr; //[FALSE|TRUE] uint8_t powerCycleSeen; //[FALSE|TRUE] uint8_t resetState; // [FALSE|TRUE]}ctrl_device_status_t;
Control device reaction capabilities struct Name:
ctrl_device_capabilities_t
Description:
each control device shall expose its features as acombination of device capabilitiesto request this information, the action function with theaction code
deviceActionType: DALILIB_ACT_TYPE_CTRL_DEVICE_CONTROLLERcontrollerAction: DALILIB_ACT_CTRL_DEVICE
_QUERY_DEVICE_CAPABILITIESwill be executed.
typedef struct _ctrl_device_capabilities_t{ uint8_t applicationCtrlPresent; //[FALSE|TRUE] uint8_t numberOfInstance; //[FALSE|TRUE]}ctrl_device_capabilities_t;
Input device reaction instance status struct Name:
ctrl_device_instance_status_t
Description:
each instance shall expose its status as a combination ofinstance propertiesto request this information, the action function with theaction code
deviceActionType: DALILIB_ACT_TYPE_INPUT_DEVICEinputDeviceAction: DALILIB_ACT_INPUT_DEVICE_QUERY_INSTANCE_STATUS
will be executed.
typedef struct _ctrl_device_instance_status_t{ uint8_t instanceError; // [FALSE|TRUE] uint8_t instanceActive; // [FALSE|TRUE]}ctrl_device_instance_status_t;
DALI stack event reaction structs
Event reaction struct Name:
dalilib_react_event_t
Description:
reaction struct contains informationcontrol device reaction codeevent message
typedef struct{ DALILIB_CTRL_DEVICE_REACTION_CODES reactionCode; ctrl_device_event_message_t eventMessage;}dalilib_react_event_t;
Name:
www.cslab.de 49
Event message reaction struct ctrl_device_event_message_t
Description:
reaction struct contains informationevent source addressing schemeinstance type of the input devicedepending on event scheme the following fieldsare filled out
instance numberinstance groupshort address of the input devicegroup address of the input device
typedef struct _ctrl_device_event_message_t{ CTRL_DEVICE_EVENT_SCHEME eventScheme; INPUT_DEVICE_INSTANCE_TYPE instanceType; uint8_t instanceNumber; uint8_t instanceGroup; uint8_t shortAddress; uint8_t deviceGroup;}ctrl_device_event_message_t;
Enumerations
DALI stack reaction value valid flagName:
valueType
Description:
this flag describes whether the answer is valid or notthe request could not be sentwhen it is the scene requests, returns whether the sceneis set or not
typedef enum _DALILIB_RESPONSE_VALUE_TYPE{ DALILIB_RESPONSE_VALUE_VALID = 0, DALILIB_RESPONSE_VALUE_NO_ANSWER, DALILIB_RESPONSE_VALUE_REQUEST_NOT_SEND, DALILIB_RESPONSE_VALUE_SCENE_NOT_USED,}DALILIB_RESPONSE_VALUE_TYPE;
DALI stack reaction type enumerationsName:
DALILIB_ACTION_TYPE
Description:
possible reaction codesDALILIB_CTRL_GEAR_REACTIONDALILIB_CTRL_DEVICE_REACTIONDALILIB_EVENT_ACTION
typedef enum _DALILIB_ACTION_TYPE{ DALILIB_ACTION_NONE = 0, DALILIB_CTRL_GEAR_ACTION, // control gearactions DALILIB_CTRL_GEAR_REACTION, // control gearreactions DALILIB_CTRL_DEVICE_ACTION, // control deviceactions DALILIB_CTRL_DEVICE_REACTION, // control devicereactions DALILIB_EVENT_ACTION, // input device eventactions DALILIB_GW_ACTION, // gatewayactions/reactions DALILIB_ACTION_MAX}DALILIB_ACTION_TYPE;
DALI stack control gear reaction
enumerations
Name:
DALILIB_CTRL_GEAR_REACTION_CODES
Description:
actionType is equal DALILIB_CTRL_GEAR_REACTION
DALILIB_REACT_CTRL_GEAR_NONE
reserved reaction code
www.cslab.de 50
DALILIB_REACT_INTERNAL_CTRL_GEAR_QUERY_LAMPFAILURE
stack can query about the lamp failure flag viathis reaction codethis is an internal reaction code between thestack and the applicationthe application must respond with action code DALILIB_ACT_INTRNAL_CTRL_GEAR_SET_LAMPFAILURE
DALILIB_REACT_INTERNAL_CTRL_GEAR_OFFstack notifies about "OFF" command theapplicationthis is an internal reaction code between thestack and the application
DALILIB_REACT_INTERNAL_CTRL_GEAR_SET_ACTUAL_LEVEL
stack notifies the new level of the control gearthe applicationthis is an internal reaction code between thestack and the application
DALILIB_REACT_INTERNAL_CTRL_GEAR_QUERY_ACTUAL_LEVEL
stack can query about the actual level of thecontrol gear via this reaction codethis is an internal reaction code between thestack and the applicationthe application must respond with action code DALILIB_ACT_INTERNAL_CTRL_GEAR_SET_ACTUAL_LEVEL
DALILIB_REACT_INTERNAL_CTRL_GEAR_QUERY_GEAR_FAILURE
stack can query about the control gear(hardware) failure flag via this reaction codethis is an internal reaction code between thestack and the applicationthe application must respond with action code DALILIB_ACT_INTERNAL_CTRL_GEAR_SET_GEAR_FAILURE
DALILIB_REACT_INTERNAL_CTRL_GEAR_LED_MEASUREMENT_START
stack notify to start the application theLED-reference measurementthis is an internal reaction code between thestack and the application
DALILIB_REACT_INTERNAL_CTRL_GEAR_LED_MEASUREMENT_STOP
stack notify to stop the application theLED-reference measurementthis is an internal reaction code between thestack and the application
DALILIB_REACT_CTRL_GEAR_QUERY_STATUSstack notify the response to the request DALILIB
_ACT_TYPE_CTRL_GEAR_QUERY_STATUSstatus with this response codethe structure is filled in forctrl_gear_status_tthe responsethe response is valid if the flag isvalueTypeequal to DALILIB_RESPONSE_VALUE_VALID
DALILIB_REACT_CTRL_GEAR_QUERIESstack notifies the application of the response tothe requests from DALILIB_ACT_CTRL_GEAR
with this response code_QUERIESthe response is written into the structure variable reactValuethe response is valid if the flag isvalueTypeequal to DALILIB_RESPONSE_VALUE_VALID
DALILIB_REACT_CTRL_GEAR_VENDORstack notifies the application of the response to
typedef enum _DALILIB_CTRL_GEAR_REACTION_CODES{ DALILIB_REACT_CTRL_GEAR_NONE = 0,
//---------------------------------------------------------------------- // reaction codes, if stack mode equalSTACK_MODE_CONTROL_GEAR // internal reaction codes between application andDALI-Library //---------------------------------------------------------------------- DALILIB_REACT_INTERNAL_CTRL_GEAR_QUERY_LAMPFAILURE, DALILIB_REACT_INTERNAL_CTRL_GEAR_OFF, DALILIB_REACT_INTERNAL_CTRL_GEAR_SET_ACTUAL_LEVEL, DALILIB_REACT_INTERNAL_CTRL_GEAR_QUERY_ACTUAL_LEVEL, DALILIB_REACT_INTERNAL_CTRL_GEAR_QUERY_GEAR_FAILURE, DALILIB_REACT_INTERNAL_CTRL_GEAR_LED_MEASUREMENT_START, DALILIB_REACT_INTERNAL_CTRL_GEAR_LED_MEASUREMENT_STOP, //----------------------------------------------------------------------
//---------------------------------------------------------------------- // reaction codes, if stack mode equalSTACK_MODE_CONTROL_DEVICE //---------------------------------------------------------------------- DALILIB_REACT_CTRL_GEAR_QUERY_STATUS, DALILIB_REACT_CTRL_GEAR_QUERIES, DALILIB_REACT_CTRL_GEAR_VENDOR, DALILIB_REACT_CTRL_GEAR_INITIALISE, DALILIB_REACT_CTRL_GEAR_MEMORY, DALILIB_REACT_CTRL_GEAR_LED, DALILIB_REACT_CTRL_GEAR_FLUORESCENT,
DALILIB_REACT_CTRL_GEAR_LAST}DALILIB_CTRL_GEAR_REACTION_CODES;
www.cslab.de 51
the requests from DALILIB_ACT_CTRL_GEAR with this response code_VENDOR
the response is written into the structure dalilib_ variable react_ctrl_gear_t
gtinfirmware_ver_majorfirmware_ver_minoridentify_numberhardware_ver_majorhardware_ver_minordali_norm_version
the response variable is dependent on thevendor request the response is valid if the flag isvalueTypeequal to DALILIB_RESPONSE_VALUE_VALID
DALILIB_REACT_CTRL_GEAR_INITIALISEstack notifies the application of the response tothe requests from DALILIB_ACT_CTRL_GEAR
with this response code_INITIALISEthe response is written into the structure variable reactValuethe response is valid if the flag isvalueTypeequal to DALILIB_RESPONSE_VALUE_VALID
DALILIB_REACT_CTRL_GEAR_MEMORYstack notifies the application of the response tothe requests from DALILIB_ACT_CTRL_GEAR
with this response code_MEMORYthe response is written into the structure variable reactValuethe response is valid if the flag isvalueTypeequal to DALILIB_RESPONSE_VALUE_VALID
DALILIB_REACT_CTRL_GEAR_LEDstack notifies the application of the response tothe requests from DALILIB_ACT_CTRL_GEAR
with this response code_LEDthe response is written into the structure variable reactValuethe response is valid if the flag isvalueTypeequal to DALILIB_RESPONSE_VALUE_VALID
DALILIB_REACT_CTRL_GEAR_FLUORESCENTstack notifies the application of the response tothe requests from DALILIB_ACT_CTRL_GEAR
with this response code_FLUORESCENTthe response is written into the structure variable reactValuethe response is valid if the flag isvalueTypeequal to DALILIB_RESPONSE_VALUE_VALID
DALILIB_REACT_CTRL_GEAR_LASTreserved reaction code
DALI stack control device reaction
enumerations
Name:
DALILIB_CTRL_DEVICE_REACTION_CODES
Description:
actionType is equal DALILIB_CTRL_DEVICE_REACTION
DALILIB_REACT_CTRL_DEVICE_QUERY_STATUSDALILIB_REACT_CTRL_DEVICE_QUERIESDALILIB_REACT_CTRL_DEVICE_INITIALISEDALILIB_REACT_CTRL_DEVICE_VENDORDALILIB_REACT_CTRL_DEVICE_MEMORY
which are constructed in the same way as withthe control gear
DALILIB_REACT_CTRL_DEVICE_CAPABILITIES
www.cslab.de 52
stack notify the response to the request DALILIB_ACT_CTRL_DEVICE_QUERY_DEVICE_CAP
status with this response codeABILITIESthe structure is filledctrl_device_capabilities_tin for the responsethe response is valid if the flag isvalueTypeequal to DALILIB_RESPONSE_VALUE_VALID
DALILIB_REACT_CTRL_DEVICE_INSTANCE_STATUS
stack notify the response to the request DALILIB_ACT_INPUT_DEVICE_QUERY_INSTANCE_S
status with this response codeTATUSthe structure isctrl_device_instance_status_tfilled in for the responsethe response is valid if the flag isvalueTypeequal to DALILIB_RESPONSE_VALUE_VALID
DALILIB_REACT_PUSH_BUTTON stack notifies the application of the response tothe requests from DALILIB_ACT_PUSH_BUTT
with this response codeONthe response is written into the structure variable reactValuethe response is valid if the flag isvalueTypeequal to DALILIB_RESPONSE_VALUE_VALID
DALILIB_REACT_EVENT_STARTreserved reaction code
DALILIB_REACT_INTERNAL_PUSH_BUTTON_SHORT_TIMERDALILIB_REACT_INTERNAL_PUSH_BUTTON_DOUBLE_TIMERDALILIB_REACT_INTERNAL_PUSH_BUTTON_REPEAT_TIMERDALILIB_REACT_INTERNAL_PUSH_BUTTON_STUCK_TIMER
the response to the requests from DALILIB_ACT_INTERNAL_CTRL_DEVICEstack returns the value for these properties to theapplication.this is an internal reaction code between thestack and the application
DALILIB_REACT_EVENT_PUSH_BUTTON_RELEASEDDALILIB_REACT_EVENT_PUSH_BUTTON_PRESSEDDALILIB_REACT_EVENT_PUSH_BUTTON_SHORT_PRESSEDDALILIB_REACT_EVENT_PUSH_BUTTON_DOUBLE_PRESSEDDALILIB_REACT_EVENT_PUSH_BUTTON_LONG_PRESS_STARTDALILIB_REACT_EVENT_PUSH_BUTTON_LONG_PRESS_REPEATDALILIB_REACT_EVENT_PUSH_BUTTON_LONG_PRESS_STOPDALILIB_REACT_EVENT_PUSH_BUTTON_FREEDALILIB_REACT_EVENT_PUSH_BUTTON_STUCK
actionTypeAttention: is equal DALILIB_EVENT_ACTIONthe event is passed on to the application by aninput control device of the push-button type the structure is ctrl_device_event_message_tfilled with the event information, the applicationcan decide with the information whether or not tocontrol a control gear.
DALILIB_REACT_EVENT_UNKNOWN Attention: actionType is equal DALILIB_EVEN
T_ACTION an unknown or non-supported event wasreceived, and this event is passed to theapplication as a unknown event.
typedef enum _DALILIB_CTRL_DEVICE_REACTION_CODES{ DALILIB_REACT_CTRL_DEVICE_QUERY_STATUS = 0, DALILIB_REACT_CTRL_DEVICE_CAPABILITIES, DALILIB_REACT_CTRL_DEVICE_QUERIES, DALILIB_REACT_CTRL_DEVICE_INITIALISE, DALILIB_REACT_CTRL_DEVICE_VENDOR, DALILIB_REACT_CTRL_DEVICE_INSTANCE_STATUS, DALILIB_REACT_CTRL_DEVICE_MEMORY, DALILIB_REACT_PUSH_BUTTON,
DALILIB_REACT_EVENT_START,
DALILIB_REACT_INTERNAL_PUSH_BUTTON_SHORT_TIMER, DALILIB_REACT_INTERNAL_PUSH_BUTTON_DOUBLE_TIMER, DALILIB_REACT_INTERNAL_PUSH_BUTTON_REPEAT_TIMER, DALILIB_REACT_INTERNAL_PUSH_BUTTON_STUCK_TIMER,
// event message reaction codes // The button is released DALILIB_REACT_EVENT_PUSH_BUTTON_RELEASED,
// The button is pressed DALILIB_REACT_EVENT_PUSH_BUTTON_PRESSED,
// The button is pressed and released DALILIB_REACT_EVENT_PUSH_BUTTON_SHORT_PRESSED,
// The button is double pressed DALILIB_REACT_EVENT_PUSH_BUTTON_DOUBLE_PRESSED,
// The button is pressed without releasing it DALILIB_REACT_EVENT_PUSH_BUTTON_LONG_PRESS_START,
// The button is still pressed DALILIB_REACT_EVENT_PUSH_BUTTON_LONG_PRESS_REPEAT,
// Following a long press start condition, the button isreleased DALILIB_REACT_EVENT_PUSH_BUTTON_LONG_PRESS_STOP,
// The button has been stuck and is now released DALILIB_REACT_EVENT_PUSH_BUTTON_FREE,
// The button has been pressed for a very long time and isassumed stuck DALILIB_REACT_EVENT_PUSH_BUTTON_STUCK,
// raw event will be transmitted on application DALILIB_REACT_EVENT_UNKNOWN,
DALILIB_REACT_EVENT_END,
}DALILIB_CTRL_DEVICE_REACTION_CODES;
www.cslab.de 53
DALILIB_REACT_EVENT_ENDreserved reaction code
DALI stack event enumerations
Event scheme Name:
CTRL_DEVICE_EVENT_SCHEME
Description:
An instance of an input device shall, when transmitting anevent message, use the selected event sourceaddressing scheme as defined in Eventscheme table.
Eventscheme table
typedef enum _CTRL_DEVICE_EVENT_SCHEME{ EVENT_SCHEME_INSTANCE = 0, EVENT_SCHEME_DEVICE, EVENT_SCHEME_DEVICE_INSTANCE, EVENT_SCHEME_DEVICE_GROUP, EVENT_SCHEME_INSTANCE_GROUP, EVENT_SCHEME_RESERVED}CTRL_DEVICE_EVENT_SCHEME;
Examples
DALI stack control gear reaction examples
Control gear off
Description:
if the stack receives the DALI command OFF from acontrol unit, checks if this command is addressed to thisdevice
yes, the stack informs the application that thelamp should switch off via the callback function(fAppReAction) with reaction code DALILIB_REACT_INTERNAL_CTRL_GEAR_OFFno, the frame will be ignored
Example:
// libdali.h// typedef R_DALILIB_RESULT(*fAppReAction)(dalilib_action_t* pAction);
R_DALILIB_RESULT dali_demo_lib_cb_reaction(dalilib_action_t * p_action){ dalilib_action_t action; if (DALILIB_CTRL_GEAR_REACTION ==p_action->actionType) { if(DALILIB_REACT_INTERNAL_CTRL_GEAR_OFF ==p_action->gearReact.reactionCode) { // TODO // lamp off
/* refresh actual level of the stack */ action.actionType =DALILIB_CTRL_GEAR_ACTION; action.gearAct.action.internalAction =DALILIB_ACT_INTERNAL_CTRL_GEAR_SET_ACTUAL_LEVEL; action.gearAct.gearActionType =DALILIB_ACT_TYPE_INTERNAL_CTRL_GEAR; action.gearAct.value.actionValue = 0;
dalilib_action(pDaliStackInstance, &action); } } return R_DALILIB_OK;}
www.cslab.de 54
DALI stack control device reaction examples
Control gear query status
Description:
a application controller (control device) can interrogatethe status of a control gear.if a response from the control gear to the stack arrives onthis request, the response function is passed on to theapplication.the structure ctrl_gear_status_t is filled in.
Example:
1. send query status to the control gear with the shortaddress (0x04)
void dali_demo_query_status(void){ dalilib_action_t action;
// this flag is set with the callback function ready if (g_dalilib_ready) { action.actionType =DALILIB_CTRL_GEAR_ACTION; action.gearAct.adr.adr = 0x04; action.gearAct.adr.adrType =DALI_ADRTYPE_SHORT; action.gearAct.gearActionType =DALILIB_ACT_TYPE_CTRL_GEAR_QUERY_STATUS;
dalilib_action(pDaliStackInstance, &action); }
}
2. answer of the query from control gear
// libdali.h// typedef R_DALILIB_RESULT(*fAppReAction)(dalilib_action_t* pAction);
R_DALILIB_RESULT dali_demo_lib_cb_reaction(dalilib_action_t * p_action){ dalilib_action_t act; if (DALILIB_CTRL_GEAR_REACTION ==p_action->actionType) { if(DALILIB_ACT_TYPE_CTRL_GEAR_QUERY_STATUS== p_action->gearReact.reactionCode) { // evaluate the status // p_action->gearReact.gearStatus
} } return R_DALILIB_OK;}
DALI stack event reaction examples
Push button pressed event
Description:
When an event is triggered by an input control device, thecontrol devices receive it.This event is passed to the application via the callbackfunction fAppReaction.Appending this event can decide the application whetherto respond to it or not.On the example, a push button pressed event is sent tothe application, whereupon the application turns on thecontrol gear with the short address 0x04.
Example:
www.cslab.de 55
// libdali.h// typedef R_DALILIB_RESULT(*fAppReAction)(dalilib_action_t* pAction);
R_DALILIB_RESULT dali_demo_lib_cb_reaction(dalilib_action_t * p_action){ dalilib_action_t act; if ( == p_action->actionType)DALILIB_EVENT_ACTION { if(DALILIB_REACT_EVENT_PUSH_BUTTON_RELEASED ==p_action->eventReact.reactionCode) {
if (EVENT_SCHEME_DEVICE ==p_action->eventReact.eventMessage.eventScheme) { // event triggered by an input device with shortaddress 0x06 if (0x06 ==p_action->eventReact.eventMessage.shortAddress) { dalilib_action_t action;
action.actionType =DALILIB_CTRL_GEAR_ACTION; action.gearAct.adr.adr = 0x04; action.gearAct.adr.adrType =DALI_ADRTYPE_SHORT; action.gearAct.action.levelAction =DALILIB_ACT_CTRL_GEAR_LEVEL_RECALL_MAX_LEVEL;
dalilib_action(pDaliStackInstance, &action); } } } } return R_DALILIB_OK;}
Implementation examples
Contents
Control gear exampleControl device example
Control gear exampleDescription
Here, the DALI stack instance is implemented as an control gear.And the communication between the DALI stack and the application is shown.
. In the example, the control gear is operated as an LED module
/***********************************************************************************************************************/* include DALI stack header file***********************************************************************************************************************/
#include "libdali.h"
static dalilib_instance_t pDaliStackInstance = NULL;static dalilib_cfg_t ctrl_gear_config;static uint8_t bDaliStackReady = 0;
static uint32_t = 0;actualLevel static dalilib_action_t action;
www.cslab.de 56
/*********************************************************************************************************************//* DALI stack callback functions**********************************************************************************************************************//********************************************************************************************************************//* will be called by the DALI library if it wants to send a DALI message to the driver* result: 0: success **********************************************************************************************************************/static uint8_t dali_send_callback(void * p_context, dalilib_frame_t* p_frame){ uint8_t result; hal_driver_frame frame; // TODO // convert DALI stack format to HAL driver frame format
// forward frame to the HAL driver result = hal_drivre_send_frame(&frame);
return result;}
/*******************************************************************************************************************//* invoked by the DALI stack to notify the application that is ready to receive the actions********************************************************************************************************************/static void dali_ready_callback(void){ bDaliStackReady = 1;}
/*******************************************************************************************************************//* will be called by the DALI stack to tell the application shall load the persistent variables
**********************************************************************************************************************/static uint8_t dali_loadmemory_callback(void* pMemory, uint8_t nSize){ uint8_t err = 0; //SUCCESS switch(stack_config0.mode) { case STACK_MODE_CONTROL_GEAR: err = flash_read(pMemory, nSize, 0); break; case STACK_MODE_CONTROL_DEVICE: err = flash_read(pMemory, nSize, 1); break; } return (err);}
/*******************************************************************************************************************//* will be called by the DALI library to tell the application shall save the persistent variables**********************************************************************************************************************/static uint8_t dali_savememory_callback(void* pMemory, uint8_t nSize){ uint8_t err = 0; //SUCCESS switch(stack_config0.mode) { case STACK_MODE_CONTROL_GEAR: err = flash_write(pMemory, nSize, 0); break; case STACK_MODE_CONTROL_DEVICE: err = flash_write(pMemory, nSize, 1); break; } return (err);}
/*******************************************************************************************************************//* will be called by the DALI library to notify the application about 'something'**********************************************************************************************************************/static uint8_t dali_gear_reaction_callback(dalilib_react_ctrl_gear_t * p_args){ switch(p_args->reactionCode) { case DALILIB_REACT_INTERNAL_CTRL_GEAR_OFF: { // hardware shall be set to 0, e.g. turn the lamp off // set internal actualLevel actualLevel = 0;
www.cslab.de 57
// refresh actual level of the Stack action.actionType = DALILIB_CTRL_GEAR_ACTION; action.gearAct.gearActionType = DALILIB_ACT_TYPE_INTERNAL_CTRL_GEAR; action.gearAct.action.internalAction = DALILIB_ACT_INTERNAL_CTRL_GEAR_SET_ACTUAL_LEVEL; action.gearAct.value.actionValue = 0;
dalilib_action(pDaliStackInstance, &action); } break;
case DALILIB_REACT_INTERNAL_CTRL_GEAR_SET_ACTUAL_LEVEL: { // hardware shall be set to reaction value
// refresh actual level of the Stack action.actionType = DALILIB_CTRL_GEAR_ACTION; action.gearAct.gearActionType = DALILIB_ACT_TYPE_INTERNAL_CTRL_GEAR; action.gearAct.action.internalAction = DALILIB_ACT_INTERNAL_CTRL_GEAR_SET_ACTUAL_LEVEL; actualLevel = action.gearAct.value.actionValue = p_args->reactValue;
dalilib_action(pDaliStackInstance, &action); } break;
case DALILIB_REACT_INTERNAL_CTRL_GEAR_QUERY_ACTUAL_LEVEL: { action.actionType = DALILIB_CTRL_GEAR_ACTION; action.gearAct.gearActionType = DALILIB_ACT_TYPE_INTERNAL_CTRL_GEAR; action.gearAct.action.internalAction = DALILIB_ACT_INTERNAL_CTRL_GEAR_SET_ACTUAL_LEVEL; action.gearAct.value.actionValue = actualLevel;
dalilib_action(pDaliStackInstance, &action);
} break; }
return (0);
}
/*******************************************************************************************************************//* will be called by the DALI library to notify the application about 'something'**********************************************************************************************************************/static uint8_t dali_reaction_callback(dalilib_action_t * p_args){ uint8_t res = 0; switch(p_args->actionType) { case DALILIB_CTRL_GEAR_REACTION: res = daliwrapper_gear_reaction_callback(&p_args->gearReact); break;
default: res = 0xFF; //unsupported reaction type break; }
return (res);}
/*********************************************************************************************************************//* DALI stack configuration struct will be initialized**********************************************************************************************************************/static void dali_create_gear_config(void){ memset(ctrl_gear_config, 0, sizeof(ctrl_gear_config));
// stack mode ctrl_gear_config.mode = STACK_MODE_CONTROL_GEAR; ctrl_gear_config.vendor.control_device_mode = CTRL_DEV_MODE_NONE;
www.cslab.de 58
// vendor information ctrl_gear_config.vendor.control_gear_phm = 85; ctrl_gear_config.vendor.control_gear_device_type = GEAR_TYPE_LED_MODULES; ctrl_gear_config.vendor.gtin[0] = 'M'; ctrl_gear_config.vendor.gtin[1] = 'B'; ctrl_gear_config.vendor.gtin[2] = 'S'; ctrl_gear_config.vendor.gtin[3] = '0'; ctrl_gear_config.vendor.gtin[4] = '1'; ctrl_gear_config.vendor.gtin[5] = '7';
ctrl_gear_config.vendor.firmware_ver_major = 0x01; ctrl_gear_config.vendor.firmware_ver_minor = 0x02;
ctrl_gear_config.vendor.identify_number[0] = 0x01; ctrl_gear_config.vendor.identify_number[1] = 0x02; ctrl_gear_config.vendor.identify_number[2] = 0x03; ctrl_gear_config.vendor.identify_number[3] = 0x04; ctrl_gear_config.vendor.identify_number[4] = 0x08; ctrl_gear_config.vendor.identify_number[5] = 0x0A; ctrl_gear_config.vendor.identify_number[6] = 0x12; ctrl_gear_config.vendor.identify_number[7] = 0x12;
ctrl_gear_config.vendor.hw_ver_major = 0x10; ctrl_gear_config.vendor.hw_ver_minor = 0x33;
// callbacks ctrl_gear_config.callbacks.fPAppReady = dali_ready_callback; ctrl_gear_config.callbacks.fPAppSend = dali_send_callback; ctrl_gear_config.callbacks.fPAppLoadMem = dali_loadmemory_callback; ctrl_gear_config.callbacks.fPAppSaveMem = dali_savememory_callback; ctrl_gear_config.callbacks.fPAppReAction = dali_reaction_callback;
/* LED vendor parameters */ ctrl_gear_config.vendor.led_params.min_fast_fade_time = 1;
// no address, shall be set to 0xFF ctrl_gear_config.vendor.shortAddress = 0x03;}
/*********************************************************************************************************************//* application function/* Here only the example call of the action functions is displayed./* The application should decide when the action functions should be called**********************************************************************************************************************/void app_action(void){ // if a hardware error occurs, the application must notify the stack action.actionType = DALILIB_CTRL_GEAR_ACTION; action.gearAct.gearActionType = DALILIB_ACT_TYPE_INTERNAL_CTRL_GEAR; action.gearAct.action.internalAction = DALILIB_ACT_INTERNAL_CTRL_GEAR_SET_GEAR_FAILURE; action.gearAct.value.actionValue = 1; // 1: error, 0: no error
dalilib_action(pDaliStackInstance, &action);
// if a led error occurs, the application must notify the stack action.actionType = DALILIB_CTRL_GEAR_ACTION; action.gearAct.gearActionType = DALILIB_ACT_TYPE_INTERNAL_CTRL_GEAR; action.gearAct.action.internalAction = DALILIB_ACT_INTERNAL_CTRL_GEAR_SET_LAMPFAILURE; action.gearAct.value.actionValue = 1; // 1: error, 0: no error
dalilib_action(pDaliStackInstance, &action);
// if a led actual level changed, the application can notify the stack action.actionType = DALILIB_CTRL_GEAR_ACTION; action.gearAct.gearActionType = DALILIB_ACT_TYPE_INTERNAL_CTRL_GEAR; action.gearAct.action.internalAction = DALILIB_ACT_INTERNAL_CTRL_GEAR_SET_ACTUAL_LEVEL; action.gearAct.value.actionValue = 85500; // 85,50 % = 85,50 * 1000
dalilib_action(pDaliStackInstance, &action);}
www.cslab.de 59
/*********************************************************************************************************************//* timer ever 20ms**********************************************************************************************************************/static void timer_callback(void){ static uint32_t time_ticker = 0;
time_ticker += 200;
// DALI stack time ticker must have the resolution 100us dalilib_timingHelper(pDaliStackInstance, time_ticker);}
/*******************************************************************************************************************//* This threads wraps the application with the HAL driver and the DALI stack **********************************************************************************************************************/void dali_thread_entry(vodi){ dalilib_frame_t dalilib_frame; hal_driver_frame frame;
// TODO // HAL driver start // create a timer // dalilib_timingHelper must called ever 20 ms
// create new DALI stack instance pDaliStackInstance = dalilib_createinstance(); if (NULL == pDaliStackInstance) { // error return; }
// create DALI stack config dali_create_gear_config();
// initialize DALI stack instance if (R_DALILIB_OK != dalilib_init(pDaliStackInstance , &ctrl_gear_config)) { // error return; }
// start DALI stack instance if (R_DALILIB_OK != dalilib_start(pDaliStackInstance)) { // error return; }
// loop whie(1) {
// check HAL driver receive buffer or message queue // if a new frame received, convert it and send to DALI stack
frame = get_new_frame();
if (bDaliStackReady) { dalilib_frame = map2daliframe(frame); dalilib_receive(pDaliStackInstance, &dalilib_frame); } }
}
Control device exampleDescription
Here, the DALI stack instance is implemented as an single master application controller (control device).And the communication between the DALI stack and the application is shown.
www.cslab.de 60
/***********************************************************************************************************************/* include DALI stack header file***********************************************************************************************************************/
#include "libdali.h"
static dalilib_instance_t pDaliStackInstance = NULL;static dalilib_cfg_t ctrl_device_config;static uint8_t bDaliStackReady = 0;
static dalilib_action_t action;
/*********************************************************************************************************************//* DALI stack callback functions**********************************************************************************************************************//********************************************************************************************************************//* will be called by the DALI library if it wants to send a DALI message to the driver* result: 0: success **********************************************************************************************************************/static uint8_t dali_send_callback(void * p_context, dalilib_frame_t* p_frame){ uint8_t result; hal_driver_frame frame; // TODO // convert DALI stack format to HAL driver frame format
// forward frame to the HAL driver result = hal_drivre_send_frame(&frame);
return result;}
/*******************************************************************************************************************//* invoked by the DALI stack to notify the application that is ready to receive the actions********************************************************************************************************************/static void dali_ready_callback(void){ bDaliStackReady = 1;}
/*******************************************************************************************************************//* will be called by the DALI stack to tell the application shall load the persistent variables
**********************************************************************************************************************/static uint8_t dali_loadmemory_callback(void* pMemory, uint8_t nSize){ uint8_t err = 0; //SUCCESS switch(stack_config0.mode) { case STACK_MODE_CONTROL_GEAR: err = flash_read(pMemory, nSize, 0); break; case STACK_MODE_CONTROL_DEVICE: err = flash_read(pMemory, nSize, 1); break; } return (err);}
www.cslab.de 61
/*******************************************************************************************************************//* will be called by the DALI library to tell the application shall save the persistent variables**********************************************************************************************************************/static uint8_t dali_savememory_callback(void* pMemory, uint8_t nSize){ uint8_t err = 0; //SUCCESS switch(stack_config0.mode) { case STACK_MODE_CONTROL_GEAR: err = flash_write(pMemory, nSize, 0); break; case STACK_MODE_CONTROL_DEVICE: err = flash_write(pMemory, nSize, 1); break; } return (err);}
/*******************************************************************************************************************//* will be called by the DALI library to notify the application about 'something'**********************************************************************************************************************/static uint8_t dali_gear_reaction_callback(dalilib_react_ctrl_gear_t * p_args){ switch(p_args->reactionCode) { case DALILIB_REACT_CTRL_GEAR_QUERIES: { // if the actual level is equal to 0 of the control gear with the short address 0x05
if (0 == p_args->reactValue && DALILIB_RESPONSE_VALUE_VALID == p_args->valueType) { // action step 2 // application controller wants to set the actual level of the control gear with short address // 0x05 to maximum level action.actionType = DALILIB_CTRL_GEAR_ACTION action.gearAct.adr.adr = 0x05; // control gear short address 0x05 action.gearAct.adr.adrType = DALI_ADRTYPE_SHORT; action.gearAct.gearActionType = DALILIB_ACT_TYPE_CTRL_GEAR_LEVEL; action.gearAct.action.levelAction = DALILIB_ACT_CTRL_GEAR_LEVEL_RECALL_MAX_LEVEL;
dalilib_action(pDaliStackInstance, &action); } } break;
}
return (0);
}
/*******************************************************************************************************************//* will be called by the DALI library to notify the application about 'something'**********************************************************************************************************************/static uint8_t dali_reaction_callback(dalilib_action_t * p_args){ uint8_t res = 0; switch(p_args->actionType) { case DALILIB_CTRL_GEAR_REACTION: res = daliwrapper_gear_reaction_callback(&p_args->gearReact); break;
default: res = 0xFF; //unsupported reaction type break; }
return (res);}
www.cslab.de 62
/*********************************************************************************************************************//* DALI stack configuration struct will be initialized**********************************************************************************************************************/static void dali_create_device_config(void){ memset(ctrl_device_config, 0, sizeof(ctrl_device_config));
// stack mode ctrl_device_config.mode = STACK_MODE_CONTROL_DEVICE; ctrl_device_config.vendor.control_device_mode = CTRL_DEV_MODE_SINGLE;
// vendor information ctrl_device_config.vendor.gtin[0] = 'M'; ctrl_device_config.vendor.gtin[1] = 'B'; ctrl_device_config.vendor.gtin[2] = 'S'; ctrl_device_config.vendor.gtin[3] = '0'; ctrl_device_config.vendor.gtin[4] = '1'; ctrl_device_config.vendor.gtin[5] = '7';
ctrl_device_config.vendor.firmware_ver_major = 0x01; ctrl_device_config.vendor.firmware_ver_minor = 0x02;
ctrl_device_config.vendor.identify_number[0] = 0x01; ctrl_device_config.vendor.identify_number[1] = 0x02; ctrl_device_config.vendor.identify_number[2] = 0x03; ctrl_device_config.vendor.identify_number[3] = 0x04; ctrl_device_config.vendor.identify_number[4] = 0x08; ctrl_device_config.vendor.identify_number[5] = 0x0A; ctrl_device_config.vendor.identify_number[6] = 0x12; ctrl_device_config.vendor.identify_number[7] = 0x12;
ctrl_device_config.vendor.hw_ver_major = 0x10; ctrl_device_config.vendor.hw_ver_minor = 0x33;
// callbacks ctrl_device_config.callbacks.fPAppReady = dali_ready_callback; ctrl_device_config.callbacks.fPAppSend = dali_send_callback; ctrl_device_config.callbacks.fPAppLoadMem = dali_loadmemory_callback; ctrl_device_config.callbacks.fPAppSaveMem = dali_savememory_callback; ctrl_device_config.callbacks.fPAppReAction = dali_reaction_callback;
// control device information ctrl_device_config.vendor.control_device_instance_type = INPUT_DEVICE_INST_0; ctrl_device_config.vendor.control_device_instance_number = 0;
// no address, shall be set to 0xFF ctrl_device_config.vendor.shortAddress = 0x03;}
/*********************************************************************************************************************//* application function/* Here only the example call of the action functions is displayed./* The application should decide when the action functions should be called**********************************************************************************************************************/void app_action(void){
// action step 1
// application controller wants to query the actual level of the control gear with short address // 0x05 action.actionType = DALILIB_CTRL_GEAR_ACTION
action.gearAct.adr.adr = 0x05; // control gear short address 0x05 action.gearAct.adr.adrType = DALI_ADRTYPE_SHORT; action.gearAct.gearActionType = DALILIB_ACT_TYPE_CTRL_GEAR_QUERIES; action.gearAct.action.queriesAction = DALILIB_ACT_CTRL_GEAR_QUERY_ACTUAL_LEVEL;
dalilib_action(pDaliStackInstance, &action);
}
/*********************************************************************************************************************//* timer ever 20ms**********************************************************************************************************************/static void timer_callback(void){ static uint32_t time_ticker = 0;
www.cslab.de 63
time_ticker += 200;
// DALI stack time ticker must have the resolution 100us dalilib_timingHelper(pDaliStackInstance, time_ticker);}
/*******************************************************************************************************************//* This threads wraps the application with the HAL driver and the DALI stack **********************************************************************************************************************/void dali_thread_entry(vodi){ dalilib_frame_t dalilib_frame; hal_driver_frame frame;
// TODO // HAL driver start // create a timer // dalilib_timingHelper must called ever 20 ms
// create new DALI stack instance pDaliStackInstance = dalilib_createinstance(); if (NULL == pDaliStackInstance) { // error return; }
// create DALI stack config dali_create_device_config();
// initialize DALI stack instance if (R_DALILIB_OK != dalilib_init(pDaliStackInstance , &ctrl_device_config)) { // error return; }
// start DALI stack instance if (R_DALILIB_OK != dalilib_start(pDaliStackInstance)) { // error return; }
// loop whie(1) {
// check HAL driver receive buffer or message queue // if a new frame received, convert it and send to DALI stack
frame = get_new_frame();
if (bDaliStackReady) { dalilib_frame = map2daliframe(frame); dalilib_receive(pDaliStackInstance, &dalilib_frame); } }
}
www.cslab.de 64