The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.
Dependents: hello SerialTestv11 SerialTestv12 Sierpinski ... more
mbed 2
This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.
TARGET_EFM32GG_STK3700/TOOLCHAIN_ARM_MICRO/em_leuart.h@171:3a7713b1edbc, 2018-11-08 (annotated)
- Committer:
- AnnaBridge
- Date:
- Thu Nov 08 11:45:42 2018 +0000
- Revision:
- 171:3a7713b1edbc
- Parent:
- TARGET_EFM32GG_STK3700/TARGET_Silicon_Labs/TARGET_EFM32/emlib/inc/em_leuart.h@160:5571c4ff569f
mbed library. Release version 164
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AnnaBridge | 156:ff21514d8981 | 1 | /***************************************************************************//** |
AnnaBridge | 156:ff21514d8981 | 2 | * @file em_leuart.h |
AnnaBridge | 156:ff21514d8981 | 3 | * @brief Low Energy Universal Asynchronous Receiver/Transmitter (LEUART) |
AnnaBridge | 156:ff21514d8981 | 4 | * peripheral API |
Anna Bridge |
160:5571c4ff569f | 5 | * @version 5.3.3 |
AnnaBridge | 156:ff21514d8981 | 6 | ******************************************************************************* |
Anna Bridge |
160:5571c4ff569f | 7 | * # License |
AnnaBridge | 156:ff21514d8981 | 8 | * <b>Copyright 2016 Silicon Laboratories, Inc. http://www.silabs.com</b> |
AnnaBridge | 156:ff21514d8981 | 9 | ******************************************************************************* |
AnnaBridge | 156:ff21514d8981 | 10 | * |
AnnaBridge | 156:ff21514d8981 | 11 | * Permission is granted to anyone to use this software for any purpose, |
AnnaBridge | 156:ff21514d8981 | 12 | * including commercial applications, and to alter it and redistribute it |
AnnaBridge | 156:ff21514d8981 | 13 | * freely, subject to the following restrictions: |
AnnaBridge | 156:ff21514d8981 | 14 | * |
AnnaBridge | 156:ff21514d8981 | 15 | * 1. The origin of this software must not be misrepresented; you must not |
AnnaBridge | 156:ff21514d8981 | 16 | * claim that you wrote the original software. |
AnnaBridge | 156:ff21514d8981 | 17 | * 2. Altered source versions must be plainly marked as such, and must not be |
AnnaBridge | 156:ff21514d8981 | 18 | * misrepresented as being the original software. |
AnnaBridge | 156:ff21514d8981 | 19 | * 3. This notice may not be removed or altered from any source distribution. |
AnnaBridge | 156:ff21514d8981 | 20 | * |
AnnaBridge | 156:ff21514d8981 | 21 | * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Labs has no |
AnnaBridge | 156:ff21514d8981 | 22 | * obligation to support this Software. Silicon Labs is providing the |
AnnaBridge | 156:ff21514d8981 | 23 | * Software "AS IS", with no express or implied warranties of any kind, |
AnnaBridge | 156:ff21514d8981 | 24 | * including, but not limited to, any implied warranties of merchantability |
AnnaBridge | 156:ff21514d8981 | 25 | * or fitness for any particular purpose or warranties against infringement |
AnnaBridge | 156:ff21514d8981 | 26 | * of any proprietary rights of a third party. |
AnnaBridge | 156:ff21514d8981 | 27 | * |
AnnaBridge | 156:ff21514d8981 | 28 | * Silicon Labs will not be liable for any consequential, incidental, or |
AnnaBridge | 156:ff21514d8981 | 29 | * special damages, or any other relief, or for any claim by any third party, |
AnnaBridge | 156:ff21514d8981 | 30 | * arising from your use of this Software. |
AnnaBridge | 156:ff21514d8981 | 31 | * |
AnnaBridge | 156:ff21514d8981 | 32 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 33 | |
AnnaBridge | 156:ff21514d8981 | 34 | #ifndef EM_LEUART_H |
AnnaBridge | 156:ff21514d8981 | 35 | #define EM_LEUART_H |
AnnaBridge | 156:ff21514d8981 | 36 | |
AnnaBridge | 156:ff21514d8981 | 37 | #include "em_device.h" |
AnnaBridge | 156:ff21514d8981 | 38 | #if defined(LEUART_COUNT) && (LEUART_COUNT > 0) |
AnnaBridge | 156:ff21514d8981 | 39 | |
AnnaBridge | 156:ff21514d8981 | 40 | #include <stdbool.h> |
AnnaBridge | 156:ff21514d8981 | 41 | |
AnnaBridge | 156:ff21514d8981 | 42 | #ifdef __cplusplus |
AnnaBridge | 156:ff21514d8981 | 43 | extern "C" { |
AnnaBridge | 156:ff21514d8981 | 44 | #endif |
AnnaBridge | 156:ff21514d8981 | 45 | |
AnnaBridge | 156:ff21514d8981 | 46 | /***************************************************************************//** |
AnnaBridge | 156:ff21514d8981 | 47 | * @addtogroup emlib |
AnnaBridge | 156:ff21514d8981 | 48 | * @{ |
AnnaBridge | 156:ff21514d8981 | 49 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 50 | |
AnnaBridge | 156:ff21514d8981 | 51 | /***************************************************************************//** |
AnnaBridge | 156:ff21514d8981 | 52 | * @addtogroup LEUART |
AnnaBridge | 156:ff21514d8981 | 53 | * @{ |
AnnaBridge | 156:ff21514d8981 | 54 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 55 | |
AnnaBridge | 156:ff21514d8981 | 56 | /******************************************************************************* |
AnnaBridge | 156:ff21514d8981 | 57 | ******************************** ENUMS ************************************ |
AnnaBridge | 156:ff21514d8981 | 58 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 59 | |
AnnaBridge | 156:ff21514d8981 | 60 | /** Databit selection. */ |
Anna Bridge |
160:5571c4ff569f | 61 | typedef enum { |
AnnaBridge | 156:ff21514d8981 | 62 | leuartDatabits8 = LEUART_CTRL_DATABITS_EIGHT, /**< 8 databits. */ |
AnnaBridge | 156:ff21514d8981 | 63 | leuartDatabits9 = LEUART_CTRL_DATABITS_NINE /**< 9 databits. */ |
AnnaBridge | 156:ff21514d8981 | 64 | } LEUART_Databits_TypeDef; |
AnnaBridge | 156:ff21514d8981 | 65 | |
AnnaBridge | 156:ff21514d8981 | 66 | /** Enable selection. */ |
Anna Bridge |
160:5571c4ff569f | 67 | typedef enum { |
AnnaBridge | 156:ff21514d8981 | 68 | /** Disable both receiver and transmitter. */ |
AnnaBridge | 156:ff21514d8981 | 69 | leuartDisable = 0x0, |
AnnaBridge | 156:ff21514d8981 | 70 | |
AnnaBridge | 156:ff21514d8981 | 71 | /** Enable receiver only, transmitter disabled. */ |
AnnaBridge | 156:ff21514d8981 | 72 | leuartEnableRx = LEUART_CMD_RXEN, |
AnnaBridge | 156:ff21514d8981 | 73 | |
AnnaBridge | 156:ff21514d8981 | 74 | /** Enable transmitter only, receiver disabled. */ |
AnnaBridge | 156:ff21514d8981 | 75 | leuartEnableTx = LEUART_CMD_TXEN, |
AnnaBridge | 156:ff21514d8981 | 76 | |
AnnaBridge | 156:ff21514d8981 | 77 | /** Enable both receiver and transmitter. */ |
AnnaBridge | 156:ff21514d8981 | 78 | leuartEnable = (LEUART_CMD_RXEN | LEUART_CMD_TXEN) |
AnnaBridge | 156:ff21514d8981 | 79 | } LEUART_Enable_TypeDef; |
AnnaBridge | 156:ff21514d8981 | 80 | |
AnnaBridge | 156:ff21514d8981 | 81 | /** Parity selection. */ |
Anna Bridge |
160:5571c4ff569f | 82 | typedef enum { |
AnnaBridge | 156:ff21514d8981 | 83 | leuartNoParity = LEUART_CTRL_PARITY_NONE, /**< No parity. */ |
AnnaBridge | 156:ff21514d8981 | 84 | leuartEvenParity = LEUART_CTRL_PARITY_EVEN, /**< Even parity. */ |
AnnaBridge | 156:ff21514d8981 | 85 | leuartOddParity = LEUART_CTRL_PARITY_ODD /**< Odd parity. */ |
AnnaBridge | 156:ff21514d8981 | 86 | } LEUART_Parity_TypeDef; |
AnnaBridge | 156:ff21514d8981 | 87 | |
AnnaBridge | 156:ff21514d8981 | 88 | /** Stopbits selection. */ |
Anna Bridge |
160:5571c4ff569f | 89 | typedef enum { |
AnnaBridge | 156:ff21514d8981 | 90 | leuartStopbits1 = LEUART_CTRL_STOPBITS_ONE, /**< 1 stopbits. */ |
AnnaBridge | 156:ff21514d8981 | 91 | leuartStopbits2 = LEUART_CTRL_STOPBITS_TWO /**< 2 stopbits. */ |
AnnaBridge | 156:ff21514d8981 | 92 | } LEUART_Stopbits_TypeDef; |
AnnaBridge | 156:ff21514d8981 | 93 | |
AnnaBridge | 156:ff21514d8981 | 94 | /******************************************************************************* |
AnnaBridge | 156:ff21514d8981 | 95 | ******************************* STRUCTS *********************************** |
AnnaBridge | 156:ff21514d8981 | 96 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 97 | |
AnnaBridge | 156:ff21514d8981 | 98 | /** Init structure. */ |
Anna Bridge |
160:5571c4ff569f | 99 | typedef struct { |
AnnaBridge | 156:ff21514d8981 | 100 | /** Specifies whether TX and/or RX shall be enabled when init completed. */ |
AnnaBridge | 156:ff21514d8981 | 101 | LEUART_Enable_TypeDef enable; |
AnnaBridge | 156:ff21514d8981 | 102 | |
AnnaBridge | 156:ff21514d8981 | 103 | /** |
AnnaBridge | 156:ff21514d8981 | 104 | * LEUART reference clock assumed when configuring baudrate setup. Set |
AnnaBridge | 156:ff21514d8981 | 105 | * it to 0 if currently configurated reference clock shall be used. |
AnnaBridge | 156:ff21514d8981 | 106 | */ |
AnnaBridge | 156:ff21514d8981 | 107 | uint32_t refFreq; |
AnnaBridge | 156:ff21514d8981 | 108 | |
AnnaBridge | 156:ff21514d8981 | 109 | /** Desired baudrate. */ |
AnnaBridge | 156:ff21514d8981 | 110 | uint32_t baudrate; |
AnnaBridge | 156:ff21514d8981 | 111 | |
AnnaBridge | 156:ff21514d8981 | 112 | /** Number of databits in frame. */ |
AnnaBridge | 156:ff21514d8981 | 113 | LEUART_Databits_TypeDef databits; |
AnnaBridge | 156:ff21514d8981 | 114 | |
AnnaBridge | 156:ff21514d8981 | 115 | /** Parity mode to use. */ |
AnnaBridge | 156:ff21514d8981 | 116 | LEUART_Parity_TypeDef parity; |
AnnaBridge | 156:ff21514d8981 | 117 | |
AnnaBridge | 156:ff21514d8981 | 118 | /** Number of stopbits to use. */ |
AnnaBridge | 156:ff21514d8981 | 119 | LEUART_Stopbits_TypeDef stopbits; |
AnnaBridge | 156:ff21514d8981 | 120 | } LEUART_Init_TypeDef; |
AnnaBridge | 156:ff21514d8981 | 121 | |
AnnaBridge | 156:ff21514d8981 | 122 | /** Default config for LEUART init structure. */ |
AnnaBridge | 156:ff21514d8981 | 123 | #define LEUART_INIT_DEFAULT \ |
Anna Bridge |
160:5571c4ff569f | 124 | { \ |
Anna Bridge |
160:5571c4ff569f | 125 | leuartEnable, /* Enable RX/TX when init completed. */ \ |
Anna Bridge |
160:5571c4ff569f | 126 | 0, /* Use current configured reference clock for configuring baudrate. */ \ |
Anna Bridge |
160:5571c4ff569f | 127 | 9600, /* 9600 bits/s. */ \ |
Anna Bridge |
160:5571c4ff569f | 128 | leuartDatabits8, /* 8 databits. */ \ |
Anna Bridge |
160:5571c4ff569f | 129 | leuartNoParity, /* No parity. */ \ |
Anna Bridge |
160:5571c4ff569f | 130 | leuartStopbits1 /* 1 stopbit. */ \ |
Anna Bridge |
160:5571c4ff569f | 131 | } |
AnnaBridge | 156:ff21514d8981 | 132 | |
AnnaBridge | 156:ff21514d8981 | 133 | /******************************************************************************* |
AnnaBridge | 156:ff21514d8981 | 134 | ***************************** PROTOTYPES ********************************** |
AnnaBridge | 156:ff21514d8981 | 135 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 136 | |
AnnaBridge | 156:ff21514d8981 | 137 | uint32_t LEUART_BaudrateCalc(uint32_t refFreq, uint32_t clkdiv); |
AnnaBridge | 156:ff21514d8981 | 138 | uint32_t LEUART_BaudrateGet(LEUART_TypeDef *leuart); |
AnnaBridge | 156:ff21514d8981 | 139 | void LEUART_BaudrateSet(LEUART_TypeDef *leuart, |
AnnaBridge | 156:ff21514d8981 | 140 | uint32_t refFreq, |
AnnaBridge | 156:ff21514d8981 | 141 | uint32_t baudrate); |
AnnaBridge | 156:ff21514d8981 | 142 | void LEUART_Enable(LEUART_TypeDef *leuart, LEUART_Enable_TypeDef enable); |
AnnaBridge | 156:ff21514d8981 | 143 | void LEUART_FreezeEnable(LEUART_TypeDef *leuart, bool enable); |
AnnaBridge | 156:ff21514d8981 | 144 | void LEUART_Init(LEUART_TypeDef *leuart, LEUART_Init_TypeDef const *init); |
AnnaBridge | 156:ff21514d8981 | 145 | void LEUART_TxDmaInEM2Enable(LEUART_TypeDef *leuart, bool enable); |
AnnaBridge | 156:ff21514d8981 | 146 | void LEUART_RxDmaInEM2Enable(LEUART_TypeDef *leuart, bool enable); |
AnnaBridge | 156:ff21514d8981 | 147 | |
AnnaBridge | 156:ff21514d8981 | 148 | /***************************************************************************//** |
AnnaBridge | 156:ff21514d8981 | 149 | * @brief |
AnnaBridge | 156:ff21514d8981 | 150 | * Clear one or more pending LEUART interrupts. |
AnnaBridge | 156:ff21514d8981 | 151 | * |
AnnaBridge | 156:ff21514d8981 | 152 | * @param[in] leuart |
AnnaBridge | 156:ff21514d8981 | 153 | * Pointer to LEUART peripheral register block. |
AnnaBridge | 156:ff21514d8981 | 154 | * |
AnnaBridge | 156:ff21514d8981 | 155 | * @param[in] flags |
AnnaBridge | 156:ff21514d8981 | 156 | * Pending LEUART interrupt source to clear. Use a bitwise logic OR |
AnnaBridge | 156:ff21514d8981 | 157 | * combination of valid interrupt flags for the LEUART module (LEUART_IF_nnn). |
AnnaBridge | 156:ff21514d8981 | 158 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 159 | __STATIC_INLINE void LEUART_IntClear(LEUART_TypeDef *leuart, uint32_t flags) |
AnnaBridge | 156:ff21514d8981 | 160 | { |
AnnaBridge | 156:ff21514d8981 | 161 | leuart->IFC = flags; |
AnnaBridge | 156:ff21514d8981 | 162 | } |
AnnaBridge | 156:ff21514d8981 | 163 | |
AnnaBridge | 156:ff21514d8981 | 164 | /***************************************************************************//** |
AnnaBridge | 156:ff21514d8981 | 165 | * @brief |
AnnaBridge | 156:ff21514d8981 | 166 | * Disable one or more LEUART interrupts. |
AnnaBridge | 156:ff21514d8981 | 167 | * |
AnnaBridge | 156:ff21514d8981 | 168 | * @param[in] leuart |
AnnaBridge | 156:ff21514d8981 | 169 | * Pointer to LEUART peripheral register block. |
AnnaBridge | 156:ff21514d8981 | 170 | * |
AnnaBridge | 156:ff21514d8981 | 171 | * @param[in] flags |
AnnaBridge | 156:ff21514d8981 | 172 | * LEUART interrupt sources to disable. Use a bitwise logic OR combination of |
AnnaBridge | 156:ff21514d8981 | 173 | * valid interrupt flags for the LEUART module (LEUART_IF_nnn). |
AnnaBridge | 156:ff21514d8981 | 174 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 175 | __STATIC_INLINE void LEUART_IntDisable(LEUART_TypeDef *leuart, uint32_t flags) |
AnnaBridge | 156:ff21514d8981 | 176 | { |
AnnaBridge | 156:ff21514d8981 | 177 | leuart->IEN &= ~flags; |
AnnaBridge | 156:ff21514d8981 | 178 | } |
AnnaBridge | 156:ff21514d8981 | 179 | |
AnnaBridge | 156:ff21514d8981 | 180 | /***************************************************************************//** |
AnnaBridge | 156:ff21514d8981 | 181 | * @brief |
AnnaBridge | 156:ff21514d8981 | 182 | * Enable one or more LEUART interrupts. |
AnnaBridge | 156:ff21514d8981 | 183 | * |
AnnaBridge | 156:ff21514d8981 | 184 | * @note |
AnnaBridge | 156:ff21514d8981 | 185 | * Depending on the use, a pending interrupt may already be set prior to |
AnnaBridge | 156:ff21514d8981 | 186 | * enabling the interrupt. Consider using LEUART_IntClear() prior to enabling |
AnnaBridge | 156:ff21514d8981 | 187 | * if such a pending interrupt should be ignored. |
AnnaBridge | 156:ff21514d8981 | 188 | * |
AnnaBridge | 156:ff21514d8981 | 189 | * @param[in] leuart |
AnnaBridge | 156:ff21514d8981 | 190 | * Pointer to LEUART peripheral register block. |
AnnaBridge | 156:ff21514d8981 | 191 | * |
AnnaBridge | 156:ff21514d8981 | 192 | * @param[in] flags |
AnnaBridge | 156:ff21514d8981 | 193 | * LEUART interrupt sources to enable. Use a bitwise logic OR combination of |
AnnaBridge | 156:ff21514d8981 | 194 | * valid interrupt flags for the LEUART module (LEUART_IF_nnn). |
AnnaBridge | 156:ff21514d8981 | 195 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 196 | __STATIC_INLINE void LEUART_IntEnable(LEUART_TypeDef *leuart, uint32_t flags) |
AnnaBridge | 156:ff21514d8981 | 197 | { |
AnnaBridge | 156:ff21514d8981 | 198 | leuart->IEN |= flags; |
AnnaBridge | 156:ff21514d8981 | 199 | } |
AnnaBridge | 156:ff21514d8981 | 200 | |
AnnaBridge | 156:ff21514d8981 | 201 | /***************************************************************************//** |
AnnaBridge | 156:ff21514d8981 | 202 | * @brief |
AnnaBridge | 156:ff21514d8981 | 203 | * Get pending LEUART interrupt flags. |
AnnaBridge | 156:ff21514d8981 | 204 | * |
AnnaBridge | 156:ff21514d8981 | 205 | * @note |
AnnaBridge | 156:ff21514d8981 | 206 | * The event bits are not cleared by the use of this function. |
AnnaBridge | 156:ff21514d8981 | 207 | * |
AnnaBridge | 156:ff21514d8981 | 208 | * @param[in] leuart |
AnnaBridge | 156:ff21514d8981 | 209 | * Pointer to LEUART peripheral register block. |
AnnaBridge | 156:ff21514d8981 | 210 | * |
AnnaBridge | 156:ff21514d8981 | 211 | * @return |
AnnaBridge | 156:ff21514d8981 | 212 | * LEUART interrupt sources pending. A bitwise logic OR combination of valid |
AnnaBridge | 156:ff21514d8981 | 213 | * interrupt flags for the LEUART module (LEUART_IF_nnn). |
AnnaBridge | 156:ff21514d8981 | 214 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 215 | __STATIC_INLINE uint32_t LEUART_IntGet(LEUART_TypeDef *leuart) |
AnnaBridge | 156:ff21514d8981 | 216 | { |
AnnaBridge | 156:ff21514d8981 | 217 | return leuart->IF; |
AnnaBridge | 156:ff21514d8981 | 218 | } |
AnnaBridge | 156:ff21514d8981 | 219 | |
AnnaBridge | 156:ff21514d8981 | 220 | /***************************************************************************//** |
AnnaBridge | 156:ff21514d8981 | 221 | * @brief |
AnnaBridge | 156:ff21514d8981 | 222 | * Get enabled and pending LEUART interrupt flags. |
AnnaBridge | 156:ff21514d8981 | 223 | * Useful for handling more interrupt sources in the same interrupt handler. |
AnnaBridge | 156:ff21514d8981 | 224 | * |
AnnaBridge | 156:ff21514d8981 | 225 | * @param[in] leuart |
AnnaBridge | 156:ff21514d8981 | 226 | * Pointer to LEUART peripheral register block. |
AnnaBridge | 156:ff21514d8981 | 227 | * |
AnnaBridge | 156:ff21514d8981 | 228 | * @note |
AnnaBridge | 156:ff21514d8981 | 229 | * Interrupt flags are not cleared by the use of this function. |
AnnaBridge | 156:ff21514d8981 | 230 | * |
AnnaBridge | 156:ff21514d8981 | 231 | * @return |
AnnaBridge | 156:ff21514d8981 | 232 | * Pending and enabled LEUART interrupt sources. |
AnnaBridge | 156:ff21514d8981 | 233 | * The return value is the bitwise AND combination of |
AnnaBridge | 156:ff21514d8981 | 234 | * - the OR combination of enabled interrupt sources in LEUARTx_IEN_nnn |
AnnaBridge | 156:ff21514d8981 | 235 | * register (LEUARTx_IEN_nnn) and |
AnnaBridge | 156:ff21514d8981 | 236 | * - the OR combination of valid interrupt flags of the LEUART module |
AnnaBridge | 156:ff21514d8981 | 237 | * (LEUARTx_IF_nnn). |
AnnaBridge | 156:ff21514d8981 | 238 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 239 | __STATIC_INLINE uint32_t LEUART_IntGetEnabled(LEUART_TypeDef *leuart) |
AnnaBridge | 156:ff21514d8981 | 240 | { |
AnnaBridge | 156:ff21514d8981 | 241 | uint32_t tmp; |
AnnaBridge | 156:ff21514d8981 | 242 | |
AnnaBridge | 156:ff21514d8981 | 243 | /* Store LEUARTx->IEN in temporary variable in order to define explicit order |
AnnaBridge | 156:ff21514d8981 | 244 | * of volatile accesses. */ |
AnnaBridge | 156:ff21514d8981 | 245 | tmp = leuart->IEN; |
AnnaBridge | 156:ff21514d8981 | 246 | |
AnnaBridge | 156:ff21514d8981 | 247 | /* Bitwise AND of pending and enabled interrupts */ |
AnnaBridge | 156:ff21514d8981 | 248 | return leuart->IF & tmp; |
AnnaBridge | 156:ff21514d8981 | 249 | } |
AnnaBridge | 156:ff21514d8981 | 250 | |
AnnaBridge | 156:ff21514d8981 | 251 | /***************************************************************************//** |
AnnaBridge | 156:ff21514d8981 | 252 | * @brief |
AnnaBridge | 156:ff21514d8981 | 253 | * Set one or more pending LEUART interrupts from SW. |
AnnaBridge | 156:ff21514d8981 | 254 | * |
AnnaBridge | 156:ff21514d8981 | 255 | * @param[in] leuart |
AnnaBridge | 156:ff21514d8981 | 256 | * Pointer to LEUART peripheral register block. |
AnnaBridge | 156:ff21514d8981 | 257 | * |
AnnaBridge | 156:ff21514d8981 | 258 | * @param[in] flags |
AnnaBridge | 156:ff21514d8981 | 259 | * LEUART interrupt sources to set to pending. Use a bitwise logic OR |
AnnaBridge | 156:ff21514d8981 | 260 | * combination of valid interrupt flags for the LEUART module (LEUART_IF_nnn). |
AnnaBridge | 156:ff21514d8981 | 261 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 262 | __STATIC_INLINE void LEUART_IntSet(LEUART_TypeDef *leuart, uint32_t flags) |
AnnaBridge | 156:ff21514d8981 | 263 | { |
AnnaBridge | 156:ff21514d8981 | 264 | leuart->IFS = flags; |
AnnaBridge | 156:ff21514d8981 | 265 | } |
AnnaBridge | 156:ff21514d8981 | 266 | |
AnnaBridge | 156:ff21514d8981 | 267 | /***************************************************************************//** |
AnnaBridge | 156:ff21514d8981 | 268 | * @brief |
AnnaBridge | 156:ff21514d8981 | 269 | * Get LEUART STATUS register. |
AnnaBridge | 156:ff21514d8981 | 270 | * |
AnnaBridge | 156:ff21514d8981 | 271 | * @param[in] leuart |
AnnaBridge | 156:ff21514d8981 | 272 | * Pointer to LEUART peripheral register block. |
AnnaBridge | 156:ff21514d8981 | 273 | * |
AnnaBridge | 156:ff21514d8981 | 274 | * @return |
AnnaBridge | 156:ff21514d8981 | 275 | * STATUS register value. |
AnnaBridge | 156:ff21514d8981 | 276 | * |
AnnaBridge | 156:ff21514d8981 | 277 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 278 | __STATIC_INLINE uint32_t LEUART_StatusGet(LEUART_TypeDef *leuart) |
AnnaBridge | 156:ff21514d8981 | 279 | { |
AnnaBridge | 156:ff21514d8981 | 280 | return leuart->STATUS; |
AnnaBridge | 156:ff21514d8981 | 281 | } |
AnnaBridge | 156:ff21514d8981 | 282 | |
AnnaBridge | 156:ff21514d8981 | 283 | void LEUART_Reset(LEUART_TypeDef *leuart); |
AnnaBridge | 156:ff21514d8981 | 284 | uint8_t LEUART_Rx(LEUART_TypeDef *leuart); |
AnnaBridge | 156:ff21514d8981 | 285 | uint16_t LEUART_RxExt(LEUART_TypeDef *leuart); |
AnnaBridge | 156:ff21514d8981 | 286 | void LEUART_Tx(LEUART_TypeDef *leuart, uint8_t data); |
AnnaBridge | 156:ff21514d8981 | 287 | void LEUART_TxExt(LEUART_TypeDef *leuart, uint16_t data); |
AnnaBridge | 156:ff21514d8981 | 288 | |
AnnaBridge | 156:ff21514d8981 | 289 | /***************************************************************************//** |
AnnaBridge | 156:ff21514d8981 | 290 | * @brief |
AnnaBridge | 156:ff21514d8981 | 291 | * Receive one 8 bit frame, (or part of a 9 bit frame). |
AnnaBridge | 156:ff21514d8981 | 292 | * |
AnnaBridge | 156:ff21514d8981 | 293 | * @details |
AnnaBridge | 156:ff21514d8981 | 294 | * This function is used to quickly receive one 8 bit frame by reading the |
AnnaBridge | 156:ff21514d8981 | 295 | * RXDATA register directly, without checking the STATUS register for the |
AnnaBridge | 156:ff21514d8981 | 296 | * RXDATAV flag. This can be useful from the RXDATAV interrupt handler, |
AnnaBridge | 156:ff21514d8981 | 297 | * i.e. waiting is superfluous, in order to quickly read the received data. |
AnnaBridge | 156:ff21514d8981 | 298 | * Please refer to @ref LEUART_RxDataXGet() for reception of 9 bit frames. |
AnnaBridge | 156:ff21514d8981 | 299 | * |
AnnaBridge | 156:ff21514d8981 | 300 | * @note |
AnnaBridge | 156:ff21514d8981 | 301 | * Since this function does not check whether the RXDATA register actually |
AnnaBridge | 156:ff21514d8981 | 302 | * holds valid data, it should only be used in situations when it is certain |
AnnaBridge | 156:ff21514d8981 | 303 | * that there is valid data, ensured by some external program routine, e.g. |
AnnaBridge | 156:ff21514d8981 | 304 | * like when handling an RXDATAV interrupt. The @ref LEUART_Rx() is normally a |
AnnaBridge | 156:ff21514d8981 | 305 | * better choice if the validity of the RXDATA register is not certain. |
AnnaBridge | 156:ff21514d8981 | 306 | * |
AnnaBridge | 156:ff21514d8981 | 307 | * @note |
AnnaBridge | 156:ff21514d8981 | 308 | * Notice that possible parity/stop bits are not |
AnnaBridge | 156:ff21514d8981 | 309 | * considered part of specified frame bit length. |
AnnaBridge | 156:ff21514d8981 | 310 | * |
AnnaBridge | 156:ff21514d8981 | 311 | * @param[in] leuart |
AnnaBridge | 156:ff21514d8981 | 312 | * Pointer to LEUART peripheral register block. |
AnnaBridge | 156:ff21514d8981 | 313 | * |
AnnaBridge | 156:ff21514d8981 | 314 | * @return |
AnnaBridge | 156:ff21514d8981 | 315 | * Data received. |
AnnaBridge | 156:ff21514d8981 | 316 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 317 | __STATIC_INLINE uint8_t LEUART_RxDataGet(LEUART_TypeDef *leuart) |
AnnaBridge | 156:ff21514d8981 | 318 | { |
AnnaBridge | 156:ff21514d8981 | 319 | return (uint8_t)leuart->RXDATA; |
AnnaBridge | 156:ff21514d8981 | 320 | } |
AnnaBridge | 156:ff21514d8981 | 321 | |
AnnaBridge | 156:ff21514d8981 | 322 | /***************************************************************************//** |
AnnaBridge | 156:ff21514d8981 | 323 | * @brief |
AnnaBridge | 156:ff21514d8981 | 324 | * Receive one 8-9 bit frame, with extended information. |
AnnaBridge | 156:ff21514d8981 | 325 | * |
AnnaBridge | 156:ff21514d8981 | 326 | * @details |
AnnaBridge | 156:ff21514d8981 | 327 | * This function is used to quickly receive one 8-9 bit frame with extended |
AnnaBridge | 156:ff21514d8981 | 328 | * information by reading the RXDATAX register directly, without checking the |
AnnaBridge | 156:ff21514d8981 | 329 | * STATUS register for the RXDATAV flag. This can be useful from the RXDATAV |
AnnaBridge | 156:ff21514d8981 | 330 | * interrupt handler, i.e. waiting is superfluous, in order to quickly read |
AnnaBridge | 156:ff21514d8981 | 331 | * the received data. |
AnnaBridge | 156:ff21514d8981 | 332 | * |
AnnaBridge | 156:ff21514d8981 | 333 | * @note |
AnnaBridge | 156:ff21514d8981 | 334 | * Since this function does not check whether the RXDATAX register actually |
AnnaBridge | 156:ff21514d8981 | 335 | * holds valid data, it should only be used in situations when it is certain |
AnnaBridge | 156:ff21514d8981 | 336 | * that there is valid data, ensured by some external program routine, e.g. |
AnnaBridge | 156:ff21514d8981 | 337 | * like when handling an RXDATAV interrupt. The @ref LEUART_RxExt() is normally |
AnnaBridge | 156:ff21514d8981 | 338 | * a better choice if the validity of the RXDATAX register is not certain. |
AnnaBridge | 156:ff21514d8981 | 339 | * |
AnnaBridge | 156:ff21514d8981 | 340 | * @note |
AnnaBridge | 156:ff21514d8981 | 341 | * Notice that possible parity/stop bits are not |
AnnaBridge | 156:ff21514d8981 | 342 | * considered part of specified frame bit length. |
AnnaBridge | 156:ff21514d8981 | 343 | * |
AnnaBridge | 156:ff21514d8981 | 344 | * @param[in] leuart |
AnnaBridge | 156:ff21514d8981 | 345 | * Pointer to LEUART peripheral register block. |
AnnaBridge | 156:ff21514d8981 | 346 | * |
AnnaBridge | 156:ff21514d8981 | 347 | * @return |
AnnaBridge | 156:ff21514d8981 | 348 | * Data received. |
AnnaBridge | 156:ff21514d8981 | 349 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 350 | __STATIC_INLINE uint16_t LEUART_RxDataXGet(LEUART_TypeDef *leuart) |
AnnaBridge | 156:ff21514d8981 | 351 | { |
AnnaBridge | 156:ff21514d8981 | 352 | return (uint16_t)leuart->RXDATAX; |
AnnaBridge | 156:ff21514d8981 | 353 | } |
AnnaBridge | 156:ff21514d8981 | 354 | |
AnnaBridge | 156:ff21514d8981 | 355 | /** @} (end addtogroup LEUART) */ |
AnnaBridge | 156:ff21514d8981 | 356 | /** @} (end addtogroup emlib) */ |
AnnaBridge | 156:ff21514d8981 | 357 | |
AnnaBridge | 156:ff21514d8981 | 358 | #ifdef __cplusplus |
AnnaBridge | 156:ff21514d8981 | 359 | } |
AnnaBridge | 156:ff21514d8981 | 360 | #endif |
AnnaBridge | 156:ff21514d8981 | 361 | |
AnnaBridge | 156:ff21514d8981 | 362 | #endif /* defined(LEUART_COUNT) && (LEUART_COUNT > 0) */ |
AnnaBridge | 156:ff21514d8981 | 363 | #endif /* EM_LEUART_H */ |