Browse Source

[2.0.x] Enable hardware serial ports on LPC1768 (#8004)

* Enable hardware serial ports on LPC1768

* Fix compilation errors with other HALs

* FIx order of includes in LPC1768 HAL main.cpp

* Add support for RX_BUFFER_SIZE and TX_BUFFER_SIZE options in Configuration_adv.h
Thomas Moore 6 years ago
parent
commit
51fafccc16

+ 3
- 24
Marlin/src/HAL/HAL_AVR/MarlinSerial.h View File

@@ -78,30 +78,9 @@
78 78
 #define BYTE 0
79 79
 
80 80
 #ifndef USBCON
81
-  // Define constants and variables for buffering incoming serial data.  We're
82
-  // using a ring buffer (I think), in which rx_buffer_head is the index of the
83
-  // location to which to write the next incoming character and rx_buffer_tail
84
-  // is the index of the location from which to read.
85
-  // 256 is the max limit due to uint8_t head and tail. Use only powers of 2. (...,16,32,64,128,256)
86
-  #ifndef RX_BUFFER_SIZE
87
-    #define RX_BUFFER_SIZE 128
88
-  #endif
89
-  #ifndef TX_BUFFER_SIZE
90
-    #define TX_BUFFER_SIZE 32
91
-  #endif
92
-
93
-  #if ENABLED(SERIAL_XON_XOFF) && RX_BUFFER_SIZE < 1024
94
-    #error "XON/XOFF requires RX_BUFFER_SIZE >= 1024 for reliable transfers without drops."
95
-  #endif
96
-
97
-  #if !IS_POWER_OF_2(RX_BUFFER_SIZE) || RX_BUFFER_SIZE < 2
98
-    #error "RX_BUFFER_SIZE must be a power of 2 greater than 1."
99
-  #endif
100
-
101
-  #if TX_BUFFER_SIZE && (TX_BUFFER_SIZE < 2 || TX_BUFFER_SIZE > 256 || !IS_POWER_OF_2(TX_BUFFER_SIZE))
102
-    #error "TX_BUFFER_SIZE must be 0 or a power of 2 greater than 1."
103
-  #endif
104
-
81
+  // We're using a ring buffer (I think), in which rx_buffer_head is the index of the
82
+  // location to which to write the next incoming character and rx_buffer_tail is the
83
+  // index of the location from which to read.
105 84
   #if RX_BUFFER_SIZE > 256
106 85
     typedef uint16_t ring_buffer_pos_t;
107 86
   #else

+ 3
- 6
Marlin/src/HAL/HAL_LPC1768/HAL.cpp View File

@@ -20,10 +20,7 @@
20 20
 
21 21
 #ifdef TARGET_LPC1768
22 22
 
23
-#include "../../core/macros.h"
24
-#include "../HAL.h"
25
-
26
-#include <stdint.h>
23
+#include "../../inc/MarlinConfig.h"
27 24
 
28 25
 extern "C" {
29 26
   //#include <lpc17xx_adc.h>
@@ -86,7 +83,7 @@ extern const char errormagic[];
86 83
 
87 84
 void HAL_adc_enable_channel(int pin) {
88 85
   if (!WITHIN(pin, 0, NUM_ANALOG_INPUTS - 1)) {
89
-    usb_serial.printf("%sINVALID ANALOG PORT:%d\n", errormagic, pin);
86
+    MYSERIAL.printf("%sINVALID ANALOG PORT:%d\n", errormagic, pin);
90 87
     kill(MSG_KILLED);
91 88
   }
92 89
 
@@ -116,7 +113,7 @@ void HAL_adc_enable_channel(int pin) {
116 113
 uint8_t active_adc = 0;
117 114
 void HAL_adc_start_conversion(const uint8_t adc_pin) {
118 115
   if (adc_pin >= (NUM_ANALOG_INPUTS) || adc_pin_map[adc_pin].port == 0xFF) {
119
-    usb_serial.printf("HAL: HAL_adc_start_conversion: no pinmap for %d\n", adc_pin);
116
+    MYSERIAL.printf("HAL: HAL_adc_start_conversion: no pinmap for %d\n", adc_pin);
120 117
     return;
121 118
   }
122 119
   LPC_ADC->ADCR &= ~0xFF;                       // Reset

+ 14
- 5
Marlin/src/HAL/HAL_LPC1768/HAL.h View File

@@ -41,9 +41,7 @@ void _printf (const  char *format, ...);
41 41
 void _putc(uint8_t c);
42 42
 uint8_t _getc();
43 43
 
44
-extern volatile uint32_t _millis;
45
-
46
-#define USBCON
44
+extern "C" volatile uint32_t _millis;
47 45
 
48 46
 //arduino: Print.h
49 47
 #define DEC 10
@@ -60,7 +58,7 @@ extern volatile uint32_t _millis;
60 58
 #include "watchdog.h"
61 59
 #include "serial.h"
62 60
 #include "HAL_timers.h"
63
-
61
+#include "HardwareSerial.h"
64 62
 
65 63
 #define ST7920_DELAY_1 DELAY_5_NOP;DELAY_5_NOP;DELAY_5_NOP;DELAY_5_NOP;DELAY_5_NOP;DELAY_5_NOP;DELAY_5_NOP;DELAY_5_NOP;DELAY_5_NOP;DELAY_5_NOP;DELAY_5_NOP;DELAY_5_NOP
66 64
 #define ST7920_DELAY_2 DELAY_5_NOP;DELAY_5_NOP;DELAY_5_NOP;DELAY_5_NOP;DELAY_5_NOP;DELAY_5_NOP;DELAY_5_NOP;DELAY_5_NOP;DELAY_5_NOP;DELAY_5_NOP;DELAY_5_NOP;DELAY_5_NOP;DELAY_5_NOP;DELAY_5_NOP;DELAY_5_NOP
@@ -68,7 +66,18 @@ extern volatile uint32_t _millis;
68 66
 
69 67
 //Serial override
70 68
 extern HalSerial usb_serial;
71
-#define MYSERIAL usb_serial
69
+
70
+#if SERIAL_PORT == -1
71
+  #define MYSERIAL usb_serial
72
+#elif SERIAL_PORT == 0
73
+  #define MYSERIAL Serial
74
+#elif SERIAL_PORT == 1
75
+  #define MYSERIAL Serial1
76
+#elif SERIAL_PORT == 2
77
+  #define MYSERIAL Serial2
78
+#elif SERIAL_PORT == 3
79
+  #define MYSERIAL Serial3
80
+#endif
72 81
 
73 82
 #define CRITICAL_SECTION_START  uint32_t primask = __get_PRIMASK(); __disable_irq();
74 83
 #define CRITICAL_SECTION_END    if (!primask) __enable_irq();

+ 1
- 1
Marlin/src/HAL/HAL_LPC1768/HAL_timers.cpp View File

@@ -28,7 +28,7 @@
28 28
 
29 29
 #ifdef TARGET_LPC1768
30 30
 
31
-#include "../HAL.h"
31
+#include "../../inc/MarlinConfig.h"
32 32
 #include "HAL_timers.h"
33 33
 
34 34
 void HAL_timer_init(void) {

+ 264
- 535
Marlin/src/HAL/HAL_LPC1768/HardwareSerial.cpp View File

@@ -22,391 +22,297 @@
22 22
 
23 23
 #ifdef TARGET_LPC1768
24 24
 
25
-#include "../../core/macros.h"
26
-#include "../HAL.h"
25
+#include "../../inc/MarlinConfig.h"
27 26
 #include "HardwareSerial.h"
28
-#define UART3 3
29
-HardwareSerial Serial3 = HardwareSerial(UART3);
30
-
31
-volatile uint32_t UART0Status, UART1Status, UART2Status, UART3Status;
32
-volatile uint8_t UART0TxEmpty = 1, UART1TxEmpty = 1, UART2TxEmpty=1, UART3TxEmpty=1;
33
-volatile uint8_t UART0Buffer[UARTRXQUEUESIZE], UART1Buffer[UARTRXQUEUESIZE], UART2Buffer[UARTRXQUEUESIZE], UART3Buffer[UARTRXQUEUESIZE];
34
-volatile uint32_t UART0RxQueueWritePos = 0, UART1RxQueueWritePos = 0, UART2RxQueueWritePos = 0, UART3RxQueueWritePos = 0;
35
-volatile uint32_t UART0RxQueueReadPos = 0, UART1RxQueueReadPos = 0, UART2RxQueueReadPos = 0, UART3RxQueueReadPos = 0;
36
-volatile uint8_t dummy;
37
-
38
-  void HardwareSerial::begin(uint32_t baudrate) {
39
-    uint32_t Fdiv;
40
-     uint32_t pclkdiv, pclk;
41
-
42
-     if ( PortNum == 0 )
43
-     {
44
-   	LPC_PINCON->PINSEL0 &= ~0x000000F0;
45
-   	LPC_PINCON->PINSEL0 |= 0x00000050;  /* RxD0 is P0.3 and TxD0 is P0.2 */
46
-   	/* By default, the PCLKSELx value is zero, thus, the PCLK for
47
-   	all the peripherals is 1/4 of the SystemFrequency. */
48
-   	/* Bit 6~7 is for UART0 */
49
-   	pclkdiv = (LPC_SC->PCLKSEL0 >> 6) & 0x03;
50
-   	switch ( pclkdiv )
51
-   	{
52
-   	  case 0x00:
53
-   	  default:
54
-   		pclk = SystemCoreClock/4;
55
-   		break;
56
-   	  case 0x01:
57
-   		pclk = SystemCoreClock;
58
-   		break;
59
-   	  case 0x02:
60
-   		pclk = SystemCoreClock/2;
61
-   		break;
62
-   	  case 0x03:
63
-   		pclk = SystemCoreClock/8;
64
-   		break;
65
-   	}
66
-
67
-       LPC_UART0->LCR = 0x83;		/* 8 bits, no Parity, 1 Stop bit */
68
-   	Fdiv = ( pclk / 16 ) / baudrate ;	/*baud rate */
69
-       LPC_UART0->DLM = Fdiv / 256;
70
-       LPC_UART0->DLL = Fdiv % 256;
71
-   	LPC_UART0->LCR = 0x03;		/* DLAB = 0 */
72
-       LPC_UART0->FCR = 0x07;		/* Enable and reset TX and RX FIFO. */
73
-
74
-      	NVIC_EnableIRQ(UART0_IRQn);
75
-
76
-       LPC_UART0->IER = IER_RBR | IER_THRE | IER_RLS;	/* Enable UART0 interrupt */
77
-     }
78
-     else if ( PortNum == 1 )
79
-     {
80
-   	LPC_PINCON->PINSEL4 &= ~0x0000000F;
81
-   	LPC_PINCON->PINSEL4 |= 0x0000000A;	/* Enable RxD1 P2.1, TxD1 P2.0 */
82
-
83
-   	/* By default, the PCLKSELx value is zero, thus, the PCLK for
84
-   	all the peripherals is 1/4 of the SystemFrequency. */
85
-   	/* Bit 8,9 are for UART1 */
86
-   	pclkdiv = (LPC_SC->PCLKSEL0 >> 8) & 0x03;
87
-   	switch ( pclkdiv )
88
-   	{
89
-   	  case 0x00:
90
-   	  default:
91
-   		pclk = SystemCoreClock/4;
92
-   		break;
93
-   	  case 0x01:
94
-   		pclk = SystemCoreClock;
95
-   		break;
96
-   	  case 0x02:
97
-   		pclk = SystemCoreClock/2;
98
-   		break;
99
-   	  case 0x03:
100
-   		pclk = SystemCoreClock/8;
101
-   		break;
102
-   	}
103
-
104
-       LPC_UART1->LCR = 0x83;		/* 8 bits, no Parity, 1 Stop bit */
105
-   	Fdiv = ( pclk / 16 ) / baudrate ;	/*baud rate */
106
-       LPC_UART1->DLM = Fdiv / 256;
107
-       LPC_UART1->DLL = Fdiv % 256;
108
-   	LPC_UART1->LCR = 0x03;		/* DLAB = 0 */
109
-       LPC_UART1->FCR = 0x07;		/* Enable and reset TX and RX FIFO. */
110
-
111
-      	NVIC_EnableIRQ(UART1_IRQn);
112
-
113
-       LPC_UART1->IER = IER_RBR | IER_THRE | IER_RLS;	/* Enable UART1 interrupt */
114
-     }
115
-     else if ( PortNum == 2 )
116
-     {
117
-   	  //LPC_PINCON->PINSEL4 &= ~0x000F0000;  /*Pinsel4 Bits 16-19*/
118
-   	  //LPC_PINCON->PINSEL4 |=  0x000A0000;  /* RxD2 is P2.9 and TxD2 is P2.8, value 10*/
119
-   	  LPC_PINCON->PINSEL0 &= ~0x00F00000;  /*Pinsel0 Bits 20-23*/
120
-   	  LPC_PINCON->PINSEL0 |=  0x00500000;  /* RxD2 is P0.11 and TxD2 is P0.10, value 01*/
121
-
122
-   	  LPC_SC->PCONP |= 1<<24; //Enable PCUART2
123
-   	  /* By default, the PCLKSELx value is zero, thus, the PCLK for
124
-   		all the peripherals is 1/4 of the SystemFrequency. */
125
-   	  /* Bit 6~7 is for UART3 */
126
-   	  pclkdiv = (LPC_SC->PCLKSEL1 >> 16) & 0x03;
127
-   	  switch ( pclkdiv )
128
-   	  {
129
-   	  case 0x00:
130
-   	  default:
131
-   		  pclk = SystemCoreClock/4;
132
-   		  break;
133
-   	  case 0x01:
134
-   		  pclk = SystemCoreClock;
135
-   		  break;
136
-   	  case 0x02:
137
-   		  pclk = SystemCoreClock/2;
138
-   		  break;
139
-   	  case 0x03:
140
-   		  pclk = SystemCoreClock/8;
141
-   		  break;
142
-   	  }
143
-   	  LPC_UART2->LCR = 0x83;		/* 8 bits, no Parity, 1 Stop bit */
144
-   	  Fdiv = ( pclk / 16 ) / baudrate ;	/*baud rate */
145
-   	  LPC_UART2->DLM = Fdiv / 256;
146
-   	  LPC_UART2->DLL = Fdiv % 256;
147
-   	  LPC_UART2->LCR = 0x03;		/* DLAB = 0 */
148
-   	  LPC_UART2->FCR = 0x07;		/* Enable and reset TX and RX FIFO. */
149
-
150
-   	  NVIC_EnableIRQ(UART2_IRQn);
151
-
152
-   	  LPC_UART2->IER = IER_RBR | IER_THRE | IER_RLS;	/* Enable UART3 interrupt */
153
-     }
154
-     else if ( PortNum == 3 )
155
-     {
156
-   	  LPC_PINCON->PINSEL0 &= ~0x0000000F;
157
-   	  LPC_PINCON->PINSEL0 |=  0x0000000A;  /* RxD3 is P0.1 and TxD3 is P0.0 */
158
-   	  LPC_SC->PCONP |= 1<<4 | 1<<25; //Enable PCUART1
159
-   	  /* By default, the PCLKSELx value is zero, thus, the PCLK for
160
-   		all the peripherals is 1/4 of the SystemFrequency. */
161
-   	  /* Bit 6~7 is for UART3 */
162
-   	  pclkdiv = (LPC_SC->PCLKSEL1 >> 18) & 0x03;
163
-   	  switch ( pclkdiv )
164
-   	  {
165
-   	  case 0x00:
166
-   	  default:
167
-   		  pclk = SystemCoreClock/4;
168
-   		  break;
169
-   	  case 0x01:
170
-   		  pclk = SystemCoreClock;
171
-   		  break;
172
-   	  case 0x02:
173
-   		  pclk = SystemCoreClock/2;
174
-   		  break;
175
-   	  case 0x03:
176
-   		  pclk = SystemCoreClock/8;
177
-   		  break;
178
-   	  }
179
-   	  LPC_UART3->LCR = 0x83;		/* 8 bits, no Parity, 1 Stop bit */
180
-   	  Fdiv = ( pclk / 16 ) / baudrate ;	/*baud rate */
181
-   	  LPC_UART3->DLM = Fdiv / 256;
182
-   	  LPC_UART3->DLL = Fdiv % 256;
183
-   	  LPC_UART3->LCR = 0x03;		/* DLAB = 0 */
184
-   	  LPC_UART3->FCR = 0x07;		/* Enable and reset TX and RX FIFO. */
185
-
186
-   	  NVIC_EnableIRQ(UART3_IRQn);
187
-
188
-   	  LPC_UART3->IER = IER_RBR | IER_THRE | IER_RLS;	/* Enable UART3 interrupt */
189
-     }
190
-  }
191 27
 
192
-  int HardwareSerial::read() {
193
-    uint8_t rx;
194
-  	if ( PortNum == 0 )
195
-  	  {
196
-  		  if (UART0RxQueueReadPos == UART0RxQueueWritePos)
197
-  		    return -1;
198
-
199
-  		  // Read from "head"
200
-  		  rx = UART0Buffer[UART0RxQueueReadPos]; // grab next byte
201
-  		  UART0RxQueueReadPos = (UART0RxQueueReadPos + 1) % UARTRXQUEUESIZE;
202
-  		  return rx;
203
-  	  }
204
-  	  if ( PortNum == 1 )
205
-  	  {
206
-  		  if (UART1RxQueueReadPos == UART1RxQueueWritePos)
207
-  		    return -1;
208
-
209
-  		  // Read from "head"
210
-  		  rx = UART1Buffer[UART1RxQueueReadPos]; // grab next byte
211
-  		  UART1RxQueueReadPos = (UART1RxQueueReadPos + 1) % UARTRXQUEUESIZE;
212
-  		  return rx;
213
-  	  }
214
-  	  if ( PortNum == 2 )
215
-  	  {
216
-  		  if (UART2RxQueueReadPos == UART2RxQueueWritePos)
217
-  		    return -1;
218
-
219
-  		  // Read from "head"
220
-  		  rx = UART2Buffer[UART2RxQueueReadPos]; // grab next byte
221
-  		  UART2RxQueueReadPos = (UART2RxQueueReadPos + 1) % UARTRXQUEUESIZE;
222
-  		  return rx;
223
-  	  }
224
-  	  if ( PortNum == 3 )
225
-  	  {
226
-  		  if (UART3RxQueueReadPos == UART3RxQueueWritePos)
227
-  		    return -1;
228
-
229
-  		  // Read from "head"
230
-  		  rx = UART3Buffer[UART3RxQueueReadPos]; // grab next byte
231
-  		  UART3RxQueueReadPos = (UART3RxQueueReadPos + 1) % UARTRXQUEUESIZE;
232
-  		  return rx;
233
-  	  }
234
-  	  return 0;
28
+HardwareSerial Serial = HardwareSerial(LPC_UART0);
29
+HardwareSerial Serial1 = HardwareSerial((LPC_UART_TypeDef *) LPC_UART1);
30
+HardwareSerial Serial2 = HardwareSerial(LPC_UART2);
31
+HardwareSerial Serial3 = HardwareSerial(LPC_UART3);
32
+
33
+void HardwareSerial::begin(uint32_t baudrate) {
34
+
35
+  UART_CFG_Type UARTConfigStruct;
36
+  PINSEL_CFG_Type PinCfg;
37
+  UART_FIFO_CFG_Type FIFOConfig;
38
+
39
+  if (UARTx == LPC_UART0) {
40
+    /*
41
+    * Initialize UART0 pin connect
42
+    */
43
+    PinCfg.Funcnum = 1;
44
+    PinCfg.OpenDrain = 0;
45
+    PinCfg.Pinmode = 0;
46
+    PinCfg.Pinnum = 2;
47
+    PinCfg.Portnum = 0;
48
+    PINSEL_ConfigPin(&PinCfg);
49
+    PinCfg.Pinnum = 3;
50
+    PINSEL_ConfigPin(&PinCfg);
235 51
   }
236
-
237
-  size_t HardwareSerial::write(uint8_t send) {
238
-    if ( PortNum == 0 )
239
-     {
240
-   	  /* THRE status, contain valid data */
241
-   	  while ( !(UART0TxEmpty & 0x01) );
242
-   	  LPC_UART0->THR = send;
243
-   	  UART0TxEmpty = 0;	/* not empty in the THR until it shifts out */
244
-     }
245
-     else if (PortNum == 1)
246
-     {
247
-
248
-   	  /* THRE status, contain valid data */
249
-   	  while ( !(UART1TxEmpty & 0x01) );
250
-   	  LPC_UART1->THR = send;
251
-   	  UART1TxEmpty = 0;	/* not empty in the THR until it shifts out */
252
-
253
-
254
-     }
255
-     else if ( PortNum == 2 )
256
-     {
257
-   	  /* THRE status, contain valid data */
258
-   	  while ( !(UART2TxEmpty & 0x01) );
259
-   	  LPC_UART2->THR = send;
260
-   	  UART2TxEmpty = 0;	/* not empty in the THR until it shifts out */
261
-
262
-     }
263
-     else if ( PortNum == 3 )
264
-     {
265
-   	  /* THRE status, contain valid data */
266
-   	  while ( !(UART3TxEmpty & 0x01) );
267
-   	  LPC_UART3->THR = send;
268
-   	  UART3TxEmpty = 0;	/* not empty in the THR until it shifts out */
269
-
270
-     }
271
-     return 0;
52
+  else if ((LPC_UART1_TypeDef *) UARTx == LPC_UART1) {
53
+    /*
54
+    * Initialize UART1 pin connect
55
+    */
56
+    PinCfg.Funcnum = 1;
57
+    PinCfg.OpenDrain = 0;
58
+    PinCfg.Pinmode = 0;
59
+    PinCfg.Pinnum = 15;
60
+    PinCfg.Portnum = 0;
61
+    PINSEL_ConfigPin(&PinCfg);
62
+    PinCfg.Pinnum = 16;
63
+    PINSEL_ConfigPin(&PinCfg);
64
+  }
65
+  else if (UARTx == LPC_UART2) {
66
+    /*
67
+    * Initialize UART2 pin connect
68
+    */
69
+    PinCfg.Funcnum = 1;
70
+    PinCfg.OpenDrain = 0;
71
+    PinCfg.Pinmode = 0;
72
+    PinCfg.Pinnum = 10;
73
+    PinCfg.Portnum = 0;
74
+    PINSEL_ConfigPin(&PinCfg);
75
+    PinCfg.Pinnum = 11;
76
+    PINSEL_ConfigPin(&PinCfg);
77
+  }
78
+  else if (UARTx == LPC_UART3) {
79
+    /*
80
+    * Initialize UART2 pin connect
81
+    */
82
+    PinCfg.Funcnum = 1;
83
+    PinCfg.OpenDrain = 0;
84
+    PinCfg.Pinmode = 0;
85
+    PinCfg.Pinnum = 0;
86
+    PinCfg.Portnum = 0;
87
+    PINSEL_ConfigPin(&PinCfg);
88
+    PinCfg.Pinnum = 1;
89
+    PINSEL_ConfigPin(&PinCfg);
272 90
   }
273 91
 
274
-  int HardwareSerial::available() {
275
-    if ( PortNum == 0 )
276
-{
277
-  return (UART0RxQueueWritePos + UARTRXQUEUESIZE - UART0RxQueueReadPos) % UARTRXQUEUESIZE;
278
-}
279
-if ( PortNum == 1 )
280
-{
281
-  return (UART1RxQueueWritePos + UARTRXQUEUESIZE - UART1RxQueueReadPos) % UARTRXQUEUESIZE;
282
-}
283
-if ( PortNum == 2 )
284
-{
285
-  return (UART2RxQueueWritePos + UARTRXQUEUESIZE - UART2RxQueueReadPos) % UARTRXQUEUESIZE;
286
-}
287
-if ( PortNum == 3 )
288
-{
289
-  return (UART3RxQueueWritePos + UARTRXQUEUESIZE - UART3RxQueueReadPos) % UARTRXQUEUESIZE;
92
+	/* Initialize UART Configuration parameter structure to default state:
93
+	 * Baudrate = 9600bps
94
+	 * 8 data bit
95
+	 * 1 Stop bit
96
+	 * None parity
97
+	 */
98
+	UART_ConfigStructInit(&UARTConfigStruct);
99
+
100
+	// Re-configure baudrate
101
+	UARTConfigStruct.Baud_rate = baudrate;
102
+
103
+	// Initialize eripheral with given to corresponding parameter
104
+  UART_Init(UARTx, &UARTConfigStruct);
105
+  
106
+  // Enable and reset the TX and RX FIFOs
107
+  UART_FIFOConfigStructInit(&FIFOConfig);
108
+  UART_FIFOConfig(UARTx, &FIFOConfig);
109
+
110
+	// Enable UART Transmit
111
+  UART_TxCmd(UARTx, ENABLE);
112
+
113
+  // Configure Interrupts
114
+  UART_IntConfig(UARTx, UART_INTCFG_RBR, ENABLE);
115
+  UART_IntConfig(UARTx, UART_INTCFG_RLS, ENABLE);
116
+  
117
+  if (UARTx == LPC_UART0)
118
+    NVIC_EnableIRQ(UART0_IRQn);
119
+  else if ((LPC_UART1_TypeDef *) UARTx == LPC_UART1)
120
+    NVIC_EnableIRQ(UART1_IRQn);
121
+  else if (UARTx == LPC_UART2)
122
+    NVIC_EnableIRQ(UART2_IRQn);
123
+  else if (UARTx == LPC_UART3)
124
+    NVIC_EnableIRQ(UART3_IRQn);
125
+
126
+  RxQueueWritePos = RxQueueReadPos = 0;
127
+  #if TX_BUFFER_SIZE > 0
128
+    TxQueueWritePos = TxQueueReadPos = 0;
129
+  #endif
290 130
 }
291
-return 0;
292
-  }
293 131
 
294
-  void HardwareSerial::flush() {
295
-    if ( PortNum == 0 )
296
-{
297
-  UART0RxQueueWritePos = 0;
298
-  UART0RxQueueReadPos = 0;
132
+int HardwareSerial::peek() {
133
+  int byte = -1;
299 134
 
135
+  /* Temporarily lock out UART receive interrupts during this read so the UART receive
136
+     interrupt won't cause problems with the index values */
137
+  UART_IntConfig(UARTx, UART_INTCFG_RBR, DISABLE);
138
+  
139
+  if (RxQueueReadPos != RxQueueWritePos)
140
+    byte = RxBuffer[RxQueueReadPos];
141
+
142
+  /* Re-enable UART interrupts */
143
+  UART_IntConfig(UARTx, UART_INTCFG_RBR, ENABLE);
144
+  
145
+  return byte;
300 146
 }
301
-if ( PortNum == 1 )
302
-{
303
-  UART1RxQueueWritePos = 0;
304
-  UART1RxQueueReadPos = 0;
305
-}
306
-if ( PortNum == 2 )
307
-{
308
-  UART2RxQueueWritePos = 0;
309
-  UART2RxQueueReadPos = 0;
310
-}
311
-if ( PortNum == 3 )
312
-{
313
-  UART3RxQueueWritePos = 0;
314
-  UART3RxQueueReadPos = 0;
315
-}
316
-return;
147
+
148
+int HardwareSerial::read() {
149
+  int byte = -1;
150
+
151
+  /* Temporarily lock out UART receive interrupts during this read so the UART receive
152
+     interrupt won't cause problems with the index values */
153
+  UART_IntConfig(UARTx, UART_INTCFG_RBR, DISABLE);
154
+  
155
+  if (RxQueueReadPos != RxQueueWritePos) {
156
+    byte = RxBuffer[RxQueueReadPos];
157
+    RxQueueReadPos = (RxQueueReadPos + 1) % RX_BUFFER_SIZE;
317 158
   }
318 159
 
319
-  void HardwareSerial::printf(const char *format, ...) {
320
-    static char buffer[256];
321
-    va_list vArgs;
322
-    va_start(vArgs, format);
323
-    int length = vsnprintf((char *) buffer, 256, (char const *) format, vArgs);
324
-    va_end(vArgs);
325
-    if (length > 0 && length < 256) {
326
-        for (int i = 0; i < length;) {
327
-          write(buffer[i]);
328
-            ++i;
329
-          }
330
-        }
160
+  /* Re-enable UART interrupts */
161
+  UART_IntConfig(UARTx, UART_INTCFG_RBR, ENABLE);
162
+  
163
+  return byte;
164
+}
165
+
166
+size_t HardwareSerial::write(uint8_t send) {
167
+  #if TX_BUFFER_SIZE > 0
168
+    size_t   bytes = 0;
169
+    uint32_t fifolvl = 0;
170
+
171
+    /* If the Tx Buffer is full, wait for space to clear */
172
+    if ((TxQueueWritePos+1) % TX_BUFFER_SIZE == TxQueueReadPos) flushTX();
173
+  
174
+    /* Temporarily lock out UART transmit interrupts during this read so the UART transmit interrupt won't
175
+       cause problems with the index values */
176
+    UART_IntConfig(UARTx, UART_INTCFG_THRE, DISABLE);
177
+
178
+    /* LPC17xx.h incorrectly defines FIFOLVL as a uint8_t, when it's actually a 32-bit register */
179
+    if ((LPC_UART1_TypeDef *) UARTx == LPC_UART1)
180
+      fifolvl = *(reinterpret_cast<volatile uint32_t *>(&((LPC_UART1_TypeDef *) UARTx)->FIFOLVL));
181
+    else
182
+      fifolvl = *(reinterpret_cast<volatile uint32_t *>(&UARTx->FIFOLVL));
183
+  
184
+    /* If the queue is empty and there's space in the FIFO, immediately send the byte */
185
+    if (TxQueueWritePos == TxQueueReadPos && fifolvl < UART_TX_FIFO_SIZE) {
186
+      bytes = UART_Send(UARTx, &send, 1, BLOCKING);
331 187
     }
188
+    /* Otherwiise, write the byte to the transmit buffer */
189
+    else if ((TxQueueWritePos+1) % TX_BUFFER_SIZE != TxQueueReadPos) {
190
+      TxBuffer[TxQueueWritePos] = send;
191
+      TxQueueWritePos = (TxQueueWritePos+1) % TX_BUFFER_SIZE;
192
+      bytes++;
193
+    }
194
+  
195
+    /* Re-enable the TX Interrupt */
196
+    UART_IntConfig(UARTx, UART_INTCFG_THRE, ENABLE);
197
+  
198
+    return bytes;
199
+  #else
200
+    return UART_Send(UARTx, &send, 1, BLOCKING);
201
+  #endif
202
+}
332 203
 
333
-#ifdef __cplusplus
334
-extern "C" {
204
+#if TX_BUFFER_SIZE > 0
205
+  void HardwareSerial::flushTX() {
206
+    /* Wait for the tx buffer and FIFO to drain */
207
+    while (TxQueueWritePos != TxQueueReadPos && UART_CheckBusy(UARTx) == SET);
208
+  }
335 209
 #endif
336 210
 
337
-/*****************************************************************************
338
-** Function name:		UART0_IRQHandler
339
-**
340
-** Descriptions:		UART0 interrupt handler
341
-**
342
-** parameters:			None
343
-** Returned value:		None
344
-**
345
-*****************************************************************************/
346
-void UART0_IRQHandler (void)
347
-{
348
-  uint8_t IIRValue, LSRValue;
211
+int HardwareSerial::available() {
212
+  return (RxQueueWritePos + RX_BUFFER_SIZE - RxQueueReadPos) % RX_BUFFER_SIZE;
213
+}
214
+
215
+void HardwareSerial::flush() {
216
+  RxQueueWritePos = 0;
217
+  RxQueueReadPos = 0;
218
+}
219
+
220
+void HardwareSerial::printf(const char *format, ...) {
221
+  char RxBuffer[256];
222
+  va_list vArgs;
223
+  va_start(vArgs, format);
224
+  int length = vsnprintf(RxBuffer, 256, format, vArgs);
225
+  va_end(vArgs);
226
+  if (length > 0 && length < 256) {
227
+    for (int i = 0; i < length; ++i)
228
+      write(RxBuffer[i]);
229
+  }
230
+}
231
+
232
+void HardwareSerial::IRQHandler() {
233
+  uint32_t IIRValue;
234
+  uint8_t LSRValue, byte;
349 235
 
350
-  IIRValue = LPC_UART0->IIR;
236
+  IIRValue = UART_GetIntId(UARTx);
237
+  IIRValue &= UART_IIR_INTID_MASK;		/* check bit 1~3, interrupt identification */
351 238
 
352
-  IIRValue >>= 1;			/* skip pending bit in IIR */
353
-  IIRValue &= 0x07;			/* check bit 1~3, interrupt identification */
354
-  if ( IIRValue == IIR_RLS )		/* Receive Line Status */
239
+  if ( IIRValue == UART_IIR_INTID_RLS )		/* Receive Line Status */
355 240
   {
356
-    LSRValue = LPC_UART0->LSR;
241
+    LSRValue = UART_GetLineStatus(UARTx);
242
+
357 243
     /* Receive Line Status */
358
-    if ( LSRValue & (LSR_OE|LSR_PE|LSR_FE|LSR_RXFE|LSR_BI) )
244
+    if ( LSRValue & (UART_LSR_OE|UART_LSR_PE|UART_LSR_FE|UART_LSR_RXFE|UART_LSR_BI) )
359 245
     {
360 246
       /* There are errors or break interrupt */
361 247
       /* Read LSR will clear the interrupt */
362
-      UART0Status = LSRValue;
363
-      dummy = LPC_UART0->RBR;		/* Dummy read on RX to clear
364
-                                   interrupt, then bail out */
248
+      Status = LSRValue;
249
+      byte = UART_ReceiveByte(UARTx);		/* Dummy read on RX to clear
250
+                                           interrupt, then bail out */
365 251
       return;
366 252
     }
367
-    if ( LSRValue & LSR_RDR )	/* Receive Data Ready */
368
-    {
369
-      /* If no error on RLS, normal ready, save into the data buffer. */
370
-      /* Note: read RBR will clear the interrupt */
371
-      if ((UART0RxQueueWritePos+1) % UARTRXQUEUESIZE != UART0RxQueueReadPos)
253
+  }
254
+  
255
+  if ( IIRValue == UART_IIR_INTID_RDA )	/* Receive Data Available */
256
+  {
257
+    /* Clear the FIFO */
258
+    while ( UART_Receive(UARTx, &byte, 1, NONE_BLOCKING) ) {
259
+      if ((RxQueueWritePos+1) % RX_BUFFER_SIZE != RxQueueReadPos)
372 260
       {
373
-        UART0Buffer[UART0RxQueueWritePos] = LPC_UART0->RBR;
374
-        UART0RxQueueWritePos = (UART0RxQueueWritePos+1) % UARTRXQUEUESIZE;
261
+        RxBuffer[RxQueueWritePos] = byte;
262
+        RxQueueWritePos = (RxQueueWritePos+1) % RX_BUFFER_SIZE;
375 263
       }
376 264
       else
377
-        dummy = LPC_UART0->RBR;
265
+        break;
378 266
     }
379 267
   }
380
-  else if ( IIRValue == IIR_RDA )	/* Receive Data Available */
381
-  {
382
-	  /* Receive Data Available */
383
-	  if ((UART0RxQueueWritePos+1) % UARTRXQUEUESIZE != UART0RxQueueReadPos)
384
-	  {
385
-		  UART0Buffer[UART0RxQueueWritePos] = LPC_UART0->RBR;
386
-		  UART0RxQueueWritePos = (UART0RxQueueWritePos+1) % UARTRXQUEUESIZE;
387
-	  }
388
-	  else
389
-		  dummy = LPC_UART1->RBR;
390
-  }
391
-  else if ( IIRValue == IIR_CTI )	/* Character timeout indicator */
268
+  else if ( IIRValue == UART_IIR_INTID_CTI )	/* Character timeout indicator */
392 269
   {
393 270
     /* Character Time-out indicator */
394
-    UART0Status |= 0x100;		/* Bit 9 as the CTI error */
271
+    Status |= 0x100;		/* Bit 9 as the CTI error */
395 272
   }
396
-  else if ( IIRValue == IIR_THRE )	/* THRE, transmit holding register empty */
397
-  {
398
-    /* THRE interrupt */
399
-    LSRValue = LPC_UART0->LSR;		/* Check status in the LSR to see if
400
-                                     valid data in U0THR or not */
401
-    if ( LSRValue & LSR_THRE )
402
-    {
403
-      UART0TxEmpty = 1;
404
-    }
405
-    else
406
-    {
407
-      UART0TxEmpty = 0;
273
+
274
+  #if TX_BUFFER_SIZE > 0
275
+    if (IIRValue == UART_IIR_INTID_THRE) {
276
+      /* Disable THRE interrupt */
277
+      UART_IntConfig(UARTx, UART_INTCFG_THRE, DISABLE);
278
+
279
+      /* Wait for FIFO buffer empty */
280
+      while (UART_CheckBusy(UARTx) == SET);
281
+    
282
+      /* Transfer up to UART_TX_FIFO_SIZE bytes of data */
283
+      for (int i = 0; i < UART_TX_FIFO_SIZE && TxQueueWritePos != TxQueueReadPos; i++) {
284
+        /* Move a piece of data into the transmit FIFO */
285
+        if (UART_Send(UARTx, &TxBuffer[TxQueueReadPos], 1, NONE_BLOCKING))
286
+          TxQueueReadPos = (TxQueueReadPos+1) % TX_BUFFER_SIZE;
287
+        else
288
+          break;
289
+      }
290
+    
291
+      /* If there is no more data to send, disable the transmit interrupt - else enable it or keep it enabled */
292
+      if (TxQueueWritePos == TxQueueReadPos)
293
+        UART_IntConfig(UARTx, UART_INTCFG_THRE, DISABLE);
294
+      else
295
+        UART_IntConfig(UARTx, UART_INTCFG_THRE, ENABLE);
408 296
     }
409
-  }
297
+  #endif
298
+}
299
+
300
+#ifdef __cplusplus
301
+extern "C" {
302
+#endif
303
+
304
+/*****************************************************************************
305
+** Function name:		UART0_IRQHandler
306
+**
307
+** Descriptions:		UART0 interrupt handler
308
+**
309
+** parameters:			None
310
+** Returned value:		None
311
+**
312
+*****************************************************************************/
313
+void UART0_IRQHandler (void)
314
+{
315
+  Serial.IRQHandler();
410 316
 }
411 317
 
412 318
 /*****************************************************************************
@@ -420,69 +326,9 @@ void UART0_IRQHandler (void)
420 326
 *****************************************************************************/
421 327
 void UART1_IRQHandler (void)
422 328
 {
423
-  uint8_t IIRValue, LSRValue;
424
-
425
-  IIRValue = LPC_UART1->IIR;
426
-
427
-  IIRValue >>= 1;			/* skip pending bit in IIR */
428
-  IIRValue &= 0x07;			/* check bit 1~3, interrupt identification */
429
-  if ( IIRValue == IIR_RLS )		/* Receive Line Status */
430
-  {
431
-    LSRValue = LPC_UART1->LSR;
432
-    /* Receive Line Status */
433
-    if ( LSRValue & (LSR_OE|LSR_PE|LSR_FE|LSR_RXFE|LSR_BI) )
434
-    {
435
-      /* There are errors or break interrupt */
436
-      /* Read LSR will clear the interrupt */
437
-      UART1Status = LSRValue;
438
-      dummy = LPC_UART1->RBR;		/* Dummy read on RX to clear
439
-                                   interrupt, then bail out */
440
-      return;
441
-    }
442
-    if ( LSRValue & LSR_RDR )	/* Receive Data Ready */
443
-    {
444
-      /* If no error on RLS, normal ready, save into the data buffer. */
445
-      /* Note: read RBR will clear the interrupt */
446
-      if ((UART1RxQueueWritePos+1) % UARTRXQUEUESIZE != UART1RxQueueReadPos)
447
-      {
448
-        UART1Buffer[UART1RxQueueWritePos] = LPC_UART1->RBR;
449
-        UART1RxQueueWritePos =(UART1RxQueueWritePos+1) % UARTRXQUEUESIZE;
450
-      }
451
-      else
452
-        dummy = LPC_UART1->RBR;
453
-    }
454
-  }
455
-  else if ( IIRValue == IIR_RDA )	/* Receive Data Available */
456
-  {
457
-	  /* Receive Data Available */
458
-	  if ((UART1RxQueueWritePos+1) % UARTRXQUEUESIZE != UART1RxQueueReadPos)
459
-	  {
460
-		  UART1Buffer[UART1RxQueueWritePos] = LPC_UART1->RBR;
461
-		  UART1RxQueueWritePos = (UART1RxQueueWritePos+1) % UARTRXQUEUESIZE;
462
-	  }
463
-	  else
464
-		  dummy = LPC_UART1->RBR;
465
-  }
466
-  else if ( IIRValue == IIR_CTI )	/* Character timeout indicator */
467
-  {
468
-    /* Character Time-out indicator */
469
-    UART1Status |= 0x100;		/* Bit 9 as the CTI error */
470
-    }
471
-    else if ( IIRValue == IIR_THRE )	/* THRE, transmit holding register empty */
472
-    {
473
-    /* THRE interrupt */
474
-    LSRValue = LPC_UART1->LSR;		/* Check status in the LSR to see if
475
-                                     valid data in U0THR or not */
476
-    if ( LSRValue & LSR_THRE )
477
-    {
478
-      UART1TxEmpty = 1;
479
-    }
480
-    else
481
-    {
482
-      UART1TxEmpty = 0;
483
-    }
484
-  }
329
+  Serial1.IRQHandler();
485 330
 }
331
+
486 332
 /*****************************************************************************
487 333
 ** Function name:		UART2_IRQHandler
488 334
 **
@@ -494,71 +340,13 @@ void UART1_IRQHandler (void)
494 340
 *****************************************************************************/
495 341
 void UART2_IRQHandler (void)
496 342
 {
497
-  uint8_t IIRValue, LSRValue;
498
-
499
-  IIRValue = LPC_UART2->IIR;
500
-
501
-  IIRValue >>= 1;			/* skip pending bit in IIR */
502
-  IIRValue &= 0x07;			/* check bit 1~3, interrupt identification */
503
-  if ( IIRValue == IIR_RLS )		/* Receive Line Status */
504
-  {
505
-    LSRValue = LPC_UART2->LSR;
506
-    /* Receive Line Status */
507
-    if ( LSRValue & (LSR_OE|LSR_PE|LSR_FE|LSR_RXFE|LSR_BI) )
508
-    {
509
-      /* There are errors or break interrupt */
510
-      /* Read LSR will clear the interrupt */
511
-      UART2Status = LSRValue;
512
-      dummy = LPC_UART2->RBR;		/* Dummy read on RX to clear
513
-                                   interrupt, then bail out */
514
-      return;
515
-    }
516
-    if ( LSRValue & LSR_RDR )	/* Receive Data Ready */
517
-    {
518
-      /* If no error on RLS, normal ready, save into the data buffer. */
519
-      /* Note: read RBR will clear the interrupt */
520
-      if ((UART2RxQueueWritePos+1) % UARTRXQUEUESIZE != UART2RxQueueReadPos)
521
-      {
522
-        UART2Buffer[UART2RxQueueWritePos] = LPC_UART2->RBR;
523
-        UART2RxQueueWritePos = (UART2RxQueueWritePos+1) % UARTRXQUEUESIZE;
524
-      }
525
-    }
526
-  }
527
-  else if ( IIRValue == IIR_RDA )	/* Receive Data Available */
528
-  {
529
-	  /* Receive Data Available */
530
-	  if ((UART2RxQueueWritePos+1) % UARTRXQUEUESIZE != UART2RxQueueReadPos)
531
-	  {
532
-		  UART2Buffer[UART2RxQueueWritePos] = LPC_UART2->RBR;
533
-		  UART2RxQueueWritePos = (UART2RxQueueWritePos+1) % UARTRXQUEUESIZE;
534
-	  }
535
-	  else
536
-		  dummy = LPC_UART2->RBR;
537
-  }
538
-  else if ( IIRValue == IIR_CTI )	/* Character timeout indicator */
539
-  {
540
-    /* Character Time-out indicator */
541
-    UART2Status |= 0x100;		/* Bit 9 as the CTI error */
542
-  }
543
-  else if ( IIRValue == IIR_THRE )	/* THRE, transmit holding register empty */
544
-  {
545
-    /* THRE interrupt */
546
-    LSRValue = LPC_UART2->LSR;		/* Check status in the LSR to see if
547
-                                     valid data in U0THR or not */
548
-    if ( LSRValue & LSR_THRE )
549
-    {
550
-      UART2TxEmpty = 1;
551
-    }
552
-    else
553
-    {
554
-      UART2TxEmpty = 0;
555
-    }
556
-  }
343
+  Serial2.IRQHandler();
557 344
 }
345
+
558 346
 /*****************************************************************************
559 347
 ** Function name:		UART3_IRQHandler
560 348
 **
561
-** Descriptions:		UART0 interrupt handler
349
+** Descriptions:		UART3 interrupt handler
562 350
 **
563 351
 ** parameters:			None
564 352
 ** Returned value:		None
@@ -566,66 +354,7 @@ void UART2_IRQHandler (void)
566 354
 *****************************************************************************/
567 355
 void UART3_IRQHandler (void)
568 356
 {
569
-  uint8_t IIRValue, LSRValue;
570
-
571
-  IIRValue = LPC_UART3->IIR;
572
-
573
-  IIRValue >>= 1;			/* skip pending bit in IIR */
574
-  IIRValue &= 0x07;			/* check bit 1~3, interrupt identification */
575
-  if ( IIRValue == IIR_RLS )		/* Receive Line Status */
576
-  {
577
-    LSRValue = LPC_UART3->LSR;
578
-    /* Receive Line Status */
579
-    if ( LSRValue & (LSR_OE|LSR_PE|LSR_FE|LSR_RXFE|LSR_BI) )
580
-    {
581
-      /* There are errors or break interrupt */
582
-      /* Read LSR will clear the interrupt */
583
-      UART3Status = LSRValue;
584
-      dummy = LPC_UART3->RBR;		/* Dummy read on RX to clear
585
-                                  interrupt, then bail out */
586
-      return;
587
-    }
588
-    if ( LSRValue & LSR_RDR )	/* Receive Data Ready */
589
-    {
590
-      /* If no error on RLS, normal ready, save into the data buffer. */
591
-      /* Note: read RBR will clear the interrupt */
592
-      if ((UART3RxQueueWritePos+1) % UARTRXQUEUESIZE != UART3RxQueueReadPos)
593
-        {
594
-          UART3Buffer[UART3RxQueueWritePos] = LPC_UART3->RBR;
595
-          UART3RxQueueWritePos = (UART3RxQueueWritePos+1) % UARTRXQUEUESIZE;
596
-        }
597
-    }
598
-  }
599
-  else if ( IIRValue == IIR_RDA )	/* Receive Data Available */
600
-  {
601
-	  /* Receive Data Available */
602
-	  if ((UART3RxQueueWritePos+1) % UARTRXQUEUESIZE != UART3RxQueueReadPos)
603
-	  {
604
-		  UART3Buffer[UART3RxQueueWritePos] = LPC_UART3->RBR;
605
-		  UART3RxQueueWritePos = (UART3RxQueueWritePos+1) % UARTRXQUEUESIZE;
606
-	  }
607
-	  else
608
-		  dummy = LPC_UART3->RBR;
609
-  }
610
-  else if ( IIRValue == IIR_CTI )	/* Character timeout indicator */
611
-  {
612
-    /* Character Time-out indicator */
613
-    UART3Status |= 0x100;		/* Bit 9 as the CTI error */
614
-  }
615
-  else if ( IIRValue == IIR_THRE )	/* THRE, transmit holding register empty */
616
-  {
617
-    /* THRE interrupt */
618
-    LSRValue = LPC_UART3->LSR;		/* Check status in the LSR to see if
619
-                                     valid data in U0THR or not */
620
-    if ( LSRValue & LSR_THRE )
621
-    {
622
-      UART3TxEmpty = 1;
623
-    }
624
-    else
625
-    {
626
-      UART3TxEmpty = 0;
627
-    }
628
-  }
357
+  Serial3.IRQHandler();
629 358
 }
630 359
 
631 360
 #ifdef __cplusplus

+ 32
- 35
Marlin/src/HAL/HAL_LPC1768/HardwareSerial.h View File

@@ -28,54 +28,51 @@
28 28
 #include <Stream.h>
29 29
 
30 30
 extern "C" {
31
-  #include <debug_frmwrk.h>
32
-  //#include <lpc17xx_uart.h>
31
+  #include <lpc17xx_uart.h>
32
+  #include "lpc17xx_pinsel.h"
33 33
 }
34 34
 
35
-#define IER_RBR   0x01
36
-#define IER_THRE  0x02
37
-#define IER_RLS   0x04
38
-
39
-#define IIR_PEND  0x01
40
-#define IIR_RLS   0x03
41
-#define IIR_RDA   0x02
42
-#define IIR_CTI   0x06
43
-#define IIR_THRE  0x01
44
-
45
-#define LSR_RDR   0x01
46
-#define LSR_OE    0x02
47
-#define LSR_PE    0x04
48
-#define LSR_FE    0x08
49
-#define LSR_BI    0x10
50
-#define LSR_THRE  0x20
51
-#define LSR_TEMT  0x40
52
-#define LSR_RXFE  0x80
53
-
54
-#define UARTRXQUEUESIZE   0x10
55
-
56 35
 class HardwareSerial : public Stream {
57 36
 private:
58
-uint8_t PortNum;
59
-uint32_t baudrate;
37
+  LPC_UART_TypeDef *UARTx;
38
+
39
+  uint32_t Status;
40
+  uint8_t RxBuffer[RX_BUFFER_SIZE];
41
+  uint32_t RxQueueWritePos;
42
+  uint32_t RxQueueReadPos;
43
+  #if TX_BUFFER_SIZE > 0
44
+    uint8_t TxBuffer[TX_BUFFER_SIZE];
45
+    uint32_t TxQueueWritePos;
46
+    uint32_t TxQueueReadPos;
47
+  #endif
60 48
 
61 49
 public:
62
-  HardwareSerial(uint32_t uart) :
63
-    PortNum(uart)
64
-    {
65
-    }
50
+  HardwareSerial(LPC_UART_TypeDef *UARTx)
51
+    : UARTx(UARTx)
52
+    , RxQueueWritePos(0)
53
+    , RxQueueReadPos(0)
54
+    #if TX_BUFFER_SIZE > 0
55
+      , TxQueueWritePos(0)
56
+      , TxQueueReadPos(0)
57
+    #endif
58
+  {
59
+  }
66 60
 
67 61
   void begin(uint32_t baudrate);
62
+  int peek();
68 63
   int read();
69 64
   size_t write(uint8_t send);
65
+  #if TX_BUFFER_SIZE > 0
66
+    void flushTX();
67
+  #endif
70 68
   int available();
71 69
   void flush();
72 70
   void printf(const char *format, ...);
73
-  int peek() {
74
-    return 0;
75
-  };
76 71
 
77 72
   operator bool() { return true; }
78 73
 
74
+  void IRQHandler();
75
+
79 76
   void print(const char value[])              { printf("%s" , value); }
80 77
   void print(char value, int = 0)             { printf("%c" , value); }
81 78
   void print(unsigned char value, int = 0)    { printf("%u" , value); }
@@ -100,9 +97,9 @@ public:
100 97
 
101 98
 };
102 99
 
103
-//extern HardwareSerial Serial0;
104
-//extern HardwareSerial Serial1;
105
-//extern HardwareSerial Serial2;
100
+extern HardwareSerial Serial;
101
+extern HardwareSerial Serial1;
102
+extern HardwareSerial Serial2;
106 103
 extern HardwareSerial Serial3;
107 104
 
108 105
 #endif // MARLIN_SRC_HAL_HAL_SERIAL_H_

+ 1
- 2
Marlin/src/HAL/HAL_LPC1768/SoftwareSerial.cpp View File

@@ -35,8 +35,7 @@ http://arduiniana.org.
35 35
 // Includes
36 36
 //
37 37
 //#include <WInterrupts.h>
38
-#include "../../core/macros.h"
39
-#include "../HAL.h"
38
+#include "../../inc/MarlinConfig.h"
40 39
 #include <stdint.h>
41 40
 #include <stdarg.h>
42 41
 #include "arduino.h"

+ 1
- 2
Marlin/src/HAL/HAL_LPC1768/WInterrupts.cpp View File

@@ -18,8 +18,7 @@
18 18
 
19 19
 #ifdef TARGET_LPC1768
20 20
 
21
-#include "../../core/macros.h"
22
-#include "../HAL.h"
21
+#include "../../inc/MarlinConfig.h"
23 22
 #include "arduino.h"
24 23
 #include "pinmapping.h"
25 24
 //#include "HAL_timers.h"

+ 3
- 4
Marlin/src/HAL/HAL_LPC1768/arduino.cpp View File

@@ -22,10 +22,9 @@
22 22
 
23 23
 #ifdef TARGET_LPC1768
24 24
 
25
+#include "../../inc/MarlinConfig.h"
26
+
25 27
 #include <lpc17xx_pinsel.h>
26
-#include "HAL.h"
27
-#include "../../core/macros.h"
28
-#include "../../core/types.h"
29 28
 
30 29
 // Interrupts
31 30
 void cli(void) { __disable_irq(); } // Disable
@@ -147,7 +146,7 @@ void analogWrite(uint8_t pin, int pwm_value) {  // 1 - 254: pwm_value, 0: LOW, 2
147 146
     if (LPC1768_PWM_attach_pin(pin, 1, (LPC_PWM1->MR0 - MR0_MARGIN),  0xff))   // locks up if get too close to MR0 value
148 147
       LPC1768_PWM_write(pin, map(value, 1, 254, 1, (LPC_PWM1->MR0 - MR0_MARGIN)));  // map 1-254 onto PWM range
149 148
     else {                                                                 // out of PWM channels
150
-      if (!out_of_PWM_slots) usb_serial.printf(".\nWARNING - OUT OF PWM CHANNELS\n.\n");  //only warn once
149
+      if (!out_of_PWM_slots) MYSERIAL.printf(".\nWARNING - OUT OF PWM CHANNELS\n.\n");  //only warn once
151 150
       out_of_PWM_slots = true;
152 151
       digitalWrite(pin, value);  // treat as a digital pin if out of channels
153 152
     }

+ 1
- 0
Marlin/src/HAL/HAL_LPC1768/lpc1768_flag_script.py View File

@@ -12,6 +12,7 @@ if __name__ == "__main__":
12 12
                     "-ffreestanding",
13 13
                     "-fsigned-char",
14 14
                     "-fno-move-loop-invariants",
15
+                    "-fno-strict-aliasing",
15 16
 
16 17
                     "--specs=nano.specs",
17 18
                     "--specs=nosys.specs",

+ 17
- 4
Marlin/src/HAL/HAL_LPC1768/main.cpp View File

@@ -24,6 +24,8 @@ extern "C" {
24 24
 #include <chanfs/ff.h>
25 25
 }
26 26
 
27
+#include "../../inc/MarlinConfig.h"
28
+#include "HAL.h"
27 29
 #include "fastio.h"
28 30
 #include "HAL_timers.h"
29 31
 #include <stdio.h>
@@ -69,21 +71,32 @@ extern "C" void SystemPostInit() {
69 71
 }
70 72
 
71 73
 extern uint32_t MSC_SD_Init(uint8_t pdrv);
72
-extern HalSerial usb_serial;
74
+
73 75
 int main(void) {
74 76
 
75 77
   (void)MSC_SD_Init(0);
78
+
76 79
   USB_Init();                               // USB Initialization
77 80
   USB_Connect(TRUE);                        // USB Connect
78 81
 
79 82
   volatile uint32_t usb_timeout = millis() + 2000;
80 83
   while (!USB_Configuration && millis() < usb_timeout) {
81 84
     delay(50);
82
-    TOGGLE(13);     // Flash fast while USB initialisation completes
85
+
86
+    #if PIN_EXISTS(LED)
87
+      TOGGLE(LED_PIN);     // Flash fast while USB initialisation completes
88
+    #endif
83 89
   }
84 90
 
85
-  debug_frmwrk_init();
86
-  usb_serial.printf("\n\nRe-ARM (LPC1768 @ %dMhz) UART0 Initialised\n", SystemCoreClock / 1000000);
91
+  // Only initialize the debug framework if using the USB emulated serial port
92
+  if ((HalSerial*) &MYSERIAL == &usb_serial)
93
+    debug_frmwrk_init();
94
+
95
+  MYSERIAL.begin(BAUDRATE);
96
+  MYSERIAL.printf("\n\nLPC1768 (%dMhz) UART0 Initialised\n", SystemCoreClock / 1000000);
97
+  #if TX_BUFFER_SIZE > 0
98
+    MYSERIAL.flushTX();
99
+  #endif
87 100
 
88 101
   HAL_timer_init();
89 102
 

+ 35
- 19
Marlin/src/HAL/HAL_LPC1768/pinmap_re_arm.h View File

@@ -27,7 +27,11 @@
27 27
 // Runtime pinmapping
28 28
 // ******************
29 29
 
30
-#define NUM_ANALOG_INPUTS 8
30
+#if SERIAL_PORT == 0
31
+  #define NUM_ANALOG_INPUTS 6
32
+#else
33
+  #define NUM_ANALOG_INPUTS 8
34
+#endif
31 35
 
32 36
 const adc_pin_data adc_pin_map[] = {
33 37
   {0, 23, 0},         //A0 (T0) - D67 - TEMP_0_PIN
@@ -36,27 +40,39 @@ const adc_pin_data adc_pin_map[] = {
36 40
   {0, 26, 3},         //A3 - D63
37 41
   {1, 30, 4},         //A4 - D37 - BUZZER_PIN
38 42
   {1, 31, 5},         //A5 - D49 - SD_DETECT_PIN
39
-  {0,  3, 6},         //A6 - D0  - RXD0
40
-  {0,  2, 7}          //A7 - D1  - TXD0
43
+  #if SERIAL_PORT != 0
44
+    {0,  3, 6},       //A6 - D0  - RXD0
45
+    {0,  2, 7}        //A7 - D1  - TXD0
46
+  #endif
41 47
 };
42 48
 
43
-#define analogInputToDigitalPin(p) (p == 0 ? 67: \
44
-                                    p == 1 ? 68: \
45
-                                    p == 2 ? 69: \
46
-                                    p == 3 ? 63: \
47
-                                    p == 4 ? 37: \
48
-                                    p == 5 ? 49: \
49
-                                    p == 6 ?  0: \
50
-                                    p == 7 ?  1: -1)
49
+constexpr FORCE_INLINE int8_t analogInputToDigitalPin(int8_t p) {
50
+  return (p == 0 ? 67:
51
+          p == 1 ? 68:
52
+          p == 2 ? 69:
53
+          p == 3 ? 63:
54
+          p == 4 ? 37:
55
+          p == 5 ? 49:
56
+          #if SERIAL_PORT != 0
57
+            p == 6 ?  0:
58
+            p == 7 ?  1:
59
+          #endif
60
+          -1);
61
+}
51 62
 
52
-#define DIGITAL_PIN_TO_ANALOG_PIN(p) (p == 67 ? 0: \
53
-                                      p == 68 ? 1: \
54
-                                      p == 69 ? 2: \
55
-                                      p == 63 ? 3: \
56
-                                      p == 37 ? 4: \
57
-                                      p == 49 ? 5: \
58
-                                      p == 0  ? 6: \
59
-                                      p == 1  ? 7: -1)
63
+constexpr FORCE_INLINE int8_t DIGITAL_PIN_TO_ANALOG_PIN(int8_t p) {
64
+  return (p == 67 ? 0:
65
+          p == 68 ? 1:
66
+          p == 69 ? 2:
67
+          p == 63 ? 3:
68
+          p == 37 ? 4:
69
+          p == 49 ? 5:
70
+          #if SERIAL_PORT != 0
71
+            p == 0  ? 6:
72
+            p == 1  ? 7:
73
+          #endif
74
+          -1);
75
+}
60 76
 
61 77
 #define NUM_DIGITAL_PINS 84
62 78
 

+ 4
- 0
Marlin/src/gcode/feature/pause/M125.cpp View File

@@ -29,6 +29,10 @@
29 29
 #include "../../../feature/pause.h"
30 30
 #include "../../../module/motion.h"
31 31
 
32
+#if DISABLED(SDSUPPORT)
33
+  #include "../../../module/printcounter.h"
34
+#endif
35
+
32 36
 /**
33 37
  * M125: Store current position and move to filament change position.
34 38
  *       Called on pause (by M25) to prevent material leaking onto the

+ 1
- 1
Marlin/src/gcode/parser.h View File

@@ -135,7 +135,7 @@ public:
135 135
     // Code is found in the string. If not found, value_ptr is unchanged.
136 136
     // This allows "if (seen('A')||seen('B'))" to use the last-found value.
137 137
     static bool seen(const char c) {
138
-      const char *p = strchr(command_args, c);
138
+      char *p = strchr(command_args, c);
139 139
       const bool b = !!p;
140 140
       if (b) value_ptr = DECIMAL_SIGNED(p[1]) ? &p[1] : (char*)NULL;
141 141
       return b;

+ 8
- 0
Marlin/src/inc/Conditionals_LCD.h View File

@@ -491,4 +491,12 @@
491 491
   #define HAS_RESUME_CONTINUE (ENABLED(NEWPANEL) || ENABLED(EMERGENCY_PARSER))
492 492
   #define HAS_COLOR_LEDS (ENABLED(BLINKM) || ENABLED(RGB_LED) || ENABLED(RGBW_LED) || ENABLED(PCA9632) || ENABLED(NEOPIXEL_LED))
493 493
 
494
+  // For Re-ARM boards, always use the USB Emulated Serial Port unless RE_ARM_FORCE_SERIAL_PORT is defined
495
+  #if MB(RAMPS_14_RE_ARM_EFB) || MB(RAMPS_14_RE_ARM_EEB) || MB(RAMPS_14_RE_ARM_EFF) || MB(RAMPS_14_RE_ARM_EEF) || MB(RAMPS_14_RE_ARM_SF)
496
+    #ifndef RE_ARM_FORCE_SERIAL_PORT
497
+      #undef SERIAL_PORT
498
+      #define SERIAL_PORT -1
499
+    #endif
500
+  #endif
501
+
494 502
 #endif // CONDITIONALS_LCD_H

+ 42
- 0
Marlin/src/inc/Conditionals_adv.h View File

@@ -0,0 +1,42 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+/**
24
+ * Conditionals_adv.h
25
+ * Defines that depend on advanced onfiguration.
26
+ */
27
+
28
+#ifndef CONDITIONALS_ADV_H
29
+#define CONDITIONALS_ADV_H
30
+
31
+  #ifndef USBCON
32
+    // Define constants and variables for buffering incoming serial data.
33
+    // 256 is the max limit due to uint8_t head and tail. Use only powers of 2. (...,16,32,64,128,256)
34
+    #ifndef RX_BUFFER_SIZE
35
+      #define RX_BUFFER_SIZE 128
36
+    #endif
37
+    #ifndef TX_BUFFER_SIZE
38
+      #define TX_BUFFER_SIZE 32
39
+    #endif
40
+  #endif
41
+
42
+#endif // CONDITIONALS_ADV_H

+ 1
- 0
Marlin/src/inc/MarlinConfig.h View File

@@ -30,6 +30,7 @@
30 30
 #include "../../Configuration.h"
31 31
 #include "Conditionals_LCD.h"
32 32
 #include "../../Configuration_adv.h"
33
+#include "Conditionals_adv.h"
33 34
 #include "../HAL/HAL.h"
34 35
 #include "../pins/pins.h"
35 36
 #if defined(__AVR__) && !defined(USBCON)

+ 18
- 0
Marlin/src/inc/SanityCheck.h View File

@@ -236,6 +236,24 @@
236 236
 #endif
237 237
 
238 238
 /**
239
+ * Serial
240
+ */
241
+#ifndef USBCON
242
+  #if ENABLED(SERIAL_XON_XOFF) && RX_BUFFER_SIZE < 1024
243
+    #error "XON/XOFF requires RX_BUFFER_SIZE >= 1024 for reliable transfers without drops."
244
+  #endif
245
+
246
+  #if !IS_POWER_OF_2(RX_BUFFER_SIZE) || RX_BUFFER_SIZE < 2
247
+    #error "RX_BUFFER_SIZE must be a power of 2 greater than 1."
248
+  #endif
249
+
250
+  // 256 is the max limit due to uint8_t head and tail. Use only powers of 2. (...,16,32,64,128,256)
251
+  #if TX_BUFFER_SIZE && (TX_BUFFER_SIZE < 2 || TX_BUFFER_SIZE > 256 || !IS_POWER_OF_2(TX_BUFFER_SIZE))
252
+    #error "TX_BUFFER_SIZE must be 0 or a power of 2 greater than 1."
253
+  #endif
254
+#endif
255
+
256
+/**
239 257
  * Dual Stepper Drivers
240 258
  */
241 259
 #if ENABLED(X_DUAL_STEPPER_DRIVERS) && ENABLED(DUAL_X_CARRIAGE)

+ 46
- 26
frameworks/CMSIS/LPC1768/driver/debug_frmwrk.c View File

@@ -44,17 +44,18 @@
44 44
 
45 45
 #ifdef _DBGFWK
46 46
 /* Debug framework */
47
+static Bool debug_frmwrk_initialized = FALSE;
47 48
 
48
-void (*_db_msg)(LPC_UART_TypeDef *UARTx, const void *s);
49
-void (*_db_msg_)(LPC_UART_TypeDef *UARTx, const void *s);
50
-void (*_db_char)(LPC_UART_TypeDef *UARTx, uint8_t ch);
51
-void (*_db_dec)(LPC_UART_TypeDef *UARTx, uint8_t decn);
52
-void (*_db_dec_16)(LPC_UART_TypeDef *UARTx, uint16_t decn);
53
-void (*_db_dec_32)(LPC_UART_TypeDef *UARTx, uint32_t decn);
54
-void (*_db_hex)(LPC_UART_TypeDef *UARTx, uint8_t hexn);
55
-void (*_db_hex_16)(LPC_UART_TypeDef *UARTx, uint16_t hexn);
56
-void (*_db_hex_32)(LPC_UART_TypeDef *UARTx, uint32_t hexn);
57
-uint8_t (*_db_get_char)(LPC_UART_TypeDef *UARTx);
49
+void (*_db_msg)(LPC_UART_TypeDef *UARTx, const void *s) = UARTPuts;
50
+void (*_db_msg_)(LPC_UART_TypeDef *UARTx, const void *s) = UARTPuts_;
51
+void (*_db_char)(LPC_UART_TypeDef *UARTx, uint8_t ch) = UARTPutChar;
52
+void (*_db_dec)(LPC_UART_TypeDef *UARTx, uint8_t decn) = UARTPutHex;
53
+void (*_db_dec_16)(LPC_UART_TypeDef *UARTx, uint16_t decn) = UARTPutHex16;
54
+void (*_db_dec_32)(LPC_UART_TypeDef *UARTx, uint32_t decn) = UARTPutHex32;
55
+void (*_db_hex)(LPC_UART_TypeDef *UARTx, uint8_t hexn) = UARTPutDec;
56
+void (*_db_hex_16)(LPC_UART_TypeDef *UARTx, uint16_t hexn) = UARTPutDec16;
57
+void (*_db_hex_32)(LPC_UART_TypeDef *UARTx, uint32_t hexn) = UARTPutDec32;
58
+uint8_t (*_db_get_char)(LPC_UART_TypeDef *UARTx) = UARTGetChar;
58 59
 
59 60
 
60 61
 /*********************************************************************//**
@@ -65,7 +66,8 @@ uint8_t (*_db_get_char)(LPC_UART_TypeDef *UARTx);
65 66
  **********************************************************************/
66 67
 void UARTPutChar (LPC_UART_TypeDef *UARTx, uint8_t ch)
67 68
 {
68
-	UART_Send(UARTx, &ch, 1, BLOCKING);
69
+  if (debug_frmwrk_initialized)
70
+	  UART_Send(UARTx, &ch, 1, BLOCKING);
69 71
 }
70 72
 
71 73
 
@@ -76,8 +78,11 @@ void UARTPutChar (LPC_UART_TypeDef *UARTx, uint8_t ch)
76 78
  **********************************************************************/
77 79
 uint8_t UARTGetChar (LPC_UART_TypeDef *UARTx)
78 80
 {
79
-	uint8_t tmp = 0;
80
-	UART_Receive(UARTx, &tmp, 1, BLOCKING);
81
+  uint8_t tmp = 0;
82
+  
83
+  if (debug_frmwrk_initialized)
84
+    UART_Receive(UARTx, &tmp, 1, BLOCKING);
85
+    
81 86
 	return(tmp);
82 87
 }
83 88
 
@@ -90,7 +95,10 @@ uint8_t UARTGetChar (LPC_UART_TypeDef *UARTx)
90 95
  **********************************************************************/
91 96
 void UARTPuts(LPC_UART_TypeDef *UARTx, const void *str)
92 97
 {
93
-	uint8_t *s = (uint8_t *) str;
98
+  uint8_t *s = (uint8_t *) str;
99
+  
100
+  if (!debug_frmwrk_initialized)
101
+    return;
94 102
 
95 103
 	while (*s)
96 104
 	{
@@ -107,6 +115,9 @@ void UARTPuts(LPC_UART_TypeDef *UARTx, const void *str)
107 115
  **********************************************************************/
108 116
 void UARTPuts_(LPC_UART_TypeDef *UARTx, const void *str)
109 117
 {
118
+  if (!debug_frmwrk_initialized)
119
+    return;
120
+
110 121
 	UARTPuts (UARTx, str);
111 122
 	UARTPuts (UARTx, "\n\r");
112 123
 }
@@ -120,6 +131,9 @@ void UARTPuts_(LPC_UART_TypeDef *UARTx, const void *str)
120 131
  **********************************************************************/
121 132
 void UARTPutDec(LPC_UART_TypeDef *UARTx, uint8_t decnum)
122 133
 {
134
+  if (!debug_frmwrk_initialized)
135
+    return;
136
+
123 137
 	uint8_t c1=decnum%10;
124 138
 	uint8_t c2=(decnum/10)%10;
125 139
 	uint8_t c3=(decnum/100)%10;
@@ -135,7 +149,10 @@ void UARTPutDec(LPC_UART_TypeDef *UARTx, uint8_t decnum)
135 149
  * @return		None
136 150
  **********************************************************************/
137 151
 void UARTPutDec16(LPC_UART_TypeDef *UARTx, uint16_t decnum)
138
-{
152
+{  
153
+  if (!debug_frmwrk_initialized)
154
+    return;
155
+
139 156
 	uint8_t c1=decnum%10;
140 157
 	uint8_t c2=(decnum/10)%10;
141 158
 	uint8_t c3=(decnum/100)%10;
@@ -156,6 +173,9 @@ void UARTPutDec16(LPC_UART_TypeDef *UARTx, uint16_t decnum)
156 173
  **********************************************************************/
157 174
 void UARTPutDec32(LPC_UART_TypeDef *UARTx, uint32_t decnum)
158 175
 {
176
+  if (!debug_frmwrk_initialized)
177
+    return;
178
+
159 179
 	uint8_t c1=decnum%10;
160 180
 	uint8_t c2=(decnum/10)%10;
161 181
 	uint8_t c3=(decnum/100)%10;
@@ -187,6 +207,9 @@ void UARTPutDec32(LPC_UART_TypeDef *UARTx, uint32_t decnum)
187 207
 void UARTPutHex (LPC_UART_TypeDef *UARTx, uint8_t hexnum)
188 208
 {
189 209
 	uint8_t nibble, i;
210
+  
211
+  if (!debug_frmwrk_initialized)
212
+    return;
190 213
 
191 214
 	UARTPuts(UARTx, "0x");
192 215
 	i = 1;
@@ -206,6 +229,9 @@ void UARTPutHex (LPC_UART_TypeDef *UARTx, uint8_t hexnum)
206 229
 void UARTPutHex16 (LPC_UART_TypeDef *UARTx, uint16_t hexnum)
207 230
 {
208 231
 	uint8_t nibble, i;
232
+  
233
+  if (!debug_frmwrk_initialized)
234
+    return;
209 235
 
210 236
 	UARTPuts(UARTx, "0x");
211 237
 	i = 3;
@@ -223,7 +249,10 @@ void UARTPutHex16 (LPC_UART_TypeDef *UARTx, uint16_t hexnum)
223 249
  **********************************************************************/
224 250
 void UARTPutHex32 (LPC_UART_TypeDef *UARTx, uint32_t hexnum)
225 251
 {
226
-	uint8_t nibble, i;
252
+  uint8_t nibble, i;
253
+  
254
+  if (!debug_frmwrk_initialized)
255
+    return;
227 256
 
228 257
 	UARTPuts(UARTx, "0x");
229 258
 	i = 7;
@@ -305,16 +334,7 @@ void debug_frmwrk_init(void)
305 334
 	// Enable UART Transmit
306 335
 	UART_TxCmd((LPC_UART_TypeDef *)DEBUG_UART_PORT, ENABLE);
307 336
 
308
-	_db_msg	= UARTPuts;
309
-	_db_msg_ = UARTPuts_;
310
-	_db_char = UARTPutChar;
311
-	_db_hex = UARTPutHex;
312
-	_db_hex_16 = UARTPutHex16;
313
-	_db_hex_32 = UARTPutHex32;
314
-	_db_dec = UARTPutDec;
315
-	_db_dec_16 = UARTPutDec16;
316
-	_db_dec_32 = UARTPutDec32;
317
-	_db_get_char = UARTGetChar;
337
+  debug_frmwrk_initialized = TRUE;
318 338
 }
319 339
 #endif /*_DBGFWK */
320 340
 

+ 2
- 2
frameworks/CMSIS/LPC1768/lib/Print.h View File

@@ -17,8 +17,8 @@
17 17
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18 18
 */
19 19
 
20
-#ifndef Print_h
21
-#define Print_h
20
+#ifndef CMSIS_Print_h
21
+#define CMSIS_Print_h
22 22
 
23 23
 
24 24
 #include <inttypes.h>

+ 2
- 2
frameworks/CMSIS/LPC1768/lib/Printable.h View File

@@ -17,8 +17,8 @@
17 17
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18 18
 */
19 19
 
20
-#ifndef Printable_h
21
-#define Printable_h
20
+#ifndef CMSIS_Printable_h
21
+#define CMSIS_Printable_h
22 22
 
23 23
 #include <stdlib.h>
24 24
 #include <inttypes.h>

Loading…
Cancel
Save