/*L4b-Program exemplificare executie 2 actiuni declarate * ca thread utilizind CMSIS_RTOX_RTX * * Conexiuni interfata motor pas cu pas unipolar: * * Bobina D - P0.4 * Bobina C - P0.3 * Bobina B - P0.2 * Bobina A - P0.1 * * * */ #include //Declarations from DAVE Code Generation (includes SFR declaration) void stepper() // actiune 1 { while(1U) { DIGITAL_IO_SetOutputLow(&A); // Activare bobina A osDelay(500); DIGITAL_IO_SetOutputHigh(&A); osDelay(10); // B este inversat cu C DIGITAL_IO_SetOutputLow(&C); // Activare bobina C osDelay(500); DIGITAL_IO_SetOutputHigh(&C); osDelay(10); DIGITAL_IO_SetOutputLow(&B); // Activare bobina B osDelay(500); DIGITAL_IO_SetOutputHigh(&B); osDelay(10); DIGITAL_IO_SetOutputLow(&D); // Activare bobina D osDelay(500); DIGITAL_IO_SetOutputHigh(&D); osDelay(10); } } osThreadDef(stepper, osPriorityNormal, 1, 0); // defineste stepper ca thread void blink() // actiune 2 { while(1) { DIGITAL_IO_ToggleOutput (&led); osDelay(100); // milisecunde } } osThreadDef(blink, osPriorityNormal, 1, 0); // defineste blink ca thread int main(void) { DAVE_Init(); // Initialization of DAVE APPs osKernelInitialize (); // initialize RTOS kernel osThreadCreate(osThread(stepper),NULL); // Activare actiune 1 osThreadCreate(osThread(blink),NULL); // Activare actiune 2 osKernelStart(); // start KernelRTOS while(1U) { } }