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.

Committer:
AnnaBridge
Date:
Wed Feb 20 20:53:29 2019 +0000
Revision:
172:65be27845400
Parent:
171:3a7713b1edbc
mbed library release version 165

Who changed what in which revision?

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