Преглед на файлове

Merge pull request #366 from KurtE/T4_B2_PR

Add SD Cards as IO pins - plus fix Serial2 and Serial8 for T4 B2
teensy4-core
Paul Stoffregen преди 5 години
родител
ревизия
0172e0392b
No account linked to committer's email address
променени са 7 файла, в които са добавени 127 реда и са изтрити 10 реда
  1. +4
    -0
      teensy4/HardwareSerial.cpp
  2. +10
    -2
      teensy4/HardwareSerial.h
  3. +5
    -0
      teensy4/HardwareSerial2.cpp
  4. +2
    -0
      teensy4/HardwareSerial8.cpp
  5. +93
    -5
      teensy4/core_pins.h
  6. +9
    -1
      teensy4/digital.c
  7. +4
    -2
      teensy4/pins_arduino.h

+ 4
- 0
teensy4/HardwareSerial.cpp Целия файл

@@ -62,7 +62,11 @@

#define UART_CLOCK 24000000

#if defined(__IMXRT1052__)
SerialEventCheckingFunctionPointer HardwareSerial::serial_event_handler_checks[8] = {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr};
#else
SerialEventCheckingFunctionPointer HardwareSerial::serial_event_handler_checks[7] = {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr};
#endif
uint8_t HardwareSerial::serial_event_handlers_active = 0;



+ 10
- 2
teensy4/HardwareSerial.h Целия файл

@@ -120,7 +120,9 @@ extern "C" {
extern void IRQHandler_Serial5();
extern void IRQHandler_Serial6();
extern void IRQHandler_Serial7();
#if defined(__IMXRT1052__)
extern void IRQHandler_Serial8();
#endif
}

typedef void(*SerialEventCheckingFunctionPointer)();
@@ -228,9 +230,12 @@ private:
friend void IRQHandler_Serial5();
friend void IRQHandler_Serial6();
friend void IRQHandler_Serial7();
#if defined(__IMXRT1052__)
friend void IRQHandler_Serial8();

static SerialEventCheckingFunctionPointer serial_event_handler_checks[8];
#else
static SerialEventCheckingFunctionPointer serial_event_handler_checks[7];
#endif
static uint8_t serial_event_handlers_active;


@@ -243,7 +248,6 @@ extern HardwareSerial Serial4;
extern HardwareSerial Serial5;
extern HardwareSerial Serial6;
extern HardwareSerial Serial7;
extern HardwareSerial Serial8;
extern void serialEvent1(void);
extern void serialEvent2(void);
extern void serialEvent3(void);
@@ -251,7 +255,11 @@ extern void serialEvent4(void);
extern void serialEvent5(void);
extern void serialEvent6(void);
extern void serialEvent7(void);

#if defined(__IMXRT1052__)
extern HardwareSerial Serial8;
extern void serialEvent8(void);
#endif


#endif // __cplusplus

+ 5
- 0
teensy4/HardwareSerial2.cpp Целия файл

@@ -58,8 +58,13 @@ static BUFTYPE rx_buffer2[SERIAL2_RX_BUFFER_SIZE];
static HardwareSerial::hardware_t UART4_Hardware = {
1, IRQ_LPUART4, &IRQHandler_Serial2, &serial_event_check_serial2,
CCM_CCGR1, CCM_CCGR1_LPUART4(CCM_CCGR_ON),
#if defined(__IMXRT1052__)
6, //IOMUXC_SW_MUX_CTL_PAD_GPIO_B1_01, // pin 6
7, // IOMUXC_SW_MUX_CTL_PAD_GPIO_B1_00, // pin 7
#elif defined(__IMXRT1062__)
7, //IOMUXC_SW_MUX_CTL_PAD_GPIO_B1_01, // pin 6
8, // IOMUXC_SW_MUX_CTL_PAD_GPIO_B1_00, // pin 7
#endif
0xff, // No CTS pin
IOMUXC_LPUART4_RX_SELECT_INPUT,
2, // page 521

+ 2
- 0
teensy4/HardwareSerial8.cpp Целия файл

@@ -30,6 +30,7 @@

#include <Arduino.h>
#include "HardwareSerial.h"
#if defined(__IMXRT1052__)

#ifndef SERIAL8_TX_BUFFER_SIZE
#define SERIAL8_TX_BUFFER_SIZE 40 // number of outgoing bytes to buffer
@@ -73,3 +74,4 @@ HardwareSerial Serial8(&IMXRT_LPUART5, &UART5_Hardware, tx_buffer8, SERIAL8_TX_B

void serialEvent8() __attribute__((weak));
void serialEvent8() {Serial8.disableSerialEvents(); } // No use calling this so disable if called...
#endif

+ 93
- 5
teensy4/core_pins.h Целия файл

@@ -50,9 +50,9 @@

#if defined(__IMXRT1062__)

#define CORE_NUM_TOTAL_PINS 34
#define CORE_NUM_DIGITAL 34
#define CORE_NUM_INTERRUPT 34
#define CORE_NUM_TOTAL_PINS 40
#define CORE_NUM_DIGITAL 40
#define CORE_NUM_INTERRUPT 40
#define CORE_NUM_ANALOG 14
#define CORE_NUM_PWM 27

@@ -90,6 +90,12 @@
#define CORE_PIN31_BIT 23
#define CORE_PIN32_BIT 12
#define CORE_PIN33_BIT 7
#define CORE_PIN34_BIT 15
#define CORE_PIN35_BIT 14
#define CORE_PIN36_BIT 13
#define CORE_PIN37_BIT 12
#define CORE_PIN38_BIT 17
#define CORE_PIN39_BIT 16

#define CORE_PIN0_BITMASK (1<<(CORE_PIN0_BIT))
#define CORE_PIN1_BITMASK (1<<(CORE_PIN1_BIT))
@@ -125,6 +131,12 @@
#define CORE_PIN31_BITMASK (1<<(CORE_PIN31_BIT))
#define CORE_PIN32_BITMASK (1<<(CORE_PIN32_BIT))
#define CORE_PIN33_BITMASK (1<<(CORE_PIN33_BIT))
#define CORE_PIN34_BITMASK (1<<(CORE_PIN34_BIT))
#define CORE_PIN35_BITMASK (1<<(CORE_PIN35_BIT))
#define CORE_PIN36_BITMASK (1<<(CORE_PIN36_BIT))
#define CORE_PIN37_BITMASK (1<<(CORE_PIN37_BIT))
#define CORE_PIN38_BITMASK (1<<(CORE_PIN38_BIT))
#define CORE_PIN39_BITMASK (1<<(CORE_PIN39_BIT))

#define CORE_PIN0_PORTREG GPIO1_DR
#define CORE_PIN1_PORTREG GPIO1_DR
@@ -160,6 +172,12 @@
#define CORE_PIN31_PORTREG GPIO4_DR
#define CORE_PIN32_PORTREG GPIO2_DR
#define CORE_PIN33_PORTREG GPIO4_DR
#define CORE_PIN34_PORTREG GPIO3_DR
#define CORE_PIN35_PORTREG GPIO3_DR
#define CORE_PIN36_PORTREG GPIO3_DR
#define CORE_PIN37_PORTREG GPIO3_DR
#define CORE_PIN38_PORTREG GPIO3_DR
#define CORE_PIN39_PORTREG GPIO3_DR

#define CORE_PIN0_PORTSET GPIO1_DR_SET
#define CORE_PIN1_PORTSET GPIO1_DR_SET
@@ -195,6 +213,12 @@
#define CORE_PIN31_PORTSET GPIO4_DR_SET
#define CORE_PIN32_PORTSET GPIO2_DR_SET
#define CORE_PIN33_PORTSET GPIO4_DR_SET
#define CORE_PIN34_PORTSET GPIO3_DR_SET
#define CORE_PIN35_PORTSET GPIO3_DR_SET
#define CORE_PIN36_PORTSET GPIO3_DR_SET
#define CORE_PIN37_PORTSET GPIO3_DR_SET
#define CORE_PIN38_PORTSET GPIO3_DR_SET
#define CORE_PIN39_PORTSET GPIO3_DR_SET

#define CORE_PIN0_PORTCLEAR GPIO1_DR_CLEAR
#define CORE_PIN1_PORTCLEAR GPIO1_DR_CLEAR
@@ -230,6 +254,12 @@
#define CORE_PIN31_PORTCLEAR GPIO4_DR_CLEAR
#define CORE_PIN32_PORTCLEAR GPIO2_DR_CLEAR
#define CORE_PIN33_PORTCLEAR GPIO4_DR_CLEAR
#define CORE_PIN34_PORTCLEAR GPIO3_DR_CLEAR
#define CORE_PIN35_PORTCLEAR GPIO3_DR_CLEAR
#define CORE_PIN36_PORTCLEAR GPIO3_DR_CLEAR
#define CORE_PIN37_PORTCLEAR GPIO3_DR_CLEAR
#define CORE_PIN38_PORTCLEAR GPIO3_DR_CLEAR
#define CORE_PIN39_PORTCLEAR GPIO3_DR_CLEAR

#define CORE_PIN0_DDRREG GPIO1_GDIR
#define CORE_PIN1_DDRREG GPIO1_GDIR
@@ -265,6 +295,12 @@
#define CORE_PIN31_DDRREG GPIO4_GDIR
#define CORE_PIN32_DDRREG GPIO2_GDIR
#define CORE_PIN33_DDRREG GPIO4_GDIR
#define CORE_PIN34_DDRREG GPIO3_GDIR
#define CORE_PIN35_DDRREG GPIO3_GDIR
#define CORE_PIN36_DDRREG GPIO3_GDIR
#define CORE_PIN37_DDRREG GPIO3_GDIR
#define CORE_PIN38_DDRREG GPIO3_GDIR
#define CORE_PIN39_DDRREG GPIO3_GDIR

#define CORE_PIN0_PINREG GPIO1_PSR
#define CORE_PIN1_PINREG GPIO1_PSR
@@ -300,6 +336,12 @@
#define CORE_PIN31_PINREG GPIO4_PSR
#define CORE_PIN32_PINREG GPIO2_PSR
#define CORE_PIN33_PINREG GPIO4_PSR
#define CORE_PIN34_PINREG GPIO3_PSR
#define CORE_PIN35_PINREG GPIO3_PSR
#define CORE_PIN36_PINREG GPIO3_PSR
#define CORE_PIN37_PINREG GPIO3_PSR
#define CORE_PIN38_PINREG GPIO3_PSR
#define CORE_PIN39_PINREG GPIO3_PSR

// mux config registers control which peripheral uses the pin
#define CORE_PIN0_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B0_03
@@ -336,6 +378,12 @@
#define CORE_PIN31_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_23
#define CORE_PIN32_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_B0_12
#define CORE_PIN33_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_07
#define CORE_PIN34_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_SD_B0_03
#define CORE_PIN35_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_SD_B0_02
#define CORE_PIN36_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_SD_B0_01
#define CORE_PIN37_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_SD_B0_00
#define CORE_PIN38_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_SD_B0_05
#define CORE_PIN39_CONFIG IOMUXC_SW_MUX_CTL_PAD_GPIO_SD_B0_04

// pad config registers control pullup/pulldown/keeper, drive strength, etc
#define CORE_PIN0_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B0_03
@@ -372,6 +420,12 @@
#define CORE_PIN31_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_23
#define CORE_PIN32_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_B0_12
#define CORE_PIN33_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_07
#define CORE_PIN34_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_SD_B0_03
#define CORE_PIN35_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_SD_B0_02
#define CORE_PIN36_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_SD_B0_01
#define CORE_PIN37_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_SD_B0_00
#define CORE_PIN38_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_SD_B0_05
#define CORE_PIN39_PADCONFIG IOMUXC_SW_PAD_CTL_PAD_GPIO_SD_B0_04

#define CORE_LED0_PIN 13

@@ -388,8 +442,8 @@

#define CORE_RXD0_PIN 0
#define CORE_TXD0_PIN 1
#define CORE_RXD1_PIN 6
#define CORE_TXD1_PIN 7
#define CORE_RXD1_PIN 7
#define CORE_TXD1_PIN 8
#define CORE_RXD2_PIN 15
#define CORE_TXD2_PIN 14
#define CORE_RXD3_PIN 16
@@ -435,6 +489,12 @@
#define CORE_INT31_PIN 31
#define CORE_INT32_PIN 32
#define CORE_INT33_PIN 33
#define CORE_INT34_PIN 34
#define CORE_INT35_PIN 35
#define CORE_INT36_PIN 36
#define CORE_INT37_PIN 37
#define CORE_INT38_PIN 38
#define CORE_INT39_PIN 39
#define CORE_INT_EVERY_PIN 1


@@ -910,6 +970,20 @@ static inline void digitalWriteFast(uint8_t pin, uint8_t val)
CORE_PIN32_PORTSET = CORE_PIN32_BITMASK;
} else if (pin == 33) {
CORE_PIN33_PORTSET = CORE_PIN33_BITMASK;
#if defined(__IMXRT1062__)
} else if (pin == 34) {
CORE_PIN34_PORTSET = CORE_PIN34_BITMASK;
} else if (pin == 35) {
CORE_PIN35_PORTSET = CORE_PIN35_BITMASK;
} else if (pin == 36) {
CORE_PIN36_PORTSET = CORE_PIN36_BITMASK;
} else if (pin == 37) {
CORE_PIN37_PORTSET = CORE_PIN37_BITMASK;
} else if (pin == 38) {
CORE_PIN38_PORTSET = CORE_PIN38_BITMASK;
} else if (pin == 39) {
CORE_PIN39_PORTSET = CORE_PIN39_BITMASK;
#endif
}
} else {
if (pin == 0) {
@@ -980,6 +1054,20 @@ static inline void digitalWriteFast(uint8_t pin, uint8_t val)
CORE_PIN32_PORTCLEAR = CORE_PIN32_BITMASK;
} else if (pin == 33) {
CORE_PIN33_PORTCLEAR = CORE_PIN33_BITMASK;
#if defined(__IMXRT1062__)
} else if (pin == 34) {
CORE_PIN34_PORTCLEAR = CORE_PIN34_BITMASK;
} else if (pin == 35) {
CORE_PIN35_PORTCLEAR = CORE_PIN35_BITMASK;
} else if (pin == 36) {
CORE_PIN36_PORTCLEAR = CORE_PIN36_BITMASK;
} else if (pin == 37) {
CORE_PIN37_PORTCLEAR = CORE_PIN37_BITMASK;
} else if (pin == 38) {
CORE_PIN38_PORTCLEAR = CORE_PIN38_BITMASK;
} else if (pin == 39) {
CORE_PIN39_PORTCLEAR = CORE_PIN39_BITMASK;
#endif
}
}
} else {

+ 9
- 1
teensy4/digital.c Целия файл

@@ -56,7 +56,15 @@ const struct digital_pin_bitband_and_config_table_struct digital_pin_to_info_PGM
{&CORE_PIN31_PORTREG, &CORE_PIN31_CONFIG, &CORE_PIN31_PADCONFIG, CORE_PIN31_BITMASK},
{&CORE_PIN32_PORTREG, &CORE_PIN32_CONFIG, &CORE_PIN32_PADCONFIG, CORE_PIN32_BITMASK},
{&CORE_PIN33_PORTREG, &CORE_PIN33_CONFIG, &CORE_PIN33_PADCONFIG, CORE_PIN33_BITMASK},
};
#if defined(__IMXRT1062__)
{&CORE_PIN34_PORTREG, &CORE_PIN34_CONFIG, &CORE_PIN34_PADCONFIG, CORE_PIN34_BITMASK},
{&CORE_PIN35_PORTREG, &CORE_PIN35_CONFIG, &CORE_PIN35_PADCONFIG, CORE_PIN35_BITMASK},
{&CORE_PIN36_PORTREG, &CORE_PIN36_CONFIG, &CORE_PIN36_PADCONFIG, CORE_PIN36_BITMASK},
{&CORE_PIN37_PORTREG, &CORE_PIN37_CONFIG, &CORE_PIN37_PADCONFIG, CORE_PIN37_BITMASK},
{&CORE_PIN38_PORTREG, &CORE_PIN38_CONFIG, &CORE_PIN38_PADCONFIG, CORE_PIN38_BITMASK},
{&CORE_PIN39_PORTREG, &CORE_PIN39_CONFIG, &CORE_PIN39_PADCONFIG, CORE_PIN39_BITMASK},
#endif
};

void digitalWrite(uint8_t pin, uint8_t val)
{

+ 4
- 2
teensy4/pins_arduino.h Целия файл

@@ -82,7 +82,7 @@ const static uint8_t SCL = 19;
#define PIN_SERIAL_TX (1)


#define NUM_DIGITAL_PINS 34
#define NUM_DIGITAL_PINS 40
#define NUM_ANALOG_INPUTS 12


@@ -164,12 +164,14 @@ static inline uint8_t digitalPinToTimer(uint8_t pin)
#define SERIAL_PORT_HARDWARE4 Serial5
#define SERIAL_PORT_HARDWARE5 Serial6
#define SERIAL_PORT_HARDWARE6 Serial7
#define SERIAL_PORT_HARDWARE7 Serial8
#define SERIAL_PORT_HARDWARE_OPEN3 Serial4
#define SERIAL_PORT_HARDWARE_OPEN4 Serial5
#define SERIAL_PORT_HARDWARE_OPEN5 Serial6
#define SERIAL_PORT_HARDWARE_OPEN6 Serial7
#if defined(__IMXRT1052__)
#define SERIAL_PORT_HARDWARE7 Serial8
#define SERIAL_PORT_HARDWARE_OPEN7 Serial8
#endif

#define SerialUSB Serial


Loading…
Отказ
Запис