uart.h
#ifndef __UART4_H__
#define __UART4_H__
#include "/home/ubuntu/2022101/ARM/03-uart4-c/common/include/stm32mp1xx_uart.h"
#define RCC_AHB4_ENSETR (*(volatile unsigned int *)0x50000A28)
#define RCC_APB1_ENSETR (*(volatile unsigned int *)0x50000A00)
#define GPIOB_AHB4_MODER (*(volatile unsigned int *)0x50003000)
#define GPIOG_AHB4_MODER (*(volatile unsigned int *)0x50008000)
#define GPIOB_AFRL (*(volatile unsigned int *)0x50003020)
#define GPIOG_AFRH (*(volatile unsigned int *)0x50008024)
//初始化串口函数
void hal_uart4_init();
//发送一个字符
void put_char(const char str);
//接受一个字符
char get_char();
#endif
uart.c
#include "uart4.h"
//初始化串口函数
void hal_uart4_init()
{
/*******RCC章节初始化******/
//使能RCC_AHB4_ENSETR [gpio-b,gpio-g]寄存器
RCC_AHB4_ENSETR=RCC_AHB4_ENSETR|(0x01<<1); //gpio-b组
RCC_AHB4_ENSETR=RCC_AHB4_ENSETR|(0x01<<6); //gpio-g组
//使能RCC_APB1_ENSETR 寄