初级会员

- 积分
- 96
- 金钱
- 96
- 注册时间
- 2020-9-30
- 在线时间
- 22 小时
|
#include "sys.h"
#include "delay.h"
#include "usart.h"
UART_HandleTypeDef usart1_handler;
//′®¿úÅäÖÃoˉêy
void uart1_init ()
{
usart1_handler.Instance=USART1;
usart1_handler.Init.BaudRate=115200;
usart1_handler.Init.WordLength=USART_WORDLENGTH_8B;
usart1_handler.Init.StopBits=USART_STOPBITS_1;
usart1_handler.Init.HwFlowCtl=UART_HWCONTROL_NONE;
usart1_handler.Init.Mode=UART_MODE_TX_RX; //êÕ·¢Ä£ê½
usart1_handler.Init.Parity= USART_PARITY_NONE;
HAL_UART_Init(&usart1_handler);//μ÷óÿa′®¿ú3õê¼»ˉoˉêy
}
void HAL_UART_MspInit(UART_HandleTypeDef *huart)
{
GPIO_InitTypeDef GPIO_Initure;
if(huart->Instance==USART1)//èç1ûêÇ′®¿ú1£¬½øDD′®¿ú1 MSP3õê¼»ˉ,°å×óĬèÏ′®¿úò»êÇ×óÏ·½usb¿ú£¬
{
__HAL_RCC_GPIOA_CLK_ENABLE(); //ê1ÄüGPIOAê±Öó
__HAL_RCC_USART1_CLK_ENABLE(); //ê1ÄüUSART1ê±Öó
GPIO_Initure.Pin=GPIO_PIN_9; //PA9
GPIO_Initure.Mode=GPIO_MODE_AF_PP; //¸′óÃíÆíìêä3ö
GPIO_Initure.Pull=GPIO_PULLUP; //éÏà-
GPIO_Initure.Speed=GPIO_SPEED_FAST; //¸ßËù
GPIO_Initure.Alternate=GPIO_AF7_USART1; //¸′óÃÎaUSART1
HAL_GPIO_Init(GPIOA,&GPIO_Initure); //3õê¼»ˉPA9
GPIO_Initure.Pin=GPIO_PIN_10; //PA10
HAL_GPIO_Init(GPIOA,&GPIO_Initure); //3õê¼»ˉPA10
}
}
int main(void)
{
u8 buff[]="TEST";
Cache_Enable(); //′ò¿aL1-cache
HAL_Init(); //3õê¼»ˉHAL¿a
Stm32_Clock_Init(432,25,2,9); //éèÖÃê±Öó,216Mhz
//Stm32_Clock_Init(360,25,2,8); //éèÖÃê±Öó,216Mhz
delay_init(216);
uart1_init ();
while (1)
{
HAL_USART_Transmit(&usart1_handler,buff,sizeof(buff),1000);//1.¾ä±ú2.êy¾YÖ¸Õë3.òa·¢Ëí¶àéù¸ö×Ö½ú4.3¬ê±ê±¼ä
delay_ms(300);
}
}
编译结果:
main.c(59): error: #167: argument of type "UART_HandleTypeDef *" is incompatible with parameter of type "USART_HandleTypeDef *"
|
|