Mouse code for the MacroRat

Dependencies:   ITG3200 QEI

Committer:
sahilmgandhi
Date:
Sun May 14 23:18:57 2017 +0000
Revision:
18:6a4db94011d3
Publishing again

Who changed what in which revision?

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