mbed library sources. Supersedes mbed-src.

Fork of mbed by teralytic

Committer:
rodriguise
Date:
Mon Oct 17 18:47:01 2016 +0000
Revision:
148:4802eb17e82b
Parent:
147:30b64687e01f
backup

Who changed what in which revision?

UserRevisionLine numberNew contents of line
<> 144:ef7eb2e8f9f7 1 /**
<> 144:ef7eb2e8f9f7 2 ******************************************************************************
<> 144:ef7eb2e8f9f7 3 * @file char_driver.h
<> 144:ef7eb2e8f9f7 4 * @brief Defines a character driver data type.
<> 144:ef7eb2e8f9f7 5 * @internal
<> 144:ef7eb2e8f9f7 6 * @author ON Semiconductor
<> 144:ef7eb2e8f9f7 7 * $Rev: 2607 $
<> 144:ef7eb2e8f9f7 8 * $Date: 2013-12-06 18:02:43 +0530 (Fri, 06 Dec 2013) $
<> 144:ef7eb2e8f9f7 9 ******************************************************************************
<> 147:30b64687e01f 10 * Copyright 2016 Semiconductor Components Industries LLC (d/b/a “ON Semiconductor”).
<> 147:30b64687e01f 11 * All rights reserved. This software and/or documentation is licensed by ON Semiconductor
<> 147:30b64687e01f 12 * under limited terms and conditions. The terms and conditions pertaining to the software
<> 147:30b64687e01f 13 * and/or documentation are available at http://www.onsemi.com/site/pdf/ONSEMI_T&C.pdf
<> 147:30b64687e01f 14 * (“ON Semiconductor Standard Terms and Conditions of Sale, Section 8 Software”) and
<> 147:30b64687e01f 15 * if applicable the software license agreement. Do not use this software and/or
<> 147:30b64687e01f 16 * documentation unless you have carefully read and you agree to the limited terms and
<> 147:30b64687e01f 17 * conditions. By using this software and/or documentation, you agree to the limited
<> 147:30b64687e01f 18 * terms and conditions.
<> 144:ef7eb2e8f9f7 19 *
<> 144:ef7eb2e8f9f7 20 * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
<> 144:ef7eb2e8f9f7 21 * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
<> 144:ef7eb2e8f9f7 22 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
<> 144:ef7eb2e8f9f7 23 * ON SEMICONDUCTOR SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL,
<> 144:ef7eb2e8f9f7 24 * INCIDENTAL, OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
<> 144:ef7eb2e8f9f7 25 * @endinternal
<> 144:ef7eb2e8f9f7 26 *
<> 144:ef7eb2e8f9f7 27 * @details
<> 144:ef7eb2e8f9f7 28 * The character driver is intended for devices that allow read and write
<> 144:ef7eb2e8f9f7 29 * operations with "streams" of data, such as UART devices, SPI or I2c, etc.
<> 144:ef7eb2e8f9f7 30 *
<> 144:ef7eb2e8f9f7 31 * The character driver derives from the generic driver template (see driver.h).
<> 144:ef7eb2e8f9f7 32 * It does so by including an element of the generic driver_t type.
<> 144:ef7eb2e8f9f7 33 *
<> 144:ef7eb2e8f9f7 34 * The driver defines blocking and non-blocking read and write operations. It is
<> 144:ef7eb2e8f9f7 35 * up to the driver implementation to decide which of these to actually implement.
<> 144:ef7eb2e8f9f7 36 *
<> 144:ef7eb2e8f9f7 37 * @ingroup char_drivers
<> 144:ef7eb2e8f9f7 38 */
<> 144:ef7eb2e8f9f7 39
<> 144:ef7eb2e8f9f7 40 #ifndef CHAR_DRIVER_H_
<> 144:ef7eb2e8f9f7 41 #define CHAR_DRIVER_H_
<> 144:ef7eb2e8f9f7 42
<> 144:ef7eb2e8f9f7 43 #include "driver.h"
<> 144:ef7eb2e8f9f7 44
<> 144:ef7eb2e8f9f7 45 #define DRV_NO_ERROR (True)
<> 144:ef7eb2e8f9f7 46 #define DRV_ERROR (False)
<> 144:ef7eb2e8f9f7 47
<> 144:ef7eb2e8f9f7 48 /** A character driver structure. */
<> 144:ef7eb2e8f9f7 49 typedef struct char_driver {
<> 144:ef7eb2e8f9f7 50 /** The parent generic driver. */
<> 144:ef7eb2e8f9f7 51 driver_t driver;
<> 144:ef7eb2e8f9f7 52
<> 144:ef7eb2e8f9f7 53 /** Blocking read into a buffer.
<> 144:ef7eb2e8f9f7 54 * @param device The device to read from.
<> 144:ef7eb2e8f9f7 55 * @param buf The buffer to read into.
<> 144:ef7eb2e8f9f7 56 * @param len The number of bytes to read.
<> 144:ef7eb2e8f9f7 57 */
<> 144:ef7eb2e8f9f7 58 uint8_t (*read_b)(device_pt device, uint8_t *const buf, uint32_t len);
<> 144:ef7eb2e8f9f7 59
<> 144:ef7eb2e8f9f7 60 /** Non-blocking read into a buffer.
<> 144:ef7eb2e8f9f7 61 * @param device The device to read from.
<> 144:ef7eb2e8f9f7 62 * @param buf The buffer to read into.
<> 144:ef7eb2e8f9f7 63 * @param len The maximum number of bytes to read; typically the size of the buffer.
<> 144:ef7eb2e8f9f7 64 * @return The number of bytes actually read.
<> 144:ef7eb2e8f9f7 65 */
<> 144:ef7eb2e8f9f7 66 uint32_t (*read_nb)(device_pt device, uint8_t *const buf, uint32_t len);
<> 144:ef7eb2e8f9f7 67
<> 144:ef7eb2e8f9f7 68 /** Blocking write from a buffer.
<> 144:ef7eb2e8f9f7 69 * @param device The device to write to.
<> 144:ef7eb2e8f9f7 70 * @param buf The buffer to read from.
<> 144:ef7eb2e8f9f7 71 * @param len The number of bytes to write; typically the size of the buffer.
<> 144:ef7eb2e8f9f7 72 * @return success or error message
<> 144:ef7eb2e8f9f7 73 */
<> 144:ef7eb2e8f9f7 74 uint8_t (*write_b)(device_pt device, const uint8_t *buf, uint32_t len);
<> 144:ef7eb2e8f9f7 75
<> 144:ef7eb2e8f9f7 76 /** Non-blocking write from a buffer.
<> 144:ef7eb2e8f9f7 77 * @param device The device to write to.
<> 144:ef7eb2e8f9f7 78 * @param buf The buffer to read from.
<> 144:ef7eb2e8f9f7 79 * @param len The number of bytes to write; typically the size of the buffer.
<> 144:ef7eb2e8f9f7 80 * @return success or error message
<> 144:ef7eb2e8f9f7 81 */
<> 144:ef7eb2e8f9f7 82 uint8_t (*write_nb)(device_pt device, const uint8_t *buf, uint32_t len);
<> 144:ef7eb2e8f9f7 83 } char_driver_t, *char_driver_pt;
<> 144:ef7eb2e8f9f7 84
<> 144:ef7eb2e8f9f7 85 #endif /* CHAR_DRIVER_H_ */