diff options
author | Bernhard Tittelbach <xro@realraum.at> | 2012-02-15 01:09:13 +0000 |
---|---|---|
committer | Bernhard Tittelbach <xro@realraum.at> | 2012-02-15 01:09:13 +0000 |
commit | 0382f7ac36b2faf91995e69403ccf7e02db236ad (patch) | |
tree | 4dd8954422172fd34a4a0a11caf5f1764d41ae99 /hardware/cmx589a_teensy_test/cmx589a.c | |
parent | cmx589a test inital base (diff) |
some random rx
git-svn-id: https://svn.spreadspace.org/mur.sat@247 7de4ea59-55d0-425e-a1af-a3118ea81d4c
Diffstat (limited to 'hardware/cmx589a_teensy_test/cmx589a.c')
-rw-r--r-- | hardware/cmx589a_teensy_test/cmx589a.c | 91 |
1 files changed, 39 insertions, 52 deletions
diff --git a/hardware/cmx589a_teensy_test/cmx589a.c b/hardware/cmx589a_teensy_test/cmx589a.c index c444abb..ebeeca6 100644 --- a/hardware/cmx589a_teensy_test/cmx589a.c +++ b/hardware/cmx589a_teensy_test/cmx589a.c @@ -43,6 +43,13 @@ #define ExtInt1On EIMSK |= 1 << INT1 #define ExtInt1Config EICRA |= (1 << ISC10 ) | ( 1 << ISC11) +#define UART_SET_DEFAULT UCSR1C = 0 +#define UART_SET_8BIT UCSR1C |= (1 << UMSEL10) | (1 << UCSZ10) | (1 << UCSZ11) +#define UART_SET_EXT_CLK XCK1_DDR &= ~(1<<XCK1) + + + + //#define INIT_COUNTER_0 TCNT0 = 0 //#define SET_CTC_MODE WGM &= !7; WGM |= 2 //#define SET_EXT_FREQ_5_3_MHZ OCR0A = 3 @@ -52,33 +59,33 @@ unsigned int snr_rsii_counter = 0; ISR(INT1_vect) { snr_rsii_counter++; + + return 0; } +#define BAUD_RATE 9600 - -void send_str(const char *s); -uint8_t recv_str(char *buf, uint8_t size); -void parse_and_execute_command(const char *buf, uint8_t num); - -#if 0 -// Very simple character echo test -int main(void) +// write a string to the uart +#define uart_print(s) uart_print_P(PSTR(s)) +void uart_print_P(const char *str) { - CPU_PRESCALE(0); - usb_init(); + char c; while (1) { - int n = usb_serial_getchar(); - if (n >= 0) usb_serial_putchar(n); + c = pgm_read_byte(str++); + if (!c) break; + uart_putchar(c); } } -#else +void send_str(const char *s); +uint8_t recv_str(char *buf, uint8_t size); +void parse_and_execute_command(const char *buf, uint8_t num); // Basic command interpreter for controlling port pins int main(void) { char buf[32]; - uint8_t n; + uint8_t n, c; // set for 16 MHz clock, and turn on the LED CPU_PRESCALE(0); @@ -90,13 +97,28 @@ int main(void) ExtInt1Config; PB3_SET_OUTPUT; - PB3_TX_DISABLE; + //PB3_TX_DISABLE; + PB3_TX_ENABLE; + + usb_init(); + uart_init(BAUD_RATE); + + while (1) { + if (uart_available()) { + c = uart_getchar(); + + } + uart_print("TEST\r\n"); + } + return 0; + + //END + // initialize the USB, and then wait for the host // to set configuration. If the Teensy is powered // without a PC connected to the USB port, this // will wait forever. - usb_init(); while (!usb_configured()) /* wait */ ; _delay_ms(1000); @@ -128,7 +150,7 @@ int main(void) } } } -#endif + // Send a string to the USB serial port. The string must be in // flash memory, using PSTR @@ -243,38 +265,3 @@ void parse_and_execute_command(const char *buf, uint8_t num) send_str(PSTR("\", must be ? or =\r\n")); } - -#define BAUD_RATE 9600 - -//~ // write a string to the uart -//~ #define uart_print(s) uart_print_P(PSTR(s)) -//~ void uart_print_P(const char *str) -//~ { - //~ char c; - //~ while (1) { - //~ c = pgm_read_byte(str++); - //~ if (!c) break; - //~ uart_putchar(c); - //~ } -//~ } - -//~ // A very basic example... -//~ // when the user types a character, print it back -//~ int main(void) -//~ { - //~ uint8_t c; - - //~ CPU_PRESCALE(0); // run at 16 MHz - //~ uart_init(BAUD_RATE); - //~ uart_print("UART Example\r\n"); - //~ while (1) { - //~ if (uart_available()) { - //~ c = uart_getchar(); - //~ uart_print("Byte: "); - //~ uart_putchar(c); - //~ uart_putchar('\r'); - //~ uart_putchar('\n'); - //~ } - //~ } -//~ } - |