An initial port to the FRDM-K46Z based on the the following: https://developer.mbed.org/users/okini3939/notebook/dmx512/
Fork of DMX by
DMX.h
00001 /* 00002 * DMX512 send/recv library 00003 * Copyright (c) 2013 Hiroshi Suga 00004 * Released under the MIT License: http://mbed.org/license/mit 00005 */ 00006 00007 /** @file 00008 * @brief DMX512 send/recv 00009 */ 00010 00011 00012 00013 #ifndef DMX_H 00014 #define DMX_H 00015 00016 #include "mbed.h" 00017 #include "RawSerial.h" 00018 00019 00020 #define DMX_UART_DIRECT 00021 00022 #define DMX_SIZE 512 00023 #define DMX_TIME_BREAK 100 // 100us (88us-1s) 00024 #define DMX_TIME_MAB 10 // 10us (8us-1s) 00025 #define DMX_TIME_BETWEEN 200 // 10us (0-1s) 00026 #define DMX_START_CODE 0 00027 00028 enum DMX_MODE { 00029 DMX_MODE_BEGIN, 00030 DMX_MODE_START, 00031 DMX_MODE_BREAK, 00032 DMX_MODE_MAB, 00033 DMX_MODE_DATA, 00034 DMX_MODE_ERROR, 00035 DMX_MODE_STOP, 00036 }; 00037 00038 /** DMX512 class (sender/client) 00039 */ 00040 class DMX { 00041 public: 00042 /** init DMX class 00043 * @param p_tx TX serial port (p9, p13, p28) 00044 * @param p_rx RX serial port (p10, p14, p27) 00045 */ 00046 DMX (PinName p_tx, PinName p_rx); 00047 00048 /** Send the data 00049 * @param addr DMX data address (0-511) 00050 * @param data DMX data (0-255) 00051 */ 00052 void put (int addr, int data); 00053 /** Send the data 00054 * @param buf DMX data buffer 00055 * @param addr DMX data address 00056 * @param len data length 00057 */ 00058 void put (unsigned char *buf, int addr = 0, int len = DMX_SIZE); 00059 00060 /** Send the data 00061 * @param addr DMX data address (0-511) 00062 * @return DMX data (0-255) 00063 */ 00064 int get (int addr); 00065 /** Send the data 00066 * @param buf DMX data buffer 00067 * @param addr DMX data address 00068 * @param len data length 00069 */ 00070 void get (unsigned char *buf, int addr = 0, int len = DMX_SIZE); 00071 00072 /** Start DMX send operation 00073 */ 00074 void start (); 00075 /** Stop DMX send operation 00076 */ 00077 void stop (); 00078 /** Clear DMX data 00079 */ 00080 void clear (); 00081 00082 /** Get the receiver Mode 00083 */ 00084 int get_mode_rx(){return mode_rx;} 00085 00086 volatile int is_recived, is_sent; 00087 00088 protected: 00089 00090 void int_timer (); 00091 void int_tx (); 00092 void int_rx (); 00093 00094 // Serial _dmx; 00095 RawSerial _dmx; 00096 Timeout timeout01; 00097 volatile DMX_MODE mode_tx, mode_rx; 00098 volatile int addr_tx, addr_rx; 00099 unsigned char data_tx[DMX_SIZE]; 00100 unsigned char data_rx[DMX_SIZE]; 00101 00102 private: 00103 00104 #if defined(TARGET_LPC1768) || defined(TARGET_LPC2368) || defined(TARGET_LPC4088) 00105 LPC_UART_TypeDef *_uart; 00106 #elif defined(TARGET_LPC11UXX) 00107 LPC_USART_Type *_uart; 00108 #elif defined(TARGET_LPC11XX) 00109 LPC_UART_TypeDef *_uart; 00110 #elif defined(TARGET_KL46Z) 00111 /** 00112 The UART type changes for the Freescale KL46Z 00113 */ 00114 UARTLP_Type *_uart; 00115 #else 00116 #error "this CPU not supported." 00117 #endif 00118 00119 }; 00120 00121 #endif
Generated on Sun Jul 24 2022 00:08:43 by 1.7.2