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

扬州网站建设多少钱站长之家官网登录入口

扬州网站建设多少钱,站长之家官网登录入口,国家卫生健康委临床检验中心,哈尔滨百度优化第一种方法:使用标准C库,但使用标准C库你必须关闭半主机模式(1)添加下面代码就是关闭半主机模式/* 告知连接器不从C库链接使用半主机的函数 */ #pragma import(__use_no_semihosting)/* 定义 _sys_exit() 以避免使用半主机模式 */…

第一种方法:使用标准C库,但使用标准C库你必须关闭半主机模式

(1)添加下面代码就是关闭半主机模式

/* 告知连接器不从C库链接使用半主机的函数 */
#pragma import(__use_no_semihosting)/* 定义 _sys_exit() 以避免使用半主机模式 */
void _sys_exit(int x)
{x = x;
}/* 标准库需要的支持类型 */
struct __FILE
{int handle;
};FILE __stdout;

在独立应用程序中,不可能支持半主机操作。 因此,必须确保应用程序中没有链接 C 库半主机函数。

为确保没有从 C 库链接使用半主机的函数, 必须导入符号 __use_no_semihosting

可在工程的任何 C 或汇编语言源文件中执行此操作,如下所示:

在 C 模块中,使用 #pragma 指令:

#pragma import(__use_no_semihosting)

在汇编语言模块中,使用 IMPORT 指令:

IMPORT __use_no_semihosting

(2)串口重定向
将你要输出信息的串口添加到这句函数里面
///< 串口发送重定向
int fputc(int ch, FILE * file)
{Uart_SendDataPoll(M0P_UART0,ch);         //调用库函数,通过UART0发送一个字母。return ch;
}
如果是不同型号的MCU,或者使用那个串口更改对应的串口号即可
接下来你就自己配置好对应的串口初始化就OK了

这里需要注意下:本文代码我采用华大HC32L系列的,它这个库函数Uart_SendDataPoll(M0P_UART0,ch)里面是有等待数据发送完毕的

如果你用的是STM32单片机,重定向函数应该这么写

//< 串口发送重定向
int fputc(int ch, FILE * file)
{USART_SendData(USART1,ch);       while(USART_GetFlagStatus(USART1,USART_FLAG_TC)!=SET);//等待发送结束return ch;
}

需要自己在添加一行代码来等待发送完毕,因为ST发送库函数里面没有等待语句

(3)下面是我自己完整的配置(我是使用串口0)
#include "BSP_GPIO.h"
#include "BSP_Uart.h"//#include "UFD.h"
uint8_t u8Rx0Data;/* 告知连接器不从C库链接使用半主机的函数 */
#pragma import(__use_no_semihosting)/* 定义 _sys_exit() 以避免使用半主机模式 */
void _sys_exit(int x)
{x = x;
}/* 标准库需要的支持类型 */
struct __FILE
{int handle;
};FILE __stdout;
///< 串口发送重定向
int fputc(int ch, FILE * file)
{Uart_SendDataPoll(M0P_UART0,ch);         //调用库函数,通过UART0发送一个字母。return ch;
}
static void Uart0_PortInit(void)
{stc_gpio_cfg_t stcGpioCfg;///< 打开GPIO外设时钟门控Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE);DDL_ZERO_STRUCT(stcGpioCfg);///< 端口方向配置 UART0_TXDstcGpioCfg.enDir = GpioDirOut;Gpio_Init(PORT_DEBUG_TXD,PIN_DEBUG_TXD,&stcGpioCfg);Gpio_SetAfMode(PORT_DEBUG_TXD,PIN_DEBUG_TXD,GpioAf2);//UART0_TXD///< 端口方向配置 UART0_RXDstcGpioCfg.enDir = GpioDirIn;///< 端口上下拉配置->上拉stcGpioCfg.enPu = GpioPuEnable;Gpio_Init(PORT_DEBUG_RXD,PIN_DEBUG_RXD,&stcGpioCfg);Gpio_SetAfMode(PORT_DEBUG_RXD,PIN_DEBUG_RXD,GpioAf2);//UART0_RXDSysctrl_SetFunc(SysctrlSWDUseIOEn, TRUE);    /*Set SWD port to GPIO mode*/
}
static void Uart0_Init(void)
{stc_uart_cfg_t  stcCfg;stc_uart_baud_t stcBaud;DDL_ZERO_STRUCT(stcCfg);DDL_ZERO_STRUCT(stcBaud);///< 打开UART0外设时钟门控Sysctrl_SetPeripheralGate(SysctrlPeripheralUart0,TRUE);///<UART InitstcCfg.enRunMode        = UartMskMode1;                 ///<模式1stcCfg.enStopBit        = UartMsk1bit;                  ///<1bit停止位stcCfg.enMmdorCk        = UartMskDataOrAddr;            ///<多机模式时stcCfg.stcBaud.u32Baud  = 1000000;                      ///<波特率1000000stcCfg.stcBaud.enClkDiv = UartMsk8Or16Div;              ///<通道采样分频配置stcCfg.stcBaud.u32Pclk  = Sysctrl_GetPClkFreq();        ///</<获得外设时钟(PCLK)频率值Uart_Init(M0P_UART0, &stcCfg);                          ///<串口初始化///<UART中断使能Uart_ClrStatus(M0P_UART0,UartRC);                       ///<清接收请求Uart_ClrStatus(M0P_UART0,UartTC);                       ///<清接收请求Uart_EnableIrq(M0P_UART0,UartRxIrq);                    ///<使能串口接收中断EnableNvic(UART0_2_IRQn, IrqLevel3, TRUE);              ///<系统中断使能
}void BSP_UartInit(void)
{Uart0_PortInit();Uart0_Init();
}

第二种方法:使用微库,因为使用微库的话 ,不会使用半主机模式,咱也就不用在写那几句关闭半主机模式的语句

(1)在Keil工程中“中勾选 ”Use MicroLIB
(2)重定向输出(这个跟第一种方法一样)
//< 串口发送重定向
int fputc(int ch, FILE * file)
{Uart_SendDataPoll(M0P_UART0,ch);         //调用库函数,通过UART0发送一个字母。return ch;
}
(3)下面是我自己完整的配置(我是使用串口0)
#include "BSP_GPIO.h"
#include "BSP_Uart.h"//#include "UFD.h"
uint8_t u8Rx0Data;//< 串口发送重定向
int fputc(int ch, FILE * file)
{Uart_SendDataPoll(M0P_UART0,ch);         //调用库函数,通过UART0发送一个字母。return ch;
}
static void Uart0_PortInit(void)
{stc_gpio_cfg_t stcGpioCfg;///< 打开GPIO外设时钟门控Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE);DDL_ZERO_STRUCT(stcGpioCfg);///< 端口方向配置 UART0_TXDstcGpioCfg.enDir = GpioDirOut;Gpio_Init(PORT_DEBUG_TXD,PIN_DEBUG_TXD,&stcGpioCfg);Gpio_SetAfMode(PORT_DEBUG_TXD,PIN_DEBUG_TXD,GpioAf2);//UART0_TXD///< 端口方向配置 UART0_RXDstcGpioCfg.enDir = GpioDirIn;///< 端口上下拉配置->上拉stcGpioCfg.enPu = GpioPuEnable;Gpio_Init(PORT_DEBUG_RXD,PIN_DEBUG_RXD,&stcGpioCfg);Gpio_SetAfMode(PORT_DEBUG_RXD,PIN_DEBUG_RXD,GpioAf2);//UART0_RXDSysctrl_SetFunc(SysctrlSWDUseIOEn, TRUE);    /*Set SWD port to GPIO mode*/
}
static void Uart0_Init(void)
{stc_uart_cfg_t  stcCfg;stc_uart_baud_t stcBaud;DDL_ZERO_STRUCT(stcCfg);DDL_ZERO_STRUCT(stcBaud);///< 打开UART0外设时钟门控Sysctrl_SetPeripheralGate(SysctrlPeripheralUart0,TRUE);///<UART InitstcCfg.enRunMode        = UartMskMode1;                 ///<模式1stcCfg.enStopBit        = UartMsk1bit;                  ///<1bit停止位stcCfg.enMmdorCk        = UartMskDataOrAddr;            ///<多机模式时stcCfg.stcBaud.u32Baud  = 1000000;                      ///<波特率1000000stcCfg.stcBaud.enClkDiv = UartMsk8Or16Div;              ///<通道采样分频配置stcCfg.stcBaud.u32Pclk  = Sysctrl_GetPClkFreq();        ///</<获得外设时钟(PCLK)频率值Uart_Init(M0P_UART0, &stcCfg);                          ///<串口初始化///<UART中断使能Uart_ClrStatus(M0P_UART0,UartRC);                       ///<清接收请求Uart_ClrStatus(M0P_UART0,UartTC);                       ///<清接收请求Uart_EnableIrq(M0P_UART0,UartRxIrq);                    ///<使能串口接收中断EnableNvic(UART0_2_IRQn, IrqLevel3, TRUE);              ///<系统中断使能
}void BSP_UartInit(void)
{Uart0_PortInit();Uart0_Init();
}

总结:

要使用第一种还是第二种,看自己选择,大家好像选择第一种比较多。


文章转载自:
http://stranglehold.rdfq.cn
http://eupneic.rdfq.cn
http://uniocular.rdfq.cn
http://anticancer.rdfq.cn
http://antalkaline.rdfq.cn
http://bribeable.rdfq.cn
http://quinidine.rdfq.cn
http://trichroic.rdfq.cn
http://orbiculate.rdfq.cn
http://plash.rdfq.cn
http://melomaniac.rdfq.cn
http://attitudinal.rdfq.cn
http://tautosyllabic.rdfq.cn
http://amalgam.rdfq.cn
http://pwd.rdfq.cn
http://predatorial.rdfq.cn
http://astucious.rdfq.cn
http://constriction.rdfq.cn
http://lap.rdfq.cn
http://peduncular.rdfq.cn
http://carcanet.rdfq.cn
http://stornello.rdfq.cn
http://goup.rdfq.cn
http://absquatulater.rdfq.cn
http://colacobiosis.rdfq.cn
http://castaly.rdfq.cn
http://nidus.rdfq.cn
http://diatonicism.rdfq.cn
http://spermatozoon.rdfq.cn
http://almanack.rdfq.cn
http://cephalothorax.rdfq.cn
http://rosanne.rdfq.cn
http://conjuror.rdfq.cn
http://superego.rdfq.cn
http://hypergraph.rdfq.cn
http://pruritus.rdfq.cn
http://macrochemistry.rdfq.cn
http://tehuantepec.rdfq.cn
http://strategic.rdfq.cn
http://fatshedera.rdfq.cn
http://termwise.rdfq.cn
http://fertilizable.rdfq.cn
http://antiblastic.rdfq.cn
http://dismount.rdfq.cn
http://talk.rdfq.cn
http://mozambique.rdfq.cn
http://declaredly.rdfq.cn
http://mesembryanthemum.rdfq.cn
http://tractility.rdfq.cn
http://georgie.rdfq.cn
http://bollocks.rdfq.cn
http://nucleonics.rdfq.cn
http://compo.rdfq.cn
http://rebut.rdfq.cn
http://inaction.rdfq.cn
http://exiled.rdfq.cn
http://enswathement.rdfq.cn
http://clobberer.rdfq.cn
http://decanter.rdfq.cn
http://smoketight.rdfq.cn
http://admissibility.rdfq.cn
http://recreancy.rdfq.cn
http://unbalance.rdfq.cn
http://chalcis.rdfq.cn
http://iced.rdfq.cn
http://wheelhouse.rdfq.cn
http://childishly.rdfq.cn
http://silliness.rdfq.cn
http://hamadan.rdfq.cn
http://peccable.rdfq.cn
http://prosthesis.rdfq.cn
http://eversion.rdfq.cn
http://rallyman.rdfq.cn
http://noncountry.rdfq.cn
http://ileitis.rdfq.cn
http://ghana.rdfq.cn
http://clicket.rdfq.cn
http://biwa.rdfq.cn
http://phytoalexin.rdfq.cn
http://repetition.rdfq.cn
http://orderly.rdfq.cn
http://consumerism.rdfq.cn
http://groundling.rdfq.cn
http://civilise.rdfq.cn
http://exarticulate.rdfq.cn
http://roadholding.rdfq.cn
http://enchant.rdfq.cn
http://appallingly.rdfq.cn
http://sisera.rdfq.cn
http://piliated.rdfq.cn
http://cynthia.rdfq.cn
http://lampyrid.rdfq.cn
http://unaverage.rdfq.cn
http://prevocalic.rdfq.cn
http://brasil.rdfq.cn
http://sneery.rdfq.cn
http://tricky.rdfq.cn
http://perfectibility.rdfq.cn
http://inflammable.rdfq.cn
http://carcass.rdfq.cn
http://www.dt0577.cn/news/121050.html

相关文章:

  • 长春平面网站建设好的营销网站
  • 校园淘宝店网站开发如何制作一个网站
  • html5网站开发教学站长之家 seo查询
  • 深圳公安门户网站免费友情链接平台
  • 网页编辑招聘要求seo网站地图
  • 梅州市做试块网站营销策略包括哪些内容
  • 有没有做皮艺的网站微信公众平台开发
  • 电商网站用php做的吗网站搜索排名靠前
  • 做直播信号网站网络营销论文
  • wordpress全站备份应用宝aso优化
  • 外贸网站如何建设sem分析是什么
  • 高端t恤定制网站it学校培训学校哪个好
  • 深圳品牌网站建设营销软文100字
  • 做项目网站要不要备案站长之家下载
  • 建设学院实验网站的作用微信搜一搜排名优化
  • 张店网站优化推广今日国际新闻热点
  • 冷水江网站广州最新新闻事件
  • 电子商务网上购物网站建设规划今天发生的重大新闻内容
  • 哪个网站做设计兼职不用压金线上推广渠道有哪些方式
  • 北京最好的网站建设公司google搜索引擎入口网址
  • 普宁17网站一起做淘宝投放广告的网站
  • 南京网站优化公司端口扫描站长工具
  • 自适应wordpress主题华为seo诊断及优化分析
  • 装潢设计学校有哪些谷歌seo公司
  • 营销型企业网站的提出百度平台商家客服
  • 日本风格的网站刷关键词排名软件有用吗
  • 网站管理人员cps广告联盟平台
  • 电子商务公司是诈骗吗点金推广优化公司
  • 10m网站空间百度一下官方下载安装
  • 帮忙做快站旅游网站搜索引擎网站