Tool/software: TI-RTOS
Hi,
I getting start with SYS/BIOS on F28379D. I read document
and try to follow it.
I found some problem when I test in HwiHook example code, it error when i compile.
- project file struct
- main.c
#include <xdc/std.h>
#include <xdc/runtime/Error.h>
#include <xdc/runtime/System.h>
#include <xdc/runtime/Timestamp.h>
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
#include <ti/sysbios/hal/Timer.h>
#include <ti/sysbios/hal/Hwi.h>
extern Timer_Handle myTimer;
volatile Bool myEnd2Flag = FALSE;
Int myHookSetId1, myHookSetId2;
Error_Block eb;
Error_init(&eb);
/* HookSet 1 functions */
/* ======== myRegister1 ========
* invoked during Hwi module startup before main()
* for each HookSet */
Void myRegister1(Int hookSetId){
System_printf("myRegister1: assigned hookSet Id = %d\n", hookSetId);
myHookSetId1 = hookSetId;
}
/* ======== myCreate1 ========
* invoked during Hwi module startup before main()
* for statically created Hwis */
Void myCreate1(Hwi_Handle hwi, Error_Block *eb){
Ptr pEnv;
pEnv = Hwi_getHookContext(hwi, myHookSetId1);
/* pEnv should be 0 at this point. If not, there's a bug. */
System_printf("myCreate1: pEnv = 0x%x, time = %d\n", pEnv, Timestamp_get32());
Hwi_setHookContext(hwi, myHookSetId1, (Ptr)0xdead1);
}
/* ======== myBegin1 ========
* invoked before Timer Hwi func */
Void myBegin1(Hwi_Handle hwi){
Ptr pEnv;
pEnv = Hwi_getHookContext(hwi, myHookSetId1);
System_printf("myBegin1: pEnv = 0x%x, time = %d\n", pEnv, Timestamp_get32());
Hwi_setHookContext(hwi, myHookSetId1, (Ptr)0xbeef1);
}
/* ======== myEnd1 ========
* invoked after Timer Hwi func */
Void myEnd1(Hwi_Handle hwi){
Ptr pEnv;
pEnv = Hwi_getHookContext(hwi, myHookSetId1);
System_printf("myEnd1: pEnv = 0x%x, time = %d\n", pEnv, Timestamp_get32());
Hwi_setHookContext(hwi, myHookSetId1, (Ptr)0xc0de1);
}
/* HookSet 2 functions */
/* ======== myRegister2 ========
* invoked during Hwi module startup before main
* for each HookSet */
Void myRegister2(Int hookSetId){
System_printf("myRegister2: assigned hookSet Id = %d\n", hookSetId);
myHookSetId2 = hookSetId;
}
/* ======== myCreate2 ========
* invoked during Hwi module startup before main
* for statically created Hwis */
Void myCreate2(Hwi_Handle hwi, Error_Block *eb){
Ptr pEnv;
pEnv = Hwi_getHookContext(hwi, myHookSetId2);
/* pEnv should be 0 at this point. If not, there's a bug. */
System_printf("myCreate2: pEnv = 0x%x, time = %d\n", pEnv, Timestamp_get32());
Hwi_setHookContext(hwi, myHookSetId2, (Ptr)0xdead2);
}
/* ======== myBegin2 ========
* invoked before Timer Hwi func */
Void myBegin2(Hwi_Handle hwi){
Ptr pEnv;
pEnv = Hwi_getHookContext(hwi, myHookSetId2);
System_printf("myBegin2: pEnv = 0x%x, time = %d\n", pEnv, Timestamp_get32());
Hwi_setHookContext(hwi, myHookSetId2, (Ptr)0xbeef2);
}
/* ======== myEnd2 ========
* invoked after Timer Hwi func */
Void myEnd2(Hwi_Handle hwi){
Ptr pEnv;
pEnv = Hwi_getHookContext(hwi, myHookSetId2);
System_printf("myEnd2: pEnv = 0x%x, time = %d\n", pEnv, Timestamp_get32());
Hwi_setHookContext(hwi, myHookSetId2, (Ptr)0xc0de2);
myEnd2Flag = TRUE;
}
/* ======== myTimerFunc ========
* Timer interrupt handler */
Void myTimerFunc(UArg arg){
System_printf("Entering myTimerHwi\n");
}
/* ======== myTaskFunc ======== */
Void myTaskFunc(UArg arg0, UArg arg1){
System_printf("Entering myTask.\n");
Timer_start(myTimer);
/* wait for timer interrupt and myEnd2 to complete */
while (!myEnd2Flag) {
;
}
System_printf("myTask exiting ...\n");
}
/* ======== myIdleFunc ======== */
Void myIdleFunc(){
System_printf("Entering myIdleFunc().\n");
System_exit(0);
}
/* ======== main ======== */
Int main(Int argc, Char* argv[]){
System_printf("Starting HwiHookExample...\n");
BIOS_start();
return (0);
}
/* ========== End of file ========= */
-app.cfg
/* pull in Timestamp to print time in hook functions */
xdc.useModule('xdc.runtime.Timestamp');
var Defaults = xdc.useModule('xdc.runtime.Defaults');
var Diags = xdc.useModule('xdc.runtime.Diags');
var Error = xdc.useModule('xdc.runtime.Error');
var Log = xdc.useModule('xdc.runtime.Log');
var LoggerBuf = xdc.useModule('xdc.runtime.LoggerBuf');
var Main = xdc.useModule('xdc.runtime.Main');
var SysMin = xdc.useModule('xdc.runtime.SysMin');
var System = xdc.useModule('xdc.runtime.System');
var Text = xdc.useModule('xdc.runtime.Text');
var BIOS = xdc.useModule('ti.sysbios.BIOS');
var Task = xdc.useModule('ti.sysbios.knl.Task');
var Idle = xdc.useModule('ti.sysbios.knl.Idle');
var Hwi = xdc.useModule('ti.sysbios.hal.Hwi');
Idle.addFunc('&myIdleFunc');
/*
* Uncomment this line to globally disable Asserts.
* All modules inherit the default from the 'Defaults' module. You
* can override these defaults on a per-module basis using Module.common$.
* Disabling Asserts will save code space and improve runtime performance.
Defaults.common$.diags_ASSERT = Diags.ALWAYS_OFF;
*/
/*
* Uncomment this line to keep module names from being loaded on the target.
* The module name strings are placed in the .const section. Setting this
* parameter to false will save space in the .const section. Error and
* Assert messages will contain an "unknown module" prefix instead
* of the actual module name.
*/
Defaults.common$.namedModule = false;
/*
* Minimize exit handler array in System. The System module includes
* an array of functions that are registered with System_atexit() to be
* called by System_exit().
*/
System.maxAtexitHandlers = 4;
/*
* Uncomment this line to disable the Error print function.
* We lose error information when this is disabled since the errors are
* not printed. Disabling the raiseHook will save some code space if
* your app is not using System_printf() since the Error_print() function
* calls System_printf().
Error.raiseHook = null;
*/
/*
* Uncomment this line to keep Error, Assert, and Log strings from being
* loaded on the target. These strings are placed in the .const section.
* Setting this parameter to false will save space in the .const section.
* Error, Assert and Log message will print raw ids and args instead of
* a formatted message.
*/
Text.isLoaded = false;
/*
* Uncomment this line to disable the output of characters by SysMin
* when the program exits. SysMin writes characters to a circular buffer.
* This buffer can be viewed using the SysMin Output view in ROV.
*/
SysMin.flushAtExit = false;
/*
* The BIOS module will create the default heap for the system.
* Specify the size of this default heap.
*/
BIOS.heapSize = 0x0;
/* System stack size (used by ISRs and Swis) */
Program.stack = 0x100;
/* Circular buffer size for System_printf() */
SysMin.bufSize = 0x400;
/*
* Create and install logger for the whole system
*/
var loggerBufParams = new LoggerBuf.Params();
loggerBufParams.numEntries = 4;
var logger0 = LoggerBuf.create(loggerBufParams);
Defaults.common$.logger = logger0;
Main.common$.diags_INFO = Diags.ALWAYS_ON;
System.SupportProxy = SysMin;
/*
* Build a custom BIOS library. The custom library will be smaller than the
* pre-built "instrumented" (default) and "non-instrumented" libraries.
*
* The BIOS.logsEnabled parameter specifies whether the Logging is enabled
* within BIOS for this custom build. These logs are used by the RTA and
* UIA analysis tools.
*
* The BIOS.assertsEnabled parameter specifies whether BIOS code will
* include Assert() checks. Setting this parameter to 'false' will generate
* smaller and faster code, but having asserts enabled is recommended for
* early development as the Assert() checks will catch lots of programming
* errors (invalid parameters, etc.)
*/
BIOS.logsEnabled = false;
BIOS.assertsEnabled = true;
BIOS.clockEnabled = false;
/* Create myTask with default task params */
var taskParams = new Task.Params();
Program.global.myTask = Task.create('&myTaskFunc', taskParams);
/* Create myTimer as source of Hwi */
var Timer = xdc.useModule('ti.sysbios.hal.Timer');
var timerParams = new Timer.Params();
timerParams.startMode = Timer.StartMode_USER;
timerParams.runMode = Timer.RunMode_ONESHOT;
timerParams.period = 1000; // 1ms
Program.global.myTimer = Timer.create(Timer.ANY, "&myTimerFunc", timerParams);
/* Define and add two Hwi HookSets
* Notice, no deleteFxn is provided.
*/
/* Hook Set 1 */
Hwi.addHookSet({
registerFxn: '&myRegister1',
createFxn: '&myCreate1',
beginFxn: '&myBegin1',
endFxn: '&myEnd1',
});
/* Hook Set 2 */
Hwi.addHookSet({
registerFxn: '&myRegister2',
createFxn: '&myCreate2',
beginFxn: '&myBegin2',
endFxn: '&myEnd2',
});
-Error response
When I double click at error code it go to position error in main.c
These problem not found with SwiHook example code.
Thanks,
Thepnimit


