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

📄 flash.c

📁 驱动,用于闪寸的处理,主要是为了能够更好的处理这些内存
💻 C
📖 第 1 页 / 共 2 页
字号:
    	value = value | (~(*w_ptr));
#endif

    	*w_ptr = EE_program_intel;		// Program setup cmd.
    	_nop();                                	// NOP added to avoid 2 writes in succession (timing violation)
    	*w_ptr = value;                      	// Program value

    	do
	{
      		*w_ptr = EE_read_status_intel; 	// Check program status
      		word_written = *w_ptr & 128;
    	} while (!word_written);               	// Wait for program done

    	*w_ptr = EE_read_intel;                	// Change direction
 // EE_FLASH_TYPE condition

#ifdef PAGEMODE_BUSCON0_SUPPORTED
    	if (pagemode_on)                       	// Enable page mode if it was enabled before erase.
      		clk_sw_pagemode_enable();
#endif

  	FLASHIN = 0x0060;		// Disable write to flash

  	return status;
}
#pragma default_attributes


/****************************************************************
*
*  FUNCTION:       program_word_suspend (local, must be located in RAM)
*
*  PARAMETERS:     w_ptr : determines which word to program.
*                  value : value to program
*
*  RETURNS:        None
*
*  DESCRIPTION:    Is writing a word in the flash.
*                  Essential intr. requests is monitored and allowed.
*                  Suspend resume active. Int enable disable done internal.
*
*  IMPORTANT:      Any changes made to this function shall also be changed in the dummy
*                  function to take effect.
*                  If changes is made the located area in RAM for the dummy function
*                  shall also be changed.
*
*  CREATED:        04.09.00 by EC
*
*  MODIFIED:       02.11.00 by EC
*                    Code re-written in assembler to avoid changes in the code
*                    due to compiler options/revisions, and to avoid the JMPA
*                    instruktion which will course problems then the code is
*                    copied from the flash-function.
*                  21.09.01 by EC
*                    NOP's added to avoid 2 writes in succession (timing violation).
*
****************************************************************/
#pragma class PR=EE_RAMCODE
static BOOL program_word_suspend(unsigned int *w_ptr, unsigned int value)
{
#ifdef PAGEMODE_BUSCON0_SUPPORTED
	unsigned char pagemode_on = 0;
#endif
	unsigned int  toggle_val_1;
	unsigned int  toggle_val_2;
// unsigned int timeout;
	BOOL status = TRUE;


  	DISABLE_INTR		// Disable all intr.

  	FLASHIN = 0x0066;	// Enable write to flash

#ifdef PAGEMODE_BUSCON0_SUPPORTED   // If CS0 is used then page mode must be disabled before proceeding
    	if ((pagemode_on = clk_sw_pagemode_is_active(0)))	// BUSCON0 - Disable page mode if it is enabled
      		clk_sw_pagemode_disable(0);
#endif

// EE_FLASH_TYPE == EE_intel a.o.
    	*w_ptr = EE_read_status_intel;		// check if program suspended
    	if (*w_ptr & 0x04)
    	{
      		*w_ptr = EE_resume_intel;		// Resume program operation
    	}
    	else
	{
      		*w_ptr = EE_read_intel;		// Change direction
      		value &= *w_ptr;

	#if defined(EE_FLASH_TYPE_sharp)
      		value = value | (~(*w_ptr));
	#endif

      		program_block_addr1.value = program_block_addr2.value = value;
      		program_block_addr1.ptr = program_block_addr2.ptr = w_ptr;
      		*w_ptr = EE_program_intel;		// Program setup cmd.
      		_nop();                                	// NOP added to avoid 2 writes in succession (timing violation)
      		*w_ptr = value;                        // Program value
    	}

    	do
	{
      		*w_ptr       = EE_read_status_intel;   // Check program status
      		word_written = *w_ptr & 128;

      		if (EE_essential_intr_request) 	// Check for intr. req.
		{
        		*w_ptr = EE_suspend_intel;	// Suspend
        		_nop();                              // NOP added to avoid 2 writes in succession (timing violation)
        		*w_ptr = EE_read_status_intel;

        		while (!(*w_ptr & 128));	// Wait for state machine ready

        		word_written = !(*w_ptr & 4);		// Check if program is done

        		if (!word_written)	// If program done
			{
          			*w_ptr = EE_read_intel;	// Change direction

			#ifdef PAGEMODE_BUSCON0_SUPPORTED
            			if (pagemode_on)	// Enable page mode if it was enabled before erase.
              			clk_sw_pagemode_enable();
			#endif

        			FLASHIN = 0x0060;		// Disable write to flash
        			ENABLE_INTR			// Allow intr. to be executed
        			DISABLE_INTR
        			FLASHIN = 0x0066;	// Enable write to flash

        			if (program_block_addr1.ptr == NULL)
        			{
          				FLASHIN = 0x0060;	// Disable write to flash
          				ENABLE_INTR
          				return TRUE;		// Program have been resumed from other task and is allready finished
        			}

			#ifdef PAGEMODE_BUSCON0_SUPPORTED
          			clk_sw_pagemode_disable(0);	// BUSCON0 - Disable page mode

				*w_ptr = EE_resume_intel;		// Continue program
      			}
    		}

  	} while (!word_written);		// Wait for program done

  	*w_ptr = EE_read_intel;	// Change direction

#endif // EE_FLASH_TYPE condition

#ifdef PAGEMODE_BUSCON0_SUPPORTED
   	if (pagemode_on)		// Enable page mode if it was enabled before erase.
      		clk_sw_pagemode_enable();
#endif

	if (status == TRUE)
    		program_block_addr1.ptr = program_block_addr2.ptr = NULL;

  	FLASHIN = 0x0060;		// Disable write to flash
  	ENABLE_INTR			// Re-enable all intr.

  	return status;
}
#pragma default_attributes


/****************************************************************
*
*  FUNCTION:       get_flash_type_intel_cmd (local, must be located in RAM)
*
*  PARAMETERS:     None.
*
*  RETURNS:        None.
*
*  DESCRIPTION:    Is detecting the present flash type.
*
*  IMPORTANT:      Any changes made to this function shall also be changed in the dummy
*                  function to take effect.
*                  If changes is made the located area in RAM for the dummy function
*                  shall also be changed.
*
*  CREATED:        06.09.00 by EC
*
*  MODIFIED:       13.10.00 by EC
*                    Code re-written in assembler to avoid changes in the code
*                    due to compiler options/revisions, and to avoid the JMPA
*                    instruktion which will course problems then the code is
*                    copied from the flash-function.
*
****************************************************************/
#if defined(EE_FLASH_TYPE_INTEL_AO)
#pragma class PR=EE_RAMCODE
static unsigned int get_flash_type_intel_cmd(void)
{
	unsigned int  id = MANUFACTURER_CODE_FUJITSU;
	unsigned int  *ip;

  	DISABLE_INTR		// Disable all intr.
  	FLASHIN = 0x0066;	// Enable write to flash

  	// Check for Intel type flash
  	ip  = (unsigned int*)EE_FLASH_BASE_CS_ADDRESS;
  	*ip = EE_identify_device_intel;	// Set device ID mode
  	id  = *ip;
  	*ip = EE_read_intel;	// Change direction

  	FLASHIN = 0x0060;		// Disable write to flash
  	ENABLE_INTR			// Re-enable all intr.

  	return id;
}
#pragma default_attributes
#endif // EE_FLASH_TYPE

/****************************************************************
*
*  FUNCTION:       EE_unlock_block (local, must be located in RAM)
*
*  PARAMETERS:     None.
*
*  RETURNS:        None.
*
*  DESCRIPTION:    Is unlocking a locked block.
*
*  IMPORTANT:      Any changes made to this function shall also be changed in the dummy
*                  function to take effect.
*                  If changes is made the located area in RAM for the dummy function
*                  shall also be changed.
*
*  CREATED:        13.06.00 by EC
*
*  MODIFIED:       21.09.01 by EC
*                    NOP's added to avoid 2 writes in succession (timing violation).
*
****************************************************************/
#pragma class PR=EE_RAMCODE
void EE_unlock_block(unsigned int *w_ptr)
{
#ifdef EE_FLASH_TYPE_INTEL_AO
#ifdef PAGEMODE_BUSCON0_SUPPORTED
	unsigned int pagemode_on = 0;
#endif

    	DISABLE_INTR		// Disable all intr.
    	FLASHIN = 0x0066;	// Enable write to flash

#ifdef PAGEMODE_BUSCON0_SUPPORTED   // If CS0 is used then page mode must be disabled before proceeding
      	if ((pagemode_on = clk_sw_pagemode_is_active(0)))	// BUSCON0 - Disable page mode if it is enabled
        	clk_sw_pagemode_disable(0);
#endif

    	*w_ptr = EE_config_read_intel;	// Config read cmd. //tzl

    	if (*(w_ptr+2) & 1)
	{
      		do
		      {
        		*w_ptr = EE_config_setup_intel;	// Send unlock cmd.
        		_nop();                            		// NOP added to avoid 2 writes in succession (timing violation)
        		*w_ptr = EE_unlock_block_intel;
        		_nop();                            		// NOP added to avoid 2 writes in succession (timing violation)
        		*w_ptr = EE_config_read_intel;	// Config read cmd.
        	} while (*(w_ptr+2) & 1);              	// Until unlocked
    	}

    	*w_ptr = EE_read_intel;	// Change direction

#ifdef PAGEMODE_BUSCON0_SUPPORTED
      	if (pagemode_on)			// Enable page mode if it was enabled before erase.
      		clk_sw_pagemode_enable();
#endif

    	FLASHIN = 0x0060;		// Disable write to flash
    	ENABLE_INTR			// Re-enable all intr.

#endif //EE_FLASH_TYPE_INTEL_AO
}
#pragma default_attributes




________________________________________
发件人: jason [mailto:ya.chen@memocom.com.tw] 
发送时间: 2007年7月20日 12:01
收件人: Wenson Chang 張世宏; Jimmy Tan(谭智亮)
抄送: Stephen Ho 何祥正
主题: Fw: Chipnuts question

Dear Jimmy:
The attachment is our MCP C demo code. Pls check it. If you have any problem with your program or spec. 
You can direct contact with Wenson about your issue!
 
Dear Wenson:
Pls fully support Jimmy in this case!
Thanks!
 
Jason
 
----- Original Message ----- 
From: stephen.ho 
To: YA Chen 陳奕安 
Cc: jimmy.tan@chipnuts.com 
Sent: Friday, July 20, 2007 11:36 AM
Subject: Chipnuts question

Hi Jason:
 
        Chipnuts Mr. Jimmy Tan has some techical questions. Please contact with him and help him to solve.
 
Hi mobile: +86-13714655337
     Office: +86-75526995371 

Best regards,
 
Stephen Ho
 
MemoCom Corp. 
A Company with Saving Power Solution
Mainland Mobile: +86-13701849548
Taiwan Mobile: +886-933889156
Website: http://www.memocom.com.tw
  
  

⌨️ 快捷键说明

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