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:
- 0:6cb7026982fc
- Child:
- 1:319d52b5116b
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DALI.h Wed Jul 22 03:04:04 2020 +0000 @@ -0,0 +1,60 @@ +/* + * DALI send/recv library + * Copyright (c) 2020 Hiroshi Suga + * Released under the MIT License: http://mbed.org/license/mit + */ + +/** @file + * @brief DALI send/recv + */ + + #ifndef _DALI_H_ +#define _DALI_H_ + +#include "CBuffer.h" + +class DALI { +public: + enum DALI_FRAME { + DALI_FORWARD_SHORT_DAP, + DALI_FORWARD_SHORT_IAP, + DALI_FORWARD_GROUP_DAP, + DALI_FORWARD_GROUP_IAP, + DALI_BACKWARD, + }; + + DALI (PinName tx, PinName rx); + + int read (enum DALI_FRAME *frame, int *addr, int *value); + int readable (); + + int write (enum DALI_FRAME frame, int addr, int value); + +private: + InterruptIn _rx; + DigitalOut _tx; + Timeout _timer; + Ticker _ticker; + + CircBuffer<int> *recv_buf; + CircBuffer<int> *send_buf; + + int mode; + int count; + int timeflg; + int recv_bit; + int recv_data; + + int send_data; + int send_bit; + int halfbit; + int busy; + + void isr_rx (); + void isr_timer (); + void isr_timeout (); + void isr_send (); + +}; + +#endif