From f1598e62ac2cdd4a6077aed6ca200743a4de59e5 Mon Sep 17 00:00:00 2001 From: iperry Date: Sun, 10 Jan 2010 13:22:52 +0000 Subject: enabled serial3 git-svn-id: https://leaflabs.googlecode.com/svn/trunk/library@109 749a229e-a60e-11de-b98f-4500b42dc123 --- Makefile | 11 ++++------- src/lib/usart.c | 8 +++++++- src/main.cpp | 22 +++++++++++++++++----- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 8260770..3f45b5f 100644 --- a/Makefile +++ b/Makefile @@ -109,16 +109,15 @@ _CPPOBJ = $(boop:.cpp=.o) COBJ = $(patsubst %, $(BUILD_PATH)/%,$(_COBJ)) CPPOBJ = $(patsubst %, $(BUILD_PATH)/%,$(_CPPOBJ)) -.PHONY: run cscope clean info - +.PHONY: run cscope clean info program_ram program_flash program_jtag info: @echo "Maple library help" @echo "------------------:" @echo "Compile targets:" - @echo " ram: Compile sketch code for RAM to be loaded over the bootloader" - @echo " flash: Compile sketch code for flash to be loaded over the bootloader" - @echo " jtag: Compile sketch code for flash to be loaded over JTAG" + @echo " ram: Compile sketch code for RAM to be loaded over the bootloader" + @echo " flash: Compile sketch code for flash to be loaded over the bootloader" + @echo " jtag: Compile sketch code for flash to be loaded over JTAG" @echo "" @echo "Programming targets:" @echo " program_ram: Upload code to RAM via bootloader" @@ -138,13 +137,11 @@ $(OUTDIRS): # actual build rules $(COBJ) : $(BUILD_PATH)/%.o : %.c @echo $(MSG_COMPILING) $< - @echo $(PATH) $(CC) $(CFLAGS) -c $< -o $@ @echo $(CPPOBJ) : $(BUILD_PATH)/%.o : %.cpp @echo $(MSG_COMPILING) $< - @echo $(PATH) $(CPP) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ @echo diff --git a/src/lib/usart.c b/src/lib/usart.c index a06690e..76685fd 100644 --- a/src/lib/usart.c +++ b/src/lib/usart.c @@ -83,7 +83,12 @@ void USART2_IRQHandler(void) { ring_buf2.buf[ring_buf2.tail++] = (uint8_t)(((usart_port*)(USART2_BASE))->DR); ring_buf2.tail %= USART_RECV_BUF_SIZE; } - +/* Don't overrun your buffer, seriously */ +void USART3_IRQHandler(void) { + /* Read the data */ + ring_buf3.buf[ring_buf2.tail++] = (uint8_t)(((usart_port*)(USART3_BASE))->DR); + ring_buf3.tail %= USART_RECV_BUF_SIZE; +} /** * @brief Enable a USART in single buffer transmission mode, multibuffer @@ -124,6 +129,7 @@ void usart_init(uint8 usart_num, uint32 baud) { port = (usart_port*)USART3_BASE; ring_buf = &ring_buf3; clk_speed = USART3_CLK; + RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE); break; default: /* should never get here */ diff --git a/src/main.cpp b/src/main.cpp index b260bd0..edd4fbb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,19 +1,31 @@ #include "wiring.h" #include "HardwareSerial.h" #include "wiring_math.h" +#include "HardwareUsb.h" #include "usb.h" +//HardwareUsb USB; + int ledPin = 13; -int toggle=0; void setup() { pinMode(ledPin,OUTPUT); + Serial2.begin(9600); + Serial3.begin(9600); } +volatile int toggle = 1; + void loop() { - digitalWrite(ledPin, HIGH); - delay(1000); - digitalWrite(ledPin,LOW); - delay(1000); + digitalWrite(ledPin, toggle); + toggle ^= 1; + delay(500); +// USB.print(millis()); +// USB.println("\r"); + Serial2.print(millis(), DEC); + Serial3.print(millis(), DEC); + Serial3.print(": "); +// Serial3.print(USB.available(), DEC); + Serial3.println(); } int main(void) { -- cgit v1.2.3