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

📄 bsp.c

📁 基于 ST 公司的 ARM-7 使用之 uC/OS-II 作业系统,此例程是移植于 STR-750 上的应用,有支援 OS_View 观察器功能,于 IAR EWARM V4.41A 工程编译,而 u
💻 C
📖 第 1 页 / 共 3 页
字号:
/*
*********************************************************************************************************
*
*                                     MICIRUM BOARD SUPPORT PACKAGE
*
*                          (c) Copyright 2003-2006; Micrium, Inc.; Weston, FL
*
*               All rights reserved.  Protected by international copyright laws.
*
*               Knowledge of the source code may NOT be used to develop a similar product.
*
*               Please help us continue to provide the Embedded community with the finest
*               software available.  Your honesty is greatly appreciated.
*********************************************************************************************************
*/

/*
*********************************************************************************************************
*
*                                BOARD SUPPORT PACKAGE (BSP) FUNCTIONS
*
*                                      ST Microelectronics STR750
*                                    on the IAR STR750-SK EvalBoard
*
*
* Filename      : bsp.c
* Version       : V1.00
* Programmer(s) : Brian Nagel
*********************************************************************************************************
*/

/*
*********************************************************************************************************
*                                               INCLUDES
*********************************************************************************************************
*/

#include  <includes.h>

/*
*********************************************************************************************************
*                                               CONSTANTS
*********************************************************************************************************
*/

/*
*********************************************************************************************************
*                                             BOARD IO DEFINES
*********************************************************************************************************
*/

                                                                /* GPIO0 pins                                               */
#define  GPIO_PIN_LED_8             (CPU_INT32U)(GPIO_Pin_0)
#define  GPIO_PIN_LED_9             (CPU_INT32U)(GPIO_Pin_1)
#define  GPIO_PIN_LED_10            (CPU_INT32U)(GPIO_Pin_23)
#define  GPIO_PIN_LED_11            (CPU_INT32U)(GPIO_Pin_26)
#define  GPIO_PIN_LED_12            (CPU_INT32U)(GPIO_Pin_27)
#define  GPIO_PIN_LED_13            (CPU_INT32U)(GPIO_Pin_28)
#define  GPIO_PIN_LED_14            (CPU_INT32U)(GPIO_Pin_29)
#define  GPIO_PIN_LED_15            (CPU_INT32U)(GPIO_Pin_30)
#define  GPIO_PIN_LED_16            (CPU_INT32U)(GPIO_Pin_31)

                                                                /* GPIO1 pins                                               */
#define  GPIO_PIN_LED_1             (CPU_INT32U)(GPIO_Pin_0)
#define  GPIO_PIN_LED_2             (CPU_INT32U)(GPIO_Pin_1)
#define  GPIO_PIN_LED_3             (CPU_INT32U)(GPIO_Pin_2)
#define  GPIO_PIN_LED_4             (CPU_INT32U)(GPIO_Pin_3)
#define  GPIO_PIN_LED_5             (CPU_INT32U)(GPIO_Pin_14)


                                                                /* GPIO2 pins                                               */
#define  GPIO_PIN_LCD_E             (CPU_INT32U)(GPIO_Pin_0)
#define  GPIO_PIN_LCD_RS            (CPU_INT32U)(GPIO_Pin_1)
#define  GPIO_PIN_LCD_LED           (CPU_INT32U)(GPIO_Pin_2)

#define  GPIO_PIN_LED_6             (CPU_INT32U)(GPIO_Pin_3)
#define  GPIO_PIN_LED_7             (CPU_INT32U)(GPIO_Pin_4)

#define  GPIO_PIN_PB1               (CPU_INT32U)(GPIO_Pin_5)
#define  GPIO_PIN_PB2               (CPU_INT32U)(GPIO_Pin_7)
#define  GPIO_PIN_PB3               (CPU_INT32U)(GPIO_Pin_9)
#define  GPIO_PIN_PB4               (CPU_INT32U)(GPIO_Pin_11)

#define  GPIO_MASK_LCD_DATA         (CPU_INT32U)(0xFFFC03FF)
#define  GPIO_PIN_LCD_DATA(data)   ((CPU_INT32U)(((data) & 0x000000FF) << 10))


/*
*********************************************************************************************************
*                                         PROCESSOR IO DEFINES
*********************************************************************************************************
*/

                                                                /* GPIO0 pins                                               */
#define  GPIO_PIN_UART0_RX          (CPU_INT32U)(GPIO_Pin_10)
#define  GPIO_PIN_UART0_TX          (CPU_INT32U)(GPIO_Pin_11)


/*
*********************************************************************************************************
*                                                 MACROS
*********************************************************************************************************
*/


/*
*********************************************************************************************************
*                                            LOCAL DATA TYPES
*********************************************************************************************************
*/


/*
*********************************************************************************************************
*                                             LOCAL VARIABLES
*********************************************************************************************************
*/


/*
*********************************************************************************************************
*                                         LOCAL FUNCTION PROTOTYPES
*********************************************************************************************************
*/

static  void  MRCC_Init             (void);
static  void  IO_Init               (void);
static  void  LED_Init              (void);
static  void  PB_Init               (void);

static  void  Tmr_TickInit          (void);


/*
*********************************************************************************************************
*                                         BSP INITIALIZATION
*
* Description : This function should be called by your application code before you make use of any of the
*               functions found in this module.
*
* Arguments   : none
*********************************************************************************************************
*/

void  BSP_Init (void)
{
    MRCC_Init();                                                /* Initialize the clocks                                    */

    EIC_DeInit();                                               /* Reset the EIC                                            */

    BSP_IntInit();                                              /* Initialize the interrupt vectors and source registers    */
    IO_Init();                                                  /* Initialize the board's I/Os                              */
    LED_Init();                                                 /* Initialize the I/Os for the LED controls                 */
    PB_Init();                                                  /* Initialize the I/Os for the PB  controls                 */

    Tmr_TickInit();                                             /* Initialize the uC/OS-II tick interrupt                   */

    EIC_IRQCmd(ENABLE);                                         /* Enable interrupts                                        */
}



/*
*********************************************************************************************************
*                                     GET THE CLOCK FREQUENCIES
*
* Description: These four functions return the four primary clock frequencies on the STR750:
*                   1) BSP_CPU_ClkFreq returns the system clock (CKSYS)
*                   2) BSP_AHB_ClkFreq returns the AHB    clock (HCLK)
*                   3) BSP_APB_ClkFreq returns the APB    clock (PCLK)
*                   4) BSP_TIM_ClkFreq returns the timer  clock (CKTIM)
*
* Arguments  : none
*
* Returns    : The clock frequency, in Hz.
*********************************************************************************************************
*/

CPU_INT32U  BSP_CPU_ClkFreq (void)
{
    MRCC_ClocksTypeDef      mscc_clocks_struct;


    MRCC_GetClocksStatus(&mscc_clocks_struct);
    return ((CPU_INT32U)(mscc_clocks_struct.CKSYS_Frequency));
}

CPU_INT32U  BSP_AHB_ClkFreq (void)
{
    MRCC_ClocksTypeDef      mscc_clocks_struct;


    MRCC_GetClocksStatus(&mscc_clocks_struct);
    return ((CPU_INT32U)(mscc_clocks_struct.HCLK_Frequency));
}

CPU_INT32U  BSP_APB_ClkFreq (void)
{
    MRCC_ClocksTypeDef      mscc_clocks_struct;


    MRCC_GetClocksStatus(&mscc_clocks_struct);
    return ((CPU_INT32U)(mscc_clocks_struct.HCLK_Frequency));
}

CPU_INT32U  BSP_TIM_ClkFreq (void)
{
    MRCC_ClocksTypeDef      mscc_clocks_struct;


    MRCC_GetClocksStatus(&mscc_clocks_struct);
    return ((CPU_INT32U)(mscc_clocks_struct.CKTIM_Frequency));
}


/*
*********************************************************************************************************
*                                           PB INITIALIZATION
*
* Description : This function initializes the board's PBs.  All PB pins are initialized to input mode.
*
* Arguments   : none
*********************************************************************************************************
*/

static  void  PB_Init (void)
{
    GPIO_InitTypeDef  gpio_init_struct;


    gpio_init_struct.GPIO_Mode = GPIO_Mode_IPD;
    gpio_init_struct.GPIO_Pin  = GPIO_PIN_PB1 | GPIO_PIN_PB2 |
                                 GPIO_PIN_PB3 | GPIO_PIN_PB4 ;
    GPIO_Init(GPIO1, &gpio_init_struct);
}


/*
*********************************************************************************************************
*                                      GET PUSH BUTTON STATUS
*
* Description : This function is used to determine the status of any PB on the board on the board.
*
* Arguments   : pb     is the number of the PB to check
*                      1    return status of PB1
*                      2    return status of PB1
*                      .
*                      4    return status of PB4
*********************************************************************************************************
*/

CPU_BOOLEAN  PB_GetStatus (CPU_INT08U pb)
{
    switch (pb) {
        case 1:
             return (GPIO_ReadBit(GPIO1, GPIO_PIN_PB1) == Bit_SET);
        case 2:
             return (GPIO_ReadBit(GPIO1, GPIO_PIN_PB2) == Bit_SET);
        case 3:
             return (GPIO_ReadBit(GPIO1, GPIO_PIN_PB3) == Bit_SET);
        case 4:
             return (GPIO_ReadBit(GPIO1, GPIO_PIN_PB4) == Bit_SET);
        default:
             return (DEF_FALSE);
    }
}


/*
*********************************************************************************************************
*                                           LED INITIALIZATION
*
* Description : This function initializes the board's LEDs.  All LED pins are initialized to push/pull
*               output mode.
*
* Arguments   : none
*********************************************************************************************************
*/

static  void  LED_Init (void)
{
    GPIO_InitTypeDef  gpio_init_struct;


                                                                /* Initilize LEDs on GPIO0 to push/pull output mode         */
    gpio_init_struct.GPIO_Mode = GPIO_Mode_Out_PP;
    gpio_init_struct.GPIO_Pin  = GPIO_Pin_0  | GPIO_Pin_1  | GPIO_Pin_23 |
                                 GPIO_Pin_26 | GPIO_Pin_27 | GPIO_Pin_28 |
                                 GPIO_Pin_29 | GPIO_Pin_30 | GPIO_Pin_31;
    GPIO_Init(GPIO0, &gpio_init_struct);

                                                                /* Initilize LEDs on GPIO1 to push/pull output mode         */
    gpio_init_struct.GPIO_Mode = GPIO_Mode_Out_PP;
    gpio_init_struct.GPIO_Pin  = GPIO_Pin_0  | GPIO_Pin_1  | GPIO_Pin_2  |
                                 GPIO_Pin_3  | GPIO_Pin_14 ;
    GPIO_Init(GPIO1, &gpio_init_struct);

                                                                /* Initilize LEDs on GPIO2 to push/pull output mode         */
    gpio_init_struct.GPIO_Mode = GPIO_Mode_Out_PP;
    gpio_init_struct.GPIO_Pin  = GPIO_Pin_3  | GPIO_Pin_4  | GPIO_Pin_14 |
                                 GPIO_Pin_18 | GPIO_Pin_19 | GPIO_Pin_2  ;
    GPIO_Init(GPIO2, &gpio_init_struct);
}


/*
*********************************************************************************************************
*                                                 LED ON
*
* Description : This function is used to control any or all the LEDs on the board.
*
* Arguments   : led    is the number of the LED to control
*                      0    indicates that you want to turn on all of the board's LEDs
*                      1    turn on LED1
*                      2    turn on LED2
*                      .
*                     16    turn on LED16
*********************************************************************************************************
*/

void  LED_On (CPU_INT08U  led)
{
    switch (led) {
        case 0:

⌨️ 快捷键说明

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