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

📄 bootloader.lst

📁 非常全的nrf2401设计资料
💻 LST
字号:
C51 COMPILER V7.50   BOOTLOADER                                                            03/05/2008 17:32:45 PAGE 1   


C51 COMPILER V7.50, COMPILATION OF MODULE BOOTLOADER
OBJECT MODULE PLACED IN .\build\bootloader.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE bootloader.c OMF2 ROM(COMPACT) OPTIMIZE(9,SPEED) BROWSE MODC2 MDU_R515 DEBU
                    -G PRINT(.\list\bootloader.lst) OBJECT(.\build\bootloader.obj)

line level    source

   1          /* Copyright (c) 2007 Nordic Semiconductor. All Rights Reserved.
   2           *
   3           * The information contained herein is property of Nordic Semiconductor ASA.
   4           * Terms and conditions of usage are described in detail in NORDIC
   5           * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. 
   6           *
   7           * Licensees are granted free, non-transferable use of the information. NO
   8           * WARRENTY of ANY KIND is provided. This heading must NOT be removed from
   9           * the file.
  10           *
  11           * $LastChangedRevision: 2290 $
  12           */
  13          
  14          /** @file
  15           * This file contain parsing of USB commands
  16           *
  17           * @author Ole Saether
  18           *
  19           */
  20          #include <Nordic\reg24lu1.h>
  21          #include <intrins.h>
  22          
  23          #include "usb.h"
  24          #include "bootloader.h"
  25          #include "version.h"
  26          #include "usb_cmds.h"
  27          #include "flash.h"
  28          #include "config.h"
  29          
  30          #ifdef USE_USERCLASS
  31          #pragma userclass (code = BOOTLOADER)
  32          #pragma userclass (const = BOOTLOADER)
  33          #endif
  34          
  35          extern bool packet_received;
  36          
  37          extern xdata volatile uint8_t in1buf[];
  38          extern xdata volatile uint8_t out1buf[];
  39          extern xdata volatile uint8_t in1bc;
  40          
  41          static bool page_write;
  42          static uint8_t nblock;                      // Holds the number of the current USB_EP1_SIZE bytes block
  43          static uint8_t nblocks;                     // Holds number of the blocks programmed
  44          
  45          static bool idata used_flash_pages[32];     // Holds which flash pages to erase
  46          
  47          void parse_commands(void)
  48          {
  49   1          uint8_t count = 0;
  50   1      
  51   1          if(page_write)
  52   1          {
  53   2              flash_bytes_write((uint16_t)nblock << 6, out1buf, USB_EP1_SIZE);
  54   2              nblock++;
C51 COMPILER V7.50   BOOTLOADER                                                            03/05/2008 17:32:45 PAGE 2   

  55   2              nblocks++;
  56   2              in1buf[0] = 0;
  57   2              count = 1;
  58   2              if (nblocks == (FLASH_PAGE_SIZE/USB_EP1_SIZE))
  59   2              {
  60   3                  page_write = false;
  61   3              }
  62   2          }
  63   1          else
  64   1          {
  65   2              switch(out1buf[0])
  66   2              {
  67   3                  case CMD_FIRMWARE_VERSION:
  68   3                      in1buf[0] = FW_VER_MAJOR;
  69   3                      in1buf[1] = FW_VER_MINOR;
  70   3                      count = 2;
  71   3                      break;
  72   3                  
  73   3                  case CMD_FLASH_ERASE_PAGE:
  74   3                      flash_page_erase(out1buf[1]);
  75   3                      used_flash_pages[out1buf[1]] = false;
  76   3                      in1buf[0] = 0;
  77   3                      count = 1;
  78   3                      break;
  79   3                  
  80   3                  case CMD_FLASH_PAGE_WRITE:          // Eight 64 bytes bulk packets <- PC follow after this com
             -mand
  81   3                      if (used_flash_pages[out1buf[1]])
  82   3                      {
  83   4                          flash_page_erase(out1buf[1]);
  84   4                      }
  85   3                      nblock = out1buf[1] << 3;             // Multiply page number by 8 to get block number
  86   3                      nblocks = 0;
  87   3                      page_write = true;
  88   3                      in1buf[0] = 0;
  89   3                      count = 1;
  90   3                      break;
  91   3                  
  92   3                  case CMD_FLASH_BLOCK_READ:
  93   3                      // Read one USB_EP1_SIZE bytes block from the address given
  94   3                      // by out1buf[1] << 6:
  95   3                      flash_bytes_read((uint16_t)out1buf[1]<<6, in1buf, USB_EP1_SIZE);
  96   3                      count = USB_EP1_SIZE;
  97   3                      break;
  98   3                  
  99   3                  default:
 100   3                      break;
 101   3              }
 102   2          }
 103   1          if (count > 0)
 104   1              in1bc = count;
 105   1      }
 106          
 107          static void get_used_flash_pages(void)
 108          {    
 109   1          uint8_t xdata *pb;
 110   1          uint8_t i;
 111   1          uint16_t j;
 112   1          //
 113   1          // Read through the whole flash to find out which flash
 114   1          // pages that are in use. Store the result in the NUM_FLASH_PAGES
 115   1          // sized array used_flash_pages[]:
C51 COMPILER V7.50   BOOTLOADER                                                            03/05/2008 17:32:45 PAGE 3   

 116   1          for(i=0;i<NUM_FLASH_PAGES;i++)
 117   1          {    
 118   2              used_flash_pages[i] = false;
 119   2              pb = (uint8_t xdata *)(FLASH_PAGE_SIZE * (uint16_t)i);
 120   2              for(j=0;j<FLASH_PAGE_SIZE;j++)
 121   2              {
 122   3                  if(*pb != 0xff)
 123   3                  {
 124   4                      used_flash_pages[i] = true;
 125   4                      break;
 126   4                  }
 127   3                  pb++;
 128   3              }
 129   2          }
 130   1      }
 131          
 132          void bootloader(void)
 133          {
 134   1          EA = 0;
 135   1          get_used_flash_pages();
 136   1          usb_init();
 137   1          packet_received = page_write = false;
 138   1          //
 139   1          // Enter an infinite loop waiting checking the USB interrupt flag and
 140   1          // call the interrupt handler, usb_irq, when the flag is set. The interrupt
 141   1          // handler will set the variable packet_received to true when a packet is
 142   1          // received.     
 143   1          for(;;)
 144   1          {
 145   2              if (USBF)
 146   2              {
 147   3                  USBF = 0;
 148   3                  usb_irq();
 149   3                  if(packet_received)
 150   3                  {
 151   4                      parse_commands();
 152   4                      packet_received = false;
 153   4                  }
 154   3              }
 155   2          }
 156   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    276    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      3       3
   IDATA SIZE       =     32    ----
   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)

⌨️ 快捷键说明

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