From 0382f7ac36b2faf91995e69403ccf7e02db236ad Mon Sep 17 00:00:00 2001 From: Bernhard Tittelbach Date: Wed, 15 Feb 2012 01:09:13 +0000 Subject: some random rx git-svn-id: https://svn.spreadspace.org/mur.sat@247 7de4ea59-55d0-425e-a1af-a3118ea81d4c --- hardware/cmx589a_teensy_test/Makefile | 2 +- hardware/cmx589a_teensy_test/cmx589a.c | 91 +++++++++++++++------------------- hardware/cmx589a_teensy_test/uart.c | 9 +++- 3 files changed, 48 insertions(+), 54 deletions(-) (limited to 'hardware/cmx589a_teensy_test') diff --git a/hardware/cmx589a_teensy_test/Makefile b/hardware/cmx589a_teensy_test/Makefile index 6194ad8..0640c09 100644 --- a/hardware/cmx589a_teensy_test/Makefile +++ b/hardware/cmx589a_teensy_test/Makefile @@ -272,7 +272,7 @@ LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB) AVRDUDE_PROGRAMMER = stk500v2 # com1 = serial port. Use lpt1 to connect to parallel port. -AVRDUDE_PORT = com1 # programmer connected to serial device +AVRDUDE_PORT = /dev/ # programmer connected to serial device AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex #AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep 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<= 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'); - //~ } - //~ } -//~ } - diff --git a/hardware/cmx589a_teensy_test/uart.c b/hardware/cmx589a_teensy_test/uart.c index 2fdcc43..94afe7e 100644 --- a/hardware/cmx589a_teensy_test/uart.c +++ b/hardware/cmx589a_teensy_test/uart.c @@ -48,9 +48,16 @@ void uart_init(uint32_t baud) UBRR1 = (F_CPU / 4 / baud - 1) / 2; UCSR1A = (1<