Easily add all supported connectivity methods to your mbed OS project

Dependencies:   type-yd-driver

Committer:
MACRUM
Date:
Wed Jul 12 10:52:58 2017 +0000
Revision:
0:615f90842ce8
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MACRUM 0:615f90842ce8 1 /**
MACRUM 0:615f90842ce8 2 ******************************************************************************
MACRUM 0:615f90842ce8 3 * @file SPIRIT_Types.c
MACRUM 0:615f90842ce8 4 * @author VMA division - AMS
MACRUM 0:615f90842ce8 5 * @version 3.2.2
MACRUM 0:615f90842ce8 6 * @date 08-July-2015
MACRUM 0:615f90842ce8 7 * @brief File for SPIRIT types.
MACRUM 0:615f90842ce8 8 * @details
MACRUM 0:615f90842ce8 9 *
MACRUM 0:615f90842ce8 10 * @attention
MACRUM 0:615f90842ce8 11 *
MACRUM 0:615f90842ce8 12 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
MACRUM 0:615f90842ce8 13 *
MACRUM 0:615f90842ce8 14 * Redistribution and use in source and binary forms, with or without modification,
MACRUM 0:615f90842ce8 15 * are permitted provided that the following conditions are met:
MACRUM 0:615f90842ce8 16 * 1. Redistributions of source code must retain the above copyright notice,
MACRUM 0:615f90842ce8 17 * this list of conditions and the following disclaimer.
MACRUM 0:615f90842ce8 18 * 2. Redistributions in binary form must reproduce the above copyright notice,
MACRUM 0:615f90842ce8 19 * this list of conditions and the following disclaimer in the documentation
MACRUM 0:615f90842ce8 20 * and/or other materials provided with the distribution.
MACRUM 0:615f90842ce8 21 * 3. Neither the name of STMicroelectronics nor the names of its contributors
MACRUM 0:615f90842ce8 22 * may be used to endorse or promote products derived from this software
MACRUM 0:615f90842ce8 23 * without specific prior written permission.
MACRUM 0:615f90842ce8 24 *
MACRUM 0:615f90842ce8 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
MACRUM 0:615f90842ce8 26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
MACRUM 0:615f90842ce8 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
MACRUM 0:615f90842ce8 28 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
MACRUM 0:615f90842ce8 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
MACRUM 0:615f90842ce8 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
MACRUM 0:615f90842ce8 31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
MACRUM 0:615f90842ce8 32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
MACRUM 0:615f90842ce8 33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
MACRUM 0:615f90842ce8 34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
MACRUM 0:615f90842ce8 35 *
MACRUM 0:615f90842ce8 36 ******************************************************************************
MACRUM 0:615f90842ce8 37 */
MACRUM 0:615f90842ce8 38
MACRUM 0:615f90842ce8 39 /* Includes ------------------------------------------------------------------*/
MACRUM 0:615f90842ce8 40 #include "SPIRIT_Types.h"
MACRUM 0:615f90842ce8 41 #include "MCU_Interface.h"
MACRUM 0:615f90842ce8 42
MACRUM 0:615f90842ce8 43
MACRUM 0:615f90842ce8 44 /** @addtogroup SPIRIT_Libraries
MACRUM 0:615f90842ce8 45 * @{
MACRUM 0:615f90842ce8 46 */
MACRUM 0:615f90842ce8 47
MACRUM 0:615f90842ce8 48
MACRUM 0:615f90842ce8 49 /** @addtogroup SPIRIT_Types
MACRUM 0:615f90842ce8 50 * @{
MACRUM 0:615f90842ce8 51 */
MACRUM 0:615f90842ce8 52
MACRUM 0:615f90842ce8 53
MACRUM 0:615f90842ce8 54 /** @defgroup Types_Private_TypesDefinitions Types Private Types Definitions
MACRUM 0:615f90842ce8 55 * @{
MACRUM 0:615f90842ce8 56 */
MACRUM 0:615f90842ce8 57
MACRUM 0:615f90842ce8 58
MACRUM 0:615f90842ce8 59 /**
MACRUM 0:615f90842ce8 60 * @}
MACRUM 0:615f90842ce8 61 */
MACRUM 0:615f90842ce8 62
MACRUM 0:615f90842ce8 63
MACRUM 0:615f90842ce8 64
MACRUM 0:615f90842ce8 65 /** @defgroup Types_Private_Defines Types Private Defines
MACRUM 0:615f90842ce8 66 * @{
MACRUM 0:615f90842ce8 67 */
MACRUM 0:615f90842ce8 68
MACRUM 0:615f90842ce8 69
MACRUM 0:615f90842ce8 70 /**
MACRUM 0:615f90842ce8 71 * @}
MACRUM 0:615f90842ce8 72 */
MACRUM 0:615f90842ce8 73
MACRUM 0:615f90842ce8 74
MACRUM 0:615f90842ce8 75
MACRUM 0:615f90842ce8 76 /** @defgroup Types_Private_Macros Types Private Macros
MACRUM 0:615f90842ce8 77 * @{
MACRUM 0:615f90842ce8 78 */
MACRUM 0:615f90842ce8 79
MACRUM 0:615f90842ce8 80
MACRUM 0:615f90842ce8 81 /**
MACRUM 0:615f90842ce8 82 * @}
MACRUM 0:615f90842ce8 83 */
MACRUM 0:615f90842ce8 84
MACRUM 0:615f90842ce8 85
MACRUM 0:615f90842ce8 86
MACRUM 0:615f90842ce8 87 /** @defgroup Types_Private_Variables Types Private Variables
MACRUM 0:615f90842ce8 88 * @{
MACRUM 0:615f90842ce8 89 */
MACRUM 0:615f90842ce8 90
MACRUM 0:615f90842ce8 91 /**
MACRUM 0:615f90842ce8 92 * @brief Spirit Status global variable.
MACRUM 0:615f90842ce8 93 * This global variable of @ref SpiritStatus type is updated on every SPI transaction
MACRUM 0:615f90842ce8 94 * to maintain memory of Spirit Status.
MACRUM 0:615f90842ce8 95 */
MACRUM 0:615f90842ce8 96
MACRUM 0:615f90842ce8 97 volatile SpiritStatus g_xStatus;
MACRUM 0:615f90842ce8 98
MACRUM 0:615f90842ce8 99 /**
MACRUM 0:615f90842ce8 100 * @}
MACRUM 0:615f90842ce8 101 */
MACRUM 0:615f90842ce8 102
MACRUM 0:615f90842ce8 103
MACRUM 0:615f90842ce8 104
MACRUM 0:615f90842ce8 105 /** @defgroup Types_Private_FunctionPrototypes Types Private FunctionPrototypes
MACRUM 0:615f90842ce8 106 * @{
MACRUM 0:615f90842ce8 107 */
MACRUM 0:615f90842ce8 108
MACRUM 0:615f90842ce8 109
MACRUM 0:615f90842ce8 110
MACRUM 0:615f90842ce8 111 /**
MACRUM 0:615f90842ce8 112 * @}
MACRUM 0:615f90842ce8 113 */
MACRUM 0:615f90842ce8 114
MACRUM 0:615f90842ce8 115
MACRUM 0:615f90842ce8 116
MACRUM 0:615f90842ce8 117 /** @defgroup Types_Private_Functions Types Private Functions
MACRUM 0:615f90842ce8 118 * @{
MACRUM 0:615f90842ce8 119 */
MACRUM 0:615f90842ce8 120
MACRUM 0:615f90842ce8 121 #ifdef SPIRIT_USE_FULL_ASSERT
MACRUM 0:615f90842ce8 122 /**
MACRUM 0:615f90842ce8 123 * @brief Reports the name of the source file and the source line number
MACRUM 0:615f90842ce8 124 * where the assert_param error has occurred.
MACRUM 0:615f90842ce8 125 * @param file pointer to the source file name
MACRUM 0:615f90842ce8 126 * @param line assert_param error line source number
MACRUM 0:615f90842ce8 127 * @retval : None
MACRUM 0:615f90842ce8 128 */
MACRUM 0:615f90842ce8 129 void s_assert_failed(uint8_t* file, uint32_t line)
MACRUM 0:615f90842ce8 130 {
MACRUM 0:615f90842ce8 131 /* User can add his own implementation to report the file name and line number */
MACRUM 0:615f90842ce8 132 printf("Wrong parameters value: file %s on line %d\r\n", file, (int)line);
MACRUM 0:615f90842ce8 133
MACRUM 0:615f90842ce8 134 /* Infinite loop */
MACRUM 0:615f90842ce8 135 while (1)
MACRUM 0:615f90842ce8 136 {
MACRUM 0:615f90842ce8 137 }
MACRUM 0:615f90842ce8 138 }
MACRUM 0:615f90842ce8 139 #elif SPIRIT_USE_VCOM_ASSERT
MACRUM 0:615f90842ce8 140
MACRUM 0:615f90842ce8 141 #include "SDK_EVAL_VC_General.h"
MACRUM 0:615f90842ce8 142
MACRUM 0:615f90842ce8 143 /**
MACRUM 0:615f90842ce8 144 * @brief Reports the name of the source file and the source line number
MACRUM 0:615f90842ce8 145 * where the assert_param error has occurred.
MACRUM 0:615f90842ce8 146 * @param file pointer to the source file name
MACRUM 0:615f90842ce8 147 * @param line assert_param error line source number
MACRUM 0:615f90842ce8 148 * @param expression: string representing the assert failed expression
MACRUM 0:615f90842ce8 149 * @retval : None
MACRUM 0:615f90842ce8 150 */
MACRUM 0:615f90842ce8 151 void s_assert_failed(uint8_t* file, uint32_t line, char* expression)
MACRUM 0:615f90842ce8 152 {
MACRUM 0:615f90842ce8 153
MACRUM 0:615f90842ce8 154 printf("\n\rVCOM DEBUG: Incorrect parameter. Please reboot.\n\r");
MACRUM 0:615f90842ce8 155 printf("%s:%d \n\r",file,line);
MACRUM 0:615f90842ce8 156 printf("The expression %s returned FALSE.\n\r", expression);
MACRUM 0:615f90842ce8 157
MACRUM 0:615f90842ce8 158 /* Infinite loop */
MACRUM 0:615f90842ce8 159 while (1)
MACRUM 0:615f90842ce8 160 {
MACRUM 0:615f90842ce8 161 }
MACRUM 0:615f90842ce8 162 }
MACRUM 0:615f90842ce8 163
MACRUM 0:615f90842ce8 164 #elif SPIRIT_USE_FRAME_ASSERT
MACRUM 0:615f90842ce8 165
MACRUM 0:615f90842ce8 166 #include "SdkUsbProtocol.h"
MACRUM 0:615f90842ce8 167
MACRUM 0:615f90842ce8 168 /**
MACRUM 0:615f90842ce8 169 * @brief Sends a notify frame with a payload indicating the name
MACRUM 0:615f90842ce8 170 * of the assert failed.
MACRUM 0:615f90842ce8 171 * @param expression: string representing the assert failed expression
MACRUM 0:615f90842ce8 172 * @retval : None
MACRUM 0:615f90842ce8 173 */
MACRUM 0:615f90842ce8 174 void s_assert_failed(char* expression)
MACRUM 0:615f90842ce8 175 {
MACRUM 0:615f90842ce8 176 char pcPayload[100];
MACRUM 0:615f90842ce8 177 uint16_t i;
MACRUM 0:615f90842ce8 178
MACRUM 0:615f90842ce8 179 for(i = 0 ; expression[i]!='(' ; i++);
MACRUM 0:615f90842ce8 180 expression[i]='\0';
MACRUM 0:615f90842ce8 181
MACRUM 0:615f90842ce8 182 strcpy(pcPayload, &expression[3]);
MACRUM 0:615f90842ce8 183
MACRUM 0:615f90842ce8 184 //sprintf(pcPayload, "The expression %s returned FALSE.\n\r", expression);
MACRUM 0:615f90842ce8 185 SpiritNotifyAssertFailed(pcPayload);
MACRUM 0:615f90842ce8 186
MACRUM 0:615f90842ce8 187 }
MACRUM 0:615f90842ce8 188
MACRUM 0:615f90842ce8 189 #endif
MACRUM 0:615f90842ce8 190
MACRUM 0:615f90842ce8 191
MACRUM 0:615f90842ce8 192 /**
MACRUM 0:615f90842ce8 193 * @brief Updates the gState (the global variable used to maintain memory of Spirit Status)
MACRUM 0:615f90842ce8 194 * reading the MC_STATE register of SPIRIT.
MACRUM 0:615f90842ce8 195 * @param None
MACRUM 0:615f90842ce8 196 * @retval None
MACRUM 0:615f90842ce8 197 */
MACRUM 0:615f90842ce8 198 void SpiritRefreshStatus(void)
MACRUM 0:615f90842ce8 199 {
MACRUM 0:615f90842ce8 200 uint8_t tempRegValue;
MACRUM 0:615f90842ce8 201
MACRUM 0:615f90842ce8 202 /* Reads the MC_STATUS register to update the g_xStatus */
MACRUM 0:615f90842ce8 203 g_xStatus = SpiritSpiReadRegisters(MC_STATE1_BASE, 1, &tempRegValue);
MACRUM 0:615f90842ce8 204 }
MACRUM 0:615f90842ce8 205
MACRUM 0:615f90842ce8 206
MACRUM 0:615f90842ce8 207 /**
MACRUM 0:615f90842ce8 208 * @}
MACRUM 0:615f90842ce8 209 */
MACRUM 0:615f90842ce8 210
MACRUM 0:615f90842ce8 211
MACRUM 0:615f90842ce8 212
MACRUM 0:615f90842ce8 213 /**
MACRUM 0:615f90842ce8 214 * @}
MACRUM 0:615f90842ce8 215 */
MACRUM 0:615f90842ce8 216
MACRUM 0:615f90842ce8 217
MACRUM 0:615f90842ce8 218
MACRUM 0:615f90842ce8 219 /**
MACRUM 0:615f90842ce8 220 * @}
MACRUM 0:615f90842ce8 221 */
MACRUM 0:615f90842ce8 222
MACRUM 0:615f90842ce8 223
MACRUM 0:615f90842ce8 224
MACRUM 0:615f90842ce8 225 /******************* (C) COPYRIGHT 2015 STMicroelectronics *****END OF FILE****/