otInstance Declarations (#473)

* Add otInstance type declaration and update ot APIs to take it as input.
This commit is contained in:
Nick Banks
2016-09-12 14:29:43 -07:00
committed by Jonathan Hui
parent 9b1de7bbb2
commit ffbe65c6dd
67 changed files with 1560 additions and 1099 deletions
+8 -8
View File
@@ -51,17 +51,17 @@ namespace Cli {
static const char sCommandPrompt[] = {'>', ' '};
static const char sEraseString[] = {'\b', ' ', '\b'};
static const char CRNL[] = {'\r', '\n'};
static Uart *sServer;
Uart *Uart::sUartServer;
static otDEFINE_ALIGNED_VAR(sCliUartRaw, sizeof(Uart), uint64_t);
extern "C" void otCliUartInit(void)
extern "C" void otCliUartInit(otInstance *aInstance)
{
sServer = new(&sCliUartRaw) Uart;
Interpreter::Init();
Uart::sUartServer = new(&sCliUartRaw) Uart(aInstance);
}
Uart::Uart(void)
Uart::Uart(otInstance *aInstance):
mInterpreter(aInstance)
{
mRxLength = 0;
mTxHead = 0;
@@ -71,7 +71,7 @@ Uart::Uart(void)
extern "C" void otPlatUartReceived(const uint8_t *aBuf, uint16_t aBufLength)
{
sServer->ReceiveTask(aBuf, aBufLength);
Uart::sUartServer->ReceiveTask(aBuf, aBufLength);
}
void Uart::ReceiveTask(const uint8_t *aBuf, uint16_t aBufLength)
@@ -137,7 +137,7 @@ ThreadError Uart::ProcessCommand(void)
mRxBuffer[--mRxLength] = '\0';
}
Interpreter::ProcessLine(mRxBuffer, mRxLength, *this);
mInterpreter.ProcessLine(mRxBuffer, mRxLength, *this);
mRxLength = 0;
@@ -202,7 +202,7 @@ exit:
extern "C" void otPlatUartSendDone(void)
{
sServer->SendDoneTask();
Uart::sUartServer->SendDoneTask();
}
void Uart::SendDoneTask(void)