예제 #1
0
/******************************************************************************
 * Funcao:		void main(void)
 * Entrada:		Nenhuma (void)
 * Saída:		Nenhuma (void)
 * Descrição:	Função principal do programa.
 *****************************************************************************/
void main(void)
{

	//Função que faz configurações do firmware
	ConfiguraSistema();
	
	//Escolhe estado inicial das saidas digitais
	LED_VERDE = 0;
	LED_AMARELO = 0;
	LED_VERMELHO = 0;
	BUZZER = 0;
	RELE = 0;
	
	// Laço de repetição infinito que executa aplicação do firmware
	while(1)
	{
		
		
		
	}//end while(1)
	
}//end main
예제 #2
0
/******************************************************************************************************
* Funcao:    void main(void) 														  				  *
* Entrada:   Nenhuma 		 														  				  *
* Saída:     Nenhuma 		 														  				  *
* Descrição: Função principal do programa.											  				  *
******************************************************************************************************/
void main(void)
{
	unsigned char pass_flag = 0;
	
	ConfiguraSistema(); 
	ConfiguraUSART();

	OpenXLCD();
	SetDDRamAddr(0x00);   
	putrsXLCD(" Welcome ");
	
	while(1)		
	{
		OpenXLCD();
		SetDDRamAddr(0x00);   
		putrsXLCD("Send or receive? "); // display " Send or Receive ? "

		if(send == 1) // if sending switch is pressed 
		{
			OpenXLCD();
			SetDDRamAddr(0x00);   
			putrsXLCD(" Sending .. "); // display "sending.."
			
			pass_flag = 0;
			while (!pass_flag)
			{
				for(j = 89; j > 0; j--){
					data[j] = ' ';
				}
				Transmitir(sms_format, sizeof(sms_format)); // send to GSM ( set Text mode)
				Delay10KTCYx(250); //Tempo determinado pelo datasheet SIM300 pg 24
    			Delay10KTCYx(250);
				if(data[0] == ~'O' && data[1] == ~'K'){
					pass_flag = 1;
				}
			}
			
			pass_flag = 0;
			while (!pass_flag)
			{
				for(j = 89; j > 0; j--) data[j] = ' ';
				Transmitir(character_set, sizeof(character_set)); // send to GSM 
    			Delay10KTCYx(250);
    			Delay10KTCYx(250);
				if(data[0] == ~'O' && data[1] == ~'K'){
					pass_flag = 1;
				}
			}
			
			Transmitir(sms_write, sizeof(sms_write)); // send to GSM ( to write phone number)
    		Delay10KTCYx( 250);
            Delay10KTCYx( 250);
            Delay10KTCYx( 250);
            Delay10KTCYx( 250);
            Delay10KTCYx( 250);
			
			
    		Transmitir(sms, sizeof(sms)); // send to GSM ( to write the sms)
			Delay10KTCYx(250); 
			Delay10KTCYx(250);

			Tx_Mensagem(sms_terminate);  // ctrl+z
			Delay10KTCYx(250);
    		Delay10KTCYx(250);	
			
			Tx_Mensagem(enter); // enter Key
    		Delay10KTCYx(250);

			OpenXLCD();
			SetDDRamAddr(0x00);   
			putrsXLCD("SMS Sent..."); // display "SMS Sent .."
		}	
	
		if(rec == 1) //if Receiving switch is pressed 
        {
			OpenXLCD();
			SetDDRamAddr(0x00);   
			putrsXLCD(" Waiting for SMS"); // display " waiting for sms"

			Transmitir(sms_format, sizeof(sms_format)); // to set the mode           
			Delay10KTCYx(250);
    		Delay10KTCYx(250);
			Delay10KTCYx(250);

			Transmitir(sms_indication, sizeof(sms_indication)); // to choose how sms arrive
			Delay10KTCYx(250);
    		Delay10KTCYx(250);
			Delay10KTCYx(250);
			Rx_Mensagem();
			for(k = 0; k < 46; k++)
            {
				stringArray[k] = ch;
            }
			// --- By this point the SMS is Received and stored in Array --

			OpenXLCD();
			SetDDRamAddr(0x00);   
			putrsXLCD(" SMS Received "); // display ( sms received )
			Transmitir(stringArray, sizeof(stringArray)); // to set the mode           
			Delay10KTCYx(250);
    		Delay10KTCYx(250);
			Delay10KTCYx(250);
			/*--- display SMS on LCD ---*/
			OpenXLCD();
			SetDDRamAddr(0x00);   
			putrsXLCD(stringArray); // display the text that received
		}
	}

}//fim main