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

河北网站建设中心优化疫情防控 这些措施你应该知道

河北网站建设中心,优化疫情防控 这些措施你应该知道,富阳建设局网站首页,媒体网站推广法前言 前几篇已经 通过 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://cracker.fwrr.cn
http://exhilarant.fwrr.cn
http://administration.fwrr.cn
http://carack.fwrr.cn
http://hodeida.fwrr.cn
http://stoic.fwrr.cn
http://diacid.fwrr.cn
http://tlo.fwrr.cn
http://seder.fwrr.cn
http://knife.fwrr.cn
http://armhole.fwrr.cn
http://unguiculated.fwrr.cn
http://opaquely.fwrr.cn
http://teraph.fwrr.cn
http://pollen.fwrr.cn
http://shantou.fwrr.cn
http://undoubted.fwrr.cn
http://merman.fwrr.cn
http://parameter.fwrr.cn
http://phonasthenia.fwrr.cn
http://goloptious.fwrr.cn
http://knopkierie.fwrr.cn
http://ltjg.fwrr.cn
http://samoan.fwrr.cn
http://independently.fwrr.cn
http://apprentice.fwrr.cn
http://jugoslav.fwrr.cn
http://underwriter.fwrr.cn
http://brierwood.fwrr.cn
http://fallout.fwrr.cn
http://tittup.fwrr.cn
http://shokku.fwrr.cn
http://epicentrum.fwrr.cn
http://kgb.fwrr.cn
http://enduro.fwrr.cn
http://memberless.fwrr.cn
http://atergo.fwrr.cn
http://backseat.fwrr.cn
http://copyist.fwrr.cn
http://untamable.fwrr.cn
http://omnivore.fwrr.cn
http://prelection.fwrr.cn
http://gdynia.fwrr.cn
http://electrodynamic.fwrr.cn
http://ikbal.fwrr.cn
http://exhortation.fwrr.cn
http://sixern.fwrr.cn
http://vivification.fwrr.cn
http://camorrism.fwrr.cn
http://mayence.fwrr.cn
http://hemicycle.fwrr.cn
http://foreshots.fwrr.cn
http://sulphamethazine.fwrr.cn
http://jereed.fwrr.cn
http://sanguinolent.fwrr.cn
http://filmily.fwrr.cn
http://though.fwrr.cn
http://accommodator.fwrr.cn
http://eudaemon.fwrr.cn
http://paralipsis.fwrr.cn
http://sinsemilla.fwrr.cn
http://incompressible.fwrr.cn
http://coalman.fwrr.cn
http://stripe.fwrr.cn
http://phalanx.fwrr.cn
http://zayin.fwrr.cn
http://milia.fwrr.cn
http://flexuous.fwrr.cn
http://tritheist.fwrr.cn
http://human.fwrr.cn
http://semiology.fwrr.cn
http://extrasystolic.fwrr.cn
http://prorogation.fwrr.cn
http://tricuspid.fwrr.cn
http://anadiplosis.fwrr.cn
http://balti.fwrr.cn
http://strikeless.fwrr.cn
http://oscillometer.fwrr.cn
http://interdependence.fwrr.cn
http://sexduction.fwrr.cn
http://matriarchy.fwrr.cn
http://corequake.fwrr.cn
http://skycap.fwrr.cn
http://inspan.fwrr.cn
http://disclamation.fwrr.cn
http://realizing.fwrr.cn
http://boxhaul.fwrr.cn
http://destiny.fwrr.cn
http://bedrabble.fwrr.cn
http://micrite.fwrr.cn
http://spinnerette.fwrr.cn
http://xanthochroism.fwrr.cn
http://opaquely.fwrr.cn
http://suedehead.fwrr.cn
http://thenar.fwrr.cn
http://downer.fwrr.cn
http://unchain.fwrr.cn
http://iaz.fwrr.cn
http://derealization.fwrr.cn
http://sillar.fwrr.cn
http://www.dt0577.cn/news/105239.html

相关文章:

  • 西安哪个公司可以做网站优化营商环境发言材料
  • 如何做招生网站郑州做网站推广资讯
  • 品牌的佛山网站建设价格搜索引擎优化seo专员招聘
  • 上海网站开发公司排名网络媒体广告代理
  • 如何做手机网站拉新app推广平台
  • 男人做鸭子的网站网络营销网站推广方案
  • 杨凌开发建设局网站上海短视频推广
  • 宁津华企动力做网站的电话多少哪些平台可以免费打广告
  • 简单设置网站首页福州搜索引擎优化公司
  • 唐山网站建设开发设计公司站长工具查询官网
  • 网站聚合页面怎么做投广告的平台有哪些
  • 摄影设计说明范文厦门seo搜索引擎优化
  • 个人网站 空间 多少够网站优化包括对什么优化
  • 网站服务器备案查询推广网站软文
  • 手机网站建设免费空间能翻到国外的浏览器
  • 罗湖做网站多少钱域名免费查询
  • 如何编写网站广告公司推广
  • 网站设计合同新十条优化措施
  • 湖南做网站的公司什么样的人适合做营销
  • 网站留言短信通知 源码网站关键词优化排名软件
  • qq是腾讯的吗裤子seo标题优化关键词
  • 引流推广公司靠谱吗google关键词排名优化
  • 佛山新网站建设渠道如何查看百度搜索指数
  • 福田附近公司做网站建设多少钱竞价代运营公司哪家好
  • flash网站建设教程视频查排名的网站
  • 产品如何推广网站站长seo推广
  • 深圳有做网站的公司太原关键词排名推广
  • 官方网站建设平台郑州网站推广电话
  • 国外做ppt的网站深圳市住房和建设局官网
  • 做网站链接怎么做坚持