diff options
-rw-r--r-- | core/wiring_digital.c | 3 | ||||
-rw-r--r-- | libmaple/gpio.h | 4 | ||||
-rw-r--r-- | main.cpp.example | 8 |
3 files changed, 13 insertions, 2 deletions
diff --git a/core/wiring_digital.c b/core/wiring_digital.c index 25433de..c1b7201 100644 --- a/core/wiring_digital.c +++ b/core/wiring_digital.c @@ -133,8 +133,7 @@ void pinMode(uint8 pin, WiringPinMode mode) { uint32 digitalRead(uint8 pin) { if (pin >= NR_MAPLE_PINS) return 0; - - return (PIN_MAP[pin].port->IDR & BIT(PIN_MAP[pin].pin)) ? 1 : 0; + return gpio_read_bit(PIN_MAP[pin].port, PIN_MAP[pin].pin); } void digitalWrite(uint8 pin, uint8 val) { diff --git a/libmaple/gpio.h b/libmaple/gpio.h index ac8af5b..a44047e 100644 --- a/libmaple/gpio.h +++ b/libmaple/gpio.h @@ -93,6 +93,10 @@ static inline void gpio_write_bit(GPIO_Port *port, uint8 gpio_pin, uint8 val) { } } +static inline uint32 gpio_read_bit(GPIO_Port *port, uint8 gpio_pin) { + return (port->IDR & BIT(gpio_pin) ? 1 : 0); +} + #ifdef __cplusplus } // extern "C" #endif diff --git a/main.cpp.example b/main.cpp.example index 6152687..4130749 100644 --- a/main.cpp.example +++ b/main.cpp.example @@ -32,10 +32,15 @@ #include "wiring.h"
#include "HardwareSerial.h"
#include "math.h"
+#include "usb.h"
+
+uint8_t bytes_in;
#define LED_PIN 13
#define PWM_PIN 2
+HardwareUsb Usb;
+
void setup()
{
/* Set up the LED to blink */
@@ -48,6 +53,9 @@ void setup() /* Turn on PWM on pin PWM_PIN */
pinMode(PWM_PIN, PWM);
pwmWrite(PWM_PIN, 0x8000);
+
+ /* Send a message out the USB virtual com port */
+ Usb.println("Hello world!");
}
int toggle = 0;
|