C51 COMPILER V9.60.0.0   EFLASH                                                            03/02/2021 14:02:58 PAGE 1   


C51 COMPILER V9.60.0.0, COMPILATION OF MODULE EFLASH
OBJECT MODULE PLACED IN .\Out_Files\eflash.obj
COMPILER INVOKED BY: D:\Keil_C51\C51\BIN\C51.EXE UM800x\driver\eflash.c COMPACT OMF2 OPTIMIZE(9,SIZE) BROWSE MOD517(NOAU
                    -) INCDIR(.\APP;.\Common;.\UM800x\driver;.\UM800x\system) DEBUG PRINT(.\Out_Files\eflash.lst) OBJECT(.\Out_Files\eflash.o
                    -bj)

line level    source

   1          /***********************************************************************
   2           * Copyright (c)  2017 - 2020, Unicmicro Co.,Ltd .
   3           * All rights reserved.
   4           * Filename    : eflash.c
   5           * Description : eflash driver source file
   6           * Author(s)   : Dan
   7           * version     : V1.0
   8           * Modify date : 2020-07-16
   9           ***********************************************************************/
  10          #include  "eflash.h"
  11          #include  "config.h"
  12          
  13          void eflash_init(uint32_t system_clk_hz)  
  14          {       
  15   1              OPSET |= (0<<3);                                    //RD_WAIT = 0
  16   1          
  17   1          OUS = (system_clk_hz/2)-1;
  18   1              
  19   1              OINTUS = 0x3f;                                      //清除所有中断标志位
  20   1              OINTEN = 0x00;                                      //关闭所有中断功能
  21   1                      
  22   1      }
  23          void eflash_erase_page(uint16_t page_addr)      
  24          {
  25   1              OPSET &= ~EFC_WRITE_MODE;
  26   1              OPSET |= EFC_PAGE_ERASE_MODE;            //开启page擦除模式
  27   1                      
  28   1              OADR = page_addr;           
  29   1              OCTRL |= (0x1<<3);                                       //PUMP_SEL = 6.75v
  30   1              OCTRL |= (1<<6);                                         //PUMP_EN=1
  31   1              while(!(OCTRL & (1<<1)));                    //wait for PUMP OK
  32   1              OCTRL |= (1<<7);                                         //VPPO_EN = 1
  33   1              while((OCTRL & (1<<7)));                     //wait for VPPO_EN = 0
  34   1              OCTRL &= (1<<6);                                         //PUMP_EN=0
  35   1                      
  36   1              OPSET &= ~EFC_PAGE_ERASE_MODE;           //关闭page擦除模式
  37   1      }
  38          
  39          void eflash_write_byte(uint16_t addr,uint8_t value)      
  40          {
  41   1              OPSET |= EFC_WRITE_MODE;                    //使能写模式
  42   1              
  43   1              OADR = addr;
  44   1              ODATA = value;
  45   1              OCTRL |= (0x1<<3);                                  //PUMP_SEL = 6.75v
  46   1              OCTRL |= (1<<6);                                    //PUMP_EN=1
  47   1              while(!(OCTRL & (1<<1)));                     //wait for PUMP OK;
  48   1              OCTRL |= (1<<7);                                    //VPPO_EN = 1
  49   1              while((OCTRL & (1<<7)));                      //wait for VPPO_EN = 0
  50   1              OCTRL &= (1<<6);                                    //PUMP_EN=0
  51   1                  
  52   1              OPSET &= ~EFC_WRITE_MODE;                   //关闭写模式
  53   1              
C51 COMPILER V9.60.0.0   EFLASH                                                            03/02/2021 14:02:58 PAGE 2   

  54   1      }
  55          
  56          void eflash_write_bytes(uint16_t addr, uint8_t *buff, uint32_t length)   
  57          { 
  58   1          OPSET |= EFC_WRITE_MODE;                //使能写模式
  59   1          
  60   1          while(length--)
  61   1          {
  62   2              OADR = addr++;
  63   2              ODATA = *buff++;
  64   2              OCTRL |= (0x1<<3);                                  //PUMP_SEL = 6.75v
  65   2              OCTRL |= (1<<6);                                        //PUMP_EN=1
  66   2              while(!(OCTRL & (1<<1)));               //wait for PUMP OK;
  67   2              OCTRL |= (1<<7);                                        //VPPO_EN = 1
  68   2              while((OCTRL & (1<<7)));                //wait for VPPO_EN = 0
  69   2              OCTRL &= (1<<6);                                        //PUMP_EN=0     
  70   2          }
  71   1      
  72   1              OPSET &= ~EFC_WRITE_MODE;                   //关闭写模式        
  73   1      }
  74          
  75          
  76          uint8_t eflash_read_byte(uint16_t addr)
  77          {
  78   1              uint8_t value;
  79   1      
  80   1              value = (*(volatile uint8_t code *)(addr));
  81   1            
  82   1              return value;
  83   1      
  84   1      }
  85          
  86          uint32_t eflash_read_bytes(uint16_t addr, uint8_t *buff, uint32_t length)
  87          {
  88   1              uint32_t index;
  89   1          
  90   1          for(index = 0; index<length; index++)
  91   1          {
  92   2              buff[index] = (*(volatile uint8_t code *)(addr+index));        
  93   2          }
  94   1              
  95   1              return index;
  96   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    304    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----      26
   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
   EDATA SIZE       =   ----    ----
   HDATA SIZE       =   ----    ----
   XDATA CONST SIZE =   ----    ----
   FAR CONST SIZE   =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)
