⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 filesys103.txt

📁 台湾凌阳方案300万数码相机源代码
💻 TXT
📖 第 1 页 / 共 5 页
字号:
                          pAudsValue[5] is K_File_Wave_wBitsPerSample_Value
                                significants bits per sample
                                For IMA built into 504, this is 4 bits.
                                For non compress, typical value is 8.
                          pAudsValue[6] is K_File_Wave_wSamplesPerBlock_Value
                                This field have effect only when IMA compressed.
Return Value:
                          return audio size, unit is byte. If 0, no wave file
                          created on card.
--*/
ULONG File_RecordAudioStream(ULONG ramAddr, ULONG ramSize, ULONG *pAudsValue, WORD wFormatTag)
{
	ULONG audioSize = 0;
        WORD freeCluster;
	ULONG freeDiskSize;
	
	if ( wFormatTag == 0x01 || wFormatTag == 0x11 )
	{
        	freeCluster = DOS_GetDiskSpace();
		if ( freeCluster < ( (170L*1024L)/G_DOS_ClusterSize ) )
		{
	        	M_DOS_SetError(K_DOS_DiskFullErr);
	        	File_SendMessage(K_File_UI_Error, K_DOS_DiskFullErr);
			return 0;
		}
        	freeDiskSize = (ULONG)freeCluster * (ULONG)G_DOS_ClusterSize;
        	if ( ramSize > freeDiskSize )
        		ramSize = freeDiskSize;
        		
		G_Card_UI_Action = K_Act_Go_RecordAudio;
		File_SendMessage( K_File_UI_Periodical, G_Card_UI_Action );
		
                pAudsValue[0] = wFormatTag;  // K_File_Wave_wFormatTag_Value
		pAudsValue[1] = 1;	     // K_File_Wave_nChannels_Value
		pAudsValue[2] = 0x1f40;	     // K_File_Wave_nSamplesPerSec_Value

		if ( wFormatTag == 0x11 )    
		{
			// IMA compression
			pAudsValue[5] = 4;   // K_File_Wave_wBitsPerSample_Value
			pAudsValue[4] = 512; // please set 0x2681 to this value
			// wSamplesPerBlock = ((nBlockAlign-(4*nChannels))*8)/
			// (wBitsPerSample*nChannels) + 1
			// K_File_Wave_wSamplesPerBlock_Value
			pAudsValue[6] = ((pAudsValue[4] - (4*pAudsValue[1]))*8)/
			                (pAudsValue[5]*pAudsValue[1]) + 1; 	
		}
		else
		{
			// no compress
			pAudsValue[5] = 8;  // K_File_Wave_wBitsPerSample_Value
			pAudsValue[4] = 1;  // K_File_Wave_blockAlign_Value
		}
		
		// nAvgBytesPerSec = 
		// ( nChannels * nSamplesPerSec * wBitsPerSample ) / 8
		// K_File_Wave_nAvgBytesPerSec_Value
		pAudsValue[3] = (pAudsValue[1]*pAudsValue[2]*pAudsValue[5])>>3;
		
                // should initialize audio registers, enable audio
                // :
                // should have a loop to get audio data to ramAddr
                // should detect user key to stop 
                // should stop until ramSize reached or disk is full
                // :	
	}
	
	return audioSize;
}

06. Searching file
============================================
DOS user service function searching files only that follow DCF file name and di-
rectory specification, so a file is finding using file index or a name that 
follow DCF spec, for example sunp0001.jpg, etc. If you want to find file that
don't follow this rule, you should read Chapter 7 and 8.

By providing the file index to function USR_Delete1File you could delete a file
that is inside DCIM\100MEDIA folder, so are USR_Upload1File, USR_UploadJpg, 
USR_UploadAvi to upload file, USR_Play1File, USR_PlayJpg, USR_PlayAvi to play 
file with name "sunpxxxx" inside that folder. USR_DeleteLastFile delete file
with maximal file index. USR_DeleteAllFile delete all files with "sunpxxxx" and
recognized file type for example jpg, wav, avi.


Example C05E060:

	BYTE sts;
	
	// If the file is sunp0010.avi, then an avi file is played.
	// If the sunp0010.xxx file not exist, sts return FALSE.
	sts = USR_Play1File(10, 0);

To upload all DCF file's information that are inside DCIM\100MEDIA, you could 
use USR_UploadFdb.

Example C05E061:

	BYTE sts;
	
	// Upload all DCF file's information(fdb) inside DCIM\100MEDIA folder.
	// If there are no DCF file inside this folder, then FALSE is return.
	// Each standard fdb is 32 byte, if G_USR_FileCount is 10, then 320
	// bytes are uploaded. Please refer to DOS refernce book for definition
	// of fdb( file description block ) structure.
	sts = USR_UploadFdb(G_USR_FileCount);

All uploaded fdbs are not sorting by name, it is slow to sort using 8 bit cpu.
so sorting better done by host application if wanted.

07. Upload file
============================================
To upload a file, use USR_Upload1File.

Example C05E070:

	BYTE sts;
	
	// If the file is sunp0012.jpg, then a jpg file is uploaded.
	// If the sunp0012.xxx file not exist, sts return FALSE.
	// From the uploaded fdb, you could know the file size.
	// The uploaded number of bytes should be cluster size multiple.
	// So the host application should uploaded (file size + cluster
	// size - 1)/cluster size*cluster size btes. For example, if file size
	// is 120,789 bytes, cluster size is 16,384. Then 131,072 bytes should
	// be uploaded. The host application should then truncate to precise
	// file size. The host could know the cluster size by using bRequest = 
	// 0x23, wIndex = 0x0064 command.
	sts = USR_Upload1File(12);

08. Playback file
============================================
To play a file, use USR_Play1File.

Example C05E080:

	BYTE sts;
	
	// If the file is sunp0012.avi, then an avi file is played.
	// If the avi file have audio and specify TRUE in USR_Play1File
	// and have audio out hardware, then play avi with audio sound.
	// If the file is sunp0012.jpg, then a jpeg file is played.
	// If the file is sunp0012.wav and have audio out hardware
	// then a wave file is played.
	// If the sunp0012.xxx file not exist, sts return FALSE.
	// If the requested file index is found, File_SendMessage( 
	// K_File_UI_Start_PlayAviFile, file index ) is send, else
	// File_SendMessage( K_File_UI_Error, 0 ) is sent. To print OSD
	// font, you could intercept K_File_UI_Start_PlayAviFile message.
	// File_SendMessage( K_File_UI_PlayVideoStrm1Frame, frame number ) is
	// send while playing. File_SendMessage( K_File_UI_End_PlayAviFile, 0 )
	// is sent if play without any error.
	// If jpeg, K_File_UI_Start_PlayDscFile, K_File_UI_End_PlayDscFile are
	// sent.

	sts = USR_Play1File(12, FALSE);

09. Get card infomation
============================================
The Card_GetInformation allow host application to know about the DOS, Card info-
mation.

Example C05E090:
	
	BYTE buf[64];
	WORD len;
	
	// maximal structure len is 64 byte
	len = Card_GetInformation(&buf[0]);

The structure description:

	00 BYTE   structure len
	01 WORD   G_Card_Module		 // code included in card module
	                                 // that support different storage
	                                 // media. For example, if nand code
	                                 // is included in library than bit 2
	                                 // is on.
	                                 // bit 1 means dos for sdram code is
	                                          included.
	                                 // bit 2 means nand code is included.
	                                 // bit 3 means smc code is included.
	                                 // bit 4 means cf code is included.
	                                 // bit 5 means sd code is included.
	03 WORD   K_Card_Version	 // Ex 1.0.3 = 0x0103
	05 BYTE   K_Card_Statge		 // Final = 0x80, Beta = 0x60, 
					 // Alpha = 0x40, Development = 0x20
	06 BYTE   K_Card_Non_Release	 // Release = 0, Non Release = other 
	                                 // value, Ex 'a', 'b', 'c'... 
	07 WORD   G_Card_Supported	 // bit definition is same to G_Card_
	                                 // Module but only bit of actual   
	                                 // "running" code is on. For example, 
	                                 // if G_Card_Module have cf and nand 
	                                 // bit on, but this field have only 
	                                 // nand on. This means that library 
	                                 // code have extra cf code that you 
	                                 // may not require for your hardware.
	09 BYTE   G_Card_Type		 // current storage media type
	                                 // If your hardware solution include
	                                 // more than 1 storage media, for exam-
	                                 // ple cf and nand. This field could 
	                                 // tell whether cf or nand is current 
	                                 // active media. Possible value are
	                                 // K_MEDIA_NANDF, K_MEDIA_SMC, 
	                                 // K_MEDIA_NORF, K_MEDIA_CFC, 
	                                 // K_MEDIA_MMC, K_MEDIA_NEXTF
	                                 // K_MEDIA_SDF, K_MEDIA_DOSRAM
	                                 

	10 ULONG  G_Card_SectorPerCard	 // storage media capacity in sector 
	                                 // For example, if the card capacity
	                                 // is 16M, than the value is 32,768.

	14 BYTE   G_DOS_SystemId	 // DOS system ID. 1 is FAT12. 6 is
					 // FAT16. Please refer to DOS book
					 // for definition.
	15 BYTE   G_DOS_FileSystemType	 // DOS file system type. 0 is FAT12,
					 // 1 is FAT16, 2 is FAT32. Please
					 // refer to DOS book for definition.
	16 WORD   G_DOS_SectorSize	 // bytes per sector
	18 WORD   G_DOS_SectorPerCluster // sector per cluster
	20 ULONG  G_DOS_TotalFreeCluster // free storage space represent in
					 // cluster unit. For example if sector
					 // size is 512, sector per cluster is
					 // 32, this field have value 1200. Then
					 // free storage space is 1200*32*512 byte.					 
	24 ULONG  G_DOS_FatAddr		 // DOS FAT table start logical address
	28 ULONG  G_DOS_FatEndAddr	 // DOS FAT table end logical address
	34 WORD   reserve
	36 WORD   G_DOS_TotalRootDir	 // how many fdb allocated for root di-
					 // rectory.
	38 WORD   reserve
	40 ULONG  G_DOS_RootDirAddr	 // start logical address of root fdb 
					 // area.
	44 ULONG  G_DOS_DataAddr	 // start logical address of cluster
					 // area that managed by FAT table.
					 
					 
					 // Byte offset after 48 should check
					 // byte offset 0 for validation. For 
					 // example, offset 48 is valid only when
					 // byte offset 0 value is 49.
					 
	48 BYTE   support flags		 // bit 2 on means ecc correction by host
	                                 // during uploading is turn on. Check
	                                 // this bit only when K_Card_Version is
	                                 // greater than 0x101.

//------------------------------------------------------------------------------
// Chapter 06. DOS user service function
//------------------------------------------------------------------------------

================================================================================
Global variables
--------------------------------------------------------------------------------
WORD    G_USR_Dir0Cluster
--------------------------------
This variable hold the start cluster of "DCIM" folder.

WORD    G_USR_Dir1Cluster
--------------------------------
This variable hold the start cluster of "100Media" folder.

WORD    G_USR_FileIndex
--------------------------------
When created next DCF file, this value is used to make the name. For example,
if G_USR_FileIndex is 15 and want to capture still image, then the file name
is "sunp0015.jpg".

WORD    G_USR_FileCount
--------------------------------
The total number our DCF file. For example, if inside the "100Media" folder,
there are "sunp0001.jpg", "sunp003.avi", "sample.jpg", then G_USR_FileCount
is 2.

================================================================================

================================================================================
Constants
--------------------------------------------------------------------------------
K_DOS_MatchName
--------------------------------
Use to passed in function with matchCond. When passed this value, the refCon
should passed the name pointer to be matched.

K_DOS_MatchFree
--------------------------------
Use to passed in function with matchCond. refCon should 0. Use to find a free
fdb.

K_USR_MatchIndexName
--------------------------------
Use to passed in function with matchCond. When passed this value, the refCon
should passed the file index value should be matched.

K_USR_MatchOurFile

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -