X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=teensy3%2Fcore_pins.h;h=9449b059c8bdc7f08fb54ed16d6e15d9d315a8f7;hb=a773ac06cdc55be51ebc0bc61aa6066b54746c7d;hp=14ee829d0bec9b10251ae7637c8644147ed45ec2;hpb=35f00b6caaac4a8b93247913f0863bcd8f419041;p=megadrive.git diff --git a/teensy3/core_pins.h b/teensy3/core_pins.h index 14ee829..9449b05 100644 --- a/teensy3/core_pins.h +++ b/teensy3/core_pins.h @@ -10,10 +10,10 @@ * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * - * 1. The above copyright notice and this permission notice shall be + * 1. The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * - * 2. If the Software is incorporated into a build system that allows + * 2. If the Software is incorporated into a build system that allows * selection among a list of target devices, then similar target * devices manufactured by PJRC.COM must be included in the list of * target devices and selectable in the same manner. @@ -31,7 +31,7 @@ #ifndef _core_pins_h_ #define _core_pins_h_ -#include "mk20dx128.h" +#include "kinetis.h" #include "pins_arduino.h" @@ -50,29 +50,29 @@ // Pin Arduino // 0 B16 RXD // 1 B17 TXD -// 2 D0 -// 3 A12 FTM1_CH0 -// 4 A13 FTM1_CH1 +// 2 D0 +// 3 A12 FTM1_CH0 +// 4 A13 FTM1_CH1 // 5 D7 FTM0_CH7 OC0B/T1 // 6 D4 FTM0_CH4 OC0A -// 7 D2 +// 7 D2 // 8 D3 ICP1 // 9 C3 FTM0_CH2 OC1A // 10 C4 FTM0_CH3 SS/OC1B // 11 C6 MOSI/OC2A // 12 C7 MISO -// 13 C5 SCK -// 14 D1 -// 15 C0 -// 16 B0 (FTM1_CH0) -// 17 B1 (FTM1_CH1) +// 13 C5 SCK +// 14 D1 +// 15 C0 +// 16 B0 (FTM1_CH0) +// 17 B1 (FTM1_CH1) // 18 B3 SDA // 19 B2 SCL -// 20 D5 FTM0_CH5 -// 21 D6 FTM0_CH6 -// 22 C1 FTM0_CH0 -// 23 C2 FTM0_CH1 -// 24 A5 (FTM0_CH2) +// 20 D5 FTM0_CH5 +// 21 D6 FTM0_CH6 +// 22 C1 FTM0_CH0 +// 23 C2 FTM0_CH1 +// 24 A5 (FTM0_CH2) // 25 B19 // 26 E1 // 27 C9 @@ -693,6 +693,11 @@ void analogWriteRes(uint32_t bits); static inline void analogWriteResolution(uint32_t bits) { analogWriteRes(bits); } void analogWriteFrequency(uint8_t pin, uint32_t frequency); void analogWriteDAC0(int val); +#ifdef __cplusplus +void attachInterruptVector(IRQ_NUMBER_t irq, void (*function)(void)); +#else +void attachInterruptVector(enum IRQ_NUMBER_t irq, void (*function)(void)); +#endif void attachInterrupt(uint8_t pin, void (*function)(void), int mode); void detachInterrupt(uint8_t pin); void _init_Teensyduino_internal_(void); @@ -770,16 +775,36 @@ uint32_t micros(void); static inline void delayMicroseconds(uint32_t) __attribute__((always_inline, unused)); static inline void delayMicroseconds(uint32_t usec) { -#if F_CPU == 96000000 +#if F_CPU == 168000000 + uint32_t n = usec * 56; +#elif F_CPU == 144000000 + uint32_t n = usec * 48; +#elif F_CPU == 120000000 + uint32_t n = usec * 40; +#elif F_CPU == 96000000 uint32_t n = usec << 5; +#elif F_CPU == 72000000 + uint32_t n = usec * 24; #elif F_CPU == 48000000 uint32_t n = usec << 4; #elif F_CPU == 24000000 uint32_t n = usec << 3; +#elif F_CPU == 16000000 + uint32_t n = usec << 2; +#elif F_CPU == 8000000 + uint32_t n = usec << 1; +#elif F_CPU == 4000000 + uint32_t n = usec; +#elif F_CPU == 2000000 + uint32_t n = usec >> 1; #endif - if (usec == 0) return; - asm volatile( + // changed because a delay of 1 micro Sec @ 2MHz will be 0 + if (n == 0) return; + __asm__ volatile( "L_%=_delayMicroseconds:" "\n\t" +#if F_CPU < 24000000 + "nop" "\n\t" +#endif "subs %0, #1" "\n\t" "bne L_%=_delayMicroseconds" "\n" : "+r" (n) :