void UART_Putc(char c)
{
if (c == 'n')
*(unsigned int *)(UART0_ADDR + 0X00) = 'r';
delay_x(0x800);
*(unsigned int *)(UART0_ADDR + 0X00) = c;
}
unsigned int val_i=0;
void UART_Print(const char *str,...)
{
va_list unnamed_p;
char *sval;
unsigned int tmp=0;
va_start( unnamed_p, str);
while (*str)
{
//
if(*str=='%')
{
switch(*++str)
{
case 'd'://Output decimal
break;
case 'c'://Output character
break;
case 's'://Output string
for(sval = va_arg(unnamed_p,char*);*sval;sval++)
{
UART_Putc(*sval);
}
str++;
break;
case 'X'://Output 16 decimal
case ' x'://Output 16 decimal
val_i = va_arg(unnamed_p,unsigned int);
//
UART_Putc('0');delay_x(0X800);
UART_Putc('x');delay_x(0X800);
for(i=0; i<8;i++)
{
delay_x(0X800);
tmp = val_i>>(4*(7-i));
val_i = val_i&(~(0xff<<(4*(7-i))));
//
if(tmp<10)
UART_Putc('0'+tmp);
else
UART_Putc('A'+tmp-10);
//
}
//
str++;
break;
default://output character
break;
}
}
//
UART_Putc( *str++);
}
}
Previous article:A brief analysis of variable parameter functions in C language (taking the implementation of the printf() function in the Arm program as an example)
Next article:RO base and RW base in ADS1.2
Recommended ReadingLatest update time:2024-11-16 09:34
- Popular Resources
- Popular amplifiers
- MCU C language programming and Proteus simulation technology (Xu Aijun)
- Internet of Things Development Technology Based on C Language (Edited by Gao Song)
- Foundations of ARM64 Linux Debugging, Disassembling, and Reversing Analyze Code, Understand Stack Me
- Operating System Principles, Implementation and Practice (Li Zhijun, Liu Hongwei)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- msp430f5529lp driver problem
- [Evaluation of domestic FPGA Gaoyun GW1N-4 series development board]——3. Turn on a lamp hello_led
- When opening the project, it prompts that there is no RAA305190GBM_common.xml
- View the sea - View southern Zhejiang - View Cangnan
- Could you please help me with how to calculate the VGS of this current mirror? Thank you very much!
- GigaDevice's new GD32F470xx series with TFT and Ethernet port
- MicroPython adds support for operator @
- I would like to ask you about the ODB protocol dedicated chip
- 【GD32L233C-START Review】1. Unboxing
- Generators: Pulse, Pattern and Arbitrary Waveform (AWG)