apres v5
Dependencies: mbed bloc_io mbed-rtos html EthernetInterface
Revision 1:140b1686bf3f, committed 2021-09-28
- Comitter:
- thomascerruti
- Date:
- Tue Sep 28 15:04:04 2021 +0000
- Parent:
- 0:e30c9ba95bd4
- Commit message:
- apres validation v5;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r e30c9ba95bd4 -r 140b1686bf3f main.cpp --- a/main.cpp Sat Aug 22 15:51:59 2015 +0000 +++ b/main.cpp Tue Sep 28 15:04:04 2021 +0000 @@ -1,4 +1,4 @@ - + //#include "EthernetInterface.h" #include <stdlib.h> @@ -10,7 +10,7 @@ #define RADIUS 0.2F // wheel size #define NBPOLES 8 // magnetic pole number #define DELTA_T 0.1F // speed measurement counting period - +DigitalOut valid_PWM(p21); Bloc_IO MyPLD(p25,p26,p5,p6,p7,p8,p9,p10,p23,p24);// instantiate object needed to communicate with PLD // analog input connected to mbed @@ -56,7 +56,8 @@ //************ local function prototypes ******************* - +void init(void); +void deinit(void); @@ -116,47 +117,38 @@ //*************************** main function ***************************************** int main() { -char cChoix=0; - - - - - -//***************************************** web section ********************************************/ -//Init_Web_Server(&CGI_Function); // create and initialize tcp server socket and pass function pointer to local CGI function -//Thread WebThread(Web_Server_Thread);// create and launch web server thread -/********* main cgi function used to patch data to the web server thread **********************************/ - -//******************************************* end web section ************************************* / - - - - -pc.printf(" programme scooter mbed \n"); - + init(); + char cChoix=0; +while(cChoix!='q' and cChoix!='Q') +{ +pc.printf(" veuillez saisir un choix parmi la liste proposee: \n"); + pc.printf(" a:saisie consigne pwm \n"); + pc.printf(" q:quitter \n"); - -//********************* can bus section initialisation ******************************************* -//bCan_Active=true;// needed to lauchn CAN thread -//Thread CanThread(CAN_REC_THREAD);// create and launch can receiver thread -//********************* end can bus section ***************************************************** - +pc.scanf(" %c",&cChoix); +int PWM; -while(cChoix!='q' and cChoix!='Q') -{pc.printf(" veuillez saisir un choix parmi la liste proposee: \n"); - pc.printf(" a:saisie consigne pwm \n"); - pc.printf(" q:quitter \n"); - /************* multithreading : main thread need to sleep in order to allow web response */ - while (pc.readable()==0) // determine if char availabler - {Thread::wait(10);} // wait 10 until char available on serial input - /************* end of main thread sleep ****************/ - - pc.scanf(" %c",&cChoix); switch (cChoix){ case 'a': + + printf("donnez une valeur de pwm : \n\r"); + pc.scanf("%d", &PWM); + if (PWM < 0) + { + PWM = 0; + } + if (PWM > 255) + { + PWM = 255; + } + printf(" valeur de pwm = %d \n\r", PWM); + MyPLD.write(PWM); + + break; case 'q': + deinit(); break; } } // end while @@ -165,5 +157,17 @@ //DeInit_Web_Server(); //bCan_Active=false; //CanThread=false;// close can received thread - pc.printf(" fin programme scooter mbed \n"); -} // end main + + }// end main + +void init() +{ + valid_PWM.write(0); + MyPLD.write(0); + valid_PWM.write(1); +} +void deinit() +{ + MyPLD.write(0); + valid_PWM.write(0); +} \ No newline at end of file