![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Codeut1
Revision 0:231fb0f5d4de, committed 2020-11-07
- Comitter:
- gr66
- Date:
- Sat Nov 07 17:33:42 2020 +0000
- Commit message:
- codeur1
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Nov 07 17:33:42 2020 +0000 @@ -0,0 +1,90 @@ +/**********************************************************************/ +/* */ +/* Programme de test de l'extension codeur */ +/* pour la carte F446RE */ +/* */ +/* Sylvain CASTANET - Octobre 2019 */ +/* */ +/* ------ */ +/* */ +/* Test des différentes fonctions de la carte : */ +/* - codeur incrémental */ +/* - poussoir du codeur */ +/* - Led */ +/* */ +/**********************************************************************/ + +#include "mbed.h" +//#include "C12832.h" + +// Using Arduino pin notation +//C12832 lcd(D11, D13, D12, D7, D10); + +// Entrées numériques +//InterruptIn CodeurA(PA_15,PullUp); // Mode PullUp +//DigitalIn CodeurB(PA_14,PullUp); // Mode PullUp +InterruptIn BP(PC_12,PullUp); // Mode PullUp +InterruptIn CodeurA(PA_15); //PB_7 +DigitalIn CodeurB(PB_7); //PA_15 +//InterruptIn BP(PC_12); +Serial pc(SERIAL_TX, SERIAL_RX); + + +// Leds +DigitalOut Led(PC_10); + +int counter=0, cnt=0; +int flag=0; + +// Sortie de test + +void flip(){ + //__disable_irq(); + flag=1; + cnt++; + Led =!Led; + if(CodeurB) { + counter++; + } + else { + counter--; + } + //__enable_irq(); +} + +void clignot(){ + Led = !Led; + counter=0; +} + +int main() +{ +/* lcd.cls(); // Clear screen + lcd.locate(0,3); // 1ere ligne + lcd.printf("Essai du module codeur"); +*/ +pc.printf("Hello world \n_r"); + Led = 1; + CodeurA.rise(&flip); + BP.fall(&clignot); + + while(1) { + if(flag==1) { +/* if(CodeurB) { + counter++; + } + else { + counter--; + }*/ +// Led =!Led; +// wait(0.01); + flag=0; + //__disable_irq(); + pc.printf("Compteur : %d %d \r\n",counter,cnt); + //__enable_irq(); + } +// lcd.locate(0,15); + +// wait(0.01); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sat Nov 07 17:33:42 2020 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file