Exemplo n.º 1
0
/*** Function    : main
**   Parameters  : None
**   Return      : int
**   Description : It is the entry point of program
**/
int main(void)
{
SetOsc(OSC_FREQ);             // Set Oscillator Freq
Serialbegin(BAUD_RATE);       // Set Baud Rate
Serialflush();                // Clear the buffers
Serialprint("uart test\n\r"); // Print a string
setSerialinterrupt();         // Enable Serial Interrupt
while(1)
{
 while(uartNewLineCount<NEW_LINE_THRESHOLD); // Wait until new line count reaches threshold
 Serialprint(uartReadBuffer);                // Print the uart read buffer
 Serialflush();                              // Flush the buffer
}
}
Exemplo n.º 2
0
void SerialprintInt16(int16_t values)
{
    int i;
    char valueSigned;
    int32_t data =  values;

    char stringOutput[7] = { ' ', ' ', ' ', ' ', ' ', '0', 0};

    if (data != 0)
    {
        if (data < 0)
        {
            valueSigned = '-';
            data *= -1;
        }
        else
            valueSigned = ' ';

        for(i = 5; i >= 0; i--)
        {
            if (data != 0)
            {
                stringOutput[i] = (data % 10) + '0';
                data /= 10;
            }
            else
            {
                stringOutput[i] = valueSigned;
                break;
            }
        }
    }

    Serialprint(stringOutput);
}
Exemplo n.º 3
0
void testSesnors(void)
{
	if(sensorsDetectObstacle() == 0)
	{
		Serialprint("Obstacle Detected\n");
	}
	
		if(sensorsDetectFire() == 0)
		{
			Serialprint("Fire Detected\n");
		}
		
				if(sensorsDetectSmoke() == 0)
				{
					Serialprint("Smoke Detected\n");
				}
}
Exemplo n.º 4
0
void testMotor(void)
{
char c;
Serialflush();
Serialprint("Motor Test\n");
while(1)
{
if(uartNewLineFlag == 1)
{
	Serialprint("LF received\n");
c = uartReadBuffer[0];
Serialflush();
switch(c)
{
case 'a': motorForward();
Serialprint("Motor FW\n");
          break;
case 'b': motorBackward();
Serialprint("Motor BW\n");
          break;
case 'c': motorLeft();
Serialprint("Motor Left\n");
          break;
case 'd': motorRight();
Serialprint("Motor Right\n");
          break;
case 'e': motorStop();
Serialprint("Motor Stop\n");
          break;		  
}
}
}
}
Exemplo n.º 5
0
void uartISRTest(void)
{
	while(1)
	{
		if(uartNewLineFlag == 1)
		{
			Serialprint((char*)uartReadBuffer);
			Serialflush();
		}
	}
}
Exemplo n.º 6
0
void SerialprintUInt16(uint16_t values)
{
    char stringOutput[6] = {0};

    int i;
    for(i = 4; i >= 0; i--)
    {
        stringOutput[i] = (values % 10) + '0';
        values /= 10;
    }
    stringOutput[5] = '\0';

    Serialprint(stringOutput);
}
Exemplo n.º 7
0
void setup() {
  Serial.begin(9600);
  Serial.println();
  Serial.print(SELF_NAME);
  Serial.println(F(" started..."));

  #ifdef ETHERNET_FEATURE
    ethernetInit();
  #endif

  sdCardInit();

  #ifdef RTC_FEATURE
    rtcInit();
  #endif

  #ifdef SERVER_FEATURE
    serverInit();
  #endif

  timersInit();

  #ifdef MAJORDOMO_FEATURE
    majordomoInit();
    majordomoMegaLive();
  #endif

  #ifdef LAURENT_FEATURE
    laurentInit();
  #endif

  #ifdef SD_INFO_FEATURE
    sdInfoInit();
  #endif

  #ifdef SD_FILES_FEATURE
    sdFilesInit();
  #endif

  #ifdef PING_FEATURE
    pingInit();
  #endif

  #ifdef UPLOAD_FEATURE
    uploadInit();
  #endif

  #ifdef PIRS_FEATURE
    pirsInit();
  #endif

  #ifdef CONTACTS_FEATURE
    contactsInit();
  #endif

  #ifdef TEMP_FEATURE
    tempInit();
  #endif

  #ifdef ELECTRO_FEATURE
    electroInit();
  #endif

  #ifdef KEYS_FEATURE
    keysInit();
  #endif

  #ifdef LEDS_FEATURE
    ledsInit();
  #endif

  #ifdef NOO_FEATURE
    nooInit();
  #endif

  timeStamp();
  Serialprint("GLOBAL Init DONE\n");
  Serial.println();
  timeStamp();
  Serialprint("AMS WORK\n");
} // setup
Exemplo n.º 8
0
void testgsmSimul(void)
{
unsigned char var;

// Set Echo Off 
var = gsmEchoOff();
if(var == 0)
{
Serialprint("Echo OFF: Success\n");
}
else if(var == 1)
{
Serialprint("Echo OFF: String Error\n");
}
else if(var == 2)
{
Serialprint("Echo OFF: Timeout Error\n");
}
else if(var == 3)
{
Serialprint("Echo OFF: Unknown Error\n");
}

// Detect Modem
var = gsmDetectModem();
if(var == 0)
{
Serialprint("Detect Modem: Success\n");
}
else if(var == 1)
{
Serialprint("Detect Modem: String Error\n");
}
else if(var == 2)
{
Serialprint("Detect Modem: Timeout Error\n");
}
else if(var == 3)
{
Serialprint("Detect Modem: Unknown Error\n");
}

// Get Register Status
var = gsmGetRegStatus();
if(var == 0)
{
Serialprint("Reg Status: Success\n");
}
else if(var == 1)
{
Serialprint("Reg Status: String Error\n");
}
else if(var == 2)
{
Serialprint("Reg Status: Timeout Error\n");
}

// Enable Dtmf
var = gsmEnableDtmf();
if(var == 0)
{
Serialprint("DTMF Set: Success\n");
}
else if(var == 1)
{
Serialprint("DTMF Set: String Error\n");
}
else if(var == 2)
{
Serialprint("DTMF Set: Timeout Error\n");
}
else if(var == 3)
{
Serialprint("DTMF Set: Unknown Error\n");
}

var = gsmSignalStrength();
if(var == 0)
{
Serialprint("Network Test: Success\n");
}
else if(var == 1)
{
Serialprint("Network Test: String Error\n");
}
else if(var == 2)
{
Serialprint("Network Test: Timeout Error\n");
}
else if(var == 3)
{
Serialprint("Network Test: Unknown Error\n");
}
else if(var == 3)
{
Serialprint("Network Test: No Signal\n");
}


while(1)
{
// If Call is detected ('RING')
if(gsmDetectCall() == 0)
{
// Connect Call ('ATA')
var = gsmConnectCall();
if(var == 0)
{
Serialprint("Connect Voice Call: Success\n");
}
else if(var == 1)
{
Serialprint("Connect Voice Call: String Error\n");
}
else if(var == 2)
{
Serialprint("Connect Voice Call: Timeout Error\n");
}
else if(var == 3)
{
Serialprint("Connect Voice Call: Unknown Error\n");
}
}

// Read DTMF Value
var = gsmReadDtmf();
if(var < 15)
{
Serialprint("DTMF:-");
SerialIntWrite(var,10);
Serialwrite('\n');
}

// If Call is disconncted ('NO CARRIER')
if(gsmCallDisStatus() == 0)
{
Serialprint("Voice Call Disconnected\n");
}
}
}