parent
2cc74c5fd4
commit
1a0f01ccc4
|
@ -95,9 +95,10 @@
|
|||
|
||||
/* 192 ms, radio off -> on interval */
|
||||
#define ONOFF_TIME RTIMER_ARCH_SECOND / 3125
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if CC2530_RF_CONF_HEXDUMP
|
||||
#include "uart0.h"
|
||||
#include "dev/io-arch.h"
|
||||
static const uint8_t magic[] = { 0x53, 0x6E, 0x69, 0x66 }; /* Snif */
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -364,11 +365,11 @@ read(void *buf, unsigned short bufsize)
|
|||
|
||||
#if CC2530_RF_CONF_HEXDUMP
|
||||
/* If we reach here, chances are the FIFO is holding a valid frame */
|
||||
uart0_writeb(magic[0]);
|
||||
uart0_writeb(magic[1]);
|
||||
uart0_writeb(magic[2]);
|
||||
uart0_writeb(magic[3]);
|
||||
uart0_writeb(len);
|
||||
io_arch_writeb(magic[0]);
|
||||
io_arch_writeb(magic[1]);
|
||||
io_arch_writeb(magic[2]);
|
||||
io_arch_writeb(magic[3]);
|
||||
io_arch_writeb(len);
|
||||
#endif
|
||||
|
||||
RF_RX_LED_ON();
|
||||
|
@ -380,7 +381,7 @@ read(void *buf, unsigned short bufsize)
|
|||
for(i = 0; i < len; ++i) {
|
||||
((unsigned char*)(buf))[i] = RFD;
|
||||
#if CC2530_RF_CONF_HEXDUMP
|
||||
uart0_writeb(((unsigned char*)(buf))[i]);
|
||||
io_arch_writeb(((unsigned char*)(buf))[i]);
|
||||
#endif
|
||||
PUTHEX(((unsigned char*)(buf))[i]);
|
||||
}
|
||||
|
@ -391,8 +392,9 @@ read(void *buf, unsigned short bufsize)
|
|||
crc_corr = RFD;
|
||||
|
||||
#if CC2530_RF_CONF_HEXDUMP
|
||||
uart0_writeb(rssi);
|
||||
uart0_writeb(crc_corr);
|
||||
io_arch_writeb(rssi);
|
||||
io_arch_writeb(crc_corr);
|
||||
io_arch_flush();
|
||||
#endif
|
||||
|
||||
/* MS bit CRC OK/Not OK, 7 LS Bits, Correlation value */
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include "dev/serial-line.h"
|
||||
#include "dev/slip.h"
|
||||
#include "dev/leds.h"
|
||||
#include "dev/uart0.h"
|
||||
#include "dev/io-arch.h"
|
||||
#include "dev/dma.h"
|
||||
#include "dev/cc2530-rf.h"
|
||||
#include "dev/watchdog.h"
|
||||
|
@ -158,17 +158,16 @@ main(void) CC_NON_BANKED
|
|||
/* initialize process manager. */
|
||||
process_init();
|
||||
|
||||
/* Init UART */
|
||||
uart0_init();
|
||||
|
||||
#if DMA_ON
|
||||
dma_init();
|
||||
#endif
|
||||
|
||||
io_arch_init();
|
||||
|
||||
#if SLIP_ARCH_CONF_ENABLE
|
||||
slip_arch_init(0);
|
||||
#else
|
||||
uart0_set_input(serial_line_input_byte);
|
||||
io_arch_set_input(serial_line_input_byte);
|
||||
serial_line_init();
|
||||
#endif
|
||||
fade(LEDS_RED);
|
||||
|
|
84
platform/cc2530dk/dev/io-arch.h
Normal file
84
platform/cc2530dk/dev/io-arch.h
Normal file
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
* Copyright (c) 2012, George Oikonomou (oikonomou@users.sourceforge.net)
|
||||
* 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.
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Platform-specific header file which switches between UART and USB
|
||||
* input/output, depending on whether we are building for the
|
||||
* cc2531 USB dongle or the SmartRF
|
||||
*
|
||||
* These configuration directives are hardware-specific and you
|
||||
* normally won't have to modify anything in this file.
|
||||
*
|
||||
* \author
|
||||
* George Oikonomou - <oikonomou@users.sourceforge.net>
|
||||
*/
|
||||
|
||||
#ifndef IO_ARCH_H_
|
||||
#define IO_ARCH_H_
|
||||
|
||||
#include "contiki.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if MODEL_CC2531
|
||||
#include "dev/usb-serial.h"
|
||||
#define IO_ARCH_PREFIX usb_serial
|
||||
|
||||
/*
|
||||
* When using the cc2531 USB stick, we have the option to enable buffering
|
||||
* for USB-serial output. In this case, the driver will implicitly flush the
|
||||
* output when the TX buffer is full or when it encounters SLIP_END or '\n'.
|
||||
* We can trigger an explicit flush by calling io_arch_flush(). Naturally, this
|
||||
* does not make sense when our output uses the UART nor when buffering is
|
||||
* disabled, in which cases the calls are simply pre-processed to nothingness
|
||||
*/
|
||||
#define io_arch_flush() usb_serial_flush()
|
||||
#else
|
||||
#include "dev/uart0.h"
|
||||
#define IO_ARCH_PREFIX uart0
|
||||
#define io_arch_flush()
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Expands to uart0_init(), usb_serial_init() */
|
||||
#define io_arch_init() io_arch_init_x(IO_ARCH_PREFIX)
|
||||
#define io_arch_writeb(b) io_arch_writeb_x(IO_ARCH_PREFIX, b)
|
||||
#define io_arch_set_input(f) io_arch_set_input_x(IO_ARCH_PREFIX, f)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Second round of macro substitutions. You can stop reading here */
|
||||
#define io_arch_init_x(prefix) io_arch_init_x_x(prefix)
|
||||
#define io_arch_writeb_x(prefix, b) io_arch_writeb_x_x(prefix, b)
|
||||
#define io_arch_set_input_x(prefix, f) io_arch_set_input_x_x(prefix, f)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define io_arch_init_x_x(prefix) prefix##_init()
|
||||
#define io_arch_writeb_x_x(prefix, b) prefix##_writeb(b)
|
||||
#define io_arch_set_input_x_x(prefix, f) prefix##_set_input(f)
|
||||
|
||||
#endif /* IO_ARCH_H_ */
|
|
@ -29,21 +29,21 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Machine dependent cc2530eb SLIP routines for UART1.
|
||||
* Machine dependent cc253x SLIP routines.
|
||||
*/
|
||||
|
||||
#include "dev/slip.h"
|
||||
#include "dev/uart0.h"
|
||||
#include "dev/io-arch.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
slip_arch_writeb(unsigned char c)
|
||||
{
|
||||
uart0_writeb(c);
|
||||
io_arch_writeb(c);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
slip_arch_init(unsigned long ubr)
|
||||
{
|
||||
uart0_set_input(slip_input_byte);
|
||||
io_arch_set_input(slip_input_byte);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
#include "contiki-conf.h"
|
||||
#include "dev/uart0.h"
|
||||
#include "dev/io-arch.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
putchar(char c)
|
||||
|
@ -17,13 +17,13 @@ putchar(char c)
|
|||
static char debug_frame = 0;
|
||||
|
||||
if(!debug_frame) { /* Start of debug output */
|
||||
uart0_writeb(SLIP_END);
|
||||
uart0_writeb('\r'); /* Type debug line == '\r' */
|
||||
io_arch_writeb(SLIP_END);
|
||||
io_arch_writeb('\r'); /* Type debug line == '\r' */
|
||||
debug_frame = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
uart0_writeb((char)c);
|
||||
io_arch_writeb((char)c);
|
||||
|
||||
#if SLIP_ARCH_CONF_ENABLE
|
||||
/*
|
||||
|
@ -31,7 +31,7 @@ putchar(char c)
|
|||
* implicitly flushes debug output.
|
||||
*/
|
||||
if(c == '\n') {
|
||||
uart0_writeb(SLIP_END);
|
||||
io_arch_writeb(SLIP_END);
|
||||
debug_frame = 0;
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue