stm3210b_eval.c

Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm3210b_eval.c
00004   * @author  MCD Application Team
00005   * @version V4.3.0
00006   * @date    10/15/2010
00007   * @brief   This file provides
00008   *            - set of firmware functions to manage Leds, push-button and COM ports
00009   *            - low level initialization functions for SD card (on SPI), SPI serial
00010   *              flash (sFLASH) and temperature sensor (LM75)
00011   *          available on STM3210B-EVAL evaluation board from STMicroelectronics.    
00012   ******************************************************************************
00013   * @copy
00014   *
00015   * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
00016   * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
00017   * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
00018   * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
00019   * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
00020   * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
00021   *
00022   * <h2><center>&copy; COPYRIGHT 2010 STMicroelectronics</center></h2>
00023   */ 
00024   
00025 /* Includes ------------------------------------------------------------------*/
00026 #include "stm3210b_eval.h"
00027 
00028 /** @addtogroup Utilities
00029   * @{
00030   */ 
00031 
00032 /** @addtogroup STM32_EVAL
00033   * @{
00034   */ 
00035 
00036 /** @addtogroup STM3210B_EVAL
00037   * @{
00038   */ 
00039       
00040 /** @defgroup STM3210B_EVAL_LOW_LEVEL 
00041   * @brief This file provides firmware functions to manage Leds, push-buttons, 
00042   *        COM ports, SD card on SPI, serial flash (sFLASH), serial EEPROM (sEE) 
00043   *        and temperature sensor (LM75) available on STM3210B-EVAL evaluation
00044   *        board from STMicroelectronics.
00045   * @{
00046   */ 
00047 
00048 /** @defgroup STM3210B_EVAL_LOW_LEVEL_Private_TypesDefinitions
00049   * @{
00050   */ 
00051 /**
00052   * @}
00053   */ 
00054 
00055 
00056 /** @defgroup STM3210B_EVAL_LOW_LEVEL_Private_Defines
00057   * @{
00058   */ 
00059 /**
00060   * @}
00061   */ 
00062 
00063 
00064 /** @defgroup STM3210B_EVAL_LOW_LEVEL_Private_Macros
00065   * @{
00066   */ 
00067 /**
00068   * @}
00069   */ 
00070 
00071 
00072 /** @defgroup STM3210B_EVAL_LOW_LEVEL_Private_Variables
00073   * @{
00074   */ 
00075 GPIO_TypeDef* GPIO_PORT[LEDn] = {LED1_GPIO_PORT, LED2_GPIO_PORT, LED3_GPIO_PORT,
00076                                  LED4_GPIO_PORT};
00077 const uint16_t GPIO_PIN[LEDn] = {LED1_PIN, LED2_PIN, LED3_PIN,
00078                                  LED4_PIN};
00079 const uint32_t GPIO_CLK[LEDn] = {LED1_GPIO_CLK, LED2_GPIO_CLK, LED3_GPIO_CLK,
00080                                  LED4_GPIO_CLK};
00081 
00082 GPIO_TypeDef* BUTTON_PORT[BUTTONn] = {WAKEUP_BUTTON_GPIO_PORT, TAMPER_BUTTON_GPIO_PORT, 
00083                                       KEY_BUTTON_GPIO_PORT, RIGHT_BUTTON_GPIO_PORT,
00084                                       LEFT_BUTTON_GPIO_PORT, UP_BUTTON_GPIO_PORT,
00085                                       DOWN_BUTTON_GPIO_PORT, SEL_BUTTON_GPIO_PORT}; 
00086 
00087 const uint16_t BUTTON_PIN[BUTTONn] = {WAKEUP_BUTTON_PIN, TAMPER_BUTTON_PIN, 
00088                                       KEY_BUTTON_PIN, RIGHT_BUTTON_PIN,
00089                                       LEFT_BUTTON_PIN, UP_BUTTON_PIN,
00090                                       DOWN_BUTTON_PIN, SEL_BUTTON_PIN}; 
00091 
00092 const uint32_t BUTTON_CLK[BUTTONn] = {WAKEUP_BUTTON_GPIO_CLK, TAMPER_BUTTON_GPIO_CLK,
00093                                       KEY_BUTTON_GPIO_CLK, RIGHT_BUTTON_GPIO_CLK,
00094                                       LEFT_BUTTON_GPIO_CLK, UP_BUTTON_GPIO_CLK,
00095                                       DOWN_BUTTON_GPIO_CLK, SEL_BUTTON_GPIO_CLK};
00096 
00097 const uint16_t BUTTON_EXTI_LINE[BUTTONn] = {WAKEUP_BUTTON_EXTI_LINE,
00098                                             TAMPER_BUTTON_EXTI_LINE, 
00099                                             KEY_BUTTON_EXTI_LINE,
00100                                             RIGHT_BUTTON_EXTI_LINE,
00101                                             LEFT_BUTTON_EXTI_LINE,
00102                                             UP_BUTTON_EXTI_LINE,
00103                                             DOWN_BUTTON_EXTI_LINE,
00104                                             SEL_BUTTON_EXTI_LINE};
00105 
00106 const uint16_t BUTTON_PORT_SOURCE[BUTTONn] = {WAKEUP_BUTTON_EXTI_PORT_SOURCE,
00107                                               TAMPER_BUTTON_EXTI_PORT_SOURCE, 
00108                                               KEY_BUTTON_EXTI_PORT_SOURCE,
00109                                               RIGHT_BUTTON_EXTI_PORT_SOURCE,
00110                                               LEFT_BUTTON_EXTI_PORT_SOURCE,
00111                                               UP_BUTTON_EXTI_PORT_SOURCE,
00112                                               DOWN_BUTTON_EXTI_PORT_SOURCE,
00113                                               SEL_BUTTON_EXTI_PORT_SOURCE};
00114                                                                  
00115 const uint16_t BUTTON_PIN_SOURCE[BUTTONn] = {WAKEUP_BUTTON_EXTI_PIN_SOURCE,
00116                                              TAMPER_BUTTON_EXTI_PIN_SOURCE, 
00117                                              KEY_BUTTON_EXTI_PIN_SOURCE,
00118                                              RIGHT_BUTTON_EXTI_PIN_SOURCE,
00119                                              LEFT_BUTTON_EXTI_PIN_SOURCE,
00120                                              UP_BUTTON_EXTI_PIN_SOURCE,
00121                                              DOWN_BUTTON_EXTI_PIN_SOURCE,
00122                                              SEL_BUTTON_EXTI_PIN_SOURCE}; 
00123 
00124 const uint16_t BUTTON_IRQn[BUTTONn] = {WAKEUP_BUTTON_EXTI_IRQn, TAMPER_BUTTON_EXTI_IRQn, 
00125                                        KEY_BUTTON_EXTI_IRQn, RIGHT_BUTTON_EXTI_IRQn,
00126                                        LEFT_BUTTON_EXTI_IRQn, UP_BUTTON_EXTI_IRQn,
00127                                        DOWN_BUTTON_EXTI_IRQn, SEL_BUTTON_EXTI_IRQn};
00128 
00129 USART_TypeDef* COM_USART[COMn] = {EVAL_COM1, EVAL_COM2}; 
00130 
00131 GPIO_TypeDef* COM_TX_PORT[COMn] = {EVAL_COM1_TX_GPIO_PORT, EVAL_COM2_TX_GPIO_PORT};
00132  
00133 GPIO_TypeDef* COM_RX_PORT[COMn] = {EVAL_COM1_RX_GPIO_PORT, EVAL_COM2_RX_GPIO_PORT};
00134  
00135 const uint32_t COM_USART_CLK[COMn] = {EVAL_COM1_CLK, EVAL_COM2_CLK};
00136 
00137 const uint32_t COM_TX_PORT_CLK[COMn] = {EVAL_COM1_TX_GPIO_CLK, EVAL_COM2_TX_GPIO_CLK};
00138  
00139 const uint32_t COM_RX_PORT_CLK[COMn] = {EVAL_COM1_RX_GPIO_CLK, EVAL_COM2_RX_GPIO_CLK};
00140 
00141 const uint16_t COM_TX_PIN[COMn] = {EVAL_COM1_TX_PIN, EVAL_COM2_TX_PIN};
00142 
00143 const uint16_t COM_RX_PIN[COMn] = {EVAL_COM1_RX_PIN, EVAL_COM2_RX_PIN};
00144 
00145 
00146 /**
00147   * @}
00148   */ 
00149 
00150 
00151 /** @defgroup STM3210B_EVAL_LOW_LEVEL_Private_FunctionPrototypes
00152   * @{
00153   */ 
00154 
00155 /**
00156   * @}
00157   */ 
00158 
00159 
00160 /** @defgroup STM3210B_EVAL_LOW_LEVEL_Private_Functions
00161   * @{
00162   */ 
00163 
00164 /**
00165   * @brief  Configures LED GPIO.
00166   * @param  Led: Specifies the Led to be configured. 
00167   *   This parameter can be one of following parameters:
00168   *     @arg LED1
00169   *     @arg LED2
00170   *     @arg LED3
00171   *     @arg LED4
00172   * @retval None
00173   */
00174 void STM_EVAL_LEDInit(Led_TypeDef Led)
00175 {
00176   GPIO_InitTypeDef  GPIO_InitStructure;
00177   
00178   /* Enable the GPIO_LED Clock */
00179   RCC_APB2PeriphClockCmd(GPIO_CLK[Led], ENABLE);
00180 
00181   /* Configure the GPIO_LED pin */
00182   GPIO_InitStructure.GPIO_Pin = GPIO_PIN[Led];
00183   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
00184   GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
00185 
00186   GPIO_Init(GPIO_PORT[Led], &GPIO_InitStructure);
00187 }
00188 
00189 /**
00190   * @brief  Turns selected LED On.
00191   * @param  Led: Specifies the Led to be set on. 
00192   *   This parameter can be one of following parameters:
00193   *     @arg LED1
00194   *     @arg LED2
00195   *     @arg LED3
00196   *     @arg LED4  
00197   * @retval None
00198   */
00199 void STM_EVAL_LEDOn(Led_TypeDef Led)
00200 {
00201   GPIO_PORT[Led]->BSRR = GPIO_PIN[Led];     
00202 }
00203 
00204 /**
00205   * @brief  Turns selected LED Off.
00206   * @param  Led: Specifies the Led to be set off. 
00207   *   This parameter can be one of following parameters:
00208   *     @arg LED1
00209   *     @arg LED2
00210   *     @arg LED3
00211   *     @arg LED4 
00212   * @retval None
00213   */
00214 void STM_EVAL_LEDOff(Led_TypeDef Led)
00215 {
00216   GPIO_PORT[Led]->BRR = GPIO_PIN[Led];  
00217 }
00218 
00219 /**
00220   * @brief  Toggles the selected LED.
00221   * @param  Led: Specifies the Led to be toggled. 
00222   *   This parameter can be one of following parameters:
00223   *     @arg LED1
00224   *     @arg LED2
00225   *     @arg LED3
00226   *     @arg LED4  
00227   * @retval None
00228   */
00229 void STM_EVAL_LEDToggle(Led_TypeDef Led)
00230 {
00231   GPIO_PORT[Led]->ODR ^= GPIO_PIN[Led];
00232 }
00233 
00234 /**
00235   * @brief  Configures Button GPIO and EXTI Line.
00236   * @param  Button: Specifies the Button to be configured.
00237   *   This parameter can be one of following parameters:   
00238   *     @arg BUTTON_WAKEUP: Wakeup Push Button
00239   *     @arg BUTTON_TAMPER: Tamper Push Button  
00240   *     @arg BUTTON_KEY: Key Push Button 
00241   *     @arg BUTTON_RIGHT: Joystick Right Push Button 
00242   *     @arg BUTTON_LEFT: Joystick Left Push Button 
00243   *     @arg BUTTON_UP: Joystick Up Push Button 
00244   *     @arg BUTTON_DOWN: Joystick Down Push Button
00245   *     @arg BUTTON_SEL: Joystick Sel Push Button
00246   * @param  Button_Mode: Specifies Button mode.
00247   *   This parameter can be one of following parameters:   
00248   *     @arg BUTTON_MODE_GPIO: Button will be used as simple IO 
00249   *     @arg BUTTON_MODE_EXTI: Button will be connected to EXTI line with interrupt
00250   *                     generation capability  
00251   * @retval None
00252   */
00253 void STM_EVAL_PBInit(Button_TypeDef Button, ButtonMode_TypeDef Button_Mode)
00254 {
00255   GPIO_InitTypeDef GPIO_InitStructure;
00256   EXTI_InitTypeDef EXTI_InitStructure;
00257   NVIC_InitTypeDef NVIC_InitStructure;
00258 
00259   /* Enable the BUTTON Clock */
00260   RCC_APB2PeriphClockCmd(BUTTON_CLK[Button] | RCC_APB2Periph_AFIO, ENABLE);
00261 
00262   /* Configure Button pin as input floating */
00263   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
00264   GPIO_InitStructure.GPIO_Pin = BUTTON_PIN[Button];
00265   GPIO_Init(BUTTON_PORT[Button], &GPIO_InitStructure);
00266 
00267 
00268   if (Button_Mode == BUTTON_MODE_EXTI)
00269   {
00270     /* Connect Button EXTI Line to Button GPIO Pin */
00271     GPIO_EXTILineConfig(BUTTON_PORT_SOURCE[Button], BUTTON_PIN_SOURCE[Button]);
00272 
00273     /* Configure Button EXTI line */
00274     EXTI_InitStructure.EXTI_Line = BUTTON_EXTI_LINE[Button];
00275     EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
00276 
00277     if(Button != BUTTON_WAKEUP)
00278     {
00279       EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;  
00280     }
00281     else
00282     {
00283       EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;  
00284     }
00285     EXTI_InitStructure.EXTI_LineCmd = ENABLE;
00286     EXTI_Init(&EXTI_InitStructure);
00287 
00288     /* Enable and set Button EXTI Interrupt to the lowest priority */
00289     NVIC_InitStructure.NVIC_IRQChannel = BUTTON_IRQn[Button];
00290     NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0F;
00291     NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0F;
00292     NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
00293 
00294     NVIC_Init(&NVIC_InitStructure); 
00295   }
00296 }
00297 
00298 /**
00299   * @brief  Returns the selected Button state.
00300   * @param  Button: Specifies the Button to be checked.
00301   *   This parameter can be one of following parameters:    
00302   *     @arg BUTTON_WAKEUP: Wakeup Push Button
00303   *     @arg BUTTON_TAMPER: Tamper Push Button  
00304   *     @arg BUTTON_KEY: Key Push Button 
00305   *     @arg BUTTON_RIGHT: Joystick Right Push Button 
00306   *     @arg BUTTON_LEFT: Joystick Left Push Button 
00307   *     @arg BUTTON_UP: Joystick Up Push Button 
00308   *     @arg BUTTON_DOWN: Joystick Down Push Button
00309   *     @arg BUTTON_SEL: Joystick Sel Push Button    
00310   * @retval The Button GPIO pin value.
00311   */
00312 uint32_t STM_EVAL_PBGetState(Button_TypeDef Button)
00313 {
00314   return GPIO_ReadInputDataBit(BUTTON_PORT[Button], BUTTON_PIN[Button]);
00315 }
00316 
00317 /**
00318   * @brief  Configures COM port.
00319   * @param  COM: Specifies the COM port to be configured.
00320   *   This parameter can be one of following parameters:    
00321   *     @arg COM1
00322   *     @arg COM2  
00323   * @param  USART_InitStruct: pointer to a USART_InitTypeDef structure that
00324   *   contains the configuration information for the specified USART peripheral.
00325   * @retval None
00326   */
00327 void STM_EVAL_COMInit(COM_TypeDef COM, USART_InitTypeDef* USART_InitStruct)
00328 {
00329   GPIO_InitTypeDef GPIO_InitStructure;
00330 
00331   /* Enable GPIO clock */
00332   RCC_APB2PeriphClockCmd(COM_TX_PORT_CLK[COM] | COM_RX_PORT_CLK[COM] | RCC_APB2Periph_AFIO, ENABLE);
00333 
00334   if (COM == COM1)
00335   {
00336     RCC_APB2PeriphClockCmd(COM_USART_CLK[COM], ENABLE); 
00337   }
00338   else
00339   {
00340     /* Enable the USART2 Pins Software Remapping */
00341     GPIO_PinRemapConfig(GPIO_Remap_USART2, ENABLE);
00342     RCC_APB1PeriphClockCmd(COM_USART_CLK[COM], ENABLE);
00343   }
00344 
00345   /* Configure USART Tx as alternate function push-pull */
00346   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
00347   GPIO_InitStructure.GPIO_Pin = COM_TX_PIN[COM];
00348   GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
00349   GPIO_Init(COM_TX_PORT[COM], &GPIO_InitStructure);
00350 
00351 
00352   /* Configure USART Rx as input floating */
00353   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
00354   GPIO_InitStructure.GPIO_Pin = COM_RX_PIN[COM];
00355   GPIO_Init(COM_RX_PORT[COM], &GPIO_InitStructure);
00356 
00357   /* USART configuration */
00358   USART_Init(COM_USART[COM], USART_InitStruct);
00359     
00360   /* Enable USART */
00361   USART_Cmd(COM_USART[COM], ENABLE);
00362 }
00363 
00364 /**
00365   * @brief  DeInitializes the SD/SD communication.
00366   * @param  None
00367   * @retval None
00368   */
00369 void SD_LowLevel_DeInit(void)
00370 {
00371   GPIO_InitTypeDef  GPIO_InitStructure;
00372   
00373   SPI_Cmd(SD_SPI, DISABLE); /*!< SD_SPI disable */
00374   SPI_I2S_DeInit(SD_SPI);   /*!< DeInitializes the SD_SPI */
00375   
00376   /*!< SD_SPI Periph clock disable */
00377   RCC_APB2PeriphClockCmd(SD_SPI_CLK, DISABLE); 
00378   
00379   /*!< Configure SD_SPI pins: SCK */
00380   GPIO_InitStructure.GPIO_Pin = SD_SPI_SCK_PIN;
00381   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
00382   GPIO_Init(SD_SPI_SCK_GPIO_PORT, &GPIO_InitStructure);
00383 
00384   /*!< Configure SD_SPI pins: MISO */
00385   GPIO_InitStructure.GPIO_Pin = SD_SPI_MISO_PIN;
00386   GPIO_Init(SD_SPI_MISO_GPIO_PORT, &GPIO_InitStructure);
00387 
00388   /*!< Configure SD_SPI pins: MOSI */
00389   GPIO_InitStructure.GPIO_Pin = SD_SPI_MOSI_PIN;
00390   GPIO_Init(SD_SPI_MOSI_GPIO_PORT, &GPIO_InitStructure);
00391 
00392   /*!< Configure SD_SPI_CS_PIN pin: SD Card CS pin */
00393   GPIO_InitStructure.GPIO_Pin = SD_CS_PIN;
00394   GPIO_Init(SD_CS_GPIO_PORT, &GPIO_InitStructure);
00395 
00396   /*!< Configure SD_SPI_DETECT_PIN pin: SD Card detect pin */
00397   GPIO_InitStructure.GPIO_Pin = SD_DETECT_PIN;
00398   GPIO_Init(SD_DETECT_GPIO_PORT, &GPIO_InitStructure);
00399 }
00400 
00401 /**
00402   * @brief  Initializes the SD_SPI and CS pins.
00403   * @param  None
00404   * @retval None
00405   */
00406 void SD_LowLevel_Init(void)
00407 {
00408   GPIO_InitTypeDef  GPIO_InitStructure;
00409   SPI_InitTypeDef   SPI_InitStructure;
00410 
00411   /*!< SD_SPI_CS_GPIO, SD_SPI_MOSI_GPIO, SD_SPI_MISO_GPIO, SD_SPI_DETECT_GPIO 
00412        and SD_SPI_SCK_GPIO Periph clock enable */
00413   RCC_APB2PeriphClockCmd(SD_CS_GPIO_CLK | SD_SPI_MOSI_GPIO_CLK | SD_SPI_MISO_GPIO_CLK |
00414                          SD_SPI_SCK_GPIO_CLK | SD_DETECT_GPIO_CLK, ENABLE);
00415 
00416   /*!< SD_SPI Periph clock enable */
00417   RCC_APB2PeriphClockCmd(SD_SPI_CLK, ENABLE); 
00418 
00419   
00420   /*!< Configure SD_SPI pins: SCK */
00421   GPIO_InitStructure.GPIO_Pin = SD_SPI_SCK_PIN;
00422   GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
00423   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
00424   GPIO_Init(SD_SPI_SCK_GPIO_PORT, &GPIO_InitStructure);
00425 
00426   /*!< Configure SD_SPI pins: MOSI */
00427   GPIO_InitStructure.GPIO_Pin = SD_SPI_MOSI_PIN;
00428   GPIO_Init(SD_SPI_MOSI_GPIO_PORT, &GPIO_InitStructure);
00429 
00430   /*!< Configure SD_SPI pins: MISO */
00431   GPIO_InitStructure.GPIO_Pin = SD_SPI_MISO_PIN;
00432   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;  
00433   GPIO_Init(SD_SPI_MISO_GPIO_PORT, &GPIO_InitStructure);
00434   
00435   /*!< Configure SD_SPI_CS_PIN pin: SD Card CS pin */
00436   GPIO_InitStructure.GPIO_Pin = SD_CS_PIN;
00437   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
00438   GPIO_Init(SD_CS_GPIO_PORT, &GPIO_InitStructure);
00439 
00440   /*!< Configure SD_SPI_DETECT_PIN pin: SD Card detect pin */
00441   GPIO_InitStructure.GPIO_Pin = SD_DETECT_PIN;
00442   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
00443   GPIO_Init(SD_DETECT_GPIO_PORT, &GPIO_InitStructure);
00444 
00445   /*!< SD_SPI Config */
00446   SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
00447   SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
00448   SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;
00449   SPI_InitStructure.SPI_CPOL = SPI_CPOL_High;
00450   SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge;
00451   SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
00452   SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_4;
00453   SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
00454   SPI_InitStructure.SPI_CRCPolynomial = 7;
00455   SPI_Init(SD_SPI, &SPI_InitStructure);
00456   
00457   SPI_Cmd(SD_SPI, ENABLE); /*!< SD_SPI enable */
00458 }
00459 
00460 /**
00461   * @brief  DeInitializes the peripherals used by the SPI FLASH driver.
00462   * @param  None
00463   * @retval None
00464   */
00465 void sFLASH_LowLevel_DeInit(void)
00466 {
00467   GPIO_InitTypeDef GPIO_InitStructure;
00468 
00469   /*!< Disable the sFLASH_SPI  */
00470   SPI_Cmd(sFLASH_SPI, DISABLE);
00471   
00472   /*!< DeInitializes the sFLASH_SPI */
00473   SPI_I2S_DeInit(sFLASH_SPI);
00474   
00475   /*!< sFLASH_SPI Periph clock disable */
00476   RCC_APB2PeriphClockCmd(sFLASH_SPI_CLK, DISABLE);
00477   
00478   /*!< Configure sFLASH_SPI pins: SCK */
00479   GPIO_InitStructure.GPIO_Pin = sFLASH_SPI_SCK_PIN;
00480   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
00481   GPIO_Init(sFLASH_SPI_SCK_GPIO_PORT, &GPIO_InitStructure);
00482 
00483   /*!< Configure sFLASH_SPI pins: MISO */
00484   GPIO_InitStructure.GPIO_Pin = sFLASH_SPI_MISO_PIN;
00485   GPIO_Init(sFLASH_SPI_MISO_GPIO_PORT, &GPIO_InitStructure);
00486 
00487   /*!< Configure sFLASH_SPI pins: MOSI */
00488   GPIO_InitStructure.GPIO_Pin = sFLASH_SPI_MOSI_PIN;
00489   GPIO_Init(sFLASH_SPI_MOSI_GPIO_PORT, &GPIO_InitStructure);
00490 
00491   /*!< Configure sFLASH_CS_PIN pin: sFLASH Card CS pin */
00492   GPIO_InitStructure.GPIO_Pin = sFLASH_CS_PIN;
00493   GPIO_Init(sFLASH_CS_GPIO_PORT, &GPIO_InitStructure);
00494 }
00495 
00496 /**
00497   * @brief  Initializes the peripherals used by the SPI FLASH driver.
00498   * @param  None
00499   * @retval None
00500   */
00501 void sFLASH_LowLevel_Init(void)
00502 {
00503   GPIO_InitTypeDef GPIO_InitStructure;
00504 
00505   /*!< sFLASH_SPI_CS_GPIO, sFLASH_SPI_MOSI_GPIO, sFLASH_SPI_MISO_GPIO 
00506        and sFLASH_SPI_SCK_GPIO Periph clock enable */
00507   RCC_APB2PeriphClockCmd(sFLASH_CS_GPIO_CLK | sFLASH_SPI_MOSI_GPIO_CLK | sFLASH_SPI_MISO_GPIO_CLK |
00508                          sFLASH_SPI_SCK_GPIO_CLK, ENABLE);
00509 
00510   /*!< sFLASH_SPI Periph clock enable */
00511   RCC_APB2PeriphClockCmd(sFLASH_SPI_CLK, ENABLE);
00512   
00513   /*!< Configure sFLASH_SPI pins: SCK */
00514   GPIO_InitStructure.GPIO_Pin = sFLASH_SPI_SCK_PIN;
00515   GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
00516   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
00517   GPIO_Init(sFLASH_SPI_SCK_GPIO_PORT, &GPIO_InitStructure);
00518 
00519   /*!< Configure sFLASH_SPI pins: MOSI */
00520   GPIO_InitStructure.GPIO_Pin = sFLASH_SPI_MOSI_PIN;
00521   GPIO_Init(sFLASH_SPI_MOSI_GPIO_PORT, &GPIO_InitStructure);
00522 
00523   /*!< Configure sFLASH_SPI pins: MISO */
00524   GPIO_InitStructure.GPIO_Pin = sFLASH_SPI_MISO_PIN;
00525   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;  
00526   GPIO_Init(sFLASH_SPI_MISO_GPIO_PORT, &GPIO_InitStructure);
00527   
00528   /*!< Configure sFLASH_CS_PIN pin: sFLASH Card CS pin */
00529   GPIO_InitStructure.GPIO_Pin = sFLASH_CS_PIN;
00530   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
00531   GPIO_Init(sFLASH_CS_GPIO_PORT, &GPIO_InitStructure);
00532 }
00533 
00534 /**
00535   * @brief  DeInitializes the LM75_I2C.
00536   * @param  None
00537   * @retval None
00538   */
00539 void LM75_LowLevel_DeInit(void)
00540 {
00541   GPIO_InitTypeDef  GPIO_InitStructure;
00542 
00543   /*!< Disable LM75_I2C */
00544   I2C_Cmd(LM75_I2C, DISABLE);
00545   /*!< DeInitializes the LM75_I2C */
00546   I2C_DeInit(LM75_I2C);
00547   
00548   /*!< LM75_I2C Periph clock disable */
00549   RCC_APB1PeriphClockCmd(LM75_I2C_CLK, DISABLE);
00550     
00551   /*!< Configure LM75_I2C pins: SCL */
00552   GPIO_InitStructure.GPIO_Pin = LM75_I2C_SCL_PIN;
00553   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
00554   GPIO_Init(LM75_I2C_SCL_GPIO_PORT, &GPIO_InitStructure);
00555 
00556   /*!< Configure LM75_I2C pins: SDA */
00557   GPIO_InitStructure.GPIO_Pin = LM75_I2C_SDA_PIN;
00558   GPIO_Init(LM75_I2C_SDA_GPIO_PORT, &GPIO_InitStructure);
00559 
00560   /*!< Configure LM75_I2C pin: SMBUS ALERT */
00561   GPIO_InitStructure.GPIO_Pin = LM75_I2C_SMBUSALERT_PIN;
00562   GPIO_Init(LM75_I2C_SMBUSALERT_GPIO_PORT, &GPIO_InitStructure);
00563 }
00564 
00565 /**
00566   * @brief  Initializes the LM75_I2C.
00567   * @param  None
00568   * @retval None
00569   */
00570 void LM75_LowLevel_Init(void)
00571 {
00572   GPIO_InitTypeDef  GPIO_InitStructure;
00573 
00574   /*!< LM75_I2C Periph clock enable */
00575   RCC_APB1PeriphClockCmd(LM75_I2C_CLK, ENABLE);
00576     
00577   /*!< LM75_I2C_SCL_GPIO_CLK, LM75_I2C_SDA_GPIO_CLK 
00578        and LM75_I2C_SMBUSALERT_GPIO_CLK Periph clock enable */
00579   RCC_APB2PeriphClockCmd(LM75_I2C_SCL_GPIO_CLK | LM75_I2C_SDA_GPIO_CLK |
00580                          LM75_I2C_SMBUSALERT_GPIO_CLK, ENABLE);
00581   
00582   /*!< Configure LM75_I2C pins: SCL */
00583   GPIO_InitStructure.GPIO_Pin = LM75_I2C_SCL_PIN;
00584   GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
00585   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD;
00586   GPIO_Init(LM75_I2C_SCL_GPIO_PORT, &GPIO_InitStructure);
00587 
00588   /*!< Configure LM75_I2C pins: SDA */
00589   GPIO_InitStructure.GPIO_Pin = LM75_I2C_SDA_PIN;
00590   GPIO_Init(LM75_I2C_SDA_GPIO_PORT, &GPIO_InitStructure);
00591 
00592   /*!< Configure LM75_I2C pin: SMBUS ALERT */
00593   GPIO_InitStructure.GPIO_Pin = LM75_I2C_SMBUSALERT_PIN;
00594   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
00595   GPIO_Init(LM75_I2C_SMBUSALERT_GPIO_PORT, &GPIO_InitStructure); 
00596 }
00597   
00598 /**
00599   * @}
00600   */ 
00601 
00602 
00603 /**
00604   * @}
00605   */ 
00606 
00607 /**
00608   * @}
00609   */
00610  
00611 /**
00612   * @}
00613   */  
00614 
00615 /**
00616   * @}
00617   */  
00618     
00619 /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
STM32F10x Standard Peripherals Library: Footer

 

 

 

      For complete documentation on STM32(CORTEX M3) 32-bit Microcontrollers platform visit  www.st.com/STM32