1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-20 10:54:14 +01:00

Merge branch 'amorale/OP-943_add_malloc_for_ccsram' into next

Conflicts:
	flight/pios/common/pios_adxl345.c
	make/apps-defs.mk
This commit is contained in:
Alessio Morale 2014-06-22 19:31:03 +02:00
commit c6a773363f
87 changed files with 532 additions and 341 deletions

View File

@ -40,7 +40,6 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// I don't want this dependency, but currently using pvPortMalloc
#include "openpilot.h"
#include <stdio.h>
@ -52,7 +51,7 @@
#include "WorldMagModel.h"
#include "WMMInternal.h"
#define MALLOC(x) pvPortMalloc(x)
#define MALLOC(x) pios_malloc(x)
#define FREE(x) vPortFree(x)
// #define MALLOC(x) malloc(x)
// #define FREE(x) free(x)

View File

@ -78,7 +78,7 @@ int sin_lookup_initalize()
return 0;
}
sin_table = (float *)pvPortMalloc(sizeof(float) * SIN_RESOLUTION);
sin_table = (float *)pios_malloc(sizeof(float) * SIN_RESOLUTION);
if (sin_table == NULL) {
return -1;
}

View File

@ -73,7 +73,7 @@ static inline float Sq(float x)
void gps_airspeedInitialize()
{
// This method saves memory in case we don't use the GPS module.
gps = (struct GPSGlobals *)pvPortMalloc(sizeof(struct GPSGlobals));
gps = (struct GPSGlobals *)pios_malloc(sizeof(struct GPSGlobals));
// GPS airspeed calculation variables
VelocityStateInitialize();

View File

@ -110,7 +110,7 @@ int32_t CameraStabInitialize(void)
if (cameraStabEnabled) {
// allocate and initialize the static data storage only if module is enabled
csd = (struct CameraStab_data *)pvPortMalloc(sizeof(struct CameraStab_data));
csd = (struct CameraStab_data *)pios_malloc(sizeof(struct CameraStab_data));
if (!csd) {
return -1;
}

View File

@ -115,9 +115,9 @@ static int32_t comUsbBridgeInitialize(void)
#endif
if (bridge_enabled) {
com2usb_buf = pvPortMalloc(BRIDGE_BUF_LEN);
com2usb_buf = pios_malloc(BRIDGE_BUF_LEN);
PIOS_Assert(com2usb_buf);
usb2com_buf = pvPortMalloc(BRIDGE_BUF_LEN);
usb2com_buf = pios_malloc(BRIDGE_BUF_LEN);
PIOS_Assert(usb2com_buf);
updateSettings();

View File

@ -73,7 +73,7 @@ static int32_t fault_initialize(void)
break;
case FAULTSETTINGS_ACTIVATEFAULT_INITOUTOFMEMORY:
/* Leak all available memory */
while (pvPortMalloc(10)) {
while (pios_malloc(10)) {
;
}
break;
@ -126,7 +126,7 @@ static void fault_task(__attribute__((unused)) void *parameters)
break;
case FAULTSETTINGS_ACTIVATEFAULT_TASKOUTOFMEMORY:
/* Leak all available memory and then sleep */
while (pvPortMalloc(10)) {
while (pios_malloc(10)) {
;
}
while (1) {

View File

@ -193,7 +193,7 @@ static void FirmwareIAPCallback(UAVObjEvent *ev)
/* Note: Cant just wait timeout value, because first time is randomized */
reset_count = 0;
lastResetSysTime = xTaskGetTickCount();
UAVObjEvent *event = pvPortMalloc(sizeof(UAVObjEvent));
UAVObjEvent *event = pios_malloc(sizeof(UAVObjEvent));
memset(event, 0, sizeof(UAVObjEvent));
EventPeriodicCallbackCreate(event, resetTask, 100);
iap_state = IAP_STATE_RESETTING;

View File

@ -175,10 +175,10 @@ int32_t GPSInitialize(void)
GPSSettingsDataProtocolGet(&gpsProtocol);
switch (gpsProtocol) {
case GPSSETTINGS_DATAPROTOCOL_NMEA:
gps_rx_buffer = pvPortMalloc(NMEA_MAX_PACKET_LENGTH);
gps_rx_buffer = pios_malloc(NMEA_MAX_PACKET_LENGTH);
break;
case GPSSETTINGS_DATAPROTOCOL_UBX:
gps_rx_buffer = pvPortMalloc(sizeof(struct UBXPacket));
gps_rx_buffer = pios_malloc(sizeof(struct UBXPacket));
break;
default:
gps_rx_buffer = NULL;

View File

@ -58,7 +58,7 @@ int32_t LoggingInitialize(void)
DebugLogEntryInitialize();
FlightStatusInitialize();
PIOS_DEBUGLOG_Initialize();
entry = pvPortMalloc(sizeof(DebugLogEntryData));
entry = pios_malloc(sizeof(DebugLogEntryData));
if (!entry) {
return -1;
}

View File

@ -102,7 +102,7 @@ int32_t osdinputInitialize(void)
oposdPort = PIOS_COM_OSD;
oposd_rx_buffer = pvPortMalloc(MAX_PACKET_LENGTH);
oposd_rx_buffer = pios_malloc(MAX_PACKET_LENGTH);
PIOS_Assert(oposd_rx_buffer);
return 0;

View File

@ -118,7 +118,7 @@ int32_t OveroSyncStart(void)
return -1;
}
overosync = (struct overosync *)pvPortMalloc(sizeof(*overosync));
overosync = (struct overosync *)pios_malloc(sizeof(*overosync));
if (overosync == NULL) {
return -1;
}

View File

@ -106,7 +106,7 @@ int32_t OveroSyncInitialize(void)
*/
int32_t OveroSyncStart(void)
{
overosync = (struct overosync *)pvPortMalloc(sizeof(*overosync));
overosync = (struct overosync *)pios_malloc(sizeof(*overosync));
if (overosync == NULL) {
return -1;
}

View File

@ -225,7 +225,7 @@ static int32_t RadioComBridgeStart(void)
static int32_t RadioComBridgeInitialize(void)
{
// allocate and initialize the static data storage only if module is enabled
data = (RadioComBridgeData *)pvPortMalloc(sizeof(RadioComBridgeData));
data = (RadioComBridgeData *)pios_malloc(sizeof(RadioComBridgeData));
if (!data) {
return -1;
}

View File

@ -57,7 +57,7 @@ int32_t filterAirInitialize(stateFilter *handle)
{
handle->init = &init;
handle->filter = &filter;
handle->localdata = pvPortMalloc(sizeof(struct data));
handle->localdata = pios_malloc(sizeof(struct data));
return STACK_REQUIRED;
}

View File

@ -82,7 +82,7 @@ int32_t filterAltitudeInitialize(stateFilter *handle)
{
handle->init = &init;
handle->filter = &filter;
handle->localdata = pvPortMalloc(sizeof(struct data));
handle->localdata = pios_malloc(sizeof(struct data));
HomeLocationInitialize();
AttitudeStateInitialize();
AltitudeFilterSettingsInitialize();

View File

@ -63,7 +63,7 @@ int32_t filterBaroInitialize(stateFilter *handle)
{
handle->init = &initwithgps;
handle->filter = &filter;
handle->localdata = pvPortMalloc(sizeof(struct data));
handle->localdata = pios_malloc(sizeof(struct data));
return STACK_REQUIRED;
}
@ -71,7 +71,7 @@ int32_t filterBaroiInitialize(stateFilter *handle)
{
handle->init = &initwithoutgps;
handle->filter = &filter;
handle->localdata = pvPortMalloc(sizeof(struct data));
handle->localdata = pios_malloc(sizeof(struct data));
return STACK_REQUIRED;
}

View File

@ -106,7 +106,7 @@ int32_t filterCFInitialize(stateFilter *handle)
globalInit();
handle->init = &initwithoutmag;
handle->filter = &filter;
handle->localdata = pvPortMalloc(sizeof(struct data));
handle->localdata = pios_malloc(sizeof(struct data));
return STACK_REQUIRED;
}
@ -115,7 +115,7 @@ int32_t filterCFMInitialize(stateFilter *handle)
globalInit();
handle->init = &initwithmag;
handle->filter = &filter;
handle->localdata = pvPortMalloc(sizeof(struct data));
handle->localdata = pios_malloc(sizeof(struct data));
return STACK_REQUIRED;
}

View File

@ -104,7 +104,7 @@ int32_t filterEKF13iInitialize(stateFilter *handle)
globalInit();
handle->init = &init13i;
handle->filter = &filter;
handle->localdata = pvPortMalloc(sizeof(struct data));
handle->localdata = pios_malloc(sizeof(struct data));
return STACK_REQUIRED;
}
int32_t filterEKF13Initialize(stateFilter *handle)
@ -112,7 +112,7 @@ int32_t filterEKF13Initialize(stateFilter *handle)
globalInit();
handle->init = &init13;
handle->filter = &filter;
handle->localdata = pvPortMalloc(sizeof(struct data));
handle->localdata = pios_malloc(sizeof(struct data));
return STACK_REQUIRED;
}
// XXX
@ -123,7 +123,7 @@ int32_t filterEKF16iInitialize(stateFilter *handle)
globalInit();
handle->init = &init13i;
handle->filter = &filter;
handle->localdata = pvPortMalloc(sizeof(struct data));
handle->localdata = pios_malloc(sizeof(struct data));
return STACK_REQUIRED;
}
int32_t filterEKF16Initialize(stateFilter *handle)
@ -131,7 +131,7 @@ int32_t filterEKF16Initialize(stateFilter *handle)
globalInit();
handle->init = &init13;
handle->filter = &filter;
handle->localdata = pvPortMalloc(sizeof(struct data));
handle->localdata = pios_malloc(sizeof(struct data));
return STACK_REQUIRED;
}

View File

@ -60,7 +60,7 @@ int32_t filterLLAInitialize(stateFilter *handle)
{
handle->init = &init;
handle->filter = &filter;
handle->localdata = pvPortMalloc(sizeof(struct data));
handle->localdata = pios_malloc(sizeof(struct data));
GPSSettingsInitialize();
GPSPositionSensorInitialize();
HomeLocationInitialize();

View File

@ -68,7 +68,7 @@ int32_t filterMagInitialize(stateFilter *handle)
{
handle->init = &init;
handle->filter = &filter;
handle->localdata = pvPortMalloc(sizeof(struct data));
handle->localdata = pios_malloc(sizeof(struct data));
HomeLocationInitialize();
return STACK_REQUIRED;
}

View File

@ -108,6 +108,10 @@ typedef unsigned long UBaseType_t;
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
#define portBYTE_ALIGNMENT 8
/*-----------------------------------------------------------*/
// Following define allow to use a different malloc to allocate thread stack
extern void *pvPortMallocStack(size_t s);
#define pvPortMallocAligned( x, puxStackBuffer ) ( ( ( puxStackBuffer ) == NULL ) ? ( pvPortMallocStack( x ) ) : ( puxStackBuffer ) )
/*-----------------------------------------------------------*/
/* Scheduler utilities. */

View File

@ -138,71 +138,10 @@
})
/*
* The heap consists of ranges (free or allocated) separated and
* bounded by markers.
*
* For maximum space efficiency, the default is to use 4-byte
* 'compact' markers, which limits the heap to a maxium of 128KiB.
* For larger heaps define HEAP_SUPPORT_LARGE, which doubles markers
* to 8 bytes each, but allows heaps up to 2^^33 bytes in size.
*
* Each marker contains two structures, one describing the previous
* region and one describing the next. Thus, markers form a
* doubly-linked list chaining each region together.
*
* Each region is described by two identical structures, providing
* a measure of referential integrity that can be used to detect
* overflows out of the region without the use of separate magic
* numbers.
*
* The region descriptor size includes the size of the marker at its
* head. This means that zero is not a legal marker value.
*
* Free regions are always coalesced, and a pointer is kept to the
* most recently-created free region to accelerate allocation in the
* common case where a large number of free objects are allocated
* early.
*
* The heap is bounded by markers pointing to zero-sized allocated
* ranges, so they can never be merged.
*/
#ifdef HEAP_SUPPORT_LARGE
struct region_descriptor {
uint32_t size:31; /* size of the region (including marker) in multiples of the marker size */
uint32_t free:1; /* if nonzero, region is free */
};
static const uint32_t max_free = 0x7fffffff;
#else /* !HEAP_SUPPORT_LARGE */
struct region_descriptor {
uint16_t size:15; /* size of the region (including marker) in multiples of the marker size */
uint16_t free:1; /* if nonzero, region is free */
};
static const uint32_t max_free = 0x7fff;
#endif /* HEAP_SUPPORT_LARGE */
/**
* The marker placed between regions.
*
* Allocations are aligned and rounded to the size of this structure.
*/
struct marker {
struct region_descriptor prev;
struct region_descriptor next;
};
typedef struct marker *marker_t;
static const uintptr_t marker_size = sizeof(struct marker);
/* heap boundaries */
static marker_t heap_base;
static marker_t heap_limit;
static uint32_t heap_free;
static marker_t free_hint; /* likely free region, or heap_base if no free region hint */
/* rounding macros for powers of 2 */
#define round_down(_val, _boundary) ((_val) & ~(_boundary - 1))
@ -211,56 +150,56 @@ static marker_t free_hint; /* likely free region, or heap_base if no fr
/* default panic handler */
void msheap_panic(const char *reason) __attribute__((weak, noreturn));
static int region_check(marker_t marker);
static void split_region(marker_t marker, uint32_t size);
static int region_check(heap_handle_t *heap, marker_t marker);
static void split_region(heap_handle_t *heap, marker_t marker, uint32_t size);
static void merge_region(marker_t marker);
/**
* Initialise the heap.
* Initialise the heap->
*
* @param base The lower boundary of the heap.
* @param limit The upper boundary of the heap.
* @param base The lower boundary of the heap->
* @param limit The upper boundary of the heap->
*/
void
msheap_init(void *base, void *limit)
msheap_init(heap_handle_t *heap, void *base, void *limit)
{
heap_base = (marker_t)round_up((uintptr_t)base, marker_size);
heap_limit = (marker_t)round_down((uintptr_t)limit, marker_size) - 1;
heap->heap_base = (marker_t)round_up((uintptr_t)base, marker_size);
heap->heap_limit = (marker_t)round_down((uintptr_t)limit, marker_size) - 1;
ASSERT(3, heap_base); /* must not be NULL */
ASSERT(3, heap_limit); /* must not be NULL */
ASSERT(3, heap_limit > heap_base); /* limit must be above base */
ASSERT(3, heap->heap_base); /* must not be NULL */
ASSERT(3, heap->heap_limit); /* must not be NULL */
ASSERT(3, heap->heap_limit > heap->heap_base); /* limit must be above base */
/* Initial size of the free region (includes the heap_base marker) */
heap_free = heap_limit - heap_base;
ASSERT(0, heap_free <= max_free); /* heap must not be too large */
ASSERT(3, heap_free > 1); /* heap must be at least 1 marker in size */
heap->heap_free = heap->heap_limit - heap->heap_base;
ASSERT(0, heap->heap_free <= max_free); /* heap must not be too large */
ASSERT(3, heap->heap_free > 1); /* heap must be at least 1 marker in size */
/*
* Initialise the base and limit markers.
*/
heap_base->prev.size = 0;
heap_base->prev.free = 0;
heap_base->next.size = heap_free;
heap_base->next.free = 1;
heap_limit->prev.size = heap_free;
heap_limit->prev.free = 1;
heap_limit->next.size = 0;
heap_limit->next.free = 0;
heap->heap_base->prev.size = 0;
heap->heap_base->prev.free = 0;
heap->heap_base->next.size = heap->heap_free;
heap->heap_base->next.free = 1;
heap->heap_limit->prev.size = heap->heap_free;
heap->heap_limit->prev.free = 1;
heap->heap_limit->next.size = 0;
heap->heap_limit->next.free = 0;
free_hint = heap_base; /* a good place to start ... */
heap->free_hint = heap->heap_base; /* a good place to start ... */
region_check(heap_base);
region_check(heap_limit);
region_check(heap, heap->heap_base);
region_check(heap, heap->heap_limit);
}
void *
msheap_alloc(uint32_t size)
msheap_alloc(heap_handle_t *heap, uint32_t size)
{
marker_t cursor;
marker_t best;
ASSERT(3, msheap_check());
ASSERT(3, msheap_check(heap));
/* convert the passed-in size to the number of marker-size units we need to allocate */
size += marker_size;
@ -268,16 +207,16 @@ msheap_alloc(uint32_t size)
size /= marker_size;
/* cannot possibly satisfy this allocation */
if (size > heap_free)
if (size > heap->heap_free)
return 0;
/* simple single-pass best-fit search */
restart:
cursor = free_hint;
cursor = heap->free_hint;
best = 0;
while (cursor != heap_limit) {
while (cursor != heap->heap_limit) {
ASSERT(1, region_check(cursor));
ASSERT(1, region_check(heap, cursor));
/* if the region is free and large enough */
if ((cursor->next.free) && (cursor->next.size >= size)) {
@ -295,8 +234,8 @@ restart:
* If we were working from the hint and found nothing, reset
* the hint and try again
*/
if (free_hint != heap_base) {
free_hint = heap_base;
if (heap->free_hint != heap->heap_base) {
heap->free_hint = heap->heap_base;
goto restart;
}
@ -305,24 +244,24 @@ restart:
}
/* split the free region to make space */
split_region(best, size);
split_region(heap, best, size);
/* update free space counter */
heap_free -= size;
heap->heap_free -= size;
traceMALLOC( (void *)(best + 1), size );
/* and return a pointer to the allocated region */
return (void *)(best + 1);
}
void
msheap_free(void *ptr)
msheap_free(heap_handle_t *heap, void *ptr)
{
marker_t marker;
marker = (marker_t)ptr - 1;
ASSERT(0, region_check(marker));
ASSERT(3, msheap_check());
ASSERT(0, region_check(heap, marker));
ASSERT(3, msheap_check(heap));
/* this region is free, mark it accordingly */
marker->next.free = 1;
@ -331,7 +270,7 @@ msheap_free(void *ptr)
traceFREE( ptr, marker->next.size );
/* account for space we are freeing */
heap_free += marker->next.size;
heap->heap_free += marker->next.size;
/* possibly merge this region and the following */
merge_region(marker);
@ -344,60 +283,60 @@ msheap_free(void *ptr)
/*
* Marker now points to the new free region, so update
* the free hint if this has opened space earlier in the heap.
* the free hint if this has opened space earlier in the heap->
*/
if (marker < free_hint)
free_hint = marker;
if (marker < heap->free_hint)
heap->free_hint = marker;
}
int
msheap_check(void)
msheap_check(heap_handle_t *heap)
{
marker_t cursor;
uint32_t free_space = 0;
cursor = heap_base; /* start at the base of the heap */
cursor = heap->heap_base; /* start at the base of the heap */
for (;;) {
if (ASSERT_TEST(2, region_check(cursor))) /* check the current region */
if (ASSERT_TEST(2, region_check(heap, cursor))) /* check the current region */
return 0;
if (cursor->next.free) /* if the region is free */
free_space += cursor->next.size; /* count it as free space */
if (cursor == heap_limit) /* if this was the last region, stop */
if (cursor == heap->heap_limit) /* if this was the last region, stop */
break;
cursor += cursor->next.size; /* next region */
}
if (ASSERT_TEST(2, region_check(free_hint)))
if (ASSERT_TEST(2, region_check(heap, heap->free_hint)))
return 0;
if (ASSERT_TEST(2, free_space == heap_free))
if (ASSERT_TEST(2, free_space == heap->heap_free))
return 0;
return 1;
}
void
msheap_walk(void (* callback)(void *ptr, uint32_t size, int free))
msheap_walk(heap_handle_t *heap, void (* callback)(void *ptr, uint32_t size, int free))
{
marker_t cursor;
cursor = heap_base;
cursor = heap->heap_base;
for (;;) {
callback(cursor + 1, cursor->next.size * marker_size, cursor->next.free);
if (cursor == heap_limit)
if (cursor == heap->heap_limit)
break;
cursor += cursor->next.size;
}
}
uint32_t
msheap_free_space(void)
msheap_free_space(heap_handle_t *heap)
{
return heap_free * marker_size;
return heap->heap_free * marker_size;
}
void
msheap_extend(uint32_t size)
msheap_extend(heap_handle_t *heap, uint32_t size)
{
marker_t new_free;
@ -411,10 +350,10 @@ msheap_extend(uint32_t size)
* the heap limit, or we can turn the heap limit marker
* into the marker for a free region.
*/
if (heap_limit->prev.free) {
new_free = heap_limit - heap_limit->prev.size;
if (heap->heap_limit->prev.free) {
new_free = heap->heap_limit - heap->heap_limit->prev.size;
} else {
new_free = heap_limit;
new_free = heap->heap_limit;
}
/* update new free region */
@ -422,13 +361,13 @@ msheap_extend(uint32_t size)
new_free->next.free = 1;
/* new end marker */
heap_limit = new_free + new_free->next.size;
heap_limit->prev.size = new_free->next.size;
heap_limit->prev.free = 1;
heap_limit->next.size = 0;
heap_limit->next.free = 0;
heap->heap_limit = new_free + new_free->next.size;
heap->heap_limit->prev.size = new_free->next.size;
heap->heap_limit->prev.free = 1;
heap->heap_limit->next.size = 0;
heap->heap_limit->next.free = 0;
ASSERT(3, msheap_check());
ASSERT(3, msheap_check(heap));
}
/**
@ -456,14 +395,14 @@ msheap_panic(__attribute__((unused)) const char *reason)
* @return 0 if the region fails checking, 1 otherwise.
*/
static int
region_check(marker_t marker)
region_check(heap_handle_t *heap, marker_t marker)
{
marker_t other;
if (ASSERT_TEST(2, marker) | /* not NULL */
ASSERT_TEST(2, !((uintptr_t)marker % marker_size)) | /* properly aligned */
ASSERT_TEST(2, marker >= heap_base) | /* within the heap */
ASSERT_TEST(2, marker <= heap_limit))
ASSERT_TEST(2, marker >= heap->heap_base) | /* within the heap */
ASSERT_TEST(2, marker <= heap->heap_limit))
return 0;
/* validate link to next marker & return link from that marker */
@ -471,12 +410,12 @@ region_check(marker_t marker)
other = marker + marker->next.size;
if (ASSERT_TEST(2, other > marker) | /* must be after */
ASSERT_TEST(2, other <= heap_limit) | /* must be inside the heap */
ASSERT_TEST(2, other <= heap->heap_limit) | /* must be inside the heap */
ASSERT_TEST(2, marker->next.size == other->prev.size) | /* sizes must match */
ASSERT_TEST(2, marker->next.free == other->prev.free)) /* free state must match */
return 0;
} else {
if (ASSERT_TEST(2, marker == heap_limit)) /* or it's the end of the heap */
if (ASSERT_TEST(2, marker == heap->heap_limit)) /* or it's the end of the heap */
return 0;
}
@ -485,12 +424,12 @@ region_check(marker_t marker)
other = marker - marker->prev.size;
if (ASSERT_TEST(2, other < marker) | /* must be before */
ASSERT_TEST(2, other >= heap_base) | /* must be inside the heap */
ASSERT_TEST(2, other >= heap->heap_base) | /* must be inside the heap */
ASSERT_TEST(2, marker->prev.size == other->next.size) | /* sizes must match */
ASSERT_TEST(2, marker->prev.free == other->next.free)) /* free state must match */
return 0;
} else {
if (ASSERT_TEST(2, marker == heap_base)) /* or it's the end of the heap */
if (ASSERT_TEST(2, marker == heap->heap_base)) /* or it's the end of the heap */
return 0;
}
@ -508,7 +447,7 @@ region_check(marker_t marker)
* @param size Size of the portion to be allocated.
*/
static void
split_region(marker_t marker, uint32_t size)
split_region(heap_handle_t *heap, marker_t marker, uint32_t size)
{
marker_t split, tail;
@ -519,7 +458,7 @@ split_region(marker_t marker, uint32_t size)
ASSERT(3, size); /* split result must be at least one marker in size */
tail = marker + marker->next.size;
ASSERT(1, region_check(tail)); /* validate the following region */
ASSERT(1, region_check(heap, tail)); /* validate the following region */
/*
* The split marker is at the end of the allocated region; it may actually
@ -542,25 +481,25 @@ split_region(marker_t marker, uint32_t size)
* Update the allocation speedup hint to
* point to the new free region if we just used it.
*/
if (free_hint == marker)
free_hint = split;
if (heap->free_hint == marker)
heap->free_hint = split;
} else {
/*
* If we just allocated all of what the free hint
* pointed to, reset it to the base of the heap.
* pointed to, reset it to the base of the heap->
*/
if (free_hint == marker)
free_hint = heap_base;
if (heap->free_hint == marker)
heap->free_hint = heap->heap_base;
}
/* and update the allocated region */
marker->next.size = size;
marker->next.free = 0;
ASSERT(3, region_check(marker));
ASSERT(3, region_check(split));
ASSERT(3, region_check(tail));
ASSERT(3, region_check(heap, marker));
ASSERT(3, region_check(heap, split));
ASSERT(3, region_check(heap, tail));
}
/**

View File

@ -36,27 +36,94 @@
#include <stdint.h>
/*
* The heap consists of ranges (free or allocated) separated and
* bounded by markers.
*
* For maximum space efficiency, the default is to use 4-byte
* 'compact' markers, which limits the heap to a maxium of 128KiB.
* For larger heaps define HEAP_SUPPORT_LARGE, which doubles markers
* to 8 bytes each, but allows heaps up to 2^^33 bytes in size.
*
* Each marker contains two structures, one describing the previous
* region and one describing the next. Thus, markers form a
* doubly-linked list chaining each region together.
*
* Each region is described by two identical structures, providing
* a measure of referential integrity that can be used to detect
* overflows out of the region without the use of separate magic
* numbers.
*
* The region descriptor size includes the size of the marker at its
* head. This means that zero is not a legal marker value.
*
* Free regions are always coalesced, and a pointer is kept to the
* most recently-created free region to accelerate allocation in the
* common case where a large number of free objects are allocated
* early.
*
* The heap is bounded by markers pointing to zero-sized allocated
* ranges, so they can never be merged.
*/
#ifdef HEAP_SUPPORT_LARGE
struct region_descriptor {
uint32_t size:31; /* size of the region (including marker) in multiples of the marker size */
uint32_t free:1; /* if nonzero, region is free */
};
static const uint32_t max_free = 0x7fffffff;
#else /* !HEAP_SUPPORT_LARGE */
struct region_descriptor {
uint16_t size:15; /* size of the region (including marker) in multiples of the marker size */
uint16_t free:1; /* if nonzero, region is free */
};
static const uint32_t max_free = 0x7fff;
#endif /* HEAP_SUPPORT_LARGE */
/**
* The marker placed between regions.
*
* Allocations are aligned and rounded to the size of this structure.
*/
struct marker {
struct region_descriptor prev;
struct region_descriptor next;
};
typedef struct marker *marker_t;
/* heap handle (boundaries) */
typedef struct {
marker_t heap_base;
marker_t heap_limit;
uint32_t heap_free;
marker_t free_hint; /* likely free region, or heap_base if no free region hint */
} heap_handle_t;
/**
* Initialise the heap.
*
* @param base The lower boundary of the heap.
* @param limit The upper boundary of the heap.
*/
extern void msheap_init(void *base, void *limit);
extern void msheap_init(heap_handle_t *heap, void *base, void *limit);
/**
* Allocate memory from the heap.
*
* @param size The number of bytes required (more may be allocated).
*/
extern void *msheap_alloc(uint32_t size);
extern void *msheap_alloc(heap_handle_t *heap, uint32_t size);
/**
* Free memory back to the heap.
*
* @param ptr Pointer being freed to the heap.
*/
extern void msheap_free(void *ptr);
extern void msheap_free(heap_handle_t *heap, void *ptr);
/**
* Validate the heap.
@ -64,7 +131,7 @@ extern void msheap_free(void *ptr);
* @return Zero if the heap integrity checks pass, nonzero
* otherwise.
*/
extern int msheap_check(void);
extern int msheap_check(heap_handle_t *heap);
/**
* Walk the heap.
@ -74,18 +141,18 @@ extern int msheap_check(void);
* the free region address, size is the region size
* in bytes and free is nonzero if the region is free.
*/
extern void msheap_walk(void (* callback)(void *ptr, uint32_t size, int free));
extern void msheap_walk(heap_handle_t *heap, void (* callback)(void *ptr, uint32_t size, int free));
/**
* Return the amount of free space in the heap.
*
* @return The total number of bytes available for allocation.
*/
extern uint32_t msheap_free_space(void);
extern uint32_t msheap_free_space(heap_handle_t *heap);
/**
* Extend the heap.
*
* @param size The size of the extension in bytes.
*/
extern void msheap_extend(uint32_t size);
extern void msheap_extend(heap_handle_t *heap, uint32_t size);

View File

@ -41,6 +41,15 @@
extern char _sheap;
extern char _eheap;
#ifdef PIOS_TARGET_PROVIDES_FAST_HEAP
extern char _sfastheap;
extern char _efastheap;
#define IS_FAST_HEAP_POINTER(x) (((void *)&_sfastheap < (void *)(x)) && ((void *)&_efastheap > (void *)(x)))
#else
#define IS_FAST_HEAP_POINTER(x) (false)
#endif
#if defined(PIOS_INCLUDE_FREERTOS)
/*
* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining
@ -52,62 +61,85 @@ extern char _eheap;
# include "task.h"
#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE
heap_handle_t sram_heap;
#if PIOS_TARGET_PROVIDES_FAST_HEAP
heap_handle_t fast_heap;
#else
#define fast_heap sram_heap
#endif
/*
* Optional callback for allocation failures.
*/
extern void vApplicationMallocFailedHook(void) __attribute__((weak));
void *
pvPortMalloc(size_t s)
pios_general_malloc(size_t s, bool use_fast_heap)
{
void *p;
vPortEnterCritical();
p = msheap_alloc(s);
if(use_fast_heap){
p = msheap_alloc(&fast_heap, s);
} else {
p = msheap_alloc(&sram_heap, s);
}
vPortExitCritical();
if (p == NULL && &vApplicationMallocFailedHook != NULL)
if (p == NULL && &vApplicationMallocFailedHook != NULL) {
vApplicationMallocFailedHook();
}
return p;
}
void *
pvPortMalloc(size_t s)
{
return pios_general_malloc(s, true);
}
void *
pvPortMallocStack(size_t s)
{
return pios_general_malloc(s, false);
}
void
vPortFree(void *p)
{
vPortEnterCritical();
msheap_free(p);
if(IS_FAST_HEAP_POINTER(p)){
msheap_free(&fast_heap, p);
} else {
msheap_free(&sram_heap, p);
}
vPortExitCritical();
}
size_t
xPortGetFreeHeapSize(void)
{
return msheap_free_space();
#ifdef PIOS_TARGET_PROVIDES_FAST_HEAP
return msheap_free_space(&sram_heap) + msheap_free_space(&fast_heap);
#else
return msheap_free_space(&sram_heap);
#endif
}
void
vPortInitialiseBlocks(void)
{
msheap_init(&_sheap, &_eheap);
msheap_init(&sram_heap, &_sheap, &_eheap);
#if PIOS_TARGET_PROVIDES_FAST_HEAP
msheap_init(&fast_heap, &_sfastheap, &_efastheap);
#endif
}
void
xPortIncreaseHeapSize(size_t bytes)
{
msheap_extend(bytes);
}
void *
malloc(size_t size)
{
return pvPortMalloc(size);
}
void
free(void *p)
{
return vPortFree(p);
msheap_extend(&sram_heap, bytes);
}
#else /* !PIOS_INCLUDE_FREERTOS */
@ -118,17 +150,17 @@ malloc(size_t size)
// static
if (!heap_init_done) {
msheap_init(&_sheap, &_eheap);
msheap_init(sram_heap, &_sheap, &_eheap);
heap_init_done = 1;
}
return msheap_alloc(size);
return msheap_alloc(sram_heap, size);
}
void
free(void *p)
{
return msheap_free(p);
return msheap_free(sram_heap, p);
}
#endif /* PIOS_INCLUDE_FREERTOS */

View File

@ -41,12 +41,6 @@ struct adxl345_dev {
uint32_t slave_num;
enum pios_adxl345_dev_magic magic;
};
#undef PIOS_INCLUDE_INSTRUMENTATION
#ifdef PIOS_INCLUDE_INSTRUMENTATION
#include <pios_instrumentation.h>
static int8_t counterUpd;
// Counter 0xA3450001 time it takes to transfer the requested amount of samples using PIOS_ADXL345_ReadAndAccumulateSamples
#endif
// ! Global structure for this device device
static struct adxl345_dev *dev;
@ -65,10 +59,7 @@ static struct adxl345_dev *PIOS_ADXL345_alloc(void)
{
struct adxl345_dev *adxl345_dev;
#ifdef PIOS_INCLUDE_INSTRUMENTATION
counterUpd = PIOS_Instrumentation_CreateCounter(0xA3450001);
#endif
adxl345_dev = (struct adxl345_dev *)pvPortMalloc(sizeof(*adxl345_dev));
adxl345_dev = (struct adxl345_dev *)pios_malloc(sizeof(*adxl345_dev));
if (!adxl345_dev) {
return NULL;
}
@ -108,7 +99,7 @@ static int32_t PIOS_ADXL345_ClaimBus()
if (PIOS_SPI_ClaimBus(dev->spi_id) != 0) {
return -2;
}
PIOS_SPI_SetClockSpeed(dev->spi_id, PIOS_SPI_PRESCALER_8);
PIOS_SPI_RC_PinSet(dev->spi_id, dev->slave_num, 0);
return 0;

View File

@ -73,7 +73,7 @@ static struct bma180_dev *PIOS_BMA180_alloc(void)
{
struct bma180_dev *bma180_dev;
bma180_dev = (struct bma180_dev *)pvPortMalloc(sizeof(*bma180_dev));
bma180_dev = (struct bma180_dev *)pios_malloc(sizeof(*bma180_dev));
if (!bma180_dev) {
return NULL;
}

View File

@ -273,7 +273,7 @@ DelayedCallbackInfo *PIOS_CALLBACKSCHEDULER_Create(
// if given priorityTask does not exist, create it
if (!task) {
// allocate memory if possible
task = (struct DelayedCallbackTaskStruct *)pvPortMalloc(sizeof(struct DelayedCallbackTaskStruct));
task = (struct DelayedCallbackTaskStruct *)pios_malloc(sizeof(struct DelayedCallbackTaskStruct));
if (!task) {
xSemaphoreGiveRecursive(mutex);
return NULL;
@ -329,7 +329,7 @@ DelayedCallbackInfo *PIOS_CALLBACKSCHEDULER_Create(
}
// initialize callback scheduling info
DelayedCallbackInfo *info = (DelayedCallbackInfo *)pvPortMalloc(sizeof(DelayedCallbackInfo));
DelayedCallbackInfo *info = (DelayedCallbackInfo *)pios_malloc(sizeof(DelayedCallbackInfo));
if (!info) {
xSemaphoreGiveRecursive(mutex);
return NULL; // error - not enough memory

View File

@ -71,7 +71,7 @@ static struct pios_com_dev *PIOS_COM_alloc(void)
{
struct pios_com_dev *com_dev;
com_dev = (struct pios_com_dev *)pvPortMalloc(sizeof(struct pios_com_dev));
com_dev = (struct pios_com_dev *)pios_malloc(sizeof(struct pios_com_dev));
if (!com_dev) {
return NULL;
}

View File

@ -66,7 +66,7 @@ void PIOS_DEBUGLOG_Initialize()
#if defined(PIOS_INCLUDE_FREERTOS)
if (!mutex) {
mutex = xSemaphoreCreateRecursiveMutex();
buffer = pvPortMalloc(sizeof(DebugLogEntryData));
buffer = pios_malloc(sizeof(DebugLogEntryData));
}
#else
buffer = &staticbuffer;

View File

@ -93,7 +93,7 @@ static struct jedec_flash_dev *PIOS_Flash_Jedec_alloc(void)
{
struct jedec_flash_dev *flash_dev;
flash_dev = (struct jedec_flash_dev *)pvPortMalloc(sizeof(*flash_dev));
flash_dev = (struct jedec_flash_dev *)pios_malloc(sizeof(*flash_dev));
if (!flash_dev) {
return NULL;
}

View File

@ -485,7 +485,7 @@ static struct logfs_state *PIOS_FLASHFS_Logfs_alloc(void)
{
struct logfs_state *logfs;
logfs = (struct logfs_state *)pvPortMalloc(sizeof(*logfs));
logfs = (struct logfs_state *)pios_malloc(sizeof(*logfs));
if (!logfs) {
return NULL;
}

View File

@ -70,7 +70,7 @@ static struct pios_gcsrcvr_dev *PIOS_gcsrcvr_alloc(void)
{
struct pios_gcsrcvr_dev *gcsrcvr_dev;
gcsrcvr_dev = (struct pios_gcsrcvr_dev *)pvPortMalloc(sizeof(*gcsrcvr_dev));
gcsrcvr_dev = (struct pios_gcsrcvr_dev *)pios_malloc(sizeof(*gcsrcvr_dev));
if (!gcsrcvr_dev) {
return NULL;
}

View File

@ -69,7 +69,7 @@ static struct pios_hcsr04_dev *PIOS_PWM_alloc(void)
{
struct pios_hcsr04_dev *hcsr04_dev;
hcsr04_dev = (struct pios_hcsr04_dev *)pvPortMalloc(sizeof(*hcsr04_dev));
hcsr04_dev = (struct pios_hcsr04_dev *)pios_malloc(sizeof(*hcsr04_dev));
if (!hcsr04_dev) {
return NULL;
}

View File

@ -77,7 +77,7 @@ static struct l3gd20_dev *PIOS_L3GD20_alloc(void)
{
struct l3gd20_dev *l3gd20_dev;
l3gd20_dev = (struct l3gd20_dev *)pvPortMalloc(sizeof(*l3gd20_dev));
l3gd20_dev = (struct l3gd20_dev *)pios_malloc(sizeof(*l3gd20_dev));
if (!l3gd20_dev) {
return NULL;
}

View File

@ -0,0 +1,68 @@
/**
******************************************************************************
*
* @file pios_mem.c
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2014.
* @addtogroup PiOS
* @{
* @addtogroup PiOS
* @{
* @brief PiOS memory allocation API
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <pios.h>
#include <pios_mem.h>
#ifdef PIOS_TARGET_PROVIDES_FAST_HEAP
// relies on pios_general_malloc to perform the allocation (i.e. pios_msheap.c)
extern void *pios_general_malloc(size_t size, bool fastheap);
void *pios_fastheapmalloc(size_t size)
{
return pios_general_malloc(size, true);
}
void *pios_malloc(size_t size)
{
return pios_general_malloc(size, false);
}
void pios_free(void *p)
{
vPortFree(p);
}
#else
// demand to pvPortMalloc implementation
void *pios_fastheapmalloc(size_t size)
{
return pvPortMalloc(size);
}
void *pios_malloc(size_t size)
{
return pvPortMalloc(size);
}
void pios_free(void *p)
{
vPortFree(p);
}
#endif /* ifdef PIOS_TARGET_PROVIDES_FAST_HEAP */

View File

@ -79,7 +79,7 @@ static struct mpu6000_dev *PIOS_MPU6000_alloc(void)
{
struct mpu6000_dev *mpu6000_dev;
mpu6000_dev = (struct mpu6000_dev *)pvPortMalloc(sizeof(*mpu6000_dev));
mpu6000_dev = (struct mpu6000_dev *)pios_malloc(sizeof(*mpu6000_dev));
if (!mpu6000_dev) {
return NULL;
}

View File

@ -70,7 +70,7 @@ static struct pios_oplinkrcvr_dev *PIOS_oplinkrcvr_alloc(void)
{
struct pios_oplinkrcvr_dev *oplinkrcvr_dev;
oplinkrcvr_dev = (struct pios_oplinkrcvr_dev *)pvPortMalloc(sizeof(*oplinkrcvr_dev));
oplinkrcvr_dev = (struct pios_oplinkrcvr_dev *)pios_malloc(sizeof(*oplinkrcvr_dev));
if (!oplinkrcvr_dev) {
return NULL;
}

View File

@ -24,7 +24,7 @@ static struct pios_rcvr_dev *PIOS_RCVR_alloc(void)
{
struct pios_rcvr_dev *rcvr_dev;
rcvr_dev = (struct pios_rcvr_dev *)pvPortMalloc(sizeof(*rcvr_dev));
rcvr_dev = (struct pios_rcvr_dev *)pios_malloc(sizeof(*rcvr_dev));
if (!rcvr_dev) {
return NULL;
}

View File

@ -2408,7 +2408,7 @@ static struct pios_rfm22b_dev *pios_rfm22_alloc(void)
{
struct pios_rfm22b_dev *rfm22b_dev;
rfm22b_dev = (struct pios_rfm22b_dev *)pvPortMalloc(sizeof(*rfm22b_dev));
rfm22b_dev = (struct pios_rfm22b_dev *)pios_malloc(sizeof(*rfm22b_dev));
rfm22b_dev->spi_id = 0;
if (!rfm22b_dev) {
return NULL;

View File

@ -74,7 +74,7 @@ static struct pios_sbus_dev *PIOS_SBus_Alloc(void)
{
struct pios_sbus_dev *sbus_dev;
sbus_dev = (struct pios_sbus_dev *)pvPortMalloc(sizeof(*sbus_dev));
sbus_dev = (struct pios_sbus_dev *)pios_malloc(sizeof(*sbus_dev));
if (!sbus_dev) {
return NULL;
}

View File

@ -46,7 +46,7 @@ int32_t PIOS_TASK_MONITOR_Initialize(uint16_t max_tasks)
return -1;
}
mTaskHandles = (xTaskHandle *)pvPortMalloc(max_tasks * sizeof(xTaskHandle));
mTaskHandles = (xTaskHandle *)pios_malloc(max_tasks * sizeof(xTaskHandle));
if (!mTaskHandles) {
return -1;
}

View File

@ -0,0 +1,36 @@
/**
******************************************************************************
*
* @file pios_mem.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2014.
* @addtogroup PiOS
* @{
* @addtogroup PiOS
* @{
* @brief PiOS memory allocation API
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef PIOS_MEM_H
#define PIOS_MEM_H
void *pios_fastheapmalloc(size_t size);
void *pios_malloc(size_t size);
void pios_free(void *p);
#endif /* PIOS_MEM_H */

View File

@ -81,9 +81,10 @@
#include "queue.h"
#include "semphr.h"
#endif
#include <stdbool.h>
#include <pios_mem.h>
#include <pios_architecture.h>
#ifdef PIOS_INCLUDE_TASK_MONITOR

View File

@ -39,6 +39,7 @@
#include "queue.h"
#include "semphr.h"
#endif
#include <pios_mem.h>
#ifdef PIOS_INCLUDE_TASK_MONITOR
#ifndef PIOS_INCLUDE_FREERTOS

View File

@ -94,7 +94,7 @@ static struct pios_adc_dev *PIOS_ADC_Allocate()
{
struct pios_adc_dev *adc_dev;
adc_dev = (struct pios_adc_dev *)pvPortMalloc(sizeof(*adc_dev));
adc_dev = (struct pios_adc_dev *)pios_malloc(sizeof(*adc_dev));
if (!adc_dev) {
return NULL;
}

View File

@ -79,7 +79,7 @@ static struct pios_dsm_dev *PIOS_DSM_Alloc(void)
{
struct pios_dsm_dev *dsm_dev;
dsm_dev = (struct pios_dsm_dev *)pvPortMalloc(sizeof(*dsm_dev));
dsm_dev = (struct pios_dsm_dev *)pios_malloc(sizeof(*dsm_dev));
if (!dsm_dev) {
return NULL;
}

View File

@ -76,7 +76,7 @@ static struct pios_internal_flash_dev *PIOS_Flash_Internal_alloc(void)
{
struct pios_internal_flash_dev *flash_dev;
flash_dev = (struct pios_internal_flash_dev *)pvPortMalloc(sizeof(*flash_dev));
flash_dev = (struct pios_internal_flash_dev *)pios_malloc(sizeof(*flash_dev));
if (!flash_dev) {
return NULL;
}

View File

@ -835,7 +835,7 @@ static struct pios_i2c_adapter *PIOS_I2C_alloc(void)
{
struct pios_i2c_adapter *i2c_adapter;
i2c_adapter = (struct pios_i2c_adapter *)pvPortMalloc(sizeof(*i2c_adapter));
i2c_adapter = (struct pios_i2c_adapter *)pios_malloc(sizeof(*i2c_adapter));
if (!i2c_adapter) {
return NULL;
}

View File

@ -97,7 +97,7 @@ static struct pios_ppm_dev *PIOS_PPM_alloc(void)
{
struct pios_ppm_dev *ppm_dev;
ppm_dev = (struct pios_ppm_dev *)pvPortMalloc(sizeof(*ppm_dev));
ppm_dev = (struct pios_ppm_dev *)pios_malloc(sizeof(*ppm_dev));
if (!ppm_dev) {
return NULL;
}

View File

@ -73,7 +73,7 @@ static struct pios_ppm_out_dev *PIOS_PPM_OUT_alloc(void)
{
struct pios_ppm_out_dev *ppm_dev;
ppm_dev = (struct pios_ppm_out_dev *)pvPortMalloc(sizeof(*ppm_dev));
ppm_dev = (struct pios_ppm_out_dev *)pios_malloc(sizeof(*ppm_dev));
if (!ppm_dev) {
return NULL;
}

View File

@ -72,7 +72,7 @@ static struct pios_pwm_dev *PIOS_PWM_alloc(void)
{
struct pios_pwm_dev *pwm_dev;
pwm_dev = (struct pios_pwm_dev *)pvPortMalloc(sizeof(*pwm_dev));
pwm_dev = (struct pios_pwm_dev *)pios_malloc(sizeof(*pwm_dev));
if (!pwm_dev) {
return NULL;
}

View File

@ -48,7 +48,7 @@ static bool PIOS_SPI_validate(__attribute__((unused)) struct pios_spi_dev *com_d
#if defined(PIOS_INCLUDE_FREERTOS)
static struct pios_spi_dev *PIOS_SPI_alloc(void)
{
return pvPortMalloc(sizeof(struct pios_spi_dev));
return pios_malloc(sizeof(struct pios_spi_dev));
}
#else
static struct pios_spi_dev pios_spi_devs[PIOS_SPI_MAX_DEVS];

View File

@ -30,7 +30,7 @@ static struct pios_tim_dev *PIOS_TIM_alloc(void)
{
struct pios_tim_dev *tim_dev;
tim_dev = (struct pios_tim_dev *)malloc(sizeof(*tim_dev));
tim_dev = (struct pios_tim_dev *)pios_malloc(sizeof(*tim_dev));
if (!tim_dev) {
return NULL;
}

View File

@ -75,7 +75,7 @@ static struct pios_usart_dev *PIOS_USART_alloc(void)
{
struct pios_usart_dev *usart_dev;
usart_dev = (struct pios_usart_dev *)pvPortMalloc(sizeof(struct pios_usart_dev));
usart_dev = (struct pios_usart_dev *)pios_malloc(sizeof(struct pios_usart_dev));
if (!usart_dev) {
return NULL;
}

View File

@ -74,7 +74,7 @@ static struct pios_usb_dev *PIOS_USB_alloc(void)
{
struct pios_usb_dev *usb_dev;
usb_dev = (struct pios_usb_dev *)pvPortMalloc(sizeof(*usb_dev));
usb_dev = (struct pios_usb_dev *)pios_malloc(sizeof(*usb_dev));
if (!usb_dev) {
return NULL;
}

View File

@ -90,7 +90,7 @@ static struct pios_usb_cdc_dev *PIOS_USB_CDC_alloc(void)
{
struct pios_usb_cdc_dev *usb_cdc_dev;
usb_cdc_dev = (struct pios_usb_cdc_dev *)pvPortMalloc(sizeof(struct pios_usb_cdc_dev));
usb_cdc_dev = (struct pios_usb_cdc_dev *)pios_malloc(sizeof(struct pios_usb_cdc_dev));
if (!usb_cdc_dev) {
return NULL;
}

View File

@ -84,7 +84,7 @@ static struct pios_usb_hid_dev *PIOS_USB_HID_alloc(void)
{
struct pios_usb_hid_dev *usb_hid_dev;
usb_hid_dev = (struct pios_usb_hid_dev *)pvPortMalloc(sizeof(struct pios_usb_hid_dev));
usb_hid_dev = (struct pios_usb_hid_dev *)pios_malloc(sizeof(struct pios_usb_hid_dev));
if (!usb_hid_dev) {
return NULL;
}

View File

@ -65,7 +65,7 @@ static struct pios_usb_rctx_dev *PIOS_USB_RCTX_alloc(void)
{
struct pios_usb_rctx_dev *usb_rctx_dev;
usb_rctx_dev = (struct pios_usb_rctx_dev *)pvPortMalloc(sizeof(*usb_rctx_dev));
usb_rctx_dev = (struct pios_usb_rctx_dev *)pios_malloc(sizeof(*usb_rctx_dev));
if (!usb_rctx_dev) {
return NULL;
}

View File

@ -20,6 +20,7 @@ CDEFS += -DSYSCLK_FREQ=$(SYSCLK_FREQ)
CDEFS += -DHSE_VALUE=$(OSCILLATOR_FREQ)
CDEFS += -DUSE_STDPERIPH_DRIVER
CDEFS += -DARM_MATH_CM4 -D__FPU_PRESENT=1
CDEFS += -DPIOS_TARGET_PROVIDES_FAST_HEAP
ARCHFLAGS += -mcpu=cortex-m4 -march=armv7e-m -mfpu=fpv4-sp-d16 -mfloat-abi=hard
# PIOS device library source and includes

View File

@ -139,7 +139,24 @@ SECTIONS
*(.fast)
_efast = . ;
} > CCSRAM
.fastheap (NOLOAD) :
{
. = ALIGN(4);
_sfastheap = . ;
/*
* This allows us to declare an object or objects up to the minimum acceptable
* heap size and receive a linker error if the space available for the heap is
* not sufficient.
*/
*(.fastheap)
/* extend the fastheap up to the top of CCSRAM */
. = ORIGIN(CCSRAM) + LENGTH(CCSRAM) - ABSOLUTE(_sfastheap);
_efastheap = .;
} > CCSRAM
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }

View File

@ -238,7 +238,7 @@ static struct pios_adc_dev *PIOS_ADC_Allocate()
{
struct pios_adc_dev *adc_dev;
adc_dev = (struct pios_adc_dev *)pvPortMalloc(sizeof(*adc_dev));
adc_dev = (struct pios_adc_dev *)pios_malloc(sizeof(*adc_dev));
if (!adc_dev) {
return NULL;
}

View File

@ -82,7 +82,7 @@ static struct pios_dsm_dev *PIOS_DSM_Alloc(void)
{
struct pios_dsm_dev *dsm_dev;
dsm_dev = (struct pios_dsm_dev *)pvPortMalloc(sizeof(*dsm_dev));
dsm_dev = (struct pios_dsm_dev *)pios_malloc(sizeof(*dsm_dev));
if (!dsm_dev) {
return NULL;
}

View File

@ -141,7 +141,7 @@ static struct pios_internal_flash_dev *PIOS_Flash_Internal_alloc(void)
{
struct pios_internal_flash_dev *flash_dev;
flash_dev = (struct pios_internal_flash_dev *)pvPortMalloc(sizeof(*flash_dev));
flash_dev = (struct pios_internal_flash_dev *)pios_malloc(sizeof(*flash_dev));
if (!flash_dev) {
return NULL;
}

View File

@ -903,7 +903,7 @@ static struct pios_i2c_dev *PIOS_I2C_alloc(void)
{
struct pios_i2c_dev *i2c_adapter;
i2c_adapter = (struct pios_i2c_adapter *)malloc(sizeof(*i2c_adapter));
i2c_adapter = (struct pios_i2c_adapter *)pios_malloc(sizeof(*i2c_adapter));
if (!i2c_adapter) {
return NULL;
}

View File

@ -98,7 +98,7 @@ static struct pios_overo_dev *PIOS_OVERO_alloc(void)
{
struct pios_overo_dev *overo_dev;
overo_dev = (struct pios_overo_dev *)pvPortMalloc(sizeof(*overo_dev));
overo_dev = (struct pios_overo_dev *)pios_malloc(sizeof(*overo_dev));
if (!overo_dev) {
return NULL;
}

View File

@ -92,7 +92,7 @@ static struct pios_ppm_dev *PIOS_PPM_alloc(void)
{
struct pios_ppm_dev *ppm_dev;
ppm_dev = (struct pios_ppm_dev *)pvPortMalloc(sizeof(*ppm_dev));
ppm_dev = (struct pios_ppm_dev *)pios_malloc(sizeof(*ppm_dev));
if (!ppm_dev) {
return NULL;
}

View File

@ -71,7 +71,7 @@ static struct pios_pwm_dev *PIOS_PWM_alloc(void)
{
struct pios_pwm_dev *pwm_dev;
pwm_dev = (struct pios_pwm_dev *)pvPortMalloc(sizeof(*pwm_dev));
pwm_dev = (struct pios_pwm_dev *)pios_malloc(sizeof(*pwm_dev));
if (!pwm_dev) {
return NULL;
}

View File

@ -53,7 +53,7 @@ static bool PIOS_SPI_validate(__attribute__((unused)) struct pios_spi_dev *com_d
#if defined(PIOS_INCLUDE_FREERTOS)
static struct pios_spi_dev *PIOS_SPI_alloc(void)
{
return pvPortMalloc(sizeof(struct pios_spi_dev));
return pios_malloc(sizeof(struct pios_spi_dev));
}
#else
static struct pios_spi_dev pios_spi_devs[PIOS_SPI_MAX_DEVS];

View File

@ -77,7 +77,7 @@ static struct pios_usart_dev *PIOS_USART_alloc(void)
{
struct pios_usart_dev *usart_dev;
usart_dev = (struct pios_usart_dev *)pvPortMalloc(sizeof(struct pios_usart_dev));
usart_dev = (struct pios_usart_dev *)pios_malloc(sizeof(struct pios_usart_dev));
if (!usart_dev) {
return NULL;
}

View File

@ -70,7 +70,7 @@ static struct pios_usb_dev *PIOS_USB_alloc(void)
{
struct pios_usb_dev *usb_dev;
usb_dev = (struct pios_usb_dev *)pvPortMalloc(sizeof(*usb_dev));
usb_dev = (struct pios_usb_dev *)pios_malloc(sizeof(*usb_dev));
if (!usb_dev) {
return NULL;
}

View File

@ -103,7 +103,7 @@ static struct pios_usb_cdc_dev *PIOS_USB_CDC_alloc(void)
{
struct pios_usb_cdc_dev *usb_cdc_dev;
usb_cdc_dev = (struct pios_usb_cdc_dev *)pvPortMalloc(sizeof(struct pios_usb_cdc_dev));
usb_cdc_dev = (struct pios_usb_cdc_dev *)pios_malloc(sizeof(struct pios_usb_cdc_dev));
if (!usb_cdc_dev) {
return NULL;
}

View File

@ -87,7 +87,7 @@ static struct pios_usb_hid_dev *PIOS_USB_HID_alloc(void)
{
struct pios_usb_hid_dev *usb_hid_dev;
usb_hid_dev = (struct pios_usb_hid_dev *)pvPortMalloc(sizeof(struct pios_usb_hid_dev));
usb_hid_dev = (struct pios_usb_hid_dev *)pios_malloc(sizeof(struct pios_usb_hid_dev));
if (!usb_hid_dev) {
return NULL;
}

View File

@ -175,7 +175,7 @@ void PIOS_WS2811_Init(const struct pios_ws2811_cfg *ws2811_cfg, const struct pio
dmaSource[i] = (ledbuf_t)pios_ws2811_pin_cfg->gpioInit.GPIO_Pin;
}
fb = (ledbuf_t *)pvPortMalloc(PIOS_WS2811_BUFFER_SIZE * sizeof(ledbuf_t));
fb = (ledbuf_t *)pios_malloc(PIOS_WS2811_BUFFER_SIZE * sizeof(ledbuf_t));
memset(fb, 0, PIOS_WS2811_BUFFER_SIZE * sizeof(ledbuf_t));
Color ledoff = { 0, 0, 0 };
for (uint8_t i = 0; i < PIOS_WS2811_NUMLEDS; i++) {

View File

@ -309,8 +309,8 @@ void PIOS_Board_Init(void)
if (PIOS_USB_CDC_Init(&pios_usb_cdc_id, &pios_usb_cdc_cfg, pios_usb_id)) {
PIOS_Assert(0);
}
uint8_t *rx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_TELEM_USB_RX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_TELEM_USB_TX_BUF_LEN);
uint8_t *rx_buffer = (uint8_t *)pios_malloc(PIOS_COM_TELEM_USB_RX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pios_malloc(PIOS_COM_TELEM_USB_TX_BUF_LEN);
PIOS_Assert(rx_buffer);
PIOS_Assert(tx_buffer);
if (PIOS_COM_Init(&pios_com_telem_usb_id, &pios_usb_cdc_com_driver, pios_usb_cdc_id,
@ -328,8 +328,8 @@ void PIOS_Board_Init(void)
if (PIOS_USB_CDC_Init(&pios_usb_cdc_id, &pios_usb_cdc_cfg, pios_usb_id)) {
PIOS_Assert(0);
}
uint8_t *rx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_BRIDGE_RX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_BRIDGE_TX_BUF_LEN);
uint8_t *rx_buffer = (uint8_t *)pios_malloc(PIOS_COM_BRIDGE_RX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pios_malloc(PIOS_COM_BRIDGE_TX_BUF_LEN);
PIOS_Assert(rx_buffer);
PIOS_Assert(tx_buffer);
if (PIOS_COM_Init(&pios_com_vcp_id, &pios_usb_cdc_com_driver, pios_usb_cdc_id,
@ -348,7 +348,7 @@ void PIOS_Board_Init(void)
if (PIOS_USB_CDC_Init(&pios_usb_cdc_id, &pios_usb_cdc_cfg, pios_usb_id)) {
PIOS_Assert(0);
}
uint8_t *tx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_DEBUGCONSOLE_TX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pios_malloc(PIOS_COM_DEBUGCONSOLE_TX_BUF_LEN);
PIOS_Assert(tx_buffer);
if (PIOS_COM_Init(&pios_com_debug_id, &pios_usb_cdc_com_driver, pios_usb_cdc_id,
NULL, 0,
@ -382,8 +382,8 @@ void PIOS_Board_Init(void)
if (PIOS_USB_HID_Init(&pios_usb_hid_id, &pios_usb_hid_cfg, pios_usb_id)) {
PIOS_Assert(0);
}
uint8_t *rx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_TELEM_USB_RX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_TELEM_USB_TX_BUF_LEN);
uint8_t *rx_buffer = (uint8_t *)pios_malloc(PIOS_COM_TELEM_USB_RX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pios_malloc(PIOS_COM_TELEM_USB_TX_BUF_LEN);
PIOS_Assert(rx_buffer);
PIOS_Assert(tx_buffer);
if (PIOS_COM_Init(&pios_com_telem_usb_id, &pios_usb_hid_com_driver, pios_usb_hid_id,
@ -426,8 +426,8 @@ void PIOS_Board_Init(void)
PIOS_Assert(0);
}
uint8_t *rx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_TELEM_RF_RX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_TELEM_RF_TX_BUF_LEN);
uint8_t *rx_buffer = (uint8_t *)pios_malloc(PIOS_COM_TELEM_RF_RX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pios_malloc(PIOS_COM_TELEM_RF_TX_BUF_LEN);
PIOS_Assert(rx_buffer);
PIOS_Assert(tx_buffer);
if (PIOS_COM_Init(&pios_com_telem_rf_id, &pios_usart_com_driver, pios_usart_generic_id,
@ -467,7 +467,7 @@ void PIOS_Board_Init(void)
PIOS_Assert(0);
}
uint8_t *rx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_GPS_RX_BUF_LEN);
uint8_t *rx_buffer = (uint8_t *)pios_malloc(PIOS_COM_GPS_RX_BUF_LEN);
PIOS_Assert(rx_buffer);
if (PIOS_COM_Init(&pios_com_gps_id, &pios_usart_com_driver, pios_usart_generic_id,
rx_buffer, PIOS_COM_GPS_RX_BUF_LEN,
@ -529,7 +529,7 @@ void PIOS_Board_Init(void)
PIOS_Assert(0);
}
uint8_t *tx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_DEBUGCONSOLE_TX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pios_malloc(PIOS_COM_DEBUGCONSOLE_TX_BUF_LEN);
PIOS_Assert(tx_buffer);
if (PIOS_COM_Init(&pios_com_debug_id, &pios_usart_com_driver, pios_usart_generic_id,
NULL, 0,
@ -547,9 +547,9 @@ void PIOS_Board_Init(void)
PIOS_Assert(0);
}
uint8_t *rx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_BRIDGE_RX_BUF_LEN);
uint8_t *rx_buffer = (uint8_t *)pios_malloc(PIOS_COM_BRIDGE_RX_BUF_LEN);
PIOS_Assert(rx_buffer);
uint8_t *tx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_BRIDGE_TX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pios_malloc(PIOS_COM_BRIDGE_TX_BUF_LEN);
PIOS_Assert(tx_buffer);
if (PIOS_COM_Init(&pios_com_bridge_id, &pios_usart_com_driver, pios_usart_generic_id,
rx_buffer, PIOS_COM_BRIDGE_RX_BUF_LEN,
@ -565,7 +565,7 @@ void PIOS_Board_Init(void)
PIOS_Assert(0);
}
uint8_t *tx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_HKOSD_TX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pios_malloc(PIOS_COM_HKOSD_TX_BUF_LEN);
PIOS_Assert(tx_buffer);
if (PIOS_COM_Init(&pios_com_hkosd_id, &pios_usart_com_driver, pios_usart_hkosd_id,
NULL, 0,
@ -590,8 +590,8 @@ void PIOS_Board_Init(void)
if (PIOS_USART_Init(&pios_usart_generic_id, &pios_usart_generic_flexi_cfg)) {
PIOS_Assert(0);
}
uint8_t *rx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_TELEM_RF_RX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_TELEM_RF_TX_BUF_LEN);
uint8_t *rx_buffer = (uint8_t *)pios_malloc(PIOS_COM_TELEM_RF_RX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pios_malloc(PIOS_COM_TELEM_RF_TX_BUF_LEN);
PIOS_Assert(rx_buffer);
PIOS_Assert(tx_buffer);
if (PIOS_COM_Init(&pios_com_telem_rf_id, &pios_usart_com_driver, pios_usart_generic_id,
@ -609,8 +609,8 @@ void PIOS_Board_Init(void)
PIOS_Assert(0);
}
uint8_t *rx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_BRIDGE_RX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_BRIDGE_TX_BUF_LEN);
uint8_t *rx_buffer = (uint8_t *)pios_malloc(PIOS_COM_BRIDGE_RX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pios_malloc(PIOS_COM_BRIDGE_TX_BUF_LEN);
PIOS_Assert(rx_buffer);
PIOS_Assert(tx_buffer);
if (PIOS_COM_Init(&pios_com_bridge_id, &pios_usart_com_driver, pios_usart_generic_id,
@ -627,7 +627,7 @@ void PIOS_Board_Init(void)
if (PIOS_USART_Init(&pios_usart_generic_id, &pios_usart_generic_flexi_cfg)) {
PIOS_Assert(0);
}
uint8_t *rx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_GPS_RX_BUF_LEN);
uint8_t *rx_buffer = (uint8_t *)pios_malloc(PIOS_COM_GPS_RX_BUF_LEN);
PIOS_Assert(rx_buffer);
if (PIOS_COM_Init(&pios_com_gps_id, &pios_usart_com_driver, pios_usart_generic_id,
rx_buffer, PIOS_COM_GPS_RX_BUF_LEN,
@ -703,7 +703,7 @@ void PIOS_Board_Init(void)
PIOS_Assert(0);
}
uint8_t *tx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_DEBUGCONSOLE_TX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pios_malloc(PIOS_COM_DEBUGCONSOLE_TX_BUF_LEN);
PIOS_Assert(tx_buffer);
if (PIOS_COM_Init(&pios_com_debug_id, &pios_usart_com_driver, pios_usart_generic_id,
NULL, 0,
@ -730,7 +730,7 @@ void PIOS_Board_Init(void)
PIOS_Assert(0);
}
uint8_t *tx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_HKOSD_TX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pios_malloc(PIOS_COM_HKOSD_TX_BUF_LEN);
PIOS_Assert(tx_buffer);
if (PIOS_COM_Init(&pios_com_hkosd_id, &pios_usart_com_driver, pios_usart_hkosd_id,
NULL, 0,

View File

@ -254,10 +254,10 @@ static void PIOS_Board_configure_com(const struct pios_usart_cfg *usart_port_cfg
PIOS_Assert(0);
}
uint8_t *rx_buffer = (uint8_t *)pvPortMalloc(rx_buf_len);
uint8_t *rx_buffer = (uint8_t *)pios_malloc(rx_buf_len);
PIOS_Assert(rx_buffer);
if (tx_buf_len != (size_t)-1) { // this is the case for rx/tx ports
uint8_t *tx_buffer = (uint8_t *)pvPortMalloc(tx_buf_len);
uint8_t *tx_buffer = (uint8_t *)pios_malloc(tx_buf_len);
PIOS_Assert(tx_buffer);
if (PIOS_COM_Init(pios_com_id, com_driver, pios_usart_id,
@ -493,8 +493,8 @@ void PIOS_Board_Init(void)
case HWSETTINGS_USB_VCPPORT_USBTELEMETRY:
#if defined(PIOS_INCLUDE_COM)
{
uint8_t *rx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_TELEM_USB_RX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_TELEM_USB_TX_BUF_LEN);
uint8_t *rx_buffer = (uint8_t *)pios_malloc(PIOS_COM_TELEM_USB_RX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pios_malloc(PIOS_COM_TELEM_USB_TX_BUF_LEN);
PIOS_Assert(rx_buffer);
PIOS_Assert(tx_buffer);
if (PIOS_COM_Init(&pios_com_telem_usb_id, &pios_usb_cdc_com_driver, pios_usb_cdc_id,
@ -508,8 +508,8 @@ void PIOS_Board_Init(void)
case HWSETTINGS_USB_VCPPORT_COMBRIDGE:
#if defined(PIOS_INCLUDE_COM)
{
uint8_t *rx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_BRIDGE_RX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_BRIDGE_TX_BUF_LEN);
uint8_t *rx_buffer = (uint8_t *)pios_malloc(PIOS_COM_BRIDGE_RX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pios_malloc(PIOS_COM_BRIDGE_TX_BUF_LEN);
PIOS_Assert(rx_buffer);
PIOS_Assert(tx_buffer);
if (PIOS_COM_Init(&pios_com_vcp_id, &pios_usb_cdc_com_driver, pios_usb_cdc_id,
@ -524,7 +524,7 @@ void PIOS_Board_Init(void)
#if defined(PIOS_INCLUDE_COM)
#if defined(PIOS_INCLUDE_DEBUG_CONSOLE)
{
uint8_t *tx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_DEBUGCONSOLE_TX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pios_malloc(PIOS_COM_DEBUGCONSOLE_TX_BUF_LEN);
PIOS_Assert(tx_buffer);
if (PIOS_COM_Init(&pios_com_debug_id, &pios_usb_cdc_com_driver, pios_usb_cdc_id,
NULL, 0,
@ -555,8 +555,8 @@ void PIOS_Board_Init(void)
case HWSETTINGS_USB_HIDPORT_USBTELEMETRY:
#if defined(PIOS_INCLUDE_COM)
{
uint8_t *rx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_TELEM_USB_RX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_TELEM_USB_TX_BUF_LEN);
uint8_t *rx_buffer = (uint8_t *)pios_malloc(PIOS_COM_TELEM_USB_RX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pios_malloc(PIOS_COM_TELEM_USB_TX_BUF_LEN);
PIOS_Assert(rx_buffer);
PIOS_Assert(tx_buffer);
if (PIOS_COM_Init(&pios_com_telem_usb_id, &pios_usb_hid_com_driver, pios_usb_hid_id,
@ -750,8 +750,8 @@ void PIOS_Board_Init(void)
}
/* Configure the radio com interface */
uint8_t *rx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_RFM22B_RF_RX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_RFM22B_RF_TX_BUF_LEN);
uint8_t *rx_buffer = (uint8_t *)pios_malloc(PIOS_COM_RFM22B_RF_RX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pios_malloc(PIOS_COM_RFM22B_RF_TX_BUF_LEN);
PIOS_Assert(rx_buffer);
PIOS_Assert(tx_buffer);
if (PIOS_COM_Init(&pios_com_telem_rf_id, &pios_rfm22b_com_driver, pios_rfm22b_id,

View File

@ -185,8 +185,8 @@ void PIOS_Board_Init(void)
if (PIOS_USB_HID_Init(&pios_usb_hid_id, &pios_usb_hid_cfg, pios_usb_id)) {
PIOS_Assert(0);
}
uint8_t *rx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_TELEM_USB_RX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_TELEM_USB_TX_BUF_LEN);
uint8_t *rx_buffer = (uint8_t *)pios_malloc(PIOS_COM_TELEM_USB_RX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pios_malloc(PIOS_COM_TELEM_USB_TX_BUF_LEN);
PIOS_Assert(rx_buffer);
PIOS_Assert(tx_buffer);
if (PIOS_COM_Init(&pios_com_telem_usb_id, &pios_usb_hid_com_driver, pios_usb_hid_id,
@ -203,8 +203,8 @@ void PIOS_Board_Init(void)
if (PIOS_USB_CDC_Init(&pios_usb_cdc_id, &pios_usb_cdc_cfg, pios_usb_id)) {
PIOS_Assert(0);
}
uint8_t *rx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_TELEM_VCP_RX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_TELEM_VCP_TX_BUF_LEN);
uint8_t *rx_buffer = (uint8_t *)pios_malloc(PIOS_COM_TELEM_VCP_RX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pios_malloc(PIOS_COM_TELEM_VCP_TX_BUF_LEN);
PIOS_Assert(rx_buffer);
PIOS_Assert(tx_buffer);
if (PIOS_COM_Init(&pios_com_telem_vcp_id, &pios_usb_cdc_com_driver, pios_usb_cdc_id,
@ -216,8 +216,8 @@ void PIOS_Board_Init(void)
#endif
/* Allocate the uart buffers. */
pios_uart_rx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_TELEM_RX_BUF_LEN);
pios_uart_tx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_TELEM_TX_BUF_LEN);
pios_uart_rx_buffer = (uint8_t *)pios_malloc(PIOS_COM_TELEM_RX_BUF_LEN);
pios_uart_tx_buffer = (uint8_t *)pios_malloc(PIOS_COM_TELEM_TX_BUF_LEN);
// Configure the main port
OPLinkSettingsData oplinkSettings;
@ -372,8 +372,8 @@ void PIOS_Board_Init(void)
}
// Configure the radio com interface
uint8_t *rx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_RFM22B_RF_RX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_RFM22B_RF_TX_BUF_LEN);
uint8_t *rx_buffer = (uint8_t *)pios_malloc(PIOS_COM_RFM22B_RF_RX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pios_malloc(PIOS_COM_RFM22B_RF_TX_BUF_LEN);
PIOS_Assert(rx_buffer);
PIOS_Assert(tx_buffer);
if (PIOS_COM_Init(&pios_com_rfm22b_id, &pios_rfm22b_com_driver, pios_rfm22b_id,

View File

@ -260,8 +260,8 @@ void PIOS_Board_Init(void)
if (PIOS_USB_CDC_Init(&pios_usb_cdc_id, &pios_usb_cdc_cfg, pios_usb_id)) {
PIOS_Assert(0);
}
uint8_t *rx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_TELEM_USB_RX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_TELEM_USB_TX_BUF_LEN);
uint8_t *rx_buffer = (uint8_t *)pios_malloc(PIOS_COM_TELEM_USB_RX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pios_malloc(PIOS_COM_TELEM_USB_TX_BUF_LEN);
PIOS_Assert(rx_buffer);
PIOS_Assert(tx_buffer);
if (PIOS_COM_Init(&pios_com_telem_usb_id, &pios_usb_cdc_com_driver, pios_usb_cdc_id,
@ -279,8 +279,8 @@ void PIOS_Board_Init(void)
if (PIOS_USB_CDC_Init(&pios_usb_cdc_id, &pios_usb_cdc_cfg, pios_usb_id)) {
PIOS_Assert(0);
}
uint8_t *rx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_BRIDGE_RX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_BRIDGE_TX_BUF_LEN);
uint8_t *rx_buffer = (uint8_t *)pios_malloc(PIOS_COM_BRIDGE_RX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pios_malloc(PIOS_COM_BRIDGE_TX_BUF_LEN);
PIOS_Assert(rx_buffer);
PIOS_Assert(tx_buffer);
if (PIOS_COM_Init(&pios_com_vcp_id, &pios_usb_cdc_com_driver, pios_usb_cdc_id,
@ -314,8 +314,8 @@ void PIOS_Board_Init(void)
if (PIOS_USB_HID_Init(&pios_usb_hid_id, &pios_usb_hid_cfg, pios_usb_id)) {
PIOS_Assert(0);
}
uint8_t *rx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_TELEM_USB_RX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_TELEM_USB_TX_BUF_LEN);
uint8_t *rx_buffer = (uint8_t *)pios_malloc(PIOS_COM_TELEM_USB_RX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pios_malloc(PIOS_COM_TELEM_USB_TX_BUF_LEN);
PIOS_Assert(rx_buffer);
PIOS_Assert(tx_buffer);
if (PIOS_COM_Init(&pios_com_telem_usb_id, &pios_usb_hid_com_driver, pios_usb_hid_id,
@ -343,7 +343,7 @@ void PIOS_Board_Init(void)
PIOS_Assert(0);
}
uint8_t *gps_rx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_GPS_RX_BUF_LEN);
uint8_t *gps_rx_buffer = (uint8_t *)pios_malloc(PIOS_COM_GPS_RX_BUF_LEN);
PIOS_Assert(gps_rx_buffer);
if (PIOS_COM_Init(&pios_com_gps_id, &pios_usart_com_driver, pios_usart_gps_id,
gps_rx_buffer, PIOS_COM_GPS_RX_BUF_LEN,
@ -361,8 +361,8 @@ void PIOS_Board_Init(void)
PIOS_DEBUG_Assert(0);
}
uint8_t *aux_rx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_AUX_RX_BUF_LEN);
uint8_t *aux_tx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_AUX_TX_BUF_LEN);
uint8_t *aux_rx_buffer = (uint8_t *)pios_malloc(PIOS_COM_AUX_RX_BUF_LEN);
uint8_t *aux_tx_buffer = (uint8_t *)pios_malloc(PIOS_COM_AUX_TX_BUF_LEN);
PIOS_Assert(aux_rx_buffer);
PIOS_Assert(aux_tx_buffer);
@ -383,8 +383,8 @@ void PIOS_Board_Init(void)
PIOS_Assert(0);
}
uint8_t *telem_rx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_TELEM_RF_RX_BUF_LEN);
uint8_t *telem_tx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_TELEM_RF_TX_BUF_LEN);
uint8_t *telem_rx_buffer = (uint8_t *)pios_malloc(PIOS_COM_TELEM_RF_RX_BUF_LEN);
uint8_t *telem_tx_buffer = (uint8_t *)pios_malloc(PIOS_COM_TELEM_RF_TX_BUF_LEN);
PIOS_Assert(telem_rx_buffer);
PIOS_Assert(telem_tx_buffer);
if (PIOS_COM_Init(&pios_com_telem_rf_id, &pios_usart_com_driver, pios_usart_telem_rf_id,

View File

@ -256,10 +256,10 @@ static void PIOS_Board_configure_com(const struct pios_usart_cfg *usart_port_cfg
PIOS_Assert(0);
}
uint8_t *rx_buffer = (uint8_t *)pvPortMalloc(rx_buf_len);
uint8_t *rx_buffer = (uint8_t *)pios_malloc(rx_buf_len);
PIOS_Assert(rx_buffer);
if (tx_buf_len != (size_t)-1) { // this is the case for rx/tx ports
uint8_t *tx_buffer = (uint8_t *)pvPortMalloc(tx_buf_len);
uint8_t *tx_buffer = (uint8_t *)pios_malloc(tx_buf_len);
PIOS_Assert(tx_buffer);
if (PIOS_COM_Init(pios_com_id, com_driver, pios_usart_id,
@ -504,8 +504,8 @@ void PIOS_Board_Init(void)
case HWSETTINGS_USB_VCPPORT_USBTELEMETRY:
#if defined(PIOS_INCLUDE_COM)
{
uint8_t *rx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_TELEM_USB_RX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_TELEM_USB_TX_BUF_LEN);
uint8_t *rx_buffer = (uint8_t *)pios_malloc(PIOS_COM_TELEM_USB_RX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pios_malloc(PIOS_COM_TELEM_USB_TX_BUF_LEN);
PIOS_Assert(rx_buffer);
PIOS_Assert(tx_buffer);
if (PIOS_COM_Init(&pios_com_telem_usb_id, &pios_usb_cdc_com_driver, pios_usb_cdc_id,
@ -519,8 +519,8 @@ void PIOS_Board_Init(void)
case HWSETTINGS_USB_VCPPORT_COMBRIDGE:
#if defined(PIOS_INCLUDE_COM)
{
uint8_t *rx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_BRIDGE_RX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_BRIDGE_TX_BUF_LEN);
uint8_t *rx_buffer = (uint8_t *)pios_malloc(PIOS_COM_BRIDGE_RX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pios_malloc(PIOS_COM_BRIDGE_TX_BUF_LEN);
PIOS_Assert(rx_buffer);
PIOS_Assert(tx_buffer);
if (PIOS_COM_Init(&pios_com_vcp_id, &pios_usb_cdc_com_driver, pios_usb_cdc_id,
@ -535,7 +535,7 @@ void PIOS_Board_Init(void)
#if defined(PIOS_INCLUDE_COM)
#if defined(PIOS_INCLUDE_DEBUG_CONSOLE)
{
uint8_t *tx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_DEBUGCONSOLE_TX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pios_malloc(PIOS_COM_DEBUGCONSOLE_TX_BUF_LEN);
PIOS_Assert(tx_buffer);
if (PIOS_COM_Init(&pios_com_debug_id, &pios_usb_cdc_com_driver, pios_usb_cdc_id,
NULL, 0,
@ -566,8 +566,8 @@ void PIOS_Board_Init(void)
case HWSETTINGS_USB_HIDPORT_USBTELEMETRY:
#if defined(PIOS_INCLUDE_COM)
{
uint8_t *rx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_TELEM_USB_RX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_TELEM_USB_TX_BUF_LEN);
uint8_t *rx_buffer = (uint8_t *)pios_malloc(PIOS_COM_TELEM_USB_RX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pios_malloc(PIOS_COM_TELEM_USB_TX_BUF_LEN);
PIOS_Assert(rx_buffer);
PIOS_Assert(tx_buffer);
if (PIOS_COM_Init(&pios_com_telem_usb_id, &pios_usb_hid_com_driver, pios_usb_hid_id,
@ -761,8 +761,8 @@ void PIOS_Board_Init(void)
}
/* Configure the radio com interface */
uint8_t *rx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_RFM22B_RF_RX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_RFM22B_RF_TX_BUF_LEN);
uint8_t *rx_buffer = (uint8_t *)pios_malloc(PIOS_COM_RFM22B_RF_RX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pios_malloc(PIOS_COM_RFM22B_RF_TX_BUF_LEN);
PIOS_Assert(rx_buffer);
PIOS_Assert(tx_buffer);
if (PIOS_COM_Init(&pios_com_rf_id, &pios_rfm22b_com_driver, pios_rfm22b_id,

View File

@ -321,10 +321,10 @@ static void PIOS_Board_configure_com(const struct pios_usart_cfg *usart_port_cfg
PIOS_Assert(0);
}
uint8_t *rx_buffer = (uint8_t *)pvPortMalloc(rx_buf_len);
uint8_t *rx_buffer = (uint8_t *)pios_malloc(rx_buf_len);
PIOS_Assert(rx_buffer);
if (tx_buf_len != (size_t)-1) { // this is the case for rx/tx ports
uint8_t *tx_buffer = (uint8_t *)pvPortMalloc(tx_buf_len);
uint8_t *tx_buffer = (uint8_t *)pios_malloc(tx_buf_len);
PIOS_Assert(tx_buffer);
if (PIOS_COM_Init(pios_com_id, com_driver, pios_usart_id,
@ -529,8 +529,8 @@ void PIOS_Board_Init(void)
case HWSETTINGS_USB_VCPPORT_USBTELEMETRY:
#if defined(PIOS_INCLUDE_COM)
{
uint8_t *rx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_TELEM_USB_RX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_TELEM_USB_TX_BUF_LEN);
uint8_t *rx_buffer = (uint8_t *)pios_malloc(PIOS_COM_TELEM_USB_RX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pios_malloc(PIOS_COM_TELEM_USB_TX_BUF_LEN);
PIOS_Assert(rx_buffer);
PIOS_Assert(tx_buffer);
if (PIOS_COM_Init(&pios_com_telem_usb_id, &pios_usb_cdc_com_driver, pios_usb_cdc_id,
@ -544,8 +544,8 @@ void PIOS_Board_Init(void)
case HWSETTINGS_USB_VCPPORT_COMBRIDGE:
#if defined(PIOS_INCLUDE_COM)
{
uint8_t *rx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_BRIDGE_RX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_BRIDGE_TX_BUF_LEN);
uint8_t *rx_buffer = (uint8_t *)pios_malloc(PIOS_COM_BRIDGE_RX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pios_malloc(PIOS_COM_BRIDGE_TX_BUF_LEN);
PIOS_Assert(rx_buffer);
PIOS_Assert(tx_buffer);
if (PIOS_COM_Init(&pios_com_vcp_id, &pios_usb_cdc_com_driver, pios_usb_cdc_id,
@ -560,7 +560,7 @@ void PIOS_Board_Init(void)
#if defined(PIOS_INCLUDE_COM)
#if defined(PIOS_INCLUDE_DEBUG_CONSOLE)
{
uint8_t *tx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_DEBUGCONSOLE_TX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pios_malloc(PIOS_COM_DEBUGCONSOLE_TX_BUF_LEN);
PIOS_Assert(tx_buffer);
if (PIOS_COM_Init(&pios_com_debug_id, &pios_usb_cdc_com_driver, pios_usb_cdc_id,
NULL, 0,
@ -591,8 +591,8 @@ void PIOS_Board_Init(void)
case HWSETTINGS_USB_HIDPORT_USBTELEMETRY:
#if defined(PIOS_INCLUDE_COM)
{
uint8_t *rx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_TELEM_USB_RX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pvPortMalloc(PIOS_COM_TELEM_USB_TX_BUF_LEN);
uint8_t *rx_buffer = (uint8_t *)pios_malloc(PIOS_COM_TELEM_USB_RX_BUF_LEN);
uint8_t *tx_buffer = (uint8_t *)pios_malloc(PIOS_COM_TELEM_USB_TX_BUF_LEN);
PIOS_Assert(rx_buffer);
PIOS_Assert(tx_buffer);
if (PIOS_COM_Init(&pios_com_telem_usb_id, &pios_usb_hid_com_driver, pios_usb_hid_id,
@ -871,8 +871,8 @@ void PIOS_Board_Init(void)
PIOS_DEBUG_Assert(0);
}
const uint32_t PACKET_SIZE = 1024;
uint8_t *rx_buffer = (uint8_t *)pvPortMalloc(PACKET_SIZE);
uint8_t *tx_buffer = (uint8_t *)pvPortMalloc(PACKET_SIZE);
uint8_t *rx_buffer = (uint8_t *)pios_malloc(PACKET_SIZE);
uint8_t *tx_buffer = (uint8_t *)pios_malloc(PACKET_SIZE);
PIOS_Assert(rx_buffer);
PIOS_Assert(tx_buffer);
if (PIOS_COM_Init(&pios_com_overo_id, &pios_overo_com_driver, pios_overo_id,

View File

@ -107,7 +107,7 @@ SRC += $(PIOSCORECOMMON)/pios_debuglog.c
SRC += $(PIOSCORECOMMON)/pios_callbackscheduler.c
SRC += $(PIOSCORECOMMON)/pios_deltatime.c
SRC += $(PIOSCORECOMMON)/pios_notify.c
SRC += $(PIOSCORECOMMON)/pios_mem.c
## PIOS Hardware
include $(PIOS)/posix/library.mk

View File

@ -8,7 +8,7 @@
/* FreeRTOS Includes */
#include "FreeRTOS.h"
#endif
#include "pios_mem.h"
#ifdef PIOS_INCLUDE_FLASH
#include <pios_flash.h>
#include <pios_flashfs.h>

View File

@ -0,0 +1,34 @@
/**
******************************************************************************
*
* @file pios_mem.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2014.
* @addtogroup PiOS
* @{
* @addtogroup PiOS
* @{
* @brief PiOS memory allocation API
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef PIOS_MEM_H
#define PIOS_MEM_H
#define pios_fastheapmalloc(size) (malloc(size))
#define pios_malloc(size) (malloc(size))
#define pios_free(p) (free(p))
#endif /* PIOS_MEM_H */

View File

@ -228,7 +228,7 @@ static int32_t eventPeriodicCreate(UAVObjEvent *ev, UAVObjEventCallback cb, xQue
}
}
// Create handle
objEntry = (PeriodicObjectList *)pvPortMalloc(sizeof(PeriodicObjectList));
objEntry = (PeriodicObjectList *)pios_malloc(sizeof(PeriodicObjectList));
if (objEntry == NULL) {
return -1;
}

View File

@ -278,7 +278,7 @@ static struct UAVOData *UAVObjAllocSingle(uint32_t num_bytes)
uint32_t object_size = sizeof(struct UAVOSingle) + num_bytes;
/* Allocate the object from the heap */
struct UAVOSingle *uavo_single = (struct UAVOSingle *)pvPortMalloc(object_size);
struct UAVOSingle *uavo_single = (struct UAVOSingle *)pios_malloc(object_size);
if (!uavo_single) {
return NULL;
@ -303,7 +303,7 @@ static struct UAVOData *UAVObjAllocMulti(uint32_t num_bytes)
uint32_t object_size = sizeof(struct UAVOMulti) + num_bytes;
/* Allocate the object from the heap */
struct UAVOMulti *uavo_multi = (struct UAVOMulti *)pvPortMalloc(object_size);
struct UAVOMulti *uavo_multi = (struct UAVOMulti *)pios_malloc(object_size);
if (!uavo_multi) {
return NULL;
@ -1802,7 +1802,7 @@ static InstanceHandle createInstance(struct UAVOData *obj, uint16_t instId)
/* Create the actual instance */
uint32_t size = sizeof(struct UAVOMultiInst) + obj->instance_size;
instEntry = (struct UAVOMultiInst *)pvPortMalloc(size);
instEntry = (struct UAVOMultiInst *)pios_malloc(size);
if (!instEntry) {
return NULL;
}
@ -1890,7 +1890,7 @@ static int32_t connectObj(UAVObjHandle obj_handle, xQueueHandle queue,
}
// Add queue to list
event = (struct ObjectEventEntry *)pvPortMalloc(sizeof(struct ObjectEventEntry));
event = (struct ObjectEventEntry *)pios_malloc(sizeof(struct ObjectEventEntry));
if (event == NULL) {
return -1;
}

View File

@ -64,7 +64,7 @@ static void updateAck(UAVTalkConnectionData *connection, uint8_t type, uint32_t
UAVTalkConnection UAVTalkInitialize(UAVTalkOutputStream outputStream)
{
// allocate object
UAVTalkConnectionData *connection = pvPortMalloc(sizeof(UAVTalkConnectionData));
UAVTalkConnectionData *connection = pios_malloc(sizeof(UAVTalkConnectionData));
if (!connection) {
return 0;
@ -76,11 +76,11 @@ UAVTalkConnection UAVTalkInitialize(UAVTalkOutputStream outputStream)
connection->lock = xSemaphoreCreateRecursiveMutex();
connection->transLock = xSemaphoreCreateRecursiveMutex();
// allocate buffers
connection->rxBuffer = pvPortMalloc(UAVTALK_MAX_PACKET_LENGTH);
connection->rxBuffer = pios_malloc(UAVTALK_MAX_PACKET_LENGTH);
if (!connection->rxBuffer) {
return 0;
}
connection->txBuffer = pvPortMalloc(UAVTALK_MAX_PACKET_LENGTH);
connection->txBuffer = pios_malloc(UAVTALK_MAX_PACKET_LENGTH);
if (!connection->txBuffer) {
return 0;
}

View File

@ -101,6 +101,7 @@ SRC += $(PIOSCOMMON)/pios_task_monitor.c
SRC += $(PIOSCOMMON)/pios_callbackscheduler.c
SRC += $(PIOSCOMMON)/pios_notify.c
SRC += $(PIOSCOMMON)/pios_instrumentation.c
SRC += $(PIOSCOMMON)/pios_mem.c
## Misc library functions
SRC += $(FLIGHTLIB)/fifo_buffer.c
SRC += $(FLIGHTLIB)/sanitycheck.c

View File

@ -2,7 +2,7 @@
<object name="SystemStats" singleinstance="true" settings="false" category="System">
<description>CPU and memory usage from OpenPilot computer. </description>
<field name="FlightTime" units="ms" type="uint32" elements="1"/>
<field name="HeapRemaining" units="bytes" type="uint16" elements="1"/>
<field name="HeapRemaining" units="bytes" type="uint32" elements="1"/>
<field name="IRQStackRemaining" units="bytes" type="uint16" elements="1"/>
<field name="SystemModStackRemaining" units="bytes" type="uint16" elements="1"/>
<field name="CPULoad" units="%" type="uint8" elements="1"/>