Added UART serial interface printing

This commit is contained in:
Edvard Pettersen 2018-02-07 16:58:16 +01:00
parent 765e35ba7f
commit c8023df8a5
8 changed files with 385 additions and 26 deletions

View File

@ -29,7 +29,7 @@ CFLAGS += -I$(SDK_KERNEL)/posix
LDFLAGS += --entry resetISR
LDFLAGS += -static
LDFLAGS += --specs=nano.specs
LDFLAGS += -Wl,--defsym=_stack_origin=_stack
LDFLAGS += -Wl,--defsym=_stack_origin=__stack
LDFLAGS += -Wl,--defsym=_heap=__heap_start__
LDFLAGS += -Wl,--defsym=_eheap=__heap_end__
@ -59,7 +59,8 @@ CONTIKI_CPU_DIRS += source
### CPU-dependent source files
CONTIKI_CPU_SOURCEFILES += rtimer-arch.c clock-arch.c
CONTIKI_CPU_SOURCEFILES += watchdog-arch.c
CONTIKI_CPU_SOURCEFILES += watchdog-arch.c putchar-arch.c
CONTIKI_CPU_SOURCEFILES += simplelink-uart.c
# CONTIKI_CPU_SOURCEFILES += contiki-watchdog.c aux-ctrl.c
# CONTIKI_CPU_SOURCEFILES += putchar.c ieee-addr.c batmon-sensor.c adc-sensor.c
# CONTIKI_CPU_SOURCEFILES += slip-arch.c slip.c cc26xx-uart.c lpm.c
@ -67,7 +68,7 @@ CONTIKI_CPU_SOURCEFILES += watchdog-arch.c
# CONTIKI_CPU_SOURCEFILES += rf-core.c rf-ble.c ieee-mode.c
# CONTIKI_CPU_SOURCEFILES += random.c soc-trng.c int-master.c
# DEBUG_IO_SOURCEFILES += dbg-printf.c dbg-snprintf.c dbg-sprintf.c strformat.c
DEBUG_IO_SOURCEFILES += dbg-printf.c dbg-snprintf.c dbg-sprintf.c strformat.c
CONTIKI_SOURCEFILES += $(CONTIKI_CPU_SOURCEFILES) $(DEBUG_IO_SOURCEFILES)

View File

@ -0,0 +1,65 @@
/*
* Copyright (c) 2014, 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
* @{
*
* \defgroup cc26xx-char-io CC13xx/CC26xx Character I/O
*
* CC13xx/CC26xx CPU-specific functions for debugging and SLIP I/O
* @{
*
* \file
* Header file for the CC13xx/CC26xx Debug I/O module
*/
#ifndef DBG_H_
#define DBG_H_
/*---------------------------------------------------------------------------*/
#include "contiki.h"
/*---------------------------------------------------------------------------*/
/**
* \brief Print a stream of bytes
* \param seq A pointer to the stream
* \param len The number of bytes to print
* \return The number of printed bytes
*
* This function is an arch-specific implementation required by the dbg-io
* API in cpu/arm/common/dbg-io. It prints a stream of bytes over the
* peripheral used by the platform.
*/
unsigned int dbg_send_bytes(const unsigned char *seq, unsigned int len);
/*---------------------------------------------------------------------------*/
#endif /* DBG_H_ */
/*---------------------------------------------------------------------------*/
/**
* @}
* @}
*/

View File

@ -0,0 +1,49 @@
/*
* 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-char-io
* @{
*
* \file
* This file is here because DBG I/O expects it to be. It just includes
* our own dbg.h which has a non-misleading name and which also adheres
* to Contiki's naming convention
*/
/*---------------------------------------------------------------------------*/
#ifndef DEBUG_UART_H_
#define DEBUG_UART_H_
/*---------------------------------------------------------------------------*/
#include "dbg.h"
/*---------------------------------------------------------------------------*/
#endif /* DEBUG_UART_H_ */
/*---------------------------------------------------------------------------*/
/** @} */

View File

@ -0,0 +1,87 @@
/*
* Copyright (c) 2014, 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.
*/
/*---------------------------------------------------------------------------*/
#include <stdio.h>
#include <string.h>
#include "simplelink-uart.h"
#undef putchar
#undef puts
/*---------------------------------------------------------------------------*/
int
putchar(int c)
{
const unsigned char ch = (unsigned char)c;
return (simplelink_uart_write(&ch, 1) == 1)
? (int)ch
: EOF;
}
/*---------------------------------------------------------------------------*/
int
puts(const char *str)
{
if(!str)
{
return EOF;
}
const size_t len = strlen(str);
const unsigned char newline = '\n';
if ((simplelink_uart_write(str, len) != len) &&
(simplelink_uart_write(&newline, 1) != 1))
{
return EOF;
}
return len + 1;
}
/*---------------------------------------------------------------------------*/
unsigned int
dbg_send_bytes(const unsigned char *s, unsigned int len)
{
if(!s || strlen((const char *)s) < len)
{
return EOF;
}
const unsigned char newline = '\n';
if ((simplelink_uart_write(s, len) != len) &&
(simplelink_uart_write(&newline, 1) != 1))
{
return EOF;
}
return len + 1;
}
/*---------------------------------------------------------------------------*/

View File

@ -106,7 +106,7 @@ rtimer_arch_init(void)
volatile IsrFxn * const pfnRAMVectors = (volatile IsrFxn *)(HWREG(NVIC_VTABLE));
if (!pfnRAMVectors)
{
while (0) { /* hang */ }
for (;;) { /* hang */ }
}
// The HWI Dispatch ISR should be located at int num INT_AON_RTC_COMB.
@ -114,7 +114,7 @@ rtimer_arch_init(void)
hwiDispatch = (HwiDispatchFxn)pfnRAMVectors[INT_AON_RTC_COMB];
if (!hwiDispatch)
{
while (0) { /* hang */ }
for (;;) { /* hang */ }
}
// Override the INT_AON_RTC_COMB int num with own ISR hook

View File

@ -0,0 +1,82 @@
/*
* Copyright (c) 2014, 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
* Implementation of the CC13xx/CC26xx UART driver.
*/
/*---------------------------------------------------------------------------*/
#include <Board.h>
#include <ti/drivers/UART.h>
#include <stdint.h>
static UART_Handle hUart;
/*---------------------------------------------------------------------------*/
void
simplelink_uart_init(void)
{
UART_init();
UART_Params params;
UART_Params_init(&params);
// TODO configure
hUart = UART_open(Board_UART0, &params);
if (!hUart)
{
for (;;) { /* hang */ }
}
}
/*---------------------------------------------------------------------------*/
int_fast32_t
simplelink_uart_write(const void *buffer, size_t size)
{
if (!hUart)
{
return UART_STATUS_ERROR;
}
return UART_write(hUart, buffer, size);
}
/*---------------------------------------------------------------------------*/
int_fast32_t
simplelink_uart_read(void *buffer, size_t size)
{
if (!hUart)
{
return UART_STATUS_ERROR;
}
return UART_read(hUart, buffer, size);
}
/*---------------------------------------------------------------------------*/
/** @} */

View File

@ -0,0 +1,82 @@
/*
* Copyright (c) 2014, 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
* @{
*
* \defgroup cc26xx-uart CC13xx/CC26xx UARTs
*
* Driver for the CC13xx/CC26xx UART controller
* @{
*
* \file
* Header file for the CC13xx/CC26xx UART driver
*/
#ifndef SIMPLELINK_UART_H_
#define SIMPLELINK_UART_H_
#include <stdint.h>
/*---------------------------------------------------------------------------*/
/** \name UART functions
* @{
*/
/**
* \brief Initializes the UART driver
*/
void simplelink_uart_init(void);
/**
* \brief Writes data from a memory buffer to the UART interface.
* \param buffer A pointer to the data buffer.
* \param size Size of the data buffer.
* \return Number of bytes that has been written to the UART. If an
* error occurs, a negative value is returned.
*/
int_fast32_t simplelink_uart_write(const void *buffer, size_t size);
/**
* \brief Reads data from the UART interface to a memory buffer.
* \param buffer A pointer to the data buffer.
* \param size Number of bytes to read
* \return Number of bytes that has been written to the buffer. If an
* error occurs, a negative value is returned.
*/
int_fast32_t simplelink_uart_read(void *buffer, size_t size);
/** @} */
/*---------------------------------------------------------------------------*/
#endif /* SIMPLELINK_UART_H_ */
/**
* @}
* @}
*/

View File

@ -29,29 +29,31 @@
*/
/*---------------------------------------------------------------------------*/
/**
* \addtogroup cc26xx-platforms
* \addtogroup cc13xx-cc26xx-platforms
* @{
*
* \defgroup cc26xx-srf-tag SmartRF+CC13xx/CC26xx EM, SensorTags and LaunchPads
* \defgroup LaunchPads
*
* This platform supports a number of different boards:
* - A standard TI SmartRF06EB with a CC26xx EM mounted on it
* - A standard TI SmartRF06EB with a CC1310 EM mounted on it
* - The TI CC2650 SensorTag
* - The TI CC1350 SensorTag
* - The TI CC2650 LaunchPad
* - The TI CC1310 LaunchPad
* - The TI CC1350 LaunchPad
* - The TI CC2640 LaunchPad
* - The TI CC2650 LaunchPad
* - The TI CC1312R1 LaunchPad
* - The TI CC1352R1 LaunchPad
* - The TI CC1352P1 LaunchPad
* - The TI CC26X2R1 LaunchPad
* @{
*/
#include "contiki.h"
#include "contiki-net.h"
#include <Board.h>
#include <ti/drivers/GPIO.h>
#include <ti/drivers/Power.h>
#include <NoRTOS.h>
#include "contiki.h"
#include "contiki-net.h"
#include "simplelink-uart.h"
//#include "leds.h"
//#include "lpm.h"
@ -85,7 +87,7 @@
/*---------------------------------------------------------------------------*/
unsigned short node_id = 0;
/*---------------------------------------------------------------------------*/
/** \brief Board specific iniatialisation */
/** \brief Board specific initialization */
void board_init(void);
/*---------------------------------------------------------------------------*/
static void
@ -169,16 +171,10 @@ platform_init_stage_one()
void
platform_init_stage_two()
{
GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_OFF);
GPIO_write(Board_GPIO_LED1, Board_GPIO_LED_ON);
simplelink_uart_init();
// random_init(0x1234);
//
// /* Character I/O Initialisation */
//#if CC26XX_UART_CONF_ENABLE
// cc26xx_uart_init();
//#endif
//
// serial_line_init();
//
// /* Populate linkaddr_node_addr */
@ -190,9 +186,6 @@ platform_init_stage_two()
void
platform_init_stage_three()
{
GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_ON);
GPIO_write(Board_GPIO_LED1, Board_GPIO_LED_ON);
// radio_value_t chan, pan;
//
// set_rf_params();