Thomas MARGOTTIN
/
Fragile
exemple gene carre
Fork of FSK_EX by
Diff: main.cpp
- Revision:
- 1:b4e439085e82
- Parent:
- 0:a882c1c6acaa
--- a/main.cpp Mon May 23 06:16:46 2016 +0000 +++ b/main.cpp Mon May 23 07:33:12 2016 +0000 @@ -1,26 +1,41 @@ #include "mbed.h" - DigitalOut FSK(p20); +PwmOut DataOut(p21); +DigitalIn DataIn(p15); +/*AnalogIn DataIn(p15);*/ void myIRQ() { LPC_TIM0->IR |= 1 << 0; FSK = !FSK; -} +} - -int main() { +int main() +{ + DataOut.period(0.0017); + DataOut.write(0.50); - - while (1) { - + while (1) + { + if(DataIn == 0) + { LPC_TIM0->MR0 = 104; // Match count for 114kHz LPC_TIM0->MCR = 3; // Interrupt and Reset on Match LPC_TIM0->TCR = 1; // Enable Timer0 NVIC_SetVector(TIMER0_IRQn,(uint32_t)&myIRQ); NVIC_EnableIRQ(TIMER0_IRQn); + } + + if(DataIn == 1) + { + LPC_TIM0->MR0 = 119; // Match count for 100kHz + LPC_TIM0->MCR = 3; // Interrupt and Reset on Match + LPC_TIM0->TCR = 1; // Enable Timer0 + NVIC_SetVector(TIMER0_IRQn,(uint32_t)&myIRQ); + NVIC_EnableIRQ(TIMER0_IRQn); + } } } \ No newline at end of file