Chapter 13
void command_write_byte(void)
{
int received_data;
switch (received_command[3])
{
case 'b':
{
// Get the data to write.
received_data = ascii_hex_to_byte(received_command[4],
received_command[5]);
if (received_data > -1)
{
// The received data was valid.
// Set a port bit to match bit 0 of the received byte.
if ((received_data & 1) == 1)
{
PORTBbits.RB0 = 1;
}
else
{
PORTBbits.RB0 = 0;
}
command_response[2] = 0x0a;
prepare_to_respond();
break;
}
}
// Add more cases as needed.
default:
{
break;
}
}
}