diff --git a/cpu/rl78/dev/uart1.h b/cpu/rl78/dev/uart1.h new file mode 100644 index 000000000..87d6d8d44 --- /dev/null +++ b/cpu/rl78/dev/uart1.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2014, Analog Devices, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +/** + * \author Ian Martin + * + * \file + * This file exists only because some examples rely on it. + */ + +#ifndef UART1_H +#define UART1_H + +#undef BAUD2UBR +#define BAUD2UBR(x) (x) + +#define uart1_set_input(f) uart0_set_input(f) + +#endif /* UART1_H */ diff --git a/cpu/rl78/uart0.c b/cpu/rl78/uart0.c index 6fa1e28a2..757df7aef 100644 --- a/cpu/rl78/uart0.c +++ b/cpu/rl78/uart0.c @@ -38,14 +38,13 @@ #include "uart0.h" -#define DESIRED_BAUDRATE 9600 -#define FUDGE_FACTOR 4 +#define DESIRED_BAUDRATE 38400 -/* Note that only 9600 and 115200 bps were tested: */ -#define PRESCALE_THRESH ((9600 + 115200) / 2) +/* Note that only 9600, 38400, and 115200 bps were tested. */ +#define PRESCALE_THRESH ((38400 + 115200) / 2) #define PRS_VALUE ((DESIRED_BAUDRATE < PRESCALE_THRESH) ? 4 : 0) -#define f_MCK (f_CLK / (1 << PRS_VALUE) / FUDGE_FACTOR) -#define SDR_VALUE ((f_MCK / DESIRED_BAUDRATE) >> 1) +#define f_MCK (f_CLK / (1 << PRS_VALUE)) +#define SDR_VALUE (f_MCK / DESIRED_BAUDRATE / 2 - 1) void uart0_init(void) diff --git a/platform/eval-adf7xxxmb4z/README.md b/platform/eval-adf7xxxmb4z/README.md index 821ec46a8..bcee2a5b8 100644 --- a/platform/eval-adf7xxxmb4z/README.md +++ b/platform/eval-adf7xxxmb4z/README.md @@ -38,7 +38,7 @@ Flash the example onto the eval board after ensuring that switch #2 of DIP switc rl78flash/rl78flash -vv -i -m3 /dev/ttyUSB0 -b500000 -a contiki/examples/rime/example-abc.eval-adf7xxxmb4z.srec -Connect a terminal emulator set to 9600 bps, 8-bits, no-parity to the Secondary UART USB port (J3) to see the program output. +Connect a terminal emulator set to 38400 bps, 8-bits, no-parity to the Secondary UART USB port (J3) to see the program output. ### IPv6 Web Server ### @@ -52,7 +52,7 @@ Build and run the SLIP tunnel on the host machine. Here it is assumed that the Secondary UART USB port (J3) is attached to /dev/ttyUSB1: make -C contiki/tools tunslip6 - sudo contiki/tools/tunslip6 -B 9600 -s /dev/ttyUSB1 -v3 aaaa::1/64 + sudo contiki/tools/tunslip6 -B 38400 -s /dev/ttyUSB1 -v3 aaaa::1/64 Open the border router home page at http://[aaaa::302:304:506:708]/ @@ -96,7 +96,7 @@ Flash the output file `example-abc.eval-adf7xxxmb4z.srec` using the [Renesas Flash Programmer](http://am.renesas.com/products/tools/flash_prom_programming/rfp) (registration required). -Connect a terminal emulator (e.g. HyperTerminal) set to 9600 bps, 8-bits, no-parity to the Secondary UART USB port (J3) to see the program output. +Connect a terminal emulator (e.g. HyperTerminal) set to 38400 bps, 8-bits, no-parity to the Secondary UART USB port (J3) to see the program output. ### Using IAR Embedded Workbench ### @@ -125,4 +125,4 @@ Flash the output file `example-abc.eval-adf7xxxmb4z.srec` using the [Renesas Flash Programmer](http://am.renesas.com/products/tools/flash_prom_programming/rfp) (registration required). -Connect a terminal emulator (e.g. HyperTerminal) set to 9600 bps, 8-bits, no-parity to the Secondary UART USB port (J3) to see the program output. +Connect a terminal emulator (e.g. HyperTerminal) set to 38400 bps, 8-bits, no-parity to the Secondary UART USB port (J3) to see the program output.