<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

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

          移植ucosII到STM32F103ZE(六)

          作者: 時(shí)間:2016-11-25 來(lái)源:網(wǎng)絡(luò) 收藏
          一、 例程測(cè)試:
          1. 編寫(xiě)includes.h文件
          #ifndef __INCLUDES_H__
          #define __INCLUDES_H__

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

          #include
          #include

          #include "ucos_ii.h"

          #include
          #include

          //#include

          #endif

          2. 編寫(xiě)B(tài)sp.h和Bsp.c文件
          Bsp.h文件,板級(jí)驅(qū)動(dòng)文件。
          #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) ; //使能時(shí)鐘 //根據(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. 編寫(xiě)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]; //開(kāi)開(kāi)辟任務(wù)堆棧
          static OS_STK led1_task_stk[LED1_TASK_STK_SIZE ]; //開(kāi)辟任務(wù)堆棧
          static void systick_init(void); //函數(shù)聲明

          static void systick_init(void)
          {
          RCC_ClocksTypeDef rcc_clocks;
          RCC_GetClocksFreq(&rcc_clocks); //調(diào)用標(biāo)準(zhǔn)庫(kù)函數(shù),獲獲取系統(tǒng)時(shí)鐘。
          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 延時(shí),釋放 CPU 控制權(quán)
          led_off(LED1);
          OSTimeDlyHMSM(0,0,1,0); //1s 延時(shí),釋放 CPU 控制權(quán)
          }
          }

          上一頁(yè) 1 2 下一頁(yè)

          關(guān)鍵詞: 移植ucosIISTM32F103Z

          評(píng)論


          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();