I have one Doubt how void uart(void)__irq this function call in this program..........????
#include "lpc21xx.h" // #include "lpc210x.h" #include "stdio.h" #define baudrate_uart1 0x0f //@115200;SYS_CLK/16*2*COUNT=0x0f #define sender_no "+919328178092" #define sms "Advance Technology rising company in future" #define CR 0x0D #define LF 0x0A /****************************Prototypes****************************/
void delay(void); void getch (char ch); char *gps_strchr(char *src, char ch); int gps_strncmp( char *s1, char *s2, unsigned char length); int gps_strcpy1(unsigned char *s1,char *s2); const char *uart1Puts(const char *string); int uart1Putch(int ch); void uart1_interrupt(void); void uart1_initialize(void); void check_response(char *sentence); void lcd (int length) ; void instwrt(void); void datawrt(void); void lcd_init(void); char at_get_running; char at_get_buff[160],*at_get_idx;
char response_ok=0; char lcd_buffer[20],temp123[200]; static char array1[160];
int main() {
VPBDIV=2; IODIR0=IODIR0|0x0f00fffc;
uart1_initialize(); uart1_interrupt(); lcd_init();
uart1Puts("AT" ) ; uart1Putch(CR); delay();
while(response_ok!=1) //check response for previous cmd { response_ok=0; //uart1Puts("AT+CMGF=1" ) ; // uart1Putch(CR); // delay();
//uart1Puts("AT+CMGS=" ) ; //uart1Putch('"'); //uart1Puts(sender_no) ; //uart1Putch('"'); //uart1Putch(CR); //uart1Puts(sms); // uart1Putch(26); // delay(); } while(1) {
} }
/***************************************************************************** * FUNCTION : UART1 interrupt * PURPOSE : for data capturig at baudrate 115.2kbps * INPUTS : receive interrupt * RETURNS : none *****************************************************************************/
void uart(void)__irq { char status,temp; if((U0LSR & 0x01)==0x01) { status=U0RBR; getch(status);
} VICVectAddr=0; temp=U0IIR;
} /***************************************************************************** * FUNCTION : get_ch * PURPOSE : gets the ch from GPRS and findout gprs responses and route table information * INPUTS : passing ch receive from uart1 receive interrupt * RETURNS : none *****************************************************************************/ void getch (char ch) {
static char ch_count1=0;
if( ch_count1<150) { array1[ch_count1]=ch; ch_count1++; } else ch_count1=0;
if((ch ==LF)&&(!at_get_running)) //start of response { at_get_running = 1; //sentence being recieved flag true at_get_idx = at_get_buff; }
if(at_get_running) { if((ch== LF)&&(at_get_idx == (at_get_buff+1))) //start of response received { at_get_idx = at_get_buff; } else if((ch == CR)&&(at_get_idx > (at_get_buff+1))) //end of response { at_get_running = 0; *at_get_idx = 0; check_response( at_get_buff); } else { if(ch!=LF) *at_get_idx++ = ch; //update buffer with response on uart } }
}
/***************************************************************************** * FUNCTION : int check_response(void) * PURPOSE : check AT response type from response strored in buffer and * return appropriate value according to type * INPUTS : sentence: address of buffer * RETURNS :1 on success 0 on error/busy
*****************************************************************************/ void check_response(char *sentence) {
if(gps_strncmp(sentence, "RING", 4) == 0) { response_ok=1; // lcd_buffer[]={}; gps_strcpy1(lcd_buffer,"CALL FOR U"); lcd(10); uart1Puts("ATA" ) ; uart1Putch(CR); delay();
} else if(gps_strncmp(sentence, "NO CARRIER", 10) == 0) { response_ok=0; gps_strcpy1(lcd_buffer,"MISS CALL"); lcd(9); }
else if(gps_strncmp(sentence, "+CMTI:", 6) == 0) //+CMTI: "SM",16 ==cmti is receive response, sm: sim memory, 16 location number { // maximum 30 sms stored gps_strcpy1(lcd_buffer,"NEW MSG RECEIVED"); lcd(16);
//lcd(16);
} else if(gps_strncmp(sentence, "RING", 4) == 0) response_ok=1;
else if(gps_strncmp(sentence, "OK", 2) == 0) response_ok=1; } /***************************************************************************** * FUNCTION : gps_strchr * PURPOSE : Searches for the character and returns the location * * INPUTS : char *src - source string * char ch - character to be searched
* RETURNS : address location of character in string
*****************************************************************************/