Page 1 of 1

RTX using ADC, GPIO, USB MOUSE

Posted: 20 Jun 2017, 17:21
by Prima
Because the relationship between the case, the study of the RTX , to understand the task parallel processing, or a RTOS for TASK parallel processing will be better.
Write an example, in the KEIL RTX under the ADC sampling, GPIO switch, UART print, USB MOUSE send data together.

Code: Select all

void Task2 __task (void)       
{ 
the while (. 1) 
{ 
   os_dly_wait (10); 
  adc_value Get_ADC_Knob = (); 
    os_sem_send (Sem_arrive1);   
} 
} 
have to read using the ADC ADC TASK Semaphore value after processing, notification processing UART, 
__task void task4 (void)       
{ 
while (1) 
{ 
    printf ("0x% x \ n \ r", adc_value);    
  os_sem_wait (Sem_arrive1, 0xFFFF);    
/ / The semaphores ensure both tasks arrive here before continuing } 
} 
GPIO's TASK read ADC value changes the switching speed. 
__task void task3 (void)       
{ 
while (1) 
{ 
   Write_LED_Color_Flash (adc_value); 
} 
} 
USB TASK, check whether to send the button REPORT, the other part to interrupt processing. 
__task void Task1 (void)         
{ 
tsk1 = os_tsk_self ();       

os_tsk_prio (tsk1,. 1);       

tsk2 = os_tsk_create (Task2,. 1);    
tsk3 = os_tsk_create (Task3,. 1);    
  tsk4 = os_tsk_create (Task4,. 1);   
os_sem_init (Sem_arrive1 , 0); // Create two semaphores each with no tokens 
os_sem_init (Sem_arrive2, 0);    
while (1) 
{ 
   uint8_t * buf;

A_ziliu