Update test app
git-svn-id: https://bucket.mit.edu/svn/nilm/zoom@5805 ddd99763-3ecb-0310-9145-efcb8ce7c51f
This commit is contained in:
parent
3c9c415f7d
commit
04012c7080
|
@ -38,6 +38,16 @@ void uart_put(int uart, uint8_t x)
|
|||
}
|
||||
}
|
||||
|
||||
int uart_can_get(int uart)
|
||||
{
|
||||
if (uart == 1)
|
||||
return U1STAbits.URXDA;
|
||||
else if (uart == 2)
|
||||
return U2STAbits.URXDA;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t uart_get(int uart)
|
||||
{
|
||||
uint8_t data = 0;
|
||||
|
|
|
@ -25,6 +25,7 @@ int uart_can_put(int uart);
|
|||
|
||||
/* Helpers to work with a specific uart */
|
||||
#define uart1_init(x) uart_init(1, x)
|
||||
#define uart1_can_get() uart_can_get(1)
|
||||
#define uart1_get() uart_get(1)
|
||||
#define uart1_put(x) uart_put(1,x)
|
||||
#define uart1_put_string(x) uart_put_string(1,x)
|
||||
|
@ -36,6 +37,7 @@ int uart_can_put(int uart);
|
|||
#define uart1_put_dec(x) uart_put_dec(1,x)
|
||||
|
||||
#define uart2_init(x) uart_init(2, x)
|
||||
#define uart2_can_get() uart_can_get(2)
|
||||
#define uart2_get() uart_get(2)
|
||||
#define uart2_put(x) uart_put(2,x)
|
||||
#define uart2_put_string(x) uart_put_string(2,x)
|
||||
|
|
|
@ -15,7 +15,7 @@ int main(void)
|
|||
dac_init();
|
||||
uart1_put_string("ADC/DAC test\r\n");
|
||||
|
||||
for(;;) {
|
||||
for (;;) {
|
||||
switch((ch = uart1_get())) {
|
||||
case 'r':
|
||||
uart1_put_string("read");
|
||||
|
@ -45,15 +45,19 @@ int main(void)
|
|||
dac_write(v);
|
||||
break;
|
||||
case 't':
|
||||
for (v = 0; v < 8; v++) {
|
||||
uart1_put_string("toggling, keypress to end\r\n");
|
||||
while (!uart1_can_get()) {
|
||||
dac_write(0x0000);
|
||||
dac_write(0xFFFF);
|
||||
}
|
||||
uart1_get();
|
||||
break;
|
||||
case 's':
|
||||
for (v = 0; v < 65536; v++) {
|
||||
dac_write(v);
|
||||
}
|
||||
uart1_put_string("sweeps, keypress to end\r\n");
|
||||
while (!uart1_can_get())
|
||||
for (v = 0; v < 65536; v++)
|
||||
dac_write(v);
|
||||
uart1_get();
|
||||
break;
|
||||
default:
|
||||
uart1_put_string("ADC: Read Convert\r\n");
|
||||
|
|
Loading…
Reference in New Issue
Block a user