aboutsummaryrefslogtreecommitdiffstats
path: root/wirish/comm
diff options
context:
space:
mode:
Diffstat (limited to 'wirish/comm')
-rw-r--r--wirish/comm/HardwareSPI.cpp4
-rw-r--r--wirish/comm/HardwareSerial.cpp20
-rw-r--r--wirish/comm/HardwareSerial.h12
3 files changed, 19 insertions, 17 deletions
diff --git a/wirish/comm/HardwareSPI.cpp b/wirish/comm/HardwareSPI.cpp
index 20090f5..aea7734 100644
--- a/wirish/comm/HardwareSPI.cpp
+++ b/wirish/comm/HardwareSPI.cpp
@@ -47,8 +47,10 @@
* TODO: Do the complementary PWM outputs mess up SPI2?
* */
-#include "wirish.h"
#include "spi.h"
+#include "timer.h"
+
+#include "wirish.h"
#include "HardwareSPI.h"
static const uint32 prescaleFactors[MAX_SPI_FREQS] = {
diff --git a/wirish/comm/HardwareSerial.cpp b/wirish/comm/HardwareSerial.cpp
index 08252d8..97a5ec3 100644
--- a/wirish/comm/HardwareSerial.cpp
+++ b/wirish/comm/HardwareSerial.cpp
@@ -31,12 +31,10 @@
#include "wirish.h"
#include "HardwareSerial.h"
#include "usart.h"
-#include "gpio.h"
-#include "timers.h"
-HardwareSerial Serial1(USART1, 4500000UL, GPIOA, 9,10, TIMER1, 2);
-HardwareSerial Serial2(USART2, 2250000UL, GPIOA, 2, 3, TIMER2, 3);
-HardwareSerial Serial3(USART3, 2250000UL, GPIOB, 10,11, TIMER_INVALID, 0);
+HardwareSerial Serial1(USART1, 4500000UL, GPIOA, 9, 10, TIMER1, 2);
+HardwareSerial Serial2(USART2, 2250000UL, GPIOA, 2, 3, TIMER2, 3);
+HardwareSerial Serial3(USART3, 2250000UL, GPIOB, 10, 11, NULL, 0);
// TODO: High density device ports
HardwareSerial::HardwareSerial(uint8 usart_num,
@@ -44,15 +42,15 @@ HardwareSerial::HardwareSerial(uint8 usart_num,
gpio_dev *gpio_device,
uint8 tx_pin,
uint8 rx_pin,
- timer_dev_num timer_num,
- uint8 compare_num) {
+ timer_dev *timer_device,
+ uint8 channel_num) {
this->usart_num = usart_num;
this->max_baud = max_baud;
this->gpio_device = gpio_device;
this->tx_pin = tx_pin;
this->rx_pin = rx_pin;
- this->timer_num = timer_num;
- this->compare_num = compare_num;
+ this->timer_device = timer_device;
+ this->channel_num = channel_num;
}
uint8 HardwareSerial::read(void) {
@@ -75,9 +73,9 @@ void HardwareSerial::begin(uint32 baud) {
gpio_set_mode(gpio_device, tx_pin, GPIO_AF_OUTPUT_PP);
gpio_set_mode(gpio_device, rx_pin, GPIO_INPUT_FLOATING);
- if (timer_num != TIMER_INVALID) {
+ if (timer_device != NULL) {
/* turn off any pwm if there's a conflict on this usart */
- timer_set_mode(timer_num, compare_num, TIMER_DISABLED);
+ timer_set_mode(timer_device, channel_num, TIMER_DISABLED);
}
usart_init(usart_num, baud);
diff --git a/wirish/comm/HardwareSerial.h b/wirish/comm/HardwareSerial.h
index ef19a56..7852d51 100644
--- a/wirish/comm/HardwareSerial.h
+++ b/wirish/comm/HardwareSerial.h
@@ -31,7 +31,9 @@
#ifndef _HARDWARESERIAL_H_
#define _HARDWARESERIAL_H_
-#include "timers.h"
+#include "libmaple_types.h"
+#include "gpio.h"
+#include "timer.h"
#include "Print.h"
@@ -49,16 +51,16 @@ class HardwareSerial : public Print {
gpio_dev *gpio_device;
uint8 tx_pin;
uint8 rx_pin;
- timer_dev_num timer_num;
- uint8 compare_num;
+ timer_dev *timer_device;
+ uint8 channel_num;
public:
HardwareSerial(uint8 usart_num,
uint32 max_baud,
gpio_dev *gpio_device,
uint8 tx_pin,
uint8 rx_pin,
- timer_dev_num timer_num,
- uint8 compare_num);
+ timer_dev *timer_device,
+ uint8 channel_num);
void begin(uint32 baud);
void end(void);
uint32 available(void);