zhyinch
2018-10-01 df3db0b978b1cab3555d6878a274b0f382bf707c
Ô´Âë/ºËÐİå/Src/OnChipDevices/Usart.c
@@ -1,62 +1,6 @@
#include "Usart.h"
//void Usart_Init(void)
//{
//   USART_InitTypeDef USART_InitStructure;
//    GPIO_InitTypeDef GPIO_InitStructure;
//
//   /* Enable GPIO clock */
//    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_AFIO, ENABLE);
//   /* Enable USART clock */
//    RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
//
//   /* Configure USART Tx as alternate function push-pull */
//    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
//    GPIO_InitStructure.GPIO_Pin = USART_TX_pin;
//    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
//    GPIO_Init(USART_GPIO, &GPIO_InitStructure);
//    /* Configure USART Rx as input floating */
//    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
//    GPIO_InitStructure.GPIO_Pin = USART_RX_pin;
//    GPIO_Init(USART_GPIO, &GPIO_InitStructure);
//    /* USARTx configured as follow:
//         - BaudRate = 115200 baud
//         - Word Length = 8 Bits
//         - One Stop Bit
//         - No parity
//         - Hardware flow control disabled (RTS and CTS signals)
//         - Receive and transmit enabled
//    */
//    USART_InitStructure.USART_BaudRate = BAUD_RATE ;
//    USART_InitStructure.USART_WordLength = USART_WordLength_8b;
//    USART_InitStructure.USART_StopBits = USART_StopBits_1;
//    USART_InitStructure.USART_Parity = USART_Parity_No;
//    USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
//    USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
//    /* USART configuration */
//    USART_Init(EXT_USART, &USART_InitStructure);
//    /* Enable USART */
//    USART_Cmd(EXT_USART, ENABLE);
//}
//uint16_t Checksum_u16(uint8_t *pdata, uint32_t len)
//{
//    uint16_t sum = 0;
//    uint32_t i;
//    for(i = 0; i < len; i++)
//        sum += pdata[i];
//    sum = ~sum;
//    return sum;
//}
///////////////////////////////////
#include <string.h>
#include <stdio.h>
//数据发送队列变量
EUART_Frame m_EUART_TxFrames[EUART_TX_FRM_SIZE];   //数据发送帧队列   
@@ -345,3 +289,11 @@
   m_EUART_TxFrm_FreeFrmLen++;
}
int fputc(int ch, FILE *f)
{
   USART_SendData(USART1, (unsigned char) ch);// USART1 ???? USART2 ?
   while (!(USART1->SR & USART_FLAG_TXE));
   return (ch);
}