|
-
-
- #include <Arduino.h>
- #include "HardwareSerial.h"
-
- #ifndef SERIAL1_TX_BUFFER_SIZE
- #define SERIAL1_TX_BUFFER_SIZE 64
- #endif
- #ifndef SERIAL1_RX_BUFFER_SIZE
- #define SERIAL1_RX_BUFFER_SIZE 64
- #endif
- #define IRQ_PRIORITY 64
-
- void IRQHandler_Serial1()
- {
- Serial1.IRQHandler();
- }
-
- void serial_event_check_serial1()
- {
- if (Serial1.available()) serialEvent1();
- }
-
-
- static BUFTYPE tx_buffer1[SERIAL1_TX_BUFFER_SIZE];
- static BUFTYPE rx_buffer1[SERIAL1_RX_BUFFER_SIZE];
-
- const HardwareSerial::hardware_t UART6_Hardware = {
- 0, IRQ_LPUART6, &IRQHandler_Serial1, &serial_event_check_serial1,
- CCM_CCGR3, CCM_CCGR3_LPUART6(CCM_CCGR_ON),
- {{0,2, &IOMUXC_LPUART6_RX_SELECT_INPUT, 1}, {0xff, 0xff, nullptr, 0}},
- {{1,2, nullptr, 0}, {0xff, 0xff, nullptr, 0}},
- 0xff,
- 0,
- IRQ_PRIORITY, 38, 24,
- };
- HardwareSerial Serial1(&IMXRT_LPUART6, &UART6_Hardware, tx_buffer1, SERIAL1_TX_BUFFER_SIZE,
- rx_buffer1, SERIAL1_RX_BUFFER_SIZE);
-
- void serialEvent1() __attribute__((weak));
- void serialEvent1() {Serial1.disableSerialEvents(); }
-
-
- void serial_print(const char *p)
- {
- Serial1.write(p);
- }
-
- static void serial_phex1(uint32_t n)
- {
- n &= 15;
- if (n < 10) {
- Serial1.write('0' + n);
- } else {
- Serial1.write('A' - 10 + n);
- }
- }
-
- void serial_phex(uint32_t n)
- {
- serial_phex1(n >> 4);
- serial_phex1(n);
- }
-
- void serial_phex16(uint32_t n)
- {
- serial_phex(n >> 8);
- serial_phex(n);
- }
-
- void serial_phex32(uint32_t n)
- {
- serial_phex(n >> 24);
- serial_phex(n >> 16);
- serial_phex(n >> 8);
- serial_phex(n);
- }
|