# CPPFLAGS += -DUSB_SERIAL -DLAYOUT_US_ENGLISH
CPPFLAGS += -D__MK20DX256__ -DF_CPU=48000000
CPPFLAGS += -DUSB_RAWHID
-CPPFLAGS += -Wall -g -Os -mcpu=cortex-m4 -mthumb -nostdlib # -MMD
+CPPFLAGS += -Wall -Wno-format -g -Os
+CPPFLAGS += -mcpu=cortex-m4 -mtune=cortex-m4 -mthumb -nostdlib # -MMD
CXXFLAGS += -std=gnu++0x -felide-constructors -fno-exceptions -fno-rtti
LDFLAGS = -Os -Wl,--gc-sections -mcpu=cortex-m4 -mthumb -Tteensy3/mk20dx256.ld
LDLIBS += -lm
#include "teensy3/usb_seremu.h"
#include "teensy3/usb_rawhid.h"
+/* ?0SA 00DU, ?1CB RLDU */
+static uint8_t fixed_state[4] = { 0x33, 0x3f };
+
ssize_t _write(int fd, const void *buf, size_t nbyte)
{
char tbuf[64];
{
}
+static void pin0_irq(void)
+{
+}
+
+void portb_isr(void)
+{
+ uint32_t isfr;
+
+ //printf("irq, GPIOB_PDIR: %08x\n", GPIOB_PDIR);
+
+ GPIOD_PDOR = fixed_state[(GPIOB_PDIR >> CORE_PIN0_BIT) & 1];
+
+ isfr = PORTB_ISFR;
+ PORTB_ISFR = isfr;
+}
+
int main(void)
{
- int ret;
+ //int ret;
delay(1000); // wait for usb..
printf("starting, rawhid: %d\n", usb_rawhid_available());
+ // md pin th tr tl r l d u
+ // md bit* 6 5 4 3 2 1 0
+ // t bit b16 d5 d4 d3 d2 d1 d0
+ // t pin 0 20 6 8 7 14 2
+ // * - note: tl/tr mixed in most docs
+ pinMode(0, INPUT);
+ attachInterrupt(0, pin0_irq, CHANGE);
+
+ pinMode( 2, OUTPUT);
+ pinMode(14, OUTPUT);
+ pinMode( 7, OUTPUT);
+ pinMode( 8, OUTPUT);
+ pinMode( 6, OUTPUT);
+ pinMode(20, OUTPUT);
+
+ // led
+ pinMode(13, OUTPUT);
+ // CORE_PIN13_PORTSET = CORE_PIN13_BITMASK;
+ // CORE_PIN13_PORTCLEAR = CORE_PIN13_BITMASK;
+
+ // CORE_PIN0_PORTSET CORE_PIN0_BITMASK PORTB_PCR16
+ printf("GPIOC PDDR, PDIR: %08x %08x\n", GPIOC_PDIR, GPIOC_PDDR);
+ printf("GPIOD PDDR, PDIR: %08x %08x\n", GPIOD_PDIR, GPIOD_PDDR);
+ printf("PORTB_PCR16: %08x\n", PORTB_PCR16);
+
// ret = usb_rawhid_recv(buf, 2000);
// ret = usb_rawhid_send(buf, 2000);
- pinMode(13, OUTPUT);
- pinMode(14, OUTPUT);
while (1) {
+ delay(4000);
+ fixed_state[1] &= ~0x20;
CORE_PIN13_PORTSET = CORE_PIN13_BITMASK;
- CORE_PIN14_PORTSET = CORE_PIN14_BITMASK;
- delay(500*4);
+
+ delay(700);
+ fixed_state[1] |= 0x20;
CORE_PIN13_PORTCLEAR = CORE_PIN13_BITMASK;
- CORE_PIN14_PORTCLEAR = CORE_PIN14_BITMASK;
- delay(500*4);
}
}