DALI send/recv library.
DALI send/recv library
lighting control protocol.
設備照明の調光プロトコル DALI を送受信するライブラリです。
DALI インターフェースの回路図などは次を参照。
- http://ww1.microchip.com/downloads/jp/AppNotes/01465A_JP.pdf
- https://www.mouser.com/pdfdocs/AN11174.pdf
Diff: DALI.h
- Revision:
- 1:319d52b5116b
- Parent:
- 0:6cb7026982fc
--- a/DALI.h Wed Jul 22 03:04:04 2020 +0000 +++ b/DALI.h Mon Jul 27 05:53:55 2020 +0000 @@ -16,20 +16,51 @@ class DALI { public: enum DALI_FRAME { - DALI_FORWARD_SHORT_DAP, - DALI_FORWARD_SHORT_IAP, - DALI_FORWARD_GROUP_DAP, - DALI_FORWARD_GROUP_IAP, - DALI_BACKWARD, + FORWARD_SHORT_DAP, // DIRECT ARC POWER + FORWARD_SHORT_IAP, // COMMAND + FORWARD_GROUP_DAP, + FORWARD_GROUP_IAP, + BACKWARD, + }; + + enum DALI_COMMAND { + OFF = 0x00, + UP = 0x01, + DOWN = 0x02, + STEP_UP = 0x03, + STEP_DOWN = 0x04, + RECALL_MAX_LEVEL = 0x05, + RECALL_MIN_LEVEL = 0x06, + STEP_DOWN_AND_OFF = 0x07, + ON_AND_STEP_UP = 0x08, + RESET = 0x20, + QUERY_STATUS = 0x90, }; + /** init DALI class + * @param tx TX port + * @param rx RX port (interrupt) + */ DALI (PinName tx, PinName rx); + /** Recv the data + * @param frame enum DALI_FRAME + * @param addr DALI address (short:0-63, group:0-15,63 broadcast) + * @param value DALI value + */ int read (enum DALI_FRAME *frame, int *addr, int *value); + int readable (); + /** Send the data + * @param frame enum DALI_FRAME + * @param addr DALI address (short:0-63, group:0-15,63 broadcast) + * @param value DALI value + */ int write (enum DALI_FRAME frame, int addr, int value); + int writable (); + private: InterruptIn _rx; DigitalOut _tx; @@ -39,7 +70,7 @@ CircBuffer<int> *recv_buf; CircBuffer<int> *send_buf; - int mode; + volatile int mode; int count; int timeflg; int recv_bit; @@ -48,7 +79,7 @@ int send_data; int send_bit; int halfbit; - int busy; + volatile int busy; void isr_rx (); void isr_timer ();