Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop target specific call #633

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 14 additions & 18 deletions src/HAL/Include/nanoHAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,17 @@ void HAL_Assert ( const char* Func, int Line, const char* File );
// HAL_AssertEx is defined in the processor or platform selector files.
extern void HAL_AssertEx();

//
// This has to be extern "C" because we want to use platform implemented malloc
//
extern "C" {

void* platform_malloc ( size_t size );
void platform_free ( void* ptr );
void* platform_realloc( void* ptr, size_t size );

}

#if defined(PLATFORM_ARM)
#if !defined(BUILD_RTM)
#define ASSERT(i) { if(!(i)) HAL_AssertEx(); }
Expand Down Expand Up @@ -1339,11 +1350,8 @@ template<typename T> class HAL_RingBuffer
size_t tailSize = _write_index - 1;

// 1st move tail to temp buffer (need to malloc first)
#if defined(__arm__)
T* tempBuffer = (T*)chHeapAlloc(NULL, tailSize);
#else
T* tempBuffer = (T*)malloc(tailSize);
#endif
T* tempBuffer = (T*)platform_malloc(tailSize);

memcpy(tempBuffer, _buffer, tailSize);

// store size of remaining buffer
Expand All @@ -1356,11 +1364,7 @@ template<typename T> class HAL_RingBuffer
memcpy(_buffer + headSize, tempBuffer, tailSize);

// free memory
#if defined(__arm__)
chHeapFree(tempBuffer);
#else
free(tempBuffer);
#endif
platform_free(tempBuffer);
}

// adjust indexes
Expand Down Expand Up @@ -1525,16 +1529,8 @@ void HAL_AddSoftRebootHandler(ON_SOFT_REBOOT_HANDLER handler);
//--//


//
// This has to be extern "C" because we want to use platform implemented malloc
//
extern "C" {

void* platform_malloc ( size_t size );
void platform_free ( void* ptr );
void* platform_realloc( void* ptr, size_t size );

}



Expand Down