DMX512, RDM send/recv library http://mbed.org/users/okini3939/notebook/dmx512

Dependents:   dmx_test ArtNodeLED SPK-DVIMXR SPK-DMXer ... more

DMX512 send/recv library

DMX512 is protocol for lighting.

調光プロトコル DMX512 を送受信するライブラリです。

see: http://mbed.org/users/okini3939/notebook/dmx512/

LPC1114 support is thanks to Stanly Chen

Revision:
0:cbff6bf41542
Child:
1:f0d988e15810
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DMX.h	Tue Jun 26 08:29:33 2012 +0000
@@ -0,0 +1,77 @@
+/*
+ * DMX512 send/recv library
+ * Copyright (c) 2011 Hiroshi Suga
+ * Released under the MIT License: http://mbed.org/license/mit
+ */
+
+/** @file DMX.h
+ * @brief DMX512 send/recv
+ */
+ 
+#ifndef DMX_H
+#define DMX_H
+
+#include "mbed.h"
+
+#define DMX_DIRECT
+
+#define DMX_SIZE 512
+#define DMX_TIME_BREAK 100 // 100us
+#define DMX_TIME_MAB 10 // 10us
+#define DMX_TIME_BETWEEN 10 // 10us
+
+enum DMX_MODE {
+    DMX_MODE_BEGIN,
+    DMX_MODE_START,
+    DMX_MODE_BREAK,
+    DMX_MODE_MAB,
+    DMX_MODE_DATA,
+    DMX_MODE_ERROR,
+};
+
+/** DMX512 class (sender/client)
+ */
+class DMX {
+public:
+    /** init DMX class
+     * @param p_tx TX serial port (p9, p13, p28)
+     * @param p_rx RX serial port (p10, p14, p27)
+     */
+    DMX (PinName p_tx, PinName p_rx); 
+
+    /** Send the message
+     * @param ch DMX data address (0-511)
+     * @param data DMX data (0-255)
+     */
+    void put (int ch, int data);
+
+    /** Send the message
+     * @param ch DMX data address (0-511)
+     * @return DMX data (0-255)
+     */
+    int get (int ch);
+
+    volatile int is_recived, is_sent;
+
+protected:
+
+    void int_timer ();
+    void int_tx ();
+    void int_rx ();
+
+    Serial dmx;
+    Timeout timeout01;
+    __IO uint8_t *uart_lcr;
+    __I  uint8_t *uart_lsr;
+    __IO uint8_t *uart_thr;
+    __I  uint8_t *uart_rbr;
+    volatile DMX_MODE mode_tx, mode_rx;
+    volatile int addr_tx, addr_rx;
+    unsigned char data_tx[DMX_SIZE];
+    unsigned char data_rx[DMX_SIZE];
+
+private:
+
+};
+
+#endif
\ No newline at end of file