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

📄 usb_main.lst

📁 针对TMS320C6000系列的DSP芯片的在线升级的源码
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V6.12  USB_MAIN                                                               06/09/2004 15:44:26 PAGE 1   


C51 COMPILER V6.12, COMPILATION OF MODULE USB_MAIN
OBJECT MODULE PLACED IN USB_MAIN.OBJ
COMPILER INVOKED BY: c:\Keil\C51\BIN\C51.EXE USB_MAIN.c DB OE

stmt level    source

   1          //-----------------------------------------------------------------------------
   2          // USB_MAIN.c
   3          //-----------------------------------------------------------------------------
   4          // Copyright 2002 Cygnal Integrated Products, Inc.
   5          //
   6          // AUTH: JS
   7          // DATE: 22 FEB 02
   8          //
   9          //
  10          // Target: C8051F32x
  11          // Tool chain: KEIL C51 6.03 / KEIL EVAL C51
  12          //
  13          // REVISIONS:  11/22/02 - DM:  Added support for switches and sample USB
  14          // interrupt application.
  15          //
  16          //-----------------------------------------------------------------------------
  17          // Includes
  18          //-----------------------------------------------------------------------------
  19          
  20          #include <c8051f320.h>               
  21          #include "USB_REGISTER.h"
  22          #include "USB_MAIN.h"
  23          #include "USB_DESCRIPTOR.h"
  24          
  25          #undef c_cUSR
  26          #include "USB_USER.h"
  27          
  28          //-----------------------------------------------------------------------------
  29          // 16-bit SFR Definitions for 'F32x
  30          //-----------------------------------------------------------------------------
  31          
  32          sfr16 TMR2RL   = 0xca;                   // Timer2 reload value
  33          sfr16 TMR2     = 0xcc;                   // Timer2 counter     
  34          
  35          //-----------------------------------------------------------------------------
  36          // Global CONSTANTS
  37          //-----------------------------------------------------------------------------
  38          
  39          sbit Led1 = P2^2;                         // LED='1' means ON
  40          sbit Led2 = P2^3;
  41          
  42          #define Sw1 0x01                          // These are the port2 bits for Sw1
  43          #define Sw2 0x02                          // and Sw2 on the development board
  44          BYTE Switch1State = 0;                    // Indicate status of switch 
  45          BYTE Switch2State = 0;                    // starting at 0 == off
  46          
  47          BYTE Toggle1 = 0;                         // Variable to make sure each button
  48          BYTE Toggle2 = 0;                         // press and release toggles switch
  49          
  50          BYTE Potentiometer = 0x00;                // Last read potentiometer value
  51          BYTE Temperature = 0x00;                  // Last read temperature sensor value
  52          
  53          BYTE Out_Packet[8] = {0,0,0,0,0,0,0,0};   // Last packet received from host
  54          BYTE In_Packet[8]  = {0,0,0,0,0,0,0,0};   // Next packet to sent to host
  55          
C51 COMPILER V6.12  USB_MAIN                                                               06/09/2004 15:44:26 PAGE 2   

  56          
  57          //-----------------------------------------------------------------------------
  58          // Main Routine
  59          //-----------------------------------------------------------------------------
  60          void main(void) 
  61          {
  62   1         PCA0MD &= ~0x40;                       // Disable Watchdog timer
  63   1      
  64   1         Sysclk_Init();                         // Initialize oscillator
  65   1         Port_Init();                           // Initialize crossbar and GPIO
  66   1         Usb0_Init();                           // Initialize USB0
  67   1         Timer_Init();                          // Initialize timer2
  68   1         Adc_Init();                            // Initialize ADC
  69   1      	
  70   1         Fun_Pro_Main();
  71   1          
  72   1      }
  73          
  74          //-----------------------------------------------------------------------------
  75          // Initialization Subroutines
  76          //-----------------------------------------------------------------------------
  77          
  78          //-------------------------
  79          // Sysclk_Init
  80          //-------------------------
  81          // SYSLCK Initialization
  82          // - Initialize the system clock and USB clock
  83          //
  84          void Sysclk_Init(void)
  85          {
  86   1      #ifdef _USB_LOW_SPEED_
              
                 OSCICN |= 0x03;                       // Configure internal oscillator for
                                                       // its maximum frequency and enable
                                                       // missing clock detector
              
                 CLKSEL  = SYS_INT_OSC;                // Select System clock
                 CLKSEL |= USB_INT_OSC_DIV_2;          // Select USB clock
              #else
  95   1         OSCICN |= 0x03;                       // Configure internal oscillator for
  96   1                                               // its maximum frequency and enable
  97   1                                               // missing clock detector
  98   1      
  99   1         CLKMUL  = 0x00;                       // Select internal oscillator as 
 100   1                                               // input to clock multiplier
 101   1      
 102   1         CLKMUL |= 0x80;                       // Enable clock multiplier
 103   1         CLKMUL |= 0xC0;                       // Initialize the clock multiplier
 104   1         Delay();                              // Delay for clock multiplier to begin
 105   1      
 106   1         while(!CLKMUL & 0x20);                // Wait for multiplier to lock
 107   1         CLKSEL  = SYS_INT_OSC;                // Select system clock  
 108   1         CLKSEL |= USB_4X_CLOCK;               // Select USB clock
 109   1      #endif  /* _USB_LOW_SPEED_ */ 
 110   1      }
 111          
 112          //-------------------------
 113          // Port_Init
 114          //-------------------------
 115          // Port Initialization
 116          // - Configure the Crossbar and GPIO ports.
 117          //
C51 COMPILER V6.12  USB_MAIN                                                               06/09/2004 15:44:26 PAGE 3   

 118          void Port_Init(void)
 119          {  
 120   1         //PORT0 init 
 121   1         P0MDIN   = 0xFf;
 122   1         P0MDOUT = 0x80;                        // Port P0^7 out Port P0^0-P0^6 in
 123   1         P0SKIP   = 0xff;                       // Port 0 pin 0, 1skipped by crossbar iic
 124   1         P0 = 0xff;                             //
 125   1       //port1 init
 126   1         P1MDIN   = 0xFf;                        // Port 1 pins 0,1,2,3 set as analog input others as GPIO
 127   1         P1MDOUT = 0xFF;                        // Port 1 pins 0-3 set high impedence
 128   1         P1SKIP  = 0xFF;                        // Port 1 pin 7 skipped by crossbar
 129   1      //port2 init
 130   1         P2MDIN   = 0xFF;                        // Port 2 pins  as GPIO
 131   1         P2MDOUT = 0xff;                        // Port 2 pins 0,1 set high impedence
 132   1         P2SKIP  = 0xFF;                        // Port 1 pin 7 skipped by crossbar
 133   1         P2 = 0xFF;
 134   1      //port3
 135   1         P3MDIN   = 0xFF;                        // Port 1 pins  as GPIO
 136   1      //crossbar init
 137   1         XBR0     = 0x00;			    //none route iic and uart
 138   1         XBR1     = 0x00;                      // disenable Crossbar    
 139   1         		                         // All P0 pins open-drain output
 140   1         Delay(); 
 141   1      }
 142          

⌨️ 快捷键说明

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