1 Star 0 Fork 36

侯文宾 / BabyOS_Example

forked from bean / BabyOS_Example 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

BabyOS_Example

移植BabyOS

利用STM32CUBE新建工程

选择调试接口、选择外部时钟,使能UART1

生成代码并添加BabyOS源码

本次试验源码提交节点:

https://gitee.com/notrynohigh/BabyOS/tree/0ee92ee442f1ae1809a2d0e85cf926191d849ae5

添加源文件和头文件路径

bos/core/ 核心文件全部添加至工程

bos/config/ 配置文件及设备列表文件,添加至工程

bos/driver/ 选择需要的驱动添加至工程

bos/hal/hal/ 硬件抽象层,将用到的接口添加至工程,根据具体平台进行修改

bos/hal/utils/ 底层实用代码,添加至工程

bos/modules/ 功能模块,全部添加至工程

bos/thirdparty/ 第三方开源代码,将用到的添加至工程

添加头文件

配置b_config.h

本次实验测试b_log功能,因此只需要打开debug功能

编辑b_device_list.h

由于本次实验不需要注册任何设备,则取消B_DEVICE_REG(null, bNullDriver, "null")的注释

添加bHalIncSysTick()

void SysTick_Handler(void)
{
  /* USER CODE BEGIN SysTick_IRQn 0 */
  bHalIncSysTick();
  /* USER CODE END SysTick_IRQn 0 */
  HAL_IncTick();
  HAL_SYSTICK_IRQHandler();
  /* USER CODE BEGIN SysTick_IRQn 1 */

  /* USER CODE END SysTick_IRQn 1 */
}

包含头文件b_os.h

添加bInit()和bExec()

  //......
  /* USER CODE BEGIN WHILE */
  bInit();
  while (1)
  {
      bExec();
  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */

  }
  /* USER CODE END 3 */

移植完成,开始测试b_log

b_hal.h中定义输出log的串口号

#define HAL_LOG_UART                    B_HAL_UART_1

测试b_log b_log_i b_log_w b_log_e

  /* USER CODE BEGIN WHILE */
  bInit();
  b_log("b_log\r\n");
  b_log_i("b_log_i\r\n");
  b_log_w("b_log_w\r\n");
  b_log_e("b_log_e\r\n");
  while (1)
  {
      bExec();
  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */

  }
  /* USER CODE END 3 */

实验效果:


BabyOS master分支 https://gitee.com/notrynohigh/BabyOS

BabyOS教程更新会在公众号推送:

MIT License Copyright (c) 2020 bean Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

为BabyOS增加使用例子,每一个分支对应一篇教程,请根据需要切换至对应分支 展开 收起
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/houwenbin2019/BabyOS_Example.git
git@gitee.com:houwenbin2019/BabyOS_Example.git
houwenbin2019
BabyOS_Example
BabyOS_Example
master

搜索帮助