Jared Baxter
/
Impedance_Fast_Circuitry
Impedance Fast Circuitry Software
Fork of DSP_200kHz by
main.cpp@66:72c5c24e532c, 2016-02-26 (annotated)
- Committer:
- bmazzeo
- Date:
- Fri Feb 26 20:02:36 2016 +0000
- Revision:
- 66:72c5c24e532c
- Parent:
- 64:bb4a4bd57681
- Child:
- 67:ec0c58490ce6
DSP passthrough and switching to allow alternate DSP processes and dialog
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
donatien | 0:bb128f0e952f | 1 | #include "mbed.h" |
timmey9 | 22:523e316cbe70 | 2 | |
timmey9 | 52:5a40cc58c4c2 | 3 | // Sampling |
bmazzeo | 53:83a90a47c1fd | 4 | #include "DMA_sampling/adc.h" |
bmazzeo | 54:1697dc574b96 | 5 | #include "DMA_sampling/dac.h" |
bmazzeo | 55:2526b3317bc8 | 6 | #include "DMA_sampling/pdb.h" |
timmey9 | 22:523e316cbe70 | 7 | |
timmey9 | 22:523e316cbe70 | 8 | // for debug purposes |
timmey9 | 18:b17ddeeb1c09 | 9 | Serial pc(USBTX, USBRX); |
timmey9 | 18:b17ddeeb1c09 | 10 | DigitalOut led_red(LED_RED); |
timmey9 | 18:b17ddeeb1c09 | 11 | DigitalOut led_green(LED_GREEN); |
timmey9 | 18:b17ddeeb1c09 | 12 | DigitalOut led_blue(LED_BLUE); |
bmazzeo | 58:4bee89daccff | 13 | DigitalOut status_0(D0); |
bmazzeo | 58:4bee89daccff | 14 | DigitalOut status_1(D1); |
bmazzeo | 66:72c5c24e532c | 15 | DigitalIn sw2(SW2); |
bmazzeo | 66:72c5c24e532c | 16 | DigitalIn sw3(SW3); |
timmey9 | 51:43143a3fc2d7 | 17 | |
timmey9 | 52:5a40cc58c4c2 | 18 | // defined in dma.cpp |
timmey9 | 45:d591d138cdeb | 19 | extern int len; |
timmey9 | 45:d591d138cdeb | 20 | extern uint16_t sample_array0[]; |
timmey9 | 45:d591d138cdeb | 21 | extern uint16_t sample_array1[]; |
timmey9 | 41:3e0623d81b9a | 22 | |
bmazzeo | 54:1697dc574b96 | 23 | extern uint16_t static_input_array0[]; |
bmazzeo | 54:1697dc574b96 | 24 | extern uint16_t static_input_array1[]; |
bmazzeo | 54:1697dc574b96 | 25 | |
bmazzeo | 55:2526b3317bc8 | 26 | extern uint16_t static_output_array0[]; |
bmazzeo | 56:7e08cbc3a4f1 | 27 | extern uint16_t output_array0[]; |
bmazzeo | 55:2526b3317bc8 | 28 | |
bmazzeo | 57:7b8c49e1c1f6 | 29 | extern uint16_t sampling_status; |
bmazzeo | 57:7b8c49e1c1f6 | 30 | |
timmey9 | 22:523e316cbe70 | 31 | using namespace std; |
timmey9 | 17:2f978f823020 | 32 | |
emilmont | 7:65188f4a8c25 | 33 | int main() { |
timmey9 | 22:523e316cbe70 | 34 | led_blue = 1; |
timmey9 | 35:df40c4566826 | 35 | led_green = 1; |
timmey9 | 18:b17ddeeb1c09 | 36 | led_red = 1; |
timmey9 | 34:44cc9b76a507 | 37 | |
timmey9 | 18:b17ddeeb1c09 | 38 | pc.baud(230400); |
timmey9 | 34:44cc9b76a507 | 39 | pc.printf("Starting\r\n"); |
timmey9 | 27:8c2b30c855d1 | 40 | |
bmazzeo | 66:72c5c24e532c | 41 | pdb_init(); // Initalize PDB |
bmazzeo | 66:72c5c24e532c | 42 | dac_init(); // initializes DAC |
timmey9 | 45:d591d138cdeb | 43 | adc_init(); // always initialize adc before dma |
bmazzeo | 53:83a90a47c1fd | 44 | pc.printf("ADC Initialized\r\n"); |
timmey9 | 51:43143a3fc2d7 | 45 | dma_init(); // initializes DMAs |
bmazzeo | 55:2526b3317bc8 | 46 | dma_reset(); // This clears any DMA triggers that may have gotten things into a different state |
timmey9 | 45:d591d138cdeb | 47 | |
bmazzeo | 54:1697dc574b96 | 48 | |
timmey9 | 46:a015ebf4663b | 49 | led_green = 1; |
timmey9 | 38:ec3b16c130d7 | 50 | |
timmey9 | 40:bd6d8c35e822 | 51 | pc.printf("\r\n\r\n\r\n"); |
timmey9 | 37:8bdc71f3e874 | 52 | |
bmazzeo | 64:bb4a4bd57681 | 53 | pdb_start(); |
bmazzeo | 64:bb4a4bd57681 | 54 | while(1) |
bmazzeo | 61:a56cca07d4a6 | 55 | { |
bmazzeo | 61:a56cca07d4a6 | 56 | while(sampling_status == 0) |
bmazzeo | 61:a56cca07d4a6 | 57 | { |
bmazzeo | 61:a56cca07d4a6 | 58 | status_0 = 1; |
bmazzeo | 61:a56cca07d4a6 | 59 | } |
bmazzeo | 66:72c5c24e532c | 60 | |
bmazzeo | 61:a56cca07d4a6 | 61 | sampling_status = 0; |
bmazzeo | 61:a56cca07d4a6 | 62 | status_0 = 0; |
bmazzeo | 66:72c5c24e532c | 63 | |
bmazzeo | 66:72c5c24e532c | 64 | if(sw2) |
bmazzeo | 61:a56cca07d4a6 | 65 | { |
bmazzeo | 66:72c5c24e532c | 66 | if(sw3) |
bmazzeo | 66:72c5c24e532c | 67 | { |
bmazzeo | 66:72c5c24e532c | 68 | //Default PASSTHROUGH Condition |
bmazzeo | 66:72c5c24e532c | 69 | status_1 = 1; |
bmazzeo | 66:72c5c24e532c | 70 | for(int i = 0; i < len; i++) |
bmazzeo | 66:72c5c24e532c | 71 | { |
bmazzeo | 66:72c5c24e532c | 72 | static_output_array0[i] = static_input_array0[i] >> 4; |
bmazzeo | 66:72c5c24e532c | 73 | } |
bmazzeo | 66:72c5c24e532c | 74 | status_1 = 0; |
bmazzeo | 66:72c5c24e532c | 75 | } |
bmazzeo | 66:72c5c24e532c | 76 | else |
bmazzeo | 66:72c5c24e532c | 77 | { |
bmazzeo | 66:72c5c24e532c | 78 | // Can show that buttons are active - Serial link working |
bmazzeo | 66:72c5c24e532c | 79 | status_1 = 1; |
bmazzeo | 66:72c5c24e532c | 80 | pc.printf("DSP\r\n"); |
bmazzeo | 66:72c5c24e532c | 81 | for(int i = 0; i < len; i++) |
bmazzeo | 66:72c5c24e532c | 82 | { |
bmazzeo | 66:72c5c24e532c | 83 | static_output_array0[i] = static_input_array0[i] >> 4; |
bmazzeo | 66:72c5c24e532c | 84 | } |
bmazzeo | 66:72c5c24e532c | 85 | status_1 = 0; |
bmazzeo | 66:72c5c24e532c | 86 | } |
bmazzeo | 66:72c5c24e532c | 87 | } |
bmazzeo | 66:72c5c24e532c | 88 | else |
bmazzeo | 66:72c5c24e532c | 89 | { |
bmazzeo | 66:72c5c24e532c | 90 | // Here we can really put our DSP blocks |
bmazzeo | 66:72c5c24e532c | 91 | status_1 = 1; |
bmazzeo | 66:72c5c24e532c | 92 | for(int i = 0; i < len; i++) |
bmazzeo | 66:72c5c24e532c | 93 | { |
bmazzeo | 66:72c5c24e532c | 94 | static_output_array0[i] = static_input_array0[i] >> 4; |
bmazzeo | 66:72c5c24e532c | 95 | } |
bmazzeo | 66:72c5c24e532c | 96 | status_1 = 0; |
bmazzeo | 61:a56cca07d4a6 | 97 | } |
bmazzeo | 61:a56cca07d4a6 | 98 | } |
bmazzeo | 61:a56cca07d4a6 | 99 | } |
bmazzeo | 63:7903a33e2fd4 | 100 |