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
|
### CPU-dependent directories
|
||||||
CONTIKI_ARM_DIRS += . common/dbg-io
|
CONTIKI_ARM_DIRS += . common/dbg-io
|
||||||
CONTIKI_CPU_DIRS += . $(addprefix ../arm/, $(CPU_DIRS))
|
CONTIKI_CPU_DIRS += . $(addprefix ../arm/, $(CPU_DIRS))
|
||||||
CONTIKI_CPU_DIRS += source
|
CONTIKI_CPU_DIRS += dev
|
||||||
|
|
||||||
### CPU-dependent source files
|
### CPU-dependent source files
|
||||||
CONTIKI_CPU_SOURCEFILES += rtimer-arch.c clock-arch.c
|
CONTIKI_CPU_SOURCEFILES += rtimer-arch.c clock-arch.c
|
||||||
CONTIKI_CPU_SOURCEFILES += watchdog-arch.c putchar-arch.c
|
CONTIKI_CPU_SOURCEFILES += watchdog-arch.c putchar-arch.c
|
||||||
CONTIKI_CPU_SOURCEFILES += simplelink-uart.c
|
CONTIKI_CPU_SOURCEFILES += uart0-arch.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
|
|
||||||
|
|
||||||
|
### CPU-dependent debug source files
|
||||||
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)
|
CONTIKI_SOURCEFILES += $(CONTIKI_CPU_SOURCEFILES) $(DEBUG_IO_SOURCEFILES)
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "simplelink-uart.h"
|
#include "uart0-arch.h"
|
||||||
|
|
||||||
|
|
||||||
#undef putchar
|
#undef putchar
|
||||||
@ -41,7 +41,7 @@ int
|
|||||||
putchar(int c)
|
putchar(int c)
|
||||||
{
|
{
|
||||||
const unsigned char ch = (unsigned char)c;
|
const unsigned char ch = (unsigned char)c;
|
||||||
return (simplelink_uart_write(&ch, 1) == 1)
|
return (uart0_write(&ch, 1) == 1)
|
||||||
? (int)ch
|
? (int)ch
|
||||||
: EOF;
|
: EOF;
|
||||||
}
|
}
|
||||||
@ -49,7 +49,7 @@ putchar(int c)
|
|||||||
int
|
int
|
||||||
puts(const char *str)
|
puts(const char *str)
|
||||||
{
|
{
|
||||||
if(!str)
|
if(!str)
|
||||||
{
|
{
|
||||||
return EOF;
|
return EOF;
|
||||||
}
|
}
|
||||||
@ -57,8 +57,8 @@ puts(const char *str)
|
|||||||
const size_t len = strlen(str);
|
const size_t len = strlen(str);
|
||||||
const unsigned char newline = '\n';
|
const unsigned char newline = '\n';
|
||||||
|
|
||||||
if ((simplelink_uart_write(str, len) != len) &&
|
if ((uart0_write(str, len) != len) &&
|
||||||
(simplelink_uart_write(&newline, 1) != 1))
|
(uart0_write(&newline, 1) != 1))
|
||||||
{
|
{
|
||||||
return EOF;
|
return EOF;
|
||||||
}
|
}
|
||||||
@ -69,15 +69,15 @@ puts(const char *str)
|
|||||||
unsigned int
|
unsigned int
|
||||||
dbg_send_bytes(const unsigned char *s, unsigned int len)
|
dbg_send_bytes(const unsigned char *s, unsigned int len)
|
||||||
{
|
{
|
||||||
if(!s || strlen((const char *)s) < len)
|
if(!s || strlen((const char *)s) < len)
|
||||||
{
|
{
|
||||||
return EOF;
|
return EOF;
|
||||||
}
|
}
|
||||||
|
|
||||||
const unsigned char newline = '\n';
|
const unsigned char newline = '\n';
|
||||||
|
|
||||||
if ((simplelink_uart_write(s, len) != len) &&
|
if ((uart0_write(s, len) != len) &&
|
||||||
(simplelink_uart_write(&newline, 1) != 1))
|
(uart0_write(&newline, 1) != 1))
|
||||||
{
|
{
|
||||||
return EOF;
|
return EOF;
|
||||||
}
|
}
|
@ -41,38 +41,39 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "simplelink-uart.h"
|
#include "uart0-arch.h"
|
||||||
|
|
||||||
static UART_Handle gh_uart;
|
static UART_Handle gh_uart;
|
||||||
|
|
||||||
static volatile InputCb g_input_cb;
|
static volatile uart0_input_cb g_input_cb;
|
||||||
static unsigned char g_charbuf;
|
static unsigned char g_char_buf;
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static void
|
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; }
|
if (!g_input_cb) { return; }
|
||||||
|
|
||||||
const InputCb currCb = g_input_cb;
|
const uart0_input_cb currCb = g_input_cb;
|
||||||
currCb(g_charbuf);
|
currCb(g_char_buf);
|
||||||
if (currCb == g_input_cb)
|
if (currCb == g_input_cb)
|
||||||
{
|
{
|
||||||
UART_read(gh_uart, &g_charbuf, 1);
|
UART_read(gh_uart, &g_char_buf, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
simplelink_uart_init(void)
|
uart0_init(void)
|
||||||
{
|
{
|
||||||
UART_init();
|
UART_init();
|
||||||
|
|
||||||
UART_Params params;
|
UART_Params params;
|
||||||
UART_Params_init(¶ms);
|
UART_Params_init(¶ms);
|
||||||
params.readMode = UART_MODE_CALLBACK;
|
params.readMode = UART_MODE_CALLBACK;
|
||||||
params.writeMode = UART_MODE_BLOCKING ;
|
params.writeMode = UART_MODE_BLOCKING;
|
||||||
params.readCallback = uart_cb;
|
params.readCallback = uart0_cb;
|
||||||
// TODO configure
|
params.readDataMode = UART_DATA_TEXT;
|
||||||
|
params.readReturnMode = UART_RETURN_NEWLINE;
|
||||||
|
|
||||||
gh_uart = UART_open(Board_UART0, ¶ms);
|
gh_uart = UART_open(Board_UART0, ¶ms);
|
||||||
if (!gh_uart)
|
if (!gh_uart)
|
||||||
@ -82,7 +83,7 @@ simplelink_uart_init(void)
|
|||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
int_fast32_t
|
int_fast32_t
|
||||||
simplelink_uart_write(const void *buffer, size_t size)
|
uart0_write(const void *buffer, size_t size)
|
||||||
{
|
{
|
||||||
if (!gh_uart)
|
if (!gh_uart)
|
||||||
{
|
{
|
||||||
@ -92,18 +93,18 @@ simplelink_uart_write(const void *buffer, size_t size)
|
|||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
simplelink_uart_set_callback(InputCb input_cb)
|
uart0_set_callback(uart0_input_cb input_cb)
|
||||||
{
|
{
|
||||||
if (g_input_cb == input_cb) { return; }
|
if (g_input_cb == input_cb) { return; }
|
||||||
|
|
||||||
g_input_cb = input_cb;
|
g_input_cb = input_cb;
|
||||||
if (input_cb)
|
if (input_cb)
|
||||||
{
|
{
|
||||||
UART_read(gh_uart, &g_charbuf, 1);
|
UART_read(gh_uart, &g_char_buf, 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
UART_readCancel(gh_uart);
|
UART_readCancel(gh_uart);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
@ -39,12 +39,12 @@
|
|||||||
* \file
|
* \file
|
||||||
* Header file for the CC13xx/CC26xx UART driver
|
* Header file for the CC13xx/CC26xx UART driver
|
||||||
*/
|
*/
|
||||||
#ifndef SIMPLELINK_UART_H_
|
#ifndef UART0_ARCH_H_
|
||||||
#define SIMPLELINK_UART_H_
|
#define UART0_ARCH_H_
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
typedef void (*InputCb)(unsigned char);
|
typedef int (*uart0_input_cb)(unsigned char);
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/** \name UART functions
|
/** \name UART functions
|
||||||
@ -54,7 +54,7 @@ typedef void (*InputCb)(unsigned char);
|
|||||||
/**
|
/**
|
||||||
* \brief Initializes the UART driver
|
* \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.
|
* \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
|
* \return Number of bytes that has been written to the UART. If an
|
||||||
* error occurs, a negative value is returned.
|
* 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.
|
* \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
|
* \return Number of bytes that has been written to the buffer. If an
|
||||||
* error occurs, a negative value is returned.
|
* 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.h"
|
||||||
#include "contiki-net.h"
|
#include "contiki-net.h"
|
||||||
|
|
||||||
#include "simplelink-uart.h"
|
#include "uart0-arch.h"
|
||||||
|
|
||||||
//#include "leds.h"
|
//#include "leds.h"
|
||||||
//#include "lpm.h"
|
//#include "lpm.h"
|
||||||
@ -172,7 +172,7 @@ platform_init_stage_one()
|
|||||||
void
|
void
|
||||||
platform_init_stage_two()
|
platform_init_stage_two()
|
||||||
{
|
{
|
||||||
simplelink_uart_init();
|
uart0_init();
|
||||||
|
|
||||||
// random_init(0x1234);
|
// random_init(0x1234);
|
||||||
//
|
//
|
||||||
|
Loading…
Reference in New Issue
Block a user