No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

553 líneas
15KB

  1. #include "HardwareSerial.h"
  2. #include "core_pins.h"
  3. #include "Arduino.h"
  4. //#include "debug/printf.h"
  5. /*typedef struct {
  6. const uint32_t VERID;
  7. const uint32_t PARAM;
  8. volatile uint32_t GLOBAL;
  9. volatile uint32_t PINCFG;
  10. volatile uint32_t BAUD;
  11. volatile uint32_t STAT;
  12. volatile uint32_t CTRL;
  13. volatile uint32_t DATA;
  14. volatile uint32_t MATCH;
  15. volatile uint32_t MODIR;
  16. volatile uint32_t FIFO;
  17. volatile uint32_t WATER;
  18. } IMXRT_LPUART_t; */
  19. #define UART_CLOCK 24000000
  20. #ifndef SERIAL1_TX_BUFFER_SIZE
  21. #define SERIAL1_TX_BUFFER_SIZE 64 // number of outgoing bytes to buffer
  22. #endif
  23. #ifndef SERIAL1_RX_BUFFER_SIZE
  24. #define SERIAL1_RX_BUFFER_SIZE 64 // number of incoming bytes to buffer
  25. #endif
  26. #ifndef SERIAL2_TX_BUFFER_SIZE
  27. #define SERIAL2_TX_BUFFER_SIZE 40 // number of outgoing bytes to buffer
  28. #endif
  29. #ifndef SERIAL2_RX_BUFFER_SIZE
  30. #define SERIAL2_RX_BUFFER_SIZE 64 // number of incoming bytes to buffer
  31. #endif
  32. #ifndef SERIAL3_TX_BUFFER_SIZE
  33. #define SERIAL3_TX_BUFFER_SIZE 40 // number of outgoing bytes to buffer
  34. #endif
  35. #ifndef SERIAL3_RX_BUFFER_SIZE
  36. #define SERIAL3_RX_BUFFER_SIZE 64 // number of incoming bytes to buffer
  37. #endif
  38. #ifndef SERIAL4_TX_BUFFER_SIZE
  39. #define SERIAL4_TX_BUFFER_SIZE 40 // number of outgoing bytes to buffer
  40. #endif
  41. #ifndef SERIAL4_RX_BUFFER_SIZE
  42. #define SERIAL4_RX_BUFFER_SIZE 64 // number of incoming bytes to buffer
  43. #endif
  44. #ifndef SERIAL5_TX_BUFFER_SIZE
  45. #define SERIAL5_TX_BUFFER_SIZE 40 // number of outgoing bytes to buffer
  46. #endif
  47. #ifndef SERIAL5_RX_BUFFER_SIZE
  48. #define SERIAL5_RX_BUFFER_SIZE 64 // number of incoming bytes to buffer
  49. #endif
  50. #ifndef SERIAL6_TX_BUFFER_SIZE
  51. #define SERIAL6_TX_BUFFER_SIZE 40 // number of outgoing bytes to buffer
  52. #endif
  53. #ifndef SERIAL6_RX_BUFFER_SIZE
  54. #define SERIAL6_RX_BUFFER_SIZE 64 // number of incoming bytes to buffer
  55. #endif
  56. #ifndef SERIAL7_TX_BUFFER_SIZE
  57. #define SERIAL7_TX_BUFFER_SIZE 40 // number of outgoing bytes to buffer
  58. #endif
  59. #ifndef SERIAL7_RX_BUFFER_SIZE
  60. #define SERIAL7_RX_BUFFER_SIZE 64 // number of incoming bytes to buffer
  61. #endif
  62. #ifndef SERIAL8_TX_BUFFER_SIZE
  63. #define SERIAL8_TX_BUFFER_SIZE 40 // number of outgoing bytes to buffer
  64. #endif
  65. #ifndef SERIAL8_RX_BUFFER_SIZE
  66. #define SERIAL8_RX_BUFFER_SIZE 64 // number of incoming bytes to buffer
  67. #endif
  68. #define IRQ_PRIORITY 64 // 0 = highest priority, 255 = lowest
  69. #define CTRL_ENABLE (LPUART_CTRL_TE | LPUART_CTRL_RE | LPUART_CTRL_RIE)
  70. #define CTRL_TX_ACTIVE (CTRL_ENABLE | LPUART_CTRL_TIE)
  71. #define CTRL_TX_COMPLETING (CTRL_ENABLE | LPUART_CTRL_TCIE)
  72. #define CTRL_TX_INACTIVE CTRL_ENABLE
  73. void HardwareSerial::begin(uint32_t baud, uint8_t format)
  74. {
  75. //printf("HardwareSerial begin\n");
  76. float base = (float)UART_CLOCK / (float)baud;
  77. float besterr = 1e20;
  78. int bestdiv = 1;
  79. int bestosr = 4;
  80. for (int osr=4; osr <= 32; osr++) {
  81. float div = base / (float)osr;
  82. int divint = (int)(div + 0.5f);
  83. if (divint < 1) divint = 1;
  84. else if (divint > 8191) divint = 8191;
  85. float err = ((float)divint - div) / div;
  86. if (err < 0.0f) err = -err;
  87. if (err <= besterr) {
  88. besterr = err;
  89. bestdiv = divint;
  90. bestosr = osr;
  91. }
  92. }
  93. //printf(" baud %d: osr=%d, div=%d\n", baud, bestosr, bestdiv);
  94. rx_buffer_head_ = 0;
  95. rx_buffer_tail_ = 0;
  96. tx_buffer_head_ = 0;
  97. tx_buffer_tail_ = 0;
  98. transmitting_ = 0;
  99. hardware->ccm_register |= hardware->ccm_value;
  100. uint32_t fastio = IOMUXC_PAD_SRE | IOMUXC_PAD_DSE(3) | IOMUXC_PAD_SPEED(3);
  101. *(portControlRegister(hardware->rx_pin)) = fastio;
  102. *(portControlRegister(hardware->tx_pin)) = fastio;
  103. *(portConfigRegister(hardware->rx_pin)) = hardware->rx_mux_val;
  104. *(portConfigRegister(hardware->tx_pin)) = hardware->tx_mux_val;
  105. //hardware->rx_mux_register = hardware->rx_mux_val;
  106. //hardware->tx_mux_register = hardware->tx_mux_val;
  107. hardware->rx_select_input_register = hardware->rx_select_val;
  108. port->BAUD = LPUART_BAUD_OSR(bestosr - 1) | LPUART_BAUD_SBR(bestdiv);
  109. port->PINCFG = 0;
  110. // Enable the transmitter, receiver and enable receiver interrupt
  111. attachInterruptVector(hardware->irq, hardware->irq_handler);
  112. NVIC_SET_PRIORITY(hardware->irq, IRQ_PRIORITY); // maybe should put into hardware...
  113. NVIC_ENABLE_IRQ(hardware->irq);
  114. uint16_t tx_fifo_size = (((port->FIFO >> 4) & 0x7) << 2);
  115. uint8_t tx_water = (tx_fifo_size < 16) ? tx_fifo_size >> 1 : 7;
  116. uint16_t rx_fifo_size = (((port->FIFO >> 0) & 0x7) << 2);
  117. uint8_t rx_water = (rx_fifo_size < 16) ? rx_fifo_size >> 1 : 7;
  118. /*
  119. Serial.printf("SerialX::begin stat:%x ctrl:%x fifo:%x water:%x\n", port->STAT, port->CTRL, port->FIFO, port->WATER );
  120. Serial.printf(" FIFO sizes: tx:%d rx:%d\n",tx_fifo_size, rx_fifo_size);
  121. Serial.printf(" Watermark tx:%d, rx: %d\n", tx_water, rx_water);
  122. */
  123. port->WATER = LPUART_WATER_RXWATER(rx_water) | LPUART_WATER_TXWATER(tx_water);
  124. port->FIFO |= LPUART_FIFO_TXFE | LPUART_FIFO_RXFE;
  125. port->CTRL = CTRL_TX_INACTIVE;
  126. //Serial.printf(" stat:%x ctrl:%x fifo:%x water:%x\n", port->STAT, port->CTRL, port->FIFO, port->WATER );
  127. };
  128. void HardwareSerial::end(void)
  129. {
  130. }
  131. void HardwareSerial::transmitterEnable(uint8_t pin)
  132. {
  133. while (transmitting_) ;
  134. pinMode(pin, OUTPUT);
  135. digitalWrite(pin, LOW);
  136. transmit_pin_ = pin; // BUGBUG - Faster way?
  137. }
  138. void HardwareSerial::setRX(uint8_t pin)
  139. {
  140. // BUGBUG Implement
  141. //Serial.printf("SerialX TX(%d) param:%x stat:%x ctrl:%x fifo:%x water:%x\n", hardware->tx_pin, port->PARAM, port->STAT, port->CTRL, port->FIFO, port->WATER );
  142. }
  143. void HardwareSerial::setTX(uint8_t pin, bool opendrain)
  144. {
  145. // BUGBUG Implement
  146. }
  147. bool HardwareSerial::attachRts(uint8_t pin)
  148. {
  149. // BUGBUG Implement
  150. return false;
  151. }
  152. bool HardwareSerial::attachCts(uint8_t pin)
  153. {
  154. // BUGBUG Implement
  155. return false;
  156. }
  157. void HardwareSerial::clear(void)
  158. {
  159. // BUGBUG:: deal with FIFO
  160. rx_buffer_head_ = rx_buffer_tail_;
  161. //if (rts_pin_) rts_assert();
  162. }
  163. int HardwareSerial::availableForWrite(void)
  164. {
  165. uint32_t head, tail;
  166. head = tx_buffer_head_;
  167. tail = tx_buffer_tail_;
  168. if (head >= tail) return tx_buffer_total_size_ - 1 - head + tail;
  169. return tail - head - 1;
  170. }
  171. size_t HardwareSerial::write9bit(uint32_t c)
  172. {
  173. return 0;
  174. }
  175. int HardwareSerial::available(void)
  176. {
  177. uint32_t head, tail;
  178. head = rx_buffer_head_;
  179. tail = rx_buffer_tail_;
  180. if (head >= tail) return head - tail;
  181. return rx_buffer_total_size_ + head - tail;
  182. }
  183. int HardwareSerial::peek(void)
  184. {
  185. uint32_t head, tail;
  186. head = rx_buffer_head_;
  187. tail = rx_buffer_tail_;
  188. if (head == tail) return -1;
  189. if (++tail >= rx_buffer_total_size_) tail = 0;
  190. if (tail < rx_buffer_size_) {
  191. return rx_buffer_[tail];
  192. } else {
  193. return rx_buffer_storage_[tail-rx_buffer_size_];
  194. }
  195. }
  196. int HardwareSerial::read(void)
  197. {
  198. uint32_t head, tail;
  199. int c;
  200. head = rx_buffer_head_;
  201. tail = rx_buffer_tail_;
  202. if (head == tail) return -1;
  203. if (++tail >= rx_buffer_total_size_) tail = 0;
  204. if (tail < rx_buffer_size_) {
  205. c = rx_buffer_[tail];
  206. } else {
  207. c = rx_buffer_storage_[tail-rx_buffer_size_];
  208. }
  209. rx_buffer_tail_ = tail;
  210. if (rts_pin_) {
  211. uint32_t avail;
  212. if (head >= tail) avail = head - tail;
  213. else avail = rx_buffer_total_size_ + head - tail;
  214. /*
  215. if (avail <= rts_low_watermark_) rts_assert();
  216. */
  217. }
  218. return c;
  219. }
  220. void HardwareSerial::flush(void)
  221. {
  222. while (transmitting_) yield(); // wait
  223. }
  224. size_t HardwareSerial::write(uint8_t c)
  225. {
  226. uint32_t head, n;
  227. //digitalWrite(3, HIGH);
  228. //digitalWrite(5, HIGH);
  229. // if (transmit_pin_) transmit_assert();
  230. head = tx_buffer_head_;
  231. if (++head >= tx_buffer_total_size_) head = 0;
  232. while (tx_buffer_tail_ == head) {
  233. /*
  234. int priority = nvic_execution_priority();
  235. if (priority <= IRQ_PRIORITY) {
  236. if ((port->STAT & LPUART_STAT_TDRE)) {
  237. uint32_t tail = tx_buffer_tail_;
  238. if (++tail >= tx_buffer_total_size_) tail = 0;
  239. if (tail < tx_buffer_size_) {
  240. n = tx_buffer_[tail];
  241. } else {
  242. n = tx_buffer_storage_[tail-tx_buffer_size_];
  243. }
  244. port->DATA = n;
  245. tx_buffer_tail_ = tail;
  246. }
  247. } else if (priority >= 256)
  248. */
  249. {
  250. yield(); // wait
  251. }
  252. }
  253. //digitalWrite(5, LOW);
  254. //Serial.printf("WR %x %d %d %d %x %x\n", c, head, tx_buffer_size_, tx_buffer_total_size_, (uint32_t)tx_buffer_, (uint32_t)tx_buffer_storage_);
  255. if (head < tx_buffer_size_) {
  256. tx_buffer_[head] = c;
  257. } else {
  258. tx_buffer_storage_[head - tx_buffer_size_] = c;
  259. }
  260. transmitting_ = 1;
  261. tx_buffer_head_ = head;
  262. port->CTRL |= LPUART_CTRL_TIE; // (may need to handle this issue)BITBAND_SET_BIT(LPUART0_CTRL, TIE_BIT);
  263. //digitalWrite(3, LOW);
  264. return 1;
  265. }
  266. void HardwareSerial::IRQHandler()
  267. {
  268. //digitalWrite(4, HIGH);
  269. uint32_t head, tail, n;
  270. uint32_t ctrl;
  271. // See if we have stuff to read in.
  272. if (port->STAT & LPUART_STAT_RDRF) {
  273. //digitalWrite(5, HIGH);
  274. #if 1
  275. n = port->DATA; // get the byte...
  276. #else
  277. if (use9Bits_ && (port().C3 & 0x80)) {
  278. n = port().D | 0x100;
  279. } else {
  280. n = port().D;
  281. }
  282. #endif
  283. head = rx_buffer_head_ + 1;
  284. if (head >= rx_buffer_total_size_) head = 0;
  285. if (head != rx_buffer_tail_) {
  286. if (head < rx_buffer_size_) {
  287. rx_buffer_[head] = n;
  288. } else {
  289. rx_buffer_storage_[head-rx_buffer_size_] = n;
  290. }
  291. rx_buffer_head_ = head;
  292. }
  293. //digitalWrite(5, LOW);
  294. }
  295. // See if we are transmitting and room in buffer.
  296. ctrl = port->CTRL;
  297. if ((ctrl & LPUART_CTRL_TIE) && (port->STAT & LPUART_STAT_TDRE))
  298. {
  299. //digitalWrite(3, HIGH);
  300. head = tx_buffer_head_;
  301. tail = tx_buffer_tail_;
  302. do {
  303. if (head == tail) break;
  304. if (++tail >= tx_buffer_total_size_) tail = 0;
  305. if (tail < tx_buffer_size_) {
  306. n = tx_buffer_[tail];
  307. } else {
  308. n = tx_buffer_storage_[tail-tx_buffer_size_];
  309. }
  310. //if (use9Bits_) port().C3 = (port().C3 & ~0x40) | ((n & 0x100) >> 2);
  311. port->DATA = n;
  312. } while (((port->WATER >> 8) & 0x7) < 4); // need to computer properly
  313. tx_buffer_tail_ = tail;
  314. if (head == tail) port->CTRL = CTRL_TX_COMPLETING;
  315. //digitalWrite(3, LOW);
  316. }
  317. if ((ctrl & LPUART_CTRL_TCIE) && (port->STAT & LPUART_STAT_TDRE))
  318. {
  319. transmitting_ = 0;
  320. //if (transmit_pin_) transmit_deassert();
  321. port->CTRL = CTRL_TX_INACTIVE;
  322. }
  323. //digitalWrite(4, LOW);
  324. }
  325. void IRQHandler_Serial1()
  326. {
  327. Serial1.IRQHandler();
  328. }
  329. void IRQHandler_Serial2()
  330. {
  331. Serial2.IRQHandler();
  332. }
  333. void IRQHandler_Serial3()
  334. {
  335. Serial3.IRQHandler();
  336. }
  337. void IRQHandler_Serial4()
  338. {
  339. Serial4.IRQHandler();
  340. }
  341. void IRQHandler_Serial5()
  342. {
  343. Serial5.IRQHandler();
  344. }
  345. void IRQHandler_Serial6()
  346. {
  347. Serial6.IRQHandler();
  348. }
  349. void IRQHandler_Serial7()
  350. {
  351. Serial7.IRQHandler();
  352. }
  353. void IRQHandler_Serial8()
  354. {
  355. Serial8.IRQHandler();
  356. }
  357. // Serial1
  358. static BUFTYPE tx_buffer1[SERIAL1_TX_BUFFER_SIZE];
  359. static BUFTYPE rx_buffer1[SERIAL1_RX_BUFFER_SIZE];
  360. const HardwareSerial::hardware_t UART6_Hardware = {
  361. IRQ_LPUART6, &IRQHandler_Serial1,
  362. CCM_CCGR3, CCM_CCGR3_LPUART6(CCM_CCGR_ON),
  363. 0, //IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B0_03, // pin 0
  364. 1, //IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B0_02, // pin 1
  365. IOMUXC_LPUART6_RX_SELECT_INPUT,
  366. 2, // page 473
  367. 2, // page 472
  368. 1, // page 861
  369. };
  370. HardwareSerial Serial1(&IMXRT_LPUART6, &UART6_Hardware, tx_buffer1, SERIAL1_TX_BUFFER_SIZE,
  371. rx_buffer1, SERIAL1_RX_BUFFER_SIZE);
  372. // Serial2
  373. static BUFTYPE tx_buffer2[SERIAL2_TX_BUFFER_SIZE];
  374. static BUFTYPE rx_buffer2[SERIAL2_RX_BUFFER_SIZE];
  375. static HardwareSerial::hardware_t UART4_Hardware = {
  376. IRQ_LPUART4, &IRQHandler_Serial2,
  377. CCM_CCGR1, CCM_CCGR1_LPUART4(CCM_CCGR_ON),
  378. 6, //IOMUXC_SW_MUX_CTL_PAD_GPIO_B1_01, // pin 6
  379. 7, // IOMUXC_SW_MUX_CTL_PAD_GPIO_B1_00, // pin 7
  380. IOMUXC_LPUART4_RX_SELECT_INPUT,
  381. 2, // page 521
  382. 2, // page 520
  383. 0, // page 858
  384. };
  385. HardwareSerial Serial2(&IMXRT_LPUART4, &UART4_Hardware, tx_buffer2, SERIAL2_TX_BUFFER_SIZE,
  386. rx_buffer2, SERIAL2_RX_BUFFER_SIZE);
  387. // Serial3
  388. static BUFTYPE tx_buffer3[SERIAL3_TX_BUFFER_SIZE];
  389. static BUFTYPE rx_buffer3[SERIAL3_RX_BUFFER_SIZE];
  390. static HardwareSerial::hardware_t UART2_Hardware = {
  391. IRQ_LPUART2, &IRQHandler_Serial3,
  392. CCM_CCGR0, CCM_CCGR0_LPUART2(CCM_CCGR_ON),
  393. 15, //IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_03, // pin 15
  394. 14, //IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_02, // pin 14
  395. IOMUXC_LPUART2_RX_SELECT_INPUT,
  396. 2, // page 491
  397. 2, // page 490
  398. 1, // Page 855
  399. };
  400. HardwareSerial Serial3(&IMXRT_LPUART2, &UART2_Hardware,tx_buffer3, SERIAL3_TX_BUFFER_SIZE,
  401. rx_buffer3, SERIAL3_RX_BUFFER_SIZE);
  402. // Serial4
  403. static BUFTYPE tx_buffer4[SERIAL4_TX_BUFFER_SIZE];
  404. static BUFTYPE rx_buffer4[SERIAL4_RX_BUFFER_SIZE];
  405. static HardwareSerial::hardware_t UART3_Hardware = {
  406. IRQ_LPUART3, &IRQHandler_Serial4,
  407. CCM_CCGR0, CCM_CCGR0_LPUART3(CCM_CCGR_ON),
  408. 16, //IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_07, // pin 16
  409. 17, //IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_06, // pin 17
  410. IOMUXC_LPUART3_RX_SELECT_INPUT,
  411. 2, // page 495
  412. 2, // page 494
  413. 0, // Page 857
  414. };
  415. HardwareSerial Serial4(&IMXRT_LPUART3, &UART3_Hardware, tx_buffer4, SERIAL4_TX_BUFFER_SIZE,
  416. rx_buffer4, SERIAL4_RX_BUFFER_SIZE);
  417. // Serial5
  418. static BUFTYPE tx_buffer5[SERIAL5_TX_BUFFER_SIZE];
  419. static BUFTYPE rx_buffer5[SERIAL5_RX_BUFFER_SIZE];
  420. static HardwareSerial::hardware_t UART8_Hardware = {
  421. IRQ_LPUART8, &IRQHandler_Serial5,
  422. CCM_CCGR6, CCM_CCGR6_LPUART8(CCM_CCGR_ON),
  423. 21, //IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_11, // pin 21
  424. 20, //IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B1_10, // pin 20
  425. IOMUXC_LPUART8_RX_SELECT_INPUT,
  426. 2, // page 499
  427. 2, // page 498
  428. 1, // Page 864-5
  429. };
  430. HardwareSerial Serial5(&IMXRT_LPUART8, &UART8_Hardware, tx_buffer5, SERIAL5_TX_BUFFER_SIZE,
  431. rx_buffer5, SERIAL5_RX_BUFFER_SIZE);
  432. // Serial6
  433. static BUFTYPE tx_buffer6[SERIAL6_TX_BUFFER_SIZE];
  434. static BUFTYPE rx_buffer6[SERIAL6_RX_BUFFER_SIZE];
  435. uint32_t IOMUXC_LPUART1_RX_SELECT_INPUT; // bugbug - does not exist so hack
  436. static HardwareSerial::hardware_t UART1_Hardware = {
  437. IRQ_LPUART1, &IRQHandler_Serial6,
  438. CCM_CCGR5, CCM_CCGR5_LPUART1(CCM_CCGR_ON),
  439. 25, //IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B0_13, // pin 25
  440. 24, //IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B0_12, // pin 24
  441. IOMUXC_LPUART1_RX_SELECT_INPUT,
  442. 2, // page 486
  443. 2, // page 485
  444. 0, // ??? Does not have one ???
  445. };
  446. HardwareSerial Serial6(&IMXRT_LPUART1, &UART1_Hardware, tx_buffer6, SERIAL6_TX_BUFFER_SIZE,
  447. rx_buffer6, SERIAL6_RX_BUFFER_SIZE);
  448. // Serial7
  449. static BUFTYPE tx_buffer7[SERIAL7_TX_BUFFER_SIZE];
  450. static BUFTYPE rx_buffer7[SERIAL7_RX_BUFFER_SIZE];
  451. static HardwareSerial::hardware_t UART7_Hardware = {
  452. IRQ_LPUART7, &IRQHandler_Serial7,
  453. CCM_CCGR5, CCM_CCGR5_LPUART7(CCM_CCGR_ON),
  454. 28, //IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_32, // pin 28
  455. 29, //IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_31, // pin 29
  456. IOMUXC_LPUART7_RX_SELECT_INPUT,
  457. 2, // page 458
  458. 2, // page 457
  459. 1, // Page 863
  460. };
  461. HardwareSerial Serial7(&IMXRT_LPUART7, &UART7_Hardware, tx_buffer7, SERIAL7_TX_BUFFER_SIZE,
  462. rx_buffer7, SERIAL7_RX_BUFFER_SIZE);
  463. // Serial8
  464. static BUFTYPE tx_buffer8[SERIAL8_TX_BUFFER_SIZE];
  465. static BUFTYPE rx_buffer8[SERIAL8_RX_BUFFER_SIZE];
  466. static HardwareSerial::hardware_t UART5_Hardware = {
  467. IRQ_LPUART5, &IRQHandler_Serial8,
  468. CCM_CCGR3, CCM_CCGR3_LPUART5(CCM_CCGR_ON),
  469. 30, //IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_24, // pin 30
  470. 31, // IOMUXC_SW_MUX_CTL_PAD_GPIO_EMC_23, // pin 31
  471. IOMUXC_LPUART5_RX_SELECT_INPUT,
  472. 2, // page 450
  473. 2, // page 449
  474. 0,
  475. };
  476. HardwareSerial Serial8(&IMXRT_LPUART5, &UART5_Hardware, tx_buffer8, SERIAL8_TX_BUFFER_SIZE,
  477. rx_buffer8, SERIAL8_RX_BUFFER_SIZE);