zhyinch
2019-10-29 bbb68fd93739963f866d0c95246191962b6a7f72
Ô´Âë/ºËÐİå/Src/OnChipDevices/Usart.c
@@ -1,5 +1,6 @@
#include "Usart.h"
#include <string.h>
#include <stdio.h>
//数据发送队列变量
EUART_Frame m_EUART_TxFrames[EUART_TX_FRM_SIZE];   //数据发送帧队列   
@@ -87,7 +88,7 @@
   GPIO_Init(EU_RX_GPIO, &GPIO_InitStructure);
   
   GPIO_InitStructure.GPIO_Pin = EU_TX_PIN;
   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;                     //Tx推挽复用输出
   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;//GPIO_Mode_AF_PP;                     //Tx推挽复用输出
   GPIO_Init(EU_TX_GPIO, &GPIO_InitStructure);
   
#ifdef UART_GPIO_REMAP_ENABLE
@@ -109,7 +110,7 @@
   
   USART_ClockInit(EXT_UART, &USART_ClockInitStructure);
   USART_Init(EXT_UART, &USART_InitStructure);
//   USART_ITConfig(EXT_UART, USART_IT_RXNE, ENABLE);//??????,????? ??????????
   // Enable the USARTx 
   USART_Cmd(EXT_UART, ENABLE); 
   //DMA配置(须放到UART初始化之后)
@@ -287,4 +288,29 @@
      m_EUART_TxFrm_Head = EUART_TX_FRM_SIZE-1;
   m_EUART_TxFrm_FreeFrmLen++;
}
void USART_putc(char c)
{
   //while(!(USART2->SR & 0x00000040));
   //USART_SendData(USART2,c);
   /* e.g. write a character to the USART */
   USART_SendData(USART1, c);
   /* Loop until the end of transmission */
   while (USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET)   ;
}
void USART_puts(uint8_t *s,uint8_t len)
{
   int i;
   for(i=0; i<len; i++)
   {
      USART_putc(s[i]);
   }
}
int fputc(int ch, FILE *f)
{
   USART_SendData(USART1, (unsigned char) ch);// USART1 ???? USART2 ?
   while (!(USART1->SR & USART_FLAG_TXE));
   return (ch);
}