diff options
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | src/lib/usart.c | 6 | ||||
-rw-r--r-- | src/main.cpp | 20 |
3 files changed, 17 insertions, 11 deletions
@@ -194,7 +194,7 @@ run: $(BUILD_PATH)/main.bin cscope: rm -rf *.cscope - find . -iname "*.[hcs]" | grep -v examples | xargs cscope -R -b + find . ../bootloader -iname "*.[hcs]" | grep -v examples | xargs cscope -R -b clean: rm -f *.hex *.o diff --git a/src/lib/usart.c b/src/lib/usart.c index 76685fd..96e920c 100644 --- a/src/lib/usart.c +++ b/src/lib/usart.c @@ -86,7 +86,7 @@ void USART2_IRQHandler(void) { /* 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.buf[ring_buf3.tail++] = (uint8_t)(((usart_port*)(USART3_BASE))->DR); ring_buf3.tail %= USART_RECV_BUF_SIZE; } @@ -124,12 +124,14 @@ void usart_init(uint8 usart_num, uint32 baud) { ring_buf = &ring_buf2; clk_speed = USART2_CLK; RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE); + REG_SET(NVIC_ISER1, BIT(6)); break; case 3: port = (usart_port*)USART3_BASE; ring_buf = &ring_buf3; clk_speed = USART3_CLK; RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE); + REG_SET(NVIC_ISER1, BIT(7)); break; default: /* should never get here */ @@ -153,8 +155,6 @@ void usart_init(uint8 usart_num, uint32 baud) { USART_RE | // receiver enable USART_RXNEIE; // receive interrupt enable - /* Turn it on in the nvic */ - REG_SET(NVIC_ISER1, BIT(6)); /* Enable the USART and set mode to 8n1 */ port->CR1 |= USART_UE; diff --git a/src/main.cpp b/src/main.cpp index edd4fbb..78cdf13 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4,28 +4,34 @@ #include "HardwareUsb.h"
#include "usb.h"
-//HardwareUsb USB;
+HardwareUsb USB;
int ledPin = 13;
void setup() {
pinMode(ledPin,OUTPUT);
- Serial2.begin(9600);
+// Serial2.begin(9600);
Serial3.begin(9600);
+ Serial3.println("hello");
}
volatile int toggle = 1;
+char c;
void loop() {
digitalWrite(ledPin, toggle);
toggle ^= 1;
delay(500);
// USB.print(millis());
+// Serial3.println("hello");
// USB.println("\r");
- Serial2.print(millis(), DEC);
- Serial3.print(millis(), DEC);
- Serial3.print(": ");
-// Serial3.print(USB.available(), DEC);
- Serial3.println();
+// Serial2.print(millis(), DEC);
+// Serial2.print(": ");
+// Serial2.print(USB.available(), DEC);
+// Serial2.println();
+ if (Serial3.available()){
+ c = Serial3.read();
+ Serial3.print(c);
+ }
}
int main(void) {
|