Skip to content

Commit

Permalink
increase default baud rate to 115200, add option to set baudrate
Browse files Browse the repository at this point in the history
  • Loading branch information
jedrzejboczar committed Jan 8, 2020
1 parent 0afcd90 commit 7548a73
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions examples/serial-cdc-loopback/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
2 changes: 2 additions & 0 deletions examples/serial-cdc-loopback/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
2 changes: 1 addition & 1 deletion examples/serial-cdc-loopback/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions examples/serial-loopback/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
2 changes: 2 additions & 0 deletions examples/serial-loopback/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion examples/serial-loopback/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 7548a73

Please sign in to comment.