DMX512 send/recv library with STM32 slave support originally from http://mbed.org/users/okini3939/notebook/dmx512
Fork of DMX by
Diff: DMX.cpp
- Revision:
- 4:dd0544c80096
- Parent:
- 3:2eb66b4d99bd
- Child:
- 5:72039cd4c874
--- a/DMX.cpp Fri Sep 28 03:31:02 2012 +0000 +++ b/DMX.cpp Wed Nov 21 01:44:21 2012 +0000 @@ -18,7 +18,8 @@ data_tx[i] = 0; data_rx[i] = 0; } - mode_tx = DMX_MODE_BEGIN; +// mode_tx = DMX_MODE_BEGIN; + mode_tx = DMX_MODE_STOP; mode_rx = DMX_MODE_BEGIN; is_recived = 0; is_sent = 0; @@ -55,7 +56,7 @@ dmx.format(8, Serial::None, 2); dmx.attach(this, &DMX::int_rx, Serial::RxIrq); - timeout01.attach_us(this, &DMX::int_timer, DMX_TIME_BETWEEN); +// timeout01.attach_us(this, &DMX::int_timer, DMX_TIME_BETWEEN); } void DMX::put (int ch, int data) { @@ -162,12 +163,16 @@ } } -void DMX::reset () { +void DMX::start () { + if (mode_tx == DMX_MODE_STOP) { + mode_tx = DMX_MODE_BEGIN; + is_sent = 0; + timeout01.attach_us(this, &DMX::int_timer, DMX_TIME_BETWEEN); + } +} + +void DMX::stop () { dmx.attach(0, Serial::TxIrq); timeout01.detach(); - mode_tx = DMX_MODE_BEGIN; -// mode_rx = DMX_MODE_BEGIN; -// is_recived = 0; - is_sent = 0; - timeout01.attach_us(this, &DMX::int_timer, DMX_TIME_BETWEEN); + mode_tx = DMX_MODE_STOP; }