I'm trying to integrate FEE generated by HalCoGen Into my C++ FreeRTOS project.
A few issus had to be solved.
First all fee headerfiles are missing the:
#ifdef __cplusplus
extern "C" {
#endif
...
#ifdef __cplusplus
}
#endif /*extern "C" */
I got this compilation error in IAR
Error[Pe101]: "IDLE" has already been declared in the current scope (at line 58 of "C:\development\akurator\control\modules\common\include\ C:\development\akurator\control\modules\uiom\include\ti_fee_types.h 170
both of above problems where solved by including like this:
namespace fee
{
extern "C" {
#include "ti_fee.h"
}
}
In order to run the code from a FreeRTOS task I found some macros on the forum:
#define enter_flash_critical() \
portDISABLE_INTERRUPTS();\
xRunningPrivileged = prvRaisePrivilege();\
prvMpuDisable();
#define leave_flash_critical() \
prvMpuEnable();\
if( xRunningPrivileged == 0 ) portSWITCH_TO_USER_MODE();\
portENABLE_INTERRUPTS();
My code to be run inside a task now looks something like:
portBASE_TYPE xRunningPrivileged;
fee::TI_FeeModuleStatusType Status;
enter_flash_critical();
fee::TI_Fee_Init();
leave_flash_critical();
do
{
enter_flash_critical();
fee::TI_Fee_MainFunction();
leave_flash_critical();
delay();
Status=fee::TI_Fee_GetStatus(0 );
}
while(Status!= fee::IDLE);
I did find the "TI FEE User Guide.pdf" buy it says nothing about MPU and running on a RTOS. I would like to know if above code is the right approach.
I don't like switching of the MPU and disabling interrupts (don't know for how long). Is it nessesary to disable interrupts like this? Preventing context switching might be good enough? I guess it would be possible to add the OTP memory accessed by the FEE to the MPU and I'm looking for an example of this...
Best Regards
Henrik