You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
2.4 KiB

#include "uart.h"
bool is_recive_data=false;
bool at_cipmode_flag=false;//�Ƿ�͸��
uint8_t RxBuff[255];
uint8_t RxLen=0;
void uart1_init(void)
{
/* ���ô���1��������IO��ģʽ�������ô��� */
GPIOA_SetBits(GPIO_Pin_9);
GPIOA_ModeCfg(GPIO_Pin_8, GPIO_ModeIN_PU); // RXD-������������
GPIOA_ModeCfg(GPIO_Pin_9, GPIO_ModeOut_PP_5mA); // TXD-��������������ע������IO�������ߵ�ƽ
UART1_BaudRateCfg(uart_param.baud);
switch (uart_param.parity) {
case NO_PARITY:
R8_UART1_LCR = RB_LCR_WORD_SZ;
break;
case ODD_PARITY:
R8_UART1_LCR =RB_LCR_WORD_SZ|RB_LCR_PAR_EN;
break;
case EVEN_PARITY:
R8_UART1_LCR =RB_LCR_WORD_SZ|RB_LCR_PAR_EN|0x10;
break;
default:
R8_UART1_LCR = RB_LCR_WORD_SZ;
break;
}
R8_UART1_FCR = (2 << 6) | RB_FCR_TX_FIFO_CLR | RB_FCR_RX_FIFO_CLR | RB_FCR_FIFO_EN; // FIFO�򿪣�������4�ֽ�
R8_UART1_IER = RB_IER_TXD_EN;
R8_UART1_DIV = 1;
UART1_ByteTrigCfg(UART_7BYTE_TRIG);
UART1_INTCfg(ENABLE, RB_IER_RECV_RDY | RB_IER_LINE_STAT);
PFIC_EnableIRQ(UART1_IRQn);
}
uint32_t uart1_get_baud(void)
{
return uart_param.baud;
}
void uart1_reset(void)
{
UART1_Reset();
}
/*********************************************************************
* @fn UART1_IRQHandler
*
* @brief UART1жϺ
*
* @return none
*/
//__INTERRUPT
//__HIGH_CODE
//void UART1_IRQHandler(void)
//{
// volatile uint8_t i;
// uint8_t tmpRxBuff[100];
//
// switch(UART1_GetITFlag())
// {
// case UART_II_LINE_STAT: // ��·״̬����
// {
// //UART1_GetLinSTA();
// break;
// }
//
// case UART_II_RECV_RDY: // ���ݴﵽ���ô�����
// for(i = 0; i != 6; i++)//����Ϊ7�ֽڴ���������ֻȡ6�ֽڣ���֤һ���ܽ���ʱ�ص�
// {
// tmpRxBuff[i] = UART1_RecvByte();
// }
// memcpy(&RxBuff[RxLen],tmpRxBuff,i);
// RxLen=RxLen+i;
// break;
//
// case UART_II_RECV_TOUT: // ���ճ�ʱ����ʱһ֡���ݽ�������
// RxLen = RxLen+UART1_RecvString(&RxBuff[RxLen]);
// is_recive_data=true;
// break;
//
// case UART_II_THR_EMPTY: // ���ͻ������գ��ɼ�������
// break;
//
// case UART_II_MODEM_CHG: // ֻ֧�ִ���0
// break;
//
// default:
// break;
// }
//}