stm3210e_eval.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  1. /**
  2. ******************************************************************************
  3. * @file stm3210e_eval.c
  4. * @author MCD Application Team
  5. * @version V4.5.0
  6. * @date 07-March-2011
  7. * @brief This file provides
  8. * - set of firmware functions to manage Leds, push-button and COM ports
  9. * - low level initialization functions for SD card (on SDIO), SPI serial
  10. * flash (sFLASH) and temperature sensor (LM75)
  11. * available on STM3210E-EVAL evaluation board from STMicroelectronics.
  12. ******************************************************************************
  13. * @attention
  14. *
  15. * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  16. * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
  17. * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
  18. * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
  19. * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
  20. * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  21. *
  22. * <h2><center>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>
  23. ******************************************************************************
  24. */
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "stm3210e_eval.h"
  27. #include "stm32f10x_spi.h"
  28. //#include "stm32f10x_i2c.h"
  29. //#include "stm32f10x_sdio.h"
  30. //#include "stm32f10x_dma.h"
  31. /** @addtogroup Utilities
  32. * @{
  33. */
  34. /** @addtogroup STM32_EVAL
  35. * @{
  36. */
  37. /** @addtogroup STM3210E_EVAL
  38. * @{
  39. */
  40. /** @defgroup STM3210E_EVAL_LOW_LEVEL
  41. * @brief This file provides firmware functions to manage Leds, push-buttons,
  42. * COM ports, SD card on SDIO, serial flash (sFLASH), serial EEPROM (sEE)
  43. * and temperature sensor (LM75) available on STM3210E-EVAL evaluation
  44. * board from STMicroelectronics.
  45. * @{
  46. */
  47. /** @defgroup STM3210E_EVAL_LOW_LEVEL_Private_TypesDefinitions
  48. * @{
  49. */
  50. /**
  51. * @}
  52. */
  53. /** @defgroup STM3210E_EVAL_LOW_LEVEL_Private_Defines
  54. * @{
  55. */
  56. /**
  57. * @}
  58. */
  59. /** @defgroup STM3210E_EVAL_LOW_LEVEL_Private_Macros
  60. * @{
  61. */
  62. /**
  63. * @}
  64. */
  65. /** @defgroup STM3210E_EVAL_LOW_LEVEL_Private_Variables
  66. * @{
  67. */
  68. //GPIO_TypeDef* GPIO_PORT[LEDn] = {LED1_GPIO_PORT, LED2_GPIO_PORT, LED3_GPIO_PORT,
  69. // LED4_GPIO_PORT};
  70. //const uint16_t GPIO_PIN[LEDn] = {LED1_PIN, LED2_PIN, LED3_PIN,
  71. // LED4_PIN};
  72. //const uint32_t GPIO_CLK[LEDn] = {LED1_GPIO_CLK, LED2_GPIO_CLK, LED3_GPIO_CLK,
  73. // LED4_GPIO_CLK};
  74. //
  75. //GPIO_TypeDef* BUTTON_PORT[BUTTONn] = {WAKEUP_BUTTON_GPIO_PORT, TAMPER_BUTTON_GPIO_PORT,
  76. // KEY_BUTTON_GPIO_PORT, RIGHT_BUTTON_GPIO_PORT,
  77. // LEFT_BUTTON_GPIO_PORT, UP_BUTTON_GPIO_PORT,
  78. // DOWN_BUTTON_GPIO_PORT, SEL_BUTTON_GPIO_PORT};
  79. //
  80. //const uint16_t BUTTON_PIN[BUTTONn] = {WAKEUP_BUTTON_PIN, TAMPER_BUTTON_PIN,
  81. // KEY_BUTTON_PIN, RIGHT_BUTTON_PIN,
  82. // LEFT_BUTTON_PIN, UP_BUTTON_PIN,
  83. // DOWN_BUTTON_PIN, SEL_BUTTON_PIN};
  84. //
  85. //const uint32_t BUTTON_CLK[BUTTONn] = {WAKEUP_BUTTON_GPIO_CLK, TAMPER_BUTTON_GPIO_CLK,
  86. // KEY_BUTTON_GPIO_CLK, RIGHT_BUTTON_GPIO_CLK,
  87. // LEFT_BUTTON_GPIO_CLK, UP_BUTTON_GPIO_CLK,
  88. // DOWN_BUTTON_GPIO_CLK, SEL_BUTTON_GPIO_CLK};
  89. //
  90. //const uint16_t BUTTON_EXTI_LINE[BUTTONn] = {WAKEUP_BUTTON_EXTI_LINE,
  91. // TAMPER_BUTTON_EXTI_LINE,
  92. // KEY_BUTTON_EXTI_LINE,
  93. // RIGHT_BUTTON_EXTI_LINE,
  94. // LEFT_BUTTON_EXTI_LINE,
  95. // UP_BUTTON_EXTI_LINE,
  96. // DOWN_BUTTON_EXTI_LINE,
  97. // SEL_BUTTON_EXTI_LINE};
  98. //
  99. //const uint16_t BUTTON_PORT_SOURCE[BUTTONn] = {WAKEUP_BUTTON_EXTI_PORT_SOURCE,
  100. // TAMPER_BUTTON_EXTI_PORT_SOURCE,
  101. // KEY_BUTTON_EXTI_PORT_SOURCE,
  102. // RIGHT_BUTTON_EXTI_PORT_SOURCE,
  103. // LEFT_BUTTON_EXTI_PORT_SOURCE,
  104. // UP_BUTTON_EXTI_PORT_SOURCE,
  105. // DOWN_BUTTON_EXTI_PORT_SOURCE,
  106. // SEL_BUTTON_EXTI_PORT_SOURCE};
  107. //
  108. //const uint16_t BUTTON_PIN_SOURCE[BUTTONn] = {WAKEUP_BUTTON_EXTI_PIN_SOURCE,
  109. // TAMPER_BUTTON_EXTI_PIN_SOURCE,
  110. // KEY_BUTTON_EXTI_PIN_SOURCE,
  111. // RIGHT_BUTTON_EXTI_PIN_SOURCE,
  112. // LEFT_BUTTON_EXTI_PIN_SOURCE,
  113. // UP_BUTTON_EXTI_PIN_SOURCE,
  114. // DOWN_BUTTON_EXTI_PIN_SOURCE,
  115. // SEL_BUTTON_EXTI_PIN_SOURCE};
  116. //
  117. //const uint16_t BUTTON_IRQn[BUTTONn] = {WAKEUP_BUTTON_EXTI_IRQn, TAMPER_BUTTON_EXTI_IRQn,
  118. // KEY_BUTTON_EXTI_IRQn, RIGHT_BUTTON_EXTI_IRQn,
  119. // LEFT_BUTTON_EXTI_IRQn, UP_BUTTON_EXTI_IRQn,
  120. // DOWN_BUTTON_EXTI_IRQn, SEL_BUTTON_EXTI_IRQn};
  121. //
  122. //USART_TypeDef* COM_USART[COMn] = {EVAL_COM1, EVAL_COM2};
  123. //
  124. //GPIO_TypeDef* COM_TX_PORT[COMn] = {EVAL_COM1_TX_GPIO_PORT, EVAL_COM2_TX_GPIO_PORT};
  125. //
  126. //GPIO_TypeDef* COM_RX_PORT[COMn] = {EVAL_COM1_RX_GPIO_PORT, EVAL_COM2_RX_GPIO_PORT};
  127. //
  128. //const uint32_t COM_USART_CLK[COMn] = {EVAL_COM1_CLK, EVAL_COM2_CLK};
  129. //
  130. //const uint32_t COM_TX_PORT_CLK[COMn] = {EVAL_COM1_TX_GPIO_CLK, EVAL_COM2_TX_GPIO_CLK};
  131. //
  132. //const uint32_t COM_RX_PORT_CLK[COMn] = {EVAL_COM1_RX_GPIO_CLK, EVAL_COM2_RX_GPIO_CLK};
  133. //
  134. //const uint16_t COM_TX_PIN[COMn] = {EVAL_COM1_TX_PIN, EVAL_COM2_TX_PIN};
  135. //
  136. //const uint16_t COM_RX_PIN[COMn] = {EVAL_COM1_RX_PIN, EVAL_COM2_RX_PIN};
  137. /**
  138. * @}
  139. */
  140. /** @defgroup STM3210E_EVAL_LOW_LEVEL_Private_FunctionPrototypes
  141. * @{
  142. */
  143. /**
  144. * @}
  145. */
  146. /** @defgroup STM3210E_EVAL_LOW_LEVEL_Private_Functions
  147. * @{
  148. */
  149. /**
  150. * @brief Configures LED GPIO.
  151. * @param Led: Specifies the Led to be configured.
  152. * This parameter can be one of following parameters:
  153. * @arg LED1
  154. * @arg LED2
  155. * @arg LED3
  156. * @arg LED4
  157. * @retval None
  158. */
  159. //void STM_EVAL_LEDInit(Led_TypeDef Led)
  160. //{
  161. // GPIO_InitTypeDef GPIO_InitStructure;
  162. //
  163. // /* Enable the GPIO_LED Clock */
  164. // RCC_APB2PeriphClockCmd(GPIO_CLK[Led], ENABLE);
  165. //
  166. // /* Configure the GPIO_LED pin */
  167. // GPIO_InitStructure.GPIO_Pin = GPIO_PIN[Led];
  168. // GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  169. // GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  170. //
  171. // GPIO_Init(GPIO_PORT[Led], &GPIO_InitStructure);
  172. //}
  173. /**
  174. * @brief Turns selected LED On.
  175. * @param Led: Specifies the Led to be set on.
  176. * This parameter can be one of following parameters:
  177. * @arg LED1
  178. * @arg LED2
  179. * @arg LED3
  180. * @arg LED4
  181. * @retval None
  182. */
  183. //void STM_EVAL_LEDOn(Led_TypeDef Led)
  184. //{
  185. // GPIO_PORT[Led]->BSRR = GPIO_PIN[Led];
  186. //}
  187. /**
  188. * @brief Turns selected LED Off.
  189. * @param Led: Specifies the Led to be set off.
  190. * This parameter can be one of following parameters:
  191. * @arg LED1
  192. * @arg LED2
  193. * @arg LED3
  194. * @arg LED4
  195. * @retval None
  196. */
  197. //void STM_EVAL_LEDOff(Led_TypeDef Led)
  198. //{
  199. // GPIO_PORT[Led]->BRR = GPIO_PIN[Led];
  200. //}
  201. /**
  202. * @brief Toggles the selected LED.
  203. * @param Led: Specifies the Led to be toggled.
  204. * This parameter can be one of following parameters:
  205. * @arg LED1
  206. * @arg LED2
  207. * @arg LED3
  208. * @arg LED4
  209. * @retval None
  210. */
  211. //void STM_EVAL_LEDToggle(Led_TypeDef Led)
  212. //{
  213. // GPIO_PORT[Led]->ODR ^= GPIO_PIN[Led];
  214. //}
  215. /**
  216. * @brief Configures Button GPIO and EXTI Line.
  217. * @param Button: Specifies the Button to be configured.
  218. * This parameter can be one of following parameters:
  219. * @arg BUTTON_WAKEUP: Wakeup Push Button
  220. * @arg BUTTON_TAMPER: Tamper Push Button
  221. * @arg BUTTON_KEY: Key Push Button
  222. * @arg BUTTON_RIGHT: Joystick Right Push Button
  223. * @arg BUTTON_LEFT: Joystick Left Push Button
  224. * @arg BUTTON_UP: Joystick Up Push Button
  225. * @arg BUTTON_DOWN: Joystick Down Push Button
  226. * @arg BUTTON_SEL: Joystick Sel Push Button
  227. * @param Button_Mode: Specifies Button mode.
  228. * This parameter can be one of following parameters:
  229. * @arg BUTTON_MODE_GPIO: Button will be used as simple IO
  230. * @arg BUTTON_MODE_EXTI: Button will be connected to EXTI line with interrupt
  231. * generation capability
  232. * @retval None
  233. */
  234. //void STM_EVAL_PBInit(Button_TypeDef Button, ButtonMode_TypeDef Button_Mode)
  235. //{
  236. // GPIO_InitTypeDef GPIO_InitStructure;
  237. // EXTI_InitTypeDef EXTI_InitStructure;
  238. // NVIC_InitTypeDef NVIC_InitStructure;
  239. //
  240. // /* Enable the BUTTON Clock */
  241. // RCC_APB2PeriphClockCmd(BUTTON_CLK[Button] | RCC_APB2Periph_AFIO, ENABLE);
  242. //
  243. // /* Configure Button pin as input floating */
  244. // GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
  245. // GPIO_InitStructure.GPIO_Pin = BUTTON_PIN[Button];
  246. // GPIO_Init(BUTTON_PORT[Button], &GPIO_InitStructure);
  247. //
  248. //
  249. // if (Button_Mode == BUTTON_MODE_EXTI)
  250. // {
  251. // /* Connect Button EXTI Line to Button GPIO Pin */
  252. // GPIO_EXTILineConfig(BUTTON_PORT_SOURCE[Button], BUTTON_PIN_SOURCE[Button]);
  253. //
  254. // /* Configure Button EXTI line */
  255. // EXTI_InitStructure.EXTI_Line = BUTTON_EXTI_LINE[Button];
  256. // EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
  257. //
  258. // if(Button != BUTTON_WAKEUP)
  259. // {
  260. // EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
  261. // }
  262. // else
  263. // {
  264. // EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
  265. // }
  266. // EXTI_InitStructure.EXTI_LineCmd = ENABLE;
  267. // EXTI_Init(&EXTI_InitStructure);
  268. //
  269. // /* Enable and set Button EXTI Interrupt to the lowest priority */
  270. // NVIC_InitStructure.NVIC_IRQChannel = BUTTON_IRQn[Button];
  271. // NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0F;
  272. // NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0F;
  273. // NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  274. //
  275. // NVIC_Init(&NVIC_InitStructure);
  276. // }
  277. //}
  278. /**
  279. * @brief Returns the selected Button state.
  280. * @param Button: Specifies the Button to be checked.
  281. * This parameter can be one of following parameters:
  282. * @arg BUTTON_WAKEUP: Wakeup Push Button
  283. * @arg BUTTON_TAMPER: Tamper Push Button
  284. * @arg BUTTON_KEY: Key Push Button
  285. * @arg BUTTON_RIGHT: Joystick Right Push Button
  286. * @arg BUTTON_LEFT: Joystick Left Push Button
  287. * @arg BUTTON_UP: Joystick Up Push Button
  288. * @arg BUTTON_DOWN: Joystick Down Push Button
  289. * @arg BUTTON_SEL: Joystick Sel Push Button
  290. * @retval The Button GPIO pin value.
  291. */
  292. //uint32_t STM_EVAL_PBGetState(Button_TypeDef Button)
  293. //{
  294. // return GPIO_ReadInputDataBit(BUTTON_PORT[Button], BUTTON_PIN[Button]);
  295. //}
  296. /**
  297. * @brief Configures COM port.
  298. * @param COM: Specifies the COM port to be configured.
  299. * This parameter can be one of following parameters:
  300. * @arg COM1
  301. * @arg COM2
  302. * @param USART_InitStruct: pointer to a USART_InitTypeDef structure that
  303. * contains the configuration information for the specified USART peripheral.
  304. * @retval None
  305. */
  306. //void STM_EVAL_COMInit(COM_TypeDef COM, USART_InitTypeDef* USART_InitStruct)
  307. //{
  308. // GPIO_InitTypeDef GPIO_InitStructure;
  309. //
  310. // /* Enable GPIO clock */
  311. // RCC_APB2PeriphClockCmd(COM_TX_PORT_CLK[COM] | COM_RX_PORT_CLK[COM] | RCC_APB2Periph_AFIO, ENABLE);
  312. //
  313. // /* Enable UART clock */
  314. // if (COM == COM1)
  315. // {
  316. // RCC_APB2PeriphClockCmd(COM_USART_CLK[COM], ENABLE);
  317. // }
  318. // else
  319. // {
  320. // RCC_APB1PeriphClockCmd(COM_USART_CLK[COM], ENABLE);
  321. // }
  322. //
  323. // /* Configure USART Tx as alternate function push-pull */
  324. // GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
  325. // GPIO_InitStructure.GPIO_Pin = COM_TX_PIN[COM];
  326. // GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  327. // GPIO_Init(COM_TX_PORT[COM], &GPIO_InitStructure);
  328. //
  329. // /* Configure USART Rx as input floating */
  330. // GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
  331. // GPIO_InitStructure.GPIO_Pin = COM_RX_PIN[COM];
  332. // GPIO_Init(COM_RX_PORT[COM], &GPIO_InitStructure);
  333. //
  334. // /* USART configuration */
  335. // USART_Init(COM_USART[COM], USART_InitStruct);
  336. //
  337. // /* Enable USART */
  338. // USART_Cmd(COM_USART[COM], ENABLE);
  339. //}
  340. /**
  341. * @brief DeInitializes the SDIO interface.
  342. * @param None
  343. * @retval None
  344. */
  345. //void SD_LowLevel_DeInit(void)
  346. //{
  347. // GPIO_InitTypeDef GPIO_InitStructure;
  348. //
  349. // /*!< Disable SDIO Clock */
  350. // SDIO_ClockCmd(DISABLE);
  351. //
  352. // /*!< Set Power State to OFF */
  353. // SDIO_SetPowerState(SDIO_PowerState_OFF);
  354. //
  355. // /*!< DeInitializes the SDIO peripheral */
  356. // SDIO_DeInit();
  357. //
  358. // /*!< Disable the SDIO AHB Clock */
  359. // RCC_AHBPeriphClockCmd(RCC_AHBPeriph_SDIO, DISABLE);
  360. //
  361. // /*!< Configure PC.08, PC.09, PC.10, PC.11, PC.12 pin: D0, D1, D2, D3, CLK pin */
  362. // GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12;
  363. // GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
  364. // GPIO_Init(GPIOC, &GPIO_InitStructure);
  365. //
  366. // /*!< Configure PD.02 CMD line */
  367. // GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
  368. // GPIO_Init(GPIOD, &GPIO_InitStructure);
  369. //}
  370. /**
  371. * @brief Initializes the SD Card and put it into StandBy State (Ready for
  372. * data transfer).
  373. * @param None
  374. * @retval None
  375. */
  376. //void SD_LowLevel_Init(void)
  377. //{
  378. // GPIO_InitTypeDef GPIO_InitStructure;
  379. //
  380. // /*!< GPIOC and GPIOD Periph clock enable */
  381. // RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD | SD_DETECT_GPIO_CLK, ENABLE);
  382. //
  383. // /*!< Configure PC.08, PC.09, PC.10, PC.11, PC.12 pin: D0, D1, D2, D3, CLK pin */
  384. // GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12;
  385. // GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  386. // GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
  387. // GPIO_Init(GPIOC, &GPIO_InitStructure);
  388. //
  389. // /*!< Configure PD.02 CMD line */
  390. // GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
  391. // GPIO_Init(GPIOD, &GPIO_InitStructure);
  392. //
  393. // /*!< Configure SD_SPI_DETECT_PIN pin: SD Card detect pin */
  394. // GPIO_InitStructure.GPIO_Pin = SD_DETECT_PIN;
  395. // GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
  396. // GPIO_Init(SD_DETECT_GPIO_PORT, &GPIO_InitStructure);
  397. //
  398. // /*!< Enable the SDIO AHB Clock */
  399. // RCC_AHBPeriphClockCmd(RCC_AHBPeriph_SDIO, ENABLE);
  400. //
  401. // /*!< Enable the DMA2 Clock */
  402. // RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA2, ENABLE);
  403. //}
  404. /**
  405. * @brief Configures the DMA2 Channel4 for SDIO Tx request.
  406. * @param BufferSRC: pointer to the source buffer
  407. * @param BufferSize: buffer size
  408. * @retval None
  409. */
  410. //void SD_LowLevel_DMA_TxConfig(uint32_t *BufferSRC, uint32_t BufferSize)
  411. //{
  412. //
  413. // DMA_InitTypeDef DMA_InitStructure;
  414. //
  415. // DMA_ClearFlag(DMA2_FLAG_TC4 | DMA2_FLAG_TE4 | DMA2_FLAG_HT4 | DMA2_FLAG_GL4);
  416. //
  417. // /*!< DMA2 Channel4 disable */
  418. // DMA_Cmd(DMA2_Channel4, DISABLE);
  419. //
  420. // /*!< DMA2 Channel4 Config */
  421. // DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)SDIO_FIFO_ADDRESS;
  422. // DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)BufferSRC;
  423. // DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST;
  424. // DMA_InitStructure.DMA_BufferSize = BufferSize / 4;
  425. // DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
  426. // DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
  427. // DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word;
  428. // DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Word;
  429. // DMA_InitStructure.DMA_Mode = DMA_Mode_Normal;
  430. // DMA_InitStructure.DMA_Priority = DMA_Priority_High;
  431. // DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
  432. // DMA_Init(DMA2_Channel4, &DMA_InitStructure);
  433. //
  434. // /*!< DMA2 Channel4 enable */
  435. // DMA_Cmd(DMA2_Channel4, ENABLE);
  436. //}
  437. /**
  438. * @brief Configures the DMA2 Channel4 for SDIO Rx request.
  439. * @param BufferDST: pointer to the destination buffer
  440. * @param BufferSize: buffer size
  441. * @retval None
  442. */
  443. //void SD_LowLevel_DMA_RxConfig(uint32_t *BufferDST, uint32_t BufferSize)
  444. //{
  445. // DMA_InitTypeDef DMA_InitStructure;
  446. //
  447. // DMA_ClearFlag(DMA2_FLAG_TC4 | DMA2_FLAG_TE4 | DMA2_FLAG_HT4 | DMA2_FLAG_GL4);
  448. //
  449. // /*!< DMA2 Channel4 disable */
  450. // DMA_Cmd(DMA2_Channel4, DISABLE);
  451. //
  452. // /*!< DMA2 Channel4 Config */
  453. // DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)SDIO_FIFO_ADDRESS;
  454. // DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)BufferDST;
  455. // DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
  456. // DMA_InitStructure.DMA_BufferSize = BufferSize / 4;
  457. // DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
  458. // DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
  459. // DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word;
  460. // DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Word;
  461. // DMA_InitStructure.DMA_Mode = DMA_Mode_Normal;
  462. // DMA_InitStructure.DMA_Priority = DMA_Priority_High;
  463. // DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
  464. // DMA_Init(DMA2_Channel4, &DMA_InitStructure);
  465. //
  466. // /*!< DMA2 Channel4 enable */
  467. // DMA_Cmd(DMA2_Channel4, ENABLE);
  468. //}
  469. /**
  470. * @brief Returns the DMA End Of Transfer Status.
  471. * @param None
  472. * @retval DMA SDIO Channel Status.
  473. */
  474. //uint32_t SD_DMAEndOfTransferStatus(void)
  475. //{
  476. // return (uint32_t)DMA_GetFlagStatus(DMA2_FLAG_TC4);
  477. //}
  478. /**
  479. * @brief DeInitializes the peripherals used by the SPI FLASH driver.
  480. * @param None
  481. * @retval None
  482. */
  483. void sFLASH_LowLevel_DeInit(void)
  484. {
  485. GPIO_InitTypeDef GPIO_InitStructure;
  486. /*!< Disable the sFLASH_SPI */
  487. SPI_Cmd(sFLASH_SPI, DISABLE);
  488. /*!< DeInitializes the sFLASH_SPI */
  489. SPI_I2S_DeInit(sFLASH_SPI);
  490. /*!< sFLASH_SPI Periph clock disable */
  491. RCC_APB2PeriphClockCmd(sFLASH_SPI_CLK, DISABLE);
  492. /*!< Configure sFLASH_SPI pins: SCK */
  493. GPIO_InitStructure.GPIO_Pin = sFLASH_SPI_SCK_PIN;
  494. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
  495. GPIO_Init(sFLASH_SPI_SCK_GPIO_PORT, &GPIO_InitStructure);
  496. /*!< Configure sFLASH_SPI pins: MISO */
  497. GPIO_InitStructure.GPIO_Pin = sFLASH_SPI_MISO_PIN;
  498. GPIO_Init(sFLASH_SPI_MISO_GPIO_PORT, &GPIO_InitStructure);
  499. /*!< Configure sFLASH_SPI pins: MOSI */
  500. GPIO_InitStructure.GPIO_Pin = sFLASH_SPI_MOSI_PIN;
  501. GPIO_Init(sFLASH_SPI_MOSI_GPIO_PORT, &GPIO_InitStructure);
  502. /*!< Configure sFLASH_CS_PIN pin: sFLASH Card CS pin */
  503. GPIO_InitStructure.GPIO_Pin = sFLASH_CS_PIN;
  504. GPIO_Init(sFLASH_CS_GPIO_PORT, &GPIO_InitStructure);
  505. }
  506. /**
  507. * @brief Initializes the peripherals used by the SPI FLASH driver.
  508. * @param None
  509. * @retval None
  510. */
  511. void sFLASH_LowLevel_Init(void)
  512. {
  513. GPIO_InitTypeDef GPIO_InitStructure;
  514. /*!< sFLASH_SPI_CS_GPIO, sFLASH_SPI_MOSI_GPIO, sFLASH_SPI_MISO_GPIO
  515. and sFLASH_SPI_SCK_GPIO Periph clock enable */
  516. RCC_APB2PeriphClockCmd(sFLASH_CS_GPIO_CLK | sFLASH_SPI_MOSI_GPIO_CLK | sFLASH_SPI_MISO_GPIO_CLK |
  517. sFLASH_SPI_SCK_GPIO_CLK, ENABLE);
  518. /*!< sFLASH_SPI Periph clock enable */
  519. RCC_APB2PeriphClockCmd(sFLASH_SPI_CLK, ENABLE);
  520. /*!< Configure sFLASH_SPI pins: SCK */
  521. GPIO_InitStructure.GPIO_Pin = sFLASH_SPI_SCK_PIN;
  522. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  523. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
  524. GPIO_Init(sFLASH_SPI_SCK_GPIO_PORT, &GPIO_InitStructure);
  525. /*!< Configure sFLASH_SPI pins: MOSI */
  526. GPIO_InitStructure.GPIO_Pin = sFLASH_SPI_MOSI_PIN;
  527. GPIO_Init(sFLASH_SPI_MOSI_GPIO_PORT, &GPIO_InitStructure);
  528. /*!< Configure sFLASH_SPI pins: MISO */
  529. GPIO_InitStructure.GPIO_Pin = sFLASH_SPI_MISO_PIN;
  530. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
  531. GPIO_Init(sFLASH_SPI_MISO_GPIO_PORT, &GPIO_InitStructure);
  532. /*!< Configure sFLASH_CS_PIN pin: sFLASH Card CS pin */
  533. GPIO_InitStructure.GPIO_Pin = sFLASH_CS_PIN;
  534. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  535. GPIO_Init(sFLASH_CS_GPIO_PORT, &GPIO_InitStructure);
  536. }
  537. /**
  538. * @brief DeInitializes the LM75_I2C.
  539. * @param None
  540. * @retval None
  541. */
  542. //void LM75_LowLevel_DeInit(void)
  543. //{
  544. // GPIO_InitTypeDef GPIO_InitStructure;
  545. //
  546. // /*!< Disable LM75_I2C */
  547. // I2C_Cmd(LM75_I2C, DISABLE);
  548. // /*!< DeInitializes the LM75_I2C */
  549. // I2C_DeInit(LM75_I2C);
  550. //
  551. // /*!< LM75_I2C Periph clock disable */
  552. // RCC_APB1PeriphClockCmd(LM75_I2C_CLK, DISABLE);
  553. //
  554. // /*!< Configure LM75_I2C pins: SCL */
  555. // GPIO_InitStructure.GPIO_Pin = LM75_I2C_SCL_PIN;
  556. // GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
  557. // GPIO_Init(LM75_I2C_SCL_GPIO_PORT, &GPIO_InitStructure);
  558. //
  559. // /*!< Configure LM75_I2C pins: SDA */
  560. // GPIO_InitStructure.GPIO_Pin = LM75_I2C_SDA_PIN;
  561. // GPIO_Init(LM75_I2C_SDA_GPIO_PORT, &GPIO_InitStructure);
  562. //
  563. // /*!< Configure LM75_I2C pin: SMBUS ALERT */
  564. // GPIO_InitStructure.GPIO_Pin = LM75_I2C_SMBUSALERT_PIN;
  565. // GPIO_Init(LM75_I2C_SMBUSALERT_GPIO_PORT, &GPIO_InitStructure);
  566. //}
  567. /**
  568. * @brief Initializes the LM75_I2C..
  569. * @param None
  570. * @retval None
  571. */
  572. //void LM75_LowLevel_Init(void)
  573. //{
  574. // GPIO_InitTypeDef GPIO_InitStructure;
  575. //
  576. // /*!< LM75_I2C Periph clock enable */
  577. // RCC_APB1PeriphClockCmd(LM75_I2C_CLK, ENABLE);
  578. //
  579. // /*!< LM75_I2C_SCL_GPIO_CLK, LM75_I2C_SDA_GPIO_CLK
  580. // and LM75_I2C_SMBUSALERT_GPIO_CLK Periph clock enable */
  581. // RCC_APB2PeriphClockCmd(LM75_I2C_SCL_GPIO_CLK | LM75_I2C_SDA_GPIO_CLK |
  582. // LM75_I2C_SMBUSALERT_GPIO_CLK, ENABLE);
  583. //
  584. // /*!< Configure LM75_I2C pins: SCL */
  585. // GPIO_InitStructure.GPIO_Pin = LM75_I2C_SCL_PIN;
  586. // GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  587. // GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD;
  588. // GPIO_Init(LM75_I2C_SCL_GPIO_PORT, &GPIO_InitStructure);
  589. //
  590. // /*!< Configure LM75_I2C pins: SDA */
  591. // GPIO_InitStructure.GPIO_Pin = LM75_I2C_SDA_PIN;
  592. // GPIO_Init(LM75_I2C_SDA_GPIO_PORT, &GPIO_InitStructure);
  593. //
  594. // /*!< Configure LM75_I2C pin: SMBUS ALERT */
  595. // GPIO_InitStructure.GPIO_Pin = LM75_I2C_SMBUSALERT_PIN;
  596. // GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
  597. // GPIO_Init(LM75_I2C_SMBUSALERT_GPIO_PORT, &GPIO_InitStructure);
  598. //}
  599. /**
  600. * @}
  601. */
  602. /**
  603. * @}
  604. */
  605. /**
  606. * @}
  607. */
  608. /**
  609. * @}
  610. */
  611. /**
  612. * @}
  613. */
  614. /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/