aboutsummaryrefslogtreecommitdiffstats
path: root/src/serial.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/serial.c')
-rw-r--r--src/serial.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/serial.c b/src/serial.c
index 32fcb95..db0cfbc 100644
--- a/src/serial.c
+++ b/src/serial.c
@@ -26,13 +26,13 @@ char serial_get(void)
return USART2->RDR & 0xFF;
}
-void serial_gets(char *buf)
+void serial_gets(char *buf, int max)
{
uint16_t index = 0;
do {
buf[index] = serial_get();
- } while (buf[index++] != '\r');
+ } while (index++ < max && buf[index] != '\r');
buf[index - 1] = '\0';
//return buf;