Thomas MARGOTTIN
/
Fragile
exemple gene carre
Fork of FSK_EX by
main.cpp@1:b4e439085e82, 2016-05-23 (annotated)
- Committer:
- ThomasMargottin
- Date:
- Mon May 23 07:33:12 2016 +0000
- Revision:
- 1:b4e439085e82
- Parent:
- 0:a882c1c6acaa
prout
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rpresa | 0:a882c1c6acaa | 1 | #include "mbed.h" |
rpresa | 0:a882c1c6acaa | 2 | |
rpresa | 0:a882c1c6acaa | 3 | DigitalOut FSK(p20); |
ThomasMargottin | 1:b4e439085e82 | 4 | PwmOut DataOut(p21); |
ThomasMargottin | 1:b4e439085e82 | 5 | DigitalIn DataIn(p15); |
rpresa | 0:a882c1c6acaa | 6 | |
ThomasMargottin | 1:b4e439085e82 | 7 | /*AnalogIn DataIn(p15);*/ |
rpresa | 0:a882c1c6acaa | 8 | |
rpresa | 0:a882c1c6acaa | 9 | void myIRQ() { |
rpresa | 0:a882c1c6acaa | 10 | LPC_TIM0->IR |= 1 << 0; |
rpresa | 0:a882c1c6acaa | 11 | FSK = !FSK; |
ThomasMargottin | 1:b4e439085e82 | 12 | } |
rpresa | 0:a882c1c6acaa | 13 | |
ThomasMargottin | 1:b4e439085e82 | 14 | int main() |
ThomasMargottin | 1:b4e439085e82 | 15 | { |
rpresa | 0:a882c1c6acaa | 16 | |
ThomasMargottin | 1:b4e439085e82 | 17 | DataOut.period(0.0017); |
ThomasMargottin | 1:b4e439085e82 | 18 | DataOut.write(0.50); |
rpresa | 0:a882c1c6acaa | 19 | |
ThomasMargottin | 1:b4e439085e82 | 20 | while (1) |
ThomasMargottin | 1:b4e439085e82 | 21 | { |
ThomasMargottin | 1:b4e439085e82 | 22 | if(DataIn == 0) |
ThomasMargottin | 1:b4e439085e82 | 23 | { |
rpresa | 0:a882c1c6acaa | 24 | LPC_TIM0->MR0 = 104; // Match count for 114kHz |
rpresa | 0:a882c1c6acaa | 25 | LPC_TIM0->MCR = 3; // Interrupt and Reset on Match |
rpresa | 0:a882c1c6acaa | 26 | LPC_TIM0->TCR = 1; // Enable Timer0 |
rpresa | 0:a882c1c6acaa | 27 | NVIC_SetVector(TIMER0_IRQn,(uint32_t)&myIRQ); |
rpresa | 0:a882c1c6acaa | 28 | NVIC_EnableIRQ(TIMER0_IRQn); |
ThomasMargottin | 1:b4e439085e82 | 29 | } |
ThomasMargottin | 1:b4e439085e82 | 30 | |
ThomasMargottin | 1:b4e439085e82 | 31 | if(DataIn == 1) |
ThomasMargottin | 1:b4e439085e82 | 32 | { |
ThomasMargottin | 1:b4e439085e82 | 33 | LPC_TIM0->MR0 = 119; // Match count for 100kHz |
ThomasMargottin | 1:b4e439085e82 | 34 | LPC_TIM0->MCR = 3; // Interrupt and Reset on Match |
ThomasMargottin | 1:b4e439085e82 | 35 | LPC_TIM0->TCR = 1; // Enable Timer0 |
ThomasMargottin | 1:b4e439085e82 | 36 | NVIC_SetVector(TIMER0_IRQn,(uint32_t)&myIRQ); |
ThomasMargottin | 1:b4e439085e82 | 37 | NVIC_EnableIRQ(TIMER0_IRQn); |
ThomasMargottin | 1:b4e439085e82 | 38 | } |
rpresa | 0:a882c1c6acaa | 39 | } |
rpresa | 0:a882c1c6acaa | 40 | |
rpresa | 0:a882c1c6acaa | 41 | } |