/*! \file main.hcc * * \section generic Message build up information and more * * \section project Project information. * Project Graphic Equalizer\n * \author O.M. Schinagl * \date 20041011 * \version 0.1 * * \section copyright Copyright * Copyright ©2004 Koninklijke Philips Electronics N.V. All rights reserved * * \section history Change history * 20041011: O.M. Schinagl\n Initial version * *****************************************************************************/ /* * Set the Clock rate for this domain. 25.175 Mhz is required for the Video output. */ #define PAL_TARGET_CLOCK_RATE 25175000 /******** System Includes *************/ #include "pal_master.hch" /******** Application Includes ********/ #include "configuration.hch" #include "audio.hch" #include "mouse_shared.hch" #include "eventhandler_shared.hch" #include "display_shared.hch" #include "mouse.hch" #include "eventhandler.hch" #include "display.hch" #include "smartmedia.hch" #include "fft.hch" #if HAVE_DEBUG #include "debug.hch" #endif /*! \fn void main(void); * \brief Main Application Loop. * * \return void * \retval void */ void main(void) { /* * Set VideoOut, Audio I/O and Ram Handles and set clockrate. */ macro expr ClockRate = PAL_ACTUAL_CLOCK_RATE; macro expr VideoOut = PalVideoOutOptimalCT(ClockRate); macro expr AudioIn = PalAudioInCT(0); macro expr AudioOut = PalAudioOutCT(0); macro expr RAM_BANK0 = PalPL2RAMCT(0); mousedata_t mousedata; events_t events; audiodata_t audiodata; skindata_t skindata; unsigned AUDIOINITWIDTH audioinitdelay; unsigned 1 result; audioinitdelay = AUDIOINITDELAY; while (audioinitdelay) { audioinitdelay--; } /* * Check library versions and Request various hardware functionality. * We need at least Major Version 1. For Audio purposes we need atleast * minor version 2. */ PalVersionRequire(1, 2); PalVideoOutRequire(1); PalAudioInRequire(1); PalAudioOutRequire(1); PalPL2RAMRequire(1); /* * We verify some datawidths here at compile time. This to ensure * successfull operation. */ assert (PalVideoOutGetColorWidthCT(VideoOut) == 24, 0, "We need a 24-bit color Display."); assert (PalPL2RAMGetDataWidthCT(RAM_BANK0) >= 32, 0, "We can't work with anything less then 32 bits wide ram."); /* * Run The Following main tasks in parallel. */ par { /* * Primary task is to 'Run' several hardware simultaniously. */ PalVideoOutRun(VideoOut, ClockRate); MouseRun(ClockRate); PalAudioInRun(AudioIn, ClockRate); PalAudioOutRun(AudioOut, ClockRate); PalPL2RAMRun(RAM_BANK0, ClockRate); /* * The smartmedia device needs the CPLD to run also. */ CPLDRun(ClockRate); SmartMediaRun(ClockRate); #if HAVE_DEBUG RC200RS232Run(RC200RS232_115200Baud, RC200RS232ParityNone, RC200RS232FlowControlNone, ClockRate); #endif /* * Parallel to our Primary tasks we run the application. */ seq { /* * But first we need to initialize Video and Audio. * We also load the data from the SmartMedia card * into the ram. */ #if HAVE_DEBUG print_eol(); print_string("Graphic Equalizer 2"); print_eol(); #endif PalVideoOutEnable(VideoOut); PalAudioInEnable(AudioIn); PalAudioOutEnable(AudioOut); audio_init(LINE_IN, SR_44100, AudioIn, AudioOut); /* * Once we properly setup the SmartMedia we load our * data folowed by our main program loop. */ result = smartmedia_init(); if (!result) { smartmedia_loaddata(&skindata); /* * Main application starts here! */ par { /* * From here we run the mouse driver, audio * and display in parallel. None of these * should ever return. */ mouse_main(&mousedata); display_main(&skindata, &audiodata, &events, &mousedata); eventhandler_main(&audiodata, &events, &mousedata, &skindata); audio_main(audiodata, AudioIn, AudioOut); } } else { #if HAVE_DEBUG print_string("Error Initializing SmartMedia"); #endif } } } } /* --- main() --- */