mbed-os

Fork of mbed-os by erkin yucel

Committer:
xuaner
Date:
Thu Jul 20 14:26:57 2017 +0000
Revision:
1:3deb71413561
Parent:
0:f269e3021894
mbed_os

Who changed what in which revision?

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