用S3C2410向MC35I 模块发送AT命令,想接受到OK并在超级终端上显示OK,但是无法接受到。S3C2410的COM0与PC机串口1相连,S3C2410的COM1与MC35I 相连。操作系统是UCOS-II,部分程序如下:
#include "includes.h"
#include "frmwrk.h"
#include "consol.h"
#include "mmu.h"
#include <stdarg.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#define RX_BUF_SIZE 1024
static char rx_buf[RX_BUF_SIZE];
static U16 rx_buf_head, rx_buf_tail;
#define RX_BUF_EMPTY() (rx_buf_head==rx_buf_tail)
#define RX_BUF_INC() (rx_buf_head = (rx_buf_head+1)&(RX_BUF_SIZE-1));
#define RX_BUF_DEC() (rx_buf_tail = (rx_buf_tail+1)&(RX_BUF_SIZE-1));
void putch(char ch)
{
CONSOL_SendChar(ch);//COM0发送数据函数
}
void EnableIrq(int bit)
{
rINTMSK &= ~(bit);
}
void DisableIrq(int bit)
{
rINTMSK |= (bit);
}
//串口1接收中断处理
static void __irq Uart1RxInt(void)
{
ClearSubPending(BIT_SUB_RXD1); //rSUBSRCPND = BIT_SUB_RXD0; //Clear pending bit (Requested)
ClearPending(BIT_UART1);
printf("URT1 rx interrupt!\n");
rx_buf[rx_buf_head] = RdURXH1();
RX_BUF_INC();
if(RX_BUF_EMPTY())
RX_BUF_DEC();
}
static void Echo_Rx_Data(void)
{
while(!RX_BUF_EMPTY()) {
putch(rx_buf[rx_buf_tail]);
RX_BUF_DEC();
}
}
/****************************************************************************
【功能说明】串口发送命令字符串并等待回显
****************************************************************************/
void GPRS_Cmd( char *pt )
{
int i=0;
while( pt[i] )
{
CONSOL_Select(1) ; //选择UART通道为串口1
CONSOL_SendChar( pt[i] );
CONSOL_Select( 0 ) ; //选择UART通道为串口0
i++;
}
OSTimeDly(10);
Echo_Rx_Data();
}
//****************************************************************************
【功能说明】设置开发平台的串口1波特率
****************************************************************************/
void Test_GPRS_Init()
{
printf("Initialize GPRS modem...\n");
rGPGCON &= ~((3<<4)|(3<<12));
rGPGCON |= (1<<4)|(1<<12);
rGPGDAT &= ~(1<<2);
rGPGDAT &= ~(1<<6);
rGPHCON |= 0xf<<12; //RTS1, CTS1
rGPHUP |= 3<<6; //Uart port pull-up disable
CONSOL_Select(1) ; //选择UART通道为串口1
CONSOL_Init(115200);
CONSOL_Select( 0 ) ; //选择UART通道为串口0
rx_buf_head = rx_buf_tail = 0;
pISR_UART1 = (U32)Uart1RxInt; //串口接收数据中断
ClearSubPending(BIT_SUB_RXD1);
ClearPending(BIT_UART1);
EnableSubIrq(BIT_SUB_RXD1);
EnableIrq(BIT_UART1);
GPRS_Cmd("AT\n");
OSTimeDly(500);
static void Test_GPRS_Exit(void)
{
DisableSubIrq(BIT_SUB_RXD1);
DisableIrq(BIT_UART1);
}
/****************************************************************************
【功能说明】发送短信
****************************************************************************/
static void GPRS_MGS(char *number, char *text)