Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
uart.h
00001 /***************************************************************************//** 00002 * @file uart.h 00003 * @brief Header file of UART interface. 00004 * @author Cristian Pop (cristian.pop@analog.com) 00005 ******************************************************************************** 00006 * Copyright 2019(c) Analog Devices, Inc. 00007 * 00008 * All rights reserved. 00009 * 00010 * Redistribution and use in source and binary forms, with or without 00011 * modification, are permitted provided that the following conditions are met: 00012 * - Redistributions of source code must retain the above copyright 00013 * notice, this list of conditions and the following disclaimer. 00014 * - Redistributions in binary form must reproduce the above copyright 00015 * notice, this list of conditions and the following disclaimer in 00016 * the documentation and/or other materials provided with the 00017 * distribution. 00018 * - Neither the name of Analog Devices, Inc. nor the names of its 00019 * contributors may be used to endorse or promote products derived 00020 * from this software without specific prior written permission. 00021 * - The use of this software may or may not infringe the patent rights 00022 * of one or more patent holders. This license does not release you 00023 * from the requirement that you obtain separate licenses from these 00024 * patent holders to use this software. 00025 * - Use of the software either in source or binary form, must be run 00026 * on or directly connected to an Analog Devices Inc. component. 00027 * 00028 * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR 00029 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, 00030 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 00031 * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, 00032 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00033 * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR 00034 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00035 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00036 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00037 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00038 *******************************************************************************/ 00039 #ifndef UART_H_ 00040 #define UART_H_ 00041 00042 /******************************************************************************/ 00043 /***************************** Include Files **********************************/ 00044 /******************************************************************************/ 00045 00046 #include <stdint.h> 00047 00048 /******************************************************************************/ 00049 /*************************** Types Declarations *******************************/ 00050 /******************************************************************************/ 00051 00052 /** 00053 * @struct uart_init_param 00054 * @brief Structure holding the parameters for UART initialization 00055 */ 00056 struct uart_init_param { 00057 /** UART Device ID */ 00058 uint8_t device_id; 00059 /** UART Baud Rate */ 00060 uint32_t baud_rate; 00061 /** UART extra parameters (device specific) */ 00062 void *extra; 00063 }; 00064 00065 /** 00066 * @struct uart_desc 00067 * @brief Stucture holding the UART descriptor. 00068 */ 00069 struct uart_desc { 00070 /** UART Device ID */ 00071 uint8_t device_id; 00072 /** UART Baud Rate */ 00073 uint32_t baud_rate; 00074 /** Callback to be called when an operation is done (optional) */ 00075 void (*callback)(void *callback_ctx, uint32_t event, 00076 void *extra); 00077 /** Parameter to be passed to the callback as app_param */ 00078 void *callback_ctx; 00079 /** UART extra parameters (device specific) */ 00080 void *extra; 00081 }; 00082 00083 /******************************************************************************/ 00084 /************************ Functions Declarations ******************************/ 00085 /******************************************************************************/ 00086 00087 /* Read data from UART. Blocking function */ 00088 int32_t uart_read(struct uart_desc *desc, uint8_t *data, uint32_t bytes_number); 00089 00090 /* Write data to UART. Blocking function */ 00091 int32_t uart_write(struct uart_desc *desc, const uint8_t *data, 00092 uint32_t bytes_number); 00093 00094 /* Read data from UART. Non blocking function */ 00095 int32_t uart_read_nonblocking(struct uart_desc *desc, uint8_t *data, 00096 uint32_t bytes_number); 00097 00098 /* Write data to UART. Non blocking function*/ 00099 int32_t uart_write_nonblocking(struct uart_desc *desc, const uint8_t *data, 00100 uint32_t bytes_number); 00101 00102 /* Initialize the UART communication peripheral. */ 00103 int32_t uart_init(struct uart_desc **desc, struct uart_init_param *param); 00104 00105 /* Free the resources allocated by uart_init(). */ 00106 int32_t uart_remove(struct uart_desc *desc); 00107 00108 /* Check if UART errors occurred. */ 00109 uint32_t uart_get_errors(struct uart_desc *desc); 00110 00111 #endif /* UART_H_ */
Generated on Tue Jul 12 2022 17:15:46 by
1.7.2