add keil pin definitions for DUE

This commit is contained in:
prenticedavid
2019-11-19 17:33:34 +00:00
parent 7de07a9dad
commit 8445aad72e
2 changed files with 83 additions and 0 deletions

View File

@@ -743,6 +743,57 @@
#define PIN_INPUT(port, pin) (port).DIR.reg &= ~(1u<<(pin))
#define PIN_READ(port, pin) (port).IN.reg & (1u<<(pin))
//####################################### DUE ############################
#elif defined(__SAM3X8E__)
#include <sam.h>
#define D0_PORT PIOA
#define D0_PIN 8
#define D1_PORT PIOA
#define D1_PIN 9
#define D2_PORT PIOB
#define D2_PIN 25
#define D3_PORT PIOC
#define D3_PIN 28
#define D4_PORT PIOC //also PA29
#define D4_PIN 26
#define D5_PORT PIOC
#define D5_PIN 25
#define D6_PORT PIOC
#define D6_PIN 24
#define D7_PORT PIOC
#define D7_PIN 23
#define D8_PORT PIOC
#define D8_PIN 22
#define D9_PORT PIOC
#define D9_PIN 21
#define D10_PORT PIOC //also PA28
#define D10_PIN 29
#define D11_PORT PIOD
#define D11_PIN 7
#define D12_PORT PIOD
#define D12_PIN 8
#define D13_PORT PIOB
#define D13_PIN 27
#define A0_PORT PIOA
#define A0_PIN 16
#define A1_PORT PIOA
#define A1_PIN 24
#define A2_PORT PIOA
#define A2_PIN 23
#define A3_PORT PIOA
#define A3_PIN 22
#define A4_PORT PIOA
#define A4_PIN 6
#define A5_PORT PIOA
#define A5_PIN 4
// Shield Control macros.
#define PIN_LOW(port, pin) (port)->PIO_CODR = (1<<(pin))
#define PIN_HIGH(port, pin) (port)->PIO_SODR = (1<<(pin))
#define PIN_OUTPUT(port, pin) (port)->PIO_OER = (1<<(pin))
#define PIN_INPUT(port, pin) (port)->PIO_ODR &= ~(1u<<(pin))
#define PIN_READ(port, pin) (port)->PIO_PDSR & (1u<<(pin))
#elif defined(__AVR_ATxmegaA4U__)
#include <avr/io.h>

View File

@@ -435,6 +435,38 @@
PORTA.WRCONFIG.reg = (DMASK>>16) | (1<<17) | (1<<28) | (1<<30) | (1<<31); \
}
#endif
//####################################### DUE ############################
#elif defined(__SAM3X8E__) //regular UNO shield on DUE
// configure macros for data bus
#define BMASK (1<<25)
#define CMASK (0xBF << 21)
#define write_8(x) { PIOB->PIO_CODR = BMASK; PIOC->PIO_CODR = CMASK; \
PIOB->PIO_SODR = (((x) & (1<<2)) << 23); \
PIOC->PIO_SODR = (((x) & (1<<0)) << 22) \
| (((x) & (1<<1)) << 20) \
| (((x) & (1<<3)) << 25) \
| (((x) & (1<<4)) << 22) \
| (((x) & (1<<5)) << 20) \
| (((x) & (1<<6)) << 18) \
| (((x) & (1<<7)) << 16); \
}
#define read_8() ( ((PIOC->PIO_PDSR & (1<<22)) >> 22)\
| ((PIOC->PIO_PDSR & (1<<21)) >> 20)\
| ((PIOB->PIO_PDSR & (1<<25)) >> 23)\
| ((PIOC->PIO_PDSR & (1<<28)) >> 25)\
| ((PIOC->PIO_PDSR & (1<<26)) >> 22)\
| ((PIOC->PIO_PDSR & (1<<25)) >> 20)\
| ((PIOC->PIO_PDSR & (1<<24)) >> 18)\
| ((PIOC->PIO_PDSR & (1<<23)) >> 16)\
)
#define setWriteDir() { PIOB->PIO_OER = BMASK; PIOC->PIO_OER = CMASK; }
#define setReadDir() { \
PMC->PMC_PCER0 = (1 << ID_PIOB)|(1 << ID_PIOC);\
PIOB->PIO_ODR = BMASK; PIOC->PIO_ODR = CMASK;\
}
#else
#error MCU unselected
#endif // MCUs