Definition in file demo.c.
#include "dsp_process.h"
#include "gui.h"
#include "controller.h"
#include "board.h"
#include "twim.h"
#include "pm.h"
#include "tpa6130.h"
#include "gpio.h"
#include "print_funcs.h"
#include "intc.h"
#include "flashc.h"
#include "conf_demo.h"
Go to the source code of this file.
Defines | |
#define | TEXT_FILTER "Filters\nFUNC 1 - 3:\n Select filter" |
#define | TEXT_FUNC1 "FUNC1" |
#define | TEXT_FUNC2 "FUNC2" |
#define | TEXT_FUNC3 "FUNC3" |
#define | TEXT_FUNC_NOT_IMPLEMENTED "Function not\nimplemented" |
#define | TEXT_IDLE "FUNC1 - Frame/s\nFUNC2 - Volume\nWHEEL - Select box" |
#define | TEXT_INPUT "Input signal\nFUNC1 - Time/FFT\nFUNC3 - Zoom" |
#define | TEXT_OUTPUT "Output signal\nFUNC1 - Time/FFT\nFUNC3 - Zoom" |
#define | TEXT_SOURCE1 "Source1\nFUNC1 - Amplitude\nFUNC2 - Frequency\nFUNC3 - Zoom" |
#define | TEXT_SOURCE2 "Source2\nFUNC1 - Amplitude\nFUNC2 - Frequency\nFUNC3 - Zoom" |
#define | TEXT_WHEEL "(Use the WHEEL)" |
Enumerations | |
enum | state_function { STATE_FCT_IDLE, STATE_FCT_FUNCTION1, STATE_FCT_FUNCTION2, STATE_FCT_FUNCTION3, STATE_FCT_ZOOM } |
enum | state_master { STATE_IDLE, STATE_SOURCE1, STATE_SOURCE2, STATE_FILTER, STATE_INPUT, STATE_OUTPUT } |
Functions | |
void | init_sys_clocks (void) |
Initializes the MCU system clocks. | |
int | main (void) |
static Bool | state_machine_filter (enum state_function *state) |
static Bool | state_machine_idle (enum state_function *state) |
static Bool | state_machine_signal (enum state_master id, enum state_function *state) |
static Bool | state_machine_source (int source_id, enum state_function *state) |
static void | state_machine_task (void) |
static void | switch_state (enum state_master state) |
static void | twi_init (void) |
Variables | |
volatile Bool | input_fft_view = FALSE |
static Bool | new_state_fct = FALSE |
volatile Bool | output_fft_view = FALSE |
static enum state_master | state = STATE_IDLE |
static enum state_function | state_fct = STATE_FCT_IDLE |
volatile Bool | zoom_view = FALSE |
volatile int | zoom_view_id |
#define TEXT_FILTER "Filters\nFUNC 1 - 3:\n Select filter" |
#define TEXT_FUNC1 "FUNC1" |
Definition at line 76 of file demo.c.
Referenced by state_machine_idle(), state_machine_signal(), and state_machine_source().
#define TEXT_FUNC2 "FUNC2" |
Definition at line 77 of file demo.c.
Referenced by state_machine_idle(), and state_machine_source().
#define TEXT_FUNC_NOT_IMPLEMENTED "Function not\nimplemented" |
Definition at line 92 of file demo.c.
Referenced by state_machine_idle(), and state_machine_signal().
#define TEXT_IDLE "FUNC1 - Frame/s\nFUNC2 - Volume\nWHEEL - Select box" |
#define TEXT_INPUT "Input signal\nFUNC1 - Time/FFT\nFUNC3 - Zoom" |
#define TEXT_OUTPUT "Output signal\nFUNC1 - Time/FFT\nFUNC3 - Zoom" |
#define TEXT_SOURCE1 "Source1\nFUNC1 - Amplitude\nFUNC2 - Frequency\nFUNC3 - Zoom" |
#define TEXT_SOURCE2 "Source2\nFUNC1 - Amplitude\nFUNC2 - Frequency\nFUNC3 - Zoom" |
#define TEXT_WHEEL "(Use the WHEEL)" |
Definition at line 75 of file demo.c.
Referenced by state_machine_idle(), and state_machine_source().
enum state_function |
STATE_FCT_IDLE | |
STATE_FCT_FUNCTION1 | |
STATE_FCT_FUNCTION2 | |
STATE_FCT_FUNCTION3 | |
STATE_FCT_ZOOM |
Definition at line 191 of file demo.c.
00192 { 00193 STATE_FCT_IDLE, 00194 STATE_FCT_FUNCTION1, 00195 STATE_FCT_FUNCTION2, 00196 STATE_FCT_FUNCTION3, 00197 STATE_FCT_ZOOM 00198 };
enum state_master |
Definition at line 181 of file demo.c.
00182 { 00183 STATE_IDLE, 00184 STATE_SOURCE1, 00185 STATE_SOURCE2, 00186 STATE_FILTER, 00187 STATE_INPUT, 00188 STATE_OUTPUT 00189 };
void init_sys_clocks | ( | void | ) |
Initializes the MCU system clocks.
Definition at line 120 of file demo.c.
Referenced by main().
00121 { 00122 // Switch to OSC0 to speed up the booting 00123 pm_switch_to_osc0(&AVR32_PM, FOSC0, OSC0_STARTUP); 00124 00125 // Start oscillator1 00126 pm_enable_osc1_crystal(&AVR32_PM, FOSC1); 00127 pm_enable_clk1(&AVR32_PM, OSC1_STARTUP); 00128 00129 // Set PLL0 (fed from OSC0 = 12 MHz) to 132 MHz 00130 // We use OSC1 since we need a correct master clock for the SSC module to generate 00131 // the correct sample rate 00132 pm_pll_setup(&AVR32_PM, 0, // pll. 00133 10, // mul. 00134 1, // div. 00135 0, // osc. 00136 16); // lockcount. 00137 00138 // Set PLL operating range and divider (fpll = fvco/2) 00139 // -> PLL0 output = 66 MHz 00140 pm_pll_set_option(&AVR32_PM, 0, // pll. 00141 1, // pll_freq. 00142 1, // pll_div2. 00143 0); // pll_wbwdisable. 00144 00145 // start PLL0 and wait for the lock 00146 pm_pll_enable(&AVR32_PM, 0); 00147 pm_wait_for_pll0_locked(&AVR32_PM); 00148 // Set all peripheral clocks torun at master clock rate 00149 00150 // Set one waitstate for the flash 00151 flashc_set_wait_state(1); 00152 00153 // Switch to PLL0 as the master clock 00154 pm_switch_to_clock(&AVR32_PM, AVR32_PM_MCCTRL_MCSEL_PLL0); 00155 00156 // Use 12MHz from OSC0 and generate 96 MHz 00157 pm_pll_setup(&AVR32_PM, 1, // pll. 00158 7, // mul. 00159 1, // div. 00160 0, // osc. 00161 16); // lockcount. 00162 00163 pm_pll_set_option(&AVR32_PM, 1, // pll. 00164 1, // pll_freq: choose the range 80-180MHz. 00165 1, // pll_div2. 00166 0); // pll_wbwdisable. 00167 00168 // start PLL1 and wait forl lock 00169 pm_pll_enable(&AVR32_PM, 1); 00170 00171 // Wait for PLL1 locked. 00172 pm_wait_for_pll1_locked(&AVR32_PM); 00173 00174 }
int main | ( | void | ) |
Definition at line 636 of file demo.c.
References controller_init(), controller_task(), dsp_process_init(), dsp_process_task(), FCPU_HZ, FHSB_HZ, filter_active_get_description(), FPBA_HZ, FPBB_HZ, GUI_COMMENT_ID, GUI_FILTER_ID, gui_init(), gui_task(), gui_text_print(), init_sys_clocks(), state_machine_task(), TEXT_IDLE, and twi_init().
00637 { 00638 init_sys_clocks(); 00639 00640 init_dbg_rs232(FPBA_HZ); 00641 00642 print_dbg("AVR UC3 DSP DEMO\n"); 00643 00644 INTC_init_interrupts(); 00645 Disable_global_interrupt(); 00646 00647 // GUI, Controller and DSP process init 00648 gui_init(FCPU_HZ, FHSB_HZ, FPBA_HZ, FPBB_HZ); 00649 gui_text_print(GUI_COMMENT_ID, TEXT_IDLE); 00650 gui_text_print(GUI_FILTER_ID, filter_active_get_description()); 00651 controller_init(FCPU_HZ, FHSB_HZ, FPBA_HZ, FPBB_HZ); 00652 twi_init(); 00653 dsp_process_init(FCPU_HZ, FHSB_HZ, FPBA_HZ, FPBB_HZ); 00654 00655 Enable_global_interrupt(); 00656 00657 // Main loop 00658 while (1) 00659 { 00660 gui_task(); 00661 controller_task(); 00662 dsp_process_task(); 00663 state_machine_task(); 00664 } 00665 }
static Bool state_machine_filter | ( | enum state_function * | state | ) | [static] |
Definition at line 399 of file demo.c.
References controller_reset(), controller_wheel_left(), controller_wheel_right(), FALSE, filter_active_get_description(), filter_set_active(), GUI_COMMENT_ID, GUI_FILTER_ID, gui_set_selection(), gui_text_print(), new_state_fct, STATE_FCT_FUNCTION1, STATE_FCT_FUNCTION2, STATE_FCT_FUNCTION3, STATE_FCT_IDLE, STATE_FCT_ZOOM, STATE_INPUT, STATE_OUTPUT, switch_state(), TEXT_FILTER, and TRUE.
Referenced by state_machine_task().
00400 { 00401 switch (*state) 00402 { 00403 case STATE_FCT_IDLE: 00404 if (new_state_fct) 00405 { 00406 gui_set_selection(GUI_FILTER_ID); 00407 gui_text_print(GUI_COMMENT_ID, TEXT_FILTER); 00408 } 00409 else 00410 { 00411 if (controller_wheel_right(2)) 00412 switch_state(STATE_OUTPUT); 00413 else if (controller_wheel_left(2)) 00414 switch_state(STATE_INPUT); 00415 return FALSE; 00416 } 00417 break; 00418 // FFT 00419 case STATE_FCT_FUNCTION1: 00420 if (new_state_fct) 00421 filter_set_active(0); 00422 break; 00423 case STATE_FCT_FUNCTION2: 00424 if (new_state_fct) 00425 filter_set_active(1); 00426 break; 00427 case STATE_FCT_FUNCTION3: 00428 if (new_state_fct) 00429 filter_set_active(2); 00430 break; 00431 case STATE_FCT_ZOOM: 00432 break; 00433 } 00434 00435 if (new_state_fct) 00436 gui_text_print(GUI_FILTER_ID, filter_active_get_description()); 00437 00438 if (controller_wheel_right(0) || controller_wheel_left(0)) 00439 { 00440 *state = STATE_FCT_IDLE; 00441 controller_reset(); 00442 } 00443 00444 return TRUE; 00445 }
static Bool state_machine_idle | ( | enum state_function * | state | ) | [static] |
Definition at line 447 of file demo.c.
References controller_wheel_left(), controller_wheel_right(), FALSE, gui_change_update_fs(), GUI_COMMENT_ID, gui_get_update_fs(), GUI_NO_SEL, gui_set_selection(), gui_text_print(), gui_text_printf, new_state_fct, STATE_FCT_FUNCTION1, STATE_FCT_FUNCTION2, STATE_FCT_FUNCTION3, STATE_FCT_IDLE, STATE_FCT_ZOOM, STATE_SOURCE1, switch_state(), TEXT_FUNC1, TEXT_FUNC2, TEXT_FUNC_NOT_IMPLEMENTED, TEXT_IDLE, TEXT_WHEEL, TRUE, and signal_source::volume.
Referenced by state_machine_task().
00448 { 00449 uint32_t frame_rate_ms; 00450 S8 volume; 00451 const S8 volume_inc = (TPA6130_VOL_MAX - TPA6130_VOL_MIN) / 20; 00452 00453 switch (*state) 00454 { 00455 case STATE_FCT_IDLE: 00456 if (new_state_fct) 00457 { 00458 gui_set_selection(GUI_NO_SEL); 00459 gui_text_print(GUI_COMMENT_ID, TEXT_IDLE); 00460 } 00461 else 00462 { 00463 if (controller_wheel_right(1) || controller_wheel_left(1)) 00464 switch_state(STATE_SOURCE1); 00465 return FALSE; 00466 } 00467 break; 00468 // Frame rate 00469 case STATE_FCT_FUNCTION1: 00470 frame_rate_ms = gui_get_update_fs(); 00471 if (controller_wheel_left(1) && frame_rate_ms < 1000) 00472 { 00473 if (!frame_rate_ms) 00474 frame_rate_ms = 40; 00475 else 00476 frame_rate_ms = 1000 / ((1000 / frame_rate_ms) - 1); 00477 new_state_fct = TRUE; 00478 } 00479 else if (controller_wheel_right(1)) 00480 { 00481 if (frame_rate_ms <= 40) 00482 frame_rate_ms = 0; 00483 else 00484 frame_rate_ms = 1000 / ((1000 / frame_rate_ms) + 1); 00485 new_state_fct = TRUE; 00486 } 00487 if (new_state_fct) 00488 { 00489 gui_change_update_fs(frame_rate_ms); 00490 if (frame_rate_ms) 00491 { 00492 gui_text_printf(GUI_COMMENT_ID, TEXT_FUNC1 "\n%i Frame(s)/s\n\n\n\n" TEXT_WHEEL, (1000 / frame_rate_ms)); 00493 } 00494 else 00495 gui_text_print(GUI_COMMENT_ID, TEXT_FUNC1 "\nMAX Frame(s)/s\n\n\n\n" TEXT_WHEEL); 00496 } 00497 break; 00498 // Volume 00499 case STATE_FCT_FUNCTION2: 00500 volume = tpa6130_get_volume(); 00501 if (volume < TPA6130_VOL_MIN) 00502 volume = TPA6130_VOL_MIN; 00503 if (controller_wheel_right(1)) 00504 { 00505 if (volume < TPA6130_VOL_MAX - volume_inc) 00506 volume += volume_inc; 00507 else 00508 volume = TPA6130_VOL_MAX; 00509 new_state_fct = TRUE; 00510 } 00511 else if (controller_wheel_left(1)) 00512 { 00513 if (volume > TPA6130_VOL_MIN + volume_inc) 00514 volume -= volume_inc; 00515 else 00516 volume = TPA6130_VOL_MIN; 00517 new_state_fct = TRUE; 00518 } 00519 if (new_state_fct) 00520 { 00521 tpa6130_set_volume(volume); 00522 gui_text_printf(GUI_COMMENT_ID, TEXT_FUNC2 "\nVolume %i%%\n\n\n\n" TEXT_WHEEL, ((int) volume * 100) / (TPA6130_VOL_MAX - TPA6130_VOL_MIN)); 00523 } 00524 break; 00525 /* 00526 extern U8 tpa6130_get_volume(void); 00527 extern void tpa6130_set_volume(U8 volume); 00528 */ 00529 case STATE_FCT_FUNCTION3: 00530 if (new_state_fct) 00531 gui_text_print(GUI_COMMENT_ID, TEXT_FUNC_NOT_IMPLEMENTED); 00532 else if (controller_wheel_right(1) || controller_wheel_left(1)) { 00533 switch_state(STATE_SOURCE1); 00534 return FALSE; 00535 } 00536 break; 00537 case STATE_FCT_ZOOM: 00538 break; 00539 } 00540 return TRUE; 00541 }
static Bool state_machine_signal | ( | enum state_master | id, | |
enum state_function * | state | |||
) | [static] |
Definition at line 313 of file demo.c.
References controller_reset(), controller_wheel_left(), controller_wheel_right(), FALSE, GUI_COMMENT_ID, GUI_INPUT_ID, GUI_OUTPUT_ID, gui_set_selection(), gui_text_print(), input_fft_view, new_state_fct, output_fft_view, STATE_FCT_FUNCTION1, STATE_FCT_FUNCTION2, STATE_FCT_FUNCTION3, STATE_FCT_IDLE, STATE_FCT_ZOOM, STATE_FILTER, STATE_INPUT, STATE_OUTPUT, STATE_SOURCE2, switch_state(), TEXT_FUNC1, TEXT_FUNC_NOT_IMPLEMENTED, TEXT_INPUT, TEXT_OUTPUT, TRUE, zoom_view, and zoom_view_id.
Referenced by state_machine_task().
00314 { 00315 switch (*state) 00316 { 00317 case STATE_FCT_IDLE: 00318 if (id == STATE_INPUT) 00319 { 00320 if (new_state_fct) 00321 { 00322 gui_set_selection(GUI_INPUT_ID); 00323 gui_text_print(GUI_COMMENT_ID, TEXT_INPUT); 00324 } 00325 else 00326 { 00327 if (controller_wheel_right(2)) 00328 switch_state(STATE_FILTER); 00329 else if (controller_wheel_left(2)) 00330 switch_state(STATE_SOURCE2); 00331 return FALSE; 00332 } 00333 } 00334 else if (id == STATE_OUTPUT) 00335 { 00336 if (new_state_fct) 00337 { 00338 gui_set_selection(GUI_OUTPUT_ID); 00339 gui_text_print(GUI_COMMENT_ID, TEXT_OUTPUT); 00340 } 00341 else 00342 { 00343 if (controller_wheel_left(2)) 00344 switch_state(STATE_FILTER); 00345 return FALSE; 00346 } 00347 } 00348 break; 00349 // FFT 00350 case STATE_FCT_FUNCTION1: 00351 if (new_state_fct) 00352 { 00353 if (id == STATE_INPUT) 00354 { 00355 input_fft_view = !input_fft_view; 00356 if (input_fft_view) 00357 gui_text_print(GUI_COMMENT_ID, "Input - " TEXT_FUNC1 "\nFrequency domain\n\n\n\n(Use " TEXT_FUNC1 ")"); 00358 else 00359 gui_text_print(GUI_COMMENT_ID, "Input - " TEXT_FUNC1 "\nTemporal domain\n\n\n\n(Use " TEXT_FUNC1 ")"); 00360 } 00361 else if (id == STATE_OUTPUT) 00362 { 00363 output_fft_view = !output_fft_view; 00364 if (output_fft_view) 00365 gui_text_print(GUI_COMMENT_ID, "Output - " TEXT_FUNC1 "\nFrequency domain\n\n\n\n(Use " TEXT_FUNC1 ")"); 00366 else 00367 gui_text_print(GUI_COMMENT_ID, "Output - " TEXT_FUNC1 "\nTemporal domain\n\n\n\n(Use " TEXT_FUNC1 ")"); 00368 } 00369 } 00370 break; 00371 case STATE_FCT_FUNCTION2: 00372 case STATE_FCT_FUNCTION3: 00373 if (new_state_fct) 00374 gui_text_print(GUI_COMMENT_ID, TEXT_FUNC_NOT_IMPLEMENTED); 00375 break; 00376 // Zoom 00377 case STATE_FCT_ZOOM: 00378 if (new_state_fct) 00379 { 00380 zoom_view = TRUE; 00381 if (id == STATE_INPUT) 00382 zoom_view_id = GUI_INPUT_ID; 00383 else if (id == STATE_OUTPUT) 00384 zoom_view_id = GUI_OUTPUT_ID; 00385 // controller_reset(); 00386 } 00387 break; 00388 } 00389 00390 if (controller_wheel_right(0) || controller_wheel_left(0)) 00391 { 00392 *state = STATE_FCT_IDLE; 00393 controller_reset(); 00394 } 00395 00396 return TRUE; 00397 }
static Bool state_machine_source | ( | int | source_id, | |
enum state_function * | state | |||
) | [static] |
Definition at line 206 of file demo.c.
References controller_reset(), controller_wheel_left(), controller_wheel_right(), DSP16_Q, FALSE, GUI_COMMENT_ID, gui_set_selection(), GUI_SOURCE1_ID, GUI_SOURCE2_ID, gui_text_print(), gui_text_printf, new_state_fct, signal1_generator, signal2_generator, signal_source_get_freq(), signal_source_get_volume(), signal_source_set_freq(), signal_source_set_volume(), STATE_FCT_FUNCTION1, STATE_FCT_FUNCTION2, STATE_FCT_FUNCTION3, STATE_FCT_IDLE, STATE_FCT_ZOOM, STATE_INPUT, STATE_SOURCE1, STATE_SOURCE2, switch_state(), TEXT_FUNC1, TEXT_FUNC2, TEXT_SOURCE1, TEXT_SOURCE2, TEXT_WHEEL, TRUE, zoom_view, and zoom_view_id.
Referenced by state_machine_task().
00207 { 00208 static dsp16_t volume; 00209 static unsigned int frequency; 00210 struct signal_source *source = NULL; 00211 00212 if (source_id == 1) 00213 source = &signal1_generator; 00214 else if (source_id == 2) 00215 source = &signal2_generator; 00216 00217 switch (*state) 00218 { 00219 case STATE_FCT_IDLE: 00220 if (source_id == 1) 00221 { 00222 if (new_state_fct) 00223 { 00224 gui_set_selection(GUI_SOURCE1_ID); 00225 gui_text_print(GUI_COMMENT_ID, TEXT_SOURCE1); 00226 } 00227 else 00228 { 00229 if (controller_wheel_right(2)) 00230 switch_state(STATE_SOURCE2); 00231 return FALSE; 00232 } 00233 } 00234 else if (source_id == 2) 00235 { 00236 if (new_state_fct) 00237 { 00238 gui_set_selection(GUI_SOURCE2_ID); 00239 gui_text_print(GUI_COMMENT_ID, TEXT_SOURCE2); 00240 } 00241 else 00242 { 00243 if (controller_wheel_left(2)) 00244 switch_state(STATE_SOURCE1); 00245 else if (controller_wheel_right(2)) 00246 switch_state(STATE_INPUT); 00247 return FALSE; 00248 } 00249 } 00250 break; 00251 // Amplitude 00252 case STATE_FCT_FUNCTION1: 00253 volume = signal_source_get_volume(source); 00254 if (controller_wheel_right(1) && volume < DSP16_Q(1.)) 00255 { 00256 if (volume < DSP16_Q(1.) - DSP16_Q(1./16)) 00257 volume += DSP16_Q(1./16); 00258 else 00259 volume = DSP16_Q(1.); 00260 new_state_fct = TRUE; 00261 } 00262 else if (controller_wheel_left(1)) 00263 { 00264 if (volume > DSP16_Q(1./16)) 00265 volume -= DSP16_Q(1./16); 00266 else 00267 volume = 0; 00268 new_state_fct = TRUE; 00269 } 00270 if (new_state_fct) 00271 { 00272 signal_source_set_volume(source, volume); 00273 gui_text_printf(GUI_COMMENT_ID, "Source%i - " TEXT_FUNC1 "\nAmplitude %f\n\n\n\n" TEXT_WHEEL, source_id, volume); 00274 } 00275 break; 00276 // Frequency 00277 case STATE_FCT_FUNCTION2: 00278 frequency = signal_source_get_freq(source); 00279 if (controller_wheel_right(1) && frequency < 10000) 00280 { 00281 frequency *= 1.1; 00282 new_state_fct = TRUE; 00283 } 00284 else if (controller_wheel_left(1) && frequency > 100) 00285 { 00286 frequency *= 0.9; 00287 new_state_fct = TRUE; 00288 } 00289 if (new_state_fct) 00290 { 00291 signal_source_set_freq(source, frequency); 00292 gui_text_printf(GUI_COMMENT_ID, "Source%i - " TEXT_FUNC2 "\nFrequency %iHz\n\n\n\n" TEXT_WHEEL, source_id, frequency); 00293 } 00294 break; 00295 case STATE_FCT_FUNCTION3: 00296 break; 00297 // Zoom 00298 case STATE_FCT_ZOOM: 00299 if (new_state_fct) 00300 { 00301 zoom_view = TRUE; 00302 if (source_id == 1) 00303 zoom_view_id = GUI_SOURCE1_ID; 00304 else if (source_id == 2) 00305 zoom_view_id = GUI_SOURCE2_ID; 00306 controller_reset(); 00307 } 00308 break; 00309 } 00310 return TRUE; 00311 }
static void state_machine_task | ( | void | ) | [static] |
Definition at line 550 of file demo.c.
References controller_key_back(), controller_key_fct1(), controller_key_fct2(), controller_key_fct3(), controller_key_fct3_pressed(), controller_key_reset(), controller_reset(), FALSE, filter_active_get_description(), gui_clear_view(), GUI_FILTER_ID, gui_text_print(), new_state_fct, state, state_fct, STATE_FCT_FUNCTION1, STATE_FCT_FUNCTION2, STATE_FCT_FUNCTION3, STATE_FCT_IDLE, STATE_FCT_ZOOM, STATE_FILTER, STATE_IDLE, STATE_INPUT, state_machine_filter(), state_machine_idle(), state_machine_signal(), state_machine_source(), STATE_OUTPUT, STATE_SOURCE1, STATE_SOURCE2, TRUE, and zoom_view.
Referenced by main().
00551 { 00552 Bool is_reset; 00553 00554 00555 // Set function state 00556 if (controller_key_fct3_pressed()) 00557 { 00558 state_fct = STATE_FCT_ZOOM; 00559 new_state_fct = TRUE; 00560 } 00561 else if (controller_key_fct1()) 00562 { 00563 state_fct = STATE_FCT_FUNCTION1; 00564 new_state_fct = TRUE; 00565 } 00566 else if (controller_key_fct2()) 00567 { 00568 state_fct = STATE_FCT_FUNCTION2; 00569 new_state_fct = TRUE; 00570 } 00571 else if (controller_key_fct3()) 00572 { 00573 state_fct = STATE_FCT_FUNCTION3; 00574 new_state_fct = TRUE; 00575 } 00576 00577 // Clear Zoom state if on and a key is pressed 00578 if (zoom_view && !controller_key_fct3_pressed()) 00579 { 00580 zoom_view = FALSE; 00581 gui_clear_view(); 00582 gui_text_print(GUI_FILTER_ID, filter_active_get_description()); 00583 new_state_fct = TRUE; 00584 state_fct = STATE_FCT_IDLE; 00585 controller_key_reset(); 00586 } 00587 00588 // Reset or back modes 00589 is_reset = controller_key_reset(); 00590 if ((controller_key_back() && !zoom_view) || is_reset) 00591 { 00592 if (is_reset) 00593 { 00594 // SW resetof the application 00595 Reset_CPU(); 00596 while(1); 00597 } 00598 if (state_fct == STATE_FCT_IDLE) 00599 state = STATE_IDLE; 00600 state_fct = STATE_FCT_IDLE; 00601 // Reset the controller (delete saved key states) 00602 controller_reset(); 00603 new_state_fct = TRUE; 00604 } 00605 00606 switch (state) 00607 { 00608 case STATE_IDLE: 00609 if (!state_machine_idle(&state_fct)) 00610 return; 00611 break; 00612 case STATE_SOURCE1: 00613 if (!state_machine_source(1, &state_fct)) 00614 return; 00615 break; 00616 case STATE_SOURCE2: 00617 if (!state_machine_source(2, &state_fct)) 00618 return; 00619 break; 00620 case STATE_INPUT: 00621 if (!state_machine_signal(STATE_INPUT, &state_fct)) 00622 return; 00623 break; 00624 case STATE_FILTER: 00625 if (!state_machine_filter(&state_fct)) 00626 return; 00627 break; 00628 case STATE_OUTPUT: 00629 if (!state_machine_signal(STATE_OUTPUT, &state_fct)) 00630 return; 00631 break; 00632 } 00633 new_state_fct = FALSE; 00634 }
static void switch_state | ( | enum state_master | state | ) | [static] |
Definition at line 543 of file demo.c.
References new_state_fct, state, state_fct, STATE_FCT_IDLE, and TRUE.
Referenced by state_machine_filter(), state_machine_idle(), state_machine_signal(), and state_machine_source().
00544 { 00545 state = new_state; 00546 state_fct = STATE_FCT_IDLE; 00547 new_state_fct = TRUE; 00548 }
static void twi_init | ( | void | ) | [static] |
Definition at line 94 of file demo.c.
References FPBA_HZ, and TPA6130_TWI_MASTER_SPEED.
Referenced by main().
00095 { 00096 const gpio_map_t TPA6130_TWI_GPIO_MAP = 00097 { 00098 {TPA6130_TWI_SCL_PIN, TPA6130_TWI_SCL_FUNCTION}, 00099 {TPA6130_TWI_SDA_PIN, TPA6130_TWI_SDA_FUNCTION} 00100 }; 00101 00102 const twi_options_t TPA6130_TWI_OPTIONS = 00103 { 00104 .pba_hz = FPBA_HZ, 00105 .speed = TPA6130_TWI_MASTER_SPEED, 00106 .chip = TPA6130_TWI_ADDRESS 00107 }; 00108 00109 // Assign I/Os to TWI 00110 gpio_enable_module(TPA6130_TWI_GPIO_MAP, 00111 sizeof(TPA6130_TWI_GPIO_MAP) / sizeof(TPA6130_TWI_GPIO_MAP[0])); 00112 00113 // Initialize as master. 00114 twi_master_init(TPA6130_TWI, &TPA6130_TWI_OPTIONS); 00115 00116 }
volatile Bool input_fft_view = FALSE |
Bool new_state_fct = FALSE [static] |
Definition at line 204 of file demo.c.
Referenced by state_machine_filter(), state_machine_idle(), state_machine_signal(), state_machine_source(), state_machine_task(), and switch_state().
volatile Bool output_fft_view = FALSE |
enum state_master state = STATE_IDLE [static] |
enum state_function state_fct = STATE_FCT_IDLE [static] |
volatile Bool zoom_view = FALSE |
Definition at line 178 of file demo.c.
Referenced by gui_print_fft_box(), gui_print_signal_box(), gui_text_print(), state_machine_signal(), state_machine_source(), and state_machine_task().
volatile int zoom_view_id |
Definition at line 179 of file demo.c.
Referenced by gui_print_fft_box(), gui_print_signal_box(), state_machine_signal(), and state_machine_source().