Main Page | Data Structures | File List | Data Fields | Globals

AVRGSM_FILES/AVRGSM_com.h File Reference


Detailed Description

Atmel Corporation

Revision
1.2
Date
Wednesday, January 26, 2005 10:43:44 UTC

Definition in file AVRGSM_com.h.

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Defines

#define CMTI_   1
 Used to look up in COM_setSearchString( unsigned char Response ).

#define CRLF_   3
 Used to look up in COM_setSearchString( unsigned char Response ).

#define OK_   0
 Used to look up in COM_setSearchString( unsigned char Response ).

#define READY_   2
 Used to look up in COM_setSearchString( unsigned char Response ).

#define RX_BUFFER_MASK   RX_BUFFER_SIZE - 2
 Used to set overflow flag.

#define RX_BUFFER_SIZE   256
 rx_buffer size

#define RX_WAIT   65000
 Timeout value.


Functions

unsigned char * COM_gets (void)
 Return pointer to receive buffer.

void COM_init (unsigned int baudrate)
 USART0 initialization.

void COM_put_integer (int i)
 This method will print an integer in the range +-(10^5 - 1 ).

int COM_putchar (unsigned char data)
 Adapted putchar method...no need for interrup driven tx-isr.

void COM_puts (unsigned char *str)
 Print unsigned char string.

void COM_putsf (const unsigned char __flash *fstr)
 Print const unsigned char __flash string.

void COM_rx_off (void)
 RX interrupt disable.

void COM_rx_on (void)
 RX interrupt enable.

void COM_rx_reset (void)
 Reset receive interrupt.

void COM_setSearchString (unsigned char Response)
 Set desired search string.

int COM_trim (void)
 Remove trailing O, K, and
.


Define Documentation

#define CMTI_   1
 

Used to look up in COM_setSearchString( unsigned char Response ).

Definition at line 30 of file AVRGSM_com.h.

Referenced by ST_delete_msg(), ST_init_phone(), and USART0_RX_interrupt().

#define CRLF_   3
 

Used to look up in COM_setSearchString( unsigned char Response ).

Definition at line 32 of file AVRGSM_com.h.

Referenced by USART0_RX_interrupt().

#define OK_   0
 

Used to look up in COM_setSearchString( unsigned char Response ).

Definition at line 29 of file AVRGSM_com.h.

Referenced by API_deletemsg(), API_modem_init(), API_readmsg(), and API_sendmsg().

#define READY_   2
 

Used to look up in COM_setSearchString( unsigned char Response ).

Definition at line 31 of file AVRGSM_com.h.

Referenced by API_sendmsg().

#define RX_BUFFER_MASK   RX_BUFFER_SIZE - 2
 

Used to set overflow flag.

Definition at line 27 of file AVRGSM_com.h.

Referenced by USART0_RX_interrupt().

#define RX_BUFFER_SIZE   256
 

rx_buffer size

Definition at line 26 of file AVRGSM_com.h.

#define RX_WAIT   65000
 

Timeout value.

Definition at line 28 of file AVRGSM_com.h.

Referenced by COM_putchar().


Function Documentation

unsigned char* COM_gets void   ) 
 

Return pointer to receive buffer.

Parameters:
void 
Return values:
rx_buffer Pointer to receive buffer

Definition at line 317 of file AVRGSM_com.c.

References rx_buffer.

Referenced by TOOLS__decodeCMGR(), and TOOLS_decodeCMTI().

00318 { 00319 return rx_buffer; 00320 }

void COM_init unsigned int  baudrate  ) 
 

USART0 initialization.

This function set correct baurate and functionality of the USART0. See data sheet for more details.

Parameters:
input Desired baudrate...see datasheet
Return values:
void 

Definition at line 66 of file AVRGSM_com.c.

References COM_rx_reset().

Referenced by Initialization().

00067 { 00068 00069 UBRR0H = (unsigned char) (baudrate>>8); //Setting baudrate 00070 UBRR0L = (unsigned char) baudrate; //Setting baudrate 00071 00072 UCSR0B = ( 1 << RXEN0 ) | ( 1 << TXEN0 ); //Enable receiver and transmitter 00073 UCSR0C = ( 1 << USBS0 ) | ( 1 << UCSZ01 ) | ( 1 << UCSZ00 ); //8N1...see Datasheet for more information 00074 00075 COM_rx_reset(); //Reset buffers etc. 00076 }

Here is the call graph for this function:

void COM_put_integer int  i  ) 
 

This method will print an integer in the range +-(10^5 - 1 ).

Parameters:
i integer to be printed
Return values:
void 

Local variables

Definition at line 224 of file AVRGSM_com.c.

References COM_putchar().

Referenced by API_deletemsg(), API_readmsg(), and API_sendmsg().

00225 { 00226 00228 int ii; 00229 unsigned char int_buf[5]; 00230 00231 if (i < 0) //Integer is negative 00232 { 00233 i = -i; //Convert to positive Integer 00234 COM_putchar('-'); //Print - sign 00235 } 00236 00237 for (ii=0; ii < 5; ) //Convert Integer to char array 00238 { 00239 int_buf[ii++] = '0'+ i % 10; //Find carry using modulo operation 00240 i = i / 10; //Move towards MSB 00241 } 00242 do{ ii--; }while( (int_buf[ii] == '0') && (ii != 0) ); //Remove leading 0's 00243 do{ COM_putchar( int_buf[ii--] ); }while (ii >= 0); //Print int->char array convertion 00244 00245 }

Here is the call graph for this function:

int COM_putchar unsigned char  data  ) 
 

Adapted putchar method...no need for interrup driven tx-isr.

Adpation of ansi c putchar() method

Parameters:
data Character to send
Return values:
data if successful
-1 if timeout

Definition at line 198 of file AVRGSM_com.c.

References RX_WAIT.

Referenced by API_sendmsg(), COM_put_integer(), COM_puts(), and COM_putsf().

00199 { 00200 00201 //Local variables 00202 unsigned int i; 00203 00204 for( i = 0; !( UCSR0A & ( 1 << UDRE0 ) ); i++ ) // Wait for empty transmit buffer 00205 { 00206 if( i > RX_WAIT ) //How long one should wait 00207 { 00208 return -1; //Give feedback to function caller 00209 } 00210 } 00211 00212 UDR0 = data; // Start transmittion 00213 00214 return (int)data; //Cast and return int value 00215 }

void COM_puts unsigned char *  str  ) 
 

Print unsigned char string.

Parameters:
str Pointer to the string
Return values:
void 

Definition at line 254 of file AVRGSM_com.c.

References COM_putchar().

Referenced by API_sendmsg().

00255 { 00256 00257 for( ;*str != '\0'; ) 00258 { 00259 COM_putchar( *str++ ); 00260 } 00261 }

Here is the call graph for this function:

void COM_putsf const unsigned char __flash *  fstr  ) 
 

Print const unsigned char __flash string.

Parameters:
fstr Pointer to the string
Return values:
void 

Definition at line 270 of file AVRGSM_com.c.

References COM_putchar().

Referenced by API_deletemsg(), API_modem_init(), API_readmsg(), and API_sendmsg().

00271 { 00272 00273 for( ;*fstr != '\0'; ) 00274 { 00275 COM_putchar( *fstr++ ); 00276 } 00277 }

Here is the call graph for this function:

void COM_rx_off void   ) 
 

RX interrupt disable.

Parameters:
void 
Return values:
void 

Definition at line 114 of file AVRGSM_com.c.

Referenced by API_check_acknowledge().

00115 { 00116 00117 UCSR0B &= ~( 1 << RXCIE0 ); // Disable RX interrupt 00118 }

void COM_rx_on void   ) 
 

RX interrupt enable.

Parameters:
void 
Return values:
void 

Definition at line 101 of file AVRGSM_com.c.

Referenced by API_deletemsg(), API_modem_init(), API_readmsg(), API_sendmsg(), ST_delete_msg(), ST_init_phone(), and ST_read().

00102 { 00103 00104 UCSR0B |= ( 1 << RXCIE0 ); // Enable RX interrupt 00105 }

void COM_rx_reset void   ) 
 

Reset receive interrupt.

Parameters:
void 
Return values:
void 

Definition at line 85 of file AVRGSM_com.c.

References rx_ack, rx_buffer, rx_i, rx_overflow, and rx_wr_i.

Referenced by API_check_acknowledge(), API_deletemsg(), API_modem_init(), API_readmsg(), API_sendmsg(), COM_init(), ST_delete_msg(), ST_init_phone(), and ST_read().

00086 { 00087 00088 UCSR0B &= ~(1<<RXCIE0); // Disable RX interrupt 00089 rx_i = rx_wr_i = 0; //Init variables 00090 rx_overflow = rx_ack = 0; //Zero overflow flag 00091 rx_buffer[ rx_wr_i ] = '\0'; //Buffer init. 00092 }

void COM_setSearchString unsigned char  Response  ) 
 

Set desired search string.

Parameters:
void 
Return values:
void 

Definition at line 127 of file AVRGSM_com.c.

References rx_i, searchFor, searchStr, and searchStrings.

Referenced by API_deletemsg(), API_modem_init(), API_readmsg(), API_sendmsg(), ST_delete_msg(), ST_init_phone(), and ST_read().

00128 { 00129 00130 UCSR0B &= ~( 1 << RXCIE0 ); // Disable RX interrupt 00131 searchFor = searchStrings[Response]; //Set desired search dtring 00132 searchStr = Response; //Used in rx_isr 00133 rx_i = 0; 00134 }

int COM_trim void   ) 
 

Remove trailing O, K, and
.

If the receive buffer have trailing "OK\r\n" These characters will be deleted.

Parameters:
void 
Return values:
i Length of trimmed buffer

Local variables

Definition at line 289 of file AVRGSM_com.c.

References rx_buffer, and rx_wr_i.

Referenced by TOOLS__decodeCMGR(), and TOOLS_decodeCMTI().

00290 { 00291 00293 int i; 00294 unsigned char temp; 00295 00296 for( i = rx_wr_i - 1; i >= 0; i--) //Run through COM_in[] backwards 00297 { 00298 temp = rx_buffer[i]; //rx_buff[i] into temp 00299 if( ( temp != '\r' ) && ( temp != '\n' ) && ( temp != 'O' ) && ( temp != 'K' ) ) //If not equal to 'O', 'K', '\r' or '\n', break 00300 { 00301 break; //Do break 00302 } 00303 } 00304 00305 rx_buffer[ i+1 ] = '\0'; //Terminate trimmed string 00306 00307 return i; //Return new length 00308 }


Generated on Tue Nov 1 16:21:41 2005 for AVR323 Interfacing GSM modems by doxygen 1.3.7