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

📄 usbhal.lst

📁 周立功的LPC214x固件程序
💻 LST
📖 第 1 页 / 共 2 页
字号:
ARM COMPILER V2.53,  USBHAL                                                                28/06/07  09:54:11  PAGE 1   


ARM COMPILER V2.53, COMPILATION OF MODULE USBHAL
OBJECT MODULE PLACED IN USBHAL.OBJ
COMPILER INVOKED BY: C:\Keil\ARM\BIN\CA.exe USBHAL.c THUMB OPTIMIZE(0,SPEED) BROWSE DEBUG TABS(4) 

stmt  level    source

    1          /****************************************Copyright (c)**************************************************
    2          **                               Guangzou ZLG-MCU Development Co.,LTD.
    3          **                                      graduate school
    4          **                                 http://www.zlgmcu.com
    5          **
    6          **--------------File Info-------------------------------------------------------------------------------
    7          ** File name:           USBHAL.c
    8          ** Last modified Date:  2005-8-6
    9          ** Last Version:        V1.0
   10          ** Descriptions:        USBHAL.c, 硬件抽象层,设置 USB 设备的运行条件
   11          **                      USBHAL.c, Hardware abstract layer, configure the running condition of USB device
   12          **------------------------------------------------------------------------------------------------------
   13          ** Created by:          郑明远      MingYuan Zheng
   14          ** Created date:        2005-8-6
   15          ** Version:             V1.0
   16          ** Descriptions:        初始版本    The original version
   17          **
   18          **------------------------------------------------------------------------------------------------------
   19          ** Modified by:         
   20          ** Modified date:
   21          ** Version:             
   22          ** Descriptions:
   23          **
   24          **------------------------------------------------------------------------------------------------------
   25          ** Modified by: 
   26          ** Modified date:
   27          ** Version: 
   28          ** Descriptions: 
   29          **
   30          ********************************************************************************************************/
   31          
   32          /**************************************************************************************
   33          PLL1:           USB device PLL clock
   34          
   35          P0.23:          VBUS — Indicates the presence of USB bus power.
   36          P0.31:          UP_LED  --- USB Good Link LED indicator. or 
   37                          CONNECT --- signal used to switch an external 1.5K resistor under software control   
   38          P0.26(Pin 10):  USB D+   
   39          P0.27(Pin 11):  USB D-
   40          
   41          USB Interrupt VIC = 22
   42          **************************************************************************************/
   43          
   44          //#include  "config.h"
   45          #include  "LPC214x.h"
   46          #include  "USBConfig.h"
   47          #include  "USBCI.h"
   48          #include  "USBHAL.h"
   49          #include "target.h"
   50          /********************************************************************************************************
             -***********
   51          ** 函数名称: USB_ConfigPll                      Name:     USB_ConfigPll
   52          ** 功能描述: 配置 USB 设备控制器的时钟          Function: Config the clock of USB device controller 
   53          ** 注    意: PLL的输出必须是 12MHZ 的整数倍,    Note:     The output frequency of the PLL must the Multiplier of
             - 12MHZ,
   54                       而且必须是 2 倍以上.                         and it must be above 2 times.
   55          *********************************************************************************************************
             -***********/
   56          void USB_ConfigPll(void)
ARM COMPILER V2.53,  USBHAL                                                                28/06/07  09:54:11  PAGE 2   

   57          {
   58   1          /* 外部 Fosc = 12MHz, 配置 PLL1 输出值为 48MHz. Fosc = 12MHz, Configure PLL1 (USB PLL) for 48 MHz. */
   59   1          PLL1CFG = 0x23;                                         /* P = 2, M = 4 */
   60   1          PLL1CON = 0x1;                                          /* Enable PLL1 */
   61   1          PLL1FEED = 0xAA;                                        
   62   1          PLL1FEED = 0x55;                                        /* PLL Feed */
   63   1          
   64   1          while((PLL1STAT & 0x400) == 0);                         /* 等待 PLL1 锁定 */
   65   1        
   66   1          PLL1CON = 0x3;                                          /* Enable and connect*/
   67   1          PLL1FEED = 0xaa;                                        
   68   1          PLL1FEED = 0x55;                                        /* PLL Feed part 2 */
   69   1      }
   70          
   71          
   72          /********************************************************************************************************
             -***********
   73          ** 函数名称: USB_InitHareware                   Name:     USB_InitHareware
   74          ** 功能描述: 初始化 USB 设备控制器硬件          Function: Initialize the hardware of USB device controller 
   75          *********************************************************************************************************
             -***********/
   76          void USB_InitHareware(void)
   77          {   
   78   1      
   79   1          PCONP |= 0x80000000;                                    /* 给USB控制器提供电源    power on USB controller */
   80   1          USB_ConfigPll();                                        /* 配置USB时钟            config USB clock */
   81   1      
   82   1      //  PINSEL1 &= ~(0x03U << 30);      
   83   1      //  PINSEL1 |= (0x02U << 30);                               /* P0.31为SoftConnect引脚 P0.31 is SoftConnect Pin */
   84   1          
   85   1          PINSEL1 &= ~(0x03U << 14);      
   86   1          PINSEL1 |= (0x01U << 14);                               /* P0.23为 Vbus 引脚      P0.23 is Vbus Pin */
   87   1      
   88   1          
   89   1      }
   90          
   91          
   92          /********************************************************************************************************
             -***********
   93          ** 函数名称: USB_USBDevIntConfig                Name:     USB_USBDevIntConfig
   94          ** 功能描述: 配置USB设备控制器的中断            Function: Config the Interrupt of USB device controller 
   95          *********************************************************************************************************
             -***********/
   96          void USB_USBDevIntConfig(void)
   97          {
   98   1          INT32U tmp = EP_SLOW;
   99   1                      
  100   1          // Clears the frame interrupt flag in USBDevIntClr
  101   1          USBDevIntClr = FRAME;                                   /* 禁止同步传输帧中断 */
  102   1      
  103   1          // Enables ep_slow and dev_stat interrupt only in USBDevIntEn 
  104   1          USBDevIntEn = tmp;                                      /* 使能复位中断, 低速中断 */
  105   1            
  106   1          // the EP_FAST interrupt is slow priority interrupt
  107   1          USBDevIntPri = 0;                                       /* 使能端点中断为低优先级中断 */
  108   1      
  109   1      #if DMA_ENGINE_EN
                   tmp = (0x01 << 0) + (0x01 << 1);                        /* 使能控制传输端点从机中断 */
               #else
  112   1          tmp = (0x01 << 0) + (0x01 << 1) + (0x01 << 2) + 
  113   1                (0x01 << 3) + (0x01 << 4) + (0x01 << 5);          /* 使能端点 0 ~ 5 从机中断 */
  114   1      #endif
  115   1              
  116   1          // Enable Endpoint Interrupt: endpoint 0 ~ 5
  117   1          USBEpIntEn = tmp;                                       /* 使能物理端点 0 ~ 5中断 */
  118   1          
ARM COMPILER V2.53,  USBHAL                                                                28/06/07  09:54:11  PAGE 3   

  119   1          // Routes all endp ints to the ep_slow int USBEpIntPri
  120   1          USBEpIntPri &= ~tmp;                                    /* 设置物理端点 0 ~ 5为低优先级中断 */
  121   1      
  122   1      }
  123          
  124          /*******************************************************************************************************
  125          **                            End Of File
  126          ********************************************************************************************************/

⌨️ 快捷键说明

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