Merge pull request #131 from g-oikonomou/contrib/tidy-up-slip-arch-init

Tidy-up slip_arch_init and all its side-effects
This commit is contained in:
Simon Duquennoy 2017-10-31 23:22:21 +01:00 committed by GitHub
commit 6ad790b202
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 15 additions and 202 deletions

View File

@ -1,51 +0,0 @@
/*
* Copyright (c) 2012, Texas Instruments Incorporated - http://www.ti.com/
* 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.
*/
/**
* \addtogroup cc2538-uart
* @{
*
* \file
* This file really only exists because some examples rely on it.
*
* For instance, some examples do uart1_set_input(f). We re-write this to
* uart_set_input
*/
#ifndef UART1_H_
#define UART1_H_
#include "dev/uart.h"
#define BAUD2UBR(x) x
#define uart1_set_input(f) uart_set_input(UART1_CONF_UART, f)
#endif /* UART1_H_ */
/** @} */

View File

@ -74,10 +74,9 @@ slip_arch_writeb(unsigned char c)
/*---------------------------------------------------------------------------*/
/**
* \brief Initialise the arch-specific SLIP driver
* \param ubr Ignored for the cc2538
*/
void
slip_arch_init(unsigned long ubr)
slip_arch_init()
{
set_input(slip_input_byte);
}

View File

@ -1,51 +0,0 @@
/*
* Copyright (c) 2012, Texas Instruments Incorporated - http://www.ti.com/
* 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.
*/
/**
* \addtogroup cc26xx-uart
* @{
*
* \file
* This file really only exists because some examples rely on it.
*
* For instance, some examples do uart1_set_input(f). We re-write this to
* uart_set_input
*/
#ifndef UART1_H_
#define UART1_H_
#include "dev/cc26xx-uart.h"
#define BAUD2UBR(x) x
#define uart1_set_input(f) cc26xx_uart_set_input(f)
#endif /* UART1_H_ */
/** @} */

View File

@ -53,10 +53,9 @@ slip_arch_writeb(unsigned char c)
/*---------------------------------------------------------------------------*/
/**
* \brief Initialise the arch-specific SLIP driver
* \param ubr Ignored for the cc26xx
*/
void
slip_arch_init(unsigned long ubr)
slip_arch_init()
{
/*
* Enable an input handler. In doing so, the driver will make sure that UART

View File

@ -46,7 +46,7 @@ slip_arch_writeb(unsigned char c)
*
*/
void
slip_arch_init(unsigned long ubr)
slip_arch_init()
{
uart0_set_input(slip_input_byte);
}

View File

@ -47,7 +47,7 @@ slip_arch_writeb(unsigned char c)
*
*/
void
slip_arch_init(unsigned long ubr)
slip_arch_init()
{
uart1_set_input(slip_input_byte);
}

View File

@ -1,31 +0,0 @@
/*
Copied from mc1322x/dev/cpu.
This file exists as a work-around for the hardware dependant calls
to slip_arch_init.
Current the prototype for slip_arch_init is slip_arch_init(urb)
and a typical call is something like
slip_arch_init(BAUD2URB(115200))
BAUD2UBR is hardware specific, however. Furthermore, for the sky
platform it's typically defined with #include "dev/uart1.h" (see
rpl-boarder-router/slip-bridge.c), a sky specific file. dev/uart1.h
includes msp430.h which includes the sky contiki-conf.h which
defines BAUD2UBR.
To me, the correct think to pass is simply the baudrate and have the
hardware specific conversion happen inside slip_arch_init.
Notably, most implementations just ignore the passed parameter
anyway. (except AVR)
*/
#ifndef DEV_UART1_H
#define DEV_UART1_H
#define BAUD2UBR(x) x
#endif

View File

@ -1,31 +0,0 @@
/*
Copied from mc1322x/dev/cpu.
This file exists as a work-around for the hardware dependant calls
to slip_arch_init.
Current the prototype for slip_arch_init is slip_arch_init(urb)
and a typical call is something like
slip_arch_init(BAUD2URB(115200))
BAUD2UBR is hardware specific, however. Furthermore, for the sky
platform it's typically defined with #include "dev/uart1.h" (see
rpl-boarder-router/slip-bridge.c), a sky specific file. dev/uart1.h
includes msp430.h which includes the sky contiki-conf.h which
defines BAUD2UBR.
To me, the correct think to pass is simply the baudrate and have the
hardware specific conversion happen inside slip_arch_init.
Notably, most implementations just ignore the passed parameter
anyway. (except AVR)
*/
#ifndef DEV_UART1_H
#define DEV_UART1_H
#define BAUD2UBR(x) x
#endif

View File

@ -32,7 +32,7 @@
#include "dev/rs232.h"
void
slip_arch_init(unsigned long ubr)
slip_arch_init()
{
rs232_set_input(slip_input_byte);
}

View File

@ -47,7 +47,7 @@ slip_arch_writeb(unsigned char c)
*
*/
void
slip_arch_init(unsigned long ubr)
slip_arch_init()
{
uart0_set_input(slip_input_byte);
}

View File

@ -181,10 +181,6 @@ typedef uint32_t rtimer_clock_t;
#define TSCH_DEBUG_SLOT_END()
#endif /* TSCH_DEBUG */
#ifndef BAUD2UBR
#define BAUD2UBR(X) (X)
#endif /* BAUD2UBR */
/* UART baud rates */
#define UART_RATE_4800 0
#define UART_RATE_9600 1

View File

@ -127,7 +127,7 @@ platform_init_stage_two(void)
#ifdef UART0_ENABLED
uart0_init();
#if SLIP_ARCH_CONF_ENABLE
slip_arch_init(0);
slip_arch_init();
#else
uart0_set_input(serial_line_input_byte);
serial_line_init();

View File

@ -53,10 +53,6 @@
#define DEBUG DEBUG_NONE
#include "net/ipv6/uip-debug.h"
#ifndef BAUD2UBR
#define BAUD2UBR(X) (X)
#endif
void set_prefix_64(uip_ipaddr_t *);
static uip_ipaddr_t last_sender;
@ -102,7 +98,7 @@ slip_input_callback(void)
static void
init(void)
{
slip_arch_init(BAUD2UBR(115200));
slip_arch_init();
process_start(&slip_process, NULL);
slip_set_input_callback(slip_input_callback);
}

View File

@ -53,10 +53,6 @@
#define DEBUG DEBUG_NONE
#include "net/ipv6/uip-debug.h"
#ifndef BAUD2UBR
#define BAUD2UBR(X) (X)
#endif
void set_prefix_64(uip_ipaddr_t *);
static uip_ipaddr_t last_sender;
@ -103,7 +99,7 @@ slip_input_callback(void)
static void
init(void)
{
slip_arch_init(BAUD2UBR(115200));
slip_arch_init();
process_start(&slip_process, NULL);
slip_set_input_callback(slip_input_callback);
}

View File

@ -53,10 +53,6 @@
#define DEBUG DEBUG_NONE
#include "net/ipv6/uip-debug.h"
#ifndef BAUD2UBR
#define BAUD2UBR(X) (X)
#endif
void set_prefix_64(uip_ipaddr_t *);
static uip_ipaddr_t last_sender;
@ -103,7 +99,7 @@ slip_input_callback(void)
static void
init(void)
{
slip_arch_init(BAUD2UBR(115200));
slip_arch_init();
process_start(&slip_process, NULL);
slip_set_input_callback(slip_input_callback);
}

View File

@ -41,7 +41,6 @@
#include "net/ipv6/uip.h"
#include "net/ipv6/uip-ds6.h"
#include "dev/slip.h"
#include "dev/uart1.h"
#include <string.h>
#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])
@ -95,7 +94,7 @@ slip_input_callback(void)
static void
init(void)
{
slip_arch_init(BAUD2UBR(115200));
slip_arch_init();
process_start(&slip_process, NULL);
slip_set_input_callback(slip_input_callback);
}

View File

@ -205,10 +205,7 @@ slip_input_callback(void)
static void
init(void)
{
#ifndef BAUD2UBR
#define BAUD2UBR(baud) baud
#endif
slip_arch_init(BAUD2UBR(115200));
slip_arch_init();
process_start(&slip_process, NULL);
slip_set_input_callback(slip_input_callback);
packet_pos = 0;

View File

@ -80,7 +80,7 @@ void slip_set_input_callback(void (*callback)(void));
* These machine dependent functions and an interrupt service routine
* must be provided externally (slip_arch.c).
*/
void slip_arch_init(unsigned long ubr);
void slip_arch_init(void);
void slip_arch_writeb(unsigned char c);
#endif /* SLIP_H_ */

View File

@ -110,7 +110,6 @@ static void
init(void)
{
PRINTF("ip64-slip-interface: init\n");
// slip_arch_init(BAUD2UBR(115200));
process_start(&slip_process, NULL);
slip_set_input_callback(input_callback);
}

View File

@ -86,7 +86,7 @@ void slip_set_tcpip_input_callback(void (*callback)(void));
* These machine dependent functions and an interrupt service routine
* must be provided externally (slip_arch.c).
*/
void slip_arch_init(unsigned long ubr);
void slip_arch_init(void);
void slip_arch_writeb(unsigned char c);
#endif /* SLIP_H_ */

View File

@ -117,7 +117,7 @@ PROCESS_THREAD(uip6_bridge, ev, data)
mac_ethernetSetup();
slip_arch_init(BAUD2UBR(115200));
slip_arch_init();
slip_set_input_callback(slip_activity);
slip_set_tcpip_input_callback(slip_tcpip_input);
process_start(&slip_process, NULL);