UART0 arch driver impl
* Async read * Renamed driver to uart0-arch * Renamed arch/cpu source folder to dev/
This commit is contained in:
parent
8f0b3fb49c
commit
2b0091246d
@ -55,19 +55,14 @@ endif
|
||||
### CPU-dependent directories
|
||||
CONTIKI_ARM_DIRS += . common/dbg-io
|
||||
CONTIKI_CPU_DIRS += . $(addprefix ../arm/, $(CPU_DIRS))
|
||||
CONTIKI_CPU_DIRS += source
|
||||
CONTIKI_CPU_DIRS += dev
|
||||
|
||||
### CPU-dependent source files
|
||||
CONTIKI_CPU_SOURCEFILES += rtimer-arch.c clock-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
|
||||
# CONTIKI_CPU_SOURCEFILES += gpio-interrupt.c oscillators.c
|
||||
# CONTIKI_CPU_SOURCEFILES += rf-core.c rf-ble.c ieee-mode.c
|
||||
# CONTIKI_CPU_SOURCEFILES += random.c soc-trng.c int-master.c
|
||||
CONTIKI_CPU_SOURCEFILES += uart0-arch.c
|
||||
|
||||
### CPU-dependent debug source files
|
||||
DEBUG_IO_SOURCEFILES += dbg-printf.c dbg-snprintf.c dbg-sprintf.c strformat.c
|
||||
|
||||
CONTIKI_SOURCEFILES += $(CONTIKI_CPU_SOURCEFILES) $(DEBUG_IO_SOURCEFILES)
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "simplelink-uart.h"
|
||||
#include "uart0-arch.h"
|
||||
|
||||
|
||||
#undef putchar
|
||||
@ -41,7 +41,7 @@ int
|
||||
putchar(int c)
|
||||
{
|
||||
const unsigned char ch = (unsigned char)c;
|
||||
return (simplelink_uart_write(&ch, 1) == 1)
|
||||
return (uart0_write(&ch, 1) == 1)
|
||||
? (int)ch
|
||||
: EOF;
|
||||
}
|
||||
@ -57,8 +57,8 @@ puts(const char *str)
|
||||
const size_t len = strlen(str);
|
||||
const unsigned char newline = '\n';
|
||||
|
||||
if ((simplelink_uart_write(str, len) != len) &&
|
||||
(simplelink_uart_write(&newline, 1) != 1))
|
||||
if ((uart0_write(str, len) != len) &&
|
||||
(uart0_write(&newline, 1) != 1))
|
||||
{
|
||||
return EOF;
|
||||
}
|
||||
@ -76,8 +76,8 @@ dbg_send_bytes(const unsigned char *s, unsigned int len)
|
||||
|
||||
const unsigned char newline = '\n';
|
||||
|
||||
if ((simplelink_uart_write(s, len) != len) &&
|
||||
(simplelink_uart_write(&newline, 1) != 1))
|
||||
if ((uart0_write(s, len) != len) &&
|
||||
(uart0_write(&newline, 1) != 1))
|
||||
{
|
||||
return EOF;
|
||||
}
|
@ -41,29 +41,29 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "simplelink-uart.h"
|
||||
#include "uart0-arch.h"
|
||||
|
||||
static UART_Handle gh_uart;
|
||||
|
||||
static volatile InputCb g_input_cb;
|
||||
static unsigned char g_charbuf;
|
||||
static volatile uart0_input_cb g_input_cb;
|
||||
static unsigned char g_char_buf;
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
uart_cb(UART_Handle handle, void *buf, size_t count)
|
||||
uart0_cb(UART_Handle handle, void *buf, size_t count)
|
||||
{
|
||||
if (!g_input_cb) { return; }
|
||||
|
||||
const InputCb currCb = g_input_cb;
|
||||
currCb(g_charbuf);
|
||||
const uart0_input_cb currCb = g_input_cb;
|
||||
currCb(g_char_buf);
|
||||
if (currCb == g_input_cb)
|
||||
{
|
||||
UART_read(gh_uart, &g_charbuf, 1);
|
||||
UART_read(gh_uart, &g_char_buf, 1);
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
simplelink_uart_init(void)
|
||||
uart0_init(void)
|
||||
{
|
||||
UART_init();
|
||||
|
||||
@ -71,8 +71,9 @@ simplelink_uart_init(void)
|
||||
UART_Params_init(¶ms);
|
||||
params.readMode = UART_MODE_CALLBACK;
|
||||
params.writeMode = UART_MODE_BLOCKING;
|
||||
params.readCallback = uart_cb;
|
||||
// TODO configure
|
||||
params.readCallback = uart0_cb;
|
||||
params.readDataMode = UART_DATA_TEXT;
|
||||
params.readReturnMode = UART_RETURN_NEWLINE;
|
||||
|
||||
gh_uart = UART_open(Board_UART0, ¶ms);
|
||||
if (!gh_uart)
|
||||
@ -82,7 +83,7 @@ simplelink_uart_init(void)
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int_fast32_t
|
||||
simplelink_uart_write(const void *buffer, size_t size)
|
||||
uart0_write(const void *buffer, size_t size)
|
||||
{
|
||||
if (!gh_uart)
|
||||
{
|
||||
@ -92,14 +93,14 @@ simplelink_uart_write(const void *buffer, size_t size)
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
simplelink_uart_set_callback(InputCb input_cb)
|
||||
uart0_set_callback(uart0_input_cb input_cb)
|
||||
{
|
||||
if (g_input_cb == input_cb) { return; }
|
||||
|
||||
g_input_cb = input_cb;
|
||||
if (input_cb)
|
||||
{
|
||||
UART_read(gh_uart, &g_charbuf, 1);
|
||||
UART_read(gh_uart, &g_char_buf, 1);
|
||||
}
|
||||
else
|
||||
{
|
@ -39,12 +39,12 @@
|
||||
* \file
|
||||
* Header file for the CC13xx/CC26xx UART driver
|
||||
*/
|
||||
#ifndef SIMPLELINK_UART_H_
|
||||
#define SIMPLELINK_UART_H_
|
||||
#ifndef UART0_ARCH_H_
|
||||
#define UART0_ARCH_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef void (*InputCb)(unsigned char);
|
||||
typedef int (*uart0_input_cb)(unsigned char);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** \name UART functions
|
||||
@ -54,7 +54,7 @@ typedef void (*InputCb)(unsigned char);
|
||||
/**
|
||||
* \brief Initializes the UART driver
|
||||
*/
|
||||
void simplelink_uart_init(void);
|
||||
void uart0_init(void);
|
||||
|
||||
/**
|
||||
* \brief Writes data from a memory buffer to the UART interface.
|
||||
@ -63,7 +63,7 @@ void simplelink_uart_init(void);
|
||||
* \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);
|
||||
int_fast32_t uart0_write(const void *buffer, size_t size);
|
||||
|
||||
/**
|
||||
* \brief Reads data from the UART interface to a memory buffer.
|
||||
@ -72,11 +72,11 @@ int_fast32_t simplelink_uart_write(const void *buffer, size_t size);
|
||||
* \return Number of bytes that has been written to the buffer. If an
|
||||
* error occurs, a negative value is returned.
|
||||
*/
|
||||
void simplelink_uart_set_callback(InputCb input_cb);
|
||||
void uart0_set_callback(uart0_input_cb input_cb);
|
||||
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* SIMPLELINK_UART_H_ */
|
||||
#endif /* UART0_ARCH_H_ */
|
||||
|
||||
/**
|
||||
* @}
|
@ -55,7 +55,7 @@
|
||||
#include "contiki.h"
|
||||
#include "contiki-net.h"
|
||||
|
||||
#include "simplelink-uart.h"
|
||||
#include "uart0-arch.h"
|
||||
|
||||
//#include "leds.h"
|
||||
//#include "lpm.h"
|
||||
@ -172,7 +172,7 @@ platform_init_stage_one()
|
||||
void
|
||||
platform_init_stage_two()
|
||||
{
|
||||
simplelink_uart_init();
|
||||
uart0_init();
|
||||
|
||||
// random_init(0x1234);
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user