当前位置:网站首页>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_
边栏推荐
- Hashcode details
- Resolve the error: org.apache.ibatis.binding.bindingexception
- Vscode configuration, eslint+prettier combined with detailed configuration steps, standardized development
- The latest interview questions and analysis of software testing in 2022
- Wechat sports field reservation of applet completion works applet graduation design (8) graduation design thesis template
- 05 - MVVM model
- [jailhouse article] certify the uncertified rewards assessment of virtualization for mixed criticality
- New features commonly used in ES6
- Vulntarget vulnerability shooting range -vulntarget-b
- Download the jar package of jsqlparser and PageHelper
猜你喜欢

JS foundation -- JSON

JS foundation -- object static method

Import and export using poi

Technical experts from large factories: Thoughts on cloud nativity and software supply chain security
![[Kali's sshd service is enabled]](/img/1b/180534d51049177254e30c4b783eba.png)
[Kali's sshd service is enabled]

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

Review all frames before sum of SSM frames

New key points of ES6

Experiment 4 CTF practice

Riotboard development board series notes (VIII) -- building desktop system
随机推荐
Learning record Xi
Color space (1) - RGB
[stm32f103rct6] can communication
Backtracking to solve combinatorial problems
Wechat H5 record
# CF #807 Div.2(A - D)
mysql_ Record the executed SQL
Keras load history H5 format model error: attributeerror 'STR' object has no attribute 'decode‘
How to use two stacks to simulate the implementation of a queue
2022-07-19: all factors of F (I): I are added up after each factor is squared. For example, f (10) = 1 square + 2 square + 5 square + 10 square = 1 + 4 + 25 + 100 = 130.
04 -- two ways of writing el and data
Print the common part of two ordered linked lists
Merge sort / quick sort
Wechat sports field reservation of applet completion works applet graduation design (8) graduation design thesis template
Vscode copy synchronization plug-in expansion
JS written test questions -- random numbers, array de duplication
Solve ''_ Xsrf 'argument missing from post
Win10 -- open the hosts file as an administrator
Function of each layer of data warehouse
Publish the project online and don't want to open a port