use task
This commit is contained in:
@@ -27,28 +27,22 @@ void InitDoneCallback(void * p_arg) {
|
||||
(void) p_arg;
|
||||
UCOS_Print("OS started!\r\n");
|
||||
|
||||
//OSTaskCreateExt(timer_Task,
|
||||
// 0,
|
||||
// &TimerStk[TIMER_STK_SIZE-1],
|
||||
// TIMER_PRIO,
|
||||
// TIMER_PRIO,
|
||||
// &TimerStk[0],
|
||||
// TIMER_STK_SIZE,
|
||||
// 0,
|
||||
// 0
|
||||
// );
|
||||
|
||||
timer_Init();
|
||||
OSTaskCreateExt(timer_Task,
|
||||
0,
|
||||
&TimerStk[TIMER_STK_SIZE-1],
|
||||
TIMER_PRIO,
|
||||
TIMER_PRIO,
|
||||
&TimerStk[0],
|
||||
TIMER_STK_SIZE,
|
||||
0,
|
||||
0
|
||||
);
|
||||
|
||||
uint16_t melody[][2] = {{440, 500}, {440, 500}, {440, 500}, {349, 350}, {523, 150}, {440, 500}, {349, 350}, {523, 150}, {440, 1000}, {659, 500}, {659, 500}, {659, 500}, {698, 350}, {523, 150}, {415, 500}, {349, 350}, {523, 150}, {440, 1000}};
|
||||
|
||||
while(1){
|
||||
for(uint8_t i=0; i<(sizeof(melody)/sizeof(melody[0])); i++){
|
||||
CPU_SR cpu_sr;
|
||||
OS_ENTER_CRITICAL();
|
||||
pidValue = melody[i][0];
|
||||
OS_EXIT_CRITICAL();
|
||||
timer_Task(0);
|
||||
OSTimeDly(melody[i][1]);
|
||||
}
|
||||
//for(int16_t i = -1000; i<=1000; i++){
|
||||
|
||||
@@ -31,23 +31,27 @@ XGpioPs_Config* gpioCfg;
|
||||
extern int16_t pidValue;
|
||||
|
||||
void timer_Task(void *pdata) {
|
||||
if(pidValue){
|
||||
uint16_t interval = 1.337*(64000/abs(pidValue));
|
||||
uint8_t direction = pidValue<0;
|
||||
//UCOS_Printf("%d %d\r\n", direction, interval);
|
||||
//UCOS_Printf("counter value: %d\r\n", XTtcPs_GetCounterValue(&xttcps));
|
||||
timer_Stop(0);
|
||||
timer_Stop(1);
|
||||
timer_Set_Interval_Length(0,interval);
|
||||
timer_Set_Interval_Length(1,interval);
|
||||
timer_Start(0);
|
||||
timer_Start(1);
|
||||
motor_Set_Moving_Direction(54, direction);
|
||||
motor_Set_Moving_Direction(55, !direction);
|
||||
}
|
||||
else
|
||||
{
|
||||
timer_Stop(0);
|
||||
timer_Init();
|
||||
|
||||
while(1){
|
||||
if(pidValue){
|
||||
uint16_t interval = 1.337*(64000/abs(pidValue));
|
||||
uint8_t direction = pidValue<0;
|
||||
//UCOS_Printf("%d %d\r\n", direction, interval);
|
||||
//UCOS_Printf("counter value: %d\r\n", XTtcPs_GetCounterValue(&xttcps));
|
||||
timer_Stop(0);
|
||||
timer_Stop(1);
|
||||
timer_Set_Interval_Length(0,interval);
|
||||
timer_Set_Interval_Length(1,interval);
|
||||
timer_Start(0);
|
||||
timer_Start(1);
|
||||
motor_Set_Moving_Direction(54, direction);
|
||||
motor_Set_Moving_Direction(55, !direction);
|
||||
}
|
||||
else
|
||||
{
|
||||
timer_Stop(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,9 +60,7 @@ int timer_Init(){
|
||||
UCOS_Print("Setting up Timer!\r\n");
|
||||
|
||||
timer_Dual_Timer_Setup();
|
||||
|
||||
timer_gpio_Init();
|
||||
motor_Set_Moving_Direction(54, 1);
|
||||
|
||||
UCOS_Print("Done!\r\n");
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user