REVISION
Definition in file generic.h.
#include "../feature.h"
Include dependency graph for generic.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Enumerations | |
| enum | CODE_CONST |
| Code section enumeration definitions. More... | |
| enum | OBJ_ID |
| Object ID enumerations. More... | |
Functions | |
| USHORT | GEN_int2ASCII (ULONG, char *, BOOL, USHORT) |
| Function converts an unsigned long integer value into ASCII character array. | |
| void | GEN_zeroOut (UINT16 *, UINT16) |
| Function zeros out specified data object. | |
| USHORT | GEN_createTimeString (ULONG, char *) |
| Function creates a time string that is ready to be displayed. | |
| USHORT | GEN_createSizeString (ULONG, char *) |
| Function creates a size string that is ready to be displayed. | |
| void | GEN_memInit (void) |
| Function initializes the SRAM memory management module. | |
| unsigned long | GEN_malloc (unsigned short) |
| Function manages the SRAM as data memory. | |
| void | GEN_free (unsigned long) |
| Function frees the allocated SRAM data buffer. | |
| unsigned short | GEN_memsize (unsigned long) |
| Function returns the allocated SRAM buffer size. | |
| UINT | GEN_strUnpack (UINT16 *, UINT16) |
| Function checks to unpack given string. | |
| UINT | GEN_strPack (char *, const char *, UINT) |
| Function packs input string and returns number of output words. | |
| int | GEN_ascii2hex (long) |
| Function turns a 32 bit ASCII number into hex format. | |
| long | GEN_hex2ascii (int) |
| Function turns a 16 bit hex number into ASCII format. | |
| int | GEN_eepromFormat (int) |
| Function checks to format the EEPROM. | |
| int | GEN_eepromWrite (int, int, int *) |
| Function reads the specified number of bytes from EEPROM. | |
| int | GEN_eepromRead (int, int, int *) |
| Function reads the specified number of bytes from EEPROM. | |
| USHORT | GEN_checksum (USHORT *, USHORT) |
| Function generates a checksum for supplied data. | |
|
|
Code section enumeration definitions. NOTE:This has to match definitions in GEN_load.asm. Definition at line 44 of file generic.h. Referenced by UI_SF_menu(). 00045 {
00046 SYNC_CODE,
00047 SYNC_CONST,
00048 USB_CODE,
00049 USB_CONST,
00050 DISKDB_CODE,
00051 DISKDB_CONST,
00052 MP3_CODE,
00053 MP3_CONST,
00054 PLAY_CODE,
00055 PLAY_IPROG_CODE,
00056 MYFI_IPROG_CODE,
00057 SLEEP_CODE,
00058 VOLUME_CODE,
00059 MYFICHANNEL_CODE,
00060 MSGBOX_CODE,
00061 XIM_CODE,
00062 DBMENU_CODE,
00063 SMENU_CODE,
00064 #ifdef SP_SUPPORT
00065 AUDIOMENU_CODE,
00066 #endif
00067 AUTOSCAN_CODE,
00068 DECODER_CODE,
00069 RADIO_CODE,
00070 TUNER_CODE,
00071 #ifdef WAV_SUPPORT
00072 WAV_CODE,
00073 WAV_CONST,
00074 #endif
00075 #ifdef WMA_SUPPORT
00076 WMA_CODE,
00077 WMA_CONST,
00078 #endif
00079 #ifdef OGG_SUPPORT
00080 OGG_CODE,
00081 OGG_CONST,
00082 #endif
00083 ENCODER_CODE,
00084 ENCODERINIT_CODE,
00085 RECORD_CODE,
00086 RECORDDONE_CODE,
00087 HISI_CODE,
00088 HISIDONE_CODE,
00089 MPR_CODE,
00090 MPR_CONST,
00091 WAVR_CODE,
00092 POWERUP_CODE,
00093
00094 AUTOFF_CODE,
00095 BACKLIGHT_CODE,
00096 BKPKSWAP_CODE,
00097 CONTRAST_CODE,
00098 DATETIME_CODE,
00099 DBRECORDINFO_CODE,
00100 #ifdef DJ_SUPPORT
00101 DJMENU_CODE,
00102 #endif
00103 #ifdef M3U_SUPPORT
00104 PLAYQMENU_CODE,
00105 #endif
00106 EQMENU_CODE,
00107 HISIMENU_CODE,
00108 MAINMENU_CODE,
00109 MYFIMENU_CODE,
00110 PRESETREVIEW_CODE,
00111 PROPERTIES_CODE,
00112 RECQUALITY_CODE,
00113 REPEAT_CODE,
00114 SETTINGS_CODE,
00115 //DeepB
00116 XTRA_CODE,
00117 SHUFFLE_CODE,
00118 SYNCLOG_CODE,
00119
00120 DIAGNOSIS_CODE,
00121 DIAG_HDD_CODE,
00122 DIAG_NAND_CODE,
00123 Invalid_Code
00124 } CODE_CONST;
|
|
|
Object ID enumerations. NOTE: THIS DEFINITION MUST MATCH THE ONE IN GEN_reinit.asm. Definition at line 130 of file generic.h. 00131 {
00132 SYNC_OBJ,
00133 USB_OBJ,
00134 DISKDB_OBJ,
00135 DB_OBJ,
00136
00137 MP3_DECODER_OBJ,
00138 LCD_OBJ,
00139 MENU_OBJ,
00140 UI_OBJ,
00141
00142 #ifdef WAV_SUPPORT
00143 WAV_DECODER_OBJ,
00144 #endif
00145
00146 #ifdef WMA_SUPPORT
00147 WMA_DECODER_OBJ,
00148 #endif
00149
00150 #ifdef OGG_SUPPORT
00151 OGG_DECODER_OBJ,
00152 #endif
00153
00154 ENCODER_OBJ,
00155 MP3_ENCODER_OBJ,
00156 #ifdef WAV_SUPPORT
00157 WAV_ENCODER_OBJ,
00158 #endif
00159
00160 Invalid_Object
00161
00162 } OBJ_ID;
|
|
|
Function turns a 32 bit ASCII number into hex format.
Definition at line 139 of file GEN_string.c. Referenced by SYS_serialNumber(). 00140 {
00141 int i;
00142 int ch;
00143 int hex = 0;
00144
00145 for (i = 0; i < 4; i++)
00146 {
00147 ch = 0x0ff&(ascii>>24);
00148 if (ch >= 'A') ch -= ('A'-10);
00149 else ch -= '0';
00150
00151 hex <<= 4;
00152 hex |= ch;
00153
00154 ascii <<= 8;
00155 }
00156
00157 return hex;
00158 }
|
|
||||||||||||
|
Function generates a checksum for supplied data.
Definition at line 38 of file GEN_checksum.c. Referenced by SYS_getParams(), SYS_regist(), SYS_setParams(), UI_audioPresetUpdate(), UI_isPresetValid(), UI_presetAudio(), and UI_presetRadio(). 00039 {
00040 USHORT checkSum = *pData++;
00041 USHORT tmp;
00042
00043 /* Following to implement an unsigned short integer rotate right. */
00044 while(--len)
00045 {
00046 tmp = (checkSum & 0x0001)? 0x8000 : 0;
00047 checkSum >>= 1;
00048 checkSum += tmp + (*pData++);
00049 }
00050 return checkSum;
00051 }
|
|
||||||||||||
|
Function creates a size string that is ready to be displayed. Function takes the following rule,
Definition at line 43 of file GEN_createSizeString.c. References GEN_int2ASCII(). Referenced by MENU__createDbRecordInfoMenu(), and MENU__createPropertiesMenu(). 00044 {
00045 int len = 0;
00046 int tmp;
00047 BOOL returnMB = FALSE;
00048 BOOL bLeadZero = FALSE;
00049
00050 if( size >= 100000L )
00051 {
00052 /* Return in MB. */
00053 size = size/1000;
00054 returnMB = TRUE;
00055 }
00056
00057 /* Determine if , is needed. */
00058 if( size >= 1000 )
00059 {
00060 tmp = size/1000;
00061
00062 len = GEN_int2ASCII(tmp, str, FALSE, 0);
00063
00064 str += len;
00065 *str++ = ',';
00066 len++;
00067 size %= (ULONG)1000;
00068
00069 bLeadZero = TRUE;
00070 }
00071
00072 tmp = GEN_int2ASCII(size, str, bLeadZero, 3);
00073 str += tmp;
00074
00075 if(returnMB == FALSE)
00076 {
00077 *str++ = 'K';
00078 *str++ = 'B';
00079 }
00080
00081 else
00082 {
00083 *str++ = 'M';
00084 *str++ = 'B';
00085 }
00086
00087 *str = 0;
00088
00089 return len + tmp + 3;
00090 }
|
Here is the call graph for this function:

|
||||||||||||
|
Function creates a time string that is ready to be displayed.
Definition at line 37 of file GEN_createTimeString.c. References GEN_int2ASCII(). Referenced by MENU__createDbRecordInfoMenu(), MENU__createPlayMenu(), MENU_statusBar(), and UI_PSF_recorddone(). 00038 {
00039 USHORT iSec, iHour, iMin;
00040 char * pC = str;
00041
00042 iSec = (unsigned int)(iSecond%60);
00043 iMin = (unsigned int)((iSecond/60) % 60);
00044 iHour = (unsigned int)(iSecond/3600);
00045
00046 /* start to create the string. */
00047 if( iHour )
00048 {
00049 pC += GEN_int2ASCII(iHour, pC, FALSE, 0);
00050 *pC++ = ':';
00051 if( iMin < 10 ) *pC++ = '0';
00052 }
00053
00054 pC += GEN_int2ASCII(iMin, pC, FALSE, 0);
00055 *pC++ = ':';
00056
00057 if( iSec < 10 ) *pC++ = '0';
00058 pC += GEN_int2ASCII(iSec, pC, FALSE, 0);
00059
00060 /* Length does NOT include the terminated NULL. */
00061 *pC = 0;
00062
00063 return (pC - str);
00064 }
|
Here is the call graph for this function:

|
|
Function checks to format the EEPROM.
Definition at line 58 of file GEN_eeprom.c. References GEN_eepromRead(), and GEN_eepromWrite(). Referenced by SYS_loadParams(). 00059 {
00060 int Data;
00061 int i;
00062 unsigned long timeout = TIME_OUT;
00063 unsigned long lData;
00064
00065 GEN_eepromRead(0, 2, &Data);
00066 if( ( Data != 0xdead ) || (Force != 0) )
00067 {
00068 lData = (ULONG)EEPROM_WREN<<16;
00069 EEPROM__spi(EE_UNPROTECT, &lData);
00070 do
00071 {
00072 timeout--;
00073
00074 lData = (ULONG)EEPROM_RDSR<<16;
00075 EEPROM__spi(EE_READSTATUS, &lData);
00076 while (!(lData &0x80000000L)); // wait until valid data
00077
00078 // wait here until write enabled.
00079 // keep doing this until we time out or ready bit is set.
00080 } while ( (!(lData&0x2))&&(timeout) );
00081
00082 if(0 == timeout) return -1;
00083
00084 Data = 0;
00085 for (i = EEPROM_FORMAT_BEGIN; i < EEPROM_FORMAT_END; i++)
00086 {
00087 GEN_eepromWrite(i, 1, &Data);
00088 }
00089
00090 Data = 0xdead;
00091 GEN_eepromWrite(0, 2, &Data);
00092 }
00093 return(0);
00094 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Function reads the specified number of bytes from EEPROM. bytes are big-endian aligned in a word buffer.
Definition at line 117 of file GEN_eeprom.c. Referenced by BAT_calibrate(), GEN_eepromFormat(), MENU__createPropertiesMenu(), SYS_checkRegistration(), SYS_loadParams(), SYS_regist(), and SYS_serialNumber(). 00118 {
00119 unsigned long lData;
00120 int hiByte = 0;
00121
00122 while (Length--)
00123 {
00124 lData = ((unsigned long)EEPROM_READ<<16);
00125 lData |= (((unsigned long)Address & 0xff)<<8);
00126 lData |= (((unsigned long)Address & 0x100)<<3);
00127
00128 EEPROM__spi(EE_READ, &lData);
00129 while(!(lData&0x80000000L));
00130
00131 hiByte ^= 1;
00132
00133 if(hiByte) *ptr = (unsigned int)(lData << 8) & 0xFF00;
00134 else *ptr++ |= (unsigned int)(lData & 0x00FF);
00135
00136 Address++;
00137 }
00138
00139 return(0);
00140 }
|
|
||||||||||||||||
|
Function reads the specified number of bytes from EEPROM. bytes are big-endian aligned in a word buffer.
Definition at line 156 of file GEN_eeprom.c. Referenced by GEN_eepromFormat(), SYS_regist(), SYS_saveParams(), and SYS_serialNumber(). 00157 {
00158 int byte;
00159 int hiByte = 0;
00160 unsigned long lData;
00161 unsigned long timeout = TIME_OUT;
00162
00163 // read the status register and see if it's ok to write
00164 // for reads from EEPROM, the MSBit of the word indicates valid data.
00165 // only the D0-D7 is valid, however when D15 goes high
00166 while (Length--)
00167 {
00168 lData = (ULONG)EEPROM_WREN<<16;
00169 EEPROM__spi(EE_UNPROTECT, &lData);
00170 // Wait till busy is cleared.
00171 do
00172 {
00173 timeout--;
00174
00175 lData = (ULONG)EEPROM_RDSR<<16;
00176 EEPROM__spi(EE_READSTATUS, &lData);
00177 while (!(lData &0x80000000L)); // wait until valid data
00178 // wait here until write enabled.
00179 // keep doing this until we time out or ready bit is set.
00180 } while ( ((lData&0x01)||(!(lData&0x2)))&&(timeout) );
00181
00182 if(0 == timeout) return -1;
00183 timeout = TIME_OUT;
00184
00185 hiByte ^= 1;
00186
00187 byte = (hiByte == 1)? (*ptr) >> 8 : *ptr++ ;
00188
00189 lData = ((unsigned long)EEPROM_WRITE<<16);
00190 lData |= ((unsigned long)Address&0xff)<<8;
00191 lData |= ((unsigned long)Address &0x100)<<3;
00192
00193 lData |= (byte&0x0FF);
00194
00195 EEPROM__spi(EE_WRITE, &lData);
00196 Address++;
00197
00198 do
00199 {
00200 timeout--;
00201
00202 lData = (ULONG)EEPROM_RDSR<<16;
00203 EEPROM__spi(EE_READSTATUS, &lData);
00204 while (!(lData &0x80000000L)); // wait until valid data
00205
00206 // wait here until write enabled.
00207 // keep doing this until we time out or ready bit is set.
00208 //} while ( ((lData&0x01)||(!(lData&0x2)))&&(timeout) );
00209 } while ( (lData&0x01)&&(timeout) );
00210
00211 if(0 == timeout) return -1;
00212 timeout = TIME_OUT;
00213 }
00214
00215 timeout = TIME_OUT;
00216 lData = (unsigned long)EEPROM_WRDI<<16;
00217 EEPROM__spi(EE_PROTECT, &lData);
00218 do
00219 {
00220 timeout--;
00221 lData = (unsigned long)EEPROM_RDSR<<16;
00222 EEPROM__spi(EE_READSTATUS, &lData);
00223 while (!(lData &0x80000000)); // wait until valid data
00224 // keep doing this until we time out or ready bit is set.
00225 } while( ((lData&0x1) && (lData&0x2))&&(timeout) );
00226 if(0 == timeout) return -1;
00227
00228 return(0);
00229 }
|
|
|
Function frees the allocated SRAM data buffer.
Definition at line 102 of file GEN_sramManager.c. Referenced by ENCODER_releaseObj(), MENU__restore(), MENU_action(), NAND__formatChip(), NAND_mount(), and NAND_unmount(). 00103 {
00104 unsigned long ll1, ll2;
00105 unsigned short tmp1, tmp2;
00106
00107 if(0L == dptr) return;
00108
00109 TSK_disable();
00110
00111 // Read back curren block info.
00112 GEN_rdSRAM(dptr - 1, &tmp1, 1);
00113 tmp2 = tmp1 & SRAM_SIZEMASK;
00114 ll2 = dptr - 1;
00115
00116 // Check to merge next block.
00117 ll1 = dptr + tmp2;
00118 if( ll1 < (SRAM_MEMSTART + SRAM_MEMLENGTH) )
00119 {
00120 GEN_rdSRAM(ll1, &tmp1, 1);
00121 if( !(tmp1 & SRAM_MEMMASK) )
00122 {
00123 // Concatenate.
00124 tmp2 += (tmp1 + 1);
00125 }
00126 }
00127
00128 // Check to merge previous block.
00129 ll1 = SRAM_MEMSTART;
00130 tmp1 = SRAM_MEMMASK;
00131
00132 // Search previous block.
00133 while( ll1 != ll2 )
00134 {
00135 GEN_rdSRAM(ll1, &tmp1, 1);
00136 ll1 += ( (tmp1 & SRAM_SIZEMASK) + 1);
00137 }
00138
00139 if( !( tmp1 & SRAM_MEMMASK ) )
00140 {
00141 // Concatenate.
00142 tmp2 += tmp1 + 1;
00143 ll2 -= (tmp1 + 1);
00144 }
00145
00146 // Mark block to be free.
00147 GEN_wrSRAM(ll2, &tmp2, 1);
00148 TSK_enable();
00149 }
|
|
|
Function turns a 16 bit hex number into ASCII format.
Definition at line 109 of file GEN_string.c. Referenced by SYS_serialNumber(). 00110 {
00111 int i;
00112 int ch;
00113 long ascii = 0;
00114
00115 for (i = 0; i < 4; i++)
00116 {
00117 ch = 0x0f&(hex>>12);
00118 if (ch > 9) ch += ('A'-10);
00119 else ch += '0';
00120
00121 ascii <<= 8;
00122 ascii |= ch;
00123
00124 hex <<= 4;
00125 }
00126
00127 return ascii;
00128 }
|
|
||||||||||||||||||||
|
Function converts an unsigned long integer value into ASCII character array.
Definition at line 45 of file GEN_int2ASCII.c. Referenced by GEN_createSizeString(), GEN_createTimeString(), MENU__createDateTimeMenu(), MENU__createPresetMenu(), MENU__createSynclogMenu(), MENU_statusBar(), UI_m3uPut(), and UI_PSF_record(). 00046 {
00047 char buf[kGenInt2AsciiBufLen];
00048 int i;
00049 USHORT retLen;
00050 int bufLen = 0;
00051 char* pC0 = pC; // Save the original pointer.
00052
00053 // Do-while ensures at least one iteration. If ii is zero, we want string to be '0'
00054 do{
00055 // Isolate each digit, starting with the least significant.
00056 ULONG newii = ii / 10L;
00057 int digit = (int)(ii - (newii * 10L));
00058
00059 // Convert to ASCII. Digits going in backward.
00060 buf[bufLen++] = (char)(digit + '0');
00061
00062 ii = newii;
00063
00064 } while (ii != 0);
00065
00066 if (bZeroLead){
00067 // How many leading zeros do we need to add?
00068 int nLeadingZeros = (int)ASCIIbits - bufLen;
00069 if (nLeadingZeros < 0){
00070 return 0; // error.
00071 }
00072
00073 for (i=0 ; i < nLeadingZeros ; i++){
00074 *pC++ = '0';
00075 }
00076 }
00077
00078 for (i = bufLen-1 ; i >= 0 ; i--){
00079 *pC++ = buf[i];
00080 }
00081 *pC = '\0'; // Terminate the string.
00082
00083 retLen = (USHORT)(pC - pC0);
00084
00085 return retLen;
00086 }
|
|
|
Function manages the SRAM as data memory.
Definition at line 53 of file GEN_sramManager.c. Referenced by DB__register(), ENCODER_config(), MENU__preserve(), MENU_create(), NAND__formatChip(), and NAND_mount(). 00054 {
00055
00056 unsigned long dptr;
00057 unsigned short tmp;
00058 unsigned short header;
00059
00060 TSK_disable();
00061 dptr = SRAM_MEMSTART;
00062
00063 // Search available memory.
00064 while(dptr < (SRAM_MEMSTART + SRAM_MEMLENGTH) )
00065 {
00066 GEN_rdSRAM(dptr, &tmp, 1);
00067 if( !(tmp & SRAM_MEMMASK) )
00068 {
00069 // Free memory.
00070 if( tmp >= size )
00071 {
00072 // Memory found, mark it.
00073 header = size | SRAM_MEMMASK;
00074 GEN_wrSRAM(dptr, &header, 1);
00075
00076 // check to split memory.
00077 if( tmp > size )
00078 {
00079 header = (tmp - size - 1);
00080 GEN_wrSRAM(dptr + size + 1, &header, 1);
00081 }
00082
00083 TSK_enable();
00084 return (dptr + 1);
00085 }
00086 else dptr += (tmp+1);
00087 }
00088 else dptr += ( (tmp & SRAM_SIZEMASK) + 1);
00089 }
00090
00091 TSK_enable();
00092 return 0L;
00093 }
|
|
|
Function returns the allocated SRAM buffer size.
Definition at line 160 of file GEN_sramManager.c. 00161 {
00162 unsigned short size;
00163
00164 GEN_rdSRAM(dptr - 1, &size, 1);
00165 return (size & SRAM_SIZEMASK);
00166 }
|
|
||||||||||||||||
|
Function packs input string and returns number of output words. Packed string is always NULL terminated on a word boundary.
Definition at line 78 of file GEN_string.c. Referenced by UI_insertAudioRecord(), UI_insertHisiRecord(), and UI_m3uPut(). 00079 {
00080 unsigned int ii, jj;
00081
00082 jj = len / 2;
00083 for( ii = 0; ii < jj; ii++)
00084 {
00085 out[ii] = (in[ii*2]<<8)|in[(ii*2) + 1];
00086 }
00087
00088 if(len & 0x01)
00089 {
00090 out[ii] = (in[ii*2]<<8);
00091 out[ii+1] = 0;
00092 jj++;
00093 }
00094 else out[ii] = 0;
00095
00096 return jj + 1;
00097 }
|
|
||||||||||||
|
Function checks to unpack given string. It is the caller's responsibility to make sure the buffer is big enough to hold the unpacked string.
Definition at line 41 of file GEN_string.c. Referenced by MENU__create(), MENU__createListMenu(), SYS_regist(), UI_interpretAudioRecord(), UI_interpretFailedHisiRecord(), UI_interpretIdentifiedHisiRecord(), UI_interpretUnidentifiedHisiRecord(), and UI_m3uGet(). 00042 {
00043 UINT16 * pCh;
00044 UINT16 ii;
00045
00046 if( *pData & 0xFF00 )
00047 {
00048 ii = iDataLen;
00049 pCh = pData + ii*2 - 1;
00050 pData = pData + ii - 1;
00051
00052 while(ii--)
00053 {
00054 *pCh-- = *pData&0x0ff;
00055 *pCh-- = (*pData--)>>8;
00056 }
00057
00058 iDataLen *= 2;
00059 }
00060
00061 return iDataLen;
00062 }
|
1.3.9.1