Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: DISCO-F746NG_DMX-Test
Fork of DMX by
Diff: DMX.h
- Revision:
- 17:b87addd12d20
- Parent:
- 15:4ea4a31c7609
- Child:
- 18:e5e5eca21b4a
--- a/DMX.h Thu Aug 20 09:21:28 2015 +0000
+++ b/DMX.h Sat Dec 12 13:16:07 2015 +0000
@@ -14,15 +14,15 @@
#include "mbed.h"
#include "RawSerial.h"
-#define DMX_UART_DIRECT
+//#define DMX_UART_DIRECT
-#define DMX_SIZE 512
#define DMX_TIME_BREAK 100 // 100us (88us-1s)
#define DMX_TIME_MAB 10 // 10us (8us-1s)
#define DMX_TIME_BETWEEN 200 // 10us (0-1s)
#define DMX_START_CODE 0
-enum DMX_MODE {
+enum DMX_MODE
+{
DMX_MODE_BEGIN,
DMX_MODE_START,
DMX_MODE_BREAK,
@@ -34,75 +34,82 @@
/** DMX512 class (sender/client)
*/
-class DMX {
+class DMX
+{
public:
/** init DMX class
- * @param p_tx TX serial port (p9, p13, p28)
- * @param p_rx RX serial port (p10, p14, p27)
+ * @param p_tx TX serial port (PC_2, PA_2)
+ * @param p_rx RX serial port (PC_2, PA_2)
+ * @param size dmx size, default = 512
*/
- DMX (PinName p_tx, PinName p_rx);
+ DMX(PinName p_tx, PinName p_rx, unsigned int size = 512);
+ ~DMX();
/** Send the data
* @param addr DMX data address (0-511)
* @param data DMX data (0-255)
*/
- void put (int addr, int data);
+ void put(int addr, int data);
/** Send the data
* @param buf DMX data buffer
* @param addr DMX data address
* @param len data length
*/
- void put (unsigned char *buf, int addr = 0, int len = DMX_SIZE);
+ void put(unsigned char *buf, int addr = 0, int len = 0);
/** Send the data
* @param addr DMX data address (0-511)
* @return DMX data (0-255)
*/
- int get (int addr);
+ int get(int addr);
/** Send the data
* @param buf DMX data buffer
* @param addr DMX data address
* @param len data length
*/
- void get (unsigned char *buf, int addr = 0, int len = DMX_SIZE);
+ void get(unsigned char *buf, int addr = 0, int len = 0);
/** Start DMX send operation
*/
- void start ();
+ void start();
/** Stop DMX send operation
*/
- void stop ();
+ void stop();
/** Clear DMX data
*/
- void clear ();
+ void clear();
- volatile int is_recived, is_sent;
+ volatile int is_recived;
+ volatile int is_sent;
protected:
- void int_timer ();
- void int_tx ();
- void int_rx ();
+ void int_timer();
+ void int_tx();
+ void int_rx();
// Serial _dmx;
RawSerial _dmx;
Timeout timeout01;
- 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];
+ volatile DMX_MODE mode_tx;
+ volatile DMX_MODE mode_rx;
+ volatile int addr_tx;
+ volatile int addr_rx;
+ char *data_tx;
+ char *data_rx;
private:
-#if defined(TARGET_LPC1768) || defined(TARGET_LPC2368) || defined(TARGET_LPC4088)
- LPC_UART_TypeDef *_uart;
-#elif defined(TARGET_LPC11UXX)
- LPC_USART_Type *_uart;
-#elif defined(TARGET_LPC11XX)
- LPC_UART_TypeDef *_uart;
-#else
-#error "this CPU not supported."
-#endif
-
+ unsigned int myDMXSize;
+ // struct recreated from LPC port -> must be converted to STM32 port
+ typedef struct
+ {
+ uint8_t LCR; // ?
+ uint8_t LSR; // flg
+ uint8_t RBR; // read port
+ uint8_t THR; // ?
+ }DUMMY_UART_TypeDef;
+
+ DUMMY_UART_TypeDef *_uart;
};
#endif
\ No newline at end of file
