在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,91精品国产91免费

  • <object id="1jp1h"></object>
    <address id="1jp1h"><nav id="1jp1h"></nav></address>
  • <label id="1jp1h"></label>
    
    

    <bdo id="1jp1h"></bdo>

    新聞中心

    EEPW首頁 > 嵌入式系統(tǒng) > 設計應用 > 移植ucosII到STM32F103ZE(六)

    移植ucosII到STM32F103ZE(六)

    作者: 時間:2016-11-25 來源:網(wǎng)絡 收藏
    一、 例程測試:
    1. 編寫includes.h文件
    #ifndef __INCLUDES_H__
    #define __INCLUDES_H__

    //#include
    //#include
    //#include
    //#include
    //#include

    #include
    #include

    #include "ucos_ii.h"

    #include
    #include

    //#include

    #endif

    2. 編寫B(tài)sp.h和Bsp.c文件
    Bsp.h文件,板級驅(qū)動文件。
    #ifndef __BSP_H
    #define __BSP_H

    #define GPIO_PORT_LED GPIOF //根據(jù)自己板子情況修改
    #define RCC_GPIO_PORT_LED RCC_APB2Periph_GPIOF //根據(jù)自己板子情況修改
    #define GPIO_Pin_led1 GPIO_Pin_6 //根據(jù)自己板子情況修改
    #define GPIO_Pin_led2 GPIO_Pin_7 //根據(jù)自己板子情況修改

    #define LED1 0
    #define LED2 1

    void BSP_Init(void);
    void led_on(uint32_t n);
    void led_off(uint32_t n);

    #endif
    Bsp.c文件
    #include

    static void BSP_LED_Init(void);
    // static void BSP_KEY_Init (void);

    void BSP_Init (void)
    {
    SystemInit();
    BSP_LED_Init();
    // Init_Uart_on_Chip(9600);
    // BSP_KEY_Init();
    }

    static void BSP_LED_Init(void)
    {
    GPIO_InitTypeDef GPIO_InitStructure;

    RCC_APB2PeriphClockCmd(RCC_GPIO_PORT_LED, ENABLE) ; //使能時鐘 //根據(jù)自己板子情況修改

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_led1|GPIO_Pin_led2; //根據(jù)自己板子情況修改
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
    GPIO_Init(GPIO_PORT_LED, &GPIO_InitStructure); //根據(jù)自己板子情況修改
    }

    void led_on(uint32_t n)
    {
    switch (n)
    {
    case LED1: GPIO_SetBits(GPIO_PORT_LED, GPIO_Pin_led1);
    break;
    case LED2: GPIO_SetBits(GPIO_PORT_LED, GPIO_Pin_led2);
    break;
    default:
    break;
    }
    }
    void led_off(uint32_t n)
    {
    switch (n)
    {
    case LED1: GPIO_ResetBits(GPIO_PORT_LED, GPIO_Pin_led1); break;
    case LED2: GPIO_ResetBits(GPIO_PORT_LED, GPIO_Pin_led2); break;
    default: break;
    }
    }
    3. 編寫app_cfg.h和app.c文件
    app_cfg.h

    #define STARTUP_TASK_PRIO 4
    #define LED1_TASK_PRIO 6


    #define STARTUP_TASK_STK_SIZE 80

    #define LED1_TASK_STK_SIZE 80
    app.c文件
    #include
    static OS_STK startup_task_stk[STARTUP_TASK_STK_SIZE]; //開開辟任務堆棧
    static OS_STK led1_task_stk[LED1_TASK_STK_SIZE ]; //開辟任務堆棧
    static void systick_init(void); //函數(shù)聲明

    static void systick_init(void)
    {
    RCC_ClocksTypeDef rcc_clocks;
    RCC_GetClocksFreq(&rcc_clocks); //調(diào)用標準庫函數(shù),獲獲取系統(tǒng)時鐘。
    SysTick_Config(rcc_clocks.HCLK_Frequency / OS_TICKS_PER_SEC); //初始化并使能 SysTick
    //OS_TICKS_PPER_SEC 是在 os_cfg.h 中定義的
    }

    static void led1_task (void *p_arg)
    {
    p_arg=p_arg; //防止編譯器產(chǎn)生警告
    while(1)
    {

    led_on(LED1);
    OSTimeDlyHMSM(0,0,1,0); //1s 延時,釋放 CPU 控制權
    led_off(LED1);
    OSTimeDlyHMSM(0,0,1,0); //1s 延時,釋放 CPU 控制權
    }
    }

    上一頁 1 2 下一頁

    評論


    技術專區(qū)

    關閉