I have a class defined that encapsulates a task. I can successfully create and start the task but then it all falls apart. I've got a 28335 peripheral explorer kit and I'm trying to toggle one of the leds in my task object but the Task_sleep function just ends up going off into the either.
Here is my code
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <xdc/std.h>
#include <xdc/runtime/Error.h>
#include <xdc/runtime/System.h>
#include <ti/sysbios/knl/Task.h>
#include "DSP2833x_Device.h"
#include <xdc/std.h>
#include <xdc/runtime/Log.h>
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
#include <xdc/std.h>
#include <xdc/runtime/Log.h>
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
#include <xdc/runtime/System.h>
#include <xdc/runtime/Error.h>
#include "DSP2833x_Device.h"
void InitSystem(void);
void Gpio_select(void);
extern "C" { Void minTaskWrapper(UArg a0, UArg a1);}
// class definition
class MinAppTask {
private:
Task_Handle _taskHandle;
Error_Block _eb;
public:
MinAppTask(void);
~MinAppTask();
virtual Void taskFxn(UArg a0, UArg a1);
bool initialize();
};
MinAppTask::MinAppTask(void) {
}
bool MinAppTask::initialize()
{
bool result;
Task_Params taskParams;
Task_Params_init(&taskParams);
taskParams.priority = 1;
taskParams.arg0 = (UArg)this;
_taskHandle = Task_create((Task_FuncPtr)minTaskWrapper, &taskParams, &_eb);
if (_taskHandle == NULL) {
result = false;
}
else
{
result = true;
}
return (result);
}
MinAppTask::~MinAppTask()
{
// TODO Auto-generated destructor stub
Task_delete(&_taskHandle);
}
void MinAppTask::taskFxn (UArg a0, UArg a1)
{
//char holdBuf[128];
while(1)
{
GpioDataRegs.GPADAT.bit.GPIO9 = 1;
Task_sleep(500);
GpioDataRegs.GPADAT.bit.GPIO9 = 0;
Task_sleep(500);
}
}
extern "C" {
Void minTaskWrapper(UArg a0, UArg a1)
{
MinAppTask * aTask;
aTask = (MinAppTask *)a0;
aTask->taskFxn(a0,a1);
}
}
void InitSystem(void);
void Gpio_select(void);
/*
* ======== main ========
*/
int main()
{
InitSystem();
Gpio_select();
MinAppTask task1;
if (!task1.initialize())
{
System_printf("Could not create tasks, terminating\n");
BIOS_exit(0);
}else
BIOS_start();
}
void InitSystem(void)
{
EALLOW;
SysCtrlRegs.WDCR = 0x0028; // Watchdog enabled, 4.3 milliseconds
SysCtrlRegs.PLLSTS.bit.DIVSEL = 2;
SysCtrlRegs.PLLCR.bit.DIV = 10; // 30MHz * 10 / 2 = 150 MHz
SysCtrlRegs.HISPCP.all = 0x0001;
SysCtrlRegs.LOSPCP.all = 0x0002;
SysCtrlRegs.PCLKCR0.all = 0x0000;
SysCtrlRegs.PCLKCR1.all = 0x0000;
SysCtrlRegs.PCLKCR3.all = 0x0000;
SysCtrlRegs.PCLKCR3.bit.GPIOINENCLK = 1;
EDIS;
}
void Gpio_select(void)
{
EALLOW;
GpioCtrlRegs.GPAMUX1.all = 0; // GPIO15 ... GPIO0 = General Puropse I/O
GpioCtrlRegs.GPAMUX2.all = 0; // GPIO31 ... GPIO16 = General Purpose I/O
GpioCtrlRegs.GPBMUX1.all = 0; // GPIO47 ... GPIO32 = General Purpose I/O
GpioCtrlRegs.GPBMUX2.all = 0; // GPIO63 ... GPIO48 = General Purpose I/O
GpioCtrlRegs.GPCMUX1.all = 0; // GPIO79 ... GPIO64 = General Purpose I/O
GpioCtrlRegs.GPCMUX2.all = 0; // GPIO87 ... GPIO80 = General Purpose I/O
GpioCtrlRegs.GPADIR.all = 0;
GpioCtrlRegs.GPADIR.bit.GPIO9 = 1; // peripheral explorer: LED LD1 at GPIO9
GpioCtrlRegs.GPADIR.bit.GPIO11 = 1; // peripheral explorer: LED LD2 at GPIO11
GpioCtrlRegs.GPBDIR.all = 0; // GPIO63-32 as inputs
GpioCtrlRegs.GPBDIR.bit.GPIO34 = 1; // peripheral explorer: LED LD3 at GPIO34
GpioCtrlRegs.GPBDIR.bit.GPIO49 = 1; // peripheral explorer: LED LD4 at GPIO49
GpioCtrlRegs.GPCDIR.all = 0; // GPIO87-64 as inputs
EDIS;
}
I could use a little help in getting this example to flash LD1.