by Rob Toulson and Tim Wilmshurst from textbook "Fast and Effective Embedded Systems Design: Applying the ARM mbed"
main.cpp@0:9ba494009efb, 2013-06-16 (annotated)
- Committer:
- robt
- Date:
- Sun Jun 16 15:18:06 2013 +0000
- Revision:
- 0:9ba494009efb
by Rob Toulson and Tim Wilmshurst from textbook "Fast and Effective Embedded Systems Design: Applying the ARM mbed"
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
robt | 0:9ba494009efb | 1 | /* Program Example 11.1 DSP input and Output |
robt | 0:9ba494009efb | 2 | */ |
robt | 0:9ba494009efb | 3 | #include "mbed.h" |
robt | 0:9ba494009efb | 4 | //mbed objects |
robt | 0:9ba494009efb | 5 | AnalogIn Ain(p15); |
robt | 0:9ba494009efb | 6 | AnalogOut Aout(p18); |
robt | 0:9ba494009efb | 7 | Ticker s20khz_tick; |
robt | 0:9ba494009efb | 8 | |
robt | 0:9ba494009efb | 9 | //function prototypes |
robt | 0:9ba494009efb | 10 | void s20khz_task(void); |
robt | 0:9ba494009efb | 11 | //variables and data |
robt | 0:9ba494009efb | 12 | float data_in, data_out; |
robt | 0:9ba494009efb | 13 | |
robt | 0:9ba494009efb | 14 | //main program start here |
robt | 0:9ba494009efb | 15 | int main() { |
robt | 0:9ba494009efb | 16 | s20khz_tick.attach_us(&s20khz_task,50); //attach task to 50us tick |
robt | 0:9ba494009efb | 17 | } |
robt | 0:9ba494009efb | 18 | |
robt | 0:9ba494009efb | 19 | // function 20khz_task |
robt | 0:9ba494009efb | 20 | void s20khz_task(void){ |
robt | 0:9ba494009efb | 21 | data_in=Ain; |
robt | 0:9ba494009efb | 22 | data_out=data_in; |
robt | 0:9ba494009efb | 23 | Aout=data_out; |
robt | 0:9ba494009efb | 24 | } |
robt | 0:9ba494009efb | 25 |