UART2MSP432E4.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
49 #ifndef ti_drivers_uart2_UART2MSP432E4__include
50 #define ti_drivers_uart2_UART2MSP432E4__include
51 
52 #include <stddef.h>
53 #include <stdint.h>
54 #include <stdbool.h>
55 
56 #include <ti/devices/msp432e4/inc/msp432.h>
57 
58 #include <ti/devices/msp432e4/driverlib/gpio.h>
59 #include <ti/devices/msp432e4/driverlib/pin_map.h>
60 #include <ti/devices/msp432e4/driverlib/udma.h>
61 
62 #include <ti/drivers/dpl/HwiP.h>
63 #include <ti/drivers/dpl/SemaphoreP.h>
65 #include <ti/drivers/UART2.h>
67 
68 #ifdef __cplusplus
69 extern "C" {
70 #endif
71 
78 #define UART2MSP432E4_PIN_UNASSIGNED 0xFFFFFFFF
79 
86 #define UART2MSP432E4_DMACH_UNASSIGNED 0xFF
87 
91 #define UART2MSP432E4_FLOWCTRL_NONE 0
92 
96 #define UART2MSP432E4_FLOWCTRL_HARDWARE 1
97 
101 #define UART2MSP432E4_PA0_U0RX GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTA, 0, GPIO_PA0_U0RX)
102 
106 #define UART2MSP432E4_PA1_U0TX GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTA, 1, GPIO_PA1_U0TX)
107 
111 #define UART2MSP432E4_PH1_U0CTS GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTH, 1, GPIO_PH1_U0CTS)
112 
116 #define UART2MSP432E4_PM4_U0CTS GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTM, 4, GPIO_PM4_U0CTS)
117 
121 #define UART2MSP432E4_PB4_U0CTS GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTB, 4, GPIO_PB4_U0CTS)
122 
126 #define UART2MSP432E4_PE6_U0CTS GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTE, 6, GPIO_PE6_U0CTS)
127 
131 #define UART2MSP432E4_PG4_U0CTS GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTG, 4, GPIO_PG4_U0CTS)
132 
136 #define UART2MSP432E4_PH0_U0RTS GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTH, 0, GPIO_PH0_U0RTS)
137 
141 #define UART2MSP432E4_PB5_U0RTS GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTB, 5, GPIO_PB5_U0RTS)
142 
146 #define UART2MSP432E4_PE7_U0RTS GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTE, 7, GPIO_PE7_U0RTS)
147 
151 #define UART2MSP432E4_PG5_U0RTS GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTG, 5, GPIO_PG5_U0RTS)
152 
153 
157 #define UART2MSP432E4_PB0_U1RX GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTB, 0, GPIO_PB0_U1RX)
158 
162 #define UART2MSP432E4_PQ4_U1RX GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTQ, 4, GPIO_PQ4_U1RX)
163 
167 #define UART2MSP432E4_PR5_U1RX GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTR, 5, GPIO_PR5_U1RX)
168 
172 #define UART2MSP432E4_PB1_U1TX GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTB, 1, GPIO_PB1_U1TX)
173 
177 #define UART2MSP432E4_PQ5_U1TX GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTQ, 5, GPIO_PQ5_U1TX)
178 
182 #define UART2MSP432E4_PR6_U1TX GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTR, 6, GPIO_PR6_U1TX)
183 
187 #define UART2MSP432E4_PP3_U1CTS GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTP, 3, GPIO_PP3_U1CTS)
188 
192 #define UART2MSP432E4_PN1_U1CTS GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTN, 1, GPIO_PN1_U1CTS)
193 
197 #define UART2MSP432E4_PE0_U1RTS GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTE, 0, GPIO_PE0_U1RTS)
198 
202 #define UART2MSP432E4_PN0_U1RTS GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTN, 0, GPIO_PN0_U1RTS)
203 
207 #define UART2MSP432E4_PN7_U1RTS GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTN, 7, GPIO_PN7_U1RTS)
208 
209 
213 #define UART2MSP432E4_PA6_U2RX GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTA, 6, GPIO_PA6_U2RX)
214 
218 #define UART2MSP432E4_PD4_U2RX GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTD, 4, GPIO_PD4_U2RX)
219 
223 #define UART2MSP432E4_PA7_U2TX GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTA, 7, GPIO_PA7_U2TX)
224 
228 #define UART2MSP432E4_PD5_U2TX GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTD, 5, GPIO_PD5_U2TX)
229 
233 #define UART2MSP432E4_PN3_U2CTS GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTN, 3, GPIO_PN3_U2CTS)
234 
238 #define UART2MSP432E4_PD7_U2CTS GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTD, 7, GPIO_PD7_U2CTS)
239 
243 #define UART2MSP432E4_PJ3_U2CTS GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTJ, 3, GPIO_PJ3_U2CTS)
244 
248 #define UART2MSP432E4_PN2_U2RTS GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTN, 2, GPIO_PN2_U2RTS)
249 
253 #define UART2MSP432E4_PD6_U2RTS GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTD, 6, GPIO_PD6_U2RTS)
254 
258 #define UART2MSP432E4_PJ2_U2RTS GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTJ, 2, GPIO_PJ2_U2RTS)
259 
260 
264 #define UART2MSP432E4_PA4_U3RX GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTA, 4, GPIO_PA4_U3RX)
265 
269 #define UART2MSP432E4_PJ0_U3RX GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTJ, 0, GPIO_PJ0_U3RX)
270 
274 #define UART2MSP432E4_PA5_U3TX GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTA, 5, GPIO_PA5_U3TX)
275 
279 #define UART2MSP432E4_PJ1_U3TX GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTJ, 1, GPIO_PJ1_U3TX)
280 
284 #define UART2MSP432E4_PP5_U3CTS GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTP, 5, GPIO_PP5_U3CTS)
285 
289 #define UART2MSP432E4_PN5_U3CTS GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTN, 5, GPIO_PN5_U3CTS)
290 
294 #define UART2MSP432E4_PJ5_U3CTS GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTJ, 5, GPIO_PJ5_U3CTS)
295 
299 #define UART2MSP432E4_PP4_U3RTS GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTP, 4, GPIO_PP4_U3RTS)
300 
304 #define UART2MSP432E4_PN4_U3RTS GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTN, 4, GPIO_PN4_U3RTS)
305 
309 #define UART2MSP432E4_PJ4_U3RTS GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTJ, 4, GPIO_PJ4_U3RTS)
310 
311 
315 #define UART2MSP432E4_PA2_U4RX GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTA, 2, GPIO_PA2_U4RX)
316 
320 #define UART2MSP432E4_PK0_U4RX GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTK, 0, GPIO_PK0_U4RX)
321 
325 #define UART2MSP432E4_PR1_U4RX GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTR, 1, GPIO_PR1_U4RX)
326 
330 #define UART2MSP432E4_PA3_U4TX GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTA, 3, GPIO_PA3_U4TX)
331 
335 #define UART2MSP432E4_PK1_U4TX GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTK, 1, GPIO_PK1_U4TX)
336 
340 #define UART2MSP432E4_PR0_U4TX GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTR, 0, GPIO_PR0_U4TX)
341 
345 #define UART2MSP432E4_PK3_U4CTS GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTK, 3, GPIO_PK3_U4CTS)
346 
350 #define UART2MSP432E4_PJ7_U4CTS GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTJ, 7, GPIO_PJ7_U4CTS)
351 
355 #define UART2MSP432E4_PN7_U4CTS GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTN, 7, GPIO_PN7_U4CTS)
356 
360 #define UART2MSP432E4_PK2_U4RTS GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTK, 2, GPIO_PK2_U4RTS)
361 
365 #define UART2MSP432E4_PJ6_U4RTS GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTJ, 6, GPIO_PJ6_U4RTS)
366 
370 #define UART2MSP432E4_PN6_U4RTS GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTN, 6, GPIO_PN6_U4RTS)
371 
372 
376 #define UART2MSP432E4_PC6_U5RX GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTC, 6, GPIO_PC6_U5RX)
377 
381 #define UART2MSP432E4_PH6_U5RX GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTH, 6, GPIO_PH6_U5RX)
382 
386 #define UART2MSP432E4_PC7_U5TX GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTC, 7, GPIO_PC7_U5TX)
387 
391 #define UART2MSP432E4_PH7_U5TX GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTH, 7, GPIO_PH7_U5TX)
392 
393 
397 #define UART2MSP432E4_PP0_U6RX GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTP, 0, GPIO_PP0_U6RX)
398 
402 #define UART2MSP432E4_PP1_U6TX GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTP, 1, GPIO_PP1_U6TX)
403 
404 
408 #define UART2MSP432E4_PC4_U7RX GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTC, 4, GPIO_PC4_U7RX)
409 
413 #define UART2MSP432E4_PH6_U7RX GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTH, 6, GPIO_PH6_U7RX)
414 
418 #define UART2MSP432E4_PC5_U7TX GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTC, 5, GPIO_PC5_U7TX)
419 
423 #define UART2MSP432E4_PH7_U7TX GPIOMSP432E4_pinConfigMask(GPIOMSP432E4_PORTH, 7, GPIO_PH7_U7TX)
424 
425 /* UART2MSP432E4 functions */
426 extern void UART2MSP432E4_close(UART2_Handle handle);
427 extern UART2_Handle UART2MSP432E4_open(uint_least8_t, UART2_Params *params);
428 extern int_fast16_t UART2MSP432E4_read(UART2_Handle handle, void *buffer,
429  size_t size, size_t *bytesRead, uint32_t timeout);
430 extern void UART2MSP432E4_readCancel(UART2_Handle handle);
431 extern int_fast16_t UART2MSP432E4_write(UART2_Handle handle,
432  const void *buffer, size_t size, size_t *bytesWritten,
433  uint32_t timeout);
434 extern void UART2MSP432E4_writeCancel(UART2_Handle handle);
435 extern void UART2MSP432E4_flushRx(UART2_Handle handle);
436 
437 /* UART2 function table pointer */
439 
504 typedef struct {
506  uint32_t baseAddr;
508  int intNum;
510  uint8_t intPriority;
512  uint32_t flowControl;
514  uint32_t rxPin;
516  uint32_t txPin;
518  uint32_t ctsPin;
520  uint32_t rtsPin;
522  uint32_t rxDmaChannel;
524  uint32_t txDmaChannel;
526 
532 typedef struct {
533  /* UART2 state variable */
534  struct {
535  bool opened:1; /* Has the obj been opened */
536  UART2_Mode readMode; /* Mode for read calls */
537  UART2_Mode writeMode; /* Mode for write calls */
538  UART2_ReadReturnMode readReturnMode:1; /* RX return mode (partial/full) */
539  bool txEnabled:1; /* Flag to show ongoing transmit */
540  } state;
541 
542  HwiP_Handle hwi; /* Hwi object for interrupts */
543  int32_t rxStatus; /* RX status */
544  int32_t txStatus; /* TX status */
545  void *userArg; /* User supplied arg for callbacks */
546  UDMAMSP432E4_Handle udmaHandle; /* For setting power dependency */
547 
548  /* UART read variables */
549  unsigned char *readBuf; /* Buffer data pointer */
550  size_t readSize; /* Number of bytes to read */
551  uint32_t nReadTransfers; /* Number of DMA transfers needed */
552  size_t readCount; /* Number of bytes left to read */
553  size_t rxSize; /* # of bytes to read in DMA xfer */
554  size_t bytesRead; /* Number of bytes read */
555  SemaphoreP_Handle readSem; /* UART read semaphore */
556  UART2_Callback readCallback; /* Pointer to read callback */
557 
558  /* UART write variables */
559  const unsigned char *writeBuf; /* Buffer data pointer */
560  size_t writeSize; /* Number of bytes to write*/
561  uint32_t nWriteTransfers; /* Number of DMA transfers needed */
562  size_t writeCount; /* Number of bytes left to write */
563  size_t txSize; /* # of bytes to write with DMA */
564  size_t bytesWritten; /* Number of bytes written */
565  SemaphoreP_Handle writeSem; /* UART write semaphore*/
566  UART2_Callback writeCallback; /* Pointer to write callback */
567 
568  /* For Power management */
569  unsigned int powerMgrId; /* Determined from base address */
571 
572 #ifdef __cplusplus
573 }
574 #endif
575 
576 #endif /* ti_drivers_uart2_UART2MSP432E4__include */
UART2MSP432E4 Object.
Definition: UART2MSP432E4.h:532
UART2 Global configuration.
Definition: UART2.h:516
uint32_t rtsPin
Definition: UART2MSP432E4.h:520
const unsigned char * writeBuf
Definition: UART2MSP432E4.h:559
uint32_t txDmaChannel
Definition: UART2MSP432E4.h:524
UART2_ReadReturnMode
UART2 return mode settings.
Definition: UART2.h:373
int32_t rxStatus
Definition: UART2MSP432E4.h:543
SemaphoreP_Handle readSem
Definition: UART2MSP432E4.h:555
UDMAMSP432E4 Global configuration.
Definition: UDMAMSP432E4.h:143
size_t txSize
Definition: UART2MSP432E4.h:563
SemaphoreP_Handle writeSem
Definition: UART2MSP432E4.h:565
PRELIMINARY UART driver interface
UART2_Mode writeMode
Definition: UART2MSP432E4.h:537
uint32_t nWriteTransfers
Definition: UART2MSP432E4.h:561
uDMA driver implementation for MSP432E4.
UART2MSP432E4 Hardware attributes.
Definition: UART2MSP432E4.h:504
uint32_t nReadTransfers
Definition: UART2MSP432E4.h:551
The definition of a UART2 function table that contains the required set of functions to control a spe...
Definition: UART2.h:486
UART2_Handle UART2MSP432E4_open(uint_least8_t, UART2_Params *params)
UART2_Mode readMode
Definition: UART2MSP432E4.h:536
int32_t txStatus
Definition: UART2MSP432E4.h:544
int_fast16_t UART2MSP432E4_read(UART2_Handle handle, void *buffer, size_t size, size_t *bytesRead, uint32_t timeout)
unsigned char * readBuf
Definition: UART2MSP432E4.h:549
uint8_t intPriority
Definition: UART2MSP432E4.h:510
size_t readCount
Definition: UART2MSP432E4.h:552
int intNum
Definition: UART2MSP432E4.h:508
UART2_Callback readCallback
Definition: UART2MSP432E4.h:556
void UART2MSP432E4_writeCancel(UART2_Handle handle)
UART2_Mode
UART2 mode settings.
Definition: UART2.h:336
size_t bytesRead
Definition: UART2MSP432E4.h:554
void * userArg
Definition: UART2MSP432E4.h:545
uint32_t ctsPin
Definition: UART2MSP432E4.h:518
uint32_t flowControl
Definition: UART2MSP432E4.h:512
UART2 Parameters.
Definition: UART2.h:424
size_t writeSize
Definition: UART2MSP432E4.h:560
MSP432E4 GPIO driver.
UART2_Callback writeCallback
Definition: UART2MSP432E4.h:566
uint32_t baseAddr
Definition: UART2MSP432E4.h:506
uint32_t rxDmaChannel
Definition: UART2MSP432E4.h:522
size_t rxSize
Definition: UART2MSP432E4.h:553
uint32_t txPin
Definition: UART2MSP432E4.h:516
UDMAMSP432E4_Handle udmaHandle
Definition: UART2MSP432E4.h:546
void UART2MSP432E4_readCancel(UART2_Handle handle)
size_t readSize
Definition: UART2MSP432E4.h:550
const UART2_FxnTable UART2MSP432E4_fxnTable
HwiP_Handle hwi
Definition: UART2MSP432E4.h:542
size_t writeCount
Definition: UART2MSP432E4.h:562
void UART2MSP432E4_flushRx(UART2_Handle handle)
void UART2MSP432E4_close(UART2_Handle handle)
unsigned int powerMgrId
Definition: UART2MSP432E4.h:569
void(* UART2_Callback)(UART2_Handle handle, void *buf, size_t count, void *userArg, int_fast16_t status)
The definition of a callback function used by the UART2 driver when used in UART2_Mode_CALLBACK The c...
Definition: UART2.h:328
size_t bytesWritten
Definition: UART2MSP432E4.h:564
uint32_t rxPin
Definition: UART2MSP432E4.h:514
int_fast16_t UART2MSP432E4_write(UART2_Handle handle, const void *buffer, size_t size, size_t *bytesWritten, uint32_t timeout)
struct UART2MSP432E4_Object * UART2MSP432E4_Handle
© Copyright 1995-2020, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale