Mistake on this page?
Report an issue in GitHub or email us
pal_uart.h
Go to the documentation of this file.
1 /*************************************************************************************************/
2 /*!
3  * \file
4  *
5  * \brief UART driver definition.
6  *
7  * Copyright (c) 2018 ARM Ltd. All Rights Reserved.
8  *
9  * Copyright (c) 2019-2020 Packetcraft, Inc.
10  *
11  * Licensed under the Apache License, Version 2.0 (the "License");
12  * you may not use this file except in compliance with the License.
13  * You may obtain a copy of the License at
14  *
15  * http://www.apache.org/licenses/LICENSE-2.0
16  *
17  * Unless required by applicable law or agreed to in writing, software
18  * distributed under the License is distributed on an "AS IS" BASIS,
19  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20  * See the License for the specific language governing permissions and
21  * limitations under the License.
22  */
23 /*************************************************************************************************/
24 
25 #ifndef PAL_UART_H
26 #define PAL_UART_H
27 
28 #include "pal_types.h"
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 /*! \addtogroup PAL_UART
35  * \{ */
36 
37 /**************************************************************************************************
38  Data Types
39 **************************************************************************************************/
40 
41 /*! \brief Completion callback. */
42 typedef void (*PalUartCompCback_t)(void);
43 
44 /*! \brief Peripheral configuration. */
45 typedef struct
46 {
47  PalUartCompCback_t rdCback; /*!< Read data completion callback. */
48  PalUartCompCback_t wrCback; /*!< Write data completion callback. */
49  uint32_t baud; /*!< Baud rate. */
50  bool_t hwFlow; /*!< Use HW Flow control */
52 
53 /*! \brief Operational states. */
54 typedef enum
55 {
56  PAL_UART_STATE_UNINIT = 0, /*!< Uninitialized state. */
57  PAL_UART_STATE_ERROR = 0, /*!< Error state. */
58  PAL_UART_STATE_READY = 1, /*!< Ready state. */
59  PAL_UART_STATE_BUSY = 2, /*!< Busy state. */
61 
62 /*! \brief Reserved UART ID. */
63 typedef enum
64 {
65  PAL_UART_ID_USER = 0, /*!< UART 0. */
66  PAL_UART_ID_CHCI = 1, /*!< UART CHCI. */
67  PAL_UART_ID_TERMINAL = 2, /*!< UART TERMINAL. */
68  PAL_UART_ID_MAX /*!< Number of UART instances. */
69 } PalUartId_t;
70 
71 /**************************************************************************************************
72  Function Declarations
73 **************************************************************************************************/
74 
75 /* Initialization */
76 void PalUartInit(PalUartId_t id, const PalUartConfig_t *pCfg);
77 void PalUartDeInit(PalUartId_t id);
78 
79 /* Control and Status */
80 PalUartState_t PalUartGetState(PalUartId_t id);
81 
82 /* Data Transfer */
83 void PalUartReadData(PalUartId_t id, uint8_t *pData, uint16_t len);
84 void PalUartWriteData(PalUartId_t id, const uint8_t *pData, uint16_t len);
85 
86 /*! \} */ /* PAL_UART */
87 
88 #ifdef __cplusplus
89 };
90 #endif
91 
92 #endif /* PAL_UART_H */
PalUartId_t
Reserved UART ID.
Definition: pal_uart.h:63
PalUartCompCback_t rdCback
Definition: pal_uart.h:47
void(* PalUartCompCback_t)(void)
Completion callback.
Definition: pal_uart.h:42
PalUartState_t
Operational states.
Definition: pal_uart.h:54
Peripheral configuration.
Definition: pal_uart.h:45
PalUartCompCback_t wrCback
Definition: pal_uart.h:48
uint32_t baud
Definition: pal_uart.h:49
Platform-independent data types.
uint8_t hwFlow
Definition: pal_uart.h:50
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.