mbed w/ spi bug fig

Dependents:   display-puck

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Thu May 22 20:00:09 2014 +0100
Revision:
205:c41fc65bcfb4
Child:
218:44081b78fdc2
Synchronized with git revision ea4b6f76efab17a3f7d7777b0cc1ef05fec6d1cb

Full URL: https://github.com/mbedmicro/mbed/commit/ea4b6f76efab17a3f7d7777b0cc1ef05fec6d1cb/

[NUCLEO_F072RB] cmsis files

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 205:c41fc65bcfb4 1 /**
mbed_official 205:c41fc65bcfb4 2 ******************************************************************************
mbed_official 205:c41fc65bcfb4 3 * @file stm32f0xx_hal_cec.c
mbed_official 205:c41fc65bcfb4 4 * @author MCD Application Team
mbed_official 205:c41fc65bcfb4 5 * @version V1.0.0
mbed_official 205:c41fc65bcfb4 6 * @date 20-May-2014
mbed_official 205:c41fc65bcfb4 7 * @brief CEC HAL module driver.
mbed_official 205:c41fc65bcfb4 8 *
mbed_official 205:c41fc65bcfb4 9 * This file provides firmware functions to manage the following
mbed_official 205:c41fc65bcfb4 10 * functionalities of the High Definition Multimedia Interface
mbed_official 205:c41fc65bcfb4 11 * Consumer Electronics Control Peripheral (CEC).
mbed_official 205:c41fc65bcfb4 12 * + Initialization and de-initialization function
mbed_official 205:c41fc65bcfb4 13 * + IO operation function
mbed_official 205:c41fc65bcfb4 14 * + Peripheral Control function
mbed_official 205:c41fc65bcfb4 15 *
mbed_official 205:c41fc65bcfb4 16 *
mbed_official 205:c41fc65bcfb4 17 @verbatim
mbed_official 205:c41fc65bcfb4 18 ===============================================================================
mbed_official 205:c41fc65bcfb4 19 ##### How to use this driver #####
mbed_official 205:c41fc65bcfb4 20 ===============================================================================
mbed_official 205:c41fc65bcfb4 21 [..]
mbed_official 205:c41fc65bcfb4 22 The CEC HAL driver can be used as follows:
mbed_official 205:c41fc65bcfb4 23
mbed_official 205:c41fc65bcfb4 24 (#) Declare a CEC_HandleTypeDef handle structure.
mbed_official 205:c41fc65bcfb4 25 (#) Initialize the CEC low level resources by implementing the HAL_CEC_MspInit ()API:
mbed_official 205:c41fc65bcfb4 26 (##) Enable the CEC interface clock.
mbed_official 205:c41fc65bcfb4 27 (##) CEC pins configuration:
mbed_official 205:c41fc65bcfb4 28 (+) Enable the clock for the CEC GPIOs.
mbed_official 205:c41fc65bcfb4 29 (+) Configure these CEC pins as alternate function pull-up.
mbed_official 205:c41fc65bcfb4 30 (##) NVIC configuration if you need to use interrupt process (HAL_CEC_Transmit_IT()
mbed_official 205:c41fc65bcfb4 31 and HAL_CEC_Receive_IT() APIs):
mbed_official 205:c41fc65bcfb4 32 (+) Configure the CEC interrupt priority.
mbed_official 205:c41fc65bcfb4 33 (+) Enable the NVIC CEC IRQ handle.
mbed_official 205:c41fc65bcfb4 34 (@) The specific CEC interrupts (Transmission complete interrupt,
mbed_official 205:c41fc65bcfb4 35 RXNE interrupt and Error Interrupts) will be managed using the macros
mbed_official 205:c41fc65bcfb4 36 __HAL_CEC_ENABLE_IT() and __HAL_CEC_DISABLE_IT() inside the transmit
mbed_official 205:c41fc65bcfb4 37 and receive process.
mbed_official 205:c41fc65bcfb4 38
mbed_official 205:c41fc65bcfb4 39 (#) Program the Signal Free Time (SFT) and SFT option, Tolerance, reception stop in
mbed_official 205:c41fc65bcfb4 40 in case of Bit Rising Error, Error-Bit generation conditions, device logical
mbed_official 205:c41fc65bcfb4 41 address and Listen mode in the hcec Init structure.
mbed_official 205:c41fc65bcfb4 42
mbed_official 205:c41fc65bcfb4 43 (#) Initialize the CEC registers by calling the HAL_CEC_Init() API.
mbed_official 205:c41fc65bcfb4 44
mbed_official 205:c41fc65bcfb4 45 (@) This API (HAL_CEC_Init()) configures also the low level Hardware GPIO, CLOCK, CORTEX...etc)
mbed_official 205:c41fc65bcfb4 46 by calling the customed HAL_CEC_MspInit() API.
mbed_official 205:c41fc65bcfb4 47
mbed_official 205:c41fc65bcfb4 48 @endverbatim
mbed_official 205:c41fc65bcfb4 49 ******************************************************************************
mbed_official 205:c41fc65bcfb4 50 * @attention
mbed_official 205:c41fc65bcfb4 51 *
mbed_official 205:c41fc65bcfb4 52 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
mbed_official 205:c41fc65bcfb4 53 *
mbed_official 205:c41fc65bcfb4 54 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 205:c41fc65bcfb4 55 * are permitted provided that the following conditions are met:
mbed_official 205:c41fc65bcfb4 56 * 1. Redistributions of source code must retain the above copyright notice,
mbed_official 205:c41fc65bcfb4 57 * this list of conditions and the following disclaimer.
mbed_official 205:c41fc65bcfb4 58 * 2. Redistributions in binary form must reproduce the above copyright notice,
mbed_official 205:c41fc65bcfb4 59 * this list of conditions and the following disclaimer in the documentation
mbed_official 205:c41fc65bcfb4 60 * and/or other materials provided with the distribution.
mbed_official 205:c41fc65bcfb4 61 * 3. Neither the name of STMicroelectronics nor the names of its contributors
mbed_official 205:c41fc65bcfb4 62 * may be used to endorse or promote products derived from this software
mbed_official 205:c41fc65bcfb4 63 * without specific prior written permission.
mbed_official 205:c41fc65bcfb4 64 *
mbed_official 205:c41fc65bcfb4 65 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
mbed_official 205:c41fc65bcfb4 66 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
mbed_official 205:c41fc65bcfb4 67 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 205:c41fc65bcfb4 68 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
mbed_official 205:c41fc65bcfb4 69 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
mbed_official 205:c41fc65bcfb4 70 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
mbed_official 205:c41fc65bcfb4 71 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
mbed_official 205:c41fc65bcfb4 72 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
mbed_official 205:c41fc65bcfb4 73 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
mbed_official 205:c41fc65bcfb4 74 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 205:c41fc65bcfb4 75 *
mbed_official 205:c41fc65bcfb4 76 ******************************************************************************
mbed_official 205:c41fc65bcfb4 77 */
mbed_official 205:c41fc65bcfb4 78
mbed_official 205:c41fc65bcfb4 79 /* Includes ------------------------------------------------------------------*/
mbed_official 205:c41fc65bcfb4 80 #include "stm32f0xx_hal.h"
mbed_official 205:c41fc65bcfb4 81
mbed_official 205:c41fc65bcfb4 82 /** @addtogroup STM32F0xx_HAL_Driver
mbed_official 205:c41fc65bcfb4 83 * @{
mbed_official 205:c41fc65bcfb4 84 */
mbed_official 205:c41fc65bcfb4 85
mbed_official 205:c41fc65bcfb4 86 /** @defgroup CEC
mbed_official 205:c41fc65bcfb4 87 * @brief HAL CEC module driver
mbed_official 205:c41fc65bcfb4 88 * @{
mbed_official 205:c41fc65bcfb4 89 */
mbed_official 205:c41fc65bcfb4 90 #ifdef HAL_CEC_MODULE_ENABLED
mbed_official 205:c41fc65bcfb4 91
mbed_official 205:c41fc65bcfb4 92 #if defined(STM32F042x6) || defined(STM32F048xx) ||\
mbed_official 205:c41fc65bcfb4 93 defined(STM32F051x8) || defined(STM32F058xx) ||\
mbed_official 205:c41fc65bcfb4 94 defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx)
mbed_official 205:c41fc65bcfb4 95
mbed_official 205:c41fc65bcfb4 96 /* Private typedef -----------------------------------------------------------*/
mbed_official 205:c41fc65bcfb4 97 /* Private define ------------------------------------------------------------*/
mbed_official 205:c41fc65bcfb4 98 #define CEC_CFGR_FIELDS (CEC_CFGR_SFT | CEC_CFGR_RXTOL | CEC_CFGR_BRESTP \
mbed_official 205:c41fc65bcfb4 99 | CEC_CFGR_BREGEN | CEC_CFGR_LBPEGEN | CEC_CFGR_SFTOPT \
mbed_official 205:c41fc65bcfb4 100 | CEC_CFGR_BRDNOGEN | CEC_CFGR_OAR | CEC_CFGR_LSTN)
mbed_official 205:c41fc65bcfb4 101 /* Private macro -------------------------------------------------------------*/
mbed_official 205:c41fc65bcfb4 102 /* Private variables ---------------------------------------------------------*/
mbed_official 205:c41fc65bcfb4 103 /* Private function prototypes -----------------------------------------------*/
mbed_official 205:c41fc65bcfb4 104 static HAL_StatusTypeDef CEC_Transmit_IT(CEC_HandleTypeDef *hcec);
mbed_official 205:c41fc65bcfb4 105 static HAL_StatusTypeDef CEC_Receive_IT(CEC_HandleTypeDef *hcec);
mbed_official 205:c41fc65bcfb4 106 /* Private functions ---------------------------------------------------------*/
mbed_official 205:c41fc65bcfb4 107
mbed_official 205:c41fc65bcfb4 108 /** @defgroup CEC_Private_Functions
mbed_official 205:c41fc65bcfb4 109 * @{
mbed_official 205:c41fc65bcfb4 110 */
mbed_official 205:c41fc65bcfb4 111
mbed_official 205:c41fc65bcfb4 112 /** @defgroup HAL_CEC_Group1 Initialization/de-initialization function
mbed_official 205:c41fc65bcfb4 113 * @brief Initialization and Configuration functions
mbed_official 205:c41fc65bcfb4 114 *
mbed_official 205:c41fc65bcfb4 115 @verbatim
mbed_official 205:c41fc65bcfb4 116 ===============================================================================
mbed_official 205:c41fc65bcfb4 117 ##### Initialization and Configuration functions #####
mbed_official 205:c41fc65bcfb4 118 ===============================================================================
mbed_official 205:c41fc65bcfb4 119 [..]
mbed_official 205:c41fc65bcfb4 120 This subsection provides a set of functions allowing to initialize the CEC
mbed_official 205:c41fc65bcfb4 121 (+) The following parameters need to be configured:
mbed_official 205:c41fc65bcfb4 122 (++) SignalFreeTime
mbed_official 205:c41fc65bcfb4 123 (++) Tolerance
mbed_official 205:c41fc65bcfb4 124 (++) BRERxStop (RX stopped or not upon Bit Rising Error)
mbed_official 205:c41fc65bcfb4 125 (++) BREErrorBitGen (Error-Bit generation in case of Bit Rising Error)
mbed_official 205:c41fc65bcfb4 126 (++) LBPEErrorBitGen (Error-Bit generation in case of Long Bit Period Error)
mbed_official 205:c41fc65bcfb4 127 (++) BroadcastMsgNoErrorBitGen (Error-bit generation in case of broadcast message error)
mbed_official 205:c41fc65bcfb4 128 (++) SignalFreeTimeOption (SFT Timer start definition)
mbed_official 205:c41fc65bcfb4 129 (++) OwnAddress (CEC device address)
mbed_official 205:c41fc65bcfb4 130 (++) ListenMode
mbed_official 205:c41fc65bcfb4 131
mbed_official 205:c41fc65bcfb4 132 @endverbatim
mbed_official 205:c41fc65bcfb4 133 * @{
mbed_official 205:c41fc65bcfb4 134 */
mbed_official 205:c41fc65bcfb4 135
mbed_official 205:c41fc65bcfb4 136 /**
mbed_official 205:c41fc65bcfb4 137 * @brief Initializes the CEC mode according to the specified
mbed_official 205:c41fc65bcfb4 138 * parameters in the CEC_InitTypeDef and creates the associated handle .
mbed_official 205:c41fc65bcfb4 139 * @param hcec: CEC handle
mbed_official 205:c41fc65bcfb4 140 * @retval HAL status
mbed_official 205:c41fc65bcfb4 141 */
mbed_official 205:c41fc65bcfb4 142 HAL_StatusTypeDef HAL_CEC_Init(CEC_HandleTypeDef *hcec)
mbed_official 205:c41fc65bcfb4 143 {
mbed_official 205:c41fc65bcfb4 144 uint32_t tmpreg = 0x0;
mbed_official 205:c41fc65bcfb4 145
mbed_official 205:c41fc65bcfb4 146 /* Check the CEC handle allocation */
mbed_official 205:c41fc65bcfb4 147 if(hcec == NULL)
mbed_official 205:c41fc65bcfb4 148 {
mbed_official 205:c41fc65bcfb4 149 return HAL_ERROR;
mbed_official 205:c41fc65bcfb4 150 }
mbed_official 205:c41fc65bcfb4 151
mbed_official 205:c41fc65bcfb4 152 /* Check the parameters */
mbed_official 205:c41fc65bcfb4 153 assert_param(IS_CEC_SIGNALFREETIME(hcec->Init.SignalFreeTime));
mbed_official 205:c41fc65bcfb4 154 assert_param(IS_CEC_TOLERANCE(hcec->Init.Tolerance));
mbed_official 205:c41fc65bcfb4 155 assert_param(IS_CEC_BRERXSTOP(hcec->Init.BRERxStop));
mbed_official 205:c41fc65bcfb4 156 assert_param(IS_CEC_BREERRORBITGEN(hcec->Init.BREErrorBitGen));
mbed_official 205:c41fc65bcfb4 157 assert_param(IS_CEC_LBPEERRORBITGEN(hcec->Init.LBPEErrorBitGen));
mbed_official 205:c41fc65bcfb4 158 assert_param(IS_CEC_BROADCASTERROR_NO_ERRORBIT_GENERATION(hcec->Init.BroadcastMsgNoErrorBitGen));
mbed_official 205:c41fc65bcfb4 159 assert_param(IS_CEC_SFTOP(hcec->Init.SignalFreeTimeOption));
mbed_official 205:c41fc65bcfb4 160 assert_param(IS_CEC_OAR_ADDRESS(hcec->Init.OwnAddress));
mbed_official 205:c41fc65bcfb4 161 assert_param(IS_CEC_LISTENING_MODE(hcec->Init.ListenMode));
mbed_official 205:c41fc65bcfb4 162 assert_param(IS_CEC_ADDRESS(hcec->Init.InitiatorAddress));
mbed_official 205:c41fc65bcfb4 163
mbed_official 205:c41fc65bcfb4 164
mbed_official 205:c41fc65bcfb4 165 if(hcec->State == HAL_CEC_STATE_RESET)
mbed_official 205:c41fc65bcfb4 166 {
mbed_official 205:c41fc65bcfb4 167 /* Init the low level hardware : GPIO, CLOCK */
mbed_official 205:c41fc65bcfb4 168 HAL_CEC_MspInit(hcec);
mbed_official 205:c41fc65bcfb4 169 }
mbed_official 205:c41fc65bcfb4 170
mbed_official 205:c41fc65bcfb4 171 hcec->State = HAL_CEC_STATE_BUSY;
mbed_official 205:c41fc65bcfb4 172
mbed_official 205:c41fc65bcfb4 173 /* Disable the Peripheral */
mbed_official 205:c41fc65bcfb4 174 __HAL_CEC_DISABLE(hcec);
mbed_official 205:c41fc65bcfb4 175
mbed_official 205:c41fc65bcfb4 176 tmpreg = hcec->Init.SignalFreeTime;
mbed_official 205:c41fc65bcfb4 177 tmpreg |= hcec->Init.Tolerance;
mbed_official 205:c41fc65bcfb4 178 tmpreg |= hcec->Init.BRERxStop;
mbed_official 205:c41fc65bcfb4 179 tmpreg |= hcec->Init.BREErrorBitGen;
mbed_official 205:c41fc65bcfb4 180 tmpreg |= hcec->Init.LBPEErrorBitGen;
mbed_official 205:c41fc65bcfb4 181 tmpreg |= hcec->Init.BroadcastMsgNoErrorBitGen;
mbed_official 205:c41fc65bcfb4 182 tmpreg |= hcec->Init.SignalFreeTimeOption;
mbed_official 205:c41fc65bcfb4 183 tmpreg |= (hcec->Init.OwnAddress << CEC_CFGR_OAR_LSB_POS);
mbed_official 205:c41fc65bcfb4 184 tmpreg |= hcec->Init.ListenMode;
mbed_official 205:c41fc65bcfb4 185
mbed_official 205:c41fc65bcfb4 186 /* Write to CEC Control Register */
mbed_official 205:c41fc65bcfb4 187 MODIFY_REG(hcec->Instance->CFGR, CEC_CFGR_FIELDS, tmpreg);
mbed_official 205:c41fc65bcfb4 188
mbed_official 205:c41fc65bcfb4 189 /* Enable the Peripheral */
mbed_official 205:c41fc65bcfb4 190 __HAL_CEC_ENABLE(hcec);
mbed_official 205:c41fc65bcfb4 191
mbed_official 205:c41fc65bcfb4 192 hcec->State = HAL_CEC_STATE_READY;
mbed_official 205:c41fc65bcfb4 193
mbed_official 205:c41fc65bcfb4 194 return HAL_OK;
mbed_official 205:c41fc65bcfb4 195 }
mbed_official 205:c41fc65bcfb4 196
mbed_official 205:c41fc65bcfb4 197
mbed_official 205:c41fc65bcfb4 198
mbed_official 205:c41fc65bcfb4 199 /**
mbed_official 205:c41fc65bcfb4 200 * @brief DeInitializes the CEC peripheral
mbed_official 205:c41fc65bcfb4 201 * @param hcec: CEC handle
mbed_official 205:c41fc65bcfb4 202 * @retval HAL status
mbed_official 205:c41fc65bcfb4 203 */
mbed_official 205:c41fc65bcfb4 204 HAL_StatusTypeDef HAL_CEC_DeInit(CEC_HandleTypeDef *hcec)
mbed_official 205:c41fc65bcfb4 205 {
mbed_official 205:c41fc65bcfb4 206 /* Check the CEC handle allocation */
mbed_official 205:c41fc65bcfb4 207 if(hcec == NULL)
mbed_official 205:c41fc65bcfb4 208 {
mbed_official 205:c41fc65bcfb4 209 return HAL_ERROR;
mbed_official 205:c41fc65bcfb4 210 }
mbed_official 205:c41fc65bcfb4 211
mbed_official 205:c41fc65bcfb4 212 /* Check the parameters */
mbed_official 205:c41fc65bcfb4 213 assert_param(IS_CEC_ALL_INSTANCE(hcec->Instance));
mbed_official 205:c41fc65bcfb4 214
mbed_official 205:c41fc65bcfb4 215 hcec->State = HAL_CEC_STATE_BUSY;
mbed_official 205:c41fc65bcfb4 216
mbed_official 205:c41fc65bcfb4 217 /* DeInit the low level hardware */
mbed_official 205:c41fc65bcfb4 218 HAL_CEC_MspDeInit(hcec);
mbed_official 205:c41fc65bcfb4 219 /* Disable the Peripheral */
mbed_official 205:c41fc65bcfb4 220 __HAL_CEC_DISABLE(hcec);
mbed_official 205:c41fc65bcfb4 221
mbed_official 205:c41fc65bcfb4 222 hcec->ErrorCode = HAL_CEC_ERROR_NONE;
mbed_official 205:c41fc65bcfb4 223 hcec->State = HAL_CEC_STATE_RESET;
mbed_official 205:c41fc65bcfb4 224
mbed_official 205:c41fc65bcfb4 225 /* Process Unlock */
mbed_official 205:c41fc65bcfb4 226 __HAL_UNLOCK(hcec);
mbed_official 205:c41fc65bcfb4 227
mbed_official 205:c41fc65bcfb4 228 return HAL_OK;
mbed_official 205:c41fc65bcfb4 229 }
mbed_official 205:c41fc65bcfb4 230
mbed_official 205:c41fc65bcfb4 231 /**
mbed_official 205:c41fc65bcfb4 232 * @brief CEC MSP Init
mbed_official 205:c41fc65bcfb4 233 * @param hcec: CEC handle
mbed_official 205:c41fc65bcfb4 234 * @retval None
mbed_official 205:c41fc65bcfb4 235 */
mbed_official 205:c41fc65bcfb4 236 __weak void HAL_CEC_MspInit(CEC_HandleTypeDef *hcec)
mbed_official 205:c41fc65bcfb4 237 {
mbed_official 205:c41fc65bcfb4 238 /* NOTE : This function should not be modified, when the callback is needed,
mbed_official 205:c41fc65bcfb4 239 the HAL_CEC_MspInit can be implemented in the user file
mbed_official 205:c41fc65bcfb4 240 */
mbed_official 205:c41fc65bcfb4 241 }
mbed_official 205:c41fc65bcfb4 242
mbed_official 205:c41fc65bcfb4 243 /**
mbed_official 205:c41fc65bcfb4 244 * @brief CEC MSP DeInit
mbed_official 205:c41fc65bcfb4 245 * @param hcec: CEC handle
mbed_official 205:c41fc65bcfb4 246 * @retval None
mbed_official 205:c41fc65bcfb4 247 */
mbed_official 205:c41fc65bcfb4 248 __weak void HAL_CEC_MspDeInit(CEC_HandleTypeDef *hcec)
mbed_official 205:c41fc65bcfb4 249 {
mbed_official 205:c41fc65bcfb4 250 /* NOTE : This function should not be modified, when the callback is needed,
mbed_official 205:c41fc65bcfb4 251 the HAL_CEC_MspDeInit can be implemented in the user file
mbed_official 205:c41fc65bcfb4 252 */
mbed_official 205:c41fc65bcfb4 253 }
mbed_official 205:c41fc65bcfb4 254
mbed_official 205:c41fc65bcfb4 255 /**
mbed_official 205:c41fc65bcfb4 256 * @}
mbed_official 205:c41fc65bcfb4 257 */
mbed_official 205:c41fc65bcfb4 258
mbed_official 205:c41fc65bcfb4 259 /** @defgroup HAL_CEC_Group2 IO operation function
mbed_official 205:c41fc65bcfb4 260 * @brief CEC Transmit/Receive functions
mbed_official 205:c41fc65bcfb4 261 *
mbed_official 205:c41fc65bcfb4 262 @verbatim
mbed_official 205:c41fc65bcfb4 263 ===============================================================================
mbed_official 205:c41fc65bcfb4 264 ##### I/O operation function #####
mbed_official 205:c41fc65bcfb4 265 ===============================================================================
mbed_official 205:c41fc65bcfb4 266 This subsection provides a set of functions allowing to manage the CEC data transfers.
mbed_official 205:c41fc65bcfb4 267
mbed_official 205:c41fc65bcfb4 268 (#) The CEC handle must contain the initiator (TX side) and the destination (RX side)
mbed_official 205:c41fc65bcfb4 269 logical addresses (4-bit long addresses, 0xF for broadcast messages destination)
mbed_official 205:c41fc65bcfb4 270
mbed_official 205:c41fc65bcfb4 271 (#) There are two mode of transfer:
mbed_official 205:c41fc65bcfb4 272 (+) Blocking mode: The communication is performed in polling mode.
mbed_official 205:c41fc65bcfb4 273 The HAL status of all data processing is returned by the same function
mbed_official 205:c41fc65bcfb4 274 after finishing transfer.
mbed_official 205:c41fc65bcfb4 275 (+) No-Blocking mode: The communication is performed using Interrupts.
mbed_official 205:c41fc65bcfb4 276 These API's return the HAL status.
mbed_official 205:c41fc65bcfb4 277 The end of the data processing will be indicated through the
mbed_official 205:c41fc65bcfb4 278 dedicated CEC IRQ when using Interrupt mode.
mbed_official 205:c41fc65bcfb4 279 The HAL_CEC_TxCpltCallback(), HAL_CEC_RxCpltCallback() user callbacks
mbed_official 205:c41fc65bcfb4 280 will be executed respectivelly at the end of the transmit or Receive process
mbed_official 205:c41fc65bcfb4 281 The HAL_CEC_ErrorCallback()user callback will be executed when a communication
mbed_official 205:c41fc65bcfb4 282 error is detected
mbed_official 205:c41fc65bcfb4 283
mbed_official 205:c41fc65bcfb4 284 (#) Blocking mode API's are :
mbed_official 205:c41fc65bcfb4 285 (+) HAL_CEC_Transmit()
mbed_official 205:c41fc65bcfb4 286 (+) HAL_CEC_Receive()
mbed_official 205:c41fc65bcfb4 287
mbed_official 205:c41fc65bcfb4 288 (#) Non-Blocking mode API's with Interrupt are :
mbed_official 205:c41fc65bcfb4 289 (+) HAL_CEC_Transmit_IT()
mbed_official 205:c41fc65bcfb4 290 (+) HAL_CEC_Receive_IT()
mbed_official 205:c41fc65bcfb4 291 (+) HAL_CEC_IRQHandler()
mbed_official 205:c41fc65bcfb4 292
mbed_official 205:c41fc65bcfb4 293 (#) A set of Transfer Complete Callbacks are provided in No_Blocking mode:
mbed_official 205:c41fc65bcfb4 294 (+) HAL_CEC_TxCpltCallback()
mbed_official 205:c41fc65bcfb4 295 (+) HAL_CEC_RxCpltCallback()
mbed_official 205:c41fc65bcfb4 296 (+) HAL_CEC_ErrorCallback()
mbed_official 205:c41fc65bcfb4 297
mbed_official 205:c41fc65bcfb4 298 @endverbatim
mbed_official 205:c41fc65bcfb4 299 * @{
mbed_official 205:c41fc65bcfb4 300 */
mbed_official 205:c41fc65bcfb4 301
mbed_official 205:c41fc65bcfb4 302 /**
mbed_official 205:c41fc65bcfb4 303 * @brief Send data in blocking mode
mbed_official 205:c41fc65bcfb4 304 * @param hcec: CEC handle
mbed_official 205:c41fc65bcfb4 305 * @param DestinationAddress: destination logical address
mbed_official 205:c41fc65bcfb4 306 * @param pData: pointer to input byte data buffer
mbed_official 205:c41fc65bcfb4 307 * @param Size: amount of data to be sent in bytes (without counting the header).
mbed_official 205:c41fc65bcfb4 308 * 0 means only the header is sent (ping operation).
mbed_official 205:c41fc65bcfb4 309 * Maximum TX size is 15 bytes (1 opcode and up to 14 operands).
mbed_official 205:c41fc65bcfb4 310 * @param Timeout: Timeout duration.
mbed_official 205:c41fc65bcfb4 311 * @retval HAL status
mbed_official 205:c41fc65bcfb4 312 */
mbed_official 205:c41fc65bcfb4 313 HAL_StatusTypeDef HAL_CEC_Transmit(CEC_HandleTypeDef *hcec, uint8_t DestinationAddress, uint8_t *pData, uint32_t Size, uint32_t Timeout)
mbed_official 205:c41fc65bcfb4 314 {
mbed_official 205:c41fc65bcfb4 315 uint8_t temp = 0;
mbed_official 205:c41fc65bcfb4 316 uint32_t tempisr = 0;
mbed_official 205:c41fc65bcfb4 317 uint32_t tickstart = 0;
mbed_official 205:c41fc65bcfb4 318
mbed_official 205:c41fc65bcfb4 319 if((hcec->State == HAL_CEC_STATE_READY) && (__HAL_CEC_GET_TRANSMISSION_START_FLAG(hcec) == RESET))
mbed_official 205:c41fc65bcfb4 320 {
mbed_official 205:c41fc65bcfb4 321 hcec->ErrorCode = HAL_CEC_ERROR_NONE;
mbed_official 205:c41fc65bcfb4 322 if((pData == NULL ) && (Size > 0))
mbed_official 205:c41fc65bcfb4 323 {
mbed_official 205:c41fc65bcfb4 324 hcec->State = HAL_CEC_STATE_ERROR;
mbed_official 205:c41fc65bcfb4 325 return HAL_ERROR;
mbed_official 205:c41fc65bcfb4 326 }
mbed_official 205:c41fc65bcfb4 327
mbed_official 205:c41fc65bcfb4 328 assert_param(IS_CEC_ADDRESS(DestinationAddress));
mbed_official 205:c41fc65bcfb4 329 assert_param(IS_CEC_MSGSIZE(Size));
mbed_official 205:c41fc65bcfb4 330
mbed_official 205:c41fc65bcfb4 331 /* Process Locked */
mbed_official 205:c41fc65bcfb4 332 __HAL_LOCK(hcec);
mbed_official 205:c41fc65bcfb4 333
mbed_official 205:c41fc65bcfb4 334 hcec->State = HAL_CEC_STATE_BUSY_TX;
mbed_official 205:c41fc65bcfb4 335
mbed_official 205:c41fc65bcfb4 336 hcec->TxXferCount = Size;
mbed_official 205:c41fc65bcfb4 337
mbed_official 205:c41fc65bcfb4 338 /* case no data to be sent, sender is only pinging the system */
mbed_official 205:c41fc65bcfb4 339 if (Size == 0)
mbed_official 205:c41fc65bcfb4 340 {
mbed_official 205:c41fc65bcfb4 341 /* Set TX End of Message (TXEOM) bit, must be set before writing data to TXDR */
mbed_official 205:c41fc65bcfb4 342 __HAL_CEC_LAST_BYTE_TX_SET(hcec);
mbed_official 205:c41fc65bcfb4 343 }
mbed_official 205:c41fc65bcfb4 344
mbed_official 205:c41fc65bcfb4 345 /* send header block */
mbed_official 205:c41fc65bcfb4 346 temp = ((uint32_t)hcec->Init.InitiatorAddress << CEC_INITIATOR_LSB_POS) | DestinationAddress;
mbed_official 205:c41fc65bcfb4 347 hcec->Instance->TXDR = temp;
mbed_official 205:c41fc65bcfb4 348 /* Set TX Start of Message (TXSOM) bit */
mbed_official 205:c41fc65bcfb4 349 __HAL_CEC_FIRST_BYTE_TX_SET(hcec);
mbed_official 205:c41fc65bcfb4 350
mbed_official 205:c41fc65bcfb4 351 while (hcec->TxXferCount > 0)
mbed_official 205:c41fc65bcfb4 352 {
mbed_official 205:c41fc65bcfb4 353 hcec->TxXferCount--;
mbed_official 205:c41fc65bcfb4 354
mbed_official 205:c41fc65bcfb4 355 tickstart = HAL_GetTick();
mbed_official 205:c41fc65bcfb4 356 while(HAL_IS_BIT_CLR(hcec->Instance->ISR, CEC_ISR_TXBR))
mbed_official 205:c41fc65bcfb4 357 {
mbed_official 205:c41fc65bcfb4 358 if(Timeout != HAL_MAX_DELAY)
mbed_official 205:c41fc65bcfb4 359 {
mbed_official 205:c41fc65bcfb4 360 if((HAL_GetTick() - tickstart) > Timeout)
mbed_official 205:c41fc65bcfb4 361 {
mbed_official 205:c41fc65bcfb4 362 hcec->State = HAL_CEC_STATE_TIMEOUT;
mbed_official 205:c41fc65bcfb4 363 /* Process Unlocked */
mbed_official 205:c41fc65bcfb4 364 __HAL_UNLOCK(hcec);
mbed_official 205:c41fc65bcfb4 365 return HAL_TIMEOUT;
mbed_official 205:c41fc65bcfb4 366 }
mbed_official 205:c41fc65bcfb4 367 }
mbed_official 205:c41fc65bcfb4 368
mbed_official 205:c41fc65bcfb4 369 /* check whether error occured while waiting for TXBR to be set:
mbed_official 205:c41fc65bcfb4 370 * has Tx underrun occurred ?
mbed_official 205:c41fc65bcfb4 371 * has Tx error occurred ?
mbed_official 205:c41fc65bcfb4 372 * has Tx Missing Acknowledge error occurred ?
mbed_official 205:c41fc65bcfb4 373 * has Arbitration Loss error occurred ? */
mbed_official 205:c41fc65bcfb4 374 tempisr = hcec->Instance->ISR;
mbed_official 205:c41fc65bcfb4 375 if ((tempisr & (CEC_ISR_TXUDR|CEC_ISR_TXERR|CEC_ISR_TXACKE|CEC_ISR_ARBLST)) != 0)
mbed_official 205:c41fc65bcfb4 376 {
mbed_official 205:c41fc65bcfb4 377 /* copy ISR for error handling purposes */
mbed_official 205:c41fc65bcfb4 378 hcec->ErrorCode = tempisr;
mbed_official 205:c41fc65bcfb4 379 /* clear all error flags by default */
mbed_official 205:c41fc65bcfb4 380 __HAL_CEC_CLEAR_FLAG(hcec, (CEC_ISR_TXUDR|CEC_ISR_TXERR|CEC_ISR_TXACKE|CEC_ISR_ARBLST));
mbed_official 205:c41fc65bcfb4 381 hcec->State = HAL_CEC_STATE_ERROR;
mbed_official 205:c41fc65bcfb4 382 __HAL_UNLOCK(hcec);
mbed_official 205:c41fc65bcfb4 383 return HAL_ERROR;
mbed_official 205:c41fc65bcfb4 384 }
mbed_official 205:c41fc65bcfb4 385 }
mbed_official 205:c41fc65bcfb4 386 /* TXBR to clear BEFORE writing TXDR register */
mbed_official 205:c41fc65bcfb4 387 __HAL_CEC_CLEAR_FLAG(hcec,CEC_ISR_TXBR);
mbed_official 205:c41fc65bcfb4 388 if (hcec->TxXferCount == 0)
mbed_official 205:c41fc65bcfb4 389 {
mbed_official 205:c41fc65bcfb4 390 /* if last byte transmission, set TX End of Message (TXEOM) bit */
mbed_official 205:c41fc65bcfb4 391 __HAL_CEC_LAST_BYTE_TX_SET(hcec);
mbed_official 205:c41fc65bcfb4 392 }
mbed_official 205:c41fc65bcfb4 393 hcec->Instance->TXDR = *pData++;
mbed_official 205:c41fc65bcfb4 394
mbed_official 205:c41fc65bcfb4 395 /* error check after TX byte write up */
mbed_official 205:c41fc65bcfb4 396 tempisr = hcec->Instance->ISR;
mbed_official 205:c41fc65bcfb4 397 if ((tempisr & (CEC_ISR_TXUDR|CEC_ISR_TXERR|CEC_ISR_TXACKE|CEC_ISR_ARBLST)) != 0)
mbed_official 205:c41fc65bcfb4 398 {
mbed_official 205:c41fc65bcfb4 399 /* copy ISR for error handling purposes */
mbed_official 205:c41fc65bcfb4 400 hcec->ErrorCode = tempisr;
mbed_official 205:c41fc65bcfb4 401 /* clear all error flags by default */
mbed_official 205:c41fc65bcfb4 402 __HAL_CEC_CLEAR_FLAG(hcec, (CEC_ISR_TXUDR|CEC_ISR_TXERR|CEC_ISR_TXACKE|CEC_ISR_ARBLST));
mbed_official 205:c41fc65bcfb4 403 hcec->State = HAL_CEC_STATE_ERROR;
mbed_official 205:c41fc65bcfb4 404 __HAL_UNLOCK(hcec);
mbed_official 205:c41fc65bcfb4 405 return HAL_ERROR;
mbed_official 205:c41fc65bcfb4 406 }
mbed_official 205:c41fc65bcfb4 407 } /* end while (while (hcec->TxXferCount > 0)) */
mbed_official 205:c41fc65bcfb4 408
mbed_official 205:c41fc65bcfb4 409
mbed_official 205:c41fc65bcfb4 410 /* if no error up to this point, check that transmission is
mbed_official 205:c41fc65bcfb4 411 * complete, that is wait until TXEOM is reset */
mbed_official 205:c41fc65bcfb4 412 tickstart = HAL_GetTick();
mbed_official 205:c41fc65bcfb4 413
mbed_official 205:c41fc65bcfb4 414 while (HAL_IS_BIT_SET(hcec->Instance->CR, CEC_CR_TXEOM))
mbed_official 205:c41fc65bcfb4 415 {
mbed_official 205:c41fc65bcfb4 416 if(Timeout != HAL_MAX_DELAY)
mbed_official 205:c41fc65bcfb4 417 {
mbed_official 205:c41fc65bcfb4 418 if((HAL_GetTick() - tickstart) > Timeout)
mbed_official 205:c41fc65bcfb4 419 {
mbed_official 205:c41fc65bcfb4 420 hcec->State = HAL_CEC_STATE_ERROR;
mbed_official 205:c41fc65bcfb4 421 __HAL_UNLOCK(hcec);
mbed_official 205:c41fc65bcfb4 422 return HAL_TIMEOUT;
mbed_official 205:c41fc65bcfb4 423 }
mbed_official 205:c41fc65bcfb4 424 }
mbed_official 205:c41fc65bcfb4 425 }
mbed_official 205:c41fc65bcfb4 426
mbed_official 205:c41fc65bcfb4 427 /* Final error check once all bytes have been transmitted */
mbed_official 205:c41fc65bcfb4 428 tempisr = hcec->Instance->ISR;
mbed_official 205:c41fc65bcfb4 429 if ((tempisr & (CEC_ISR_TXUDR|CEC_ISR_TXERR|CEC_ISR_TXACKE)) != 0)
mbed_official 205:c41fc65bcfb4 430 {
mbed_official 205:c41fc65bcfb4 431 /* copy ISR for error handling purposes */
mbed_official 205:c41fc65bcfb4 432 hcec->ErrorCode = tempisr;
mbed_official 205:c41fc65bcfb4 433 /* clear all error flags by default */
mbed_official 205:c41fc65bcfb4 434 __HAL_CEC_CLEAR_FLAG(hcec, (CEC_ISR_TXUDR|CEC_ISR_TXERR|CEC_ISR_TXACKE));
mbed_official 205:c41fc65bcfb4 435 hcec->State = HAL_CEC_STATE_ERROR;
mbed_official 205:c41fc65bcfb4 436 __HAL_UNLOCK(hcec);
mbed_official 205:c41fc65bcfb4 437 return HAL_ERROR;
mbed_official 205:c41fc65bcfb4 438 }
mbed_official 205:c41fc65bcfb4 439
mbed_official 205:c41fc65bcfb4 440 hcec->State = HAL_CEC_STATE_READY;
mbed_official 205:c41fc65bcfb4 441 __HAL_UNLOCK(hcec);
mbed_official 205:c41fc65bcfb4 442
mbed_official 205:c41fc65bcfb4 443 return HAL_OK;
mbed_official 205:c41fc65bcfb4 444 }
mbed_official 205:c41fc65bcfb4 445 else
mbed_official 205:c41fc65bcfb4 446 {
mbed_official 205:c41fc65bcfb4 447 return HAL_BUSY;
mbed_official 205:c41fc65bcfb4 448 }
mbed_official 205:c41fc65bcfb4 449 }
mbed_official 205:c41fc65bcfb4 450
mbed_official 205:c41fc65bcfb4 451 /**
mbed_official 205:c41fc65bcfb4 452 * @brief Receive data in blocking mode. Must be invoked when RXBR has been set.
mbed_official 205:c41fc65bcfb4 453 * @param hcec: CEC handle
mbed_official 205:c41fc65bcfb4 454 * @param pData: pointer to received data buffer.
mbed_official 205:c41fc65bcfb4 455 * @param Timeout: Timeout duration.
mbed_official 205:c41fc65bcfb4 456 * Note that the received data size is not known beforehand, the latter is known
mbed_official 205:c41fc65bcfb4 457 * when the reception is complete and is stored in hcec->RxXferSize.
mbed_official 205:c41fc65bcfb4 458 * hcec->RxXferSize is the sum of opcodes + operands (0 to 14 operands max).
mbed_official 205:c41fc65bcfb4 459 * If only a header is received, hcec->RxXferSize = 0
mbed_official 205:c41fc65bcfb4 460 * @retval HAL status
mbed_official 205:c41fc65bcfb4 461 */
mbed_official 205:c41fc65bcfb4 462 HAL_StatusTypeDef HAL_CEC_Receive(CEC_HandleTypeDef *hcec, uint8_t *pData, uint32_t Timeout)
mbed_official 205:c41fc65bcfb4 463 {
mbed_official 205:c41fc65bcfb4 464 uint32_t temp;
mbed_official 205:c41fc65bcfb4 465 uint32_t tickstart = 0;
mbed_official 205:c41fc65bcfb4 466
mbed_official 205:c41fc65bcfb4 467 if (hcec->State == HAL_CEC_STATE_READY)
mbed_official 205:c41fc65bcfb4 468 {
mbed_official 205:c41fc65bcfb4 469 hcec->ErrorCode = HAL_CEC_ERROR_NONE;
mbed_official 205:c41fc65bcfb4 470 if (pData == NULL )
mbed_official 205:c41fc65bcfb4 471 {
mbed_official 205:c41fc65bcfb4 472 hcec->State = HAL_CEC_STATE_ERROR;
mbed_official 205:c41fc65bcfb4 473 return HAL_ERROR;
mbed_official 205:c41fc65bcfb4 474 }
mbed_official 205:c41fc65bcfb4 475
mbed_official 205:c41fc65bcfb4 476 hcec->RxXferSize = 0;
mbed_official 205:c41fc65bcfb4 477 /* Process Locked */
mbed_official 205:c41fc65bcfb4 478 __HAL_LOCK(hcec);
mbed_official 205:c41fc65bcfb4 479
mbed_official 205:c41fc65bcfb4 480
mbed_official 205:c41fc65bcfb4 481 /* Rx loop until CEC_ISR_RXEND is set */
mbed_official 205:c41fc65bcfb4 482 while (HAL_IS_BIT_CLR(hcec->Instance->ISR, CEC_ISR_RXEND))
mbed_official 205:c41fc65bcfb4 483 {
mbed_official 205:c41fc65bcfb4 484 tickstart = HAL_GetTick();
mbed_official 205:c41fc65bcfb4 485 /* Wait for next byte to be received */
mbed_official 205:c41fc65bcfb4 486 while (HAL_IS_BIT_CLR(hcec->Instance->ISR, CEC_ISR_RXBR))
mbed_official 205:c41fc65bcfb4 487 {
mbed_official 205:c41fc65bcfb4 488 if(Timeout != HAL_MAX_DELAY)
mbed_official 205:c41fc65bcfb4 489 {
mbed_official 205:c41fc65bcfb4 490 if((HAL_GetTick() - tickstart) > Timeout)
mbed_official 205:c41fc65bcfb4 491 {
mbed_official 205:c41fc65bcfb4 492 hcec->State = HAL_CEC_STATE_TIMEOUT;
mbed_official 205:c41fc65bcfb4 493 __HAL_UNLOCK(hcec);
mbed_official 205:c41fc65bcfb4 494 return HAL_TIMEOUT;
mbed_official 205:c41fc65bcfb4 495 }
mbed_official 205:c41fc65bcfb4 496 }
mbed_official 205:c41fc65bcfb4 497 /* any error so far ?
mbed_official 205:c41fc65bcfb4 498 * has Rx Missing Acknowledge occurred ?
mbed_official 205:c41fc65bcfb4 499 * has Rx Long Bit Period error occurred ?
mbed_official 205:c41fc65bcfb4 500 * has Rx Short Bit Period error occurred ?
mbed_official 205:c41fc65bcfb4 501 * has Rx Bit Rising error occurred ?
mbed_official 205:c41fc65bcfb4 502 * has Rx Overrun error occurred ? */
mbed_official 205:c41fc65bcfb4 503 temp = (uint32_t) (hcec->Instance->ISR);
mbed_official 205:c41fc65bcfb4 504 if ((temp & (CEC_ISR_RXACKE|CEC_ISR_LBPE|CEC_ISR_SBPE|CEC_ISR_BRE|CEC_ISR_RXOVR)) != 0)
mbed_official 205:c41fc65bcfb4 505 {
mbed_official 205:c41fc65bcfb4 506 /* copy ISR for error handling purposes */
mbed_official 205:c41fc65bcfb4 507 hcec->ErrorCode = temp;
mbed_official 205:c41fc65bcfb4 508 /* clear all error flags by default */
mbed_official 205:c41fc65bcfb4 509 __HAL_CEC_CLEAR_FLAG(hcec, (CEC_ISR_RXACKE|CEC_ISR_LBPE|CEC_ISR_SBPE|CEC_ISR_BRE|CEC_ISR_RXOVR));
mbed_official 205:c41fc65bcfb4 510 hcec->State = HAL_CEC_STATE_ERROR;
mbed_official 205:c41fc65bcfb4 511 __HAL_UNLOCK(hcec);
mbed_official 205:c41fc65bcfb4 512 return HAL_ERROR;
mbed_official 205:c41fc65bcfb4 513 }
mbed_official 205:c41fc65bcfb4 514 } /* while (HAL_IS_BIT_CLR(hcec->Instance->ISR, CEC_ISR_RXBR)) */
mbed_official 205:c41fc65bcfb4 515
mbed_official 205:c41fc65bcfb4 516
mbed_official 205:c41fc65bcfb4 517 /* read received data */
mbed_official 205:c41fc65bcfb4 518 *pData++ = hcec->Instance->RXDR;
mbed_official 205:c41fc65bcfb4 519 temp = (uint32_t) (hcec->Instance->ISR);
mbed_official 205:c41fc65bcfb4 520 /* end of message ? */
mbed_official 205:c41fc65bcfb4 521 if ((temp & CEC_ISR_RXEND) != 0)
mbed_official 205:c41fc65bcfb4 522 {
mbed_official 205:c41fc65bcfb4 523 assert_param(IS_CEC_MSGSIZE(hcec->RxXferSize));
mbed_official 205:c41fc65bcfb4 524 __HAL_CEC_CLEAR_FLAG(hcec,CEC_ISR_RXEND);
mbed_official 205:c41fc65bcfb4 525 hcec->State = HAL_CEC_STATE_READY;
mbed_official 205:c41fc65bcfb4 526 __HAL_UNLOCK(hcec);
mbed_official 205:c41fc65bcfb4 527 return HAL_OK;
mbed_official 205:c41fc65bcfb4 528 }
mbed_official 205:c41fc65bcfb4 529
mbed_official 205:c41fc65bcfb4 530 /* clear Rx-Byte Received flag */
mbed_official 205:c41fc65bcfb4 531 __HAL_CEC_CLEAR_FLAG(hcec,CEC_ISR_RXBR);
mbed_official 205:c41fc65bcfb4 532 /* increment payload byte counter */
mbed_official 205:c41fc65bcfb4 533 hcec->RxXferSize++;
mbed_official 205:c41fc65bcfb4 534 } /* while (HAL_IS_BIT_CLR(hcec->Instance->ISR, CEC_ISR_RXEND)) */
mbed_official 205:c41fc65bcfb4 535
mbed_official 205:c41fc65bcfb4 536 /* if the instructions below are executed, it means RXEND was set when RXBR was
mbed_official 205:c41fc65bcfb4 537 * set for the first time:
mbed_official 205:c41fc65bcfb4 538 * the code within the "while (HAL_IS_BIT_CLR(hcec->Instance->ISR, CEC_ISR_RXEND))"
mbed_official 205:c41fc65bcfb4 539 * loop has not been executed and this means a single byte has been sent */
mbed_official 205:c41fc65bcfb4 540 *pData++ = hcec->Instance->RXDR;
mbed_official 205:c41fc65bcfb4 541 /* only one header is received: RxXferSize is set to 0 (no operand, no opcode) */
mbed_official 205:c41fc65bcfb4 542 hcec->RxXferSize = 0;
mbed_official 205:c41fc65bcfb4 543 __HAL_CEC_CLEAR_FLAG(hcec,CEC_ISR_RXEND);
mbed_official 205:c41fc65bcfb4 544
mbed_official 205:c41fc65bcfb4 545 hcec->State = HAL_CEC_STATE_READY;
mbed_official 205:c41fc65bcfb4 546 __HAL_UNLOCK(hcec);
mbed_official 205:c41fc65bcfb4 547 return HAL_OK;
mbed_official 205:c41fc65bcfb4 548 }
mbed_official 205:c41fc65bcfb4 549 else
mbed_official 205:c41fc65bcfb4 550 {
mbed_official 205:c41fc65bcfb4 551 return HAL_BUSY;
mbed_official 205:c41fc65bcfb4 552 }
mbed_official 205:c41fc65bcfb4 553 }
mbed_official 205:c41fc65bcfb4 554
mbed_official 205:c41fc65bcfb4 555
mbed_official 205:c41fc65bcfb4 556 /**
mbed_official 205:c41fc65bcfb4 557 * @brief Send data in interrupt mode
mbed_official 205:c41fc65bcfb4 558 * @param hcec: CEC handle
mbed_official 205:c41fc65bcfb4 559 * @param DestinationAddress: destination logical address
mbed_official 205:c41fc65bcfb4 560 * @param pData: pointer to input byte data buffer
mbed_official 205:c41fc65bcfb4 561 * @param Size: amount of data to be sent in bytes (without counting the header).
mbed_official 205:c41fc65bcfb4 562 * 0 means only the header is sent (ping operation).
mbed_official 205:c41fc65bcfb4 563 * Maximum TX size is 15 bytes (1 opcode and up to 14 operands).
mbed_official 205:c41fc65bcfb4 564 * @retval HAL status
mbed_official 205:c41fc65bcfb4 565 */
mbed_official 205:c41fc65bcfb4 566 HAL_StatusTypeDef HAL_CEC_Transmit_IT(CEC_HandleTypeDef *hcec, uint8_t DestinationAddress, uint8_t *pData, uint32_t Size)
mbed_official 205:c41fc65bcfb4 567 {
mbed_official 205:c41fc65bcfb4 568 uint8_t temp = 0;
mbed_official 205:c41fc65bcfb4 569 /* if the IP isn't already busy and if there is no previous transmission
mbed_official 205:c41fc65bcfb4 570 already pending due to arbitration lost */
mbed_official 205:c41fc65bcfb4 571 if (((hcec->State == HAL_CEC_STATE_READY) || (hcec->State == HAL_CEC_STATE_STANDBY_RX))
mbed_official 205:c41fc65bcfb4 572 && (__HAL_CEC_GET_TRANSMISSION_START_FLAG(hcec) == RESET))
mbed_official 205:c41fc65bcfb4 573 {
mbed_official 205:c41fc65bcfb4 574 if((pData == NULL ) && (Size > 0))
mbed_official 205:c41fc65bcfb4 575 {
mbed_official 205:c41fc65bcfb4 576 hcec->State = HAL_CEC_STATE_ERROR;
mbed_official 205:c41fc65bcfb4 577 return HAL_ERROR;
mbed_official 205:c41fc65bcfb4 578 }
mbed_official 205:c41fc65bcfb4 579
mbed_official 205:c41fc65bcfb4 580 assert_param(IS_CEC_ADDRESS(DestinationAddress));
mbed_official 205:c41fc65bcfb4 581 assert_param(IS_CEC_MSGSIZE(Size));
mbed_official 205:c41fc65bcfb4 582
mbed_official 205:c41fc65bcfb4 583 /* Process Locked */
mbed_official 205:c41fc65bcfb4 584 __HAL_LOCK(hcec);
mbed_official 205:c41fc65bcfb4 585 hcec->pTxBuffPtr = pData;
mbed_official 205:c41fc65bcfb4 586 hcec->State = HAL_CEC_STATE_BUSY_TX;
mbed_official 205:c41fc65bcfb4 587 hcec->ErrorCode = HAL_CEC_ERROR_NONE;
mbed_official 205:c41fc65bcfb4 588
mbed_official 205:c41fc65bcfb4 589 /* Disable Peripheral to write CEC_IER register */
mbed_official 205:c41fc65bcfb4 590 __HAL_CEC_DISABLE(hcec);
mbed_official 205:c41fc65bcfb4 591
mbed_official 205:c41fc65bcfb4 592 /* Enable the following two CEC Transmission interrupts as
mbed_official 205:c41fc65bcfb4 593 * well as the following CEC Transmission Errors interrupts:
mbed_official 205:c41fc65bcfb4 594 * Tx Byte Request IT
mbed_official 205:c41fc65bcfb4 595 * End of Transmission IT
mbed_official 205:c41fc65bcfb4 596 * Tx Missing Acknowledge IT
mbed_official 205:c41fc65bcfb4 597 * Tx-Error IT
mbed_official 205:c41fc65bcfb4 598 * Tx-Buffer Underrun IT
mbed_official 205:c41fc65bcfb4 599 * Tx arbitration lost */
mbed_official 205:c41fc65bcfb4 600 __HAL_CEC_ENABLE_IT(hcec, CEC_IER_TXBRIE|CEC_IER_TXENDIE|CEC_IER_TX_ALL_ERR);
mbed_official 205:c41fc65bcfb4 601
mbed_official 205:c41fc65bcfb4 602 /* Enable the Peripheral */
mbed_official 205:c41fc65bcfb4 603 __HAL_CEC_ENABLE(hcec);
mbed_official 205:c41fc65bcfb4 604
mbed_official 205:c41fc65bcfb4 605 /* initialize the number of bytes to send,
mbed_official 205:c41fc65bcfb4 606 * 0 means only one header is sent (ping operation) */
mbed_official 205:c41fc65bcfb4 607 hcec->TxXferCount = Size;
mbed_official 205:c41fc65bcfb4 608
mbed_official 205:c41fc65bcfb4 609 /* Process Unlocked */
mbed_official 205:c41fc65bcfb4 610 __HAL_UNLOCK(hcec);
mbed_official 205:c41fc65bcfb4 611
mbed_official 205:c41fc65bcfb4 612 /* in case of no payload (Size = 0), sender is only pinging the system;
mbed_official 205:c41fc65bcfb4 613 * Set TX End of Message (TXEOM) bit, must be set before writing data to TXDR */
mbed_official 205:c41fc65bcfb4 614 if (Size == 0)
mbed_official 205:c41fc65bcfb4 615 {
mbed_official 205:c41fc65bcfb4 616 __HAL_CEC_LAST_BYTE_TX_SET(hcec);
mbed_official 205:c41fc65bcfb4 617 }
mbed_official 205:c41fc65bcfb4 618
mbed_official 205:c41fc65bcfb4 619 /* send header block */
mbed_official 205:c41fc65bcfb4 620 temp = ((uint32_t)hcec->Init.InitiatorAddress << CEC_INITIATOR_LSB_POS) | DestinationAddress;
mbed_official 205:c41fc65bcfb4 621 hcec->Instance->TXDR = temp;
mbed_official 205:c41fc65bcfb4 622 /* Set TX Start of Message (TXSOM) bit */
mbed_official 205:c41fc65bcfb4 623 __HAL_CEC_FIRST_BYTE_TX_SET(hcec);
mbed_official 205:c41fc65bcfb4 624
mbed_official 205:c41fc65bcfb4 625 return HAL_OK;
mbed_official 205:c41fc65bcfb4 626 }
mbed_official 205:c41fc65bcfb4 627 /* if the IP is already busy or if there is a previous transmission
mbed_official 205:c41fc65bcfb4 628 already pending due to arbitration loss */
mbed_official 205:c41fc65bcfb4 629 else if ((hcec->State == HAL_CEC_STATE_BUSY_TX)
mbed_official 205:c41fc65bcfb4 630 || (__HAL_CEC_GET_TRANSMISSION_START_FLAG(hcec) != RESET))
mbed_official 205:c41fc65bcfb4 631 {
mbed_official 205:c41fc65bcfb4 632 __HAL_LOCK(hcec);
mbed_official 205:c41fc65bcfb4 633 /* set state to BUSY TX, in case it wasn't set already (case
mbed_official 205:c41fc65bcfb4 634 * of transmission new attempt after arbitration loss) */
mbed_official 205:c41fc65bcfb4 635 if (hcec->State != HAL_CEC_STATE_BUSY_TX)
mbed_official 205:c41fc65bcfb4 636 {
mbed_official 205:c41fc65bcfb4 637 hcec->State = HAL_CEC_STATE_BUSY_TX;
mbed_official 205:c41fc65bcfb4 638 }
mbed_official 205:c41fc65bcfb4 639
mbed_official 205:c41fc65bcfb4 640 /* if all data have been sent */
mbed_official 205:c41fc65bcfb4 641 if(hcec->TxXferCount == 0)
mbed_official 205:c41fc65bcfb4 642 {
mbed_official 205:c41fc65bcfb4 643 /* Disable Peripheral to write CEC_IER register */
mbed_official 205:c41fc65bcfb4 644 __HAL_CEC_DISABLE(hcec);
mbed_official 205:c41fc65bcfb4 645
mbed_official 205:c41fc65bcfb4 646 /* Disable the CEC Transmission Interrupts */
mbed_official 205:c41fc65bcfb4 647 __HAL_CEC_DISABLE_IT(hcec, CEC_IER_TXBRIE|CEC_IER_TXENDIE);
mbed_official 205:c41fc65bcfb4 648 /* Disable the CEC Transmission Error Interrupts */
mbed_official 205:c41fc65bcfb4 649 __HAL_CEC_DISABLE_IT(hcec, CEC_IER_TX_ALL_ERR);
mbed_official 205:c41fc65bcfb4 650
mbed_official 205:c41fc65bcfb4 651 /* Enable the Peripheral */
mbed_official 205:c41fc65bcfb4 652 __HAL_CEC_ENABLE(hcec);
mbed_official 205:c41fc65bcfb4 653
mbed_official 205:c41fc65bcfb4 654 __HAL_CEC_CLEAR_FLAG(hcec,CEC_ISR_TXBR|CEC_ISR_TXEND);
mbed_official 205:c41fc65bcfb4 655
mbed_official 205:c41fc65bcfb4 656 hcec->State = HAL_CEC_STATE_READY;
mbed_official 205:c41fc65bcfb4 657 /* Call the Process Unlocked before calling the Tx call back API to give the possibility to
mbed_official 205:c41fc65bcfb4 658 start again the Transmission under the Tx call back API */
mbed_official 205:c41fc65bcfb4 659 __HAL_UNLOCK(hcec);
mbed_official 205:c41fc65bcfb4 660
mbed_official 205:c41fc65bcfb4 661 HAL_CEC_TxCpltCallback(hcec);
mbed_official 205:c41fc65bcfb4 662
mbed_official 205:c41fc65bcfb4 663 return HAL_OK;
mbed_official 205:c41fc65bcfb4 664 }
mbed_official 205:c41fc65bcfb4 665 else
mbed_official 205:c41fc65bcfb4 666 {
mbed_official 205:c41fc65bcfb4 667 if (hcec->TxXferCount == 1)
mbed_official 205:c41fc65bcfb4 668 {
mbed_official 205:c41fc65bcfb4 669 /* if this is the last byte transmission, set TX End of Message (TXEOM) bit */
mbed_official 205:c41fc65bcfb4 670 __HAL_CEC_LAST_BYTE_TX_SET(hcec);
mbed_official 205:c41fc65bcfb4 671 }
mbed_official 205:c41fc65bcfb4 672 /* clear Tx-Byte request flag */
mbed_official 205:c41fc65bcfb4 673 __HAL_CEC_CLEAR_FLAG(hcec,CEC_ISR_TXBR);
mbed_official 205:c41fc65bcfb4 674 hcec->Instance->TXDR = *hcec->pTxBuffPtr++;
mbed_official 205:c41fc65bcfb4 675 hcec->TxXferCount--;
mbed_official 205:c41fc65bcfb4 676
mbed_official 205:c41fc65bcfb4 677 /* Process Unlocked */
mbed_official 205:c41fc65bcfb4 678 __HAL_UNLOCK(hcec);
mbed_official 205:c41fc65bcfb4 679
mbed_official 205:c41fc65bcfb4 680 return HAL_OK;
mbed_official 205:c41fc65bcfb4 681 }
mbed_official 205:c41fc65bcfb4 682 }
mbed_official 205:c41fc65bcfb4 683 else
mbed_official 205:c41fc65bcfb4 684 {
mbed_official 205:c41fc65bcfb4 685 return HAL_BUSY;
mbed_official 205:c41fc65bcfb4 686 }
mbed_official 205:c41fc65bcfb4 687 }
mbed_official 205:c41fc65bcfb4 688
mbed_official 205:c41fc65bcfb4 689
mbed_official 205:c41fc65bcfb4 690 /**
mbed_official 205:c41fc65bcfb4 691 * @brief Receive data in interrupt mode.
mbed_official 205:c41fc65bcfb4 692 * @param hcec: CEC handle
mbed_official 205:c41fc65bcfb4 693 * @param pData: pointer to received data buffer.
mbed_official 205:c41fc65bcfb4 694 * Note that the received data size is not known beforehand, the latter is known
mbed_official 205:c41fc65bcfb4 695 * when the reception is complete and is stored in hcec->RxXferSize.
mbed_official 205:c41fc65bcfb4 696 * hcec->RxXferSize is the sum of opcodes + operands (0 to 14 operands max).
mbed_official 205:c41fc65bcfb4 697 * If only a header is received, hcec->RxXferSize = 0
mbed_official 205:c41fc65bcfb4 698 * @retval HAL status
mbed_official 205:c41fc65bcfb4 699 */
mbed_official 205:c41fc65bcfb4 700 HAL_StatusTypeDef HAL_CEC_Receive_IT(CEC_HandleTypeDef *hcec, uint8_t *pData)
mbed_official 205:c41fc65bcfb4 701 {
mbed_official 205:c41fc65bcfb4 702 if(hcec->State == HAL_CEC_STATE_READY)
mbed_official 205:c41fc65bcfb4 703 {
mbed_official 205:c41fc65bcfb4 704 if(pData == NULL )
mbed_official 205:c41fc65bcfb4 705 {
mbed_official 205:c41fc65bcfb4 706 hcec->State = HAL_CEC_STATE_ERROR;
mbed_official 205:c41fc65bcfb4 707 return HAL_ERROR;
mbed_official 205:c41fc65bcfb4 708 }
mbed_official 205:c41fc65bcfb4 709
mbed_official 205:c41fc65bcfb4 710 /* Process Locked */
mbed_official 205:c41fc65bcfb4 711 __HAL_LOCK(hcec);
mbed_official 205:c41fc65bcfb4 712 hcec->RxXferSize = 0;
mbed_official 205:c41fc65bcfb4 713 hcec->pRxBuffPtr = pData;
mbed_official 205:c41fc65bcfb4 714 hcec->ErrorCode = HAL_CEC_ERROR_NONE;
mbed_official 205:c41fc65bcfb4 715 /* the IP is moving to a ready to receive state */
mbed_official 205:c41fc65bcfb4 716 hcec->State = HAL_CEC_STATE_STANDBY_RX;
mbed_official 205:c41fc65bcfb4 717
mbed_official 205:c41fc65bcfb4 718 /* Disable Peripheral to write CEC_IER register */
mbed_official 205:c41fc65bcfb4 719 __HAL_CEC_DISABLE(hcec);
mbed_official 205:c41fc65bcfb4 720
mbed_official 205:c41fc65bcfb4 721 /* Enable the following CEC Reception Error Interrupts:
mbed_official 205:c41fc65bcfb4 722 * Rx overrun
mbed_official 205:c41fc65bcfb4 723 * Rx bit rising error
mbed_official 205:c41fc65bcfb4 724 * Rx short bit period error
mbed_official 205:c41fc65bcfb4 725 * Rx long bit period error
mbed_official 205:c41fc65bcfb4 726 * Rx missing acknowledge */
mbed_official 205:c41fc65bcfb4 727 __HAL_CEC_ENABLE_IT(hcec, CEC_IER_RX_ALL_ERR);
mbed_official 205:c41fc65bcfb4 728
mbed_official 205:c41fc65bcfb4 729 /* Process Unlocked */
mbed_official 205:c41fc65bcfb4 730 __HAL_UNLOCK(hcec);
mbed_official 205:c41fc65bcfb4 731
mbed_official 205:c41fc65bcfb4 732 /* Enable the following two CEC Reception interrupts:
mbed_official 205:c41fc65bcfb4 733 * Rx Byte Received IT
mbed_official 205:c41fc65bcfb4 734 * End of Reception IT */
mbed_official 205:c41fc65bcfb4 735 __HAL_CEC_ENABLE_IT(hcec, CEC_IER_RXBRIE|CEC_IER_RXENDIE);
mbed_official 205:c41fc65bcfb4 736
mbed_official 205:c41fc65bcfb4 737 __HAL_CEC_ENABLE(hcec);
mbed_official 205:c41fc65bcfb4 738
mbed_official 205:c41fc65bcfb4 739 return HAL_OK;
mbed_official 205:c41fc65bcfb4 740 }
mbed_official 205:c41fc65bcfb4 741 else
mbed_official 205:c41fc65bcfb4 742 {
mbed_official 205:c41fc65bcfb4 743 return HAL_BUSY;
mbed_official 205:c41fc65bcfb4 744 }
mbed_official 205:c41fc65bcfb4 745 }
mbed_official 205:c41fc65bcfb4 746
mbed_official 205:c41fc65bcfb4 747
mbed_official 205:c41fc65bcfb4 748
mbed_official 205:c41fc65bcfb4 749 /**
mbed_official 205:c41fc65bcfb4 750 * @brief This function handles CEC interrupt requests.
mbed_official 205:c41fc65bcfb4 751 * @param hcec: CEC handle
mbed_official 205:c41fc65bcfb4 752 * @retval None
mbed_official 205:c41fc65bcfb4 753 */
mbed_official 205:c41fc65bcfb4 754 void HAL_CEC_IRQHandler(CEC_HandleTypeDef *hcec)
mbed_official 205:c41fc65bcfb4 755 {
mbed_official 205:c41fc65bcfb4 756 /* save interrupts register for further error or interrupts handling purposes */
mbed_official 205:c41fc65bcfb4 757 hcec->ErrorCode = hcec->Instance->ISR;
mbed_official 205:c41fc65bcfb4 758 /* CEC TX missing acknowledge error interrupt occurred -------------------------------------*/
mbed_official 205:c41fc65bcfb4 759 if((__HAL_CEC_GET_IT(hcec, CEC_ISR_TXACKE) != RESET) && (__HAL_CEC_GET_IT_SOURCE(hcec, CEC_IER_TXACKEIE) != RESET))
mbed_official 205:c41fc65bcfb4 760 {
mbed_official 205:c41fc65bcfb4 761 __HAL_CEC_CLEAR_FLAG(hcec, CEC_ISR_TXACKE);
mbed_official 205:c41fc65bcfb4 762 hcec->State = HAL_CEC_STATE_ERROR;
mbed_official 205:c41fc65bcfb4 763 }
mbed_official 205:c41fc65bcfb4 764
mbed_official 205:c41fc65bcfb4 765 /* CEC transmit error interrupt occured --------------------------------------*/
mbed_official 205:c41fc65bcfb4 766 if((__HAL_CEC_GET_IT(hcec, CEC_ISR_TXERR) != RESET) && (__HAL_CEC_GET_IT_SOURCE(hcec, CEC_IER_TXERRIE) != RESET))
mbed_official 205:c41fc65bcfb4 767 {
mbed_official 205:c41fc65bcfb4 768 __HAL_CEC_CLEAR_FLAG(hcec, CEC_ISR_TXERR);
mbed_official 205:c41fc65bcfb4 769 hcec->State = HAL_CEC_STATE_ERROR;
mbed_official 205:c41fc65bcfb4 770 }
mbed_official 205:c41fc65bcfb4 771
mbed_official 205:c41fc65bcfb4 772 /* CEC TX underrun error interrupt occured --------------------------------------*/
mbed_official 205:c41fc65bcfb4 773 if((__HAL_CEC_GET_IT(hcec, CEC_ISR_TXUDR) != RESET) && (__HAL_CEC_GET_IT_SOURCE(hcec, CEC_IER_TXUDRIE) != RESET))
mbed_official 205:c41fc65bcfb4 774 {
mbed_official 205:c41fc65bcfb4 775 __HAL_CEC_CLEAR_FLAG(hcec, CEC_ISR_TXUDR);
mbed_official 205:c41fc65bcfb4 776 hcec->State = HAL_CEC_STATE_ERROR;
mbed_official 205:c41fc65bcfb4 777 }
mbed_official 205:c41fc65bcfb4 778
mbed_official 205:c41fc65bcfb4 779 /* CEC TX arbitration error interrupt occured --------------------------------------*/
mbed_official 205:c41fc65bcfb4 780 if((__HAL_CEC_GET_IT(hcec, CEC_ISR_ARBLST) != RESET) && (__HAL_CEC_GET_IT_SOURCE(hcec, CEC_IER_ARBLSTIE) != RESET))
mbed_official 205:c41fc65bcfb4 781 {
mbed_official 205:c41fc65bcfb4 782 __HAL_CEC_CLEAR_FLAG(hcec, CEC_ISR_ARBLST);
mbed_official 205:c41fc65bcfb4 783 hcec->State = HAL_CEC_STATE_ERROR;
mbed_official 205:c41fc65bcfb4 784 }
mbed_official 205:c41fc65bcfb4 785
mbed_official 205:c41fc65bcfb4 786 /* CEC RX overrun error interrupt occured --------------------------------------*/
mbed_official 205:c41fc65bcfb4 787 if((__HAL_CEC_GET_IT(hcec, CEC_ISR_RXOVR) != RESET) && (__HAL_CEC_GET_IT_SOURCE(hcec, CEC_IER_RXOVRIE) != RESET))
mbed_official 205:c41fc65bcfb4 788 {
mbed_official 205:c41fc65bcfb4 789 __HAL_CEC_CLEAR_FLAG(hcec, CEC_ISR_RXOVR);
mbed_official 205:c41fc65bcfb4 790 hcec->State = HAL_CEC_STATE_ERROR;
mbed_official 205:c41fc65bcfb4 791 }
mbed_official 205:c41fc65bcfb4 792
mbed_official 205:c41fc65bcfb4 793 /* CEC RX bit rising error interrupt occured --------------------------------------*/
mbed_official 205:c41fc65bcfb4 794 if((__HAL_CEC_GET_IT(hcec, CEC_ISR_BRE) != RESET) && (__HAL_CEC_GET_IT_SOURCE(hcec, CEC_IER_BREIE) != RESET))
mbed_official 205:c41fc65bcfb4 795 {
mbed_official 205:c41fc65bcfb4 796 __HAL_CEC_CLEAR_FLAG(hcec, CEC_ISR_BRE);
mbed_official 205:c41fc65bcfb4 797 hcec->State = HAL_CEC_STATE_ERROR;
mbed_official 205:c41fc65bcfb4 798 }
mbed_official 205:c41fc65bcfb4 799
mbed_official 205:c41fc65bcfb4 800 /* CEC RX short bit period error interrupt occured --------------------------------------*/
mbed_official 205:c41fc65bcfb4 801 if((__HAL_CEC_GET_IT(hcec, CEC_ISR_SBPE) != RESET) && (__HAL_CEC_GET_IT_SOURCE(hcec, CEC_IER_SBPEIE) != RESET))
mbed_official 205:c41fc65bcfb4 802 {
mbed_official 205:c41fc65bcfb4 803 __HAL_CEC_CLEAR_FLAG(hcec, CEC_ISR_SBPE);
mbed_official 205:c41fc65bcfb4 804 hcec->State = HAL_CEC_STATE_ERROR;
mbed_official 205:c41fc65bcfb4 805 }
mbed_official 205:c41fc65bcfb4 806
mbed_official 205:c41fc65bcfb4 807 /* CEC RX long bit period error interrupt occured --------------------------------------*/
mbed_official 205:c41fc65bcfb4 808 if((__HAL_CEC_GET_IT(hcec, CEC_ISR_LBPE) != RESET) && (__HAL_CEC_GET_IT_SOURCE(hcec, CEC_IER_LBPEIE) != RESET))
mbed_official 205:c41fc65bcfb4 809 {
mbed_official 205:c41fc65bcfb4 810 __HAL_CEC_CLEAR_FLAG(hcec, CEC_ISR_LBPE);
mbed_official 205:c41fc65bcfb4 811 hcec->State = HAL_CEC_STATE_ERROR;
mbed_official 205:c41fc65bcfb4 812 }
mbed_official 205:c41fc65bcfb4 813
mbed_official 205:c41fc65bcfb4 814 /* CEC RX missing acknowledge error interrupt occured --------------------------------------*/
mbed_official 205:c41fc65bcfb4 815 if((__HAL_CEC_GET_IT(hcec, CEC_ISR_RXACKE) != RESET) && (__HAL_CEC_GET_IT_SOURCE(hcec, CEC_IER_RXACKEIE) != RESET))
mbed_official 205:c41fc65bcfb4 816 {
mbed_official 205:c41fc65bcfb4 817 __HAL_CEC_CLEAR_FLAG(hcec, CEC_ISR_RXACKE);
mbed_official 205:c41fc65bcfb4 818 hcec->State = HAL_CEC_STATE_ERROR;
mbed_official 205:c41fc65bcfb4 819 }
mbed_official 205:c41fc65bcfb4 820
mbed_official 205:c41fc65bcfb4 821 if ((hcec->ErrorCode & CEC_ISR_ALL_ERROR) != 0)
mbed_official 205:c41fc65bcfb4 822 {
mbed_official 205:c41fc65bcfb4 823 HAL_CEC_ErrorCallback(hcec);
mbed_official 205:c41fc65bcfb4 824 }
mbed_official 205:c41fc65bcfb4 825
mbed_official 205:c41fc65bcfb4 826 /* CEC RX byte received interrupt ---------------------------------------------------*/
mbed_official 205:c41fc65bcfb4 827 if((__HAL_CEC_GET_IT(hcec, CEC_ISR_RXBR) != RESET) && (__HAL_CEC_GET_IT_SOURCE(hcec, CEC_IER_RXBRIE) != RESET))
mbed_official 205:c41fc65bcfb4 828 {
mbed_official 205:c41fc65bcfb4 829 /* RXBR IT is cleared during HAL_CEC_Transmit_IT processing */
mbed_official 205:c41fc65bcfb4 830 CEC_Receive_IT(hcec);
mbed_official 205:c41fc65bcfb4 831 }
mbed_official 205:c41fc65bcfb4 832
mbed_official 205:c41fc65bcfb4 833 /* CEC RX end received interrupt ---------------------------------------------------*/
mbed_official 205:c41fc65bcfb4 834 if((__HAL_CEC_GET_IT(hcec, CEC_ISR_RXEND) != RESET) && (__HAL_CEC_GET_IT_SOURCE(hcec, CEC_IER_RXENDIE) != RESET))
mbed_official 205:c41fc65bcfb4 835 {
mbed_official 205:c41fc65bcfb4 836 /* RXBR IT is cleared during HAL_CEC_Transmit_IT processing */
mbed_official 205:c41fc65bcfb4 837 CEC_Receive_IT(hcec);
mbed_official 205:c41fc65bcfb4 838 }
mbed_official 205:c41fc65bcfb4 839
mbed_official 205:c41fc65bcfb4 840
mbed_official 205:c41fc65bcfb4 841 /* CEC TX byte request interrupt ------------------------------------------------*/
mbed_official 205:c41fc65bcfb4 842 if((__HAL_CEC_GET_IT(hcec, CEC_ISR_TXBR) != RESET) &&(__HAL_CEC_GET_IT_SOURCE(hcec, CEC_IER_TXBRIE) != RESET))
mbed_official 205:c41fc65bcfb4 843 {
mbed_official 205:c41fc65bcfb4 844 /* TXBR IT is cleared during HAL_CEC_Transmit_IT processing */
mbed_official 205:c41fc65bcfb4 845 CEC_Transmit_IT(hcec);
mbed_official 205:c41fc65bcfb4 846 }
mbed_official 205:c41fc65bcfb4 847
mbed_official 205:c41fc65bcfb4 848 /* CEC TX end interrupt ------------------------------------------------*/
mbed_official 205:c41fc65bcfb4 849 if((__HAL_CEC_GET_IT(hcec, CEC_ISR_TXEND) != RESET) &&(__HAL_CEC_GET_IT_SOURCE(hcec, CEC_IER_TXENDIE) != RESET))
mbed_official 205:c41fc65bcfb4 850 {
mbed_official 205:c41fc65bcfb4 851 /* TXEND IT is cleared during HAL_CEC_Transmit_IT processing */
mbed_official 205:c41fc65bcfb4 852 CEC_Transmit_IT(hcec);
mbed_official 205:c41fc65bcfb4 853 }
mbed_official 205:c41fc65bcfb4 854
mbed_official 205:c41fc65bcfb4 855 }
mbed_official 205:c41fc65bcfb4 856
mbed_official 205:c41fc65bcfb4 857
mbed_official 205:c41fc65bcfb4 858 /**
mbed_official 205:c41fc65bcfb4 859 * @brief Tx Transfer completed callback
mbed_official 205:c41fc65bcfb4 860 * @param hcec: CEC handle
mbed_official 205:c41fc65bcfb4 861 * @retval None
mbed_official 205:c41fc65bcfb4 862 */
mbed_official 205:c41fc65bcfb4 863 __weak void HAL_CEC_TxCpltCallback(CEC_HandleTypeDef *hcec)
mbed_official 205:c41fc65bcfb4 864 {
mbed_official 205:c41fc65bcfb4 865 /* NOTE : This function should not be modified, when the callback is needed,
mbed_official 205:c41fc65bcfb4 866 the HAL_CEC_TxCpltCallback can be implemented in the user file
mbed_official 205:c41fc65bcfb4 867 */
mbed_official 205:c41fc65bcfb4 868 }
mbed_official 205:c41fc65bcfb4 869
mbed_official 205:c41fc65bcfb4 870 /**
mbed_official 205:c41fc65bcfb4 871 * @brief Rx Transfer completed callback
mbed_official 205:c41fc65bcfb4 872 * @param hcec: CEC handle
mbed_official 205:c41fc65bcfb4 873 * @retval None
mbed_official 205:c41fc65bcfb4 874 */
mbed_official 205:c41fc65bcfb4 875 __weak void HAL_CEC_RxCpltCallback(CEC_HandleTypeDef *hcec)
mbed_official 205:c41fc65bcfb4 876 {
mbed_official 205:c41fc65bcfb4 877 /* NOTE : This function should not be modified, when the callback is needed,
mbed_official 205:c41fc65bcfb4 878 the HAL_CEC_TxCpltCallback can be implemented in the user file
mbed_official 205:c41fc65bcfb4 879 */
mbed_official 205:c41fc65bcfb4 880 }
mbed_official 205:c41fc65bcfb4 881
mbed_official 205:c41fc65bcfb4 882 /**
mbed_official 205:c41fc65bcfb4 883 * @brief CEC error callbacks
mbed_official 205:c41fc65bcfb4 884 * @param hcec: CEC handle
mbed_official 205:c41fc65bcfb4 885 * @retval None
mbed_official 205:c41fc65bcfb4 886 */
mbed_official 205:c41fc65bcfb4 887 __weak void HAL_CEC_ErrorCallback(CEC_HandleTypeDef *hcec)
mbed_official 205:c41fc65bcfb4 888 {
mbed_official 205:c41fc65bcfb4 889 /* NOTE : This function should not be modified, when the callback is needed,
mbed_official 205:c41fc65bcfb4 890 the HAL_CEC_ErrorCallback can be implemented in the user file
mbed_official 205:c41fc65bcfb4 891 */
mbed_official 205:c41fc65bcfb4 892 }
mbed_official 205:c41fc65bcfb4 893
mbed_official 205:c41fc65bcfb4 894
mbed_official 205:c41fc65bcfb4 895 /**
mbed_official 205:c41fc65bcfb4 896 * @brief Send data in interrupt mode
mbed_official 205:c41fc65bcfb4 897 * @param hcec: CEC handle.
mbed_official 205:c41fc65bcfb4 898 * Function called under interruption only, once
mbed_official 205:c41fc65bcfb4 899 * interruptions have been enabled by HAL_CEC_Transmit_IT()
mbed_official 205:c41fc65bcfb4 900 * @retval HAL status
mbed_official 205:c41fc65bcfb4 901 */
mbed_official 205:c41fc65bcfb4 902 static HAL_StatusTypeDef CEC_Transmit_IT(CEC_HandleTypeDef *hcec)
mbed_official 205:c41fc65bcfb4 903 {
mbed_official 205:c41fc65bcfb4 904 /* if the IP is already busy or if there is a previous transmission
mbed_official 205:c41fc65bcfb4 905 already pending due to arbitration loss */
mbed_official 205:c41fc65bcfb4 906 if ((hcec->State == HAL_CEC_STATE_BUSY_TX)
mbed_official 205:c41fc65bcfb4 907 || (__HAL_CEC_GET_TRANSMISSION_START_FLAG(hcec) != RESET))
mbed_official 205:c41fc65bcfb4 908 {
mbed_official 205:c41fc65bcfb4 909 __HAL_LOCK(hcec);
mbed_official 205:c41fc65bcfb4 910 /* set state to BUSY TX, in case it wasn't set already (case
mbed_official 205:c41fc65bcfb4 911 * of transmission new attempt after arbitration loss) */
mbed_official 205:c41fc65bcfb4 912 if (hcec->State != HAL_CEC_STATE_BUSY_TX)
mbed_official 205:c41fc65bcfb4 913 {
mbed_official 205:c41fc65bcfb4 914 hcec->State = HAL_CEC_STATE_BUSY_TX;
mbed_official 205:c41fc65bcfb4 915 }
mbed_official 205:c41fc65bcfb4 916
mbed_official 205:c41fc65bcfb4 917 /* if all data have been sent */
mbed_official 205:c41fc65bcfb4 918 if(hcec->TxXferCount == 0)
mbed_official 205:c41fc65bcfb4 919 {
mbed_official 205:c41fc65bcfb4 920 /* Disable Peripheral to write CEC_IER register */
mbed_official 205:c41fc65bcfb4 921 __HAL_CEC_DISABLE(hcec);
mbed_official 205:c41fc65bcfb4 922
mbed_official 205:c41fc65bcfb4 923 /* Disable the CEC Transmission Interrupts */
mbed_official 205:c41fc65bcfb4 924 __HAL_CEC_DISABLE_IT(hcec, CEC_IER_TXBRIE|CEC_IER_TXENDIE);
mbed_official 205:c41fc65bcfb4 925 /* Disable the CEC Transmission Error Interrupts */
mbed_official 205:c41fc65bcfb4 926 __HAL_CEC_DISABLE_IT(hcec, CEC_IER_TX_ALL_ERR);
mbed_official 205:c41fc65bcfb4 927
mbed_official 205:c41fc65bcfb4 928 /* Enable the Peripheral */
mbed_official 205:c41fc65bcfb4 929 __HAL_CEC_ENABLE(hcec);
mbed_official 205:c41fc65bcfb4 930
mbed_official 205:c41fc65bcfb4 931 __HAL_CEC_CLEAR_FLAG(hcec,CEC_ISR_TXBR|CEC_ISR_TXEND);
mbed_official 205:c41fc65bcfb4 932
mbed_official 205:c41fc65bcfb4 933 hcec->State = HAL_CEC_STATE_READY;
mbed_official 205:c41fc65bcfb4 934 /* Call the Process Unlocked before calling the Tx call back API to give the possibility to
mbed_official 205:c41fc65bcfb4 935 start again the Transmission under the Tx call back API */
mbed_official 205:c41fc65bcfb4 936 __HAL_UNLOCK(hcec);
mbed_official 205:c41fc65bcfb4 937
mbed_official 205:c41fc65bcfb4 938 HAL_CEC_TxCpltCallback(hcec);
mbed_official 205:c41fc65bcfb4 939
mbed_official 205:c41fc65bcfb4 940 return HAL_OK;
mbed_official 205:c41fc65bcfb4 941 }
mbed_official 205:c41fc65bcfb4 942 else
mbed_official 205:c41fc65bcfb4 943 {
mbed_official 205:c41fc65bcfb4 944 if (hcec->TxXferCount == 1)
mbed_official 205:c41fc65bcfb4 945 {
mbed_official 205:c41fc65bcfb4 946 /* if this is the last byte transmission, set TX End of Message (TXEOM) bit */
mbed_official 205:c41fc65bcfb4 947 __HAL_CEC_LAST_BYTE_TX_SET(hcec);
mbed_official 205:c41fc65bcfb4 948 }
mbed_official 205:c41fc65bcfb4 949 /* clear Tx-Byte request flag */
mbed_official 205:c41fc65bcfb4 950 __HAL_CEC_CLEAR_FLAG(hcec,CEC_ISR_TXBR);
mbed_official 205:c41fc65bcfb4 951 hcec->Instance->TXDR = *hcec->pTxBuffPtr++;
mbed_official 205:c41fc65bcfb4 952 hcec->TxXferCount--;
mbed_official 205:c41fc65bcfb4 953
mbed_official 205:c41fc65bcfb4 954 /* Process Unlocked */
mbed_official 205:c41fc65bcfb4 955 __HAL_UNLOCK(hcec);
mbed_official 205:c41fc65bcfb4 956
mbed_official 205:c41fc65bcfb4 957 return HAL_OK;
mbed_official 205:c41fc65bcfb4 958 }
mbed_official 205:c41fc65bcfb4 959 }
mbed_official 205:c41fc65bcfb4 960 else
mbed_official 205:c41fc65bcfb4 961 {
mbed_official 205:c41fc65bcfb4 962 return HAL_BUSY;
mbed_official 205:c41fc65bcfb4 963 }
mbed_official 205:c41fc65bcfb4 964 }
mbed_official 205:c41fc65bcfb4 965
mbed_official 205:c41fc65bcfb4 966
mbed_official 205:c41fc65bcfb4 967 /**
mbed_official 205:c41fc65bcfb4 968 * @brief Receive data in interrupt mode.
mbed_official 205:c41fc65bcfb4 969 * @param hcec: CEC handle.
mbed_official 205:c41fc65bcfb4 970 * Function called under interruption only, once
mbed_official 205:c41fc65bcfb4 971 * interruptions have been enabled by HAL_CEC_Receive_IT()
mbed_official 205:c41fc65bcfb4 972 * @retval HAL status
mbed_official 205:c41fc65bcfb4 973 */
mbed_official 205:c41fc65bcfb4 974 static HAL_StatusTypeDef CEC_Receive_IT(CEC_HandleTypeDef *hcec)
mbed_official 205:c41fc65bcfb4 975 {
mbed_official 205:c41fc65bcfb4 976 uint32_t tempisr;
mbed_official 205:c41fc65bcfb4 977
mbed_official 205:c41fc65bcfb4 978 /* Three different conditions are tested to carry out the RX IT processing:
mbed_official 205:c41fc65bcfb4 979 * - the IP is in reception stand-by (the IP state is HAL_CEC_STATE_STANDBY_RX) and
mbed_official 205:c41fc65bcfb4 980 * the reception of the first byte is starting
mbed_official 205:c41fc65bcfb4 981 * - a message reception is already on-going (the IP state is HAL_CEC_STATE_BUSY_RX)
mbed_official 205:c41fc65bcfb4 982 * and a new byte is being received
mbed_official 205:c41fc65bcfb4 983 * - a transmission has just been started (the IP state is HAL_CEC_STATE_BUSY_TX)
mbed_official 205:c41fc65bcfb4 984 * but has been interrupted by a new message reception or discarded due to
mbed_official 205:c41fc65bcfb4 985 * arbitration loss: the reception of the first or higher priority message
mbed_official 205:c41fc65bcfb4 986 * (the arbitration winner) is starting */
mbed_official 205:c41fc65bcfb4 987 if ((hcec->State == HAL_CEC_STATE_STANDBY_RX)
mbed_official 205:c41fc65bcfb4 988 || (hcec->State == HAL_CEC_STATE_BUSY_RX)
mbed_official 205:c41fc65bcfb4 989 || (hcec->State == HAL_CEC_STATE_BUSY_TX))
mbed_official 205:c41fc65bcfb4 990 {
mbed_official 205:c41fc65bcfb4 991 /* reception is starting */
mbed_official 205:c41fc65bcfb4 992 hcec->State = HAL_CEC_STATE_BUSY_RX;
mbed_official 205:c41fc65bcfb4 993 tempisr = (uint32_t) (hcec->Instance->ISR);
mbed_official 205:c41fc65bcfb4 994 if ((tempisr & CEC_ISR_RXBR) != 0)
mbed_official 205:c41fc65bcfb4 995 {
mbed_official 205:c41fc65bcfb4 996 /* Process Locked */
mbed_official 205:c41fc65bcfb4 997 __HAL_LOCK(hcec);
mbed_official 205:c41fc65bcfb4 998 /* read received byte */
mbed_official 205:c41fc65bcfb4 999 *hcec->pRxBuffPtr++ = hcec->Instance->RXDR;
mbed_official 205:c41fc65bcfb4 1000 /* if last byte has been received */
mbed_official 205:c41fc65bcfb4 1001 if ((tempisr & CEC_ISR_RXEND) != 0)
mbed_official 205:c41fc65bcfb4 1002 {
mbed_official 205:c41fc65bcfb4 1003 /* clear IT */
mbed_official 205:c41fc65bcfb4 1004 __HAL_CEC_CLEAR_FLAG(hcec,CEC_ISR_RXBR|CEC_ISR_RXEND);
mbed_official 205:c41fc65bcfb4 1005 /* RX interrupts are not disabled at this point.
mbed_official 205:c41fc65bcfb4 1006 * Indeed, to disable the IT, the IP must be disabled first
mbed_official 205:c41fc65bcfb4 1007 * which resets the TXSOM flag. In case of arbitration loss,
mbed_official 205:c41fc65bcfb4 1008 * this leads to a transmission abort.
mbed_official 205:c41fc65bcfb4 1009 * Therefore, RX interruptions disabling if so required,
mbed_official 205:c41fc65bcfb4 1010 * is done in HAL_CEC_RxCpltCallback */
mbed_official 205:c41fc65bcfb4 1011
mbed_official 205:c41fc65bcfb4 1012 /* IP state is moved to READY.
mbed_official 205:c41fc65bcfb4 1013 * If the IP must remain in standby mode to listen
mbed_official 205:c41fc65bcfb4 1014 * any new message, it is up to HAL_CEC_RxCpltCallback
mbed_official 205:c41fc65bcfb4 1015 * to move it again to HAL_CEC_STATE_STANDBY_RX */
mbed_official 205:c41fc65bcfb4 1016 hcec->State = HAL_CEC_STATE_READY;
mbed_official 205:c41fc65bcfb4 1017
mbed_official 205:c41fc65bcfb4 1018 /* Call the Process Unlocked before calling the Rx call back API */
mbed_official 205:c41fc65bcfb4 1019 __HAL_UNLOCK(hcec);
mbed_official 205:c41fc65bcfb4 1020 HAL_CEC_RxCpltCallback(hcec);
mbed_official 205:c41fc65bcfb4 1021
mbed_official 205:c41fc65bcfb4 1022 return HAL_OK;
mbed_official 205:c41fc65bcfb4 1023 }
mbed_official 205:c41fc65bcfb4 1024 __HAL_CEC_CLEAR_FLAG(hcec, CEC_ISR_RXBR);
mbed_official 205:c41fc65bcfb4 1025
mbed_official 205:c41fc65bcfb4 1026 hcec->RxXferSize++;
mbed_official 205:c41fc65bcfb4 1027 /* Process Unlocked */
mbed_official 205:c41fc65bcfb4 1028 __HAL_UNLOCK(hcec);
mbed_official 205:c41fc65bcfb4 1029
mbed_official 205:c41fc65bcfb4 1030 return HAL_OK;
mbed_official 205:c41fc65bcfb4 1031 }
mbed_official 205:c41fc65bcfb4 1032 else
mbed_official 205:c41fc65bcfb4 1033 {
mbed_official 205:c41fc65bcfb4 1034 return HAL_BUSY;
mbed_official 205:c41fc65bcfb4 1035 }
mbed_official 205:c41fc65bcfb4 1036 }
mbed_official 205:c41fc65bcfb4 1037 else
mbed_official 205:c41fc65bcfb4 1038 {
mbed_official 205:c41fc65bcfb4 1039 return HAL_BUSY;
mbed_official 205:c41fc65bcfb4 1040 }
mbed_official 205:c41fc65bcfb4 1041 }
mbed_official 205:c41fc65bcfb4 1042
mbed_official 205:c41fc65bcfb4 1043
mbed_official 205:c41fc65bcfb4 1044
mbed_official 205:c41fc65bcfb4 1045 /**
mbed_official 205:c41fc65bcfb4 1046 * @}
mbed_official 205:c41fc65bcfb4 1047 */
mbed_official 205:c41fc65bcfb4 1048
mbed_official 205:c41fc65bcfb4 1049 /** @defgroup HAL_CEC_Group3 Peripheral Control function
mbed_official 205:c41fc65bcfb4 1050 * @brief CEC control functions
mbed_official 205:c41fc65bcfb4 1051 *
mbed_official 205:c41fc65bcfb4 1052 @verbatim
mbed_official 205:c41fc65bcfb4 1053 ===============================================================================
mbed_official 205:c41fc65bcfb4 1054 ##### Peripheral Control function #####
mbed_official 205:c41fc65bcfb4 1055 ===============================================================================
mbed_official 205:c41fc65bcfb4 1056 [..]
mbed_official 205:c41fc65bcfb4 1057 This subsection provides a set of functions allowing to control the CEC.
mbed_official 205:c41fc65bcfb4 1058 (+) HAL_CEC_GetState() API can be helpful to check in run-time the state of the CEC peripheral.
mbed_official 205:c41fc65bcfb4 1059 @endverbatim
mbed_official 205:c41fc65bcfb4 1060 * @{
mbed_official 205:c41fc65bcfb4 1061 */
mbed_official 205:c41fc65bcfb4 1062
mbed_official 205:c41fc65bcfb4 1063
mbed_official 205:c41fc65bcfb4 1064
mbed_official 205:c41fc65bcfb4 1065
mbed_official 205:c41fc65bcfb4 1066
mbed_official 205:c41fc65bcfb4 1067 /**
mbed_official 205:c41fc65bcfb4 1068 * @brief return the CEC state
mbed_official 205:c41fc65bcfb4 1069 * @param hcec: CEC handle
mbed_official 205:c41fc65bcfb4 1070 * @retval HAL state
mbed_official 205:c41fc65bcfb4 1071 */
mbed_official 205:c41fc65bcfb4 1072 HAL_CEC_StateTypeDef HAL_CEC_GetState(CEC_HandleTypeDef *hcec)
mbed_official 205:c41fc65bcfb4 1073 {
mbed_official 205:c41fc65bcfb4 1074 return hcec->State;
mbed_official 205:c41fc65bcfb4 1075 }
mbed_official 205:c41fc65bcfb4 1076
mbed_official 205:c41fc65bcfb4 1077 /**
mbed_official 205:c41fc65bcfb4 1078 * @brief Return the CEC error code
mbed_official 205:c41fc65bcfb4 1079 * @param hcec : pointer to a CEC_HandleTypeDef structure that contains
mbed_official 205:c41fc65bcfb4 1080 * the configuration information for the specified CEC.
mbed_official 205:c41fc65bcfb4 1081 * @retval CEC Error Code
mbed_official 205:c41fc65bcfb4 1082 */
mbed_official 205:c41fc65bcfb4 1083 uint32_t HAL_CEC_GetError(CEC_HandleTypeDef *hcec)
mbed_official 205:c41fc65bcfb4 1084 {
mbed_official 205:c41fc65bcfb4 1085 return hcec->ErrorCode;
mbed_official 205:c41fc65bcfb4 1086 }
mbed_official 205:c41fc65bcfb4 1087
mbed_official 205:c41fc65bcfb4 1088 /**
mbed_official 205:c41fc65bcfb4 1089 * @}
mbed_official 205:c41fc65bcfb4 1090 */
mbed_official 205:c41fc65bcfb4 1091
mbed_official 205:c41fc65bcfb4 1092 /**
mbed_official 205:c41fc65bcfb4 1093 * @}
mbed_official 205:c41fc65bcfb4 1094 */
mbed_official 205:c41fc65bcfb4 1095
mbed_official 205:c41fc65bcfb4 1096 #endif /* defined(STM32F042x6) || defined(STM32F048xx) || defined(STM32F051x8) || defined(STM32F058xx) || */
mbed_official 205:c41fc65bcfb4 1097 /* defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx)*/
mbed_official 205:c41fc65bcfb4 1098
mbed_official 205:c41fc65bcfb4 1099 #endif /* HAL_CEC_MODULE_ENABLED */
mbed_official 205:c41fc65bcfb4 1100 /**
mbed_official 205:c41fc65bcfb4 1101 * @}
mbed_official 205:c41fc65bcfb4 1102 */
mbed_official 205:c41fc65bcfb4 1103
mbed_official 205:c41fc65bcfb4 1104 /**
mbed_official 205:c41fc65bcfb4 1105 * @}
mbed_official 205:c41fc65bcfb4 1106 */
mbed_official 205:c41fc65bcfb4 1107
mbed_official 205:c41fc65bcfb4 1108 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/