CubeMX+BabyOS 使用方法

MCU:STM32G030F

编译器:MDK

托管工具:Sourcetree

CubeMX创建工程

BabyOS克隆

添加子模块

git submodule add https://gitee.com/notrynohigh/BabyOS.git BabyOS

进入bos文件夹

cd BabyOS/

切换dev 分支

查看当前分支

git branch -a

切换本地分支到dev

git checkout -f dev

修改配置文件路径

将config 文件夹复制出来

b_config.bat 中

set bos_path=../bos

改为

set bos_path=../BabyOS/bos

MDK工程添加BOS代码

cubemx 生成工程编译

把上图文件夹的目录文件添加到MDK中

bos/algorithm
bos/core
bos/drivers
bos/hal
bos/mcu
bos/modules
bos/services
bos/thirdparty
bos/utils
bos/config

 bos/algorithm
bos/core
bos/drivers
bos/hal
bos/mcu
bos/modules
bos/services
bos/thirdparty
bos/utils
bos/config

因为用到的串口printf 勾选 

编译结果

 添加BOS路径

 

添加BOS初始化代码

#include "b_os.h"
  /* USER CODE BEGIN 2 */
	bInit();
  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
		bExec();
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
  }
/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file    stm32g4xx_it.c
  * @brief   Interrupt Service Routines.
  ******************************************************************************
  * @attention
  *
  * Copyright (c) 2024 STMicroelectronics.
  * All rights reserved.
  *
  * This software is licensed under terms that can be found in the LICENSE file
  * in the root directory of this software component.
  * If no LICENSE file comes with this software, it is provided AS-IS.
  *
  ******************************************************************************
  */
/* USER CODE END Header */

/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "stm32g4xx_it.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "b_os.h"



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

  /* USER CODE END SysTick_IRQn 1 */
}

配置 b_config.bat

双击b_config.bat提示没有Python环境

安装Python

安装最新版本Python 3.12.0 

添加环境变量后

这里我们主要配值MCU平台;

这里我们选择串口1,与cubemx 中对应一致。

测试:

常用API

时间片轮询接口

#define BOS_PERIODIC_TASK(pf, ms)                         \
    {                                                     \
        static uint32_t tick##pf = 0;                     \
        if (bHalGetSysTick() - tick##pf > (MS2TICKS(ms))) \
        {                                                 \
            tick##pf = bHalGetSysTick();                  \
            pf();                                         \
        }                                                 \
    }

b_type.h

        宏定义的

                位/字节操作

                函数调用

                对齐操作

                ...

MDK 编码配置

GIT  命令

git status (查看状态,仓库路径,文件改动等)
git add 
git commit -m ‘+信息’
git pull origin dev /master/other
git push  origin dev /master/other

总结

        整体使用起来还是非常容易的;

        就是在添加代码的时候需要需要点点,可能不熟悉这些代码的同学不知道哪些该添加哪些不用添加,这个也很容易 看另外一个example 仓库代码,模仿一下就行;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值