stm320518_eval_cec.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. /**
  2. ******************************************************************************
  3. * @file stm320518_eval_cec.h
  4. * @author MCD Application Team
  5. * @version V1.0.0
  6. * @date 20-April-2012
  7. * @brief This file contains all the functions prototypes for the stm320518_eval_cec
  8. * firmware driver.
  9. ******************************************************************************
  10. * @attention
  11. *
  12. * <h2><center>&copy; COPYRIGHT 2012 STMicroelectronics</center></h2>
  13. *
  14. * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
  15. * You may not use this file except in compliance with the License.
  16. * You may obtain a copy of the License at:
  17. *
  18. * http://www.st.com/software_license_agreement_liberty_v2
  19. *
  20. * Unless required by applicable law or agreed to in writing, software
  21. * distributed under the License is distributed on an "AS IS" BASIS,
  22. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  23. * See the License for the specific language governing permissions and
  24. * limitations under the License.
  25. *
  26. ******************************************************************************
  27. */
  28. /* Define to prevent recursive inclusion -------------------------------------*/
  29. #ifndef __STM320518_EVAL_CEC_H
  30. #define __STM320518_EVAL_CEC_H
  31. #ifdef __cplusplus
  32. extern "C"
  33. {
  34. #endif
  35. /* Includes ------------------------------------------------------------------*/
  36. #include "stm320518_eval.h"
  37. /** @addtogroup Utilities
  38. * @{
  39. */
  40. /** @addtogroup STM32_EVAL
  41. * @{
  42. */
  43. /** @addtogroup STM320518_EVAL
  44. * @{
  45. */
  46. /** @defgroup STM320518_EVAL_CEC
  47. * @{
  48. */
  49. /** @defgroup STM320518_EVAL_CEC_Exported_Types
  50. * @{
  51. */
  52. typedef enum
  53. {
  54. HDMI_CEC_RX_OVERRUN = (1), /*!< CEC Receive overrun Error */
  55. HDMI_CEC_RX_BIT_RISING = (2), /*!< CEC Rx Bit Rising Error */
  56. HDMI_CEC_RX_SHORT_BIT_PERIOD = (3), /*!< CEC Rx Short Bit Period Error */
  57. HDMI_CEC_RX_LONG_BIT_PERIOD = (4), /*!< CEC Rx Long Bit Period Error */
  58. HDMI_CEC_RX_ACKNOWLEDGE = (5), /*!< CEC RX Acknowledge Error */
  59. HDMI_CEC_ARBITRATION_LOST = (6), /*!< Arbitration Lost Error */
  60. HDMI_CEC_TX_UNDERRUN = (7), /*!< CEC Transmit Underrun Error */
  61. HDMI_CEC_TX_ERROR = (8), /*!< CEC Transmit Error */
  62. HDMI_CEC_TX_ACKNOWLEDGE = (9), /*!< CEC TX Acknowledge Error */
  63. HDMI_CEC_DEVICE_UNREGISTRED = (10), /*!< CEC Device Unregistered */
  64. HDMI_CEC_TIMEOUT = (11), /*!< CEC TimeOut */
  65. HDMI_CEC_OK = (12) /*!< CEC OK */
  66. }HDMI_CEC_Error;
  67. typedef struct
  68. {
  69. uint8_t PhysicalAddress_A;
  70. uint8_t PhysicalAddress_B;
  71. uint8_t PhysicalAddress_C;
  72. uint8_t PhysicalAddress_D;
  73. uint8_t LogicalAddress;
  74. uint8_t DeviceType;
  75. }HDMI_CEC_Map;
  76. #define HDMI_CEC_TX_MESSAGE_LENGTH_MAX ((uint32_t)0x0000000E)
  77. #define HDMI_CEC_TIMEOUT_VALUE ((uint32_t)0x001FFFFF)
  78. /**
  79. * @brief CEC Init Structure definition
  80. */
  81. typedef struct
  82. {
  83. __IO uint8_t Header;
  84. __IO uint8_t Opcode;
  85. __IO uint8_t Operande[HDMI_CEC_TX_MESSAGE_LENGTH_MAX];
  86. __IO uint8_t TxMessageLength;
  87. __IO uint8_t RxMessageLength;
  88. }HDMI_CEC_Message;
  89. /**
  90. * @}
  91. */
  92. /** @defgroup STM320518_EVAL_CEC_Exported_Constants
  93. * @{
  94. */
  95. /**
  96. * @brief CEC device types
  97. */
  98. #define HDMI_CEC_TV 0x00
  99. #define HDMI_CEC_RECORDING 0x01
  100. #define HDMI_CEC_TUNER 0x03
  101. #define HDMI_CEC_PLAYBACK 0x04
  102. #define HDMI_CEC_AUDIOSYSTEM 0x05
  103. /**
  104. * @brief HDMI CEC I2C Interface pins
  105. */
  106. #define HDMI_CEC_I2C_SCL_PIN GPIO_Pin_6
  107. #define HDMI_CEC_I2C_SDA_PIN GPIO_Pin_7
  108. #define HDMI_CEC_I2C_SCL_PIN_SOURCE GPIO_PinSource6
  109. #define HDMI_CEC_I2C_SDA_PIN_SOURCE GPIO_PinSource7
  110. #define HDMI_CEC_I2C_GPIO_PORT GPIOB
  111. #define HDMI_CEC_I2C_GPIO_CLK RCC_AHBPeriph_GPIOB
  112. #define HDMI_CEC_I2C I2C1
  113. #define HDMI_CEC_I2C_CLK RCC_APB1Periph_I2C1
  114. #define HDMI_CEC_SINK_I2C_SCL_PIN GPIO_Pin_6
  115. #define HDMI_CEC_SINK_I2C_SDA_PIN GPIO_Pin_7
  116. #define HDMI_CEC_SINK_I2C_SCL_PIN_SOURCE GPIO_PinSource6
  117. #define HDMI_CEC_SINK_I2C_SDA_PIN_SOURCE GPIO_PinSource7
  118. #define HDMI_CEC_SINK_I2C_GPIO_PORT GPIOF
  119. #define HDMI_CEC_SINK_I2C_GPIO_CLK RCC_AHBPeriph_GPIOF
  120. #define HDMI_CEC_SINK_I2C I2C2
  121. #define HDMI_CEC_SINK_I2C_CLK RCC_APB1Periph_I2C2
  122. /**
  123. * @brief HDMI CEC HPD (Hot Plug Detect) Interface pin
  124. */
  125. #define HDMI_CEC_HPD_SINK_PIN GPIO_Pin_11
  126. #define HDMI_CEC_HPD_SINK_GPIO_PORT GPIOA
  127. #define HDMI_CEC_HPD_SINK_GPIO_CLK RCC_AHBPeriph_GPIOA
  128. /**
  129. * @brief HDMI CEC HPD (Hot Plug Detect) Interface pin
  130. */
  131. #define HDMI_CEC_HPD_SOURCE_PIN GPIO_Pin_8
  132. #define HDMI_CEC_HPD_SOURCE_GPIO_PORT GPIOA
  133. #define HDMI_CEC_HPD_SOURCE_GPIO_CLK RCC_AHBPeriph_GPIOA
  134. /**
  135. * @brief HDMI CEC Interface pin
  136. */
  137. #define HDMI_CEC_LINE_PIN GPIO_Pin_10
  138. #define HDMI_CEC_LINE_GPIO_PORT GPIOB
  139. #define HDMI_CEC_LINE_GPIO_CLK RCC_AHBPeriph_GPIOB
  140. #define HDMI_CEC_I2C_TIMING 0x00330E10
  141. #define HDMI_CEC_I2C_SLAVE_ADDRESS7 0xA0
  142. /**
  143. * @brief HDMI CEC Root (Mainly for TV with a fixed physical address (0.0.0.0))
  144. * If you want to configure the STM320518-EVAL board as CEC Root (Sink)
  145. * change the following define to 0x1
  146. */
  147. #define HDMI_CEC_ROOT 0x00
  148. /**
  149. * @brief To select if the DDC Channel will be used for physical address discovery
  150. * or not. To use the DDC Channel to read the EDID structure uncomment
  151. * the following line.
  152. * If the device is configured as HMDI source it should read his own physical
  153. * address from the sink that is connected to.
  154. */
  155. //#define HDMI_CEC_USE_DDC
  156. /**
  157. * @brief CEC version: V1.4
  158. */
  159. #define HDMI_CEC_VERSION 0x05 /* 0x04 For CEC version: V1.3.a */
  160. /**
  161. * @brief Reason for Abort feature
  162. */
  163. #define HDMI_CEC_UNRECOGNIZED_OPCODE 0x00
  164. #define HDMI_CEC_NOT_CORRECT_MODETORESPOND 0x01
  165. #define HDMI_CEC_CANNOTPROVIDE_SOURCE 0x02
  166. #define HDMI_CEC_INVALID_OPERAND 0x03
  167. #define HDMI_CEC_REFUSED 0x04
  168. /**
  169. * @brief HDMI CEC specific commands
  170. */
  171. #define HDMI_CEC_OPCODE_ACTIVE_SOURCE ((uint8_t) 0x82)
  172. #define HDMI_CEC_OPCODE_IMAGE_VIEW_ON ((uint8_t) 0x04)
  173. #define HDMI_CEC_OPCODE_TEXT_VIEW_ON ((uint8_t) 0x0D)
  174. #define HDMI_CEC_OPCODE_INACTIVE_SOURCE ((uint8_t) 0x9D)
  175. #define HDMI_CEC_OPCODE_REQUEST_ACTIVE_SOURCE ((uint8_t) 0x85)
  176. #define HDMI_CEC_OPCODE_ROUTING_CHANGE ((uint8_t) 0x80)
  177. #define HDMI_CEC_OPCODE_ROUTING_INFORMATION ((uint8_t) 0x81)
  178. #define HDMI_CEC_OPCODE_SET_STREAM_PATH ((uint8_t) 0x86)
  179. #define HDMI_CEC_OPCODE_STANDBY ((uint8_t) 0x36)
  180. #define HDMI_CEC_OPCODE_RECORD_OFF ((uint8_t) 0x0B)
  181. #define HDMI_CEC_OPCODE_RECORD_ON ((uint8_t) 0x09)
  182. #define HDMI_CEC_OPCODE_RECORD_STATUS ((uint8_t) 0x0A)
  183. #define HDMI_CEC_OPCODE_RECORD_TV_SCREEN ((uint8_t) 0x0F)
  184. #define HDMI_CEC_OPCODE_CLEAR_ANALOGUE_TIMER ((uint8_t) 0x33)
  185. #define HDMI_CEC_OPCODE_CLEAR_DIGITAL_TIMER ((uint8_t) 0x99)
  186. #define HDMI_CEC_OPCODE_CLEAR_EXTERNAL_TIMER ((uint8_t) 0xA1)
  187. #define HDMI_CEC_OPCODE_SET_ANALOGUE_TIMER ((uint8_t) 0x34)
  188. #define HDMI_CEC_OPCODE_SET_DIGITAL_TIMER ((uint8_t) 0x97)
  189. #define HDMI_CEC_OPCODE_SET_EXTERNAL_TIMER ((uint8_t) 0xA2)
  190. #define HDMI_CEC_OPCODE_SET_TIMER_PROGRAM_TITLE ((uint8_t) 0x67)
  191. #define HDMI_CEC_OPCODE_TIMER_CLEARED_STATUS ((uint8_t) 0x43)
  192. #define HDMI_CEC_OPCODE_TIMER_STATUS ((uint8_t) 0x35)
  193. #define HDMI_CEC_OPCODE_CEC_VERSION ((uint8_t) 0x9E)
  194. #define HDMI_CEC_OPCODE_GET_CEC_VERSION ((uint8_t) 0x9F)
  195. #define HDMI_CEC_OPCODE_GIVE_PHYSICAL_ADDRESS ((uint8_t) 0x83)
  196. #define HDMI_CEC_OPCODE_GET_MENU_LANGUAGE ((uint8_t) 0x91)
  197. #define HDMI_CEC_OPCODE_REPORT_PHYSICAL_ADDRESS ((uint8_t) 0x84)
  198. #define HDMI_CEC_OPCODE_SET_MENU_LANGUAGE ((uint8_t) 0x32)
  199. #define HDMI_CEC_OPCODE_DECK_CONTROL ((uint8_t) 0x42)
  200. #define HDMI_CEC_OPCODE_DECK_STATUS ((uint8_t) 0x1B)
  201. #define HDMI_CEC_OPCODE_GIVE_DECK_STATUS ((uint8_t) 0x1A)
  202. #define HDMI_CEC_OPCODE_PLAY ((uint8_t) 0x41)
  203. #define HDMI_CEC_OPCODE_GIVE_TUNER_DEVICE_STATUS ((uint8_t) 0x08)
  204. #define HDMI_CEC_OPCODE_SELECT_ANALOGUE_SERVICE ((uint8_t) 0x92)
  205. #define HDMI_CEC_OPCODE_SELECT_DIGITAL_SERVICE ((uint8_t) 0x93)
  206. #define HDMI_CEC_OPCODE_TUNER_DEVICE_STATUS ((uint8_t) 0x07)
  207. #define HDMI_CEC_OPCODE_TUNER_STEP_DECREMENT ((uint8_t) 0x06)
  208. #define HDMI_CEC_OPCODE_TUNER_STEP_INCREMENT ((uint8_t) 0x05)
  209. #define HDMI_CEC_OPCODE_DEVICE_VENDOR_ID ((uint8_t) 0x87)
  210. #define HDMI_CEC_OPCODE_GIVE_DEVICE_VENDOR_ID ((uint8_t) 0x8C)
  211. #define HDMI_CEC_OPCODE_VENDOR_COMMAND ((uint8_t) 0x89)
  212. #define HDMI_CEC_OPCODE_VENDOR_COMMAND_WITH_ID ((uint8_t) 0xA0)
  213. #define HDMI_CEC_OPCODE_VENDOR_REMOTE_BUTTON_DOWN ((uint8_t) 0x8A)
  214. #define HDMI_CEC_OPCODE_VENDOR_REMOTE_BUTTON_UP ((uint8_t) 0x8B)
  215. #define HDMI_CEC_OPCODE_SET_OSD_STRING ((uint8_t) 0x64)
  216. #define HDMI_CEC_OPCODE_GIVE_OSD_NAME ((uint8_t) 0x46)
  217. #define HDMI_CEC_OPCODE_SET_OSD_NAME ((uint8_t) 0x47)
  218. #define HDMI_CEC_OPCODE_MENU_REQUEST ((uint8_t) 0x8D)
  219. #define HDMI_CEC_OPCODE_MENU_STATUS ((uint8_t) 0x8E)
  220. #define HDMI_CEC_OPCODE_USER_CONTROL_PRESSED ((uint8_t) 0x44)
  221. #define HDMI_CEC_OPCODE_USER_CONTROL_RELEASED ((uint8_t) 0x45)
  222. #define HDMI_CEC_OPCODE_GIVE_DEVICE_POWER_STATUS ((uint8_t) 0x8F)
  223. #define HDMI_CEC_OPCODE_REPORT_POWER_STATUS ((uint8_t) 0x90)
  224. #define HDMI_CEC_OPCODE_FEATURE_ABORT ((uint8_t) 0x00)
  225. #define HDMI_CEC_OPCODE_ABORT ((uint8_t) 0xFF)
  226. #define HDMI_CEC_OPCODE_GIVE_AUDIO_STATUS ((uint8_t) 0x71)
  227. #define HDMI_CEC_OPCODE_GIVE_SYSTEM_AUDIO_MODE_STATUS ((uint8_t) 0x7D)
  228. #define HDMI_CEC_OPCODE_REPORT_AUDIO_STATUS ((uint8_t) 0x7A)
  229. #define HDMI_CEC_OPCODE_SET_SYSTEM_AUDIO_MODE ((uint8_t) 0x72)
  230. #define HDMI_CEC_OPCODE_SYSTEM_AUDIO_MODE_REQUEST ((uint8_t) 0x70)
  231. #define HDMI_CEC_OPCODE_SYSTEM_AUDIO_MODE_STATUS ((uint8_t) 0x7E)
  232. #define HDMI_CEC_OPCODE_SET_AUDIO_RATE ((uint8_t) 0x9A)
  233. /**
  234. * @}
  235. */
  236. /** @defgroup STM320518_EVAL_CEC_Exported_Macros
  237. * @{
  238. */
  239. /**
  240. * @}
  241. */
  242. /** @defgroup STM32100B_EVAL_CEC_Exported_Macros
  243. * @{
  244. */
  245. /* HDMI_CEC_HPD: HDMI HPD pin low */
  246. #define HDMI_CEC_HPD_LOW() GPIO_ResetBits(HDMI_CEC_HPD_GPIO_PORT, HDMI_CEC_HPD_PIN)
  247. /* HDMI_CEC_HPD: HDMI HPD pin high */
  248. #define HDMI_CEC_HPD_HIGH() GPIO_SetBits(HDMI_CEC_HPD_SINK_GPIO_PORT, HDMI_CEC_HPD_SINK_PIN)
  249. /**
  250. * @}
  251. */
  252. /** @defgroup STM320518_EVAL_CEC_Exported_Functions
  253. * @{
  254. */
  255. HDMI_CEC_Error HDMI_CEC_Init(void);
  256. HDMI_CEC_Error HDMI_CEC_TransmitMessage(HDMI_CEC_Message *HDMI_CEC_TX_MessageStructure);
  257. HDMI_CEC_Error HDMI_CEC_GetErrorStatus (void);
  258. void HDMI_CEC_ProcessIRQSrc(void);
  259. HDMI_CEC_Error HDMI_CEC_ReportPhysicalAddress(void);
  260. void HDMI_CEC_CommandCallBack(void);
  261. HDMI_CEC_Error HDMI_CEC_CheckConnectedDevices(void);
  262. #ifdef __cplusplus
  263. }
  264. #endif
  265. #endif /* __STM320518_EVAL_CEC_H */
  266. /**
  267. * @}
  268. */
  269. /**
  270. * @}
  271. */
  272. /**
  273. * @}
  274. */
  275. /**
  276. * @}
  277. */
  278. /**
  279. * @}
  280. */
  281. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/