Adding switch command.
This commit is contained in:
parent
ee8f6387ad
commit
4962ce9009
@ -10,10 +10,15 @@ cmd_t command = {
|
||||
.index = 0
|
||||
};
|
||||
|
||||
void cmd_mirror_char(char c)
|
||||
{
|
||||
printf("%c", c);
|
||||
}
|
||||
|
||||
void cmd_collect_char(char c)
|
||||
{
|
||||
command.buf[command.index] = c;
|
||||
printf("%c", command.buf[command.index]);
|
||||
command.buf[command.index] = c;
|
||||
cmd_mirror_char(c);
|
||||
command.index++;
|
||||
|
||||
|
||||
@ -42,6 +47,9 @@ void cmd_handle(cmd_t *command)
|
||||
|
||||
if (0 == strcmp(tok1, "set"))
|
||||
cmd_handle_set(tok2, tok3);
|
||||
|
||||
if (0 == strcmp(tok1, "switch"))
|
||||
cmd_handle_switch();
|
||||
}
|
||||
|
||||
void cmd_handle_set(char *op1, char *op2)
|
||||
@ -83,4 +91,14 @@ void cmd_handle_set(char *op1, char *op2)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cmd_handle_switch(void)
|
||||
{
|
||||
int state = 0;
|
||||
|
||||
PORTC ^= (1<<PC7);
|
||||
|
||||
state = PORTC & (1 << PC7);
|
||||
printf("Pin state is %i\r\n", state);
|
||||
}
|
@ -3,6 +3,8 @@ typedef struct {
|
||||
int index;
|
||||
} cmd_t;
|
||||
|
||||
void cmd_mirror_char(char c);
|
||||
void cmd_collect_char(char c);
|
||||
void cmd_handle(cmd_t *command);
|
||||
void cmd_handle_set(char *op1, char *op2);
|
||||
void cmd_handle_switch(void);
|
Loading…
Reference in New Issue
Block a user