mirror of
https://github.com/espressif/openthread.git
synced 2026-09-14 05:00:11 +00:00
Rename otPlatSerial* to otPlatUart*. (#253)
This commit is contained in:
@@ -41,7 +41,7 @@ libopenthread_cc2538_a_SOURCES = \
|
||||
platform.c \
|
||||
radio.c \
|
||||
random.c \
|
||||
serial.c \
|
||||
uart.c \
|
||||
startup-gcc.c \
|
||||
$(NULL)
|
||||
|
||||
|
||||
@@ -70,9 +70,9 @@ void cc2538RadioProcess(void);
|
||||
void cc2538RandomInit(void);
|
||||
|
||||
/**
|
||||
* This function performs radio driver processing.
|
||||
* This function performs UART driver processing.
|
||||
*
|
||||
*/
|
||||
void cc2538SerialProcess(void);
|
||||
void cc2538UartProcess(void);
|
||||
|
||||
#endif // PLATFORM_CC2538_H_
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
* This file includes the platform-specific initializers.
|
||||
*/
|
||||
|
||||
#include <platform/serial.h>
|
||||
#include <platform/uart.h>
|
||||
#include "platform-cc2538.h"
|
||||
|
||||
void PlatformInit(int argc, char *argv[])
|
||||
@@ -40,14 +40,14 @@ void PlatformInit(int argc, char *argv[])
|
||||
cc2538AlarmInit();
|
||||
cc2538RadioInit();
|
||||
cc2538RandomInit();
|
||||
otPlatSerialEnable();
|
||||
otPlatUartEnable();
|
||||
}
|
||||
|
||||
void PlatformProcessDrivers(void)
|
||||
{
|
||||
// should sleep and wait for interrupts here
|
||||
|
||||
cc2538SerialProcess();
|
||||
cc2538UartProcess();
|
||||
cc2538RadioProcess();
|
||||
cc2538AlarmProcess();
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* This file implements the OpenThread platform abstraction for serial communication.
|
||||
* This file implements the OpenThread platform abstraction for UART communication.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
#include <openthread-types.h>
|
||||
#include <common/code_utils.hpp>
|
||||
#include <platform/serial.h>
|
||||
#include <platform/uart.h>
|
||||
#include "platform-cc2538.h"
|
||||
|
||||
enum
|
||||
@@ -58,7 +58,7 @@ static uint8_t sReceiveBuffer[kReceiveBufferSize];
|
||||
static uint16_t sReceiveHead = 0;
|
||||
static uint16_t sReceiveLength = 0;
|
||||
|
||||
ThreadError otPlatSerialEnable(void)
|
||||
ThreadError otPlatUartEnable(void)
|
||||
{
|
||||
uint32_t div;
|
||||
|
||||
@@ -99,12 +99,12 @@ ThreadError otPlatSerialEnable(void)
|
||||
return kThreadError_None;
|
||||
}
|
||||
|
||||
ThreadError otPlatSerialDisable(void)
|
||||
ThreadError otPlatUartDisable(void)
|
||||
{
|
||||
return kThreadError_None;
|
||||
}
|
||||
|
||||
ThreadError otPlatSerialSend(const uint8_t *aBuf, uint16_t aBufLength)
|
||||
ThreadError otPlatUartSend(const uint8_t *aBuf, uint16_t aBufLength)
|
||||
{
|
||||
ThreadError error = kThreadError_None;
|
||||
|
||||
@@ -127,14 +127,14 @@ void processReceive(void)
|
||||
|
||||
if (sReceiveLength >= remaining)
|
||||
{
|
||||
otPlatSerialReceived(sReceiveBuffer + sReceiveHead, remaining);
|
||||
otPlatUartReceived(sReceiveBuffer + sReceiveHead, remaining);
|
||||
sReceiveHead = 0;
|
||||
sReceiveLength -= remaining;
|
||||
}
|
||||
|
||||
if (sReceiveLength > 0)
|
||||
{
|
||||
otPlatSerialReceived(sReceiveBuffer + sReceiveHead, sReceiveLength);
|
||||
otPlatUartReceived(sReceiveBuffer + sReceiveHead, sReceiveLength);
|
||||
sReceiveHead += sReceiveLength;
|
||||
sReceiveLength = 0;
|
||||
}
|
||||
@@ -155,13 +155,13 @@ void processTransmit(void)
|
||||
}
|
||||
|
||||
sTransmitBuffer = NULL;
|
||||
otPlatSerialSendDone();
|
||||
otPlatUartSendDone();
|
||||
|
||||
exit:
|
||||
return;
|
||||
}
|
||||
|
||||
void cc2538SerialProcess(void)
|
||||
void cc2538UartProcess(void)
|
||||
{
|
||||
processReceive();
|
||||
processTransmit();
|
||||
@@ -42,7 +42,7 @@ libopenthread_posix_a_SOURCES = \
|
||||
platform.c \
|
||||
radio.c \
|
||||
random.c \
|
||||
serial.c \
|
||||
uart.c \
|
||||
$(NULL)
|
||||
|
||||
noinst_HEADERS = \
|
||||
|
||||
@@ -100,19 +100,19 @@ void posixRadioProcess(void);
|
||||
void posixRandomInit(void);
|
||||
|
||||
/**
|
||||
* This function updates the file descriptor sets with file descriptors used by the serial driver.
|
||||
* This function updates the file descriptor sets with file descriptors used by the UART driver.
|
||||
*
|
||||
* @param[inout] aReadFdSet A pointer to the read file descriptors.
|
||||
* @param[inout] aWriteFdSet A pointer to the write file descriptors.
|
||||
* @param[inout] aMaxFd A pointer to the max file descriptor.
|
||||
*
|
||||
*/
|
||||
void posixSerialUpdateFdSet(fd_set *aReadFdSet, fd_set *aWriteFdSet, int *aMaxFd);
|
||||
void posixUartUpdateFdSet(fd_set *aReadFdSet, fd_set *aWriteFdSet, int *aMaxFd);
|
||||
|
||||
/**
|
||||
* This function performs radio driver processing.
|
||||
*
|
||||
*/
|
||||
void posixSerialProcess(void);
|
||||
void posixUartProcess(void);
|
||||
|
||||
#endif // PLATFORM_POSIX_H_
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
|
||||
#include <openthread.h>
|
||||
#include <platform/alarm.h>
|
||||
#include <platform/serial.h>
|
||||
#include <platform/uart.h>
|
||||
#include "platform-posix.h"
|
||||
|
||||
uint32_t NODE_ID = 1;
|
||||
@@ -59,7 +59,7 @@ void PlatformInit(int argc, char *argv[])
|
||||
posixAlarmInit();
|
||||
posixRadioInit();
|
||||
posixRandomInit();
|
||||
otPlatSerialEnable();
|
||||
otPlatUartEnable();
|
||||
}
|
||||
|
||||
void PlatformProcessDrivers(void)
|
||||
@@ -73,7 +73,7 @@ void PlatformProcessDrivers(void)
|
||||
FD_ZERO(&read_fds);
|
||||
FD_ZERO(&write_fds);
|
||||
|
||||
posixSerialUpdateFdSet(&read_fds, &write_fds, &max_fd);
|
||||
posixUartUpdateFdSet(&read_fds, &write_fds, &max_fd);
|
||||
posixRadioUpdateFdSet(&read_fds, &write_fds, &max_fd);
|
||||
posixAlarmUpdateTimeout(&timeout);
|
||||
|
||||
@@ -83,7 +83,7 @@ void PlatformProcessDrivers(void)
|
||||
assert(rval >= 0 && errno != ETIME);
|
||||
}
|
||||
|
||||
posixSerialProcess();
|
||||
posixUartProcess();
|
||||
posixRadioProcess();
|
||||
posixAlarmProcess();
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include <common/code_utils.hpp>
|
||||
#include <platform/serial.h>
|
||||
#include <platform/uart.h>
|
||||
#include "platform-posix.h"
|
||||
|
||||
#ifdef OPENTHREAD_TARGET_LINUX
|
||||
@@ -64,7 +64,7 @@ static void restore_stdout_termios(void)
|
||||
tcsetattr(s_out_fd, TCSAFLUSH, &original_stdout_termios);
|
||||
}
|
||||
|
||||
ThreadError otPlatSerialEnable(void)
|
||||
ThreadError otPlatUartEnable(void)
|
||||
{
|
||||
ThreadError error = kThreadError_None;
|
||||
struct termios termios;
|
||||
@@ -140,7 +140,7 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
ThreadError otPlatSerialDisable(void)
|
||||
ThreadError otPlatUartDisable(void)
|
||||
{
|
||||
ThreadError error = kThreadError_None;
|
||||
|
||||
@@ -150,7 +150,7 @@ ThreadError otPlatSerialDisable(void)
|
||||
return error;
|
||||
}
|
||||
|
||||
ThreadError otPlatSerialSend(const uint8_t *aBuf, uint16_t aBufLength)
|
||||
ThreadError otPlatUartSend(const uint8_t *aBuf, uint16_t aBufLength)
|
||||
{
|
||||
ThreadError error = kThreadError_None;
|
||||
|
||||
@@ -163,7 +163,7 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
void posixSerialUpdateFdSet(fd_set *aReadFdSet, fd_set *aWriteFdSet, int *aMaxFd)
|
||||
void posixUartUpdateFdSet(fd_set *aReadFdSet, fd_set *aWriteFdSet, int *aMaxFd)
|
||||
{
|
||||
if (aReadFdSet != NULL)
|
||||
{
|
||||
@@ -186,7 +186,7 @@ void posixSerialUpdateFdSet(fd_set *aReadFdSet, fd_set *aWriteFdSet, int *aMaxFd
|
||||
}
|
||||
}
|
||||
|
||||
void posixSerialProcess(void)
|
||||
void posixUartProcess(void)
|
||||
{
|
||||
const int flags = POLLRDNORM | POLLERR | POLLNVAL | POLLHUP;
|
||||
struct pollfd pollfd = { s_in_fd, flags, 0 };
|
||||
@@ -196,7 +196,7 @@ void posixSerialProcess(void)
|
||||
{
|
||||
rval = read(s_in_fd, s_receive_buffer, sizeof(s_receive_buffer));
|
||||
assert(rval >= 0);
|
||||
otPlatSerialReceived(s_receive_buffer, rval);
|
||||
otPlatUartReceived(s_receive_buffer, rval);
|
||||
}
|
||||
|
||||
if (s_write_length > 0)
|
||||
@@ -204,6 +204,6 @@ void posixSerialProcess(void)
|
||||
rval = write(s_out_fd, s_write_buffer, s_write_length);
|
||||
assert(rval >= 0);
|
||||
s_write_length = 0;
|
||||
otPlatSerialSendDone();
|
||||
otPlatUartSendDone();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user