Chapter 7: Microcontroller Interrupts and Timers
void parseInput(char s[])
// parse first character
switch (s
{
case 'c':
if( (s[1] == 't') && (s[2] == 'c'))
parse_ctc(s);
break;
case 'd':
if((s[1]=='e')&&(s[2]=='m')&&(s[3]=='o')&&(s[4]=='?'))
sendString("You are talking to the Precision Blinking demo.\r");
break;
default:
sendString("\rYou sent: '");
sendChar(s[0]);
sendString("' - I don't understand.\r");
break;
}
s[0] = '\0';
}
int parse_ctc(char s[])
{
char ctc[11];
unsigned char i = 3, j = 0;
while( (s[i] != '\0') && (j <= 11) )
{
if( (s[i] >= '0') && (s[i] <= '9') )
{
OSCCAL_calibration();
// Initialize the USART
USARTinit();
// set PORTD for output
DDRD = 0xFF;
MilliSec_init(250); // default to 1000 Hz
// say hello
sendString("\rPC_Comm.c ready to communicate.\r");
// identify yourself specifically
sendString("You are talking to the Precision Blinking demo.\r");
}
{
[0])