int main(void) { //The parameter structure must be created in the memory so that it exists // when the task is started (see FreeRTOS documentation): task_params *T1Parameters; T1Parameters = pvPortMalloc(sizeof(task_params)); T1Parameters->period = T1_PERIOD; T1Parameters->operation_count = T1_OPERATION_COUNT; T1Parameters->GPIO_Pin = PA6; task_params *T2Parameters; T2Parameters = pvPortMalloc(sizeof(task_params)); T2Parameters->period = T2_PERIOD; T2Parameters->operation_count = T2_OPERATION_COUNT; T2Parameters->GPIO_Pin = PA5; NVIC_PriorityGroupConfig( NVIC_PriorityGroup_4 ); //Needed for STM32F10x ledinit(); xTaskCreate(Task,"Task1",128,T1Parameters,T1_Priority,&T1_handle); xTaskCreate(Task,"Task2",128,T2Parameters,T2_Priority,&T2_handle); //Task parameters are automatically cast as (void *) in function call. vTaskStartScheduler(); //Finally, start the scheduler. return 0; }
int main() { //SYSTEMConfigPerformance(SYS_FREQ); // Configure the device for maximum performance but do not change the PBDIV // Given the options, this function will change the flash wait states, RAM // wait state and enable prefetch cache but will not change the PBDIV. // The PBDIV value is already set via the pragma FPBDIV option above.. SYSTEMConfig(SYS_FREQ, SYS_CFG_WAIT_STATES | SYS_CFG_PCACHE); PORTFbits.RF1 = 0; //Function that initializes all of the required I/O initIO(); //Initialize all of the LED pins ledinit(); adcConfigureAutoScan(); timersInit(); motorinit(); PWMinit(); motorRstop(); motorLstop(); leftspeed = 290; rightspeed = 300; while(PORTDbits.RD3 == 0) {} for(i = 0; i < 5000000; i++) { } setpwmR(rightspeed); setpwmL(leftspeed); motorRfwd(); motorLfwd(); //turnright(); //turnleft(); while (1) {} return (EXIT_SUCCESS); }
int main() { //SYSTEMConfigPerformance(SYS_FREQ); // Configure the device for maximum performance but do not change the PBDIV // Given the options, this function will change the flash wait states, RAM // wait state and enable prefetch cache but will not change the PBDIV. // The PBDIV value is already set via the pragma FPBDIV option above.. SYSTEMConfig(SYS_FREQ, SYS_CFG_WAIT_STATES | SYS_CFG_PCACHE); PORTFbits.RF1 = 0; //Function that initializes all of the required I/O initIO(); //Initialize all of the LED pins ledinit(); adcConfigureAutoScan(); timer1Init(); encodersInit(); motorinit(); PWMinit(); motorRstop(); motorLstop(); leftspeed = 310; rightspeed = 300; while(PORTDbits.RD3 == 0) {} for(i = 0; i < 5000000; i++) { } setpwmR(rightspeed); setpwmL(leftspeed); motorRfwd(); motorLfwd(); //turnright(); //turnleft(); while (1) { if(readpins(0) > 300) //left { setpwmR(100); for(i=0;i<800;i++); /* if(leftspeed < 315) leftspeed++; if(rightspeed > 275) rightspeed--; */ setpwmR(rightspeed); setpwmL(leftspeed); motorRfwd(); motorLfwd(); } //for(i = 0; i < 500; i++){}; //if (channel13 < 600) if(readpins(2) > 600) //right { setpwmL(100); for(i=0;i<800;i++); /* if(leftspeed > 265) leftspeed--; if(rightspeed < 325) rightspeed++; */ setpwmR(rightspeed); setpwmL(leftspeed); motorRfwd(); motorLfwd(); } //for(i = 0; i < 500; i++){}; //if (channel13 < 900) if(readpins(1) > 900) //middle { setpwmR(0); setpwmL(0); motorRstop(); motorLstop(); turnright(); } //for(i = 0; i < 1500; i++){}; } return (EXIT_SUCCESS); }