Change API to require all calls be from the same context. (#78)

* Remove atomic driver and all uses of otPlatAtomic* in OpenThread.
* Change posix example to only use a single thread of execution.
This commit is contained in:
Jonathan Hui
2016-05-27 09:16:04 -07:00
parent 21e0e8aa92
commit 7d2e4a0267
26 changed files with 410 additions and 591 deletions
-1
View File
@@ -29,7 +29,6 @@
include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
include_HEADERS = \
atomic.h \
alarm.h \
logging.h \
radio.h \
+2 -2
View File
@@ -71,7 +71,7 @@ void otPlatAlarmStartAt(uint32_t aT0, uint32_t aDt);
void otPlatAlarmStop(void);
/**
* Get the current current time.
* Get the current time.
*
* @returns The current time in milliseconds.
*/
@@ -80,7 +80,7 @@ uint32_t otPlatAlarmGetNow(void);
/**
* Signal that the alarm has fired.
*/
extern void otPlatAlarmSignalFired(void);
extern void otPlatAlarmFired(void);
/**
* @}
-74
View File
@@ -1,74 +0,0 @@
/*
* Copyright (c) 2016, Nest Labs, Inc.
* 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.
*/
/**
* @file
* @brief
* This file includes the platform abstraction to support critical sections.
*/
#ifndef ATOMIC_H_
#define ATOMIC_H_
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup atomic Atomic
* @ingroup platform
*
* @brief
* This module includes the platform abstraction to support critical sections.
*
* @{
*
*/
/**
* Begin critical section.
*/
uint32_t otPlatAtomicBegin(void);
/**
* End critical section.
*/
void otPlatAtomicEnd(uint32_t state);
/**
* @}
*
*/
#ifdef __cplusplus
} // end of extern "C"
#endif
#endif // ATOMIC_H_
+12 -35
View File
@@ -208,9 +208,6 @@ ThreadError otPlatRadioIdle(void);
* 2. Remain in Receive until a packet is received or reception is aborted.
* 3. Return to Idle.
*
* Upon completion of the receive sequence, otPlatRadioSignalReceiveDone() is called to signal completion to the MAC
* layer.
*
* @param[in] aPacket A pointer to a packet buffer.
*
* @note The channel is specified in @p aPacket.
@@ -221,21 +218,13 @@ ThreadError otPlatRadioIdle(void);
ThreadError otPlatRadioReceive(RadioPacket *aPacket);
/**
* Signal that a packet has been received.
* The radio driver calls this method to notify OpenThread of a received packet.
*
* This may be called from interrupt context. The MAC layer will then schedule a call to otPlatRadioHandleReceive().
*/
extern void otPlatRadioSignalReceiveDone(void);
/**
* Complete the receive sequence.
* @param[in] aError ::kThreadError_None when successfully received a frame, ::kThreadError_Abort when reception
* was aborted and a frame was not received.
*
* @retval ::kThreadError_None Successfully received a frame.
* @retval ::kThreadError_Abort Reception was aborted and a frame was not received.
* @retval ::kThreadError_InvalidState The radio was not in Receive.
*/
ThreadError otPlatRadioHandleReceiveDone(void);
extern void otPlatRadioReceiveDone(ThreadError error);
/**
* Begins the transmit sequence on the radio.
@@ -245,9 +234,6 @@ ThreadError otPlatRadioHandleReceiveDone(void);
* 2. Transmits the psdu on the given channel and at the given transmit power.
* 3. Return to Idle.
*
* Upon completion of the transmit sequence, otPlatRadioSignalTransmitDone() is called to signal completion to the MAC
* layer.
*
* @param[in] aPacket A pointer to a packet buffer.
*
* @note The channel is specified in @p aPacket.
@@ -260,25 +246,16 @@ ThreadError otPlatRadioHandleReceiveDone(void);
ThreadError otPlatRadioTransmit(RadioPacket *aPacket);
/**
* Signal that the requested transmission is complete.
* The radio driver calls this method to notify OpenThread that the transmission has completed.
*
* @param[in] aFramePending TRUE if an ACK frame was received and the Frame Pending bit was set.
* @param[in] aError ::kThreadError_None when the frame was transmitted, ::kThreadError_NoAck when the frame was
* transmitted but no ACK was received, ::kThreadError_ChannelAccessFailure when the transmission
* could not take place due to activity on the channel, ::kThreadError_Abort when transmission was
* aborted for other reasons.
*
* This may be called from interrupt context. OpenThread will then schedule a call to
* otPlatRadio_handle_transmit_done().
*/
extern void otPlatRadioSignalTransmitDone(void);
/**
* Complete the transmit sequence on the radio.
*
* @param[out] aFramePending TRUE if an ACK frame was received and the Frame Pending bit was set.
*
* @retval ::kThreadError_None The frame was transmitted.
* @retval ::kThreadError_NoAck The frame was transmitted, but no ACK was received.
* @retval ::kThreadError_CcaFailed The transmission was aborted due to CCA failure.
* @retval ::kThreadError_Abort The transmission was aborted for other reasons.
* @retval ::kThreadError_InvalidState The radio did not transmit a packet.
*/
ThreadError otPlatRadioHandleTransmitDone(bool *aFramePending);
extern void otPlatRadioTransmitDone(bool aFramePending, ThreadError error);
/**
* Get the most recent RSSI measurement.
+6 -25
View File
@@ -82,38 +82,19 @@ ThreadError otPlatSerialDisable(void);
ThreadError otPlatSerialSend(const uint8_t *aBuf, uint16_t aBufLength);
/**
* Signal that the bytes send operation has completed.
* The serial driver calls this method to notify OpenThread that the requested bytes have been sent.
*
* This may be called from interrupt context. This will schedule calls to otPlatSerialHandleSendDone().
*/
extern void otPlatSerialSignalSendDone(void);
extern void otPlatSerialSendDone(void);
/**
* Complete the send sequence.
*/
void otPlatSerialHandleSendDone(void);
/**
* Signal that bytes have been received.
* The serial driver calls this method to notify OpenThread that bytes have been received.
*
* This may be called from interrupt context. This will schedule calls to otPlatSerialGetReceivedBytes() and
* otPlatSerialHandleReceiveDone().
*/
extern void otPlatSerialSignalReceive(void);
/**
* Get a pointer to the received bytes.
* @param[in] aBuf A pointer to the received bytes.
* @param[in] aBufLength The number of bytes received.
*
* @param[out] aBufLength A pointer to a variable that this function will put the number of bytes received.
*
* @returns A pointer to the received bytes. NULL, if there are no received bytes to process.
*/
const uint8_t *otPlatSerialGetReceivedBytes(uint16_t *aBufLength);
/**
* Release received bytes.
*/
void otPlatSerialHandleReceiveDone(void);
extern void otPlatSerialReceived(const uint8_t *aBuf, uint16_t aBufLength);
/**
* @}