summaryrefslogtreecommitdiffstats
path: root/Graphic_Equalizer/src
diff options
context:
space:
mode:
authorOliver Schinagl <oliver@schinagl.nl>2004-11-10 12:45:18 (GMT)
committerOliver Schinagl <oliver@schinagl.nl>2004-11-10 12:45:18 (GMT)
commit9451e82004bb59a95d9589058759169c1c486c91 (patch)
tree991c9238e4290ed097f0d02494dc80c0f10c68f1 /Graphic_Equalizer/src
parentb7b9f1ff4da4dae9d4c14ee5e03a7555b254c31c (diff)
downloadTASS-9451e82004bb59a95d9589058759169c1c486c91.zip
TASS-9451e82004bb59a95d9589058759169c1c486c91.tar.gz
TASS-9451e82004bb59a95d9589058759169c1c486c91.tar.bz2
First Real Version
Diffstat (limited to 'Graphic_Equalizer/src')
-rw-r--r--Graphic_Equalizer/src/audiodriver.hcc (renamed from Graphic_Equalizer/src/audio/audiodriver.hcc)15
-rw-r--r--Graphic_Equalizer/src/display.hcc140
-rw-r--r--Graphic_Equalizer/src/display/display.hcc109
-rw-r--r--Graphic_Equalizer/src/display/main.hcc87
-rw-r--r--Graphic_Equalizer/src/eventhandler.hcc71
-rw-r--r--Graphic_Equalizer/src/main.hcc164
-rw-r--r--Graphic_Equalizer/src/mouse.hcc (renamed from Graphic_Equalizer/src/display/mousedriver.hcc)21
-rw-r--r--Graphic_Equalizer/src/sample.hcc (renamed from Graphic_Equalizer/src/audio/sample.hcc)0
-rw-r--r--Graphic_Equalizer/src/smartmedia.hcc166
9 files changed, 561 insertions, 212 deletions
diff --git a/Graphic_Equalizer/src/audio/audiodriver.hcc b/Graphic_Equalizer/src/audiodriver.hcc
index aadcc6e..c7d1adf 100644
--- a/Graphic_Equalizer/src/audio/audiodriver.hcc
+++ b/Graphic_Equalizer/src/audiodriver.hcc
@@ -22,8 +22,8 @@
#include "pal_master.hch"
/******** Application Includes ********/
-#include "audiodriver.hch"
-#include "audiodriver_shared.hch"
+#include "audio.hch"
+#include "audio_shared.hch"
@@ -79,6 +79,7 @@ void audio_main(void) {
*/
macro expr AudioIn = PalAudioInCT(0);
macro expr AudioOut = PalAudioOutCT(0);
+
/*
* Determin the data width for the current platform.
*/
@@ -86,21 +87,21 @@ void audio_main(void) {
macro expr OW = PalAudioOutGetMaxDataWidthCT();
signed IW sample_left_in, sample_right_in;
- signed 16 sample_left_out, sample_right_out;
+ signed OW sample_left_out, sample_right_out;
for (;;) {
PalAudioRead(AudioIn, &sample_left_in, &sample_right_in);
- par {
+/* par {
sample_add(sample_left_in);
sample_get(&sample_left_out);
sample_right_out = sample_right_in;
}
if (rotate_samples()) {
- /*
+ / *
* 64 Samples have been processed, calculate.
- */
+ * /
}
- PalAudioWrite(AudioOut, (signed OW)(sample_left @ 0), (signed OW)(sample_right @ 0));
+*/ PalAudioWrite(AudioOut, (signed OW)(sample_left_in @ 0), (signed OW)(sample_right_in @ 0));
}
} /* --- audio_main() --- */
diff --git a/Graphic_Equalizer/src/display.hcc b/Graphic_Equalizer/src/display.hcc
new file mode 100644
index 0000000..8be1f2e
--- /dev/null
+++ b/Graphic_Equalizer/src/display.hcc
@@ -0,0 +1,140 @@
+/*! \file display.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
+ *
+ ********************************************************************/
+
+/******** System Includes *************/
+#include <stdlib.hch>
+
+#include "pal_master.hch"
+
+/******** Application Includes ********/
+#include "configuration.hch"
+#include "display.hch"
+#include "eventhandler_shared.hch"
+
+
+
+/*! \fn void display_main(events_t *events, mousedata_t *mousedata);
+ * \brief This routine handles all drawing of pixels. It never returns!
+ *
+ * \param events_t *events pointer to struct with all events.
+ * \param mousedata_t *mousedata pointer to struct with coordinates to
+ * current X en Y.
+ *
+ * \return Never Returns.
+ * \retval void
+ */
+void display_main(events_t *events, mousedata_t *mousedata) {
+ /*
+ * Setup macro's RAM/Video handles and to coordinate pixel writing.
+ */
+ macro expr RAM_BANK0 = PalPL2RAMCT(0);
+ macro expr VideoOut = PalVideoOutOptimalCT(ClockRate);
+ macro expr VisibleX = PalVideoOutGetVisibleX (VideoOut, ClockRate);
+ macro expr TotalX = PalVideoOutGetTotalX (VideoOut, ClockRate);
+ macro expr TotalY = PalVideoOutGetTotalY (VideoOut);
+ macro expr X = PalVideoOutGetX (VideoOut);
+ macro expr Y = PalVideoOutGetY (VideoOut);
+
+ unsigned AW address;
+ unsigned DW pixeldata;
+
+/*
+ * To draw something usefull when only drawing our mask, we simply draw the
+ * mask itself. Thus creating a blueish image to help identify all interesting
+ * area's on the screen. Otherwise we only use the last 24 bits, the RGB values
+ * to draw on the screen.
+ */
+#if USE_MASK_ONLY
+#define PIXEL (0 @ pixeldata[31:24])
+#else
+#define PIXEL (pixeldata <- 24)
+#endif
+ /*
+ * Prime Rendering Pipeline to start where the skin starts.
+ */
+ PalPL2RAMSetReadAddress(RAM_BANK0, ADDRESS_SKIN_START);
+
+ /*
+ * Run the following tasks indefinatly and in parallel
+ */
+ par (;;) {
+ /*
+ * Before starting this loop we allready set the the address.
+ * Therefor we can start reading the previously set address and
+ * prepare the next address for the next cycle.
+ */
+ PalPL2RAMRead(RAM_BANK0, &pixeldata);
+ PalPL2RAMSetReadAddress(RAM_BANK0, address);
+
+ switch (pixeldata[31:24]) {
+ case (AREA_VOLUME_YAXIS == pixeldata[31:24]):
+ if (ScanY <= events->volume_position) {
+ PalVideoOutWrite(VideoOut, PIXEL_VOLUME_YAXIS);
+ } else {
+ PalVideoOutWrite(VideoOut, PIXEL);
+ }
+ break;
+ default:
+ PalVideoOutWrite(VideoOut, PIXEL);
+ break;
+ }
+
+ /*
+ */
+ if ((ScanX == mousedata->x) && (ScanY == mousedata->y)) {
+ events->mask = pixeldata[31:24];
+ }
+
+ /*
+ * The current position of the screen can lay in an area called
+ * the blanking area. We don't have data for this area as it is
+ * not drawn. We therefor have to determin wether we are beyond
+ * the visible area of the screen, but before the end of the
+ * total width of the screen.
+ * Our pipeline consists of 4 total stages. Therefor we have to
+ * substract 4 pixels.
+ */
+ if ((X > (VisibleX - 4)) && (X <= (TotalX - 4))) {
+ /*
+ * We are in the blanking area of the screen. If we are
+ * on the last line, and thus last pixel we reset our
+ * address counter.
+ */
+ if (Y == (TotalY -1)) {
+ /*
+ * The reset address is determined by the help
+ * bit. FIXME: This needs come from a struct.
+ */
+ address = (events->help) ? ADDRESS_HELP_START : ADDRESS_SKIN_START;
+ } else {
+ /*
+ * We should not ever get inhere. To keep
+ * everything consequent however, we add a
+ * a delay.
+ */
+ delay;
+ }
+ } else {
+ /*
+ * Increase the memory counter for each pixel drawn
+ * thus keeping the memory location in sync with
+ * the current pixel position.
+ */
+ address++;
+ }
+} /* --- display_main() --- */
diff --git a/Graphic_Equalizer/src/display/display.hcc b/Graphic_Equalizer/src/display/display.hcc
deleted file mode 100644
index 2dfc669..0000000
--- a/Graphic_Equalizer/src/display/display.hcc
+++ /dev/null
@@ -1,109 +0,0 @@
-/*! \file display.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
- *
- ********************************************************************/
-
-/******** System Includes *************/
-#include <stdlib.hch>
-
-#include "pal_master.hch"
-
-/******** Application Includes ********/
-#include "display.hch"
-
-
-
-/*! \fn void display_main(RAM_BANK0, RAM_BANK1);
- * \brief This routine handles all drawing of pixels. It never returns!
- *
- * \param PL2RAM RAM_BANK0 Handle to the first rambank.
- * \param PL2RAM RAM_BANK1 Handle to the second rambank.
- *
- * \return Never Returns.
- * \retval void
- */
-macro void display_main(RAM_BANK0, RAM_BANK1) {
- /*
- * Setup macro's to coordinate pixel writing.
- */
- macro expr VideoOut = PalVideoOutOptimalCT(ClockRate);
- macro expr VisibleX = PalVideoOutGetVisibleX (VideoOut, ClockRate);
- macro expr TotalX = PalVideoOutGetTotalX (VideoOut, ClockRate);
- macro expr TotalY = PalVideoOutGetTotalY (VideoOut);
- macro expr X = PalVideoOutGetX (VideoOut);
- macro expr Y = PalVideoOutGetY (VideoOut);
-
- unsigned 32 pixeldata;
- unsigned AW nextaddr;
- unsigned DW pixeldata;
- unsigned 1 SwitchData, help;
-
- /*
- * Prime Rendering Pipeline to start at bank 0 address 0.
- */
- PalPL2RAMSetReadAddress(RAM_BANK0, 0);
-
- /*
- * Run the following tasks indefinatly and in parallel
- */
- par (;;) {
- /*
- * We write only the last 24 bits of pixeldata as it also
- * contains information about the mask.
- */
- PalVideoOutWrite(VideoOut, pixeldata <- 24);
-
- /* FIXME this needs to be replaced by a global state array */
- PalSwitchRead(PalSwitchCT(0), &help);
- /*
- * When 'help' is activated, we display data from rambank 1
- * otherwise we draw from rambank 0.
- */
- if (help) {
- PalPL2RAMRead(RAM_BANK1, &Data);
- PalPL2RAMSetReadAddress(RAM_BANK1, nextaddr);
- } else {
- PalPL2RAMRead(PL2RAM_BANK0, &Data);
- PalPL2RAMSetReadAddress(RAM_BANK0, nextaddr);
- }
-
- /*
- * The current position of the screen can lay in an area called
- * the blanking area. We don't have data for this area as it is
- * not drawn. We therefor have to determin wether we are beyond
- * the visible area of the screen, but before the end of the
- * total width of the screen.
- * Our pipeline consists of 5 total stages. Therefor we have to
- * substract 5 pixels.
- */
- if ((X > (VisibleX - 5)) && (X <= (TotalX - 5))) {
- /*
- * We are in the blanking area of the screen. If we are
- * on the last line, and thus last pixel we reset our
- * address counter.
- */
- if (Y == (TotalY -1)) {
- nextaddr = 0;
- }
- } else {
- /*
- * Increase the memory counter for each pixel drawn
- * thus keeping the memory location in sync with
- * the current pixel position.
- */
- nextaddr++;
- }
-} /* --- display_main() --- */
diff --git a/Graphic_Equalizer/src/display/main.hcc b/Graphic_Equalizer/src/display/main.hcc
deleted file mode 100644
index 1c52856..0000000
--- a/Graphic_Equalizer/src/display/main.hcc
+++ /dev/null
@@ -1,87 +0,0 @@
-/*! \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"
-#include "pal_mouse.hch"
-
-/******** Application Includes ********/
-#include "display.hch"
-#include "mousedriver.hch"
-
-
-
-/*
- * Request Clockrate. Approximated ClockRate is compiler assigned.
- */
-static macro expr ClockRate = PAL_ACTUAL_CLOCK_RATE;
-
-
-/*! \fn void main(void);
- * \brief Main User Input/Ouput loop.
- *
- * \param void
- *
- * \return void
- * \retval void
- */
-void main(void) {
- /* Set VideoOut Pointer */
- macro expr VideoOut = PalVideoOutOptimalCT(ClockRate);
-
- /*
- * Check library versions and Request VideoOutput.
- * We need at least Major Version 1. Minor version 0 suffices.
- */
- PalVersionRequire(1, 0);
- PalVideoOutRequire(1);
-
- /*
- * Run The Following main tasks in parallel.
- */
- par {
- /*
- * Primary task is to 'Run' several hardware simultaniously.
- * VideoOutput needs to be in sync with the touchscreen and
- * need to run in sync.
- */
- PalVideoOutRun(VideoOut, ClockRate);
- MouseRun(ClockRate);
-
- /* Parallel to our Primary tasks we run the application. */
- seq {
- /* But first we need to initialize the display */
- display_init(ClockRate);
- par {
- /*
- * From here we run the mouse driver and
- * display parallel.
- */
- mouse_main();
- display_main();
- }
- }
- }
-
-} /* --- main() --- */
diff --git a/Graphic_Equalizer/src/eventhandler.hcc b/Graphic_Equalizer/src/eventhandler.hcc
new file mode 100644
index 0000000..9c67aef
--- /dev/null
+++ b/Graphic_Equalizer/src/eventhandler.hcc
@@ -0,0 +1,71 @@
+/*! \file eventhandler.hcc
+ *
+ * \section generic This modules coordinates all events. Thus for example
+ * when the mousehandler registers a 'click' we coordinate
+ * the actions that follow that click.
+ *
+ * \section project Project information.
+ * Project Graphic Equalizer\n
+ * \author O.M. Schinagl
+ * \date 20041110
+ * \version 0.1
+ *
+ * \section copyright Copyright
+ * Copyright ©2004 Koninklijke Philips Electronics N.V. All rights reserved
+ *
+ * \section history Change history
+ * 20041110: O.M. Schinagl\n Initial version
+ *
+ ********************************************************************/
+
+/******** System Includes *************/
+#include <stdlib.hch>
+
+#include "pal_master.hch"
+
+/******** Application Includes ********/
+#include "eventhandler.hch"
+#include "eventhandler_shared.hch"
+#include "mouse_shared.hch"
+#include "display_shared.hch"
+
+
+
+/*! \fn void eventhandler_main(events_t *events, mousedata_t *mousedata);
+ * \brief
+ *
+ * \param events_t *events pointer to struct with all events.
+ * \param mousedata_t *mousedata pointer to struct with mouse data.
+ *
+ * \return Never Returns.
+ * \retval void
+ */
+void eventhandler_main(events_t *events, mousedata_t *mousedata) {
+ extern chan unsigned 1 mousedata_notification;
+
+ unsigned 5 volume_left;
+ unsigned 1 newmousedata;
+
+ for (;;) {
+ /*
+ * First we determine what mousestate we currently have. Then
+ * we check where we are to decide what to do.
+ */
+ switch (mousedata->state) {
+ case MOUSE_STATE_DOWN:
+ if (BUTTON_HELP == events->mask) {
+ events->help = !events->help;
+ }
+ break;
+ case MOUSE_STATE_ON_PRESS:
+ if (AREA_VOLUME_YAXIS) {
+ events->volume_position = mousedata->y;
+ volume_left = volume_table[(mousedata->y) -65];
+ RC200SetVolume(!volume_left, volume_left, volume_left);
+ }
+ if ((AREA_EQUALIZER_MIN <= events->mask) && (events->mask <= AREA_EQUALIZER_MAX)) {
+ }
+ break;
+ }
+ }
+} /* --- eventhandler_main() --- */
diff --git a/Graphic_Equalizer/src/main.hcc b/Graphic_Equalizer/src/main.hcc
new file mode 100644
index 0000000..6e4f7ae
--- /dev/null
+++ b/Graphic_Equalizer/src/main.hcc
@@ -0,0 +1,164 @@
+/*! \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"
+#include "pal_mouse.hch"
+
+/******** Application Includes ********/
+#include "configuration.hch"
+#include "display.hch"
+#include "mouse.hch"
+#include "mouse_shared.hch"
+#include "audio.hch"
+#include "eventhandler.hch"
+#include "eventhandler_shared.hch"
+
+#if HAVE_DEBUG
+ #include "debug.hch"
+#endif
+
+
+/*
+ * Request Clockrate. Approximated ClockRate is compiler assigned. As the
+ * ClockRate is identical throughout the entire domain, this is a global
+ * expression so that all process use the correct one.
+ */
+macro expr ClockRate = PAL_ACTUAL_CLOCK_RATE;
+
+
+/*! \fn void main(void);
+ * \brief Main User Input/Ouput loop.
+ *
+ * \param void
+ *
+ * \return void
+ * \retval void
+ */
+void main(void) {
+ /*
+ * Set VideoOut, Audio I/O and Ram Handles
+ */
+ macro expr VideoOut = PalVideoOutOptimalCT(ClockRate);
+ macro expr AudioIn = PalAudioInCT(0);
+ macro expr AudioOut = PalAudioOutCT(0)
+ macro expr RAM_BANK0 = PalPL2RAMCT(0);
+
+ unsigned mousedata_t mousedata;
+ unsigned events_t events;
+
+ /*
+ * 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(PL2RAM_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);
+#if HAVE_SMART_MEDIA
+ /*
+ * The smartmedia device needs the CPLD to run.
+ */
+ CPLDRun(ClockRate);
+ SmartMediaRun(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.
+ */
+ display_init(ClockRate);
+ PalAudioInEnable(AudioIn);
+ PalAudioOutEnable(AudioOut);
+ audio_init(6, LINE_IN, SR_44100);
+#if HAVE_SMART_MEDIA
+ /*
+ * Once we properly setup the SmartMedia we load our
+ * data folowed by our main program loop.
+ */
+ if (!smartmedia_init()) {
+#endif
+#if HAVE_DEBUG
+ print_string("Loading Skin ...");
+#endif
+ smartmedia_loaddata();
+#if HAVE_DEBUG
+ print_string("Done Loading Skin ...");
+ print_eol();
+ print_string("Running Main Application.");
+#endif
+
+ /*
+ * 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(&events, &mousedata);
+ eventhandler_main(&events, &mousedata);
+ audio_main();
+ }
+#if HAVE_SMART_MEDIA
+ } else {
+#if HAVE_DEBUG
+ print_string("Error Initializing SmartMedia");
+#endif
+ }
+#endif
+ }
+ }
+
+} /* --- main() --- */
diff --git a/Graphic_Equalizer/src/display/mousedriver.hcc b/Graphic_Equalizer/src/mouse.hcc
index 6f69129..7e7ca26 100644
--- a/Graphic_Equalizer/src/display/mousedriver.hcc
+++ b/Graphic_Equalizer/src/mouse.hcc
@@ -28,14 +28,17 @@
#include "mousedriver.hch"
#include "mousedriver_shared.hch"
+
+
/*
- * Mouse data is stored in shared memory. When new mouse data is available
- * Mouse notification is triggerd.
+ * Channel to notify others when new mousedata is available. If so
+ * Then mousedata struct is updated with shared data.
*/
-mousedata_s mousedata;
chan unsigned 1 mousedata_notification;
-/*! \fn void mouse_main(void);
+
+
+/*! \fn void mouse_main(mousedata_t *mousedata);
* \brief Main mousedriver. This function never returns! It calls the
* main mousehandler and returns the States and coordinates
* into the shared mpram.
@@ -45,7 +48,7 @@ chan unsigned 1 mousedata_notification;
* \return Never Returns.
* \retval void
*/
-void mouse_main(void)
+void mouse_main(mousedata_t *mousedata)
{
unsigned 14 touch_sampler;
unsigned 10 x, oldx;
@@ -91,12 +94,12 @@ void mouse_main(void)
* Compare Previous States and Coordinates to determine
* wether they have changed. If so, Copy them into
* shared memory, notify the listening processes and
- * Set the new as previous values for the next run.
+ * Set the new as previous values for the next run.
*/
if ((oldmousestate != mousestate) || (oldx != x) || (oldy != y)) {
- mousedata.x = x;
- mousedata.y = y;
- mousedata.state = mousestate;
+ mousedata->x = x;
+ mousedata->y = y;
+ mousedata->state = mousestate;
mousedata_notification ! MOUSE_UPDATED;
oldx = x;
oldy = y;
diff --git a/Graphic_Equalizer/src/audio/sample.hcc b/Graphic_Equalizer/src/sample.hcc
index 000baf9..000baf9 100644
--- a/Graphic_Equalizer/src/audio/sample.hcc
+++ b/Graphic_Equalizer/src/sample.hcc
diff --git a/Graphic_Equalizer/src/smartmedia.hcc b/Graphic_Equalizer/src/smartmedia.hcc
new file mode 100644
index 0000000..7fc647b
--- /dev/null
+++ b/Graphic_Equalizer/src/smartmedia.hcc
@@ -0,0 +1,166 @@
+/*! \file smartmedia.hcc
+ *
+ * \section generic Here we interface with the SmartMedia card.
+ *
+ * \section project Project information.
+ * Project Graphic Equalizer\n
+ * \author O.M. Schinagl
+ * \date 20041110
+ * \version 0.1
+ *
+ * \section copyright Copyright
+ * Copyright ©2004 Koninklijke Philips Electronics N.V. All rights reserved
+ *
+ * \section history Change history
+ * 20041110: O.M. Schinagl\n Initial version
+ *
+ ********************************************************************/
+
+/******** System Includes *************/
+#include <stdlib.hch>
+
+#include "pal_master.hch"
+
+/******** Application Includes ********/
+#include "configuration.hch"
+#include "smartmedia.hch"
+
+
+
+/*! \fn void smartmedia_init(void);
+ * \brief We here initialize the Smart Media card and verify wether the
+ * card is inserted and such.
+ *
+ * \param void None.
+ *
+ * \return We return 0 on success, 1 on error.
+ * \retval unsigned 1
+ */
+unsigned 1 smartmedia_init(void) {
+ unsigned 1 retval;
+
+ /*
+ * Firstly we enable both the CPLD and the SmartMedia.
+ */
+ RC200CPLDEnable();
+ RC200SmartMediaInit(&retval);
+
+ /*
+ * In the case of initialization failing, we try to reset the
+ * SmartMedia.
+ */
+ if (retval) {
+ RC200SmartMediaReset(&retval);
+ }
+
+ return retval;
+} /* --- smartmedia_init() --- */
+
+
+
+/*! \fn void smartmedia_loaddata(void);
+ * \brief We load our memory with skin and help data from the smartmedia.
+ *
+ * \param void None.
+ *
+ * \return void
+ * \retval void
+ */
+void smartmedia_loaddata(void) {
+ /*
+ * Setup RAM Handle, and determin maximum Data and Address widths
+ */
+ macro expr RAM_BANK0 = PalPL2RAMCT(0);
+ macro expr DW = PalPL2RAMGetMaxDataWidthCT();
+ macro expr AW = PalPL2RAMGetMaxAddressWidthCT();
+
+ unsigned 27 smartmedia_address, smartmedia_address_mask;
+ unsigned AW address;
+ unsigned 8 mask, r, g, b;
+ unsigned 1 result;
+
+#if HAVE_DEBUG
+ /*
+ * Print some nice stats about data loading.
+ */
+ print_eol();
+ print_hex_value(0 @ 0);
+#endif
+ /*
+ * Before we enter our loop to fill our memory with valid data, we have
+ * to set the startup positions for the SmartMedia.
+ */
+ smartmedia_address = SMARTMEDIA_ADDRES_SKIN_START;
+ smartmedia_address_mask = SMARTMEDIA_ADDRESS_SKINMASK_START;
+ for (address = ADDRESS_SKIN_START; address != (ADDRESS_HELP_END);) {
+ /*
+ * Once we are done with the loading of our skin, we need to
+ * change the smartmedia start addresses.
+ */
+ if (address == ADDRRESS_HELP_START) {
+ smartmedia_address = SMARTMEDIA_ADDRESS_HELP_START;
+ smartmedia_address_mask = SMARTMEDIA_ADDRESS_HELPMASK_START;
+ }
+
+ /*
+ * Before reading our data from the smartmedia we set our
+ * address pointer to the address from our loop.
+ */
+ PalPL2RAMSetWriteAddress(RAM_BANK0, address);
+
+ /*
+ * SmartMedia data is read one byte per call. Because we want
+ * to store the mask + the rgb values in one variable for later
+ * useage we need to read those 4 bytes from the smartmedia
+ * before storing it as one.
+ */
+#if HAVE_SMARTMEDIA
+ /*
+ * FIXME: Due to a bug in the DK2 smartmedia libraries we need
+ * stop reading after each byte with OperationEnd call. This is
+ * VERY slow and must be changed.
+ */
+ #if !USE_MASK_ONLY
+ RC200SmartMediaSetAddress(READ, smartmedia_address);
+ RC200SmartMediaRead(&r, TRUE);
+ RC200SmartMediaOperationEnd(&result);
+ RC200SmartMediaSetAddress(READ, (smartmedia_address +1));
+ RC200SmartMediaRead(&g, TRUE);
+ RC200SmartMediaOperationEnd(&result);
+ RC200SmartMediaSetAddress(READ, (smartmedia_address +2));
+ RC200SmartMediaRead(&b, TRUE);
+ RC200SmartMediaOperationEnd(&result);
+ #endif
+ RC200SmartMediaSetAddress(READ, smartmedia_address_mask);
+ RC200SmartMediaRead(&mask, TRUE);
+ RC200SmartMediaOperationEnd(&result);
+#else
+ mask = 0x01;
+ r = 0xff;
+ g = 0x00;
+ b = 0x00;
+#endif
+ /*
+ * Now that we have gathered all pixel data, store it in ram.
+ */
+ PalPL2RAMWrite(RAM_BANK0, (unsigned DW)(0 @ mask @ r @ g @ b))
+
+#if HAVE_DEBUG
+ /*
+ * Print some nice stats about data loading.
+ */
+ if (!address[8:0]) {
+ print_cr();
+ print_hex_value(0 @ address);
+ print_string(" / 02E4000");
+ }
+#endif
+
+ /*
+ * Finally increase al our indexes approperiatly.
+ */
+ smartmedia_address += 3;
+ smartmedia_address_mask++;
+ address++;
+ }
+} /* --- smartmedia_loaddata() --- */