1 Star 0 Fork 36

梁子 / BabyOS_Example

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

BabyOS_Example

移植BabyOS

利用STM32CUBE新建工程

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

生成代码,并使用git初始化

添加git子仓库,拉取BabyOS源码

添加源文件和头文件路径

​ BabyOS\bos\core\src 文件全部添加

​ BabyOS\bos\hal 文件全部添加

​ BabyOS\bos\drivers\src 使用到的文件添加,本次实验都没使用到因此为空

​ 添加头文件路径

配置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

实现void bLogOutput(void *p)函数

void bLogOutput(void *p)
{
    HAL_UART_Transmit(&huart1, p, strlen(p), 0xffff);    
}

测试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/changlizhineng/BabyOS_Example.git
git@gitee.com:changlizhineng/BabyOS_Example.git
changlizhineng
BabyOS_Example
BabyOS_Example
master

搜索帮助