MSPM0G1X0X_G3X0X TI-Driver Library  2.01.00.03
UARTSupportMSPM0.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 UARTSupportMSPM0.h
34  *
35  * @brief UART driver support APIs for the MSPM0 devices.
36  *
37  * @defgroup UARTSupportMSPM0 UART driver supporting 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_UARTSupportMSPM0__include
51 #define ti_drivers_uart_UARTSupportMSPM0__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 #ifndef UART_NO_DMA
159  uint8_t noOfDMAChannels;
161 #endif
162 } UART_Object;
163 
164 
169 typedef struct {
170  uint8_t *rxBufPtr;
171  uint8_t *txBufPtr;
172  uint16_t rxBufSize;
173  uint16_t txBufSize;
174  RingBuf_Object rxBuf;
175  RingBuf_Object txBuf;
176  SemaphoreP_Handle rxSem;
177  SemaphoreP_Handle txSem;
179 
184 typedef struct {
186  uint32_t eventMask;
188 
193 typedef struct {
196  uint8_t *readBuf;
197  const uint8_t *writeBuf;
198  uint16_t readSize;
199  uint16_t writeSize;
200  uint16_t writeCount;
201  uint16_t readCount;
202  uint16_t bytesRead;
203  uint16_t bytesWritten;
204  int32_t rxStatus;
205  int32_t txStatus;
206  size_t rxSize;
207  size_t txSize;
208  void *userArg;
210 
215 /* Warning! The sequence in the below structure must NOT be modified. */
216 typedef struct
217 {
224 
232 typedef struct UART_Config_
233 {
235  void *object;
236 
238  void const *hwAttrs;
239 } UART_Config;
240 
245 extern const UART_Config UART_config[];
250 extern const uint_least8_t UART_count;
251 
252 
253 
272 int_fast16_t UART_readBuffered(UART_Handle handle, void *buf, size_t size, size_t *bytesRead);
273 
289 int_fast16_t UART_writeBuffered(UART_Handle handle, const void *buf, size_t size, size_t *bytesWritten);
290 
312 int_fast16_t UART_readCallback(UART_Handle handle, void *buf, size_t size, size_t *bytesRead);
313 
332 int_fast16_t UART_writeCallback(UART_Handle handle, const void *buf, size_t size, size_t *bytesWritten);
333 
355 int_fast16_t UART_readFullFeatured(UART_Handle handle, void *buf, size_t size, size_t *bytesRead);
356 
375 int_fast16_t UART_writeFullFeatured(UART_Handle handle, const void *buf, size_t size, size_t *bytesWritten);
376 
377 
378 #endif /* ti_drivers_uart_UARTSupportMSPM0__include */
379 /* clang-format on */
Private Metadata structure for a UART instance supporting callbacks.
Definition: UARTSupportMSPM0.h:193
UART_Callback writeCallback
Definition: UARTSupportMSPM0.h:195
uint16_t bytesRead
Definition: UARTSupportMSPM0.h:202
void * userArg
Definition: UARTSupportMSPM0.h:208
uint8_t noOfDMAChannels
Definition: UARTSupportMSPM0.h:159
const UART_Config UART_config[]
Array of UART_Config structure.
void * object
Definition: UARTSupportMSPM0.h:235
DMAMSPM0_Handle DMA_Handle
Definition: UARTSupportMSPM0.h:160
uint32_t eventMask
Definition: UARTSupportMSPM0.h:186
uint32_t overrunCount
Definition: UARTSupportMSPM0.h:157
UART_Callback readCallback
Definition: UARTSupportMSPM0.h:194
UART_EventCallback_Object eventCallbackObject
Definition: UARTSupportMSPM0.h:220
SemaphoreP_Handle txSem
Definition: UARTSupportMSPM0.h:177
size_t txSize
Definition: UARTSupportMSPM0.h:207
struct UART_Config_ UART_Config
UART Global configuration.
DMAMSPM0 Global configuration.
Definition: DMAMSPM0.h:181
UART Global configuration.
Definition: UARTSupportMSPM0.h:232
void const * hwAttrs
Definition: UARTSupportMSPM0.h:238
uint8_t txDmaChannel
Definition: UARTSupportMSPM0.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: UARTSupportMSPM0.h:196
size_t rxSize
Definition: UARTSupportMSPM0.h:206
uint16_t writeSize
Definition: UARTSupportMSPM0.h:199
uint16_t readCount
Definition: UARTSupportMSPM0.h:201
RingBuf_Object rxBuf
Definition: UARTSupportMSPM0.h:174
Private Metadata structure for a UART instance supporting events.
Definition: UARTSupportMSPM0.h:184
int_fast16_t UART_writeCallback(UART_Handle handle, const void *buf, size_t size, size_t *bytesWritten)
UART write that only supports callback mode.
const uint8_t * writeBuf
Definition: UARTSupportMSPM0.h:197
UART_Buffers_Object buffersObject
Definition: UARTSupportMSPM0.h:219
uint16_t bytesWritten
Definition: UARTSupportMSPM0.h:203
int32_t txStatus
Definition: UARTSupportMSPM0.h:205
uint8_t rxDmaChannel
Definition: UARTSupportMSPM0.h:153
SemaphoreP_Handle rxSem
Definition: UARTSupportMSPM0.h:176
RingBuf_Object txBuf
Definition: UARTSupportMSPM0.h:175
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.
Private Metadata structure for a UART instance supporting data structures needed for UART TX/RX execu...
Definition: UARTSupportMSPM0.h:216
UART_Object object
Definition: UARTSupportMSPM0.h:218
void * userArg
Definition: UARTSupportMSPM0.h:139
UART driver interface.
UART_Callback_Object callbackObject
Definition: UARTSupportMSPM0.h:221
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: UARTSupportMSPM0.h:169
Private Metadata structure for a UART instance.
Definition: UARTSupportMSPM0.h:137
const uint_least8_t UART_count
Count of UART instances.
int_fast16_t UART_readBuffered(UART_Handle handle, void *buf, size_t size, size_t *bytesRead)
UART read that only supports buffered mode.
uint16_t readSize
Definition: UARTSupportMSPM0.h:198
const UARTSupport_Fxns * supportFxns
Definition: UARTSupportMSPM0.h:138
UART Parameters.
Definition: UART.h:307
int_fast16_t UART_writeBuffered(UART_Handle handle, const void *buf, size_t size, size_t *bytesWritten)
UART write that only supports buffered mode.
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.
uint16_t txBufSize
Definition: UARTSupportMSPM0.h:173
int_fast16_t UART_readCallback(UART_Handle handle, void *buf, size_t size, size_t *bytesRead)
UART read that only supports callback mode.
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: UARTSupportMSPM0.h:171
uint16_t rxBufSize
Definition: UARTSupportMSPM0.h:172
Function pointers to implementation/hardware specific logic.
Definition: UARTSupportMSPM0.h:63
uint8_t * rxBufPtr
Definition: UARTSupportMSPM0.h:170
uint16_t writeCount
Definition: UARTSupportMSPM0.h:200
UART_EventCallback eventCallback
Definition: UARTSupportMSPM0.h:185
int32_t rxStatus
Definition: UARTSupportMSPM0.h:204
DMA driver implementation for MSPM0.
© Copyright 1995-2024, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale