mbed library for STMicroelectronics' X-NUCLEO-IKA01A1 expansion board.

Dependents:   HelloWorld_IKA01A1

Fork of X_NUCLEO_IKA01A1 by ST Expansion SW Team

Library for STMicroelectronics' X-NUCLEO-IKA01A1 multifunctional expansion board based on operational amplifiers.

Committer:
hemddabral
Date:
Wed Mar 02 12:58:02 2016 +0000
Revision:
2:19d1dcef0c0e
Child:
13:9cecc8d66cc1
First draft version using STM32COO utility

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hemddabral 2:19d1dcef0c0e 1 /**
hemddabral 2:19d1dcef0c0e 2 ******************************************************************************
hemddabral 2:19d1dcef0c0e 3 * @file x_nucleo_ika01a1_class.cpp
hemddabral 2:19d1dcef0c0e 4 * @author AST / Software Platforms and Cloud
hemddabral 2:19d1dcef0c0e 5 * @version V1.0
hemddabral 2:19d1dcef0c0e 6 * @date October 1st, 2015
hemddabral 2:19d1dcef0c0e 7 * @brief Implementation file for the X_NUCLEO_IKA01A1 expansion board.
hemddabral 2:19d1dcef0c0e 8 ******************************************************************************
hemddabral 2:19d1dcef0c0e 9 * @attention
hemddabral 2:19d1dcef0c0e 10 *
hemddabral 2:19d1dcef0c0e 11 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
hemddabral 2:19d1dcef0c0e 12 *
hemddabral 2:19d1dcef0c0e 13 * Redistribution and use in source and binary forms, with or without modification,
hemddabral 2:19d1dcef0c0e 14 * are permitted provided that the following conditions are met:
hemddabral 2:19d1dcef0c0e 15 * 1. Redistributions of source code must retain the above copyright notice,
hemddabral 2:19d1dcef0c0e 16 * this list of conditions and the following disclaimer.
hemddabral 2:19d1dcef0c0e 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
hemddabral 2:19d1dcef0c0e 18 * this list of conditions and the following disclaimer in the documentation
hemddabral 2:19d1dcef0c0e 19 * and/or other materials provided with the distribution.
hemddabral 2:19d1dcef0c0e 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
hemddabral 2:19d1dcef0c0e 21 * may be used to endorse or promote products derived from this software
hemddabral 2:19d1dcef0c0e 22 * without specific prior written permission.
hemddabral 2:19d1dcef0c0e 23 *
hemddabral 2:19d1dcef0c0e 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
hemddabral 2:19d1dcef0c0e 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
hemddabral 2:19d1dcef0c0e 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
hemddabral 2:19d1dcef0c0e 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
hemddabral 2:19d1dcef0c0e 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
hemddabral 2:19d1dcef0c0e 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
hemddabral 2:19d1dcef0c0e 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
hemddabral 2:19d1dcef0c0e 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
hemddabral 2:19d1dcef0c0e 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
hemddabral 2:19d1dcef0c0e 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
hemddabral 2:19d1dcef0c0e 34 *
hemddabral 2:19d1dcef0c0e 35 ******************************************************************************
hemddabral 2:19d1dcef0c0e 36 */
hemddabral 2:19d1dcef0c0e 37
hemddabral 2:19d1dcef0c0e 38
hemddabral 2:19d1dcef0c0e 39 /* Generated with STM32CubeTOO -----------------------------------------------*/
hemddabral 2:19d1dcef0c0e 40
hemddabral 2:19d1dcef0c0e 41
hemddabral 2:19d1dcef0c0e 42 /* Includes ------------------------------------------------------------------*/
hemddabral 2:19d1dcef0c0e 43
hemddabral 2:19d1dcef0c0e 44 /* ACTION 1 ------------------------------------------------------------------*
hemddabral 2:19d1dcef0c0e 45 * Include here platform specific header files. *
hemddabral 2:19d1dcef0c0e 46 *----------------------------------------------------------------------------*/
hemddabral 2:19d1dcef0c0e 47 #include "mbed.h"
hemddabral 2:19d1dcef0c0e 48 /* ACTION 2 ------------------------------------------------------------------*
hemddabral 2:19d1dcef0c0e 49 * Include here expansion board specific header files. *
hemddabral 2:19d1dcef0c0e 50 *----------------------------------------------------------------------------*/
hemddabral 2:19d1dcef0c0e 51 #include "x_nucleo_ika01a1_class.h"
hemddabral 2:19d1dcef0c0e 52
hemddabral 2:19d1dcef0c0e 53
hemddabral 2:19d1dcef0c0e 54 /* Variables -----------------------------------------------------------------*/
hemddabral 2:19d1dcef0c0e 55
hemddabral 2:19d1dcef0c0e 56 /* Singleton instance of X_NUCLEO_IKA01A1 class. */
hemddabral 2:19d1dcef0c0e 57 X_NUCLEO_IKA01A1 *X_NUCLEO_IKA01A1::_instance;
hemddabral 2:19d1dcef0c0e 58
hemddabral 2:19d1dcef0c0e 59
hemddabral 2:19d1dcef0c0e 60 /* Methods -------------------------------------------------------------------*/
hemddabral 2:19d1dcef0c0e 61
hemddabral 2:19d1dcef0c0e 62 /**
hemddabral 2:19d1dcef0c0e 63 * @brief Constructor.
hemddabral 2:19d1dcef0c0e 64 */
hemddabral 2:19d1dcef0c0e 65 X_NUCLEO_IKA01A1::X_NUCLEO_IKA01A1(void)
hemddabral 2:19d1dcef0c0e 66 {
hemddabral 2:19d1dcef0c0e 67 /* Instantiating the components. */
hemddabral 2:19d1dcef0c0e 68 /* ACTION 3 --------------------------------------------------------------*
hemddabral 2:19d1dcef0c0e 69 * Instantiate here the expansion board's components. *
hemddabral 2:19d1dcef0c0e 70 * *
hemddabral 2:19d1dcef0c0e 71 * Example: *
hemddabral 2:19d1dcef0c0e 72 * component_1 = new COMPONENT_1(); *
hemddabral 2:19d1dcef0c0e 73 * component_2 = new COMPONENT_2(); *
hemddabral 2:19d1dcef0c0e 74 *------------------------------------------------------------------------*/
hemddabral 2:19d1dcef0c0e 75 tsz124 = new TSZ124();
hemddabral 2:19d1dcef0c0e 76 tsu104 = new TSU104();
hemddabral 2:19d1dcef0c0e 77 tsv734 = new TSV734();
hemddabral 2:19d1dcef0c0e 78 }
hemddabral 2:19d1dcef0c0e 79
hemddabral 2:19d1dcef0c0e 80 /**
hemddabral 2:19d1dcef0c0e 81 * @brief Getting a singleton instance of X_NUCLEO_IKA01A1 class.
hemddabral 2:19d1dcef0c0e 82 * @retval a singleton instance of X_NUCLEO_IKA01A1 class.
hemddabral 2:19d1dcef0c0e 83 */
hemddabral 2:19d1dcef0c0e 84 X_NUCLEO_IKA01A1 *X_NUCLEO_IKA01A1::Instance(void)
hemddabral 2:19d1dcef0c0e 85 {
hemddabral 2:19d1dcef0c0e 86 if (_instance == NULL)
hemddabral 2:19d1dcef0c0e 87 {
hemddabral 2:19d1dcef0c0e 88 /* Instantiating the board. */
hemddabral 2:19d1dcef0c0e 89 _instance = new X_NUCLEO_IKA01A1();
hemddabral 2:19d1dcef0c0e 90
hemddabral 2:19d1dcef0c0e 91 /* Initializing the components. */
hemddabral 2:19d1dcef0c0e 92 if (!_instance->Init())
hemddabral 2:19d1dcef0c0e 93 error("Initialization of the X_NUCLEO_IKA01A1 expansion board failed.\n");
hemddabral 2:19d1dcef0c0e 94 }
hemddabral 2:19d1dcef0c0e 95
hemddabral 2:19d1dcef0c0e 96 return _instance;
hemddabral 2:19d1dcef0c0e 97 }
hemddabral 2:19d1dcef0c0e 98
hemddabral 2:19d1dcef0c0e 99 /**
hemddabral 2:19d1dcef0c0e 100 * @brief Initializing the X_NUCLEO_IKA01A1 board.
hemddabral 2:19d1dcef0c0e 101 * @retval true if initialization is successful, false otherwise.
hemddabral 2:19d1dcef0c0e 102 */
hemddabral 2:19d1dcef0c0e 103 bool X_NUCLEO_IKA01A1::Init(void)
hemddabral 2:19d1dcef0c0e 104 {
hemddabral 2:19d1dcef0c0e 105 /* Initializing the components. */
hemddabral 2:19d1dcef0c0e 106 /* ACTION 4 --------------------------------------------------------------*
hemddabral 2:19d1dcef0c0e 107 * Initialize here the expansion board's components. *
hemddabral 2:19d1dcef0c0e 108 * *
hemddabral 2:19d1dcef0c0e 109 * Example: *
hemddabral 2:19d1dcef0c0e 110 * return (Init_COMPONENT_1() && Init_COMPONENT_2()); *
hemddabral 2:19d1dcef0c0e 111 *------------------------------------------------------------------------*/
hemddabral 2:19d1dcef0c0e 112 //return (Init_TSZ124() && Init_TSU104() && Init_TSV734());
hemddabral 2:19d1dcef0c0e 113 return true;
hemddabral 2:19d1dcef0c0e 114 }
hemddabral 2:19d1dcef0c0e 115
hemddabral 2:19d1dcef0c0e 116 /* ACTION 5 ------------------------------------------------------------------*
hemddabral 2:19d1dcef0c0e 117 * Implement here an initialization method for each expansion board's *
hemddabral 2:19d1dcef0c0e 118 * component. *
hemddabral 2:19d1dcef0c0e 119 * *
hemddabral 2:19d1dcef0c0e 120 * Example: *
hemddabral 2:19d1dcef0c0e 121 * bool EXPANSION_BOARD::Init_COMPONENT_1(void) *
hemddabral 2:19d1dcef0c0e 122 * { *
hemddabral 2:19d1dcef0c0e 123 * // Verifying identity. *
hemddabral 2:19d1dcef0c0e 124 * uint8_t id = 0; *
hemddabral 2:19d1dcef0c0e 125 * int ret = component_1->ReadID(&id); *
hemddabral 2:19d1dcef0c0e 126 * if ((ret != COMPONENT_OK) || (id != I_AM_COMPONENT_1)) *
hemddabral 2:19d1dcef0c0e 127 * { *
hemddabral 2:19d1dcef0c0e 128 * delete component_1; *
hemddabral 2:19d1dcef0c0e 129 * component_1 = NULL; *
hemddabral 2:19d1dcef0c0e 130 * return true; *
hemddabral 2:19d1dcef0c0e 131 * } *
hemddabral 2:19d1dcef0c0e 132 * *
hemddabral 2:19d1dcef0c0e 133 * // Configuration. *
hemddabral 2:19d1dcef0c0e 134 * COMPONENT_Init_t InitStructure; *
hemddabral 2:19d1dcef0c0e 135 * InitStructure.Property_1 = COMPONENT_1_PROPERY_1_INIT; *
hemddabral 2:19d1dcef0c0e 136 * InitStructure.Property_N = COMPONENT_1_PROPERY_N_INIT; *
hemddabral 2:19d1dcef0c0e 137 * *
hemddabral 2:19d1dcef0c0e 138 * // Initialization. *
hemddabral 2:19d1dcef0c0e 139 * if (component_1->Init(&InitStructure) != COMPONENT_OK) *
hemddabral 2:19d1dcef0c0e 140 * return false; *
hemddabral 2:19d1dcef0c0e 141 * *
hemddabral 2:19d1dcef0c0e 142 * return true; *
hemddabral 2:19d1dcef0c0e 143 * } *
hemddabral 2:19d1dcef0c0e 144 *----------------------------------------------------------------------------*/
hemddabral 2:19d1dcef0c0e 145 /**
hemddabral 2:19d1dcef0c0e 146 * @brief Initialize the TSZ124 component.
hemddabral 2:19d1dcef0c0e 147 * @retval true if initialization is successful, false otherwise.
hemddabral 2:19d1dcef0c0e 148 */
hemddabral 2:19d1dcef0c0e 149 bool X_NUCLEO_IKA01A1::Init_TSZ124(void)
hemddabral 2:19d1dcef0c0e 150 {
hemddabral 2:19d1dcef0c0e 151 /* Verifying identity. */
hemddabral 2:19d1dcef0c0e 152 uint8_t id = 0;
hemddabral 2:19d1dcef0c0e 153 int ret = tsz124->ReadID(&id);
hemddabral 2:19d1dcef0c0e 154 if ((ret != COMPONENT_OK) || (id != I_AM_TSZ124))
hemddabral 2:19d1dcef0c0e 155 {
hemddabral 2:19d1dcef0c0e 156 delete tsz124;
hemddabral 2:19d1dcef0c0e 157 tsz124 = NULL;
hemddabral 2:19d1dcef0c0e 158 return true;
hemddabral 2:19d1dcef0c0e 159 }
hemddabral 2:19d1dcef0c0e 160
hemddabral 2:19d1dcef0c0e 161 /* Configuration. */
hemddabral 2:19d1dcef0c0e 162 void* InitStructure = NULL;
hemddabral 2:19d1dcef0c0e 163 /* ACTION ----------------------------------------------------------------*
hemddabral 2:19d1dcef0c0e 164 * Configure here the component's initialization structure. *
hemddabral 2:19d1dcef0c0e 165 * *
hemddabral 2:19d1dcef0c0e 166 * Example: *
hemddabral 2:19d1dcef0c0e 167 * InitStructure.Property_1 = COMPONENT_PROPERY_1_INIT; *
hemddabral 2:19d1dcef0c0e 168 * InitStructure.Property_N = COMPONENT_PROPERY_N_INIT; *
hemddabral 2:19d1dcef0c0e 169 *------------------------------------------------------------------------*/
hemddabral 2:19d1dcef0c0e 170
hemddabral 2:19d1dcef0c0e 171 /* Initialization. */
hemddabral 2:19d1dcef0c0e 172 if (tsz124->Init(&InitStructure) != COMPONENT_OK)
hemddabral 2:19d1dcef0c0e 173 return false;
hemddabral 2:19d1dcef0c0e 174
hemddabral 2:19d1dcef0c0e 175 return true;
hemddabral 2:19d1dcef0c0e 176 }
hemddabral 2:19d1dcef0c0e 177
hemddabral 2:19d1dcef0c0e 178 /**
hemddabral 2:19d1dcef0c0e 179 * @brief Initialize the TSU104 component.
hemddabral 2:19d1dcef0c0e 180 * @retval true if initialization is successful, false otherwise.
hemddabral 2:19d1dcef0c0e 181 */
hemddabral 2:19d1dcef0c0e 182 bool X_NUCLEO_IKA01A1::Init_TSU104(void)
hemddabral 2:19d1dcef0c0e 183 {
hemddabral 2:19d1dcef0c0e 184 /* Verifying identity. */
hemddabral 2:19d1dcef0c0e 185 uint8_t id = 0;
hemddabral 2:19d1dcef0c0e 186 int ret = tsu104->ReadID(&id);
hemddabral 2:19d1dcef0c0e 187 if ((ret != COMPONENT_OK) || (id != I_AM_TSU104))
hemddabral 2:19d1dcef0c0e 188 {
hemddabral 2:19d1dcef0c0e 189 delete tsu104;
hemddabral 2:19d1dcef0c0e 190 tsu104 = NULL;
hemddabral 2:19d1dcef0c0e 191 return true;
hemddabral 2:19d1dcef0c0e 192 }
hemddabral 2:19d1dcef0c0e 193
hemddabral 2:19d1dcef0c0e 194 /* Configuration. */
hemddabral 2:19d1dcef0c0e 195 void* InitStructure = NULL;
hemddabral 2:19d1dcef0c0e 196 /* ACTION ----------------------------------------------------------------*
hemddabral 2:19d1dcef0c0e 197 * Configure here the component's initialization structure. *
hemddabral 2:19d1dcef0c0e 198 * *
hemddabral 2:19d1dcef0c0e 199 * Example: *
hemddabral 2:19d1dcef0c0e 200 * InitStructure.Property_1 = COMPONENT_PROPERY_1_INIT; *
hemddabral 2:19d1dcef0c0e 201 * InitStructure.Property_N = COMPONENT_PROPERY_N_INIT; *
hemddabral 2:19d1dcef0c0e 202 *------------------------------------------------------------------------*/
hemddabral 2:19d1dcef0c0e 203
hemddabral 2:19d1dcef0c0e 204 /* Initialization. */
hemddabral 2:19d1dcef0c0e 205 if (tsu104->Init(&InitStructure) != COMPONENT_OK)
hemddabral 2:19d1dcef0c0e 206 return false;
hemddabral 2:19d1dcef0c0e 207
hemddabral 2:19d1dcef0c0e 208 return true;
hemddabral 2:19d1dcef0c0e 209 }
hemddabral 2:19d1dcef0c0e 210
hemddabral 2:19d1dcef0c0e 211 /**
hemddabral 2:19d1dcef0c0e 212 * @brief Initialize the TSV734 component.
hemddabral 2:19d1dcef0c0e 213 * @retval true if initialization is successful, false otherwise.
hemddabral 2:19d1dcef0c0e 214 */
hemddabral 2:19d1dcef0c0e 215 bool X_NUCLEO_IKA01A1::Init_TSV734(void)
hemddabral 2:19d1dcef0c0e 216 {
hemddabral 2:19d1dcef0c0e 217 /* Verifying identity. */
hemddabral 2:19d1dcef0c0e 218 uint8_t id = 0;
hemddabral 2:19d1dcef0c0e 219 int ret = tsv734->ReadID(&id);
hemddabral 2:19d1dcef0c0e 220 if ((ret != COMPONENT_OK) || (id != I_AM_TSV734))
hemddabral 2:19d1dcef0c0e 221 {
hemddabral 2:19d1dcef0c0e 222 delete tsv734;
hemddabral 2:19d1dcef0c0e 223 tsv734 = NULL;
hemddabral 2:19d1dcef0c0e 224 return true;
hemddabral 2:19d1dcef0c0e 225 }
hemddabral 2:19d1dcef0c0e 226
hemddabral 2:19d1dcef0c0e 227 /* Configuration. */
hemddabral 2:19d1dcef0c0e 228 void* InitStructure = NULL;
hemddabral 2:19d1dcef0c0e 229 /* ACTION ----------------------------------------------------------------*
hemddabral 2:19d1dcef0c0e 230 * Configure here the component's initialization structure. *
hemddabral 2:19d1dcef0c0e 231 * *
hemddabral 2:19d1dcef0c0e 232 * Example: *
hemddabral 2:19d1dcef0c0e 233 * InitStructure.Property_1 = COMPONENT_PROPERY_1_INIT; *
hemddabral 2:19d1dcef0c0e 234 * InitStructure.Property_N = COMPONENT_PROPERY_N_INIT; *
hemddabral 2:19d1dcef0c0e 235 *------------------------------------------------------------------------*/
hemddabral 2:19d1dcef0c0e 236
hemddabral 2:19d1dcef0c0e 237 /* Initialization. */
hemddabral 2:19d1dcef0c0e 238 if (tsv734->Init(&InitStructure) != COMPONENT_OK)
hemddabral 2:19d1dcef0c0e 239 return false;
hemddabral 2:19d1dcef0c0e 240
hemddabral 2:19d1dcef0c0e 241 return true;
hemddabral 2:19d1dcef0c0e 242 }
hemddabral 2:19d1dcef0c0e 243
hemddabral 2:19d1dcef0c0e 244 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/