mirror of
https://github.com/YuzuZensai/MCUFRIEND_kbv.git
synced 2026-01-31 14:57:48 +00:00
support macros for Bobcachealot Teensy
This commit is contained in:
@@ -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_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))
|
||||
|
||||
#else
|
||||
#define USE_SPECIAL_FAIL
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user