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

📄 filesys103.txt

📁 台湾凌阳方案300万数码相机源代码
💻 TXT
📖 第 1 页 / 共 5 页
字号:

Example C04E030:

Assume that your camera have 8M byte of RAM, have audio, have avi funtion, 
support 128 SMC card, sensor is 1280x960, avi frame rate is 15, allow user to 
record 1 hour of video to card. Also assume that using sample rate 8000, mono
channel sound, no compress. Typical sdram map for this system is as below:

maximal frame count = 1hr x 15 = 3600 x 15 = 54000 frames
Idx1 buffer caculation = ( 8 + maximal frame count * 16 + 16 ) / 2 
                       = 0x69794 word
                       where 16 added for 1 '01wb' idx which is for audio
audio buffer size = 0x003FFFFF - 0x0031ED94 + 1 = 0x000E126C
maximal avi with audio recording time = 0x000E126C * 2 / 8000 = 230 sec


     0x00000000  _______________
		| Video         |    
                | Buffer        |
		|               |
     0x0012C000 |---------------| 
		| VLC           |
		| Buffer        |
		|               |
     0x00294000	|---------------|
		| Thumbnail     |
		| Buffer        |
     0x0029D600 |---------------|
   DOS_WorkAddr	| DOS Working   | Use as DOS working buffer.
		| Buffer        | DOS_WorkSize = 32K
     0x002A5600	|---------------|
   DOS_FAT1Addr | FAT           | Use as DOS fat buffer. For external
		| Buffer        | flash, DOS_Fat1BufSize= 64K word.
     0x002B5600 |---------------|
                | AVI Idx1      |
                | Buffer        |
                |               |
     0x0031ED94 |---------------|              
   ImageBufAddr | Card   Also   | Use as card module still image buffer,
   AudioBufAddr | Image  Audio  | plus file header size. Or during upload,
		| Buffer Buffer | use as DOS fdb storage buffer.
		|               |
		|---------------|
		|      .        |
		|      .        |
		|               |
     0x003FFFFF |_______________| End of audio buffer
		
//------------------------------------------------------------------------------
// Chapter0 4. Develop UI function for camera
//------------------------------------------------------------------------------
Card module functions invoked by function name and related parameters set thro
-ugh some globals variables and arguments. So it doesn't assume any vendor com-
mand. For example, File_SnapJpg function could be invoked by bRequest=0x51, 
wIndex=0x00, wValue=0, wLength = 0 when using our new firmware code. It could 
be other values, if you implement your own firmware main code and own host appl-
ication software.

So, in the Sunplus new main flow code, below is the UI flow is to invoke 
File_SnapJpg:

main.c		MAIN_LockLoop
main.c		MAIN_PreDpc
ui.c		UI_Time_Division_Function
ui.c		UI_One_Timer1_Fx_Processing
ui.c		LCD_Display_Refresh
ui.c		UI_Keypad_Scan
ui.c		UI_Get_Hardware_Keypad_2
ui.c		LCDBeep
ui.c		UI_Keypad_Enter_Snap
			set G_bRequestLock to 0x51
			set G_wIndexLock to 0
main.c		MAIN_LockLoop
storage.c	STORAGE_CaptureObject
cardusr.c	Card_CaptureObject
library		File_SnapJpg
			please check "Snap a jpeg file" for globals and argument
			that control the capture action. For example, with, he-
			ight, qtable etc.

If you use host application to invoke File_SnapJpg function, the command is
bRequest=0x51, wIndex=0x00, wValue=0, wLength = 0. Flow is below:

ctlsetup.c	CTLSETUP_Packet
ctlsetup.c	CTLSETUP_VendorRequest
			Set G_bRequestLock
			Set G_wValueLock
			Set G_wIndexLock
main.c		MAIN_LockLoop
storage.c	STORAGE_CaptureObject
cardusr.c	Card_CaptureObject
library		File_SnapJpg

Since card module is a library, it use File_SendMessage function to communicate 
with outside world what is undergoing inside it's world.

ULONG File_SendMessage( WORD message, ULONG param ) which define in cardui.c.

Available messages define in cardui.h are:

NOTE : Message range 0 to 2000 reserved by Sunplus

K_File_UI_Start_DscFile		// Start capturing still image file
K_File_UI_Start_DscImage	// Start capturing still image
K_File_UI_End_DscImage		// End capturing still image
				// param is image size
K_File_UI_Start_VideoImage	// Start capturing still image by video mode
				// this message use in SPCA 500 only for capture
				// still image with subsample, 500 require using
				// video mode
K_File_UI_End_VideoImage	// End capturing still image by video mode
				// param is image size
K_File_UI_End_DscFile		// End capturing still image file
				// param is G_USR_FileCount
K_File_UI_Err_DscFile		// Error capturing still image file. If param is
				// non zero, definition is same to 
				// K_File_UI_Error.
K_File_UI_Start_AviFile		// Start recodring avi image file
K_File_UI_End_AviFile		// End recodring avi image file
				// param is G_USR_FileCount
K_File_UI_Err_AviFile		// Error capturing avi image file. If param is
				// non zero, definition is same to 
				// K_File_UI_Error.
K_File_UI_Periodical		// Card module is doing lengthy operation
				// There are many different kind of lengthy ope-
				// ration such as formatting, deleting all, etc.
				// These operations are passed in param to indi-
				// cate what kind of lengthy operation is under
				// going.
K_File_UI_VideoStrm1Frame	// During recording avi, if one video frame is
				// produced, this message will be sent. The pa-
				// ram is the video frame count G_File_AviImage
				// -Count.
K_File_UI_Error			// If any error happen, this message will be 
				// sent. If param is zero, the error cause is 
				// unknown. If param is non zero, please find
				// header file for error code meanning.
K_File_UI_Start_WaveFile	// Start recording audio wave file
K_File_UI_End_WaveFile		// End recording audio wave file
				// param is G_USR_FileCount.
K_File_UI_Err_WaveFile		// Error recording audio wave file. If param is
				// non zero, definition is same to 
				// K_File_UI_Error.
K_File_UI_Start_DscCapture	// Start capture dsc image. At this point, came-
				// ra must be fixed until K_File_UI_End_DscCapt-
				// ure message is received.
K_File_UI_End_DscCapture	// End capture dsc image. If this message rece-
				// ived, user is free to move camera. You may
				// beep a sound to inform user.
K_File_UI_Start_DscCompress	// Start compressing dsc image. While the asic
				// is compressing, camera is allowed to move.
K_File_UI_End_DscCompress	// End compressing dsc image.
K_File_UI_Start_Save_File	// Start saving data to card.
K_File_UI_End_Save_File		// End saving data to file. If param is non 
				// zero, definition is same to K_File_UI_Error.
K_File_UI_Start_Delete1File	// Start deleting 1 file.
K_File_UI_End_Delete1File	// End deleting 1 file. Param is G_USR_FileCount.
K_File_UI_Err_Delete1File	// Error deleting 1 file. If param is non zero,
				// definition is same to K_File_UI_Error.
K_File_UI_Start_DeleteAll	// Start deleting all file
K_File_UI_End_DeleteAll		// End deleting all file. Param is G_USR_File-
				// Count.
K_File_UI_Err_DeleteAll		// Error deleting all file. If param is non zero
				// , definition is same to K_File_UI_Error.
K_File_UI_Start_Initialize	// Start initialize card, dos, etc.
K_File_UI_End_Initialize	// End initialization, If param is non zero,
				// definition is same to K_File_UI_Error.
K_File_UI_Start_FormatCard	// Start formatting card.
K_File_UI_End_FormatCard	// End formatting card. If param is non zero,
				// definition is same to K_File_UI_Error.

When card module send K_File_UI_Periodical message, it means card module go into
lengthy operation. There are many case that may cause lengthy operation, such as 
recording avi, delete all file etc. The param is passed below value to indicate
what cause lengthy action:

NOTE : Message range 0 to 2000 reserved by Sunplus

K_Act_Go_SaveFile	// saving file action is running
K_Act_Go_Delete1File	// delete one file action is running	
K_Act_Go_DeletAll	// delete all file action is running	
K_Act_Go_Initialize	// initializing card action is running	
K_Act_Go_FormatCard	// formatting card action is running
K_Act_Go_RecordAvi	// recording avi action is running
K_Act_Go_RecordAviAud	// recording avi with audio action is running
K_Act_Go_RecordAudio	// recording audio action is running

cardui.c and cardui.h are provided to you and have implementation example.

An example of messages received by File_SnapJpg:
01. K_File_UI_Start_DscFile
02. K_File_UI_Start_DscImage
03. K_File_UI_Start_DscCapture
04. K_File_UI_End_DscCapture
05. K_File_UI_Start_DscCompress
06. K_File_UI_End_DscCompress
07. K_File_UI_End_DscImage
08. K_File_UI_Start_Save_File
09. K_File_UI_Periodical:K_Act_Go_SaveFile
10. K_File_UI_End_Save_File
11. if ( every thing go right )
	K_File_UI_End_DscFile
    else
	K_File_UI_Err_DscFile

If you agree that File_SendMessage is a good way to add your UI function and 
there are still more messages you want to add outside card module world, you 
are allowed to define your own message, but please don't use 0 to 2000 range,
because this range is reserved by Sunplus.

If you think that card module should add some messages inside it world, please
tell us.
			
//------------------------------------------------------------------------------
// Chapter 05. DOS user service function examples
//------------------------------------------------------------------------------	

As said in description for "dosusr.h", the functions provide in this chapter 
assume our naming convention.

Below are some brief description about the function:

01. Format card
============================================
Before using non formatted internal flash, you must format it with DOS_Format
passing 1. Passing 1 means using card erased command to erase the card, this 
will take longer time then passing 0, but it is good for card that might 
have problems particularly when you are using nand internal flash, smc card.

Example C05E010:

	BYTE sts;
	
	// pass 1, so do physical format
        sts = DOS_Format(1);
        
NOTE:For Card Module version smaller than 102, must pass 1.

If failure, the DOS_Format return 0, return non zero value when success.

02. Checking disk space
============================================
During card initialization process, the Card Module will call DOS_CheckDiskSpace
to check for whole disk space. After that, you could always check disk space by
calling DOS_GetDiskSpace. DOS_GetDiskSpace is faster than DOS_CheckDiskSpace is
that it doesn't scan DOS FAT structure to calculate the disk free space, it 
intercept all file disk space related function to set it internal global to 
calculate the disk space. 

All capture function that Sunplus provided to you will internally check against 
for enough and safe disk space before doing the capture function. For example,
If File_SnapJpg function found not enough disk space, File_SendMessage(
K_File_UI_Error, K_DOS_DiskFullErr) or File_SendMessage( K_File_UI_Err_DscFile, 
K_DOS_DiskFullErr ) will be called, the UI implementer could intercept this me-
ssage and tell user about disk is full status.

Example C05E020:

// Quick disk free space checking function
ULONG FastCalDiskFreeSize(void)
{
        WORD freeCluster;
                
        freeCluster = DOS_GetDiskSpace();
        
        // DOS_GetDiskSpace return number of free clusters,
        // have to mutiply G_DOS_ClusterSize to translate
        // it into free disk bytes
        return (ULONG)G_DOS_ClusterSize * (ULONG)freeCluster;
}    

Example C05E021:
 
// Caluclate whole disk free space
ULONG CalDiskFreeSize(void)
{  
        WORD freeCluster;

        // NOTE:This will search whole DOS FAT table, spend much
        // cpu time. Should avoid doing this oftenly.
        freeCluster = 0xFFFF;
        DOS_CheckDiskSpace(&freeCluster);
        
        // DOS_CheckDiskSpace return number of free clusters,
        // have to mutiply G_DOS_ClusterSize to translate
        // it into free disk bytes
        return (ULONG)G_DOS_ClusterSize * (ULONG)freeCluster;
}

Example C05E022:

// Check for if enough disk space write to disk
// Return TRUE if this space enough for requested dataSize, else FALSE.
BYTE IsEnoughDiskSpace(ULONG dataSize)
{  
        WORD freeCluster;

⌨️ 快捷键说明

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