Add a command to turn off Timer1.
This commit is contained in:
parent
424e2e710f
commit
8143ae4eaf
@ -6,6 +6,7 @@
|
||||
#include "commands.h"
|
||||
#include "pins.h"
|
||||
#include "uart.h"
|
||||
#include "timer.h"
|
||||
|
||||
|
||||
cmd_t command = {
|
||||
@ -38,6 +39,11 @@ void cmd_collect_char(char c)
|
||||
command.index = 0;
|
||||
cmd_terminated = 1;
|
||||
}
|
||||
|
||||
/* We are switching the timer off here because serial
|
||||
* line handling is iffy with timer on */
|
||||
if (c == 0x18)
|
||||
printf("T1: %d\r\n",cmd_handle_switch_timer());
|
||||
}
|
||||
|
||||
void cmd_handle(cmd_t *command)
|
||||
@ -57,6 +63,7 @@ void cmd_handle(cmd_t *command)
|
||||
if (0 == strcmp(tok1, "switch") || 0 == strcmp(tok1, "sw"))
|
||||
cmd_handle_switch(tok2, tok3);
|
||||
|
||||
|
||||
cmd_terminated = 0;
|
||||
}
|
||||
|
||||
@ -73,15 +80,24 @@ void cmd_handle_set(char *op1, char *op2)
|
||||
}
|
||||
else
|
||||
printf("No valid value for t0_top given\n\r");
|
||||
}
|
||||
}
|
||||
else if (0 == strcmp(op1, "t1_top")) {
|
||||
val = strtol(op2, &end, 10);
|
||||
if (op2 != end) {
|
||||
OCR0A = val;
|
||||
OCR1A = val;
|
||||
printf("Setting Timer1 TOP to %li\r\n", val);
|
||||
}
|
||||
else
|
||||
printf("No valid value for t0_top given\n\r");
|
||||
printf("No valid value for t1_top given\n\r");
|
||||
}
|
||||
else if (0 == strcmp(op1, "t1_cm")) {
|
||||
val = strtol(op2, &end, 10);
|
||||
if (op2 != end) {
|
||||
OCR1B = val;
|
||||
printf("Setting Timer1 Compare Match to %li\r\n", val);
|
||||
}
|
||||
else
|
||||
printf("No valid value for t1_cm given\n\r");
|
||||
}
|
||||
else if (0 == strcmp(op1, "t0_ps")) {
|
||||
val = strtol(op2, &end, 10);
|
||||
@ -156,4 +172,18 @@ void cmd_handle_switch(char *op1, char *op2)
|
||||
else
|
||||
togglePin(&PORTD, PD0);
|
||||
}
|
||||
}
|
||||
|
||||
int cmd_handle_switch_timer(void)
|
||||
{
|
||||
static int timer1_on = 1;
|
||||
|
||||
if (timer1_on)
|
||||
timer_disableT1();
|
||||
else
|
||||
timer_enableT1();
|
||||
|
||||
timer1_on = !timer1_on;
|
||||
|
||||
return timer1_on;
|
||||
}
|
@ -8,4 +8,5 @@ cmd_t *cmd_getcommand(void);
|
||||
void cmd_collect_char(char c);
|
||||
void cmd_handle(cmd_t *command);
|
||||
void cmd_handle_set(char *op1, char *op2);
|
||||
void cmd_handle_switch(char *op1, char *op2);
|
||||
void cmd_handle_switch(char *op1, char *op2);
|
||||
int cmd_handle_switch_timer(void);
|
Loading…
Reference in New Issue
Block a user