summaryrefslogtreecommitdiffstats
path: root/Graphic_Equalizer/src/smartmedia.hcc
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/smartmedia.hcc
parentb7b9f1ff4da4dae9d4c14ee5e03a7555b254c31c (diff)
downloadTASS-9451e82004bb59a95d9589058759169c1c486c91.zip
TASS-9451e82004bb59a95d9589058759169c1c486c91.tar.gz
TASS-9451e82004bb59a95d9589058759169c1c486c91.tar.bz2
First Real Version
Diffstat (limited to 'Graphic_Equalizer/src/smartmedia.hcc')
-rw-r--r--Graphic_Equalizer/src/smartmedia.hcc166
1 files changed, 166 insertions, 0 deletions
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() --- */