mbed library sources. Supersedes mbed-src. Edited target satm32f446 for user USART3 pins

Dependents:   IGLOO_board

Fork of mbed-dev by mbed official

Committer:
ua1arn
Date:
Mon Jul 30 12:31:10 2018 +0000
Revision:
188:3f10722804f9
Parent:
186:707f6e361f3e
before add multi-configuration USB descriptors

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Anna Bridge 186:707f6e361f3e 1 /**
Anna Bridge 186:707f6e361f3e 2 * @file
Anna Bridge 186:707f6e361f3e 3 * @brief I2CM (Inter-Integrated Circuit Master) function prototypes and
Anna Bridge 186:707f6e361f3e 4 * data types.
Anna Bridge 186:707f6e361f3e 5 */
Anna Bridge 186:707f6e361f3e 6
Anna Bridge 186:707f6e361f3e 7 /* ****************************************************************************
Anna Bridge 186:707f6e361f3e 8 * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
Anna Bridge 186:707f6e361f3e 9 *
Anna Bridge 186:707f6e361f3e 10 * Permission is hereby granted, free of charge, to any person obtaining a
Anna Bridge 186:707f6e361f3e 11 * copy of this software and associated documentation files (the "Software"),
Anna Bridge 186:707f6e361f3e 12 * to deal in the Software without restriction, including without limitation
Anna Bridge 186:707f6e361f3e 13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
Anna Bridge 186:707f6e361f3e 14 * and/or sell copies of the Software, and to permit persons to whom the
Anna Bridge 186:707f6e361f3e 15 * Software is furnished to do so, subject to the following conditions:
Anna Bridge 186:707f6e361f3e 16 *
Anna Bridge 186:707f6e361f3e 17 * The above copyright notice and this permission notice shall be included
Anna Bridge 186:707f6e361f3e 18 * in all copies or substantial portions of the Software.
Anna Bridge 186:707f6e361f3e 19 *
Anna Bridge 186:707f6e361f3e 20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
Anna Bridge 186:707f6e361f3e 21 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
Anna Bridge 186:707f6e361f3e 22 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
Anna Bridge 186:707f6e361f3e 23 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
Anna Bridge 186:707f6e361f3e 24 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
Anna Bridge 186:707f6e361f3e 25 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
Anna Bridge 186:707f6e361f3e 26 * OTHER DEALINGS IN THE SOFTWARE.
Anna Bridge 186:707f6e361f3e 27 *
Anna Bridge 186:707f6e361f3e 28 * Except as contained in this notice, the name of Maxim Integrated
Anna Bridge 186:707f6e361f3e 29 * Products, Inc. shall not be used except as stated in the Maxim Integrated
Anna Bridge 186:707f6e361f3e 30 * Products, Inc. Branding Policy.
Anna Bridge 186:707f6e361f3e 31 *
Anna Bridge 186:707f6e361f3e 32 * The mere transfer of this software does not imply any licenses
Anna Bridge 186:707f6e361f3e 33 * of trade secrets, proprietary technology, copyrights, patents,
Anna Bridge 186:707f6e361f3e 34 * trademarks, maskwork rights, or any other form of intellectual
Anna Bridge 186:707f6e361f3e 35 * property whatsoever. Maxim Integrated Products, Inc. retains all
Anna Bridge 186:707f6e361f3e 36 * ownership rights.
Anna Bridge 186:707f6e361f3e 37 *
Anna Bridge 186:707f6e361f3e 38 * $Date: 2017-02-16 12:08:14 -0600 (Thu, 16 Feb 2017) $
Anna Bridge 186:707f6e361f3e 39 * $Revision: 26469 $
Anna Bridge 186:707f6e361f3e 40 *
Anna Bridge 186:707f6e361f3e 41 *************************************************************************** */
Anna Bridge 186:707f6e361f3e 42
Anna Bridge 186:707f6e361f3e 43 /* Define to prevent redundant inclusion */
Anna Bridge 186:707f6e361f3e 44 #ifndef _I2CM_H_
Anna Bridge 186:707f6e361f3e 45 #define _I2CM_H_
Anna Bridge 186:707f6e361f3e 46
Anna Bridge 186:707f6e361f3e 47 /***** Includes *****/
Anna Bridge 186:707f6e361f3e 48 #include "mxc_config.h"
Anna Bridge 186:707f6e361f3e 49 #include "mxc_sys.h"
Anna Bridge 186:707f6e361f3e 50 /**
Anna Bridge 186:707f6e361f3e 51 * @ingroup periphlibs
Anna Bridge 186:707f6e361f3e 52 * @defgroup i2cm I2C Master
Anna Bridge 186:707f6e361f3e 53 * @brief I2C Master Peripheral API
Anna Bridge 186:707f6e361f3e 54 * @{
Anna Bridge 186:707f6e361f3e 55 */
Anna Bridge 186:707f6e361f3e 56 #include "i2cm_regs.h"
Anna Bridge 186:707f6e361f3e 57
Anna Bridge 186:707f6e361f3e 58 #ifdef __cplusplus
Anna Bridge 186:707f6e361f3e 59 extern "C" {
Anna Bridge 186:707f6e361f3e 60 #endif
Anna Bridge 186:707f6e361f3e 61
Anna Bridge 186:707f6e361f3e 62
Anna Bridge 186:707f6e361f3e 63 /* **** Definitions **** */
Anna Bridge 186:707f6e361f3e 64
Anna Bridge 186:707f6e361f3e 65 /**
Anna Bridge 186:707f6e361f3e 66 * Enumeration type to select supported I2CM frequencies.
Anna Bridge 186:707f6e361f3e 67 */
Anna Bridge 186:707f6e361f3e 68 typedef enum {
Anna Bridge 186:707f6e361f3e 69 I2CM_SPEED_100KHZ = 0, /**< Use to select a bus communication speed of 100 kHz. */
Anna Bridge 186:707f6e361f3e 70 I2CM_SPEED_400KHZ = 1 /**< Use to select a bus communication speed of 400 kHz. */
Anna Bridge 186:707f6e361f3e 71 } i2cm_speed_t;
Anna Bridge 186:707f6e361f3e 72
Anna Bridge 186:707f6e361f3e 73 /**
Anna Bridge 186:707f6e361f3e 74 * Structure type for an I2CM Transaction request.
Anna Bridge 186:707f6e361f3e 75 */
Anna Bridge 186:707f6e361f3e 76 typedef struct i2cm_req i2cm_req_t;
Anna Bridge 186:707f6e361f3e 77
Anna Bridge 186:707f6e361f3e 78 /**
Anna Bridge 186:707f6e361f3e 79 * @addtogroup i2cm_async
Anna Bridge 186:707f6e361f3e 80 * @{
Anna Bridge 186:707f6e361f3e 81 * Function type for the I2C Master callback. The function declaration for the
Anna Bridge 186:707f6e361f3e 82 * I2CM callback is:
Anna Bridge 186:707f6e361f3e 83 * @code
Anna Bridge 186:707f6e361f3e 84 * void callback(i2cm_req_t * req, int error_code);
Anna Bridge 186:707f6e361f3e 85 * @endcode
Anna Bridge 186:707f6e361f3e 86 * | | |
Anna Bridge 186:707f6e361f3e 87 * | -----: | :----------------------------------------- |
Anna Bridge 186:707f6e361f3e 88 * | @p req | Pointer to an #i2cm_req object representing the I2CM active transaction. |
Anna Bridge 186:707f6e361f3e 89 * | @p error_code | An error code if the active transaction had a failure or #E_NO_ERROR if successful. |
Anna Bridge 186:707f6e361f3e 90 *
Anna Bridge 186:707f6e361f3e 91 */
Anna Bridge 186:707f6e361f3e 92 typedef void (*i2cm_callback_fn)(i2cm_req_t * req, int error_code);
Anna Bridge 186:707f6e361f3e 93 /**@}*/
Anna Bridge 186:707f6e361f3e 94
Anna Bridge 186:707f6e361f3e 95
Anna Bridge 186:707f6e361f3e 96 /**
Anna Bridge 186:707f6e361f3e 97 * I2CM Transaction request structure.
Anna Bridge 186:707f6e361f3e 98 * @note Only supports 7-bit addressing. Driver will shift the address and
Anna Bridge 186:707f6e361f3e 99 * add the read bit when necessary.
Anna Bridge 186:707f6e361f3e 100 */
Anna Bridge 186:707f6e361f3e 101 struct i2cm_req {
Anna Bridge 186:707f6e361f3e 102 uint8_t addr; /**< 7-Bit unshifted address of the slave for communication. */
Anna Bridge 186:707f6e361f3e 103 const uint8_t *cmd_data; /**< Pointer to a command data buffer to send to the slave before either a read or write transaction. */
Anna Bridge 186:707f6e361f3e 104 uint32_t cmd_len; /**< Number of bytes in command. */
Anna Bridge 186:707f6e361f3e 105 uint8_t *data; /**< Data to write or read. */
Anna Bridge 186:707f6e361f3e 106 uint32_t data_len; /**< Length of data. */
Anna Bridge 186:707f6e361f3e 107 uint32_t cmd_num; /**< Number of command bytes sent. */
Anna Bridge 186:707f6e361f3e 108 uint32_t data_num; /**< Number of data bytes sent. */
Anna Bridge 186:707f6e361f3e 109 i2cm_callback_fn callback; /**< Function pointer to a callback function. */
Anna Bridge 186:707f6e361f3e 110 };
Anna Bridge 186:707f6e361f3e 111
Anna Bridge 186:707f6e361f3e 112 /* **** Globals **** */
Anna Bridge 186:707f6e361f3e 113
Anna Bridge 186:707f6e361f3e 114 /* **** Function Prototypes **** */
Anna Bridge 186:707f6e361f3e 115
Anna Bridge 186:707f6e361f3e 116 /**
Anna Bridge 186:707f6e361f3e 117 * @brief Initialize the I2CM peripheral module.
Anna Bridge 186:707f6e361f3e 118 *
Anna Bridge 186:707f6e361f3e 119 * @param i2cm Pointer to the I2CM registers, see #mxc_i2cm_regs_t.
Anna Bridge 186:707f6e361f3e 120 * @param sys_cfg Pointer to an I2CM configuration structure of type
Anna Bridge 186:707f6e361f3e 121 * #sys_cfg_i2cm_t.
Anna Bridge 186:707f6e361f3e 122 * @param speed I2CM bus speed, see #i2cm_speed_t.
Anna Bridge 186:707f6e361f3e 123 *
Anna Bridge 186:707f6e361f3e 124 * @return #E_NO_ERROR if initialized successfully, error if unsuccessful.
Anna Bridge 186:707f6e361f3e 125 */
Anna Bridge 186:707f6e361f3e 126 int I2CM_Init(mxc_i2cm_regs_t *i2cm, const sys_cfg_i2cm_t *sys_cfg, i2cm_speed_t speed);
Anna Bridge 186:707f6e361f3e 127
Anna Bridge 186:707f6e361f3e 128 /**
Anna Bridge 186:707f6e361f3e 129 * @brief Shutdown I2CM module.
Anna Bridge 186:707f6e361f3e 130 *
Anna Bridge 186:707f6e361f3e 131 * @param i2cm Pointer to the I2CM registers, see #mxc_i2cm_regs_t.
Anna Bridge 186:707f6e361f3e 132 *
Anna Bridge 186:707f6e361f3e 133 * @returns #E_NO_ERROR if everything is successful, error if unsuccessful.
Anna Bridge 186:707f6e361f3e 134 *
Anna Bridge 186:707f6e361f3e 135 */
Anna Bridge 186:707f6e361f3e 136 int I2CM_Shutdown(mxc_i2cm_regs_t *i2cm);
Anna Bridge 186:707f6e361f3e 137
Anna Bridge 186:707f6e361f3e 138 /**
Anna Bridge 186:707f6e361f3e 139 * @defgroup i2cm_blocking I2CM Blocking Functions
Anna Bridge 186:707f6e361f3e 140 * @{
Anna Bridge 186:707f6e361f3e 141 */
Anna Bridge 186:707f6e361f3e 142
Anna Bridge 186:707f6e361f3e 143 /**
Anna Bridge 186:707f6e361f3e 144 * @brief Read I2CM data. Will block until transaction is complete.
Anna Bridge 186:707f6e361f3e 145 *
Anna Bridge 186:707f6e361f3e 146 * @note Command is an optional feature where the master will write the @c
Anna Bridge 186:707f6e361f3e 147 * cmd_data before reading from the slave. If command is undesired,
Anna Bridge 186:707f6e361f3e 148 * set the @c *cmd_data parameter to NULL and pass 0 for the @c
Anna Bridge 186:707f6e361f3e 149 * cmd_len parameter.
Anna Bridge 186:707f6e361f3e 150 * @note If there is a command, the master will send a repeated start
Anna Bridge 186:707f6e361f3e 151 * sequence before attempting to read from the slave.
Anna Bridge 186:707f6e361f3e 152 * @note This function blocks until the transaction has completed.
Anna Bridge 186:707f6e361f3e 153 *
Anna Bridge 186:707f6e361f3e 154 * @param i2cm Pointer to the I2CM registers, see #mxc_i2cm_regs_t.
Anna Bridge 186:707f6e361f3e 155 * @param addr I2C address of the slave.
Anna Bridge 186:707f6e361f3e 156 * @param cmd_data Data to write before reading.
Anna Bridge 186:707f6e361f3e 157 * @param cmd_len Number of bytes to write before reading.
Anna Bridge 186:707f6e361f3e 158 * @param data Where to store the data read.
Anna Bridge 186:707f6e361f3e 159 * @param len Number of bytes to read.
Anna Bridge 186:707f6e361f3e 160 *
Anna Bridge 186:707f6e361f3e 161 * @return Number of bytes read if successful, error code if unsuccessful.
Anna Bridge 186:707f6e361f3e 162 */
Anna Bridge 186:707f6e361f3e 163 int I2CM_Read(mxc_i2cm_regs_t *i2cm, uint8_t addr, const uint8_t *cmd_data,
Anna Bridge 186:707f6e361f3e 164 uint32_t cmd_len, uint8_t* data, uint32_t len, uint8_t stop);
Anna Bridge 186:707f6e361f3e 165
Anna Bridge 186:707f6e361f3e 166 /**
Anna Bridge 186:707f6e361f3e 167 * @brief Write data to a slave device.
Anna Bridge 186:707f6e361f3e 168 *
Anna Bridge 186:707f6e361f3e 169 * @note Command is an optional feature where the master will write the @c
Anna Bridge 186:707f6e361f3e 170 * cmd_data before writing the @c data to the slave. If command is
Anna Bridge 186:707f6e361f3e 171 * not needed, set the @c cmd_data to @c NULL and set @c cmd_len to
Anna Bridge 186:707f6e361f3e 172 * 0. If there is a command, the master will send a repeated start
Anna Bridge 186:707f6e361f3e 173 * sequence before attempting to read from the slave.
Anna Bridge 186:707f6e361f3e 174 * @note This function blocks until the transaction has completed.
Anna Bridge 186:707f6e361f3e 175 *
Anna Bridge 186:707f6e361f3e 176 * @param i2cm Pointer to the I2CM registers, see #mxc_i2cm_regs_t.
Anna Bridge 186:707f6e361f3e 177 * @param addr I2C address of the slave.
Anna Bridge 186:707f6e361f3e 178 * @param cmd_data Data to write before writing data.
Anna Bridge 186:707f6e361f3e 179 * @param cmd_len Number of bytes to write before writing data.
Anna Bridge 186:707f6e361f3e 180 * @param data Data to be written.
Anna Bridge 186:707f6e361f3e 181 * @param len Number of bytes to Write.
Anna Bridge 186:707f6e361f3e 182 *
Anna Bridge 186:707f6e361f3e 183 * @return Number of bytes writen if successful or an @ref MXC_Error_Codes
Anna Bridge 186:707f6e361f3e 184 * "Error Code" if unsuccessful.
Anna Bridge 186:707f6e361f3e 185 */
Anna Bridge 186:707f6e361f3e 186 int I2CM_Write(mxc_i2cm_regs_t *i2cm, uint8_t addr, const uint8_t *cmd_data,
Anna Bridge 186:707f6e361f3e 187 uint32_t cmd_len, uint8_t* data, uint32_t len);
Anna Bridge 186:707f6e361f3e 188 /**@} end of i2cm_blocking functions */
Anna Bridge 186:707f6e361f3e 189
Anna Bridge 186:707f6e361f3e 190 /**
Anna Bridge 186:707f6e361f3e 191 * @defgroup i2cm_async I2CM Asynchrous Functions
Anna Bridge 186:707f6e361f3e 192 * @{
Anna Bridge 186:707f6e361f3e 193 */
Anna Bridge 186:707f6e361f3e 194
Anna Bridge 186:707f6e361f3e 195 /**
Anna Bridge 186:707f6e361f3e 196 * @brief Asynchronously read I2CM data.
Anna Bridge 186:707f6e361f3e 197 *
Anna Bridge 186:707f6e361f3e 198 * @param i2cm Pointer to the I2CM registers, see #mxc_i2cm_regs_t.
Anna Bridge 186:707f6e361f3e 199 * @param req Pointer to an I2CM transaction request structure, see
Anna Bridge 186:707f6e361f3e 200 * #i2cm_req.
Anna Bridge 186:707f6e361f3e 201 *
Anna Bridge 186:707f6e361f3e 202 * @return #E_NO_ERROR if everything is successful or an @ref
Anna Bridge 186:707f6e361f3e 203 * MXC_Error_Codes "Error Code" if unsuccessful.
Anna Bridge 186:707f6e361f3e 204 */
Anna Bridge 186:707f6e361f3e 205 int I2CM_ReadAsync(mxc_i2cm_regs_t *i2cm, i2cm_req_t *req);
Anna Bridge 186:707f6e361f3e 206
Anna Bridge 186:707f6e361f3e 207 /**
Anna Bridge 186:707f6e361f3e 208 * @brief Asynchronously write I2CM data.
Anna Bridge 186:707f6e361f3e 209 *
Anna Bridge 186:707f6e361f3e 210 * @param i2cm Pointer to the I2CM registers, see #mxc_i2cm_regs_t.
Anna Bridge 186:707f6e361f3e 211 * @param req Pointer to an I2CM transaction request structure, see
Anna Bridge 186:707f6e361f3e 212 * #i2cm_req.
Anna Bridge 186:707f6e361f3e 213 *
Anna Bridge 186:707f6e361f3e 214 * @return #E_NO_ERROR if everything is successful, error if unsuccessful.
Anna Bridge 186:707f6e361f3e 215 */
Anna Bridge 186:707f6e361f3e 216 int I2CM_WriteAsync(mxc_i2cm_regs_t *i2cm, i2cm_req_t *req);
Anna Bridge 186:707f6e361f3e 217
Anna Bridge 186:707f6e361f3e 218 /**
Anna Bridge 186:707f6e361f3e 219 * @brief Abort asynchronous request.
Anna Bridge 186:707f6e361f3e 220 * @param req Pointer to request for an I2CM transaction.
Anna Bridge 186:707f6e361f3e 221 * @note Will call the callback for the request.
Anna Bridge 186:707f6e361f3e 222 *
Anna Bridge 186:707f6e361f3e 223 * @return #E_NO_ERROR if request aborted, error if unsuccessful.
Anna Bridge 186:707f6e361f3e 224 */
Anna Bridge 186:707f6e361f3e 225 int I2CM_AbortAsync(i2cm_req_t *req);
Anna Bridge 186:707f6e361f3e 226
Anna Bridge 186:707f6e361f3e 227 /**
Anna Bridge 186:707f6e361f3e 228 * @brief I2CM interrupt handler.
Anna Bridge 186:707f6e361f3e 229 *
Anna Bridge 186:707f6e361f3e 230 * @details This function is an IRQ handler and will be called by the core if
Anna Bridge 186:707f6e361f3e 231 * I2CM interrupts are enabled. Alternately, if the application is
Anna Bridge 186:707f6e361f3e 232 * using asynchronous methods, this function can be periodically
Anna Bridge 186:707f6e361f3e 233 * called by the application if the I2CM interrupts are disabled.
Anna Bridge 186:707f6e361f3e 234 *
Anna Bridge 186:707f6e361f3e 235 * @param i2cm Base address of the I2CM module.
Anna Bridge 186:707f6e361f3e 236 */
Anna Bridge 186:707f6e361f3e 237 void I2CM_Handler(mxc_i2cm_regs_t *i2cm);
Anna Bridge 186:707f6e361f3e 238 /**@} end of i2cm_async */
Anna Bridge 186:707f6e361f3e 239
Anna Bridge 186:707f6e361f3e 240 /**
Anna Bridge 186:707f6e361f3e 241 * @brief Returns the status of the I2CM peripheral module.
Anna Bridge 186:707f6e361f3e 242 *
Anna Bridge 186:707f6e361f3e 243 * @param i2cm Pointer to the I2CM register structure, see
Anna Bridge 186:707f6e361f3e 244 * #mxc_i2cm_regs_t.
Anna Bridge 186:707f6e361f3e 245 *
Anna Bridge 186:707f6e361f3e 246 * @return #E_NO_ERROR if idle.
Anna Bridge 186:707f6e361f3e 247 * @return #E_BUSY if in use.
Anna Bridge 186:707f6e361f3e 248 */
Anna Bridge 186:707f6e361f3e 249 int I2CM_Busy(mxc_i2cm_regs_t *i2cm);
Anna Bridge 186:707f6e361f3e 250
Anna Bridge 186:707f6e361f3e 251 /**
Anna Bridge 186:707f6e361f3e 252 * @brief Attempt to prepare the I2CM for sleep.
Anna Bridge 186:707f6e361f3e 253 * @details Checks for any ongoing transactions. Disables interrupts if the
Anna Bridge 186:707f6e361f3e 254 * I2CM is idle.
Anna Bridge 186:707f6e361f3e 255 *
Anna Bridge 186:707f6e361f3e 256 * @param i2cm Pointer to the I2CM register structure, see
Anna Bridge 186:707f6e361f3e 257 * #mxc_i2cm_regs_t.
Anna Bridge 186:707f6e361f3e 258 *
Anna Bridge 186:707f6e361f3e 259 * @return #E_NO_ERROR if ready to sleep.
Anna Bridge 186:707f6e361f3e 260 * @return #E_BUSY if the bus is not ready for sleep.
Anna Bridge 186:707f6e361f3e 261 */
Anna Bridge 186:707f6e361f3e 262 int I2CM_PrepForSleep(mxc_i2cm_regs_t *i2cm);
Anna Bridge 186:707f6e361f3e 263
Anna Bridge 186:707f6e361f3e 264 /**
Anna Bridge 186:707f6e361f3e 265 * @brief Check the I2C bus to determine if any other masters are using the
Anna Bridge 186:707f6e361f3e 266 * bus.
Anna Bridge 186:707f6e361f3e 267 *
Anna Bridge 186:707f6e361f3e 268 * @param i2cm Pointer to the I2CM register structure, see
Anna Bridge 186:707f6e361f3e 269 * #mxc_i2cm_regs_t.
Anna Bridge 186:707f6e361f3e 270 *
Anna Bridge 186:707f6e361f3e 271 * @return #E_NO_ERROR if SCL and SDA are high,
Anna Bridge 186:707f6e361f3e 272 * @return #E_BUSY otherwise.
Anna Bridge 186:707f6e361f3e 273 */
Anna Bridge 186:707f6e361f3e 274 int I2CM_BusCheck(mxc_i2cm_regs_t *i2cm);
Anna Bridge 186:707f6e361f3e 275
Anna Bridge 186:707f6e361f3e 276 /**
Anna Bridge 186:707f6e361f3e 277 * @brief Drain/Empty all of the data in the I2CM Receive FIFO.
Anna Bridge 186:707f6e361f3e 278 *
Anna Bridge 186:707f6e361f3e 279 * @param i2cm Pointer to the I2CM register structure, see
Anna Bridge 186:707f6e361f3e 280 * #mxc_i2cm_regs_t.
Anna Bridge 186:707f6e361f3e 281 */
Anna Bridge 186:707f6e361f3e 282 __STATIC_INLINE void I2CM_DrainRX(mxc_i2cm_regs_t *i2cm)
Anna Bridge 186:707f6e361f3e 283 {
Anna Bridge 186:707f6e361f3e 284 i2cm->ctrl &= ~(MXC_F_I2CM_CTRL_RX_FIFO_EN);
Anna Bridge 186:707f6e361f3e 285 i2cm->ctrl |= MXC_F_I2CM_CTRL_RX_FIFO_EN;
Anna Bridge 186:707f6e361f3e 286 }
Anna Bridge 186:707f6e361f3e 287
Anna Bridge 186:707f6e361f3e 288 /**
Anna Bridge 186:707f6e361f3e 289 * @brief Drain/Empty any data in the I2CM Transmit FIFO.
Anna Bridge 186:707f6e361f3e 290 *
Anna Bridge 186:707f6e361f3e 291 * @param i2cm Pointer to the I2CM register structure, see
Anna Bridge 186:707f6e361f3e 292 * #mxc_i2cm_regs_t.
Anna Bridge 186:707f6e361f3e 293 */
Anna Bridge 186:707f6e361f3e 294 __STATIC_INLINE void I2CM_DrainTX(mxc_i2cm_regs_t *i2cm)
Anna Bridge 186:707f6e361f3e 295 {
Anna Bridge 186:707f6e361f3e 296 i2cm->ctrl &= ~(MXC_F_I2CM_CTRL_TX_FIFO_EN);
Anna Bridge 186:707f6e361f3e 297 i2cm->ctrl |= MXC_F_I2CM_CTRL_TX_FIFO_EN;
Anna Bridge 186:707f6e361f3e 298 }
Anna Bridge 186:707f6e361f3e 299
Anna Bridge 186:707f6e361f3e 300 /**
Anna Bridge 186:707f6e361f3e 301 * @brief Clear interrupt flags.
Anna Bridge 186:707f6e361f3e 302 *
Anna Bridge 186:707f6e361f3e 303 * @param i2cm Pointer to the I2CM register structure, see
Anna Bridge 186:707f6e361f3e 304 * #mxc_i2cm_regs_t.
Anna Bridge 186:707f6e361f3e 305 * @param mask Mask of I2CM interrupts to clear (1 to clear),
Anna Bridge 186:707f6e361f3e 306 * @see I2CM_INTFL_Register for the interrupt flag masks.
Anna Bridge 186:707f6e361f3e 307 */
Anna Bridge 186:707f6e361f3e 308 __STATIC_INLINE void I2CM_ClearFlags(mxc_i2cm_regs_t *i2cm, uint32_t mask)
Anna Bridge 186:707f6e361f3e 309 {
Anna Bridge 186:707f6e361f3e 310 i2cm->intfl = mask;
Anna Bridge 186:707f6e361f3e 311 }
Anna Bridge 186:707f6e361f3e 312
Anna Bridge 186:707f6e361f3e 313 /**
Anna Bridge 186:707f6e361f3e 314 * @brief Gets the current I2CM interrupt flags.
Anna Bridge 186:707f6e361f3e 315 * @param i2cm Pointer to the I2CM register structure, see
Anna Bridge 186:707f6e361f3e 316 * #mxc_i2cm_regs_t.
Anna Bridge 186:707f6e361f3e 317 *
Anna Bridge 186:707f6e361f3e 318 * @return The currently set interrupt flags, @see I2CM_INTFL_Register
Anna Bridge 186:707f6e361f3e 319 * for the interrupt flag masks.
Anna Bridge 186:707f6e361f3e 320 */
Anna Bridge 186:707f6e361f3e 321 __STATIC_INLINE unsigned I2CM_GetFlags(mxc_i2cm_regs_t *i2cm)
Anna Bridge 186:707f6e361f3e 322 {
Anna Bridge 186:707f6e361f3e 323 return(i2cm->intfl);
Anna Bridge 186:707f6e361f3e 324 }
Anna Bridge 186:707f6e361f3e 325
Anna Bridge 186:707f6e361f3e 326 /**@} end of group i2cm */
Anna Bridge 186:707f6e361f3e 327
Anna Bridge 186:707f6e361f3e 328 void I2CM_Recover(mxc_i2cm_regs_t *i2cm);
Anna Bridge 186:707f6e361f3e 329 int I2CM_Tx(mxc_i2cm_regs_t *i2cm, mxc_i2cm_fifo_regs_t *fifo, uint8_t addr, const uint8_t *data, uint32_t len, uint8_t stop);
Anna Bridge 186:707f6e361f3e 330 int I2CM_TxInProgress(mxc_i2cm_regs_t *i2cm);
Anna Bridge 186:707f6e361f3e 331 int I2CM_WriteTxFifo(mxc_i2cm_regs_t *regs, mxc_i2cm_fifo_regs_t *fifo, const uint16_t data);
Anna Bridge 186:707f6e361f3e 332 int I2CM_Rx(mxc_i2cm_regs_t *i2cm, mxc_i2cm_fifo_regs_t *fifo, uint8_t addr, uint8_t *data, uint32_t len, uint8_t stop);
Anna Bridge 186:707f6e361f3e 333
Anna Bridge 186:707f6e361f3e 334 #ifdef __cplusplus
Anna Bridge 186:707f6e361f3e 335 }
Anna Bridge 186:707f6e361f3e 336 #endif
Anna Bridge 186:707f6e361f3e 337
Anna Bridge 186:707f6e361f3e 338 #endif /* _I2CM_H_ */