Jamie Satchell
/
JSatchell_SOFT253ReferredCoursework
Finished project.
Fork of ReferredCoursework2016 by
Components/Interfaces/GenericSensor.h@48:cb18488509a5, 2015-06-08 (annotated)
- Committer:
- Wolfgang Betz
- Date:
- Mon Jun 08 17:37:59 2015 +0200
- Revision:
- 48:cb18488509a5
- Parent:
- 46:badcff0675e8
- Child:
- 50:f507d4465c31
Added important comment
Who changed what in which revision?
User | Revision | Line number | New 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>© 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 Get ID of sensor |
Wolfgang Betz |
46:badcff0675e8 | 61 | * @param[out] id Pointer to where to store the ID to |
Wolfgang Betz |
46:badcff0675e8 | 62 | * @return 0 in case of success, an error code otherwise |
Wolfgang Betz |
46:badcff0675e8 | 63 | */ |
Wolfgang Betz |
46:badcff0675e8 | 64 | virtual int ReadID(uint8_t *id) = 0; |
Wolfgang Betz |
46:badcff0675e8 | 65 | |
Wolfgang Betz |
48:cb18488509a5 | 66 | /*** betzw - TODO / NOTE: beyond code is still WIP and not confirmed yet!!! ***/ |
Wolfgang Betz |
48:cb18488509a5 | 67 | /** |
Wolfgang Betz |
48:cb18488509a5 | 68 | * @brief Enter sensor shutdown mode |
Wolfgang Betz |
48:cb18488509a5 | 69 | * @return 0 in case of success, an error code otherwise |
Wolfgang Betz |
48:cb18488509a5 | 70 | * @note not confirmed yet (WIP) |
Wolfgang Betz |
48:cb18488509a5 | 71 | */ |
Wolfgang Betz |
48:cb18488509a5 | 72 | virtual int PowerOff(void) = 0; |
Wolfgang Betz |
48:cb18488509a5 | 73 | |
Wolfgang Betz |
46:badcff0675e8 | 74 | /** |
Wolfgang Betz |
46:badcff0675e8 | 75 | * @brief Reset sensor |
Wolfgang Betz |
46:badcff0675e8 | 76 | * @return 0 in case of success, an error code otherwise |
Wolfgang Betz |
48:cb18488509a5 | 77 | * @note not confirmed yet (WIP) |
Wolfgang Betz |
46:badcff0675e8 | 78 | */ |
Wolfgang Betz |
46:badcff0675e8 | 79 | virtual int Reset(void) = 0; |
Wolfgang Betz |
46:badcff0675e8 | 80 | |
Wolfgang Betz |
46:badcff0675e8 | 81 | /* Interrupt Interface */ |
Wolfgang Betz |
46:badcff0675e8 | 82 | virtual void ConfigIT(uint16_t) = 0; |
Wolfgang Betz |
46:badcff0675e8 | 83 | virtual void EnableIT(uint8_t) = 0; |
Wolfgang Betz |
46:badcff0675e8 | 84 | virtual void DisableIT(uint8_t) = 0; |
Wolfgang Betz |
46:badcff0675e8 | 85 | virtual uint8_t ITStatus(uint16_t, uint16_t) = 0; |
Wolfgang Betz |
46:badcff0675e8 | 86 | virtual void ClearIT(uint16_t, uint16_t) = 0; |
Wolfgang Betz |
46:badcff0675e8 | 87 | |
Wolfgang Betz |
46:badcff0675e8 | 88 | /** |
Wolfgang Betz |
46:badcff0675e8 | 89 | * @brief Attach a function to be called when an interrupt occurs |
Wolfgang Betz |
46:badcff0675e8 | 90 | * @param[in] fptr A pointer to a void function, or 0 to set as none |
Wolfgang Betz |
48:cb18488509a5 | 91 | * @note not confirmed yet (WIP) |
Wolfgang Betz |
46:badcff0675e8 | 92 | */ |
Wolfgang Betz |
46:badcff0675e8 | 93 | virtual void AttachIT(void (*fptr)(void)) = 0; |
Wolfgang Betz |
46:badcff0675e8 | 94 | }; |
Wolfgang Betz |
46:badcff0675e8 | 95 | |
Wolfgang Betz |
46:badcff0675e8 | 96 | #endif /* __GENERIC_SENSOR_CLASS_H */ |