implement radio stub functions and catch up on technical debt (#1763)

This commit is contained in:
Seth Rickard
2017-05-11 22:15:06 -07:00
committed by Jonathan Hui
parent b096efe932
commit 33b079893e
4 changed files with 84 additions and 24 deletions
+13 -2
View File
@@ -85,6 +85,8 @@ void mbedtls_sha256_update(mbedtls_sha256_context *ctx, const unsigned char *inp
SHA256_execute(ctx, (uint8_t *)input, (uint32_t)ilen);
}
char *workaround_cc2650_rom;
/**
* documented in sha256_alt.h
*/
@@ -94,10 +96,19 @@ void mbedtls_sha256_finish(mbedtls_sha256_context *ctx, unsigned char output[32]
* Allocate an extra 64 bytes on the stack to make sure we have buffer
* room. This could be optomized out if you never call this function with
* a call stack shorter than 16 words, approx. 8 stack frames.
*
* The simple description is this:
* If the stack pointer is within 64bytes of the end of RAM
* the bug exposes it self.
* If the stack pointer is more then 64bytes from end of RAM
* There is no bug...
* Solution:
* Make a 64byte buffer on the stack..
* And force the compiler to think it requires this buffer.
*/
__asm("sub sp, #0x40 ");
char buffer[ 64 ];
workaround_cc2650_rom = &buffer[0];
SHA256_output(ctx, (uint8_t *)output);
__asm("add sp, #0x40 ");
return;
}
+14 -3
View File
@@ -26,10 +26,13 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <openthread/types.h>
#include "platform-cc2650.h"
otInstance *sInstance;
extern const char __ccfg[];
const char *dummy_ccfg_ref = ((const char *)(&(__ccfg[0])));
/**
* Function documented in platform-cc2650.h
@@ -38,6 +41,16 @@ void PlatformInit(int argc, char *argv[])
{
(void) argc;
(void) argv;
while (dummy_ccfg_ref == NULL)
{
/*
* This provides a code reference to the customer configuration
* area of the flash, otherwise the data is skipped by the
* linker and not put into the final flash image.
*/
}
cc2650AlarmInit();
cc2650RandomInit();
cc2650RadioInit();
@@ -48,8 +61,6 @@ void PlatformInit(int argc, char *argv[])
*/
void PlatformProcessDrivers(otInstance *aInstance)
{
sInstance = aInstance;
// should sleep and wait for interrupts here
cc2650UartProcess();
+57 -4
View File
@@ -1219,11 +1219,28 @@ exit:
return error;
}
/**
* Function documented in platform/radio.h
*/
void otPlatRadioSetDefaultTxPower(otInstance *aInstance, int8_t aPower)
{
// TODO: Create a proper implementation for this driver.
unsigned int i;
output_config_t const *powerCfg = &(rgOutputPower[0]);
(void)aInstance;
(void)aPower;
for (i = 1; i < OUTPUT_CONFIG_COUNT; i++)
{
if (rgOutputPower[i].dbm >= aPower)
{
powerCfg = &(rgOutputPower[i]);
}
else
{
break;
}
}
sCurrentOutputPower = powerCfg;
}
/**
@@ -1513,7 +1530,25 @@ exit:
void otPlatRadioClearSrcMatchShortEntries(otInstance *aInstance)
{
(void)aInstance;
// TODO - This function needs to be implemented
if (sReceiveCmd.status == ACTIVE || sReceiveCmd.status == IEEE_SUSPENDED)
{
unsigned int i;
for (i = 0; i < CC2650_SHORTADD_SRC_MATCH_NUM; i++)
{
/* we have a running or backgrounded rx command */
otEXPECT(rfCoreModifySourceMatchEntry(i, SHORT_ADDRESS, false) == CMDSTA_Done);
}
}
else
{
/* we are not running, so we can erase them ourselves */
memset((void *)&sSrcMatchShortData, 0, sizeof(sSrcMatchShortData));
}
exit:
return;
}
/**
@@ -1522,7 +1557,25 @@ void otPlatRadioClearSrcMatchShortEntries(otInstance *aInstance)
void otPlatRadioClearSrcMatchExtEntries(otInstance *aInstance)
{
(void)aInstance;
// TODO - This function needs to be implemented
if (sReceiveCmd.status == ACTIVE || sReceiveCmd.status == IEEE_SUSPENDED)
{
unsigned int i;
for (i = 0; i < CC2650_EXTADD_SRC_MATCH_NUM; i++)
{
/* we have a running or backgrounded rx command */
otEXPECT(rfCoreModifySourceMatchEntry(i, EXT_ADDRESS, false) == CMDSTA_Done);
}
}
else
{
/* we are not running, so we can erase them ourselves */
memset((void *)&sSrcMatchExtData, 0, sizeof(sSrcMatchExtData));
}
exit:
return;
}
/**
-15
View File
@@ -135,18 +135,3 @@ exit:
return error;
}
/**
* Entropy function for the entropy pool in mbedtls.
*
* Function defined in mbedtls/entropy_poll.h .
*/
int mbedtls_hardware_poll(void *data, unsigned char *aOutput, size_t aLen, size_t *oLen)
{
ThreadError error;
(void)data;
error = TRNGPoll(aOutput, aLen);
*oLen = aLen;
return error;
}