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

ATAVRBFLY_FILES/main.c File Reference


Detailed Description

Atmel Corporation

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

Definition in file main.c.

#include <inavr.h>
#include <iom169.h>
#include "main.h"
#include "LCD_functions.h"
#include "LCD_driver.h"
#include "button.h"
#include "BCD.h"
#include "types.h"
#include "STATE_functions.h"
#include "menu.h"
#include "..\AVRGSM_FILES\AVRGSM_api.h"
#include "..\AVRGSM_FILES\AVRGSM_com.h"

Include dependency graph for main.c:

Include dependency graph

Go to the source code of this file.

Defines

#define pLCDREG_test   (*(char *)(0xEC))

Functions

void Initialization (void)
 This function setup the hardware.

__C_task void main (void)
 This function is the main loop.

unsigned char StateMachine (char state, unsigned char stimuli)
 This function controls the state machine.


Variables

__flash unsigned int LCD_character_table []
int rx_ack
 Extern flag from AVRSMS_com.c.

unsigned char state


Define Documentation

#define pLCDREG_test   (*(char *)(0xEC))
 

Definition at line 64 of file main.c.


Function Documentation

void Initialization void   ) 
 

This function setup the hardware.

Set up:
*PORTB
*PORTE
*Serial communication
*Buttons
*LCD

Parameters:
void 
Return values:
none 

Definition at line 206 of file main.c.

References Button_Init(), COM_init(), and LCD_Init().

Referenced by main().

00207 { 00208 00209 PORTB = (15<<PORTB0); // Enable pullup on 00210 PORTE = (15<<PORTE4); 00211 00212 COM_init( 51 ); //9600bps @ 8MHz 00213 Button_Init( ); // Initialize pin change interrupt on joystick 00214 LCD_Init( ); // initialize the LCD 00215 }

Here is the call graph for this function:

__C_task void main void   ) 
 

This function is the main loop.

The main loop control a state machine, and reacts on joypad stimuli or arrival
of new messages.

Parameters:
void 
Return values:
none 

Local variables

Initialization of state variables

Program initalization

DO this forever

Definition at line 84 of file main.c.

References getkey(), Initialization(), input, KEY_NULL, LCD_Colon(), LCD_puts_f(), menu_state, MT_IDLE, NULL, MENU_STATE::pFunc, MENU_STATE::pText, rx_ack, ST_AVR_IDLE, ST_AVR_NEW_SMS_function, ST_AVR_READY, ST_get_index(), MENU_STATE::state, state, and StateMachine().

00085 { 00086 00088 unsigned char nextstate; 00089 static char __flash *statetext; 00090 char (*pStateFunc)(char); 00091 char input; 00092 char i; 00093 00095 state = nextstate = ST_AVR_IDLE; 00096 statetext = MT_IDLE; 00097 pStateFunc = NULL; 00098 00099 00101 Initialization( ); 00102 __enable_interrupt(); 00103 00104 00106 for( ;; ) 00107 { 00108 00109 if( ( state == ST_AVR_READY ) && ( rx_ack == 1 ) ) //New SMS 00110 { 00111 00112 state = nextstate = ST_AVR_NEW_SMS_function; //Setting new state 00113 statetext = NULL; 00114 pStateFunc = ST_get_index; 00115 } 00116 00117 // Plain menu text 00118 if( statetext ) 00119 { 00120 00121 LCD_puts_f( statetext, 1 ); 00122 LCD_Colon( 0 ); 00123 statetext = NULL; 00124 } 00125 00126 //Get input 00127 input = getkey( ); 00128 00129 if ( pStateFunc ) 00130 { 00131 00132 // When in this state, we must call the state function 00133 nextstate = pStateFunc(input); 00134 } 00135 00136 else if (input != KEY_NULL) 00137 { 00138 00139 // Plain menu, clock the state machine 00140 nextstate = StateMachine(state, input); 00141 } 00142 00143 if (nextstate != state) 00144 { 00145 state = nextstate; 00146 00147 for (i=0; menu_state[i].state; i++) 00148 { 00149 00150 if (menu_state[i].state == state) 00151 { 00152 00153 statetext = menu_state[i].pText; 00154 pStateFunc = menu_state[i].pFunc; 00155 break; 00156 } 00157 } 00158 } 00159 } 00160 }

Here is the call graph for this function:

unsigned char StateMachine char  state,
unsigned char  stimuli
 

This function controls the state machine.

Parameters:
state Present state
stimuli Input from joypad
Return values:
nextstate New state of the system

Definition at line 171 of file main.c.

References MENU_NEXTSTATE::input, menu_nextstate, MENU_NEXTSTATE::nextstate, state, and MENU_NEXTSTATE::state.

Referenced by main().

00172 { 00173 00174 unsigned char nextstate = state; // Default stay in same state 00175 unsigned char i; 00176 00177 for ( i=0; menu_nextstate[i].state; i++ ) 00178 { 00179 00180 if ( ( menu_nextstate[i].state == state ) && ( menu_nextstate[i].input == stimuli ) ) 00181 { 00182 00183 // This is the one! 00184 nextstate = menu_nextstate[i].nextstate; 00185 break; 00186 } 00187 } 00188 00189 return nextstate; 00190 }


Variable Documentation

__flash unsigned int LCD_character_table[]
 

Definition at line 69 of file main.c.

Referenced by LCD_WriteDigit().

int rx_ack
 

Extern flag from AVRSMS_com.c.

Definition at line 67 of file main.c.

unsigned char state
 

Definition at line 71 of file main.c.

Referenced by main(), and StateMachine().


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