RTEMS 6.1-rc4
Loading...
Searching...
No Matches
fsl_lpuart_freertos.h
1/*
2 * Copyright (c) 2015, Freescale Semiconductor, Inc.
3 * Copyright 2016-2020 NXP
4 * All rights reserved.
5 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8#ifndef __FSL_LPUART_RTOS_H__
9#define __FSL_LPUART_RTOS_H__
10
11#include "fsl_lpuart.h"
12#include <FreeRTOS.h>
13#include <event_groups.h>
14#include <semphr.h>
15
21/*******************************************************************************
22 * Definitions
23 ******************************************************************************/
24
28#define FSL_LPUART_FREERTOS_DRIVER_VERSION (MAKE_VERSION(2, 6, 0))
32typedef struct _lpuart_rtos_config
33{
35 uint32_t srcclk;
36 uint32_t baudrate;
39 uint8_t *buffer;
40 uint32_t buffer_size;
41 /* Zero in constant and multiplier is interpreted as infinit timeout. */
46#if defined(FSL_FEATURE_LPUART_HAS_MODEM_SUPPORT) && FSL_FEATURE_LPUART_HAS_MODEM_SUPPORT
47 bool enableRxRTS;
48 bool enableTxCTS;
49 lpuart_transmit_cts_source_t txCtsSource;
50 lpuart_transmit_cts_config_t txCtsConfig;
51#endif
53
62#define RTOS_LPUART_TX_COMPLETE 0x1U
64#define RTOS_LPUART_RX_COMPLETE 0x2U
66#define RTOS_LPUART_RING_BUFFER_OVERRUN 0x4U
68#define RTOS_LPUART_HARDWARE_BUFFER_OVERRUN 0x8U
72typedef struct _lpuart_rtos_handle
73{
74 LPUART_Type *base;
75 lpuart_transfer_t txTransfer;
76 lpuart_transfer_t rxTransfer;
77 SemaphoreHandle_t rxSemaphore;
78 SemaphoreHandle_t txSemaphore;
79 EventGroupHandle_t rxEvent;
80 EventGroupHandle_t txEvent;
81 uint32_t rx_timeout_constant_ms;
82 uint32_t rx_timeout_multiplier_ms;
83 uint32_t tx_timeout_constant_ms;
84 uint32_t tx_timeout_multiplier_ms;
85 void *t_state;
86#if (configSUPPORT_STATIC_ALLOCATION == 1)
87 StaticSemaphore_t txSemaphoreBuffer;
88 StaticSemaphore_t rxSemaphoreBuffer;
89 StaticEventGroup_t txEventBuffer;
90 StaticEventGroup_t rxEventBuffer;
91#endif
92} lpuart_rtos_handle_t;
95/*******************************************************************************
96 * API
97 ******************************************************************************/
98
99#if defined(__cplusplus)
100extern "C" {
101#endif
102
116int LPUART_RTOS_Init(lpuart_rtos_handle_t *handle, lpuart_handle_t *t_handle, const lpuart_rtos_config_t *cfg);
117
126int LPUART_RTOS_Deinit(lpuart_rtos_handle_t *handle);
127
143int LPUART_RTOS_Send(lpuart_rtos_handle_t *handle, uint8_t *buffer, uint32_t length);
144
156int LPUART_RTOS_Receive(lpuart_rtos_handle_t *handle, uint8_t *buffer, uint32_t length, size_t *received);
157
167int LPUART_RTOS_SetRxTimeout(lpuart_rtos_handle_t *handle,
168 uint32_t rx_timeout_constant_ms,
169 uint32_t rx_timeout_multiplier_ms);
170
180int LPUART_RTOS_SetTxTimeout(lpuart_rtos_handle_t *handle,
181 uint32_t tx_timeout_constant_ms,
182 uint32_t tx_timeout_multiplier_ms);
183
184/* @} */
185
186#if defined(__cplusplus)
187}
188#endif
189
192#endif /* __FSL_LPUART_RTOS_H__ */
enum _lpuart_stop_bit_count lpuart_stop_bit_count_t
LPUART stop bit count.
enum _lpuart_parity_mode lpuart_parity_mode_t
LPUART parity mode.
int LPUART_RTOS_Receive(lpuart_rtos_handle_t *handle, uint8_t *buffer, uint32_t length, size_t *received)
Receives data.
int LPUART_RTOS_Deinit(lpuart_rtos_handle_t *handle)
Deinitializes an LPUART instance for operation.
uint32_t tx_timeout_multiplier_ms
Definition: fsl_lpuart_freertos.h:45
int LPUART_RTOS_Send(lpuart_rtos_handle_t *handle, uint8_t *buffer, uint32_t length)
Sends data in the background.
uint32_t tx_timeout_constant_ms
Definition: fsl_lpuart_freertos.h:44
uint32_t srcclk
Definition: fsl_lpuart_freertos.h:35
lpuart_stop_bit_count_t stopbits
Definition: fsl_lpuart_freertos.h:38
int LPUART_RTOS_SetRxTimeout(lpuart_rtos_handle_t *handle, uint32_t rx_timeout_constant_ms, uint32_t rx_timeout_multiplier_ms)
Set RX timeout in runtime.
uint8_t * buffer
Definition: fsl_lpuart_freertos.h:39
struct _lpuart_rtos_config lpuart_rtos_config_t
LPUART RTOS configuration structure.
lpuart_parity_mode_t parity
Definition: fsl_lpuart_freertos.h:37
int LPUART_RTOS_Init(lpuart_rtos_handle_t *handle, lpuart_handle_t *t_handle, const lpuart_rtos_config_t *cfg)
Initializes an LPUART instance for operation in RTOS.
uint32_t rx_timeout_multiplier_ms
Definition: fsl_lpuart_freertos.h:43
LPUART_Type * base
Definition: fsl_lpuart_freertos.h:34
uint32_t buffer_size
Definition: fsl_lpuart_freertos.h:40
int LPUART_RTOS_SetTxTimeout(lpuart_rtos_handle_t *handle, uint32_t tx_timeout_constant_ms, uint32_t tx_timeout_multiplier_ms)
Set TX timeout in runtime.
uint32_t baudrate
Definition: fsl_lpuart_freertos.h:36
uint32_t rx_timeout_constant_ms
Definition: fsl_lpuart_freertos.h:42
Definition: MIMXRT1052.h:31147
LPUART handle structure.
Definition: fsl_lpuart.h:289
LPUART RTOS configuration structure.
Definition: fsl_lpuart_freertos.h:33
LPUART transfer structure.
Definition: fsl_lpuart.h:267