summaryrefslogtreecommitdiff
path: root/hardware
diff options
context:
space:
mode:
authorBernhard Tittelbach <xro@realraum.at>2012-02-15 01:09:13 +0000
committerBernhard Tittelbach <xro@realraum.at>2012-02-15 01:09:13 +0000
commit0382f7ac36b2faf91995e69403ccf7e02db236ad (patch)
tree4dd8954422172fd34a4a0a11caf5f1764d41ae99 /hardware
parentcmx589a 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')
-rw-r--r--hardware/cmx589a_teensy_test/Makefile2
-rw-r--r--hardware/cmx589a_teensy_test/cmx589a.c91
-rw-r--r--hardware/cmx589a_teensy_test/uart.c9
3 files changed, 48 insertions, 54 deletions
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<<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');
- //~ }
- //~ }
-//~ }
-
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<<U2X1);
UCSR1B = (1<<RXEN1) | (1<<TXEN1) | (1<<RXCIE1);
- UCSR1C = (1<<UCSZ11) | (1<<UCSZ10);
+ //UCSR1C = (1<<UCSZ11) | (1<<UCSZ10);
tx_buffer_head = tx_buffer_tail = 0;
rx_buffer_head = rx_buffer_tail = 0;
+
+ UCSR1C = 0;
+ UCSR1C |= (1 << UMSEL10) | (1 << UCSZ10) | (1 << UCSZ11);
+ //use external clk by settting PD5 aka XCK1 to Input
+ DDRD |= 1<<5;
+
+
sei();
}