- #ifndef MicroLIB//没有在MDK中打上MicroLIB对勾的话 执行下面的数据
- #pragma import(__use_no_semihosting)//这句话的意思是不调用半主机模式
- struct __FILE
- {
- int handle;
- };
- FILE __stdout;
- _sys_exit(int x)//避免使用半主机模式
- {
- x = x;
- }
- int fputc(int ch,FILE *f)//重新定义fputc函数使其输出到串口上
- {
- while(USART_GetFlagStatus(USART1,USART_FLAG_TC) == RESET)//等待发送成功
- {}
- USART_SendData(USART1,(uint8_t) ch);//发送数据
- return ch;
- }
- 在这里希望大神能想详细讲解一下#ifndef 到 #endif之间的东西,谢谢。
- int ferror(FILE *f)
- {
- return EOF;
- }
- #endif
- #ifdef USE_FULL_ASSERT
- /*************
- 如果你定义了USE_FULL_ASSERT
- 就可以在assert_failed,加入:
- printf("Wrong parameters value: file %s on line %d\r\n", file, line);
- 就可以使用assert_param(expr) 来判断当前参数是够正确,如果不正确,就会打印出错的文件,以及出错的行。
- 这样就可以方面调试信息了。
- *********/
- void assert_failed(uint8_t* file,uint32_t line)//输出错误信息
- {
- printf("Wrong parameters value: file %s on line %d\r\n",file,line);
- while(1)
- {
- }
- }
- #endif
复制代码
|