Finished project.

Dependencies:   X_NUCLEO_COMMON

Fork of ReferredCoursework2016 by Stage-1 Students SoCEM

Committer:
Wolfgang Betz
Date:
Mon Jun 08 17:22:35 2015 +0200
Revision:
46:badcff0675e8
Child:
48:cb18488509a5
Add GenericSensor interface

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Wolfgang Betz 46:badcff0675e8 1 /**
Wolfgang Betz 46:badcff0675e8 2 ******************************************************************************
Wolfgang Betz 46:badcff0675e8 3 * @file GenericSensor.h
Wolfgang Betz 46:badcff0675e8 4 * @author AST / EST
Wolfgang Betz 46:badcff0675e8 5 * @version V0.0.1
Wolfgang Betz 46:badcff0675e8 6 * @date 13-April-2015
Wolfgang Betz 46:badcff0675e8 7 * @brief This file contains the abstract class describing in general
Wolfgang Betz 46:badcff0675e8 8 * the interfaces of a generic sensor
Wolfgang Betz 46:badcff0675e8 9 ******************************************************************************
Wolfgang Betz 46:badcff0675e8 10 * @attention
Wolfgang Betz 46:badcff0675e8 11 *
Wolfgang Betz 46:badcff0675e8 12 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
Wolfgang Betz 46:badcff0675e8 13 *
Wolfgang Betz 46:badcff0675e8 14 * Redistribution and use in source and binary forms, with or without modification,
Wolfgang Betz 46:badcff0675e8 15 * are permitted provided that the following conditions are met:
Wolfgang Betz 46:badcff0675e8 16 * 1. Redistributions of source code must retain the above copyright notice,
Wolfgang Betz 46:badcff0675e8 17 * this list of conditions and the following disclaimer.
Wolfgang Betz 46:badcff0675e8 18 * 2. Redistributions in binary form must reproduce the above copyright notice,
Wolfgang Betz 46:badcff0675e8 19 * this list of conditions and the following disclaimer in the documentation
Wolfgang Betz 46:badcff0675e8 20 * and/or other materials provided with the distribution.
Wolfgang Betz 46:badcff0675e8 21 * 3. Neither the name of STMicroelectronics nor the names of its contributors
Wolfgang Betz 46:badcff0675e8 22 * may be used to endorse or promote products derived from this software
Wolfgang Betz 46:badcff0675e8 23 * without specific prior written permission.
Wolfgang Betz 46:badcff0675e8 24 *
Wolfgang Betz 46:badcff0675e8 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Wolfgang Betz 46:badcff0675e8 26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Wolfgang Betz 46:badcff0675e8 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Wolfgang Betz 46:badcff0675e8 28 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Wolfgang Betz 46:badcff0675e8 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Wolfgang Betz 46:badcff0675e8 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Wolfgang Betz 46:badcff0675e8 31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Wolfgang Betz 46:badcff0675e8 32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Wolfgang Betz 46:badcff0675e8 33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Wolfgang Betz 46:badcff0675e8 34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Wolfgang Betz 46:badcff0675e8 35 *
Wolfgang Betz 46:badcff0675e8 36 ******************************************************************************
Wolfgang Betz 46:badcff0675e8 37 */
Wolfgang Betz 46:badcff0675e8 38
Wolfgang Betz 46:badcff0675e8 39 /* Define to prevent from recursive inclusion --------------------------------*/
Wolfgang Betz 46:badcff0675e8 40 #ifndef __GENERIC_SENSOR_CLASS_H
Wolfgang Betz 46:badcff0675e8 41 #define __GENERIC_SENSOR_CLASS_H
Wolfgang Betz 46:badcff0675e8 42
Wolfgang Betz 46:badcff0675e8 43 /* Includes ------------------------------------------------------------------*/
Wolfgang Betz 46:badcff0675e8 44 #include <stdint.h>
Wolfgang Betz 46:badcff0675e8 45
Wolfgang Betz 46:badcff0675e8 46 /* Classes ------------------------------------------------------------------*/
Wolfgang Betz 46:badcff0675e8 47 /** An abstract class for Generic sensors
Wolfgang Betz 46:badcff0675e8 48 */
Wolfgang Betz 46:badcff0675e8 49 class GenericSensor
Wolfgang Betz 46:badcff0675e8 50 {
Wolfgang Betz 46:badcff0675e8 51 public:
Wolfgang Betz 46:badcff0675e8 52 /**
Wolfgang Betz 46:badcff0675e8 53 * @brief Initialization of sensor
Wolfgang Betz 46:badcff0675e8 54 * @param[out] ptr Pointer to device specific initalization structure
Wolfgang Betz 46:badcff0675e8 55 * @return 0 in case of success, an error code otherwise
Wolfgang Betz 46:badcff0675e8 56 */
Wolfgang Betz 46:badcff0675e8 57 virtual int Init(void *ptr) = 0;
Wolfgang Betz 46:badcff0675e8 58
Wolfgang Betz 46:badcff0675e8 59 /**
Wolfgang Betz 46:badcff0675e8 60 * @brief Enter sensor shutdown mode
Wolfgang Betz 46:badcff0675e8 61 * @return 0 in case of success, an error code otherwise
Wolfgang Betz 46:badcff0675e8 62 */
Wolfgang Betz 46:badcff0675e8 63 virtual int PowerOff(void) = 0;
Wolfgang Betz 46:badcff0675e8 64
Wolfgang Betz 46:badcff0675e8 65 /**
Wolfgang Betz 46:badcff0675e8 66 * @brief Get ID of sensor
Wolfgang Betz 46:badcff0675e8 67 * @param[out] id Pointer to where to store the ID to
Wolfgang Betz 46:badcff0675e8 68 * @return 0 in case of success, an error code otherwise
Wolfgang Betz 46:badcff0675e8 69 */
Wolfgang Betz 46:badcff0675e8 70 virtual int ReadID(uint8_t *id) = 0;
Wolfgang Betz 46:badcff0675e8 71
Wolfgang Betz 46:badcff0675e8 72 /**
Wolfgang Betz 46:badcff0675e8 73 * @brief Reset sensor
Wolfgang Betz 46:badcff0675e8 74 * @return 0 in case of success, an error code otherwise
Wolfgang Betz 46:badcff0675e8 75 */
Wolfgang Betz 46:badcff0675e8 76 virtual int Reset(void) = 0;
Wolfgang Betz 46:badcff0675e8 77
Wolfgang Betz 46:badcff0675e8 78 /* Interrupt Interface */
Wolfgang Betz 46:badcff0675e8 79 /* betzw - TODO: WIP */
Wolfgang Betz 46:badcff0675e8 80 virtual void ConfigIT(uint16_t) = 0;
Wolfgang Betz 46:badcff0675e8 81 virtual void EnableIT(uint8_t) = 0;
Wolfgang Betz 46:badcff0675e8 82 virtual void DisableIT(uint8_t) = 0;
Wolfgang Betz 46:badcff0675e8 83 virtual uint8_t ITStatus(uint16_t, uint16_t) = 0;
Wolfgang Betz 46:badcff0675e8 84 virtual void ClearIT(uint16_t, uint16_t) = 0;
Wolfgang Betz 46:badcff0675e8 85
Wolfgang Betz 46:badcff0675e8 86 /**
Wolfgang Betz 46:badcff0675e8 87 * @brief Attach a function to be called when an interrupt occurs
Wolfgang Betz 46:badcff0675e8 88 * @param[in] fptr A pointer to a void function, or 0 to set as none
Wolfgang Betz 46:badcff0675e8 89 */
Wolfgang Betz 46:badcff0675e8 90 virtual void AttachIT(void (*fptr)(void)) = 0;
Wolfgang Betz 46:badcff0675e8 91 };
Wolfgang Betz 46:badcff0675e8 92
Wolfgang Betz 46:badcff0675e8 93 #endif /* __GENERIC_SENSOR_CLASS_H */