C51 COMPILER V9.01   SH_IEC60730B_8051F_FLASH                                              10/11/2023 14:22:17 PAGE 1   


C51 COMPILER V9.01, COMPILATION OF MODULE SH_IEC60730B_8051F_FLASH
OBJECT MODULE PLACED IN .\output\sh_iec60730b_8051f_flash.obj
COMPILER INVOKED BY: C:\Keil_v5\C51\BIN\C51.EXE code_classb\iec60730_lib\sh_iec60730b_8051f_flash.c LARGE OPTIMIZE(7,SIZ
                    -E) REGFILE(.\output\McuFlash_ISP.ORC) BROWSE INTVECTOR(0X1000) INCDIR(.\header_app;.\header_drv;.\code_gasguage) DEBUG O
                    -BJECTEXTEND PRINT(.\output\sh_iec60730b_8051f_flash.lst) OBJECT(.\output\sh_iec60730b_8051f_flash.obj)

line level    source

   1          /*
   2           * IEC60730 Class B Library for SINOWEALTH 8051 based ICs.
   3           * File:    sh_iec60730b_8051f_flash.c
   4           * Version: 1.0
   5           * Author:  Robin.zhang Chaoming.luo
   6           * Date:    04/21/2023
   7           * SINOWEALTH IS SUPPLYING THIS SOFTWARE FOR USE EXCLUSIVELY ON SINOWEALTH'S 
   8           * MICROCONTROLLER PRODUCTS. IT IS PROTECTED UNDER APPLICABLE COPYRIGHT LAWS. 
   9           * THIS SOFTWARE IS FOR GUIDANCE IN ORDER TO SAVE TIME. AS A RESULT, SINOWEALTH 
  10           * SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES 
  11           * WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT OF SUCH FIRMWARE AND/OR
  12           * THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION CONTAINED HEREIN IN 
  13           * CONNECTION WITH THEIR PRODUCTS.
  14           *
  15          */
  16          
  17          #include "sh_iec60730b_8051f_cfg.h"
*** WARNING C318 IN LINE 17 OF code_classb\iec60730_lib\sh_iec60730b_8051f_flash.c: can't open file 'sh_iec60730b_8051f_
             -cfg.h'
  18          #include "MCURegister.h"
  19          
  20          #if SH_CHK_FLASH_EN == 1
*** WARNING C322 IN LINE 20 OF code_classb\iec60730_lib\sh_iec60730b_8051f_flash.c: unknown identifier
              SHT_FLASHADDR   __iec60730b_flash_addr;
              SHT_U16         __iec60730b_flash_crc;
              SHT_U16         __iec60730b_boot_checksum;
               
              /*******************************************************************************
               *
               * @brief    This function generate the 16-bit CRC value using SW.
               *
               * @param    dataIn        - tested data.
               * @param    crcVal        - start condition seed (for the first iteration it is
               *                           typically user defined value, for the next iterations
               *                           it is the result from the previous function call).
               *
               * @return   16-bit crc value of the memory range (CRC-16-CCITT - normal 0x1021).
               *
               ******************************************************************************/
              SHT_U16 sh_8051f_crc_sw16(SHT_U8 dataIn, SHT_U16 crcVal)
              {
                  SHT_U8 crcVH;
                  SHT_U8 i;
                  for(i = 0; i < 8; i++)
                  {
                      crcVH = crcVal>>8;        
                      crcVal <<= 1;
                      if((dataIn ^ crcVH) >> 7)
                          crcVal ^= 0x1021;
                       dataIn <<= 1;
                  }    
                      return crcVal;    
              }
C51 COMPILER V9.01   SH_IEC60730B_8051F_FLASH                                              10/11/2023 14:22:17 PAGE 2   

              #endif
  52          #if ((SH_CHK_FLASH_EN == 1)||(SH_CHK_EE_EN == 1)||(SH_CHK_BOOT_EN == 1))
*** WARNING C322 IN LINE 52 OF code_classb\iec60730_lib\sh_iec60730b_8051f_flash.c: unknown identifier
*** WARNING C322 IN LINE 52 OF code_classb\iec60730_lib\sh_iec60730b_8051f_flash.c: unknown identifier
*** WARNING C322 IN LINE 52 OF code_classb\iec60730_lib\sh_iec60730b_8051f_flash.c: unknown identifier
              /*******************************************************************************
               *
               * @brief    This function generate the ROM CRC.
               *
               * @param    startaddr    - start addr.
               * @param    endaddr      - end addr.
               * @param    crcromtype   - crc code or eeprom.
               *
               * @return   16-bit crc value of the memory range (CRC-16-CCITT - normal 0x1021).
               *
               ******************************************************************************/
              SHT_U16 sh_8051f_crc_code(SHT_EEADDR startaddr,SHT_EEADDR endaddr,SHT_U8 crcromtype)
              {   
                      CRCCON &= ~0x40;
                  CRCCON &= ~0x80;    //stop CRC
                  
                      CRCDL = 0xFF;
                      CRCDH = 0xFF;
                      
                      if(crcromtype == MCU_CRC_EE)
                      {
                              FLASHCON |= 0x02;
                      }
                      else
                      {
                              FLASHCON &= ~0x02;
                      }
                      endaddr -= 3;
                  
                      CRCSTAL = (SHT_U8)startaddr;
                      CRCSTAH = (SHT_U8)(startaddr >> 8);
                      
                      CRCSTOL = (SHT_U8)endaddr;
                      CRCSTOH = (SHT_U8)(endaddr >> 8);
                      
                      CRCCON |= 0x80; //start CRC
                  
                  while((CRCCON & 0x40) == 0){}
                      
                      CRCCON &= ~0x40;
                  return CRCD_16;
              }
              #endif
  96          
  97          #if SH_CHK_FLASH_EN == 1
*** WARNING C322 IN LINE 97 OF code_classb\iec60730_lib\sh_iec60730b_8051f_flash.c: unknown identifier
              /*******************************************************************************
               *
               * @brief    This function caculate CRC in runtime and check the result after done.
               *
               * @param    void
               *
               * @return   SH_CHK_PASS
               *           SH_CHK_FAIL_FLASH
               *
               ******************************************************************************/
              SHT_RESULT sh_8051f_flash_runtime(void)
C51 COMPILER V9.01   SH_IEC60730B_8051F_FLASH                                              10/11/2023 14:22:17 PAGE 3   

              {
                   SHT_RESULT checkResult = SH_CHK_PASS;
                   if(__iec60730b_flash_addr == SH_CHK_FLASH_START_ADDR)
                       __iec60730b_flash_crc = 0xFFFF;
                   
                   __iec60730b_flash_crc = sh_8051f_crc_sw16(*(SHT_U8 code *)__iec60730b_flash_addr, __iec60730b_flash_c
             -rc);
                   
                   __iec60730b_flash_addr++;
                   if(__iec60730b_flash_addr >= (SH_CHK_FLASH_END_ADDR-2))
                   {
                       if(__iec60730b_flash_crc != __iec60730b_flash_checksum)
                           checkResult = SH_CHK_FAIL_FLASH;
                       __iec60730b_flash_addr = SH_CHK_FLASH_START_ADDR;
                   }
                   return checkResult;
              }
              #endif


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   ----    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


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