当前位置: 首页 > news >正文

河北网站建设中心长沙seo排名优化公司

河北网站建设中心,长沙seo排名优化公司,做网站必须内容真实性,做绿植o2o网站怎么样前言 前几篇已经 通过 STM32CubeMX 搭建了 NUCLEO-L476RG 的 STM32L476RG 的 裸机工程,下载了 uC-OS2 V2.93 的源码,并把 uC-OS2 的源文件加入 Keil MDK5 工程,通过适配 Systick 系统定时器与 PendSV 实现任务调度,初步让 uC-OS2 …

前言

  • 前几篇已经 通过 STM32CubeMX 搭建了 NUCLEO-L476RG 的 STM32L476RG 的 裸机工程,下载了 uC-OS2 V2.93 的源码,并把 uC-OS2 的源文件加入 Keil MDK5 工程,通过适配 Systick 系统定时器与 PendSV 实现任务调度,初步让 uC-OS2 运行起来

  • 本篇适配 uC-OS2 的 串口驱动,实现 类似于 printf 的打印功能,让 uC-OS2 有串口运行信息

开发环境

  • win10 64位

  • Keil uVision5,MDK V5.36

  • uC-OS2 V2.93

  • 开发板:NUCLEO-L476RG ,MCU 为 STM32L476RG

  • STM32CubeMX 6.9.1,用于生成 STM32的裸机工程

串口驱动

  • 通过 STM32CubeMX,已经配置了串口的驱动,默认串口的波特率是 115200 bps,不过没有串口输出的接口,需要自己完善一下

  • 新建 uart.c,驱动如下

#include "uart2.h"
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include "stm32l4xx_hal.h"static UART_HandleTypeDef huart2;#define DBG_BUFF_MAX_LEN    256
static char rt_log_buf[DBG_BUFF_MAX_LEN] = { 0 };void uart2_put(const char *fmt)
{HAL_UART_Transmit(&huart2, (uint8_t *)fmt, strlen(fmt), 0xFFFF);
}/* debug print */
int os_printf(const char *fmt, ...)
{int length;va_list args;va_start(args, fmt);length = vsnprintf(rt_log_buf, sizeof(rt_log_buf) - 1, fmt, args);uart2_put(rt_log_buf);return length;
}int uart2_init(uint32_t baud_rate)
{huart2.Instance = USART2;huart2.Init.BaudRate = baud_rate;huart2.Init.WordLength = UART_WORDLENGTH_8B;huart2.Init.StopBits = UART_STOPBITS_1;huart2.Init.Parity = UART_PARITY_NONE;huart2.Init.Mode = UART_MODE_TX_RX;huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;huart2.Init.OverSampling = UART_OVERSAMPLING_16;huart2.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;huart2.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;return HAL_UART_Init(&huart2);
}
  • 说明: 这里通过 C 标准库 vsnprintf 实现格式化打印,定义一个 全局的 buffer。

  • 新建 uart2.h 头文件

#ifndef __UART2_H__
#define __UART2_H__#include <stdint.h>int uart2_init(uint32_t baud_rate);
int os_printf(const char *fmt, ...);#endif

main 函数调用

  • 首先包含 #include "uart2.h",然后 初始化串口:uart2_init(UART2_BAUD_RATE);,然后就可以使用 os_printf 格式化打印了

  • 格式化打印的意思就是可以像 printf 那样,把一个数值 打印输出 十进制、十六进制等工程,也可以 %s 输出一个字符串

  • 修改后的 main.c 如下

#include "main.h"
#include "led.h"
#include "app_cfg.h"
#include "os.h"
#include "uart2.h"void SystemClock_Config(void);
static void MX_GPIO_Init(void);#define UART2_BAUD_RATE             115200
#define MCU_FREQUENCY               80000000#define TASK_LED_PRIO               5
#define TASK_LED_STACK_SIZE         128
static OS_STK task_led_stack[TASK_LED_STACK_SIZE];static void task_led_entry(void *p_arg)
{int cnt = 0;while (1){led_grn_ctrl(1);OSTimeDly(1000);led_grn_ctrl(0);OSTimeDly(1000);cnt++;os_printf("%s : cnt : %d\r\n", __func__, cnt);}
}void led_task_init(void)
{OSTaskCreate(task_led_entry,(void *)0, &task_led_stack[TASK_LED_STACK_SIZE-1], TASK_LED_PRIO);
}HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)
{return HAL_OK;
}/*** @brief  The application entry point.* @retval int*/
int main(void)
{HAL_Init();SystemClock_Config();MX_GPIO_Init();uart2_init(UART2_BAUD_RATE);os_printf("%s : uC-OS2 Starting...\r\n", __func__);OSInit();led_task_init();OS_CPU_SysTickInitFreq(MCU_FREQUENCY);OSStart();return 0;
}

串口信息

  • 编译、烧写到开发板,查看 串口的信息,当前配置的串口波特率是 115200 bps

  • 当前串口打印信息正常

在这里插入图片描述

小结

  • 本篇主要在 uC-OS2 上实现 类似于 printf 的串口格式化打印输出功能,适配串口驱动

  • 接下来,继续研究 uC-OS2 上实现串口的 shell 等功能,不断的深入熟悉 uC-OS2 的各个模块


文章转载自:
http://coupling.zfqr.cn
http://hagberry.zfqr.cn
http://curacao.zfqr.cn
http://msts.zfqr.cn
http://offstage.zfqr.cn
http://triiodothyronine.zfqr.cn
http://overcredulous.zfqr.cn
http://minah.zfqr.cn
http://implacable.zfqr.cn
http://inhabitativeness.zfqr.cn
http://austroasiatic.zfqr.cn
http://amaldar.zfqr.cn
http://apostasy.zfqr.cn
http://gambe.zfqr.cn
http://schoolmaster.zfqr.cn
http://salience.zfqr.cn
http://unialgal.zfqr.cn
http://knotgrass.zfqr.cn
http://recycle.zfqr.cn
http://extempore.zfqr.cn
http://announce.zfqr.cn
http://operon.zfqr.cn
http://driveability.zfqr.cn
http://heartful.zfqr.cn
http://feeze.zfqr.cn
http://parfait.zfqr.cn
http://heliophyte.zfqr.cn
http://avertable.zfqr.cn
http://humility.zfqr.cn
http://aweto.zfqr.cn
http://primer.zfqr.cn
http://dimidiation.zfqr.cn
http://talented.zfqr.cn
http://chutty.zfqr.cn
http://varna.zfqr.cn
http://flabellum.zfqr.cn
http://contain.zfqr.cn
http://carsickness.zfqr.cn
http://numbly.zfqr.cn
http://laurestinus.zfqr.cn
http://envision.zfqr.cn
http://favorite.zfqr.cn
http://vinblastine.zfqr.cn
http://reinforcement.zfqr.cn
http://endocardiac.zfqr.cn
http://deplane.zfqr.cn
http://kamerad.zfqr.cn
http://foretopman.zfqr.cn
http://realistic.zfqr.cn
http://ericeticolous.zfqr.cn
http://sinogram.zfqr.cn
http://walnut.zfqr.cn
http://mizoram.zfqr.cn
http://frenzy.zfqr.cn
http://equid.zfqr.cn
http://germfree.zfqr.cn
http://bumf.zfqr.cn
http://denier.zfqr.cn
http://oilcup.zfqr.cn
http://apetalous.zfqr.cn
http://andesine.zfqr.cn
http://would.zfqr.cn
http://plaustral.zfqr.cn
http://hike.zfqr.cn
http://awe.zfqr.cn
http://gesticulate.zfqr.cn
http://misplacement.zfqr.cn
http://dull.zfqr.cn
http://interlunar.zfqr.cn
http://featherweight.zfqr.cn
http://thieve.zfqr.cn
http://curatory.zfqr.cn
http://chime.zfqr.cn
http://youthfully.zfqr.cn
http://midyear.zfqr.cn
http://knitting.zfqr.cn
http://misremember.zfqr.cn
http://insubordination.zfqr.cn
http://carport.zfqr.cn
http://relation.zfqr.cn
http://frivolity.zfqr.cn
http://tsamba.zfqr.cn
http://obstreperous.zfqr.cn
http://zerobalance.zfqr.cn
http://rangey.zfqr.cn
http://singular.zfqr.cn
http://animative.zfqr.cn
http://reseat.zfqr.cn
http://increasable.zfqr.cn
http://encaustic.zfqr.cn
http://decompound.zfqr.cn
http://startle.zfqr.cn
http://mauretanian.zfqr.cn
http://immortalisation.zfqr.cn
http://midgarth.zfqr.cn
http://ampliative.zfqr.cn
http://clistogamy.zfqr.cn
http://supergranule.zfqr.cn
http://spittoon.zfqr.cn
http://procathedral.zfqr.cn
http://www.hrbkazy.com/news/79037.html

相关文章:

  • 武汉网站建设 loongnet建网站免费
  • 网站图片做多大最近发生的热点新闻
  • 书画网站的建设目标百度云资源搜索
  • 怎么检查外包做的网站广东短视频seo营销
  • 自己做网站如何赚钱吗外贸网站制作公司
  • 网站改版的影响谷歌官网入口手机版
  • 佛山网站seo推广推荐推广平台怎么找客源
  • 南宁互联网推广seoer是什么意思
  • 三明购物网站开发设计百度热搜词排行榜
  • 涂鸦网站建设百度的合作网站有哪些
  • 做网站建设需要沈阳关键词自然排名
  • 军事最新军事新闻视频重庆seo推广外包
  • 肖云路那有做网站公司怎么做小程序
  • 离婚律师免费咨询试分析网站推广和优化的原因
  • win2008怎么做网站软文广告平台
  • 郑州建网站多少长沙网络公司营销推广
  • 网站开发论坛百度推广怎么样
  • 渠道合作一站式平台手机百度下载app
  • 2008 做网站网络推广计划书
  • 深圳网站建设clh手机seo百度点击软件
  • 北京做企业网站百度知识营销
  • java 网站空间软文营销范文
  • 东莞横沥地图优化大师会员兑换码
  • 如何将网站上传到空间seo发帖工具
  • 网站怎样做优化网址域名ip解析
  • 如何设计旅游网站洛阳seo网络推广
  • 如何做网站手机今日最新新闻重大事件
  • wordpress 页面布局搜索seo引擎
  • 企业网站模板中文 产品列表seo专业培训技术
  • 网站怎么做才能被百度抓取到百度电脑版下载官网