Skip to content
This repository was archived by the owner on Jun 5, 2019. It is now read-only.

Commit 6e476df

Browse files
committed
- replaced debug_printf calls with hal_printf calls for STM32F4 ethernet driver and WireProtocol.cpp to keep clarity and consistency as network could be used for the Debug transport and DebugTextPort.
- restored DEBUG_TRACE so it uses hal_printf() instead of debug_printf so that it is useful for tracing issues even when the debug port isn't fully functional.
1 parent 8e1d7be commit 6e476df

File tree

8 files changed

+55
-48
lines changed

8 files changed

+55
-48
lines changed

DeviceCode/Targets/Native/STM32F4/DeviceCode/STM32F4_ETH_lwip_OS/STM32F4_ETH_driver.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ void eth_resumeDmaReception()
228228
void eth_dmaInterruptHandler()
229229
{
230230
#if defined (_DEBUG) && DEBUG_DMA_INT
231-
debug_printf("DMA Int:");
231+
hal_printf("DMA Int:");
232232
#endif
233233

234234
// Normal interrupt summary
@@ -239,7 +239,7 @@ void eth_dmaInterruptHandler()
239239
{
240240
// Ethernet frame received
241241
#if defined (_DEBUG) && DEBUG_DMA_INT
242-
debug_printf(" RS");
242+
hal_printf(" RS");
243243
#endif
244244

245245
// Clear interrupt flag
@@ -257,7 +257,7 @@ void eth_dmaInterruptHandler()
257257
{
258258
// Ethernet frame sent
259259
#if defined (_DEBUG) && DEBUG_DMA_INT
260-
debug_printf(" TS");
260+
hal_printf(" TS");
261261
#endif
262262

263263
// Clear interrupt flag
@@ -269,7 +269,7 @@ void eth_dmaInterruptHandler()
269269
{
270270
// Transmit buffer unavailable
271271
#if defined (_DEBUG) && DEBUG_DMA_INT
272-
debug_printf(" TBUS");
272+
hal_printf(" TBUS");
273273
#endif
274274

275275
// Clear interrupt flag, transmition is resumed after descriptors have been prepared
@@ -281,7 +281,7 @@ void eth_dmaInterruptHandler()
281281
{
282282
// Early receive
283283
#if defined (_DEBUG) && DEBUG_DMA_INT
284-
debug_printf(" ERS");
284+
hal_printf(" ERS");
285285
#endif
286286

287287
// Clear interrupt flag. Also cleared automatically by RI
@@ -301,7 +301,7 @@ void eth_dmaInterruptHandler()
301301
{
302302
// Fatal bus error
303303
#if defined (_DEBUG) && DEBUG_DMA_INT
304-
debug_printf(" FBES");
304+
hal_printf(" FBES");
305305
#endif
306306

307307
// Clear interrupt flag
@@ -313,7 +313,7 @@ void eth_dmaInterruptHandler()
313313
{
314314
// Transmit process stopped
315315
#if defined (_DEBUG) && DEBUG_DMA_INT
316-
debug_printf(" TPSS");
316+
hal_printf(" TPSS");
317317
#endif
318318

319319
// Clear interrupt flag
@@ -325,7 +325,7 @@ void eth_dmaInterruptHandler()
325325
{
326326
// Transmit jabber timeout
327327
#if defined (_DEBUG) && DEBUG_DMA_INT
328-
debug_printf(" TJTS");
328+
hal_printf(" TJTS");
329329
#endif
330330

331331
// Clear interrupt flag
@@ -337,7 +337,7 @@ void eth_dmaInterruptHandler()
337337
{
338338
// Receive overflow
339339
#if defined (_DEBUG) && DEBUG_DMA_INT
340-
debug_printf(" ROS");
340+
hal_printf(" ROS");
341341
#endif
342342

343343
// Clear interrupt flag
@@ -349,7 +349,7 @@ void eth_dmaInterruptHandler()
349349
{
350350
// Transmit underflow
351351
#if defined (_DEBUG) && DEBUG_DMA_INT
352-
debug_printf(" TUS");
352+
hal_printf(" TUS");
353353
#endif
354354

355355
// Clear interrupt flag
@@ -361,7 +361,7 @@ void eth_dmaInterruptHandler()
361361
{
362362
// Receive buffer unavailable
363363
#if defined (_DEBUG) && DEBUG_DMA_INT
364-
debug_printf(" RBUS");
364+
hal_printf(" RBUS");
365365
#endif
366366

367367
// Clear interrupt flag
@@ -373,7 +373,7 @@ void eth_dmaInterruptHandler()
373373
{
374374
// Receive process stopped
375375
#if defined (_DEBUG) && DEBUG_DMA_INT
376-
debug_printf(" RPSS");
376+
hal_printf(" RPSS");
377377
#endif
378378

379379
// Clear interrupt flag
@@ -385,7 +385,7 @@ void eth_dmaInterruptHandler()
385385
{
386386
// Receive watchdog timeout
387387
#if defined (_DEBUG) && DEBUG_DMA_INT
388-
debug_printf(" RWTS");
388+
hal_printf(" RWTS");
389389
#endif
390390

391391
// Clear interrupt flag
@@ -397,7 +397,7 @@ void eth_dmaInterruptHandler()
397397
{
398398
// Early transmit interrupt
399399
#if defined (_DEBUG) && DEBUG_DMA_INT
400-
debug_printf(" ETS");
400+
hal_printf(" ETS");
401401
#endif
402402

403403
// Clear interrupt flag
@@ -410,7 +410,7 @@ void eth_dmaInterruptHandler()
410410
}
411411

412412
#if defined (_DEBUG) && DEBUG_DMA_INT
413-
debug_printf("\r\n");
413+
hal_printf("\r\n");
414414
#endif
415415
}
416416

DeviceCode/Targets/Native/STM32F4/DeviceCode/STM32F4_ETH_lwip_OS/STM32F4_ETH_lwip.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ BOOL STM32F4_ETH_LWIP_open(Netif_t *const pNetif)
8888
if ( !initEthernet(pNetif) )
8989
{
9090
#ifdef _DEBUG_TRACE
91-
debug_printf("Ethernet driver cannot be opened\r\n");
91+
hal_printf("Ethernet driver cannot be opened\r\n");
9292
#endif
9393

9494
// Set flag as closed and abort
@@ -107,7 +107,7 @@ BOOL STM32F4_ETH_LWIP_open(Netif_t *const pNetif)
107107
s_isDriverOpened = TRUE;
108108

109109
#ifdef _DEBUG_TRACE
110-
debug_printf("Ethernet driver opened\r\n");
110+
hal_printf("Ethernet driver opened\r\n");
111111
#endif
112112

113113
return TRUE;
@@ -135,7 +135,7 @@ void STM32F4_ETH_LWIP_close(const BOOL disableClocks)
135135
}
136136

137137
#ifdef _DEBUG_TRACE
138-
debug_printf("Ethernet driver closed\r\n");
138+
hal_printf("Ethernet driver closed\r\n");
139139
#endif
140140
}
141141

@@ -177,7 +177,7 @@ static uint32_t processFrame(Netif_t *const pNetif)
177177
if (frameLength == 0)
178178
{
179179
#ifdef _DEBUG_TRACE
180-
debug_printf("%s: erroneous frame\r\n", __func__);
180+
hal_printf("%s: erroneous frame\r\n", __func__);
181181
#endif
182182

183183
return releaseRxDescUntilNextFrame();
@@ -188,7 +188,7 @@ static uint32_t processFrame(Netif_t *const pNetif)
188188
if (!pbuf)
189189
{
190190
#ifdef _DEBUG_TRACE
191-
debug_printf("%s: pbuf_alloc failed, discard current frame\r\n", __func__);
191+
hal_printf("%s: pbuf_alloc failed, discard current frame\r\n", __func__);
192192
#endif
193193

194194
return releaseFrame();
@@ -218,7 +218,7 @@ static uint32_t copyFrameToPbuf(Pbuf_t *pbuf)
218218
while (!eth_isRxDescOwnedByDma() && !isLastDescProcessed)
219219
{
220220
#if DEBUG_RX_DESC
221-
debug_printf("----- Before processing RX -----\r\n");
221+
hal_printf("----- Before processing RX -----\r\n");
222222
eth_displayRxDescStatus();
223223
#endif
224224

@@ -237,7 +237,7 @@ static uint32_t copyFrameToPbuf(Pbuf_t *pbuf)
237237
nRxDesc++;
238238

239239
#if DEBUG_RX_DESC
240-
debug_printf("----- After processing RX -----\r\n");
240+
hal_printf("----- After processing RX -----\r\n");
241241
eth_displayRxDescStatus();
242242
#endif
243243
}
@@ -400,7 +400,7 @@ static BOOL waitForTxDescriptor(uint32_t timeout)
400400
if (nWait == timeout)
401401
{
402402
//#ifdef _DEBUG
403-
//debug_printf("%s: TX descriptor owned by DMA\r\n", __func__);
403+
//hal_printf("%s: TX descriptor owned by DMA\r\n", __func__);
404404
//#endif
405405

406406
return FALSE;
@@ -426,7 +426,7 @@ static BOOL copyFrameFromPbuf(const Pbuf_t *pbuf)
426426
if (frameLength > TX_BUFFER_LENGTH)
427427
{
428428
#ifdef _DEBUG_TRACE
429-
debug_printf("%s: Frame larger than TX buffer (%d)\r\n", __func__, frameLength);
429+
hal_printf("%s: Frame larger than TX buffer (%d)\r\n", __func__, frameLength);
430430
#endif
431431

432432
return FALSE;

DeviceCode/Targets/Native/STM32F4/DeviceCode/STM32F4_ETH_lwip_OS/STM32F4_ETH_phy.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ static void findPhyAddr()
5555
if ((value == PHY_KENDIN_OUI_ID1) || (value == PHY_ST802RT1X_OUI_ID1))
5656
{
5757
rc = phyAddress;
58-
debug_printf( "Valid PHY Found: %x (%x)\r\n", rc, value);
58+
hal_printf( "Valid PHY Found: %x (%x)\r\n", rc, value);
5959
g_foundPhyAddress = TRUE;
6060
g_phyAddress = phyAddress;
6161

@@ -189,7 +189,7 @@ EthMode eth_enableAutoNegotiation()
189189
return ETHMODE_FAIL;
190190

191191
#if (DEBUG_TRACE)
192-
debug_printf("PHY CR status 0x%x \n",status);
192+
hal_printf("PHY CR status 0x%x \n",status);
193193
#endif
194194

195195
// Start Auto Negotiation
@@ -210,13 +210,13 @@ EthMode eth_enableAutoNegotiation()
210210
// Check auto negotiation completed
211211
if ((status & PHY_SR_ANEGC) != PHY_SR_ANEGC)
212212
{
213-
debug_printf("autonegotiate failed. Status: %x\n", status);
213+
hal_printf("autonegotiate failed. Status: %x\n", status);
214214
return ETHMODE_FAIL;
215215

216216
}
217217

218218
#if (DEBUG_TRACE)
219-
debug_printf("Autonegotiate Complete SR:%x\n", status);
219+
hal_printf("Autonegotiate Complete SR:%x\n", status);
220220
#endif
221221

222222
#if STM32F4_ETH_PHY_MII

DeviceCode/Targets/Native/STM32F4/DeviceCode/STM32F4_ETH_lwip_OS/STM32F4_ETH_rx_desc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ void eth_initRxDescriptors()
122122
}
123123

124124
#if DEBUG_RX_DESC
125-
debug_printf("----- After init RX desc -----\r\n");
125+
hal_printf("----- After init RX desc -----\r\n");
126126
eth_displayRxDescStatus();
127127
#endif
128128

@@ -282,7 +282,7 @@ void eth_displayRxDescStatus()
282282

283283
for (uint32_t i = 0; i < N_RX_DESC; i++)
284284
{
285-
debug_printf("%d: 0x%08x %s\r\n", i, s_rxDescriptor[i].rdes0,
285+
hal_printf("%d: 0x%08x %s\r\n", i, s_rxDescriptor[i].rdes0,
286286
s_pRxDesc == &s_rxDescriptor[i] ? "<===" : "");
287287
}
288288
}

DeviceCode/Targets/Native/STM32F4/DeviceCode/STM32F4_ETH_lwip_OS/STM32F4_ETH_tx_desc.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ void eth_initTxDescriptor()
121121
}
122122

123123
#if DEBUG_TX_DESC
124-
debug_printf("----- After init TX desc -----\r\n");
124+
hal_printf("----- After init TX desc -----\r\n");
125125
eth_displayTxDescStatus();
126126
#endif
127127

@@ -220,9 +220,9 @@ void eth_displayTxDescStatus()
220220

221221
for (uint32_t i = 0; i < N_TX_DESC; i++)
222222
{
223-
debug_printf("tdes0: 0x%08x %s\r\n", s_txDescriptor[i].tdes0,
223+
hal_printf("tdes0: 0x%08x %s\r\n", s_txDescriptor[i].tdes0,
224224
s_pTxDesc == &s_txDescriptor[i] ? "<===" : "");
225-
debug_printf("tdes1: 0x%08x\r\n", s_txDescriptor[i].tdes1);
225+
hal_printf("tdes1: 0x%08x\r\n", s_txDescriptor[i].tdes1);
226226
}
227227
}
228228
#endif

DeviceCode/Targets/OS/CMSIS_RTOS/DeviceCode/lwip_1_4_1_os/arch/cc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@ typedef intptr_t mem_ptr_t;
7070
#define PACK_STRUCT_END
7171

7272
/* Plaform specific diagnostic output */
73-
extern void debug_printf(const char *format, ...);
73+
extern void hal_printf(const char *format, ...);
7474

7575
#define LWIP_PLATFORM_DIAG(x) do {debug_printf x;} while(0)
7676

7777
#ifndef LWIP_NOASSERT
7878
#define LWIP_PLATFORM_ASSERT(x) \
79-
do {debug_printf("LWIP Assertion \"%s\" failed at line %d in %s\n", \
79+
do {hal_printf("LWIP Assertion \"%s\" failed at line %d in %s\n", \
8080
x, __LINE__, __FILE__); } while(0)
8181
#else
8282
#define LWIP_PLATFORM_ASSERT(x)

DeviceCode/include/tinyhal.h

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -398,10 +398,17 @@ struct HAL_SYSTEM_CONFIG
398398

399399
COM_HANDLE DebuggerPorts[c_MaxDebuggers];
400400
COM_HANDLE MessagingPorts[c_MaxMessaging];
401-
401+
// communication channel for debug messages in the debugger
402+
// which may be VS, MFDEPLOY, etc... Accessed via debug_printf
403+
// in the HAL/PAL and System.Diagnostics.Debug.Print() in managed
404+
// applications
402405
COM_HANDLE DebugTextPort;
403406

404407
UINT32 USART_DefaultBaudRate;
408+
// internal HAL/PAL debug/tracing channel, this is seperate
409+
// to allow tracing messages in the driver that implements
410+
// the transport for the Debugger and DebugTextPort. This
411+
// channel is accessed via hal_printf() in the HAL/PAL
405412
COM_HANDLE stdio;
406413

407414
HAL_SYSTEM_MEMORY_CONFIG RAM1;
@@ -1449,16 +1456,16 @@ extern const ConfigurationSector g_ConfigurationSector;
14491456

14501457
#if !defined(BUILD_RTM)
14511458

1452-
#define DEBUG_TRACE0(t, s) if(((t) & DEBUG_TRACE) != 0) debug_printf( (s) )
1453-
#define DEBUG_TRACE1(t, s, p1) if(((t) & DEBUG_TRACE) != 0) debug_printf( (s), (p1) )
1454-
#define DEBUG_TRACE2(t, s, p1,p2) if(((t) & DEBUG_TRACE) != 0) debug_printf( (s), (p1),(p2) )
1455-
#define DEBUG_TRACE3(t, s, p1,p2,p3) if(((t) & DEBUG_TRACE) != 0) debug_printf( (s), (p1),(p2),(p3) )
1456-
#define DEBUG_TRACE4(t, s, p1,p2,p3,p4) if(((t) & DEBUG_TRACE) != 0) debug_printf( (s), (p1),(p2),(p3),(p4) )
1457-
#define DEBUG_TRACE5(t, s, p1,p2,p3,p4,p5) if(((t) & DEBUG_TRACE) != 0) debug_printf( (s), (p1),(p2),(p3),(p4),(p5) )
1458-
#define DEBUG_TRACE6(t, s, p1,p2,p3,p4,p5,p6) if(((t) & DEBUG_TRACE) != 0) debug_printf( (s), (p1),(p2),(p3),(p4),(p5),(p6) )
1459-
#define DEBUG_TRACE7(t, s, p1,p2,p3,p4,p5,p6,p7) if(((t) & DEBUG_TRACE) != 0) debug_printf( (s), (p1),(p2),(p3),(p4),(p5),(p6),(p7) )
1460-
#define DEBUG_TRACE8(t, s, p1,p2,p3,p4,p5,p6,p7,p8) if(((t) & DEBUG_TRACE) != 0) debug_printf( (s), (p1),(p2),(p3),(p4),(p5),(p6),(p7),(p8) )
1461-
#define DEBUG_TRACE9(t, s, p1,p2,p3,p4,p5,p6,p7,p8,p9) if(((t) & DEBUG_TRACE) != 0) debug_printf( (s), (p1),(p2),(p3),(p4),(p5),(p6),(p7),(p8),(p9) )
1459+
#define DEBUG_TRACE0(t, s) if(((t) & DEBUG_TRACE) != 0) hal_printf( (s) )
1460+
#define DEBUG_TRACE1(t, s, p1) if(((t) & DEBUG_TRACE) != 0) hal_printf( (s), (p1) )
1461+
#define DEBUG_TRACE2(t, s, p1,p2) if(((t) & DEBUG_TRACE) != 0) hal_printf( (s), (p1),(p2) )
1462+
#define DEBUG_TRACE3(t, s, p1,p2,p3) if(((t) & DEBUG_TRACE) != 0) hal_printf( (s), (p1),(p2),(p3) )
1463+
#define DEBUG_TRACE4(t, s, p1,p2,p3,p4) if(((t) & DEBUG_TRACE) != 0) hal_printf( (s), (p1),(p2),(p3),(p4) )
1464+
#define DEBUG_TRACE5(t, s, p1,p2,p3,p4,p5) if(((t) & DEBUG_TRACE) != 0) hal_printf( (s), (p1),(p2),(p3),(p4),(p5) )
1465+
#define DEBUG_TRACE6(t, s, p1,p2,p3,p4,p5,p6) if(((t) & DEBUG_TRACE) != 0) hal_printf( (s), (p1),(p2),(p3),(p4),(p5),(p6) )
1466+
#define DEBUG_TRACE7(t, s, p1,p2,p3,p4,p5,p6,p7) if(((t) & DEBUG_TRACE) != 0) hal_printf( (s), (p1),(p2),(p3),(p4),(p5),(p6),(p7) )
1467+
#define DEBUG_TRACE8(t, s, p1,p2,p3,p4,p5,p6,p7,p8) if(((t) & DEBUG_TRACE) != 0) hal_printf( (s), (p1),(p2),(p3),(p4),(p5),(p6),(p7),(p8) )
1468+
#define DEBUG_TRACE9(t, s, p1,p2,p3,p4,p5,p6,p7,p8,p9) if(((t) & DEBUG_TRACE) != 0) hal_printf( (s), (p1),(p2),(p3),(p4),(p5),(p6),(p7),(p8),(p9) )
14621469

14631470
#else
14641471

Support/WireProtocol/WireProtocol.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
////////////////////////////////////////////////////////////////////////////////////////////////////
88

99
#if 0
10-
#define TRACE0( msg, ...) debug_printf( msg )
11-
#define TRACE( msg, ...) debug_printf( msg, __VA_ARGS__ )
10+
#define TRACE0( msg, ...) hal_printf( msg )
11+
#define TRACE( msg, ...) hal_printf( msg, __VA_ARGS__ )
1212
#else
1313
#define TRACE0(msg,...)
1414
#define TRACE(msg,...)

0 commit comments

Comments
 (0)