STM32F37 Standard Peripheral bibliotheek  1.0
ST Microelectronics bibliotheek documentatie voor de STM32F37 Standard Peripheral Library
 All Data Structures Files Functions Variables Enumerations Enumerator Groups
stm32f37x_cec.c File Reference

This file provides firmware functions to manage the following functionalities of the Consumer Electronics Control (CEC) peripheral: More...

#include "stm32f37x_cec.h"
#include "stm32f37x_rcc.h"


#define BROADCAST_ADDRESS   ((uint32_t)0x0000F) /* Broadcast address */
#define CFGR_CLEAR_MASK   ((uint32_t)0x7000FE00) /* CFGR register Mask */
#define CR_OFFSET   (CEC_OFFSET + 0x00)
#define CECEN_BitNumber   0x00
#define CR_CECEN_BB   (PERIPH_BB_BASE + (CR_OFFSET * 32) + (CECEN_BitNumber * 4))
#define TXSOM_BitNumber   0x01
#define CR_TXSOM_BB   (PERIPH_BB_BASE + (CR_OFFSET * 32) + (TXSOM_BitNumber * 4))
#define TXEOM_BitNumber   0x02
#define CR_TXEOM_BB   (PERIPH_BB_BASE + (CR_OFFSET * 32) + (TXEOM_BitNumber * 4))
#define CFGR_OFFSET   (CEC_OFFSET + 0x04)
#define LSTN_BitNumber   0x1F
#define CFGR_LSTN_BB   (PERIPH_BB_BASE + (CFGR_OFFSET * 32) + (LSTN_BitNumber * 4))


void CEC_DeInit (void)
 Deinitializes all CEC peripheral registers to their default reset values. More...
void CEC_Init (CEC_InitTypeDef *CEC_InitStruct)
 Initializes the CEC peripheral according to the specified parameters in the CEC_InitStruct. More...
void CEC_StructInit (CEC_InitTypeDef *CEC_InitStruct)
 Fills each CEC_InitStruct member with its default value. More...
void CEC_Cmd (FunctionalState NewState)
 Enables or disables the CEC peripheral. More...
void CEC_ListenModeCmd (FunctionalState NewState)
 Enables or disables the CEC Listen Mode. More...
void CEC_OwnAddressConfig (uint8_t CEC_OwnAddress)
 Defines the Own Address of the CEC device. More...
void CEC_OwnAddressClear (void)
 Clears the Own Address of the CEC device. More...
void CEC_SendData (uint8_t Data)
 Transmits single data through the CEC peripheral. More...
uint8_t CEC_ReceiveData (void)
 Returns the most recent received data by the CEC peripheral. More...
void CEC_StartOfMessage (void)
 Starts a new message. More...
void CEC_EndOfMessage (void)
 Transmits message with an EOM bit. More...
void CEC_ITConfig (uint16_t CEC_IT, FunctionalState NewState)
 Enables or disables the selected CEC interrupts. More...
FlagStatus CEC_GetFlagStatus (uint16_t CEC_FLAG)
 Gets the CEC flag status. More...
void CEC_ClearFlag (uint16_t CEC_FLAG)
 Clears the CEC's pending flags. More...
ITStatus CEC_GetITStatus (uint16_t CEC_IT)
 Checks whether the specified CEC interrupt has occurred or not. More...
void CEC_ClearITPendingBit (uint16_t CEC_IT)
 Clears the CEC's interrupt pending bits. More...

Detailed Description

This file provides firmware functions to manage the following functionalities of the Consumer Electronics Control (CEC) peripheral:

MCD Application Team
  • Initialization and Configuration
  • Data transfers functions
  • Interrupts and flags management
                          ##### CEC features #####
    [..] This device provides some features:
         (#) Supports HDMI-CEC specification 1.4.
         (#) Supports two source clocks(HSI/244 or LSE).
         (#) Works in stop mode(without APB clock, but with CEC clock 32KHz).
             It can genarate an interrupt in the CEC clock domain that the CPU 
             wakes up from the low power mode.
         (#) Configurable Signal Free Time before of transmission start. The 
             number of nominal data bit periods waited before transmission can be
             ruled by Hardware or Software.
         (#) Configurable Peripheral Address (multi-addressing configuration).
         (#) Supports listen mode.The CEC Messages addressed to different destination
             can be received without interfering with CEC bus when Listen mode option is enabled.
         (#) Configurable Rx-Tolerance(Standard and Extended tolerance margin).
         (#) Error detection with configurable error bit generation.
         (#) Arbitration lost error in the case of two CEC devices starting at the same time.

                          ##### How to use this driver ##### 
    [..] This driver provides functions to configure and program the CEC device,
     follow steps below:
         (#) The source clock can be configured using:
             (++) RCC_CECCLKConfig(RCC_CECCLK_HSI_Div244) for HSI(Default) 
             (++) RCC_CECCLKConfig(RCC_CECCLK_LSE) for LSE.
         (#) Enable CEC peripheral clock using RCC_APBPeriphClockCmd(RCC_APBPeriph_CEC, ENABLE).
         (#) Peripherals alternate function.
             (++) Connect the pin to the desired peripherals' Alternate Function (AF) using 
             GPIO_PinAFConfig() function.
             (++) Configure the desired pin in alternate function by:
             GPIO_InitStruct->GPIO_Mode = GPIO_Mode_AF.
             (++) Select the type open-drain and output speed via GPIO_OType 
             and GPIO_Speed members.
             (++) Call GPIO_Init() function.
         (#) Configure the Signal Free Time, Rx Tolerance, Stop reception generation 
             and Bit error generation using the CEC_Init() function.
             The function CEC_Init() must be called when the CEC peripheral is disabled.
         (#) Configure the CEC own address by calling the fuction CEC_OwnAddressConfig().
         (#) Optionally, you can configure the Listen mode using the function CEC_ListenModeCmd().
         (#) Enable the NVIC and the corresponding interrupt using the function 
             CEC_ITConfig() if you need to use interrupt mode.
             CEC_ITConfig() must be called before enabling the CEC peripheral.
         (#) Enable the CEC using the CEC_Cmd() function.
         (#) Charge the first data byte in the TXDR register using CEC_SendDataByte().
         (#) Enable the transmission of the Byte of a CEC message using CEC_StartOfMessage() 
         (#) Transmit single data through the CEC peripheral using CEC_SendDataByte() 
             and Receive the last transmitted byte using CEC_ReceiveDataByte().
         (#) Enable the CEC_EndOfMessage() in order to indicate the last byte of the message.
         (@) If the listen mode is enabled, Stop reception generation and Bit error generation 
             must be in reset state.
         (@) If the CEC message consists of only 1 byte, the function CEC_EndOfMessage()
             must be called before CEC_StartOfMessage().

© COPYRIGHT 2012 STMicroelectronics

Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); You may not use this file except in compliance with the License. You may obtain a copy of the License at:

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.