Merge remote-tracking branch 'refs/remotes/origin/test_frdm'

This commit is contained in:
prenticedavid
2016-09-29 16:37:09 +01:00
2 changed files with 145 additions and 0 deletions

View File

@@ -232,6 +232,57 @@ void write_8(uint8_t x)
#define PIN_HIGH(p, b) (p) |= (1<<(b))
#define PIN_OUTPUT(p, b) *(&p-1) |= (1<<(b))
#elif defined(__MK20DX128__) || defined(__MK20DX256__) // regular UNO shield on a Teensy 3.x
#warning regular UNO shield on a Teensy 3.x
#define RD_PORT GPIOD
#define RD_PIN 1
#define WR_PORT GPIOC
#define WR_PIN 0
#define CD_PORT GPIOB
#define CD_PIN 0
#define CS_PORT GPIOB
#define CS_PIN 1
#define RESET_PORT GPIOB
#define RESET_PIN 3
// configure macros for the data pins
#define AMASK ((1<<12)|(1<<13))
#define CMASK ((1<<3))
#define DMASK ((1<<0)|(1<<2)|(1<<3)|(1<<4)|(1<<7))
#define write_8(d) { \
GPIOA_PCOR = AMASK; GPIOC_PCOR = CMASK; GPIOD_PCOR = DMASK; \
GPIOA_PSOR = (((d) & (1<<3)) << 9) \
| (((d) & (1<<4)) << 9); \
GPIOC_PSOR = (((d) & (1<<1)) << 2); \
GPIOD_PSOR = (((d) & (1<<0)) << 3) \
| (((d) & (1<<2)) >> 2) \
| (((d) & (1<<5)) << 2) \
| (((d) & (1<<6)) >> 2) \
| (((d) & (1<<7)) >> 5); \
}
#define read_8() ( (((GPIOD_PDIR & (1<<3)) >> 3) \
| ((GPIOC_PDIR & (1<<3)) >> 2) \
| ((GPIOD_PDIR & (1<<0)) << 2) \
| ((GPIOA_PDIR & (1<<12)) >> 9) \
| ((GPIOA_PDIR & (1<<13)) >> 9) \
| ((GPIOD_PDIR & (1<<7)) >> 2) \
| ((GPIOD_PDIR & (1<<4)) << 2) \
| ((GPIOD_PDIR & (1<<2)) << 5)))
#define setWriteDir() {GPIOA_PDDR |= AMASK;GPIOC_PDDR |= CMASK;GPIOD_PDDR |= DMASK; }
#define setReadDir() {GPIOA_PDDR &= ~AMASK;GPIOC_PDDR &= ~CMASK;GPIOD_PDDR &= ~DMASK; }
#define write8(x) { write_8(x); WR_ACTIVE; WR_ACTIVE; WR_STROBE; }
#define write16(x) { uint8_t h = (x)>>8, l = x; write8(h); write8(l); }
#define READ_8(dst) { RD_STROBE; RD_ACTIVE; RD_ACTIVE; RD_ACTIVE; RD_ACTIVE; RD_ACTIVE; dst = read_8(); RD_IDLE; }
#define READ_16(dst) { uint8_t hi; READ_8(hi); READ_8(dst); dst |= (hi << 8); }
#define PASTE(x, y) x ## y
#define PIN_LOW(port, pin) PASTE(port, _PCOR) = (1<<(pin))
#define PIN_HIGH(port, pin) PASTE(port, _PSOR) = (1<<(pin))
#define PIN_OUTPUT(port, pin) PASTE(port, _PDDR) |= (1<<(pin))
#else
#error MCU unsupported
#endif // regular UNO shields on Arduino boards
@@ -258,6 +309,13 @@ void write_8(uint8_t x)
#define WR_STROBE { WR_ACTIVE; WR_IDLE; } //PWLW=TWRL=50ns
#define RD_STROBE RD_IDLE, RD_ACTIVE, RD_ACTIVE, RD_ACTIVE //PWLR=TRDL=150ns, tDDR=100ns
#if defined(TEENSYDUINO)
#define CTL_INIT() { \
for (int i = 2; i <= 9; i++) pinMode(i, OUTPUT); \
for (int i = A0; i <= A4; i++) pinMode(i, OUTPUT); \
RD_OUTPUT; WR_OUTPUT; CD_OUTPUT; CS_OUTPUT; RESET_OUTPUT; }
#else
#define CTL_INIT() { RD_OUTPUT; WR_OUTPUT; CD_OUTPUT; CS_OUTPUT; RESET_OUTPUT; }
#endif
#define WriteCmd(x) { CD_COMMAND; write16(x); }
#define WriteData(x) { CD_DATA; write16(x); }

View File

@@ -10,6 +10,8 @@
//#define USE_BLD_BST_MEGA2560
//#define USE_DUE_8BIT_PROTOSHIELD
//#define USE_DUE_16BIT_SHIELD //RD on PA15 (D24)
//#define USE_BOBCACHELOT_TEENSY
//#define USE_FRDM_K20
#if 0
#elif defined(__AVR_ATmega328P__) && defined(USE_SSD1289_SHIELD_UNO) //on UNO
@@ -759,6 +761,91 @@ static inline void write_8(uint8_t val)
#define PIN_HIGH(port, pin) (port)->PIO_SODR = (1<<(pin))
#define PIN_OUTPUT(port, pin) (port)->PIO_OER = (1<<(pin))
#elif defined(__MK20DX256__) && defined(USE_BOBCACHELOT_TEENSY) // special for BOBCACHEALOT_TEENSY
#warning special for BOBCACHEALOT_TEENSY
#define RD_PORT GPIOD
#define RD_PIN 1
#define WR_PORT GPIOC
#define WR_PIN 0
#define CD_PORT GPIOB
#define CD_PIN 0
#define CS_PORT GPIOB
#define CS_PIN 1
#define RESET_PORT GPIOB
#define RESET_PIN 3
// configure macros for the data pins
#define CMASK ((1<<3))
#define DMASK ((1<<0)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7))
#define write_8(d) { \
GPIOC_PCOR = CMASK; GPIOD_PCOR = DMASK; \
GPIOC_PSOR = (((d) & (1<<1)) << 2); \
GPIOD_PSOR = (d) & DMASK; \
}
#define read_8() ( (GPIOD_PDIR & DMASK) | (GPIOC_PDIR & (1<<3)) >> 2 )
#define setWriteDir() {GPIOC_PDDR |= CMASK;GPIOD_PDDR |= DMASK; }
#define setReadDir() {GPIOC_PDDR &= ~CMASK;GPIOD_PDDR &= ~DMASK; }
#define write8(x) { write_8(x); WR_STROBE; }
#define write16(x) { uint8_t h = (x)>>8, l = x; write8(h); write8(l); }
#define READ_8(dst) { RD_STROBE; dst = read_8(); RD_IDLE; }
#define READ_16(dst) { uint8_t hi; READ_8(hi); READ_8(dst); dst |= (hi << 8); }
#define PASTE(x, y) x ## y
#define PIN_LOW(port, pin) PASTE(port, _PCOR) = (1<<(pin))
#define PIN_HIGH(port, pin) PASTE(port, _PSOR) = (1<<(pin))
#define PIN_OUTPUT(port, pin) PASTE(port, _PDDR) |= (1<<(pin))
#elif defined(__MK20DX128__) && defined(USE_FRDM_K20) // Uno Shield on FRDM-K20
#warning Uno Shield on FRDM-K20
#define RD_PORT GPIOC
#define RD_PIN 0
#define WR_PORT GPIOC
#define WR_PIN 1
#define CD_PORT GPIOD
#define CD_PIN 6
#define CS_PORT GPIOD
#define CS_PIN 5
#define RESET_PORT GPIOB
#define RESET_PIN 1
// configure macros for the data pins
#define AMASK ((1<<12)|(1<<5)|(1<<2)|(1<<1))
#define CMASK ((1<<8)|(1<<4)|(1<<3))
#define DMASK ((1<<4))
#define write_8(d) { \
GPIOA_PCOR = AMASK; GPIOC_PCOR = CMASK; GPIOD_PCOR = DMASK; \
GPIOA_PSOR = (((d) & (1<<0)) << 12) \
| (((d) & (1<<1)) << 1) \
| (((d) & (1<<2)) << 3) \
| (((d) & (1<<5)) >> 4); \
GPIOC_PSOR = (((d) & (1<<4)) << 4) \
| (((d) & (3<<6)) >> 3); \
GPIOD_PSOR = (((d) & (1<<3)) << 1); \
}
#define read_8() ( (((GPIOA_PDIR & (1<<5)) >> 3) \
| ((GPIOA_PDIR & (1<<1)) << 4) \
| ((GPIOA_PDIR & (1<<12)) >> 12) \
| ((GPIOA_PDIR & (1<<2)) >> 1) \
| ((GPIOC_PDIR & (1<<8)) >> 4) \
| ((GPIOC_PDIR & (3<<3)) << 3) \
| ((GPIOD_PDIR & (1<<4)) >> 1)))
#define setWriteDir() {GPIOA_PDDR |= AMASK;GPIOC_PDDR |= CMASK;GPIOD_PDDR |= DMASK; }
#define setReadDir() {GPIOA_PDDR &= ~AMASK;GPIOC_PDDR &= ~CMASK;GPIOD_PDDR &= ~DMASK; }
#define write8(x) { write_8(x); WR_ACTIVE; WR_ACTIVE; WR_STROBE; }
#define write16(x) { uint8_t h = (x)>>8, l = x; write8(h); write8(l); }
#define READ_8(dst) { RD_STROBE; RD_ACTIVE; RD_ACTIVE; RD_ACTIVE; RD_ACTIVE; RD_ACTIVE; dst = read_8(); RD_IDLE; }
#define READ_16(dst) { uint8_t hi; READ_8(hi); READ_8(dst); dst |= (hi << 8); }
#define PASTE(x, y) x ## y
#define PIN_LOW(port, pin) PASTE(port, _PCOR) = (1<<(pin))
#define PIN_HIGH(port, pin) PASTE(port, _PSOR) = (1<<(pin))
#define PIN_OUTPUT(port, pin) PASTE(port, _PDDR) |= (1<<(pin))
#else
#define USE_SPECIAL_FAIL
#endif