Skip to content

Commit 762a5b7

Browse files
committed
Provide SerialPut{Char,String}(), which output characters to the serial port
The new functions SerialPutChar() and SerialPutString() output charcters directly to the serial port. This is useful for debugging or in ISRs, where IPC is not available. Don't use them in regular code.
1 parent 5c2def6 commit 762a5b7

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

src/Serial.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,15 @@
44

55
#include "Serial.h"
66

7+
#include <hw_memmap.h>
8+
#include <hw_types.h>
9+
#include <prcm.h>
10+
#include <rom_map.h>
11+
#include <uart.h>
12+
#include <uart_if.h>
13+
714
#include <FreeRTOS.h>
815
#include <task.h>
9-
#include <uart_if.h>
1016

1117
#include "Task.h"
1218

@@ -21,6 +27,20 @@ typedef struct
2127
TaskHandle_t mTask;
2228
} SerialOutTask;
2329

30+
void
31+
SerialPutChar(int c)
32+
{
33+
MAP_UARTCharPut(CONSOLE, c);
34+
}
35+
36+
void
37+
SerialPutString(size_t aLength, const char* aString)
38+
{
39+
for (const char* end = aString + aLength; aString < end; ++aString) {
40+
SerialPutChar(*aString);
41+
}
42+
}
43+
2444
static void
2545
Run(SerialOutTask* aSerialOut)
2646
{
@@ -32,7 +52,8 @@ Run(SerialOutTask* aSerialOut)
3252
if (res < 0) {
3353
return;
3454
}
35-
Report(msg.mBuffer);
55+
56+
SerialPutString(IPCMessageGetBufferLength(&msg), msg.mBuffer);
3657

3758
IPCMessageConsume(&msg);
3859
}

src/Serial.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
int
1010
SerialInit(void);
1111

12+
void
13+
SerialPutChar(int c);
14+
15+
void
16+
SerialPutString(size_t aLength, const char* aString);
17+
1218
/* Returns the message queue for output of over the serial line. This
1319
* is a singleton.
1420
*/

0 commit comments

Comments
 (0)