当前位置:网站首页>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_
边栏推荐
- Arduino + si5351 square wave generator
- mysql_ User table_ Field meaning
- Hashcode details
- DOM node type
- Wechat sports field reservation of applet completion works applet graduation design (8) graduation design thesis template
- If there is a segment in the encryption field, are you "bronze" or "King"?
- Color space (1) - RGB
- Enter an integer and a binary tree
- JS foundation -- data
- ECMAScript new features
猜你喜欢

How to use two stacks to simulate the implementation of a queue

JS foundation -- hijacking of this keyword

Arduino IDE for raspberry PI Pico development firmware localization installation tutorial

NVM installation and use

Use reflection to convert RDD to dataframe
![[jailhouse article] certify the uncertified rewards assessment of virtualization for mixed criticality](/img/12/1763571a99e6ef15fb7f9512c54e9b.png)
[jailhouse article] certify the uncertified rewards assessment of virtualization for mixed criticality

Banana pie bpi-m5 toss record (3) -- compile BSP

Use and introduction of vim file editor

Consistent hash, virtual node, bloom filter

Color space (1) - RGB
随机推荐
Method of adding kernel in Jupiter notebook
Riotboard development board series notes (VIII) -- building desktop system
04 -- two ways of writing el and data
File permission management
Beginners must see the markdown User Guide
Vscode copy synchronization plug-in expansion
Wechat sports field reservation of the finished works of the applet graduation project (5) assignment
[Kali's sshd service is enabled]
Domestic edge computing organization and product research
JS foundation -- object static method
mysql_ Create temporary table
DOM operation -- get elements and nodes
Import and export using poi
Node queries the path of all files (files or folders) named filename under the target directory
Define macros in makefile and pass them to source code
Learning notes - talking about the data structure and algorithm of MySQL index and the introduction of index
B. All Distinct
JS written test -- regular expression
JS written test questions -- random numbers, array de duplication
hello csdn