Sunshine Grace Cabatan
/
EVAL-AD910x
Example program for EVAL-AD9106 and EVAL-AD9102
main.cpp@9:c8314b2228f1, 2021-04-10 (annotated)
- Committer:
- scabatan
- Date:
- Sat Apr 10 13:40:11 2021 +0000
- Revision:
- 9:c8314b2228f1
- Parent:
- 8:51792457e0da
changed default device
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
scabatan | 8:51792457e0da | 1 | /******************************************************************************* |
scabatan | 8:51792457e0da | 2 | @file: main.cpp |
scabatan | 8:51792457e0da | 3 | |
scabatan | 8:51792457e0da | 4 | @brief: Main module for EVAL-AD910x application interface |
scabatan | 8:51792457e0da | 5 | -------------------------------------------------------------------------------- |
scabatan | 8:51792457e0da | 6 | Copyright (c) 2021 Analog Devices, Inc. |
scabatan | 8:51792457e0da | 7 | All rights reserved. |
scabatan | 8:51792457e0da | 8 | |
scabatan | 8:51792457e0da | 9 | This software is proprietary to Analog Devices, Inc. and its licensors. |
scabatan | 8:51792457e0da | 10 | By using this software you agree to the terms of the associated |
scabatan | 8:51792457e0da | 11 | Analog Devices Software License Agreement. |
scabatan | 8:51792457e0da | 12 | |
scabatan | 8:51792457e0da | 13 | 20210120-LWSC-CTSLA |
scabatan | 8:51792457e0da | 14 | *******************************************************************************/ |
Kjansen45 | 0:3c9cc352dbfc | 15 | |
scabatan | 1:b9d129e45c30 | 16 | /*** Libraries ***/ |
scabatan | 1:b9d129e45c30 | 17 | #include "mbed.h" |
scabatan | 1:b9d129e45c30 | 18 | #include "platform/mbed_thread.h" |
scabatan | 1:b9d129e45c30 | 19 | #include "config.h" |
scabatan | 1:b9d129e45c30 | 20 | #include "ad910x.h" |
Kjansen45 | 0:3c9cc352dbfc | 21 | |
scabatan | 1:b9d129e45c30 | 22 | /*** Defines for UART Protocol ***/ |
scabatan | 4:abab08222795 | 23 | #define BAUD_RATE 115200 |
scabatan | 1:b9d129e45c30 | 24 | |
scabatan | 1:b9d129e45c30 | 25 | AD910x device( PA_15 ); |
scabatan | 8:51792457e0da | 26 | DigitalOut en_cvddx( PG_7, 0 ); ///DigitalOut instance for enable pin of on-board oscillator supply |
scabatan | 8:51792457e0da | 27 | DigitalOut shdn_n_lt3472( PG_9, 0 ); ///DigitalOut instance for shutdown/enable pin of on-board amplifier supply |
scabatan | 1:b9d129e45c30 | 28 | |
scabatan | 1:b9d129e45c30 | 29 | /* Configure and instantiate UART protocol and baud rate */ |
scabatan | 1:b9d129e45c30 | 30 | UnbufferedSerial pc( USBTX, USBRX, BAUD_RATE ); |
Kjansen45 | 0:3c9cc352dbfc | 31 | |
scabatan | 1:b9d129e45c30 | 32 | /*** Function Declarations ***/ |
scabatan | 1:b9d129e45c30 | 33 | void setup_device( void ); |
scabatan | 1:b9d129e45c30 | 34 | void print_title( void ); |
scabatan | 1:b9d129e45c30 | 35 | void print_prompt1( void ); |
scabatan | 1:b9d129e45c30 | 36 | void print_prompt2( void ); |
scabatan | 1:b9d129e45c30 | 37 | void print_menu( void ); |
scabatan | 1:b9d129e45c30 | 38 | void play_example1( void ); |
scabatan | 1:b9d129e45c30 | 39 | void play_example2( void ); |
scabatan | 1:b9d129e45c30 | 40 | void play_example3( void ); |
scabatan | 1:b9d129e45c30 | 41 | void play_example4( void ); |
scabatan | 1:b9d129e45c30 | 42 | void play_example5( void ); |
scabatan | 1:b9d129e45c30 | 43 | void play_example6( void ); |
scabatan | 1:b9d129e45c30 | 44 | void print_prompt3( void ); |
scabatan | 1:b9d129e45c30 | 45 | void stop_example( void ); |
scabatan | 1:b9d129e45c30 | 46 | void print_prompt4( void ); |
Kjansen45 | 0:3c9cc352dbfc | 47 | |
scabatan | 1:b9d129e45c30 | 48 | /*** Main Function ***/ |
Kjansen45 | 0:3c9cc352dbfc | 49 | |
Kjansen45 | 0:3c9cc352dbfc | 50 | int main() |
Kjansen45 | 0:3c9cc352dbfc | 51 | { |
scabatan | 1:b9d129e45c30 | 52 | char ext_clk = 'y'; |
scabatan | 1:b9d129e45c30 | 53 | char amp_out = 'n'; |
scabatan | 1:b9d129e45c30 | 54 | char stop = 'n'; |
scabatan | 1:b9d129e45c30 | 55 | char exit = 'n'; |
scabatan | 1:b9d129e45c30 | 56 | char example = 1; |
scabatan | 1:b9d129e45c30 | 57 | uint8_t connected = 1; |
scabatan | 1:b9d129e45c30 | 58 | |
scabatan | 1:b9d129e45c30 | 59 | device.resetb = 1; |
scabatan | 1:b9d129e45c30 | 60 | device.triggerb = 1; |
scabatan | 1:b9d129e45c30 | 61 | setup_device(); |
scabatan | 1:b9d129e45c30 | 62 | |
Kjansen45 | 0:3c9cc352dbfc | 63 | print_title(); |
scabatan | 1:b9d129e45c30 | 64 | |
scabatan | 1:b9d129e45c30 | 65 | while( connected == 1 ){ |
scabatan | 1:b9d129e45c30 | 66 | print_prompt1(); |
scabatan | 6:b0e941764bb7 | 67 | while( pc.readable() == 0 ); |
scabatan | 1:b9d129e45c30 | 68 | ext_clk = getchar(); |
scabatan | 1:b9d129e45c30 | 69 | if ( ext_clk == 'y' ){ |
scabatan | 1:b9d129e45c30 | 70 | en_cvddx = 0; |
scabatan | 1:b9d129e45c30 | 71 | printf("Please connect external clock source to J10.\n"); |
scabatan | 1:b9d129e45c30 | 72 | } else { |
scabatan | 1:b9d129e45c30 | 73 | en_cvddx = 1; |
scabatan | 1:b9d129e45c30 | 74 | printf("On-board oscillator supply is enabled.\n"); |
scabatan | 1:b9d129e45c30 | 75 | } |
scabatan | 2:f20dbb194f12 | 76 | thread_sleep_for(500); |
scabatan | 1:b9d129e45c30 | 77 | print_prompt2(); |
scabatan | 6:b0e941764bb7 | 78 | while( pc.readable() == 0 ); |
scabatan | 1:b9d129e45c30 | 79 | amp_out = getchar(); |
scabatan | 1:b9d129e45c30 | 80 | if ( amp_out == 'y' ){ |
scabatan | 1:b9d129e45c30 | 81 | shdn_n_lt3472 = 1; |
scabatan | 1:b9d129e45c30 | 82 | printf("On-board amplifier supply is enabled.\n"); |
scabatan | 1:b9d129e45c30 | 83 | } else { |
scabatan | 1:b9d129e45c30 | 84 | shdn_n_lt3472 = 0; |
scabatan | 1:b9d129e45c30 | 85 | } |
scabatan | 1:b9d129e45c30 | 86 | print_menu(); |
scabatan | 1:b9d129e45c30 | 87 | example = getchar(); |
scabatan | 6:b0e941764bb7 | 88 | while( pc.readable() == 0 ); |
scabatan | 1:b9d129e45c30 | 89 | printf("%c\n", example); |
scabatan | 1:b9d129e45c30 | 90 | switch (example) { |
scabatan | 1:b9d129e45c30 | 91 | case '1': |
scabatan | 1:b9d129e45c30 | 92 | play_example1(); |
scabatan | 1:b9d129e45c30 | 93 | break; |
Kjansen45 | 0:3c9cc352dbfc | 94 | |
scabatan | 1:b9d129e45c30 | 95 | case '2': |
scabatan | 1:b9d129e45c30 | 96 | play_example2(); |
scabatan | 1:b9d129e45c30 | 97 | break; |
scabatan | 1:b9d129e45c30 | 98 | |
scabatan | 1:b9d129e45c30 | 99 | case '3': |
scabatan | 1:b9d129e45c30 | 100 | play_example3(); |
Kjansen45 | 0:3c9cc352dbfc | 101 | break; |
Kjansen45 | 0:3c9cc352dbfc | 102 | |
scabatan | 1:b9d129e45c30 | 103 | case '4': |
scabatan | 1:b9d129e45c30 | 104 | play_example4(); |
Kjansen45 | 0:3c9cc352dbfc | 105 | break; |
scabatan | 1:b9d129e45c30 | 106 | |
scabatan | 1:b9d129e45c30 | 107 | case '5': |
scabatan | 1:b9d129e45c30 | 108 | play_example5(); |
scabatan | 1:b9d129e45c30 | 109 | break; |
scabatan | 1:b9d129e45c30 | 110 | |
scabatan | 1:b9d129e45c30 | 111 | case '6': |
scabatan | 1:b9d129e45c30 | 112 | play_example6(); |
scabatan | 1:b9d129e45c30 | 113 | break; |
scabatan | 1:b9d129e45c30 | 114 | |
Kjansen45 | 0:3c9cc352dbfc | 115 | default: |
scabatan | 1:b9d129e45c30 | 116 | printf("\n****Invalid Entry****\n\n"); |
Kjansen45 | 0:3c9cc352dbfc | 117 | break; |
scabatan | 1:b9d129e45c30 | 118 | } |
scabatan | 1:b9d129e45c30 | 119 | print_prompt3(); |
scabatan | 6:b0e941764bb7 | 120 | while( pc.readable() == 0 ); |
scabatan | 1:b9d129e45c30 | 121 | while ( !(stop == 'y') ){ |
scabatan | 1:b9d129e45c30 | 122 | stop = getchar(); |
scabatan | 1:b9d129e45c30 | 123 | } |
scabatan | 1:b9d129e45c30 | 124 | stop_example(); |
scabatan | 1:b9d129e45c30 | 125 | print_prompt4(); |
scabatan | 6:b0e941764bb7 | 126 | while( pc.readable() == 0 ); |
scabatan | 1:b9d129e45c30 | 127 | exit = getchar(); |
scabatan | 1:b9d129e45c30 | 128 | if ( exit == 'y' ){ |
scabatan | 1:b9d129e45c30 | 129 | connected = 0; |
scabatan | 1:b9d129e45c30 | 130 | printf("\nExiting program...\n"); |
scabatan | 6:b0e941764bb7 | 131 | }else{ |
scabatan | 6:b0e941764bb7 | 132 | stop = 'n'; |
scabatan | 1:b9d129e45c30 | 133 | } |
scabatan | 1:b9d129e45c30 | 134 | |
scabatan | 1:b9d129e45c30 | 135 | } |
scabatan | 1:b9d129e45c30 | 136 | |
scabatan | 1:b9d129e45c30 | 137 | return 0; |
scabatan | 1:b9d129e45c30 | 138 | |
scabatan | 1:b9d129e45c30 | 139 | } |
scabatan | 1:b9d129e45c30 | 140 | |
scabatan | 1:b9d129e45c30 | 141 | /*** Function Definitions ***/ |
Kjansen45 | 0:3c9cc352dbfc | 142 | |
scabatan | 1:b9d129e45c30 | 143 | /*Function to setup SPI communication*/ |
scabatan | 1:b9d129e45c30 | 144 | void setup_device() |
scabatan | 1:b9d129e45c30 | 145 | { |
scabatan | 1:b9d129e45c30 | 146 | device.spi_init( WORD_LEN, POL, FREQ ); |
scabatan | 1:b9d129e45c30 | 147 | device.AD910x_reg_reset(); |
scabatan | 1:b9d129e45c30 | 148 | } |
scabatan | 1:b9d129e45c30 | 149 | |
scabatan | 1:b9d129e45c30 | 150 | /*Function to print the title block when program first starts*/ |
scabatan | 1:b9d129e45c30 | 151 | void print_title() |
scabatan | 1:b9d129e45c30 | 152 | { |
scabatan | 1:b9d129e45c30 | 153 | printf("\n***********************************************************************\n"); |
scabatan | 2:f20dbb194f12 | 154 | printf("* EVAL-%s Demonstration Program *\n", ACTIVE_DEVICE); |
scabatan | 1:b9d129e45c30 | 155 | printf("* *\n"); |
scabatan | 1:b9d129e45c30 | 156 | printf("* This program demonstrates how to generate waveforms with the %s *\n", ACTIVE_DEVICE); |
scabatan | 1:b9d129e45c30 | 157 | printf("* using example register configurations in the datasheet. *\n"); |
scabatan | 3:7a4971eab899 | 158 | printf("* This program is developed on Mbed OS version 6. *\n"); |
scabatan | 1:b9d129e45c30 | 159 | printf("***********************************************************************\n"); |
scabatan | 1:b9d129e45c30 | 160 | } |
scabatan | 1:b9d129e45c30 | 161 | |
scabatan | 1:b9d129e45c30 | 162 | /*Function to print the first prompt/question to user to setup on-board oscillator supply*/ |
scabatan | 1:b9d129e45c30 | 163 | void print_prompt1() |
scabatan | 1:b9d129e45c30 | 164 | { |
scabatan | 1:b9d129e45c30 | 165 | printf( "\nUsing external clock source?\n" ); |
scabatan | 1:b9d129e45c30 | 166 | printf( "If yes, press y. If no, press any other key.\n" ); |
scabatan | 1:b9d129e45c30 | 167 | } |
scabatan | 1:b9d129e45c30 | 168 | |
scabatan | 1:b9d129e45c30 | 169 | /*Function to print the next prompt/question to user to setup on-board amplifier supply*/ |
scabatan | 1:b9d129e45c30 | 170 | void print_prompt2() |
scabatan | 1:b9d129e45c30 | 171 | { |
scabatan | 1:b9d129e45c30 | 172 | printf( "\nConnected DAC outputs to on-board amplifiers?\n" ); |
scabatan | 1:b9d129e45c30 | 173 | printf( "If yes, press y. If no, press any other key.\n" ); |
Kjansen45 | 0:3c9cc352dbfc | 174 | } |
Kjansen45 | 0:3c9cc352dbfc | 175 | |
scabatan | 1:b9d129e45c30 | 176 | /*Function to print summary of example AD910x configurations to play*/ |
scabatan | 1:b9d129e45c30 | 177 | void print_menu() |
scabatan | 1:b9d129e45c30 | 178 | { |
scabatan | 1:b9d129e45c30 | 179 | printf("\nExample Summary\n"); |
scabatan | 1:b9d129e45c30 | 180 | if ( ACTIVE_DEVICE == "AD9106" ){ |
scabatan | 1:b9d129e45c30 | 181 | printf(" 1 - 4 Gaussian Pulses with Different Start Delays and Digital Gain Settings\n"); |
scabatan | 1:b9d129e45c30 | 182 | printf(" 2 - 4 Pulses Generated from an SRAM Vector\n"); |
scabatan | 1:b9d129e45c30 | 183 | printf(" 3 - 4 Pulsed DDS-Generated Sine Waves with Different Start Delays and Digital Gain Settings\n"); |
scabatan | 1:b9d129e45c30 | 184 | printf(" 4 - Pulsed DDS-Generated Sine Wave and 3 Sawtooth Generator Waveforms\n"); |
scabatan | 1:b9d129e45c30 | 185 | printf(" 5 - Pulsed DDS-Generated Sine Waves Amplitude-Modulated by an SRAM Vector\n"); |
scabatan | 1:b9d129e45c30 | 186 | printf(" 6 - DDS-Generated Sine Wave and 3 Sawtooth Waveforms\n"); |
scabatan | 1:b9d129e45c30 | 187 | }else if( ACTIVE_DEVICE == "AD9102" ){ |
scabatan | 1:b9d129e45c30 | 188 | printf(" 1 - Gaussian Pulse\n"); |
scabatan | 1:b9d129e45c30 | 189 | printf(" 2 - Pulse Generated from an SRAM Vector\n"); |
scabatan | 1:b9d129e45c30 | 190 | printf(" 3 - Pulsed DDS-Generated Sine Wave\n"); |
scabatan | 1:b9d129e45c30 | 191 | printf(" 4 - Sawtooth Waveform\n"); |
scabatan | 1:b9d129e45c30 | 192 | printf(" 5 - Pulsed DDS-Generated Sine Wave Amplitude-Modulated by an SRAM Vector\n"); |
scabatan | 1:b9d129e45c30 | 193 | printf(" 6 - DDS-Generated Sine Wave\n"); |
scabatan | 1:b9d129e45c30 | 194 | } |
scabatan | 1:b9d129e45c30 | 195 | printf("Select an option: "); |
scabatan | 1:b9d129e45c30 | 196 | } |
Kjansen45 | 0:3c9cc352dbfc | 197 | |
scabatan | 1:b9d129e45c30 | 198 | /*Function to play example 1*/ |
scabatan | 1:b9d129e45c30 | 199 | void play_example1() |
Kjansen45 | 0:3c9cc352dbfc | 200 | { |
scabatan | 1:b9d129e45c30 | 201 | if ( ACTIVE_DEVICE == "AD9106" ){ |
scabatan | 1:b9d129e45c30 | 202 | printf("\n4 Gaussian Pulses with Different Start Delays and Digital Gain Settings\n"); |
scabatan | 1:b9d129e45c30 | 203 | thread_sleep_for(500); |
scabatan | 1:b9d129e45c30 | 204 | device.AD910x_update_sram( example1_RAM_gaussian ); |
scabatan | 1:b9d129e45c30 | 205 | device.AD910x_update_regs( AD9106_example1_regval ); |
scabatan | 1:b9d129e45c30 | 206 | }else if( ACTIVE_DEVICE == "AD9102" ){ |
scabatan | 1:b9d129e45c30 | 207 | printf("\nGaussian Pulse\n"); |
scabatan | 1:b9d129e45c30 | 208 | thread_sleep_for(500); |
scabatan | 1:b9d129e45c30 | 209 | device.AD910x_update_sram( example1_RAM_gaussian ); |
scabatan | 1:b9d129e45c30 | 210 | device.AD910x_update_regs( AD9102_example1_regval ); |
scabatan | 1:b9d129e45c30 | 211 | } |
scabatan | 1:b9d129e45c30 | 212 | device.AD910x_start_pattern(); |
scabatan | 1:b9d129e45c30 | 213 | } |
scabatan | 1:b9d129e45c30 | 214 | |
scabatan | 1:b9d129e45c30 | 215 | /*Function to play example 2*/ |
scabatan | 1:b9d129e45c30 | 216 | void play_example2() |
scabatan | 1:b9d129e45c30 | 217 | { |
scabatan | 1:b9d129e45c30 | 218 | if ( ACTIVE_DEVICE == "AD9106" ){ |
scabatan | 1:b9d129e45c30 | 219 | printf("\n4 Pulses Generated from an SRAM Vector\n"); |
scabatan | 1:b9d129e45c30 | 220 | thread_sleep_for(500); |
scabatan | 1:b9d129e45c30 | 221 | device.AD910x_update_sram( example2_4096_ramp ); |
scabatan | 1:b9d129e45c30 | 222 | device.AD910x_update_regs( AD9106_example2_regval ); |
scabatan | 1:b9d129e45c30 | 223 | }else if( ACTIVE_DEVICE == "AD9102" ){ |
scabatan | 1:b9d129e45c30 | 224 | printf("\nPulse Generated from an SRAM Vector\n"); |
scabatan | 1:b9d129e45c30 | 225 | thread_sleep_for(500); |
scabatan | 1:b9d129e45c30 | 226 | device.AD910x_update_sram( example2_4096_ramp ); |
scabatan | 1:b9d129e45c30 | 227 | device.AD910x_update_regs( AD9102_example2_regval ); |
scabatan | 1:b9d129e45c30 | 228 | } |
scabatan | 1:b9d129e45c30 | 229 | device.AD910x_start_pattern(); |
Kjansen45 | 0:3c9cc352dbfc | 230 | } |
Kjansen45 | 0:3c9cc352dbfc | 231 | |
scabatan | 1:b9d129e45c30 | 232 | /*Function to play example 3*/ |
scabatan | 1:b9d129e45c30 | 233 | void play_example3() |
scabatan | 1:b9d129e45c30 | 234 | { |
scabatan | 1:b9d129e45c30 | 235 | if ( ACTIVE_DEVICE == "AD9106" ){ |
scabatan | 1:b9d129e45c30 | 236 | printf("\n4 Pulsed DDS-Generated Sine Waves with Different Start Delays and Digital Gain Settings\n"); |
scabatan | 1:b9d129e45c30 | 237 | thread_sleep_for(500); |
scabatan | 1:b9d129e45c30 | 238 | device.AD910x_update_regs( AD9106_example3_regval ); |
scabatan | 1:b9d129e45c30 | 239 | }else if( ACTIVE_DEVICE == "AD9102" ){ |
scabatan | 1:b9d129e45c30 | 240 | printf("\nPulsed DDS-Generated Sine Wave\n"); |
scabatan | 1:b9d129e45c30 | 241 | thread_sleep_for(500); |
scabatan | 1:b9d129e45c30 | 242 | device.AD910x_update_regs( AD9102_example3_regval ); |
scabatan | 1:b9d129e45c30 | 243 | } |
scabatan | 1:b9d129e45c30 | 244 | device.AD910x_start_pattern(); |
scabatan | 1:b9d129e45c30 | 245 | } |
scabatan | 1:b9d129e45c30 | 246 | |
scabatan | 1:b9d129e45c30 | 247 | /*Function to play example 4*/ |
scabatan | 1:b9d129e45c30 | 248 | void play_example4() |
scabatan | 1:b9d129e45c30 | 249 | { |
scabatan | 1:b9d129e45c30 | 250 | if ( ACTIVE_DEVICE == "AD9106" ){ |
scabatan | 1:b9d129e45c30 | 251 | printf("\nPulsed DDS-Generated Sine Wave and 3 Sawtooth Generator Waveforms\n"); |
scabatan | 1:b9d129e45c30 | 252 | thread_sleep_for(500); |
scabatan | 1:b9d129e45c30 | 253 | device.AD910x_update_regs( AD9106_example4_regval ); |
scabatan | 1:b9d129e45c30 | 254 | }else if( ACTIVE_DEVICE == "AD9102" ){ |
scabatan | 1:b9d129e45c30 | 255 | printf("\nSawtooth Waveform\n"); |
scabatan | 1:b9d129e45c30 | 256 | thread_sleep_for(500); |
scabatan | 1:b9d129e45c30 | 257 | device.AD910x_update_regs( AD9102_example4_regval ); |
scabatan | 1:b9d129e45c30 | 258 | } |
scabatan | 1:b9d129e45c30 | 259 | device.AD910x_start_pattern(); |
Kjansen45 | 0:3c9cc352dbfc | 260 | } |
Kjansen45 | 0:3c9cc352dbfc | 261 | |
scabatan | 1:b9d129e45c30 | 262 | /*Function to play example 5*/ |
scabatan | 1:b9d129e45c30 | 263 | void play_example5() |
Kjansen45 | 0:3c9cc352dbfc | 264 | { |
scabatan | 1:b9d129e45c30 | 265 | if ( ACTIVE_DEVICE == "AD9106" ){ |
scabatan | 1:b9d129e45c30 | 266 | printf("\n4 Pulses Generated from an SRAM Vector\n"); |
scabatan | 1:b9d129e45c30 | 267 | thread_sleep_for(500); |
scabatan | 1:b9d129e45c30 | 268 | device.AD910x_update_sram( example5_RAM_gaussian ); |
scabatan | 1:b9d129e45c30 | 269 | device.AD910x_update_regs( AD9106_example5_regval ); |
scabatan | 1:b9d129e45c30 | 270 | }else if ( ACTIVE_DEVICE == "AD9102"){ |
scabatan | 1:b9d129e45c30 | 271 | printf("\nPulse Generated from an SRAM Vector\n"); |
scabatan | 1:b9d129e45c30 | 272 | thread_sleep_for(500); |
scabatan | 1:b9d129e45c30 | 273 | device.AD910x_update_sram( example5_RAM_gaussian ); |
scabatan | 1:b9d129e45c30 | 274 | device.AD910x_update_regs( AD9102_example5_regval ); |
scabatan | 1:b9d129e45c30 | 275 | } |
scabatan | 1:b9d129e45c30 | 276 | device.AD910x_start_pattern(); |
Kjansen45 | 0:3c9cc352dbfc | 277 | } |
Kjansen45 | 0:3c9cc352dbfc | 278 | |
scabatan | 1:b9d129e45c30 | 279 | /*Function to play example 1*/ |
scabatan | 1:b9d129e45c30 | 280 | void play_example6() |
scabatan | 1:b9d129e45c30 | 281 | { |
scabatan | 1:b9d129e45c30 | 282 | if ( ACTIVE_DEVICE == "AD9106" ){ |
scabatan | 1:b9d129e45c30 | 283 | printf("\nDDS-Generated Sine Wave and 3 Sawtooth Waveforms\n"); |
scabatan | 1:b9d129e45c30 | 284 | thread_sleep_for(500); |
scabatan | 1:b9d129e45c30 | 285 | device.AD910x_update_regs( AD9106_example6_regval ); |
scabatan | 1:b9d129e45c30 | 286 | }else if( ACTIVE_DEVICE == "AD9102" ){ |
scabatan | 1:b9d129e45c30 | 287 | printf("\nDDS-Generated Sine Wave\n"); |
scabatan | 1:b9d129e45c30 | 288 | thread_sleep_for(500); |
scabatan | 1:b9d129e45c30 | 289 | device.AD910x_update_regs( AD9102_example6_regval ); |
scabatan | 1:b9d129e45c30 | 290 | } |
scabatan | 1:b9d129e45c30 | 291 | device.AD910x_start_pattern(); |
scabatan | 1:b9d129e45c30 | 292 | } |
scabatan | 1:b9d129e45c30 | 293 | |
scabatan | 1:b9d129e45c30 | 294 | /*Function to print prompt/question to user to stop pattern*/ |
scabatan | 1:b9d129e45c30 | 295 | void print_prompt3() |
Kjansen45 | 0:3c9cc352dbfc | 296 | { |
scabatan | 1:b9d129e45c30 | 297 | printf( "\nStop pattern?\n" ); |
scabatan | 1:b9d129e45c30 | 298 | printf( "If yes, press y.\n" ); |
Kjansen45 | 0:3c9cc352dbfc | 299 | } |
scabatan | 1:b9d129e45c30 | 300 | |
scabatan | 1:b9d129e45c30 | 301 | /*Function to stop pattern generation*/ |
scabatan | 1:b9d129e45c30 | 302 | void stop_example() |
scabatan | 1:b9d129e45c30 | 303 | { |
scabatan | 1:b9d129e45c30 | 304 | device.AD910x_stop_pattern(); |
scabatan | 1:b9d129e45c30 | 305 | printf( "Pattern stopped.\n" ); |
scabatan | 1:b9d129e45c30 | 306 | } |
scabatan | 1:b9d129e45c30 | 307 | |
scabatan | 1:b9d129e45c30 | 308 | /*Function to print prompt/question to user to exit program*/ |
scabatan | 1:b9d129e45c30 | 309 | void print_prompt4() |
scabatan | 1:b9d129e45c30 | 310 | { |
scabatan | 1:b9d129e45c30 | 311 | printf( "\nExit program?\n" ); |
scabatan | 1:b9d129e45c30 | 312 | printf( "If yes, press y.\n" ); |
scabatan | 1:b9d129e45c30 | 313 | } |