Fork of my MQTTGateway

Dependencies:   mbed-http

Committer:
vpcola
Date:
Sat Apr 08 14:45:51 2017 +0000
Revision:
0:f1d3878b8dd9
Initial commit

Who changed what in which revision?

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