MSPM0L11XX_L13XX TI-Driver Library  1.20.01.06
UARTSupportMSPM0L11XX_L13XX.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021, 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  */
32 /*!****************************************************************************
33  * @file UARTSupportMSPM0L11XX_L13XX.h
34  *
35  * @brief UART driver support APIs for the MSPM0L11XX_L13XX devices.
36  *
37  * @defgroup UARTSupportMSPM0L11XX_L13XX UART MSPM0L11XX_L13XX driver support APIs
38  *
39  * # Overview
40  * Refer to @ref ti_drivers_UART_Overview for a complete description of APIs and examples
41  * of use.
42  *
43  ******************************************************************************
44  */
49 /* clang-format off */
50 #ifndef ti_drivers_uart_UARTSupportMSPM0L11XX_L13XX__include
51 #define ti_drivers_uart_UARTSupportMSPM0L11XX_L13XX__include
52 
53 #include <ti/drivers/dpl/ClockP.h>
54 #include <ti/drivers/dpl/SemaphoreP.h>
55 
57 #include <ti/drivers/utils/RingBuf.h>
58 #include <ti/drivers/UART.h>
59 
63 typedef struct {
72  bool (*enable)(UART_Handle handle, UART_Params *params);
73 
79  void (*disable)(UART_Handle handle);
80 
86  void (*txChar)(UART_Handle handle);
87 
109  int_fast16_t (*read)(
110  UART_Handle, void *buf, size_t size, size_t *bytesRead);
111 
130  int_fast16_t (*write)(
131  UART_Handle, const void *buf, size_t size, size_t *bytesWritten);
133 
137 typedef struct {
139  void *userArg;
140  uint8_t buffersSupported : 1;
141  uint8_t eventsSupported : 1;
142  uint8_t callbacksSupported : 1;
143  uint8_t dmaSupported : 1;
144  uint8_t returnMode : 1;
145  uint8_t inUse : 1;
146  uint8_t readCancel : 1;
147  uint8_t writeCancel : 1;
148  uint8_t overrunActive : 1;
149  uint8_t readTimedOut : 1;
150  uint8_t writeTimedOut : 1;
151  uint8_t readMode : 2;
152  uint8_t writeMode : 2;
153  uint8_t rxDmaChannel;
154  uint8_t txDmaChannel;
155  uint8_t readInUse : 1;
156  uint8_t writeInUse : 1;
157  uint32_t overrunCount;
158 } UART_Object;
159 
160 
165 typedef struct {
166  uint8_t *rxBufPtr;
167  uint8_t *txBufPtr;
168  uint16_t rxBufSize;
169  uint16_t txBufSize;
170  RingBuf_Object rxBuf;
171  RingBuf_Object txBuf;
172  SemaphoreP_Handle rxSem;
173  SemaphoreP_Handle txSem;
175 
180 typedef struct {
182  uint32_t eventMask;
184 
189 typedef struct {
192  uint8_t *readBuf;
193  const uint8_t *writeBuf;
194  uint16_t readSize;
195  uint16_t writeSize;
196  uint16_t writeCount;
197  uint16_t readCount;
198  uint16_t bytesRead;
199  uint16_t bytesWritten;
200  int32_t rxStatus;
201  int32_t txStatus;
202  size_t rxSize;
203  size_t txSize;
204  void *userArg;
206 
211 /* Warning! The sequence in the below structure must NOT be modified */
212 typedef struct
213 {
220 
228 typedef struct UART_Config_
229 {
231  void *object;
232 
234  void const *hwAttrs;
235 } UART_Config;
236 
241 extern const UART_Config UART_config[];
246 extern const uint_least8_t UART_count;
247 
248 
249 
268 int_fast16_t UART_readBuffered(UART_Handle handle, void *buf, size_t size, size_t *bytesRead);
269 
285 int_fast16_t UART_writeBuffered(UART_Handle handle, const void *buf, size_t size, size_t *bytesWritten);
286 
308 int_fast16_t UART_readCallback(UART_Handle handle, void *buf, size_t size, size_t *bytesRead);
309 
328 int_fast16_t UART_writeCallback(UART_Handle handle, const void *buf, size_t size, size_t *bytesWritten);
329 
351 int_fast16_t UART_readFullFeatured(UART_Handle handle, void *buf, size_t size, size_t *bytesRead);
352 
371 int_fast16_t UART_writeFullFeatured(UART_Handle handle, const void *buf, size_t size, size_t *bytesWritten);
372 
373 #endif /* ti_drivers_uart_UARTSupportMSPM0L11XX_L13XX__include */
374 /* clang-format on */
Private Metadata structure for a UART instance supporting callbacks.
Definition: UARTSupportMSPM0L11XX_L13XX.h:189
UART_Callback writeCallback
Definition: UARTSupportMSPM0L11XX_L13XX.h:191
uint16_t bytesRead
Definition: UARTSupportMSPM0L11XX_L13XX.h:198
void * userArg
Definition: UARTSupportMSPM0L11XX_L13XX.h:204
void * object
Definition: UARTSupportMSPM0L11XX_L13XX.h:231
uint32_t eventMask
Definition: UARTSupportMSPM0L11XX_L13XX.h:182
uint32_t overrunCount
Definition: UARTSupportMSPM0L11XX_L13XX.h:157
int_fast16_t UART_readCallback(UART_Handle handle, void *buf, size_t size, size_t *bytesRead)
UART read that only supports callback mode.
UART_Callback readCallback
Definition: UARTSupportMSPM0L11XX_L13XX.h:190
struct UART_Config_ UART_Config
UART Global configuration.
UART_EventCallback_Object eventCallbackObject
Definition: UARTSupportMSPM0L11XX_L13XX.h:216
int_fast16_t UART_readFullFeatured(UART_Handle handle, void *buf, size_t size, size_t *bytesRead)
UART read that only supports buffered and callback mode.
SemaphoreP_Handle txSem
Definition: UARTSupportMSPM0L11XX_L13XX.h:173
size_t txSize
Definition: UARTSupportMSPM0L11XX_L13XX.h:203
UART Global configuration.
Definition: UARTSupportMSPM0L11XX_L13XX.h:228
void const * hwAttrs
Definition: UARTSupportMSPM0L11XX_L13XX.h:234
uint8_t txDmaChannel
Definition: UARTSupportMSPM0L11XX_L13XX.h:154
void(* UART_EventCallback)(UART_Handle handle, uint32_t event, uint32_t data, void *userArg)
The definition of a callback function used by the UART driver. The callback can occur in task or inte...
Definition: UART.h:209
uint8_t * readBuf
Definition: UARTSupportMSPM0L11XX_L13XX.h:192
size_t rxSize
Definition: UARTSupportMSPM0L11XX_L13XX.h:202
const UART_Config UART_config[]
Array of UART_Config structure.
uint16_t writeSize
Definition: UARTSupportMSPM0L11XX_L13XX.h:195
uint16_t readCount
Definition: UARTSupportMSPM0L11XX_L13XX.h:197
RingBuf_Object rxBuf
Definition: UARTSupportMSPM0L11XX_L13XX.h:170
Private Metadata structure for a UART instance supporting events.
Definition: UARTSupportMSPM0L11XX_L13XX.h:180
const uint8_t * writeBuf
Definition: UARTSupportMSPM0L11XX_L13XX.h:193
UART_Buffers_Object buffersObject
Definition: UARTSupportMSPM0L11XX_L13XX.h:215
uint16_t bytesWritten
Definition: UARTSupportMSPM0L11XX_L13XX.h:199
int32_t txStatus
Definition: UARTSupportMSPM0L11XX_L13XX.h:201
uint8_t rxDmaChannel
Definition: UARTSupportMSPM0L11XX_L13XX.h:153
SemaphoreP_Handle rxSem
Definition: UARTSupportMSPM0L11XX_L13XX.h:172
RingBuf_Object txBuf
Definition: UARTSupportMSPM0L11XX_L13XX.h:171
Private Metadata structure for a UART instance supporting data structures needed for UART TX/RX execu...
Definition: UARTSupportMSPM0L11XX_L13XX.h:212
UART_Object object
Definition: UARTSupportMSPM0L11XX_L13XX.h:214
int_fast16_t UART_writeBuffered(UART_Handle handle, const void *buf, size_t size, size_t *bytesWritten)
UART write that only supports buffered mode.
void * userArg
Definition: UARTSupportMSPM0L11XX_L13XX.h:139
UART driver interface.
UART_Callback_Object callbackObject
Definition: UARTSupportMSPM0L11XX_L13XX.h:217
struct UART_Config_ * UART_Handle
A handle that is returned from a UART_open() call.
Definition: UART.h:168
Private Metadata structure for a UART instance supporting buffers.
Definition: UARTSupportMSPM0L11XX_L13XX.h:165
int_fast16_t UART_writeFullFeatured(UART_Handle handle, const void *buf, size_t size, size_t *bytesWritten)
UART write that only supports buffered and callback mode.
Private Metadata structure for a UART instance.
Definition: UARTSupportMSPM0L11XX_L13XX.h:137
uint16_t readSize
Definition: UARTSupportMSPM0L11XX_L13XX.h:194
const UARTSupport_Fxns * supportFxns
Definition: UARTSupportMSPM0L11XX_L13XX.h:138
UART Parameters.
Definition: UART.h:307
int_fast16_t UART_writeCallback(UART_Handle handle, const void *buf, size_t size, size_t *bytesWritten)
UART write that only supports callback mode.
uint16_t txBufSize
Definition: UARTSupportMSPM0L11XX_L13XX.h:169
void(* UART_Callback)(UART_Handle handle, void *buf, size_t count, void *userArg, int_fast16_t status)
The definition of a callback function used by the UART driver when used in UART_Mode_CALLBACK. The callback can occur in task or interrupt context.
Definition: UART.h:186
uint8_t * txBufPtr
Definition: UARTSupportMSPM0L11XX_L13XX.h:167
const uint_least8_t UART_count
Count of UART instances.
uint16_t rxBufSize
Definition: UARTSupportMSPM0L11XX_L13XX.h:168
Function pointers to implementation/hardware specific logic.
Definition: UARTSupportMSPM0L11XX_L13XX.h:63
int_fast16_t UART_readBuffered(UART_Handle handle, void *buf, size_t size, size_t *bytesRead)
UART read that only supports buffered mode.
uint8_t * rxBufPtr
Definition: UARTSupportMSPM0L11XX_L13XX.h:166
uint16_t writeCount
Definition: UARTSupportMSPM0L11XX_L13XX.h:196
UART_EventCallback eventCallback
Definition: UARTSupportMSPM0L11XX_L13XX.h:181
int32_t rxStatus
Definition: UARTSupportMSPM0L11XX_L13XX.h:200
DMA driver implementation for MSPM0.
© Copyright 1995-2023, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale