Merge pull request #534 from hexluthor/rl78-fixes
UART-related fixes for Renesas RL78
This commit is contained in:
commit
3724c01637
46
cpu/rl78/dev/uart1.h
Normal file
46
cpu/rl78/dev/uart1.h
Normal file
|
@ -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 <martini@redwirellc.com>
|
||||||
|
*
|
||||||
|
* \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 */
|
|
@ -38,14 +38,13 @@
|
||||||
|
|
||||||
#include "uart0.h"
|
#include "uart0.h"
|
||||||
|
|
||||||
#define DESIRED_BAUDRATE 9600
|
#define DESIRED_BAUDRATE 38400
|
||||||
#define FUDGE_FACTOR 4
|
|
||||||
|
|
||||||
/* Note that only 9600 and 115200 bps were tested: */
|
/* Note that only 9600, 38400, and 115200 bps were tested. */
|
||||||
#define PRESCALE_THRESH ((9600 + 115200) / 2)
|
#define PRESCALE_THRESH ((38400 + 115200) / 2)
|
||||||
#define PRS_VALUE ((DESIRED_BAUDRATE < PRESCALE_THRESH) ? 4 : 0)
|
#define PRS_VALUE ((DESIRED_BAUDRATE < PRESCALE_THRESH) ? 4 : 0)
|
||||||
#define f_MCK (f_CLK / (1 << PRS_VALUE) / FUDGE_FACTOR)
|
#define f_MCK (f_CLK / (1 << PRS_VALUE))
|
||||||
#define SDR_VALUE ((f_MCK / DESIRED_BAUDRATE) >> 1)
|
#define SDR_VALUE (f_MCK / DESIRED_BAUDRATE / 2 - 1)
|
||||||
|
|
||||||
void
|
void
|
||||||
uart0_init(void)
|
uart0_init(void)
|
||||||
|
|
|
@ -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
|
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 ###
|
### 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:
|
Here it is assumed that the Secondary UART USB port (J3) is attached to /dev/ttyUSB1:
|
||||||
|
|
||||||
make -C contiki/tools tunslip6
|
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]/
|
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)
|
[Renesas Flash Programmer](http://am.renesas.com/products/tools/flash_prom_programming/rfp)
|
||||||
(registration required).
|
(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 ###
|
### 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)
|
[Renesas Flash Programmer](http://am.renesas.com/products/tools/flash_prom_programming/rfp)
|
||||||
(registration required).
|
(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.
|
||||||
|
|
Loading…
Reference in a new issue