From 7548a730016c1751a79838fb47753e36ce55dda1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Boczar?= Date: Wed, 8 Jan 2020 14:45:45 +0100 Subject: [PATCH] increase default baud rate to 115200, add option to set baudrate --- examples/serial-cdc-loopback/Makefile | 3 +++ examples/serial-cdc-loopback/README.md | 2 ++ examples/serial-cdc-loopback/main.c | 2 +- examples/serial-loopback/Makefile | 3 +++ examples/serial-loopback/README.md | 2 ++ examples/serial-loopback/main.c | 2 +- 6 files changed, 12 insertions(+), 2 deletions(-) diff --git a/examples/serial-cdc-loopback/Makefile b/examples/serial-cdc-loopback/Makefile index bfc396a..39df9bf 100644 --- a/examples/serial-cdc-loopback/Makefile +++ b/examples/serial-cdc-loopback/Makefile @@ -5,6 +5,9 @@ FLAGS = -I../../common -DDEBUG SOURCES = main descriptors ../../common/cdc ../../common/uart BITBANG ?= 1 +BAUDRATE ?= 115200 + +FLAGS += -DBAUDRATE=$(BAUDRATE) ifeq ($(BITBANG), 1) FLAGS += -DUART_SOFTWARE_BITBANG=1 \ diff --git a/examples/serial-cdc-loopback/README.md b/examples/serial-cdc-loopback/README.md index 2d47966..f22bdf1 100644 --- a/examples/serial-cdc-loopback/README.md +++ b/examples/serial-cdc-loopback/README.md @@ -9,6 +9,8 @@ To run the example the pins used for UART TX and RX must be externally connected Alternatively, any data sent to UART RX pin will be passed over CDC-ACM, and any data sent over USB will be sent over UART TX pin with some data modifications. +UART baudrate can be set using `BAUDRATE` *Makefile* variable. + ## UART Configuration See the README for serial-loopback example. `../serial-loopback/README.md`. diff --git a/examples/serial-cdc-loopback/main.c b/examples/serial-cdc-loopback/main.c index c2a0a6c..87f86f8 100644 --- a/examples/serial-cdc-loopback/main.c +++ b/examples/serial-cdc-loopback/main.c @@ -48,7 +48,7 @@ int main() { SYNCDELAY; FIFORESET = 0; // configure and start bitbang uart - uart_init(9600, UART_MODE_RX_TX); + uart_init(BAUDRATE, UART_MODE_RX_TX); // Re-enumerate, to make sure our descriptors are picked up correctly. usb_init(/*disconnect=*/true); diff --git a/examples/serial-loopback/Makefile b/examples/serial-loopback/Makefile index 04476bd..dab081b 100644 --- a/examples/serial-loopback/Makefile +++ b/examples/serial-loopback/Makefile @@ -5,6 +5,9 @@ FLAGS = -I../../common -DDEBUG SOURCES = main descriptors ../../common/cdc ../../common/uart BITBANG ?= 1 +BAUDRATE ?= 115200 + +FLAGS += -DBAUDRATE=$(BAUDRATE) ifeq ($(BITBANG), 1) FLAGS += -DUART_SOFTWARE_BITBANG=1 \ diff --git a/examples/serial-loopback/README.md b/examples/serial-loopback/README.md index 0b1d405..a504acb 100644 --- a/examples/serial-loopback/README.md +++ b/examples/serial-loopback/README.md @@ -11,6 +11,8 @@ The *Makefile* provided configures proper compilation flags. By default bitbanged UART implementation is used. To use hardware UART, run with `make` with `BITBANG=0`. +UART baudrate can be set using `BAUDRATE` *Makefile* variable. + ## UART Configuration UART implementation uses two statically allocated queues to store data, diff --git a/examples/serial-loopback/main.c b/examples/serial-loopback/main.c index 658933f..cc5811a 100644 --- a/examples/serial-loopback/main.c +++ b/examples/serial-loopback/main.c @@ -48,7 +48,7 @@ int main() { SYNCDELAY; FIFORESET = 0; // configure and start bitbang uart - uart_init(9600, UART_MODE_RX_TX); + uart_init(BAUDRATE, UART_MODE_RX_TX); // Re-enumerate, to make sure our descriptors are picked up correctly. usb_init(/*disconnect=*/true);