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

📄 bsp.c

📁 ucosII 修改移植到 freescale MCF51JM128
💻 C
📖 第 1 页 / 共 2 页
字号:
/***********************************************************************************************************                                                uC/OS-II*                                          The Real-Time Kernel**                             (c) Copyright 2006, Micrium, Inc., Weston, FL*                                          All Rights Reserved**                                          Freescale MCFQE128*                                         on the DEMOQE128 EVB*                                         Board Support Package** File         : bsp.c* Programmer   : Eric Shufro**********************************************************************************************************/#include  "includes.h"/***********************************************************************************************************                                       CONSTANTS**********************************************************************************************************/#define  PTC_LED_MASK   0x50                                            /* DEMOQE EVB LED bit definitions.                          */#define  PTE_LED_MASK   0x0C                                            /* Note: PTC4 is attached to the onboard accelerometer      */                                                                        /* Note: PTC5 is attached to the SCI transceiver enable     */#define  PTF_LED_MASK   0x22#define  PTD_LED_MASK   0x04                                                                                                                                          /***********************************************************************************************************                                       PROTOTYPES**********************************************************************************************************/static  void  FLL_Init(void);static  void  OSTickISR_Init(void);                                 static  void  LED_Init(void); /***********************************************************************************************************                                       GLOBALS**********************************************************************************************************/static  CPU_INT16U  OSTickCnts;                                         /* Store number of increments of timer for OS tick rate     *//***********************************************************************************************************                                       BSP_Init()** Description: Initialize FLL, OS Ticker, and other basic hardware services.** Arguments  : None.** Returns    : None.** Note(s)    : None.**********************************************************************************************************/void  BSP_Init (void){     SOPT1           = 0x20;                                             /* Disable COP,RSTO, enable STOP,BKGD,RESET                 */     SPMSC1          = 0x00;                                             /* Disable LVD                                              */    SPMSC2          = 0x00;                                             /* Disable power-down modes                                 */ //   SPMSC3          = 0x00;                                             /* Disable LVWIE, low trip points                           */    SCGC1           = 0xFF;                                             /* Enable bus clock to peripherals                          */    SCGC2           = 0xFF;                                             /* Enable bus clock to peripherals                          */    SCGC3           = 0xFF;       // Random number generator accelerator        FLL_Init();                                                         /* Initialize the FLL.                                      */    OSTickISR_Init();                                                   /* Initialize the TPM for use as the OS time tick source    */    LED_Init();                                                         /* Initialize onboard LEDs                                  */}/***********************************************************************************************************                                       FLL_Init()** Description : This function is used to initialize the FLL. The CPU clock frequency is configured*               to 39.85MHz and the BUS Frequency is consequently set to 19.925MHz. *               * Arguments   : None.*               * Returns     : None.** Notes       : 1) The CPU clock (ICSOUT) is derived from an internal oscillator. The internal oscillator*                  frequency may be either 31250Hz when manually trimmed, or 32768Hz when DMX32 within *                  ICSSC is set. Other trimmed values are possible and should be configured within*                  bsp.h by setting the macro BSP_INT_REF_FREQ accordingly.*               2) ICSOUT MUST NOT exceed 59.77MHz (See Note 3)*               3) The peripheral bus frequency (Fbus) equals (ICSOUT / BDIV / 2). Fbus MUST NOT exceed*                  10MHz when VDD is less than 2.1 volts. If VDD is greater than 2.1 volts, then Fbus*                  must not exceed 25.165MHz.*               4) See page 241, Table 12-7 'DCO frequency range' in MCF51QE128_Reference_Manual.pdf**********************************************************************************************************/static  void  FLL_Init (void){    MCGC1 = 0x06;    MCGC4 = 0x02;   // 48MHZ        while (!MCGSC_LOCK);}/***********************************************************************************************************                                       BSP_CPU_ClkFreq()** Description : The function may be used to determine the value of ICSOUT** Arguments   : None.* * Returns     : The CPU operating frequency in Hz, or 0 if unknown. ** Note(s)     : 1) The CPU BUS frequency may be computed during runtime by dividing the *                  return value of this function by 2.*               2) This function does not account for oscillator trimming and assumes the oscillator*                  frequency is defined in bsp.h.**********************************************************************************************************/CPU_INT32U  BSP_CPU_ClkFreq (void){    CPU_INT32U  ext_ref_freq;    CPU_INT32U  ics_out;    CPU_INT16U  rdiv;    CPU_INT16U  bdiv;    CPU_INT16U  fll_factor;    CPU_INT08U  drs;    CPU_INT08U  reg_val;                ics_out                 =   0;                                      /* Initialize the return value to 0                         */    ics_out = 48000000;    return  (ics_out);                                                  /* Return the CPU operating frequency                       */}/***********************************************************************************************************                                     DISABLE ALL INTERRUPTS** Description : This function disables all interrupts from the interrupt controller.** Arguments   : none**********************************************************************************************************/void  BSP_IntDisAll (void){#if OS_CRITICAL_METHOD == 3    CPU_SR  cpu_sr;#endif    OS_ENTER_CRITICAL();                                                /* Disable all interrupts                                   */}/***********************************************************************************************************                                       LED_Init()** Description : Initialize the data direction registers for Port C and Port E both of which have*               LEDs attached to their I/O pins on the DEMOQE EVB.** Arguments   : None.** Returns     : None.** Notes       : None.**********************************************************************************************************/void  LED_Init (void){       LED_Off(0);                                                         /* Ensure LEDs I/O are initialized with LEDs off            */    PTCDD      |=   PTC_LED_MASK;                                       /* Configure Port C LED bits as outputs                     */    PTEDD      |=   PTE_LED_MASK;                                       /* Configure Port E LED bits as outputs                     */    PTFDD      |=   PTF_LED_MASK;    PTDDD      |=   PTD_LED_MASK;}/***********************************************************************************************************                                       LED_Toggle()** Description : Toggle an LED Pin** Arguments   : led   0 = Toggle ALL LEDs*                     1 = Toggle LED 1*                     2 = Toggle LED 2*                     ...*                     8 = Toggle LED 8** Returns     : None.** Notes       : None.**********************************************************************************************************/void  LED_Toggle (CPU_INT08U led){    if (led > 8) {        return;                                                         /* Argument checking, return if led > 8                     */        }    }

⌨️ 快捷键说明

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