当前位置:网站首页>Hal library serial port for note taking
Hal library serial port for note taking
2022-07-25 03:13:00 【Poetry does not appeal to the minister】
Serial port settings

Code configuration
#include "dr_debug.h"
// Redirect c Library function printf To serial port , After resetting, you can use printf function
int fputc(int ch, FILE *f)
{
#if DEBUG_ENABLE
while ((DEBUG_USARTx->SR & 0X40) == 0)
{
}
DEBUG_USARTx->DR = (uint8_t)ch;
return ch;
#endif
}
/// Redirect c Library function scanf To serial port , Override backward to use scanf、getchar Such as function
int fgetc(FILE *f)
{
#if DEBUG_ENABLE
while (((DEBUG_USARTx->SR) & 0x20) == 0)
{
}
return (uint8_t)DEBUG_USARTx->DR;
#endif
}
int DEBUG_Info(const char *format, ...)
{
int retval=0;
#if DEBUG_ENABLE
va_list ap;
va_start(ap, format);
printf("DEBUG>");
retval = vprintf(format, ap);
va_end(ap);
#endif
return retval;
}
The header file
#ifndef _DR_DEBUG_H_
#define _DR_DEBUG_H_
#include <stdio.h>
#include <stdarg.h>
#include "main.h"
#include "stm32f1xx_hal.h"
#define DEBUG_ENABLE 1
#define DEBUG_USARTx USART1
int DEBUG_Info(const char *format, ...);
#endif // _DR_DEBUG_H_
边栏推荐
- Dynamic planning of force buckle punch in summary
- Interview question -- event cycle
- Banana pie bpi-m5 toss record (3) -- compile BSP
- Vscode configuration, eslint+prettier combined with detailed configuration steps, standardized development
- Dc-2-range practice
- Beginners must see the markdown User Guide
- Inheritance (prototype)
- Map set learning
- Color space (1) - RGB
- New key points of ES6
猜你喜欢

04 -- two ways of writing el and data

Arduino IDE for raspberry PI Pico development firmware localization installation tutorial

Dynamic planning of force buckle punch in summary

Direct insert sort / Hill sort

Use and introduction of vim file editor

B. Making Towers

JS written test -- regular expression

What should I do when the interface encounters jsonstring

Mid year summary and personal feelings

How is the virtual DOM different from the actual DOM?
随机推荐
Banana pie bpi-m5 toss record (2) -- compile u-boot
IO (1) -io layering
Dynamic planning of force buckle punch in summary
Resolved (the latest version of selenium reported an error) attributeerror: module 'selenium webdriver‘ has no attribute ‘PhantomJS‘
Recursive and non recursive methods are used to realize the first order, middle order and second order traversal of binary tree respectively
JS written test question -- promise, setTimeout, task queue comprehensive question
ES6 - study notes
JS written test question -- deep copy of object
List type to string type
The latest interview questions and analysis of software testing in 2022
PHP record
Wechat H5 record
JS foundation -- task queue and event loop
Consistent hash, virtual node, bloom filter
Riotboard development board series notes (6) -- buildreoot building system image
mysql_ User table_ Field meaning
Daily three questions 7.16
Enter an integer and a binary tree
Method of adding kernel in Jupiter notebook
Inheritance (prototype)