From 3fd2c1289bf2e9cb79c1ce564a474930cc1eb6a0 Mon Sep 17 00:00:00 2001 From: prenticedavid Date: Tue, 31 Jan 2017 09:39:53 +0000 Subject: [PATCH] add pin macros for FRDM-KL26Z --- utility/pin_shield_1.h | 51 ++++++++++++++++++++++++++++++++++++++++++ utility/pin_shield_8.h | 26 +++++++++++++++++++++ 2 files changed, 77 insertions(+) diff --git a/utility/pin_shield_1.h b/utility/pin_shield_1.h index ad09ea0..bee667e 100644 --- a/utility/pin_shield_1.h +++ b/utility/pin_shield_1.h @@ -240,6 +240,57 @@ #define PIN_INPUT(port, pin) (port)->PDDR &= ~(1u<<(pin)) #define PIN_READ(port, pin) (port)->PDIR & (1u<<(pin)) +#elif defined(MKL26Z4) + #include + #define D0_PORT PTA + #define D0_PIN 1 + #define D1_PORT PTA + #define D1_PIN 2 + #define D2_PORT PTD + #define D2_PIN 3 //PTD4 on KL25 + #define D3_PORT PTA + #define D3_PIN 12 + #define D4_PORT PTA + #define D4_PIN 4 + #define D5_PORT PTA + #define D5_PIN 5 + #define D6_PORT PTC + #define D6_PIN 8 + #define D7_PORT PTC + #define D7_PIN 9 + #define D8_PORT PTA + #define D8_PIN 13 + #define D9_PORT PTD + #define D9_PIN 2 //PTD5 on KL25 + #define D10_PORT PTD + #define D10_PIN 4 //PTD0 + #define D11_PORT PTD + #define D11_PIN 6 //PTD2 + #define D12_PORT PTD + #define D12_PIN 7 //PTD3 + #define D13_PORT PTD + #define D13_PIN 5 //PTD1 + #define A0_PORT PTB + #define A0_PIN 0 + #define A1_PORT PTB + #define A1_PIN 1 + #define A2_PORT PTB + #define A2_PIN 2 + #define A3_PORT PTB + #define A3_PIN 3 + #define A4_PORT PTC + #define A4_PIN 2 + #define A5_PORT PTC + #define A5_PIN 1 +// Shield Control macros. Deliberately avoid the IOSET registers +#define PIN_LOW(port, pin) (port)->PCOR = (1<<(pin)) +#define PIN_HIGH(port, pin) (port)->PSOR = (1<<(pin)) +//#define PIN_LOW(port, pin) (port)->PDOR &= ~(1<<(pin)) +//#define PIN_HIGH(port, pin) (port)->PDOR |= (1<<(pin)) +#define PIN_OUTPUT(port, pin) (port)->PDDR |= (1<<(pin)) +#define PIN_INPUT(port, pin) (port)->PDDR &= ~(1u<<(pin)) +#define PIN_READ(port, pin) (port)->PDIR & (1u<<(pin)) + #elif defined(MKL05Z4) #include #define D0_PORT PTB diff --git a/utility/pin_shield_8.h b/utility/pin_shield_8.h index d7e7335..77a95b9 100644 --- a/utility/pin_shield_8.h +++ b/utility/pin_shield_8.h @@ -142,6 +142,32 @@ #define setReadDir() {PTA->PDDR &= ~0x3030;PTC->PDDR &= ~0x0300;PTD->PDDR &= ~0x0030; } #endif +#elif defined(MKL26Z4) + #include +// configure macros for the data pins +#define AMASK ((1<<13)|(1<<12)|(1<<5)|(1<<4)) +#define CMASK ((1<<9)|(1<<8)) +#define DMASK ((1<<3)|(1<<2)) //PTD5, PTD4 on KL25Z + #define write_8(d) { \ + PTA->PCOR = AMASK; PTC->PCOR = CMASK; PTD->PCOR = DMASK; \ + PTA->PSOR = (((d) & (1<<0)) << 13) \ + | (((d) & (1<<3)) << 9) \ + | (((d) & (1<<4)) >> 0) \ + | (((d) & (1<<5)) >> 0); \ + PTC->PSOR = (((d) & (1<<6)) << 2) \ + | (((d) & (1<<7)) << 2); \ + PTD->PSOR = (((d) & (1<<1)) << 1) \ + | (((d) & (1<<2)) << 1); \ + } + #define read_8() ( (((PTA->PDIR & (1<<13)) >> 13) \ + | ((PTA->PDIR & (1<<12)) >> 9) \ + | ((PTA->PDIR & (3<<4)) >> 0) \ + | ((PTC->PDIR & (3<<8)) >> 2) \ + | ((PTD->PDIR & (1<<3)) >> 1) \ + | ((PTD->PDIR & (1<<2)) >> 1))) + #define setWriteDir() {PTA->PDDR |= AMASK;PTC->PDDR |= CMASK;PTD->PDDR |= DMASK; } + #define setReadDir() {PTA->PDDR &= ~AMASK;PTC->PDDR &= ~CMASK;PTD->PDDR &= ~DMASK; } + #elif defined(MKL05Z4) || defined(TARGET_KL05Z) #include // configure macros for the data pins