Franz Wolf / Mbed OS nucleo-os-counter-threads

Dependencies:   IHM_V2

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 // NUClight_TEST1_V3 
00002 // Diese Software testet die verschiedenen Funktionen des M0 Boards  
00003 // BULME Graz,     by F. Wolf   05.10.2019
00004 /*
00005                              PIN-OUT-NUClight
00006                                 NUCLEO-L432KC
00007                      RGB-rot   D1|-------| VIn
00008                      RGB-gruen D0|       | GND
00009                              NRST|       | RST
00010                               GND|       | 5V0
00011                         LED1 <-D2|       | A7
00012                         LED2 <-D3|       | A6 -> LED7
00013 SDA (I2C)  (MPU6050 gyro)   <- D4|       | A5
00014 SCL (I2C)  (MPU6050 gyro)   <- D5|       | A4
00015                         LED3 <-D6|       | A3 -> POTI
00016                             nc D7|       | A2 -> Taster
00017                             nc D8|       | A1 -> Taster
00018                          LED4  D9|       | A0 -> DS18B20
00019                   RGB-blau <- D10|       | ARF
00020                       LED5 <- D11|       | 3V0
00021                       LED6 <- D12|-------| D13 -> LED8
00022         
00023  RGB LED aktiv hight (1)       
00024  */   
00025         
00026 #include "mbed.h"
00027 
00028 
00029 // ********   Definitionen  **********
00030 //Serial pc(USBTX, USBRX);
00031 Serial pc(SERIAL_TX,SERIAL_RX);
00032 
00033 
00034 
00035 DigitalOut L0 (D2) ;  // led L0
00036 DigitalOut L1 (D3) ;  // led L1
00037 DigitalOut L2 (D6) ;  // led L2
00038 
00039 void led1_thread();
00040 void led2_thread();
00041 
00042 Thread thread1 (osPriorityNormal,2*OS_STACK_SIZE );
00043 Thread thread2 (osPriorityNormal,2*OS_STACK_SIZE );
00044 
00045 // main is the 1st thread
00046 int main(void) 
00047 {   
00048     pc.printf("3-threads-%s %s",__DATE__,__TIME__);
00049     pc.printf("mbed-os-3-threads-%s %s\n\r",__DATE__,__TIME__);
00050     pc.printf("DEFAULT_STACK_SIZE:%d\n\r", OS_STACK_SIZE); 
00051 
00052     thread1.start(led1_thread);   
00053     thread2.start(led2_thread);
00054     
00055     thread2.join();  // wartet bis thread2 fertig ist
00056  
00057     while(1){
00058         L0=!L0;
00059         pc.printf("*     [pid-%d]Main \n\r",osThreadGetId());
00060         wait(0.0200);  
00061     }
00062 }
00063 
00064 void led1_thread(){
00065     
00066     
00067     while (1) {
00068         L1 = ! L1;
00069         pc.printf("  *   [pid-%d]led1_thread_1 \n\r",osThreadGetId());
00070         wait(0.500);  
00071   }
00072 }
00073 
00074 void led2_thread(){
00075     while (1) {
00076         L2 = ! L2;
00077         pc.printf("     *[pid-%d]led2_thread_2 \n\r",osThreadGetId());
00078         
00079         for(int i=0; i<100; i++) {
00080          pc.printf("Zahl %d\n", i+1);
00081         }
00082         
00083         
00084         wait(2.500);  
00085         
00086        
00087    }
00088 }
00089 
00090