Alexander M Gladtsin 4 years ago
parent
commit
e7291b7945

+ 1 - 0
111/stm32-test

@@ -0,0 +1 @@
+Subproject commit 78118cc9e399efac6c9bb245e2336962602f47b0

BIN
stm32_f0_1/build/main.elf


BIN
stm32_f0_1/build/main.o


+ 433 - 0
stm32_f0_1/inc/stm320518_eval.h

@@ -0,0 +1,433 @@
+/**
+  ******************************************************************************
+  * @file    stm320518_eval.h
+  * @author  MCD Application Team
+  * @version V1.0.0
+  * @date    20-April-2012
+  * @brief   This file contains definitions for STM320518_EVAL's Leds, push-buttons
+  *          and COM ports hardware resources.
+  ******************************************************************************
+  * @attention
+  *
+  * <h2><center>&copy; COPYRIGHT 2012 STMicroelectronics</center></h2>
+  *
+  * 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:
+  *
+  *        http://www.st.com/software_license_agreement_liberty_v2
+  *
+  * 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.
+  *
+  ******************************************************************************
+  */
+  
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM320518_EVAL_H
+#define __STM320518_EVAL_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f0xx.h"
+#include "stm32_eval_legacy.h"
+
+/** @addtogroup Utilities
+  * @{
+  */
+
+/** @addtogroup STM32_EVAL
+  * @{
+  */
+
+/** @addtogroup STM320518_EVAL
+  * @{
+  */
+      
+/** @addtogroup STM320518_EVAL_LOW_LEVEL
+  * @{
+  */ 
+
+/** @defgroup STM320518_EVAL_LOW_LEVEL_Exported_Types
+  * @{
+  */
+typedef enum 
+{
+  LED1 = 0,
+  LED2 = 1,
+  LED3 = 2,
+  LED4 = 3
+} Led_TypeDef;
+
+typedef enum 
+{
+  BUTTON_TAMPER = 0,
+  BUTTON_KEY = 1,
+  BUTTON_RIGHT = 2,
+  BUTTON_LEFT = 3,
+  BUTTON_UP = 4,
+  BUTTON_DOWN = 5,
+  BUTTON_SEL = 6
+} Button_TypeDef;
+
+typedef enum 
+{  
+  BUTTON_MODE_GPIO = 0,
+  BUTTON_MODE_EXTI = 1
+} ButtonMode_TypeDef;
+
+typedef enum 
+{ 
+  JOY_NONE = 0,
+  JOY_SEL = 1,
+  JOY_DOWN = 2,
+  JOY_LEFT = 3,
+  JOY_RIGHT = 4,
+  JOY_UP = 5
+} JOYState_TypeDef
+;
+
+typedef enum 
+{
+  COM1 = 0,
+  COM2 = 1
+} COM_TypeDef;   
+/**
+  * @}
+  */ 
+
+/** @defgroup STM320518_EVAL_LOW_LEVEL_Exported_Constants
+  * @{
+  */ 
+
+/** 
+  * @brief  Define for STM320518_EVAL board  
+  */ 
+#if !defined (USE_STM320518_EVAL)
+ #define USE_STM320518_EVAL
+#endif
+
+/**
+ * @brief Select the revision A or B(default) of the EVAL board used.  
+ */
+#if !defined (STM320518_EVAL_REVB)
+ #define STM320518_EVAL_REVB
+#endif
+
+#if !defined (STM320518_EVAL_REVA)
+ //#define STM320518_EVAL_REVA
+#endif
+
+
+/** @addtogroup STM320518_EVAL_LOW_LEVEL_LED
+  * @{
+  */
+#define LEDn                             4
+
+#define LED1_PIN                         GPIO_Pin_10
+#define LED1_GPIO_PORT                   GPIOC
+#define LED1_GPIO_CLK                    RCC_AHBPeriph_GPIOC
+  
+#define LED2_PIN                         GPIO_Pin_11
+#define LED2_GPIO_PORT                   GPIOC
+#define LED2_GPIO_CLK                    RCC_AHBPeriph_GPIOC
+  
+#define LED3_PIN                         GPIO_Pin_12
+#define LED3_GPIO_PORT                   GPIOC
+#define LED3_GPIO_CLK                    RCC_AHBPeriph_GPIOC
+  
+#define LED4_PIN                         GPIO_Pin_2
+#define LED4_GPIO_PORT                   GPIOD
+#define LED4_GPIO_CLK                    RCC_AHBPeriph_GPIOD
+
+/**
+  * @}
+  */ 
+
+/** @addtogroup STM320518_EVAL_LOW_LEVEL_BUTTON
+  * @{
+  */  
+#define BUTTONn                          7
+
+/**
+ * @brief Tamper push-button
+ */
+#define TAMPER_BUTTON_PIN                GPIO_Pin_13
+#define TAMPER_BUTTON_GPIO_PORT          GPIOC
+#define TAMPER_BUTTON_GPIO_CLK           RCC_AHBPeriph_GPIOC
+#define TAMPER_BUTTON_EXTI_LINE          EXTI_Line13
+#define TAMPER_BUTTON_EXTI_PORT_SOURCE   EXTI_PortSourceGPIOC
+#define TAMPER_BUTTON_EXTI_PIN_SOURCE    EXTI_PinSource13
+#define TAMPER_BUTTON_EXTI_IRQn          EXTI4_15_IRQn 
+
+/**
+ * @brief Key push-button
+ */
+#define KEY_BUTTON_PIN                   GPIO_Pin_8
+#define KEY_BUTTON_GPIO_PORT             GPIOB
+#define KEY_BUTTON_GPIO_CLK              RCC_AHBPeriph_GPIOB
+#define KEY_BUTTON_EXTI_LINE             EXTI_Line8
+#define KEY_BUTTON_EXTI_PORT_SOURCE      EXTI_PortSourceGPIOB
+#define KEY_BUTTON_EXTI_PIN_SOURCE       EXTI_PinSource8
+#define KEY_BUTTON_EXTI_IRQn             EXTI4_15_IRQn
+
+/**
+ * @brief Joystick Right push-button
+ */
+#define RIGHT_BUTTON_PIN                 GPIO_Pin_8
+#define RIGHT_BUTTON_GPIO_PORT           GPIOC
+#define RIGHT_BUTTON_GPIO_CLK            RCC_AHBPeriph_GPIOC
+#define RIGHT_BUTTON_EXTI_LINE           EXTI_Line8
+#define RIGHT_BUTTON_EXTI_PORT_SOURCE    EXTI_PortSourceGPIOC
+#define RIGHT_BUTTON_EXTI_PIN_SOURCE     EXTI_PinSource8
+#define RIGHT_BUTTON_EXTI_IRQn           EXTI4_15_IRQn
+
+/**
+ * @brief Joystick Left push-button
+ */
+#define LEFT_BUTTON_PIN                  GPIO_Pin_9
+#define LEFT_BUTTON_GPIO_PORT            GPIOC
+#define LEFT_BUTTON_GPIO_CLK             RCC_AHBPeriph_GPIOC
+#define LEFT_BUTTON_EXTI_LINE            EXTI_Line9
+#define LEFT_BUTTON_EXTI_PORT_SOURCE     EXTI_PortSourceGPIOC
+#define LEFT_BUTTON_EXTI_PIN_SOURCE      EXTI_PinSource9
+#define LEFT_BUTTON_EXTI_IRQn            EXTI4_15_IRQn  
+
+/**
+ * @brief Joystick Up push-button
+ */
+#define UP_BUTTON_PIN                    GPIO_Pin_6
+#define UP_BUTTON_GPIO_PORT              GPIOC
+#define UP_BUTTON_GPIO_CLK               RCC_AHBPeriph_GPIOC
+#define UP_BUTTON_EXTI_LINE              EXTI_Line6
+#define UP_BUTTON_EXTI_PORT_SOURCE       EXTI_PortSourceGPIOC
+#define UP_BUTTON_EXTI_PIN_SOURCE        EXTI_PinSource6
+#define UP_BUTTON_EXTI_IRQn              EXTI4_15_IRQn  
+
+/**
+ * @brief Joystick Down push-button
+ */  
+#define DOWN_BUTTON_PIN                  GPIO_Pin_7
+#define DOWN_BUTTON_GPIO_PORT            GPIOC
+#define DOWN_BUTTON_GPIO_CLK             RCC_AHBPeriph_GPIOC
+#define DOWN_BUTTON_EXTI_LINE            EXTI_Line7
+#define DOWN_BUTTON_EXTI_PORT_SOURCE     EXTI_PortSourceGPIOC
+#define DOWN_BUTTON_EXTI_PIN_SOURCE      EXTI_PinSource7
+#define DOWN_BUTTON_EXTI_IRQn            EXTI4_15_IRQn  
+
+/**
+ * @brief Joystick Sel push-button
+ */
+#define SEL_BUTTON_PIN                   GPIO_Pin_0
+#define SEL_BUTTON_GPIO_PORT             GPIOA
+#define SEL_BUTTON_GPIO_CLK              RCC_AHBPeriph_GPIOA
+#define SEL_BUTTON_EXTI_LINE             EXTI_Line0
+#define SEL_BUTTON_EXTI_PORT_SOURCE      EXTI_PortSourceGPIOA
+#define SEL_BUTTON_EXTI_PIN_SOURCE       EXTI_PinSource0
+#define SEL_BUTTON_EXTI_IRQn             EXTI0_1_IRQn 
+
+/**
+  * @}
+  */ 
+
+
+/** @addtogroup STM320518_EVAL_LOW_LEVEL_COM
+  * @{
+  */
+#define COMn                             1
+
+/**
+ * @brief Definition for COM port1, connected to USART1
+ */ 
+#define EVAL_COM1                        USART1
+#define EVAL_COM1_CLK                    RCC_APB2Periph_USART1
+
+#define EVAL_COM1_TX_PIN                 GPIO_Pin_9
+#define EVAL_COM1_TX_GPIO_PORT           GPIOA
+#define EVAL_COM1_TX_GPIO_CLK            RCC_AHBPeriph_GPIOA
+#define EVAL_COM1_TX_SOURCE              GPIO_PinSource9
+#define EVAL_COM1_TX_AF                  GPIO_AF_1
+
+#define EVAL_COM1_RX_PIN                 GPIO_Pin_10
+#define EVAL_COM1_RX_GPIO_PORT           GPIOA
+#define EVAL_COM1_RX_GPIO_CLK            RCC_AHBPeriph_GPIOA
+#define EVAL_COM1_RX_SOURCE              GPIO_PinSource10
+#define EVAL_COM1_RX_AF                  GPIO_AF_1
+
+#define EVAL_COM1_CTS_PIN                GPIO_Pin_11
+#define EVAL_COM1_CTS_GPIO_PORT          GPIOA
+#define EVAL_COM1_CTS_GPIO_CLK           RCC_AHBPeriph_GPIOA
+#define EVAL_COM1_CTS_SOURCE             GPIO_PinSource11
+#define EVAL_COM1_CTS_AF                 GPIO_AF_1
+
+#define EVAL_COM1_RTS_PIN                GPIO_Pin_12
+#define EVAL_COM1_RTS_GPIO_PORT          GPIOA
+#define EVAL_COM1_RTS_GPIO_CLK           RCC_AHBPeriph_GPIOA
+#define EVAL_COM1_RTS_SOURCE             GPIO_PinSource12
+#define EVAL_COM1_RTS_AF                 GPIO_AF_1
+   
+#define EVAL_COM1_IRQn                   USART1_IRQn
+
+/**
+  * @}
+  */
+
+/** @addtogroup STM320518_EVAL_LOW_LEVEL_SD_SPI
+  * @{
+  */
+/**
+  * @brief  SD SPI Interface pins
+  */
+#define SD_SPI                           SPI1
+#define SD_SPI_CLK                       RCC_APB2Periph_SPI1
+
+#define SD_SPI_SCK_PIN                   GPIO_Pin_5                  /* PA.05 */
+#define SD_SPI_SCK_GPIO_PORT             GPIOA                       /* GPIOA */
+#define SD_SPI_SCK_GPIO_CLK              RCC_AHBPeriph_GPIOA
+#define SD_SPI_SCK_SOURCE                GPIO_PinSource5
+#define SD_SPI_SCK_AF                    GPIO_AF_0
+
+#if defined (STM320518_EVAL_REVA)
+ #define SD_SPI_MISO_PIN                 GPIO_Pin_6                  /* PA.06 */
+ #define SD_SPI_MISO_GPIO_PORT           GPIOA                       /* GPIOA */
+ #define SD_SPI_MISO_GPIO_CLK            RCC_AHBPeriph_GPIOA
+ #define SD_SPI_MISO_SOURCE              GPIO_PinSource6
+ #define SD_SPI_MISO_AF                  GPIO_AF_0
+#elif defined (STM320518_EVAL_REVB)
+ #define SD_SPI_MISO_PIN                 GPIO_Pin_4                  /* PB.04 */
+ #define SD_SPI_MISO_GPIO_PORT           GPIOB                       /* GPIOB */
+ #define SD_SPI_MISO_GPIO_CLK            RCC_AHBPeriph_GPIOB
+ #define SD_SPI_MISO_SOURCE              GPIO_PinSource4
+ #define SD_SPI_MISO_AF                  GPIO_AF_0
+#endif /* STM320518_EVAL_REVA*/
+
+#define SD_SPI_MOSI_PIN                  GPIO_Pin_7                  /* PA.07 */
+#define SD_SPI_MOSI_GPIO_PORT            GPIOA                       /* GPIOA */
+#define SD_SPI_MOSI_GPIO_CLK             RCC_AHBPeriph_GPIOA
+#define SD_SPI_MOSI_SOURCE               GPIO_PinSource7
+#define SD_SPI_MOSI_AF                   GPIO_AF_0
+
+#define SD_CS_PIN                        GPIO_Pin_5                  /* PF.05 */
+#define SD_CS_GPIO_PORT                  GPIOF                       /* GPIOF */
+#define SD_CS_GPIO_CLK                   RCC_AHBPeriph_GPIOF
+
+#define SD_DETECT_PIN                    GPIO_Pin_15                 /* PB.15 */
+#define SD_DETECT_EXTI_LINE              EXTI_Line15
+#define SD_DETECT_EXTI_PIN_SOURCE        EXTI_PinSource15
+#define SD_DETECT_GPIO_PORT              GPIOB                       /* GPIOB */
+#define SD_DETECT_GPIO_CLK               RCC_AHBPeriph_GPIOB
+#define SD_DETECT_EXTI_PORT_SOURCE       EXTI_PortSourceGPIOB
+#define SD_DETECT_EXTI_IRQn              EXTI4_15_IRQn
+
+/**
+  * @}
+  */
+
+
+/** @addtogroup STM320518_EVAL_LOW_LEVEL_TSENSOR_I2C
+  * @{
+  */
+/**
+  * @brief  LM75 Temperature Sensor I2C Interface pins
+  */
+#define LM75_I2C                         I2C1
+#define LM75_I2C_CLK                     RCC_APB1Periph_I2C1
+
+#define LM75_I2C_SCL_PIN                 GPIO_Pin_6                  /* PB.06 */
+#define LM75_I2C_SCL_GPIO_PORT           GPIOB                       /* GPIOB */
+#define LM75_I2C_SCL_GPIO_CLK            RCC_AHBPeriph_GPIOB
+#define LM75_I2C_SCL_SOURCE              GPIO_PinSource6
+#define LM75_I2C_SCL_AF                  GPIO_AF_1
+
+#define LM75_I2C_SDA_PIN                 GPIO_Pin_7                  /* PB.07 */
+#define LM75_I2C_SDA_GPIO_PORT           GPIOB                       /* GPIOB */
+#define LM75_I2C_SDA_GPIO_CLK            RCC_AHBPeriph_GPIOB
+#define LM75_I2C_SDA_SOURCE              GPIO_PinSource7
+#define LM75_I2C_SDA_AF                  GPIO_AF_1
+
+#define LM75_I2C_SMBUSALERT_PIN          GPIO_Pin_5                  /* PB.05 */
+#define LM75_I2C_SMBUSALERT_GPIO_PORT    GPIOB                       /* GPIOB */
+#define LM75_I2C_SMBUSALERT_GPIO_CLK     RCC_AHBPeriph_GPIOB
+#define LM75_I2C_SMBUSALERT_SOURCE       GPIO_PinSource5
+#define LM75_I2C_SMBUSALERT_AF           GPIO_AF_3
+
+/**
+  * @}
+  */
+   
+/** @addtogroup STM320518_EVAL_LOW_LEVEL_I2C_EE
+  * @{
+  */
+/**
+  * @brief  I2C EEPROM Interface pins
+  */  
+#define sEE_I2C                          I2C1
+#define sEE_I2C_CLK                      RCC_APB1Periph_I2C1
+   
+#define sEE_I2C_SCL_PIN                  GPIO_Pin_6                  /* PB.06 */
+#define sEE_I2C_SCL_GPIO_PORT            GPIOB                       /* GPIOB */
+#define sEE_I2C_SCL_GPIO_CLK             RCC_AHBPeriph_GPIOB
+#define sEE_I2C_SCL_SOURCE               GPIO_PinSource6
+#define sEE_I2C_SCL_AF                   GPIO_AF_1
+
+#define sEE_I2C_SDA_PIN                  GPIO_Pin_7                  /* PB.07 */
+#define sEE_I2C_SDA_GPIO_PORT            GPIOB                       /* GPIOB */
+#define sEE_I2C_SDA_GPIO_CLK             RCC_AHBPeriph_GPIOB
+#define sEE_I2C_SDA_SOURCE               GPIO_PinSource7
+#define sEE_I2C_SDA_AF                   GPIO_AF_1
+
+/**
+  * @}
+  */
+
+/** @defgroup STM320518_EVAL_LOW_LEVEL_Exported_Functions
+  * @{
+  */
+void STM_EVAL_LEDInit(Led_TypeDef Led);
+void STM_EVAL_LEDOn(Led_TypeDef Led);
+void STM_EVAL_LEDOff(Led_TypeDef Led);
+void STM_EVAL_LEDToggle(Led_TypeDef Led);
+void STM_EVAL_PBInit(Button_TypeDef Button, ButtonMode_TypeDef Button_Mode);
+uint32_t STM_EVAL_PBGetState(Button_TypeDef Button);
+void STM_EVAL_COMInit(COM_TypeDef COM, USART_InitTypeDef* USART_InitStruct);
+void SD_LowLevel_DeInit(void);
+void SD_LowLevel_Init(void); 
+void sFLASH_LowLevel_DeInit(void);
+void sFLASH_LowLevel_Init(void);
+void LM75_LowLevel_DeInit(void);
+void LM75_LowLevel_Init(void);
+void sEE_LowLevel_DeInit(void);
+void sEE_LowLevel_Init(void); 
+
+/**
+  * @}
+  */
+  
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM320518_EVAL_H */
+/**
+  * @}
+  */ 
+
+/**
+  * @}
+  */ 
+
+/**
+  * @}
+  */
+
+/**
+  * @}
+  */  
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 322 - 0
stm32_f0_1/inc/stm320518_eval_cec.h

@@ -0,0 +1,322 @@
+/**
+  ******************************************************************************
+  * @file    stm320518_eval_cec.h
+  * @author  MCD Application Team
+  * @version V1.0.0
+  * @date    20-April-2012
+  * @brief   This file contains all the functions prototypes for the stm320518_eval_cec
+  *          firmware driver.
+  ******************************************************************************
+  * @attention
+  *
+  * <h2><center>&copy; COPYRIGHT 2012 STMicroelectronics</center></h2>
+  *
+  * 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:
+  *
+  *        http://www.st.com/software_license_agreement_liberty_v2
+  *
+  * 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.
+  *
+  ******************************************************************************
+  */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM320518_EVAL_CEC_H
+#define __STM320518_EVAL_CEC_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+  /* Includes ------------------------------------------------------------------*/
+#include "stm320518_eval.h"
+
+/** @addtogroup Utilities
+  * @{
+  */
+
+/** @addtogroup STM32_EVAL
+  * @{
+  */
+
+/** @addtogroup STM320518_EVAL
+  * @{
+  */  
+
+/** @defgroup STM320518_EVAL_CEC
+  * @{
+  */
+
+/** @defgroup STM320518_EVAL_CEC_Exported_Types
+  * @{
+  */
+typedef enum
+{
+  HDMI_CEC_RX_OVERRUN              = (1),  /*!< CEC Receive overrun Error     */
+  HDMI_CEC_RX_BIT_RISING           = (2),  /*!< CEC Rx Bit Rising Error       */
+  HDMI_CEC_RX_SHORT_BIT_PERIOD     = (3),  /*!< CEC Rx Short Bit Period Error */
+  HDMI_CEC_RX_LONG_BIT_PERIOD      = (4),  /*!< CEC Rx Long Bit Period Error  */
+  HDMI_CEC_RX_ACKNOWLEDGE          = (5),  /*!< CEC RX Acknowledge Error      */
+  HDMI_CEC_ARBITRATION_LOST        = (6),  /*!< Arbitration Lost Error   */
+  HDMI_CEC_TX_UNDERRUN             = (7),  /*!< CEC Transmit Underrun Error */
+  HDMI_CEC_TX_ERROR                = (8),  /*!< CEC Transmit Error */
+  HDMI_CEC_TX_ACKNOWLEDGE          = (9),  /*!< CEC TX Acknowledge Error */
+  HDMI_CEC_DEVICE_UNREGISTRED      = (10), /*!< CEC Device Unregistered */
+  HDMI_CEC_TIMEOUT                 = (11), /*!< CEC TimeOut */
+  HDMI_CEC_OK                      = (12)  /*!< CEC OK */
+}HDMI_CEC_Error;
+
+typedef struct
+{
+  uint8_t PhysicalAddress_A;
+  uint8_t PhysicalAddress_B;
+  uint8_t PhysicalAddress_C;
+  uint8_t PhysicalAddress_D;
+  uint8_t LogicalAddress;
+  uint8_t DeviceType;
+}HDMI_CEC_Map;
+
+
+#define HDMI_CEC_TX_MESSAGE_LENGTH_MAX       ((uint32_t)0x0000000E)
+#define HDMI_CEC_TIMEOUT_VALUE               ((uint32_t)0x001FFFFF)
+
+/**
+* @brief  CEC Init Structure definition
+*/
+typedef struct
+{
+  __IO uint8_t Header;
+  __IO uint8_t Opcode;
+  __IO uint8_t Operande[HDMI_CEC_TX_MESSAGE_LENGTH_MAX];
+  __IO uint8_t TxMessageLength;
+  __IO uint8_t RxMessageLength;
+}HDMI_CEC_Message;
+
+/**
+* @}
+*/
+
+/** @defgroup STM320518_EVAL_CEC_Exported_Constants
+  * @{
+  */
+
+
+/**
+  * @brief CEC device types
+  */
+#define HDMI_CEC_TV                                         0x00
+#define HDMI_CEC_RECORDING                                  0x01
+#define HDMI_CEC_TUNER                                      0x03
+#define HDMI_CEC_PLAYBACK                                   0x04
+#define HDMI_CEC_AUDIOSYSTEM                                0x05
+
+/**
+  * @brief  HDMI CEC I2C Interface pins
+  */
+#define HDMI_CEC_I2C_SCL_PIN                                GPIO_Pin_6
+#define HDMI_CEC_I2C_SDA_PIN                                GPIO_Pin_7
+#define HDMI_CEC_I2C_SCL_PIN_SOURCE                         GPIO_PinSource6
+#define HDMI_CEC_I2C_SDA_PIN_SOURCE                         GPIO_PinSource7
+#define HDMI_CEC_I2C_GPIO_PORT                              GPIOB
+#define HDMI_CEC_I2C_GPIO_CLK                               RCC_AHBPeriph_GPIOB
+#define HDMI_CEC_I2C                                        I2C1
+#define HDMI_CEC_I2C_CLK                                    RCC_APB1Periph_I2C1
+
+#define HDMI_CEC_SINK_I2C_SCL_PIN                           GPIO_Pin_6
+#define HDMI_CEC_SINK_I2C_SDA_PIN                           GPIO_Pin_7
+#define HDMI_CEC_SINK_I2C_SCL_PIN_SOURCE                    GPIO_PinSource6
+#define HDMI_CEC_SINK_I2C_SDA_PIN_SOURCE                    GPIO_PinSource7
+#define HDMI_CEC_SINK_I2C_GPIO_PORT                         GPIOF
+#define HDMI_CEC_SINK_I2C_GPIO_CLK                          RCC_AHBPeriph_GPIOF
+#define HDMI_CEC_SINK_I2C                                   I2C2
+#define HDMI_CEC_SINK_I2C_CLK                               RCC_APB1Periph_I2C2
+/**
+  * @brief  HDMI CEC HPD (Hot Plug Detect) Interface pin
+  */
+#define HDMI_CEC_HPD_SINK_PIN                               GPIO_Pin_11
+#define HDMI_CEC_HPD_SINK_GPIO_PORT                         GPIOA
+#define HDMI_CEC_HPD_SINK_GPIO_CLK                          RCC_AHBPeriph_GPIOA
+
+/**
+  * @brief  HDMI CEC HPD (Hot Plug Detect) Interface pin
+  */
+#define HDMI_CEC_HPD_SOURCE_PIN                             GPIO_Pin_8
+#define HDMI_CEC_HPD_SOURCE_GPIO_PORT                       GPIOA
+#define HDMI_CEC_HPD_SOURCE_GPIO_CLK                        RCC_AHBPeriph_GPIOA
+
+/**
+  * @brief  HDMI CEC Interface pin
+  */
+#define HDMI_CEC_LINE_PIN                                   GPIO_Pin_10
+#define HDMI_CEC_LINE_GPIO_PORT                             GPIOB
+#define HDMI_CEC_LINE_GPIO_CLK                              RCC_AHBPeriph_GPIOB
+
+
+#define HDMI_CEC_I2C_TIMING                       0x00330E10
+#define HDMI_CEC_I2C_SLAVE_ADDRESS7               0xA0
+
+/**
+  * @brief  HDMI CEC Root (Mainly for TV with a fixed physical address (0.0.0.0))
+  *         If you want to configure the STM320518-EVAL board as CEC Root (Sink)
+  *         change the following define to 0x1    
+  */
+#define HDMI_CEC_ROOT                             0x00
+
+/**
+  * @brief  To select if the DDC Channel will be used for physical address discovery
+  *         or not. To use the DDC Channel to read the EDID structure uncomment
+  *         the following line.   
+  *         If the device is configured as HMDI source it should read his own physical
+  *         address from the sink that is connected to.
+  */
+//#define HDMI_CEC_USE_DDC   
+
+/**
+  * @brief  CEC version: V1.4
+  */
+#define HDMI_CEC_VERSION                                    0x05  /* 0x04 For CEC version: V1.3.a */
+
+/**
+  * @brief  Reason for Abort feature
+  */
+#define HDMI_CEC_UNRECOGNIZED_OPCODE                        0x00
+#define HDMI_CEC_NOT_CORRECT_MODETORESPOND                  0x01
+#define HDMI_CEC_CANNOTPROVIDE_SOURCE                       0x02
+#define HDMI_CEC_INVALID_OPERAND                            0x03
+#define HDMI_CEC_REFUSED                                    0x04
+
+/**
+  * @brief  HDMI CEC specific commands
+  */
+#define HDMI_CEC_OPCODE_ACTIVE_SOURCE                       ((uint8_t) 0x82)
+#define HDMI_CEC_OPCODE_IMAGE_VIEW_ON                       ((uint8_t) 0x04)
+#define HDMI_CEC_OPCODE_TEXT_VIEW_ON                        ((uint8_t) 0x0D)
+#define HDMI_CEC_OPCODE_INACTIVE_SOURCE                     ((uint8_t) 0x9D)
+#define HDMI_CEC_OPCODE_REQUEST_ACTIVE_SOURCE               ((uint8_t) 0x85)
+#define HDMI_CEC_OPCODE_ROUTING_CHANGE                      ((uint8_t) 0x80)
+#define HDMI_CEC_OPCODE_ROUTING_INFORMATION                 ((uint8_t) 0x81)
+#define HDMI_CEC_OPCODE_SET_STREAM_PATH                     ((uint8_t) 0x86)
+#define HDMI_CEC_OPCODE_STANDBY                             ((uint8_t) 0x36)
+#define HDMI_CEC_OPCODE_RECORD_OFF                          ((uint8_t) 0x0B)
+#define HDMI_CEC_OPCODE_RECORD_ON                           ((uint8_t) 0x09)
+#define HDMI_CEC_OPCODE_RECORD_STATUS                       ((uint8_t) 0x0A)
+#define HDMI_CEC_OPCODE_RECORD_TV_SCREEN                    ((uint8_t) 0x0F)
+#define HDMI_CEC_OPCODE_CLEAR_ANALOGUE_TIMER                ((uint8_t) 0x33)
+#define HDMI_CEC_OPCODE_CLEAR_DIGITAL_TIMER                 ((uint8_t) 0x99)
+#define HDMI_CEC_OPCODE_CLEAR_EXTERNAL_TIMER                ((uint8_t) 0xA1)
+#define HDMI_CEC_OPCODE_SET_ANALOGUE_TIMER                  ((uint8_t) 0x34)
+#define HDMI_CEC_OPCODE_SET_DIGITAL_TIMER                   ((uint8_t) 0x97)
+#define HDMI_CEC_OPCODE_SET_EXTERNAL_TIMER                  ((uint8_t) 0xA2)
+#define HDMI_CEC_OPCODE_SET_TIMER_PROGRAM_TITLE             ((uint8_t) 0x67)
+#define HDMI_CEC_OPCODE_TIMER_CLEARED_STATUS                ((uint8_t) 0x43)
+#define HDMI_CEC_OPCODE_TIMER_STATUS                        ((uint8_t) 0x35)
+#define HDMI_CEC_OPCODE_CEC_VERSION                         ((uint8_t) 0x9E)
+#define HDMI_CEC_OPCODE_GET_CEC_VERSION                     ((uint8_t) 0x9F)
+#define HDMI_CEC_OPCODE_GIVE_PHYSICAL_ADDRESS               ((uint8_t) 0x83)
+#define HDMI_CEC_OPCODE_GET_MENU_LANGUAGE                   ((uint8_t) 0x91)
+#define HDMI_CEC_OPCODE_REPORT_PHYSICAL_ADDRESS             ((uint8_t) 0x84)
+#define HDMI_CEC_OPCODE_SET_MENU_LANGUAGE                   ((uint8_t) 0x32)
+#define HDMI_CEC_OPCODE_DECK_CONTROL                        ((uint8_t) 0x42)
+#define HDMI_CEC_OPCODE_DECK_STATUS                         ((uint8_t) 0x1B)
+#define HDMI_CEC_OPCODE_GIVE_DECK_STATUS                    ((uint8_t) 0x1A)
+#define HDMI_CEC_OPCODE_PLAY                                ((uint8_t) 0x41)
+#define HDMI_CEC_OPCODE_GIVE_TUNER_DEVICE_STATUS            ((uint8_t) 0x08)
+#define HDMI_CEC_OPCODE_SELECT_ANALOGUE_SERVICE             ((uint8_t) 0x92)
+#define HDMI_CEC_OPCODE_SELECT_DIGITAL_SERVICE              ((uint8_t) 0x93)
+#define HDMI_CEC_OPCODE_TUNER_DEVICE_STATUS                 ((uint8_t) 0x07)
+#define HDMI_CEC_OPCODE_TUNER_STEP_DECREMENT                ((uint8_t) 0x06)
+#define HDMI_CEC_OPCODE_TUNER_STEP_INCREMENT                ((uint8_t) 0x05)
+#define HDMI_CEC_OPCODE_DEVICE_VENDOR_ID                    ((uint8_t) 0x87)
+#define HDMI_CEC_OPCODE_GIVE_DEVICE_VENDOR_ID               ((uint8_t) 0x8C)
+#define HDMI_CEC_OPCODE_VENDOR_COMMAND                      ((uint8_t) 0x89)
+#define HDMI_CEC_OPCODE_VENDOR_COMMAND_WITH_ID              ((uint8_t) 0xA0)
+#define HDMI_CEC_OPCODE_VENDOR_REMOTE_BUTTON_DOWN           ((uint8_t) 0x8A)
+#define HDMI_CEC_OPCODE_VENDOR_REMOTE_BUTTON_UP             ((uint8_t) 0x8B)
+#define HDMI_CEC_OPCODE_SET_OSD_STRING                      ((uint8_t) 0x64)
+#define HDMI_CEC_OPCODE_GIVE_OSD_NAME                       ((uint8_t) 0x46)
+#define HDMI_CEC_OPCODE_SET_OSD_NAME                        ((uint8_t) 0x47)
+#define HDMI_CEC_OPCODE_MENU_REQUEST                        ((uint8_t) 0x8D)
+#define HDMI_CEC_OPCODE_MENU_STATUS                         ((uint8_t) 0x8E)
+#define HDMI_CEC_OPCODE_USER_CONTROL_PRESSED                ((uint8_t) 0x44)
+#define HDMI_CEC_OPCODE_USER_CONTROL_RELEASED               ((uint8_t) 0x45)
+#define HDMI_CEC_OPCODE_GIVE_DEVICE_POWER_STATUS            ((uint8_t) 0x8F)
+#define HDMI_CEC_OPCODE_REPORT_POWER_STATUS                 ((uint8_t) 0x90)
+#define HDMI_CEC_OPCODE_FEATURE_ABORT                       ((uint8_t) 0x00)
+#define HDMI_CEC_OPCODE_ABORT                               ((uint8_t) 0xFF)
+#define HDMI_CEC_OPCODE_GIVE_AUDIO_STATUS                   ((uint8_t) 0x71)
+#define HDMI_CEC_OPCODE_GIVE_SYSTEM_AUDIO_MODE_STATUS       ((uint8_t) 0x7D)
+#define HDMI_CEC_OPCODE_REPORT_AUDIO_STATUS                 ((uint8_t) 0x7A)
+#define HDMI_CEC_OPCODE_SET_SYSTEM_AUDIO_MODE               ((uint8_t) 0x72)
+#define HDMI_CEC_OPCODE_SYSTEM_AUDIO_MODE_REQUEST           ((uint8_t) 0x70)
+#define HDMI_CEC_OPCODE_SYSTEM_AUDIO_MODE_STATUS            ((uint8_t) 0x7E)
+#define HDMI_CEC_OPCODE_SET_AUDIO_RATE                      ((uint8_t) 0x9A)
+
+/**
+  * @}
+  */
+
+/** @defgroup STM320518_EVAL_CEC_Exported_Macros
+  * @{
+  */
+
+/**
+  * @}
+  */
+
+/** @defgroup STM32100B_EVAL_CEC_Exported_Macros
+  * @{
+  */
+/* HDMI_CEC_HPD: HDMI HPD pin low  */
+#define HDMI_CEC_HPD_LOW()       GPIO_ResetBits(HDMI_CEC_HPD_GPIO_PORT, HDMI_CEC_HPD_PIN)
+/* HDMI_CEC_HPD: HDMI HPD pin high  */
+#define HDMI_CEC_HPD_HIGH()      GPIO_SetBits(HDMI_CEC_HPD_SINK_GPIO_PORT, HDMI_CEC_HPD_SINK_PIN)
+
+/**
+  * @}
+  */
+
+/** @defgroup STM320518_EVAL_CEC_Exported_Functions
+  * @{
+  */
+HDMI_CEC_Error HDMI_CEC_Init(void);
+HDMI_CEC_Error HDMI_CEC_TransmitMessage(HDMI_CEC_Message *HDMI_CEC_TX_MessageStructure);
+HDMI_CEC_Error HDMI_CEC_GetErrorStatus (void);
+void HDMI_CEC_ProcessIRQSrc(void);
+HDMI_CEC_Error HDMI_CEC_ReportPhysicalAddress(void);
+void HDMI_CEC_CommandCallBack(void);
+HDMI_CEC_Error HDMI_CEC_CheckConnectedDevices(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM320518_EVAL_CEC_H */
+
+/**
+  * @}
+  */
+
+/**
+  * @}
+  */
+
+/**
+  * @}
+  */
+
+/**
+  * @}
+  */
+
+/**
+  * @}
+  */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 188 - 0
stm32_f0_1/inc/stm320518_eval_i2c_ee.h

@@ -0,0 +1,188 @@
+/**
+  ******************************************************************************
+  * @file    stm320518_eval_i2c_ee.h
+  * @author  MCD Application Team
+  * @version V1.0.0
+  * @date    20-April-2012
+  * @brief   This file contains all the functions prototypes for 
+  *          the stm320518_eval_i2c_ee.c firmware driver.
+  ******************************************************************************
+  * @attention
+  *
+  * <h2><center>&copy; COPYRIGHT 2012 STMicroelectronics</center></h2>
+  *
+  * 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:
+  *
+  *        http://www.st.com/software_license_agreement_liberty_v2
+  *
+  * 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.
+  *
+  ******************************************************************************
+  */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM320518_EVAL_I2C_EE_H
+#define __STM320518_EVAL_I2C_EE_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm320518_eval.h"
+
+/** @addtogroup Utilities
+  * @{
+  */
+  
+/** @addtogroup STM32_EVAL
+  * @{
+  */ 
+
+/** @addtogroup STM320518_EVAL
+  * @{
+  */
+  
+/** @addtogroup STM320518_EVAL_I2C_EE
+  * @{
+  */  
+
+/** @defgroup STM320518_EVAL_I2C_EE_Exported_Types
+  * @{
+  */ 
+
+/**
+  * @}
+  */
+  
+/** @defgroup STM320518_EVAL_I2C_EE_Exported_Constants
+  * @{
+  */
+
+/* Select which EEPROM will be used with this driver */
+#define sEE_M24LR64
+
+/* Uncomment the following line to use the default sEE_TIMEOUT_UserCallback() 
+   function implemented in stm320518_evel_i2c_ee.c file.
+   sEE_TIMEOUT_UserCallback() function is called whenever a timeout condition 
+   occure during communication (waiting on an event that doesn't occur, bus 
+   errors, busy devices ...). */   
+/* #define USE_DEFAULT_TIMEOUT_CALLBACK */
+   
+#if !defined (sEE_M24C08) && !defined (sEE_M24C64_32) && !defined (sEE_M24LR64)
+/* Use the defines below the choose the EEPROM type */
+/* #define sEE_M24C08*/  /* Support the device: M24C08. */
+/* note: Could support: M24C01, M24C02, M24C04 and M24C16 if the blocks and 
+   HW address are correctly defined*/
+/*#define sEE_M24C64_32*/  /* Support the devices: M24C32 and M24C64 */
+#define sEE_M24LR64  /*Support the devices: M24LR64 */ 
+#endif
+
+#ifdef sEE_M24C64_32
+/* For M24C32 and M24C64 devices, E0,E1 and E2 pins are all used for device 
+  address selection (ne need for additional address lines). According to the 
+  Harware connection on the board. */
+
+ #define sEE_HW_ADDRESS         0xA0   /* E0 = E1 = E2 = 0 */ 
+
+#elif defined (sEE_M24C08)
+/* The M24C08W contains 4 blocks (128byte each) with the adresses below: E2 = 0 
+   EEPROM Addresses defines */
+ #define sEE_HW_ADDRESS     0xA0   /* E2 = 0 */ 
+ /*#define sEE_HW_ADDRESS     0xA2*/ /* E2 = 0 */  
+ /*#define sEE_HW_ADDRESS     0xA4*/ /* E2 = 0 */
+ /*#define sEE_HW_ADDRESS     0xA6*/ /* E2 = 0 */
+
+#elif defined (sEE_M24LR64)
+ #define sEE_HW_ADDRESS         0xA0
+
+#endif /* sEE_M24C64_32 */
+
+#define sEE_I2C_TIMING          0x00210507
+
+#if defined (sEE_M24C08)
+ #define sEE_PAGESIZE           16
+#elif defined (sEE_M24C64_32)
+ #define sEE_PAGESIZE           32
+#elif defined (sEE_M24LR64)
+ #define sEE_PAGESIZE           4
+#endif
+   
+/* Maximum Timeout values for flags and events waiting loops. These timeouts are
+   not based on accurate values, they just guarantee that the application will 
+   not remain stuck if the I2C communication is corrupted.
+   You may modify these timeout values depending on CPU frequency and application
+   conditions (interrupts routines ...). */   
+#define sEE_FLAG_TIMEOUT         ((uint32_t)0x1000)
+#define sEE_LONG_TIMEOUT         ((uint32_t)(10 * sEE_FLAG_TIMEOUT))
+
+/* Maximum number of trials for sEE_WaitEepromStandbyState() function */
+#define sEE_MAX_TRIALS_NUMBER     300
+      
+#define sEE_OK                    0
+#define sEE_FAIL                  1   
+
+/**
+  * @}
+  */ 
+  
+/** @defgroup STM320518_EVAL_I2C_EE_Exported_Macros
+  * @{
+  */    
+/**
+  * @}
+  */ 
+
+/** @defgroup STM320518_EVAL_I2C_EE_Exported_Functions
+  * @{
+  */ 
+void     sEE_DeInit(void);
+void     sEE_Init(void);
+uint32_t sEE_ReadBuffer(uint8_t* pBuffer, uint16_t ReadAddr, uint16_t* NumByteToRead);
+uint32_t sEE_WritePage(uint8_t* pBuffer, uint16_t WriteAddr, uint8_t* NumByteToWrite);
+void     sEE_WriteBuffer(uint8_t* pBuffer, uint16_t WriteAddr, uint16_t NumByteToWrite);
+uint32_t sEE_WaitEepromStandbyState(void);
+
+/* USER Callbacks: These are functions for which prototypes only are declared in
+   EEPROM driver and that should be implemented into user applicaiton. */  
+/* sEE_TIMEOUT_UserCallback() function is called whenever a timeout condition 
+   occure during communication (waiting on an event that doesn't occur, bus 
+   errors, busy devices ...).
+   You can use the default timeout callback implementation by uncommenting the 
+   define USE_DEFAULT_TIMEOUT_CALLBACK in stm320518_evel_i2c_ee.h file.
+   Typically the user implementation of this callback should reset I2C peripheral
+   and re-initialize communication or in worst case reset all the application. */
+uint32_t sEE_TIMEOUT_UserCallback(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM320518_EVAL_I2C_EE_H */
+/**
+  * @}
+  */
+
+/**
+  * @}
+  */
+
+/**
+  * @}
+  */
+
+/**
+  * @}
+  */ 
+
+/**
+  * @}
+  */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 226 - 0
stm32_f0_1/inc/stm320518_eval_i2c_ee_cpal.h

@@ -0,0 +1,226 @@
+/**
+  ******************************************************************************
+  * @file    stm320518_eval_i2c_ee_cpal.h
+  * @author  MCD Application Team
+  * @version V1.0.0
+  * @date    20-April-2012
+  * @brief   This file contains all the functions prototypes for 
+  *          the stm320518_eval_i2c_ee_cpal.c firmware driver.
+  ******************************************************************************
+  * @attention
+  *
+  * <h2><center>&copy; COPYRIGHT 2012 STMicroelectronics</center></h2>
+  *
+  * 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:
+  *
+  *        http://www.st.com/software_license_agreement_liberty_v2
+  *
+  * 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.
+  *
+  ******************************************************************************
+  */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM320518_EVAL_I2C_EE_CPAL_H
+#define __STM320518_EVAL_I2C_EE_CPAL_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+
+/*==========================================================================================================
+                                             User NOTES
+============================================================================================================
+
+---------------------------------
+   How To use the EEPROM Driver:
+---------------------------------
+----- All EEPROM operations are controlled and monitored through a single
+      structure. This structure holds all necessary parameters to manage EEPROM
+      communication (pointer to CPAL I2C device structure, EEPROM address, 
+      EEPROM page size, EEPROM memory addressing mode, EEPROM state).
+         
+----- User should follow these steps to use this driver correctly :
+
+      -1-  STRUCTURE INITIALIZATION 
+      Start by initializing the structure holding EEPROM Information. To perform 
+      this action, the global variable sEEx_DevStructure declared in EEPROM driver 
+      as sEE_InitTypeDef (sEE1_DevStructure for EEPROM connected with I2C1, 
+      sEE2_DevStructure for EEPROM connected with I2C1 ...) must be used.
+
+      sEE_InitTypeDef structure contains five parameters:
+
+           *- CPAL_InitTypeDef* sEE_CPALStructure : Pointer on a CPAL Device structure 
+                                                    relative to the device instantiated 
+                                                    to communicate with EEPROM.
+
+           *- uint32_t sEEAddress : Contains the EEPROM device Address.
+  
+           *- uint32_t sEEPageSize : Contains the page size of EEPROM Memory.
+
+           *- uint8_t sEEMemoryAddrMode : Bit-field value specifying Memory Addressing Mode.
+
+           *- __IO sEE_StateTypeDef sEEState : Holds the current State of the EEPROM device. 
+
+       To configure this structure, user must initialize only three parameters 
+       (sEEAddress, sEEPageSize, sEEMemoryAddrMode).
+       
+       Example:
+         sEE1_DevStructure.sEEAddress = 0xA0; // set EEPROM address to 0xA0 
+         sEE1_DevStructure.sEEPageSize = 32;  // set page size to 32
+         sEE1_DevStructure.sEEMemoryAddrMode = sEE_OPT_16BIT_REG; // enable 16Bit memory addressing mode
+                           
+      -2- DEVICE CONFIGURATION 
+      Call the function sEE_StructInit() to initialize I2Cx CPAL device structure 
+      relative to EEPROM than call sEE_Init() to configure the selected device
+      with the selected configuration.
+      
+      -3- READ / WRITE OPERATIONS 
+      Call the function sEE_WriteBuffer() or sEE_ReadBuffer() to perform transfer operations. 
+      These functions start data transfer and exit. sEE_WriteHandler() and sEE_ReadHandler()
+      handle the remainder of the communication. sEE_WriteHandler() must be called in 
+      CPAL_I2C_TXTC_UserCallback() and sEE_ReadHandler() must be called in CPAL_I2C_RXTC_UserCallback().
+      These two callbacks are implemented in "cpal_usercallback.c" file.      
+           
+      Example of how to implement sEE_WriteHandler() in CPAL_I2C_TXTC_UserCallback():
+      
+            1** Comment "#define CPAL_I2C_TXTC_UserCallback   (void)" in cpal_conf.h.
+            2** Implement CPAL_I2C_TXTC_UserCallback in "cpal_usercallback.c" file.
+               
+               void CPAL_I2C_TXTC_UserCallback(CPAL_InitTypeDef* pDevInitStruct)
+               {
+                 sEE_WriteHandler(pDevInitStruct->CPAL_Dev);
+               }
+      
+      User should monitor transfer by testing the value of sEEState parameter of
+      sEEx_DevStructure. When transfer is ongoing sEEState is equal to sEE_STATE_WRITING
+      or sEE_STATE_READING. After transfer complete this parameter is set to sEE_STATE_IDLE.
+      
+      Example of how to wait until EEPROM communication finishes:
+            
+            while(sEE_GetEepromState(&sEE_DevStructure) != sEE_STATE_IDLE)
+              {
+                //Application may perform other tasks while transfer operation is ongoing 
+              }
+      
+      -4- DEVICE DEINITIALIZATION 
+      When transfer operations are finished, you may call sEE_DeInit() to disable I2Cx device 
+      and related resources (GPIO, DMA , IT and NVIC) relative to used EEPROM. 
+      
+*********END OF User Notes**********************************************************************************/
+ 
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f0xx_i2c_cpal.h"
+
+/* Exported types ------------------------------------------------------------*/
+
+/*========= sEE_State_Enum =========*/
+/* sEE global State enumeration contains the current state of EEPROM. 
+   Before starting each operation this state is tested. After each operation 
+   sEE_State is updated with the new value resulting from the relative operation.*/
+
+ typedef enum
+{ 
+  sEE_STATE_IDLE        = 0x01,         /*!<This state indicates that the EEPROM device is in idle state */ 
+
+  sEE_STATE_WRITING     = 0x02,         /*!<This state indicates that write operation is ongoing */
+
+  sEE_STATE_READING     = 0x03,         /*!<This state indicates that read operation is ongoing */
+  
+  sEE_STATE_ERROR       = 0x04,         /*!<This state indicates that an error is occurred during 
+                                            last operation */
+  
+}sEE_StateTypeDef;
+
+
+/*========= CPAL_sEE_TypeDef =========*/
+/* sEE Device structure definition */
+typedef struct  
+{
+  CPAL_InitTypeDef* sEE_CPALStructure;  /*!< Pointer on a CPAL Device structure relative to the device 
+                                             instantiated to communicate with EEPROM */
+  
+  uint16_t sEEPageSize;                 /*!< Contains the page size of EEPROM Memory*/ 
+  
+  uint8_t sEEAddress;                   /*!< Contains the EEPROM device Address */
+  
+  
+  uint8_t sEEMemoryAddrMode;            /*!< Bit-field value specifying Memory Addressing Mode. Can be 
+                                             any combination of following values: 
+                                             sEE_Memory_Addressing_Mode_Defines */ 
+  
+  __IO sEE_StateTypeDef sEEState;       /*!< Holds the current State of the EEPROM device. The state 
+                                             parameter can be one of the following values: sEE_State_Enum  */
+  
+} sEE_InitTypeDef;   
+
+
+/*========= sEE_Global_Device_Structures =========*/
+/* sEE Global Device Structures are the Global default structures which 
+   are used to handle sEE configuration and status.*/ 
+   
+extern sEE_InitTypeDef* sEE_DevStructures[];
+
+#ifdef CPAL_USE_I2C1 
+extern sEE_InitTypeDef sEE1_DevStructure;
+#endif /* CPAL_USE_I2C1 */
+
+#ifdef CPAL_USE_I2C2 
+extern sEE_InitTypeDef sEE2_DevStructure;
+#endif /* CPAL_USE_I2C2 */
+
+/* Exported constants --------------------------------------------------------*/
+
+/*============== TIMING Configuration ==========================*/
+#define sEE_I2C_TIMING 0x1045061D
+
+
+/*============== Programming model Configuration ==========================*/
+/* Select interrupt programming model : By default DMA programming model is selected.
+ To select interrupt programming model uncomment this define */
+#define sEE_IT
+
+/*========= sEE_Memory_Addressing_Mode_Defines =========*/
+/* sEE Memory_Addressing_Mode defines can be affected to sEEMemoryAddrMode which is 
+   a bit-field argument so any combination of these parameters can be selected. 
+   If one option is not selected then the relative feature is disabled.*/
+
+
+#define sEE_OPT_NO_MEM_ADDR            ((uint8_t)0x01)  /*!<Enable No Memory addressing mode for read operation : only EEPROM 
+                                                            device address sent. No Register/Physical address to be sent after 
+                                                            addressing phase */  
+
+#define sEE_OPT_16BIT_REG              ((uint8_t)0x02)  /*!<Enable 16-Bit Register/Physical addressing mode (two bytes, 
+                                                            MSB first). This option is supported only when sEE_OPT_NO_MEM_ADDR 
+                                                            option is not set */ 
+
+
+
+/* Exported macro ------------------------------------------------------------*/
+/* Exported functions ------------------------------------------------------- */
+
+void sEE_DeInit(sEE_InitTypeDef* sEEInitStruct);
+void sEE_Init(sEE_InitTypeDef* sEEInitStruct);
+void sEE_StructInit(sEE_InitTypeDef* sEEInitStruct);
+uint32_t sEE_WriteBuffer(sEE_InitTypeDef* sEEInitStruct, uint8_t* pBuffer, uint16_t WriteAddr, uint32_t NumByteToWrite);
+uint32_t sEE_WriteHandler(CPAL_DevTypeDef Device);
+uint32_t sEE_ReadBuffer(sEE_InitTypeDef* sEEInitStruct, uint8_t* pBuffer, uint16_t ReadAddr, uint32_t NumByteToRead);
+uint32_t sEE_ReadHandler(CPAL_DevTypeDef Device);
+uint32_t sEE_WaitEepromStandbyState(CPAL_DevTypeDef Device);
+uint32_t sEE_GetEepromState(sEE_InitTypeDef* sEEInitStruct);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM320518_EVAL_I2C_EE_CPAL_H */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 171 - 0
stm32_f0_1/inc/stm320518_eval_i2c_tsensor.h

@@ -0,0 +1,171 @@
+/**
+  ******************************************************************************
+  * @file    stm320518_eval_i2c_tsensor.h
+  * @author  MCD Application Team
+  * @version V1.0.0
+  * @date    20-April-2012
+  * @brief   This file contains all the functions prototypes for the 
+  *          stm320518_eval_i2c_tsensor.c firmware driver.
+  ******************************************************************************
+  * @attention
+  *
+  * <h2><center>&copy; COPYRIGHT 2012 STMicroelectronics</center></h2>
+  *
+  * 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:
+  *
+  *        http://www.st.com/software_license_agreement_liberty_v2
+  *
+  * 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.
+  *
+  ******************************************************************************
+  */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM320518_EVAL_I2C_TSENSOR_H
+#define __STM320518_EVAL_I2C_TSENSOR_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm320518_eval.h"
+
+/** @addtogroup Utilities
+  * @{
+  */
+  
+/** @addtogroup STM32_EVAL
+  * @{
+  */ 
+
+/** @addtogroup STM320518_EVAL
+  * @{
+  */
+  
+/** @addtogroup STM320518_EVAL_I2C_TSENSOR
+  * @{
+  */  
+
+/** @defgroup STM320518_EVAL_I2C_TSENSOR_Exported_Types
+  * @{
+  */
+   
+/** 
+  * @brief  TSENSOR Status  
+  */ 
+typedef enum
+{
+  LM75_OK = 0,
+  LM75_FAIL
+}LM75_Status_TypDef;
+
+/**
+  * @}
+  */
+  
+/** @defgroup STM320518_EVAL_I2C_TSENSOR_Exported_Constants
+  * @{
+  */ 
+    
+/* Uncomment the following line to use Timeout_User_Callback LM75_TimeoutUserCallback(). 
+   If This Callback is enabled, it should be implemented by user in main function .
+   LM75_TimeoutUserCallback() function is called whenever a timeout condition 
+   occure during communication (waiting on an event that doesn't occur, bus 
+   errors, busy devices ...). */   
+/* #define USE_TIMEOUT_USER_CALLBACK */    
+    
+/* Maximum Timeout values for flags and events waiting loops. These timeouts are
+   not based on accurate values, they just guarantee that the application will 
+   not remain stuck if the I2C communication is corrupted.
+   You may modify these timeout values depending on CPU frequency and application
+   conditions (interrupts routines ...). */   
+#define LM75_FLAG_TIMEOUT         ((uint32_t)0x1000)
+#define LM75_LONG_TIMEOUT         ((uint32_t)(10 * LM75_FLAG_TIMEOUT))    
+    
+
+/**
+  * @brief  Block Size
+  */
+#define LM75_REG_TEMP       0x00  /*!< Temperature Register of LM75 */
+#define LM75_REG_CONF       0x01  /*!< Configuration Register of LM75 */
+#define LM75_REG_THYS       0x02  /*!< Temperature Register of LM75 */
+#define LM75_REG_TOS        0x03  /*!< Over-temp Shutdown threshold Register of LM75 */
+#define I2C_TIMEOUT         ((uint32_t)0x3FFFF) /*!< I2C Time out */
+#define LM75_ADDR           0x90   /*!< LM75 address */
+
+
+#define LM75_I2C_TIMING     0x1045061D
+   
+
+/**
+  * @}
+  */
+
+/** @defgroup STM320518_EVAL_I2C_TSENSOR_Exported_Macros
+  * @{
+  */ 
+/**
+  * @}
+  */ 
+
+/** @defgroup STM320518_EVAL_I2C_TSENSOR_Exported_Functions
+  * @{
+  */ 
+void LM75_DeInit(void);
+void LM75_Init(void);
+ErrorStatus LM75_GetStatus(void);
+uint16_t LM75_ReadTemp(void);
+uint16_t LM75_ReadReg(uint8_t RegName);
+uint8_t LM75_WriteReg(uint8_t RegName, uint16_t RegValue);
+uint8_t LM75_ReadConfReg(void);
+uint8_t LM75_WriteConfReg(uint8_t RegValue);
+uint8_t LM75_ShutDown(FunctionalState NewState);
+
+/** 
+  * @brief  Timeout user callback function. This function is called when a timeout
+  *         condition occurs during communication with LM75. Only protoype
+  *         of this function is decalred in LM75 driver. Its implementation
+  *         may be done into user application. This function may typically stop
+  *         current operations and reset the I2C peripheral and LM75.
+  *         To enable this function use uncomment the define USE_TIMEOUT_USER_CALLBACK
+  *         at the top of this file.          
+  */
+#ifdef USE_TIMEOUT_USER_CALLBACK 
+ uint8_t LM75_TIMEOUT_UserCallback(void);
+#else
+ #define LM75_TIMEOUT_UserCallback()  LM75_FAIL
+#endif /* USE_TIMEOUT_USER_CALLBACK */
+ 
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM320518_EVAL_I2C_TSENSOR_H */
+/**
+  * @}
+  */
+
+/**
+  * @}
+  */
+
+/**
+  * @}
+  */
+
+/**
+  * @}
+  */ 
+
+/**
+  * @}
+  */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 125 - 0
stm32_f0_1/inc/stm320518_eval_i2c_tsensor_cpal.h

@@ -0,0 +1,125 @@
+/**
+  ******************************************************************************
+  * @file    stm320518_eval_i2c_tsensor_cpal.h
+  * @author  MCD Application Team
+  * @version V1.0.0
+  * @date    20-April-2012
+  * @brief   This file contains all the functions prototypes for the 
+  *          stm320518_eval_i2c_tsensor_cpal.c firmware driver.
+  ******************************************************************************
+  * @attention
+  *
+  * <h2><center>&copy; COPYRIGHT 2012 STMicroelectronics</center></h2>
+  *
+  * 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:
+  *
+  *        http://www.st.com/software_license_agreement_liberty_v2
+  *
+  * 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.
+  *
+  ******************************************************************************
+  */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM320518_EVAL_I2C_TSENSOR_CPAL_H
+#define __STM320518_EVAL_I2C_TSENSOR_CPAL_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+   
+   
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f0xx_i2c_cpal.h"
+   
+/* Exported types ------------------------------------------------------------*/
+
+/** 
+  * @brief  TSENSOR Status  
+  */ 
+typedef enum
+{
+  LM75_OK = 0,
+  LM75_FAIL
+}LM75_Status_TypDef;
+
+/* Exported constants --------------------------------------------------------*/
+    
+/*====================== CPAL Structure configuration ========================*/ 
+/* Select I2C device (uncomment relative define) */
+
+//#define LM75_DevStructure                I2C1_DevStructure   
+#define LM75_DevStructure                I2C2_DevStructure  
+
+   
+/*============== TIMING Configuration ==========================*/
+#define LM75_I2C_TIMING 0x1045061D
+
+
+/*=================== Programming model Configuration ========================*/
+/* Select interrupt programming model : By default DMA programming model is selected.
+ To select interrupt programming model uncomment this define */
+//#define LM75_IT
+
+
+/* Maximum Timeout values for waiting until device is ready for communication.*/
+   
+#define LM75_TIMEOUT        ((uint32_t)0x3FFFF)
+
+/**
+  * @brief  Internal register Memory
+  */
+#define LM75_REG_TEMP       0x00  /*!< Temperature Register of LM75 */
+#define LM75_REG_CONF       0x01  /*!< Configuration Register of LM75 */
+#define LM75_REG_THYS       0x02  /*!< Temperature Register of LM75 */
+#define LM75_REG_TOS        0x03  /*!< Over-temp Shutdown threshold Register of LM75 */
+#define LM75_ADDR           0x90   /*!< LM75 address */
+   
+
+/* Exported macro ------------------------------------------------------------*/
+/* Exported functions ------------------------------------------------------- */ 
+
+void LM75_DeInit(void);
+void LM75_Config(void);
+ErrorStatus LM75_GetStatus(void);
+uint16_t LM75_ReadTemp(void);
+uint16_t LM75_ReadReg(uint8_t RegName);
+uint8_t LM75_WriteReg(uint8_t RegName, uint16_t RegValue);
+uint8_t LM75_ReadConfReg(void);
+uint8_t LM75_WriteConfReg(uint8_t RegValue);
+uint8_t LM75_ShutDown(FunctionalState NewState);
+
+
+ 
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM320518_EVAL_I2C_TSENSOR_CPAL_H */
+/**
+  * @}
+  */
+
+/**
+  * @}
+  */
+
+/**
+  * @}
+  */
+
+/**
+  * @}
+  */ 
+
+/**
+  * @}
+  */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 435 - 0
stm32_f0_1/inc/stm320518_eval_lcd.h

@@ -0,0 +1,435 @@
+/**
+  ******************************************************************************
+  * @file    stm320518_eval_lcd.h
+  * @author  MCD Application Team
+  * @version V1.0.0
+  * @date    20-April-2012
+  * @brief   This file contains all the functions prototypes for the stm320518_eval_lcd
+  *          firmware driver.
+  ******************************************************************************
+  * @attention
+  *
+  * <h2><center>&copy; COPYRIGHT 2012 STMicroelectronics</center></h2>
+  *
+  * 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:
+  *
+  *        http://www.st.com/software_license_agreement_liberty_v2
+  *
+  * 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.
+  *
+  ******************************************************************************
+  */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM320518_EVAL_LCD_H
+#define __STM320518_EVAL_LCD_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm320518_eval.h"
+#include "../Common/fonts.h"
+
+/** @addtogroup Utilities
+  * @{
+  */
+  
+/** @addtogroup STM32_EVAL
+  * @{
+  */ 
+
+/** @addtogroup STM320518_EVAL
+  * @{
+  */
+  
+/** @addtogroup STM320518_EVAL_LCD
+  * @{
+  */ 
+
+
+/** @defgroup STM320518_EVAL_LCD_Exported_Types
+  * @{
+  */ 
+typedef struct 
+{
+  int16_t X;
+  int16_t Y;
+} Point, * pPoint;
+
+/**
+  * @}
+  */ 
+
+/** @defgroup STM320518_EVAL_LCD_Exported_Constants
+  * @{
+  */ 
+
+/**
+ * @brief Uncomment the line below if you want to use LCD_DrawBMP function to
+ *        display a bitmap picture on the LCD. This function assumes that the bitmap
+ *        file is loaded in the SPI Flash (mounted on STM320518-EVAL board), however
+ *        user can tailor it according to his application hardware requirement.     
+ */
+/*#define USE_LCD_DrawBMP*/
+
+/**
+ * @brief Uncomment the line below if you want to use user defined Delay function
+ *        (for precise timing), otherwise default _delay_ function defined within
+ *         this driver is used (less precise timing).  
+ */
+/* #define USE_Delay */
+
+#ifdef USE_Delay
+#include "main.h"
+ 
+  #define _delay_     Delay  /* !< User can provide more timing precise _delay_ function
+                                   (with 10ms time base), using SysTick for example */
+#else
+  #define _delay_     delay      /* !< Default _delay_ function with less precise timing */
+#endif                                     
+
+/** 
+  * @brief  LCD Control pins  
+  */ 
+#define LCD_NCS_PIN             GPIO_Pin_4                  
+#define LCD_NCS_GPIO_PORT       GPIOF                     
+#define LCD_NCS_GPIO_CLK        RCC_AHBPeriph_GPIOF 
+#define LCD_NWR_PIN             GPIO_Pin_15
+#define LCD_NWR_GPIO_PORT       GPIOD
+#define LCD_NWR_GPIO_CLK        RCC_AHBPeriph_GPIOD
+#define LCD_RS_PIN              GPIO_Pin_7                     
+#define LCD_RS_GPIO_PORT        GPIOD
+#define LCD_RS_GPIO_CLK         RCC_AHBPeriph_GPIOD 
+
+/** 
+  * @brief  LCD SPI Interface pins 
+  */ 
+#define LCD_SPI_SCK_PIN               GPIO_Pin_5                     /* PA.05 */
+#define LCD_SPI_SCK_GPIO_PORT         GPIOA                          /* GPIOA */
+#define LCD_SPI_SCK_GPIO_CLK          RCC_AHBPeriph_GPIOA  
+#define LCD_SPI_SCK_SOURCE            GPIO_PinSource15
+#define LCD_SPI_SCK_AF                GPIO_AF_0
+
+#if defined (STM320518_EVAL_REVA)
+ #define LCD_SPI_MISO_PIN              GPIO_Pin_6                    /* PA.06 */
+ #define LCD_SPI_MISO_GPIO_PORT        GPIOA                         /* GPIOA */
+ #define LCD_SPI_MISO_GPIO_CLK         RCC_AHBPeriph_GPIOA
+ #define LCD_SPI_MISO_SOURCE           GPIO_PinSource6
+ #define LCD_SPI_MISO_AF               GPIO_AF_0
+#elif defined (STM320518_EVAL_REVB)
+ #define LCD_SPI_MISO_PIN              GPIO_Pin_4                    /* PB.04 */
+ #define LCD_SPI_MISO_GPIO_PORT        GPIOB                         /* GPIOB */
+ #define LCD_SPI_MISO_GPIO_CLK         RCC_AHBPeriph_GPIOB
+ #define LCD_SPI_MISO_SOURCE           GPIO_PinSource4
+ #define LCD_SPI_MISO_AF               GPIO_AF_0
+#endif /* STM320518_EVAL_REVA*/
+
+#define LCD_SPI_MOSI_PIN              GPIO_Pin_7                     /* PA.07 */
+#define LCD_SPI_MOSI_GPIO_PORT        GPIOA                          /* GPIOA */
+#define LCD_SPI_MOSI_GPIO_CLK         RCC_AHBPeriph_GPIOA  
+#define LCD_SPI_MOSI_SOURCE           GPIO_PinSource7
+#define LCD_SPI_MOSI_AF               GPIO_AF_0
+
+#define LCD_SPI                       SPI1
+#define LCD_SPI_CLK                   RCC_APB2Periph_SPI1
+
+/** 
+  * @brief  LCD Registers  
+  */ 
+#define LCD_REG_0             0x00
+#define LCD_REG_1             0x01
+#define LCD_REG_2             0x02
+#define LCD_REG_3             0x03
+#define LCD_REG_4             0x04
+#define LCD_REG_5             0x05
+#define LCD_REG_6             0x06
+#define LCD_REG_7             0x07
+#define LCD_REG_8             0x08
+#define LCD_REG_9             0x09
+#define LCD_REG_10            0x0A
+#define LCD_REG_12            0x0C
+#define LCD_REG_13            0x0D
+#define LCD_REG_14            0x0E
+#define LCD_REG_15            0x0F
+#define LCD_REG_16            0x10
+#define LCD_REG_17            0x11
+#define LCD_REG_18            0x12
+#define LCD_REG_19            0x13
+#define LCD_REG_20            0x14
+#define LCD_REG_21            0x15
+#define LCD_REG_22            0x16
+#define LCD_REG_23            0x17
+#define LCD_REG_24            0x18
+#define LCD_REG_25            0x19
+#define LCD_REG_26            0x1A
+#define LCD_REG_27            0x1B
+#define LCD_REG_28            0x1C
+#define LCD_REG_29            0x1D
+#define LCD_REG_30            0x1E
+#define LCD_REG_31            0x1F
+#define LCD_REG_32            0x20
+#define LCD_REG_33            0x21
+#define LCD_REG_34            0x22
+#define LCD_REG_35            0x23
+#define LCD_REG_36            0x24
+#define LCD_REG_37            0x25
+#define LCD_REG_39            0x27
+#define LCD_REG_40            0x28
+#define LCD_REG_41            0x29
+#define LCD_REG_43            0x2B
+#define LCD_REG_45            0x2D
+#define LCD_REG_48            0x30
+#define LCD_REG_49            0x31
+#define LCD_REG_50            0x32
+#define LCD_REG_51            0x33
+#define LCD_REG_52            0x34
+#define LCD_REG_53            0x35
+#define LCD_REG_54            0x36
+#define LCD_REG_55            0x37
+#define LCD_REG_56            0x38
+#define LCD_REG_57            0x39
+#define LCD_REG_59            0x3B
+#define LCD_REG_60            0x3C
+#define LCD_REG_61            0x3D
+#define LCD_REG_62            0x3E
+#define LCD_REG_63            0x3F
+#define LCD_REG_64            0x40
+#define LCD_REG_65            0x41
+#define LCD_REG_66            0x42
+#define LCD_REG_67            0x43
+#define LCD_REG_68            0x44
+#define LCD_REG_69            0x45
+#define LCD_REG_70            0x46
+#define LCD_REG_71            0x47
+#define LCD_REG_72            0x48
+#define LCD_REG_73            0x49
+#define LCD_REG_74            0x4A
+#define LCD_REG_75            0x4B
+#define LCD_REG_76            0x4C
+#define LCD_REG_77            0x4D
+#define LCD_REG_78            0x4E
+#define LCD_REG_79            0x4F
+#define LCD_REG_80            0x50
+#define LCD_REG_81            0x51
+#define LCD_REG_82            0x52
+#define LCD_REG_83            0x53
+#define LCD_REG_84            0x54
+#define LCD_REG_85            0x55
+#define LCD_REG_86            0x56
+#define LCD_REG_87            0x57
+#define LCD_REG_88            0x58
+#define LCD_REG_89            0x59
+#define LCD_REG_90            0x5A
+#define LCD_REG_91            0x5B
+#define LCD_REG_92            0x5C
+#define LCD_REG_93            0x5D
+#define LCD_REG_96            0x60
+#define LCD_REG_97            0x61
+#define LCD_REG_106           0x6A
+#define LCD_REG_118           0x76
+#define LCD_REG_128           0x80
+#define LCD_REG_129           0x81
+#define LCD_REG_130           0x82
+#define LCD_REG_131           0x83
+#define LCD_REG_132           0x84
+#define LCD_REG_133           0x85
+#define LCD_REG_134           0x86
+#define LCD_REG_135           0x87
+#define LCD_REG_136           0x88
+#define LCD_REG_137           0x89
+#define LCD_REG_139           0x8B
+#define LCD_REG_140           0x8C
+#define LCD_REG_141           0x8D
+#define LCD_REG_143           0x8F
+#define LCD_REG_144           0x90
+#define LCD_REG_145           0x91
+#define LCD_REG_146           0x92
+#define LCD_REG_147           0x93
+#define LCD_REG_148           0x94
+#define LCD_REG_149           0x95
+#define LCD_REG_150           0x96
+#define LCD_REG_151           0x97
+#define LCD_REG_152           0x98
+#define LCD_REG_153           0x99
+#define LCD_REG_154           0x9A
+#define LCD_REG_157           0x9D
+#define LCD_REG_192           0xC0
+#define LCD_REG_193           0xC1
+#define LCD_REG_227           0xE3
+#define LCD_REG_229           0xE5
+#define LCD_REG_231           0xE7
+#define LCD_REG_239           0xEF
+#define LCD_REG_232           0xE8
+#define LCD_REG_233           0xE9
+#define LCD_REG_234           0xEA
+#define LCD_REG_235           0xEB
+#define LCD_REG_236           0xEC
+#define LCD_REG_237           0xED
+#define LCD_REG_241           0xF1
+#define LCD_REG_242           0xF2
+
+
+/** 
+  * @brief  LCD color  
+  */ 
+#define LCD_COLOR_WHITE          0xFFFF
+#define LCD_COLOR_BLACK          0x0000
+#define LCD_COLOR_GREY           0xF7DE
+#define LCD_COLOR_BLUE           0x001F
+#define LCD_COLOR_BLUE2          0x051F
+#define LCD_COLOR_RED            0xF800
+#define LCD_COLOR_MAGENTA        0xF81F
+#define LCD_COLOR_GREEN          0x07E0
+#define LCD_COLOR_CYAN           0x7FFF
+#define LCD_COLOR_YELLOW         0xFFE0
+
+/** 
+  * @brief  LCD Lines depending on the chosen fonts.  
+  */
+#define LCD_LINE_0               LINE(0)
+#define LCD_LINE_1               LINE(1)
+#define LCD_LINE_2               LINE(2)
+#define LCD_LINE_3               LINE(3)
+#define LCD_LINE_4               LINE(4)
+#define LCD_LINE_5               LINE(5)
+#define LCD_LINE_6               LINE(6)
+#define LCD_LINE_7               LINE(7)
+#define LCD_LINE_8               LINE(8)
+#define LCD_LINE_9               LINE(9)
+#define LCD_LINE_10              LINE(10)
+#define LCD_LINE_11              LINE(11)
+#define LCD_LINE_12              LINE(12)
+#define LCD_LINE_13              LINE(13)
+#define LCD_LINE_14              LINE(14)
+#define LCD_LINE_15              LINE(15)
+#define LCD_LINE_16              LINE(16)
+#define LCD_LINE_17              LINE(17)
+#define LCD_LINE_18              LINE(18)
+#define LCD_LINE_19              LINE(19)
+#define LCD_LINE_20              LINE(20)
+#define LCD_LINE_21              LINE(21)
+#define LCD_LINE_22              LINE(22)
+#define LCD_LINE_23              LINE(23)
+#define LCD_LINE_24              LINE(24)
+#define LCD_LINE_25              LINE(25)
+#define LCD_LINE_26              LINE(26)
+#define LCD_LINE_27              LINE(27)
+#define LCD_LINE_28              LINE(28)
+#define LCD_LINE_29              LINE(29)
+
+
+/** 
+  * @brief LCD default font 
+  */ 
+#define LCD_DEFAULT_FONT         Font16x24
+
+/** 
+  * @brief  LCD Direction  
+  */ 
+#define LCD_DIR_HORIZONTAL       0x0000
+#define LCD_DIR_VERTICAL         0x0001
+
+/** 
+  * @brief  LCD Size (Width and Height)  
+  */ 
+#define LCD_PIXEL_WIDTH          0x0140
+#define LCD_PIXEL_HEIGHT         0x00F0
+
+/**
+  * @}
+  */ 
+
+/** @defgroup STM320518_EVAL_LCD_Exported_Macros
+  * @{
+  */ 
+#define ASSEMBLE_RGB(R, G, B)    ((((R)& 0xF8) << 8) | (((G) & 0xFC) << 3) | (((B) & 0xF8) >> 3)) 
+
+/**
+  * @}
+  */ 
+
+/** @defgroup STM320518_EVAL_LCD_Exported_Functions
+  * @{
+  */ 
+void LCD_DeInit(void);
+void LCD_Setup(void);
+void STM320518_LCD_Init(void);
+void LCD_SetColors(__IO uint16_t _TextColor, __IO uint16_t _BackColor); 
+void LCD_GetColors(__IO uint16_t *_TextColor, __IO uint16_t *_BackColor); 
+void LCD_SetTextColor(__IO uint16_t Color);
+void LCD_SetBackColor(__IO uint16_t Color);
+void LCD_ClearLine(uint16_t Line);
+void LCD_Clear(uint16_t Color);
+void LCD_SetCursor(uint16_t Xpos, uint16_t Ypos);
+void LCD_DrawChar(uint16_t Xpos, uint16_t Ypos, const uint16_t *c);
+void LCD_DisplayChar(uint16_t Line, uint16_t Column, uint8_t Ascii);
+void LCD_SetFont(sFONT *fonts);
+sFONT *LCD_GetFont(void);
+void LCD_DisplayStringLine(uint16_t Line, uint8_t *ptr);
+void LCD_SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint8_t Height, uint16_t Width);
+void LCD_WindowModeDisable(void);
+void LCD_DrawLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length, uint8_t Direction);
+void LCD_DrawRect(uint16_t Xpos, uint16_t Ypos, uint8_t Height, uint16_t Width);
+void LCD_DrawCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius);
+void LCD_DrawMonoPict(const uint32_t *Pict);
+void LCD_DrawBMP(uint32_t BmpAddress);
+void LCD_DrawUniLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
+void LCD_DrawFullRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height);
+void LCD_DrawFullCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius);
+void LCD_PolyLine(pPoint Points, uint16_t PointCount);
+void LCD_PolyLineRelative(pPoint Points, uint16_t PointCount);
+void LCD_ClosedPolyLine(pPoint Points, uint16_t PointCount);
+void LCD_ClosedPolyLineRelative(pPoint Points, uint16_t PointCount);
+void LCD_FillPolyLine(pPoint Points, uint16_t PointCount);
+void LCD_nCS_StartByte(uint8_t Start_Byte);
+void LCD_WriteRegIndex(uint8_t LCD_Reg);
+void LCD_WriteReg(uint8_t LCD_Reg, uint16_t LCD_RegValue);
+void LCD_WriteRAM_Prepare(void);
+void LCD_WriteRAMWord(uint16_t RGB_Code);
+uint16_t LCD_ReadReg(uint8_t LCD_Reg);
+void LCD_WriteRAM(uint16_t RGB_Code);
+void LCD_PowerOn(void);
+void LCD_DisplayOn(void);
+void LCD_DisplayOff(void);
+
+
+void LCD_CtrlLinesConfig(void);
+void LCD_CtrlLinesWrite(GPIO_TypeDef* GPIOx, uint16_t CtrlPins, BitAction BitVal);
+void LCD_SPIConfig(void);
+
+/**
+  * @}
+  */ 
+  
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM320518_EVAL_LCD_H */
+
+
+/**
+  * @}
+  */ 
+
+/**
+  * @}
+  */ 
+
+/**
+  * @}
+  */ 
+
+/**
+  * @}
+  */   
+  
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 286 - 0
stm32_f0_1/inc/stm320518_eval_spi_sd.h

@@ -0,0 +1,286 @@
+/**
+  ******************************************************************************
+  * @file    stm320518_eval_spi_sd.h
+  * @author  MCD Application Team
+  * @version V1.0.0
+  * @date    20-April-2012
+  * @brief   This file contains all the functions prototypes for the stm320518_eval_spi_sd
+  *          firmware driver.
+  ******************************************************************************
+  * @attention
+  *
+  * <h2><center>&copy; COPYRIGHT 2012 STMicroelectronics</center></h2>
+  *
+  * 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:
+  *
+  *        http://www.st.com/software_license_agreement_liberty_v2
+  *
+  * 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.
+  *
+  ******************************************************************************
+  */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM320518_EVAL_SPI_SD_H
+#define __STM320518_EVAL_SPI_SD_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm320518_eval.h"
+
+/** @addtogroup Utilities
+  * @{
+  */
+  
+/** @addtogroup STM32_EVAL
+  * @{
+  */
+
+/** @addtogroup STM320518_EVAL
+  * @{
+  */
+
+/** @addtogroup STM320518_EVAL_SPI_SD
+  * @{
+  */  
+
+/** @defgroup STM320518_EVAL_SPI_SD_Exported_Types
+  * @{
+  */ 
+
+typedef enum
+{
+/**
+  * @brief  SD reponses and error flags
+  */
+  SD_RESPONSE_NO_ERROR      = (0x00),
+  SD_IN_IDLE_STATE          = (0x01),
+  SD_ERASE_RESET            = (0x02),
+  SD_ILLEGAL_COMMAND        = (0x04),
+  SD_COM_CRC_ERROR          = (0x08),
+  SD_ERASE_SEQUENCE_ERROR   = (0x10),
+  SD_ADDRESS_ERROR          = (0x20),
+  SD_PARAMETER_ERROR        = (0x40),
+  SD_RESPONSE_FAILURE       = (0xFF),
+
+/**
+  * @brief  Data response error
+  */
+  SD_DATA_OK                = (0x05),
+  SD_DATA_CRC_ERROR         = (0x0B),
+  SD_DATA_WRITE_ERROR       = (0x0D),
+  SD_DATA_OTHER_ERROR       = (0xFF)
+} SD_Error;
+
+/** 
+  * @brief  Card Specific Data: CSD Register
+  */ 
+typedef struct
+{
+  __IO uint8_t  CSDStruct;            /*!< CSD structure */
+  __IO uint8_t  SysSpecVersion;       /*!< System specification version */
+  __IO uint8_t  Reserved1;            /*!< Reserved */
+  __IO uint8_t  TAAC;                 /*!< Data read access-time 1 */
+  __IO uint8_t  NSAC;                 /*!< Data read access-time 2 in CLK cycles */
+  __IO uint8_t  MaxBusClkFrec;        /*!< Max. bus clock frequency */
+  __IO uint16_t CardComdClasses;      /*!< Card command classes */
+  __IO uint8_t  RdBlockLen;           /*!< Max. read data block length */
+  __IO uint8_t  PartBlockRead;        /*!< Partial blocks for read allowed */
+  __IO uint8_t  WrBlockMisalign;      /*!< Write block misalignment */
+  __IO uint8_t  RdBlockMisalign;      /*!< Read block misalignment */
+  __IO uint8_t  DSRImpl;              /*!< DSR implemented */
+  __IO uint8_t  Reserved2;            /*!< Reserved */
+  __IO uint32_t DeviceSize;           /*!< Device Size */
+  __IO uint8_t  MaxRdCurrentVDDMin;   /*!< Max. read current @ VDD min */
+  __IO uint8_t  MaxRdCurrentVDDMax;   /*!< Max. read current @ VDD max */
+  __IO uint8_t  MaxWrCurrentVDDMin;   /*!< Max. write current @ VDD min */
+  __IO uint8_t  MaxWrCurrentVDDMax;   /*!< Max. write current @ VDD max */
+  __IO uint8_t  DeviceSizeMul;        /*!< Device size multiplier */
+  __IO uint8_t  EraseGrSize;          /*!< Erase group size */
+  __IO uint8_t  EraseGrMul;           /*!< Erase group size multiplier */
+  __IO uint8_t  WrProtectGrSize;      /*!< Write protect group size */
+  __IO uint8_t  WrProtectGrEnable;    /*!< Write protect group enable */
+  __IO uint8_t  ManDeflECC;           /*!< Manufacturer default ECC */
+  __IO uint8_t  WrSpeedFact;          /*!< Write speed factor */
+  __IO uint8_t  MaxWrBlockLen;        /*!< Max. write data block length */
+  __IO uint8_t  WriteBlockPaPartial;  /*!< Partial blocks for write allowed */
+  __IO uint8_t  Reserved3;            /*!< Reserded */
+  __IO uint8_t  ContentProtectAppli;  /*!< Content protection application */
+  __IO uint8_t  FileFormatGrouop;     /*!< File format group */
+  __IO uint8_t  CopyFlag;             /*!< Copy flag (OTP) */
+  __IO uint8_t  PermWrProtect;        /*!< Permanent write protection */
+  __IO uint8_t  TempWrProtect;        /*!< Temporary write protection */
+  __IO uint8_t  FileFormat;           /*!< File Format */
+  __IO uint8_t  ECC;                  /*!< ECC code */
+  __IO uint8_t  CSD_CRC;              /*!< CSD CRC */
+  __IO uint8_t  Reserved4;            /*!< always 1*/
+} SD_CSD;
+
+/** 
+  * @brief  Card Identification Data: CID Register   
+  */
+typedef struct
+{
+  __IO uint8_t  ManufacturerID;       /*!< ManufacturerID */
+  __IO uint16_t OEM_AppliID;          /*!< OEM/Application ID */
+  __IO uint32_t ProdName1;            /*!< Product Name part1 */
+  __IO uint8_t  ProdName2;            /*!< Product Name part2*/
+  __IO uint8_t  ProdRev;              /*!< Product Revision */
+  __IO uint32_t ProdSN;               /*!< Product Serial Number */
+  __IO uint8_t  Reserved1;            /*!< Reserved1 */
+  __IO uint16_t ManufactDate;         /*!< Manufacturing Date */
+  __IO uint8_t  CID_CRC;              /*!< CID CRC */
+  __IO uint8_t  Reserved2;            /*!< always 1 */
+} SD_CID;
+
+/** 
+  * @brief SD Card information 
+  */
+typedef struct
+{
+  SD_CSD SD_csd;
+  SD_CID SD_cid;
+  uint32_t CardCapacity;  /*!< Card Capacity */
+  uint32_t CardBlockSize; /*!< Card Block Size */
+} SD_CardInfo;
+
+/**
+  * @}
+  */
+  
+/** @defgroup STM320518_EVAL_SPI_SD_Exported_Constants
+  * @{
+  */ 
+    
+/**
+  * @brief  Block Size
+  */
+#define SD_BLOCK_SIZE    0x200
+
+/**
+  * @brief  Dummy byte
+  */
+#define SD_DUMMY_BYTE   0xFF
+
+/**
+  * @brief  Start Data tokens:
+  *         Tokens (necessary because at nop/idle (and CS active) only 0xff is 
+  *         on the data/command line)  
+  */
+#define SD_START_DATA_SINGLE_BLOCK_READ    0xFE  /*!< Data token start byte, Start Single Block Read */
+#define SD_START_DATA_MULTIPLE_BLOCK_READ  0xFE  /*!< Data token start byte, Start Multiple Block Read */
+#define SD_START_DATA_SINGLE_BLOCK_WRITE   0xFE  /*!< Data token start byte, Start Single Block Write */
+#define SD_START_DATA_MULTIPLE_BLOCK_WRITE 0xFD  /*!< Data token start byte, Start Multiple Block Write */
+#define SD_STOP_DATA_MULTIPLE_BLOCK_WRITE  0xFD  /*!< Data toke stop byte, Stop Multiple Block Write */
+
+/**
+  * @brief  SD detection on its memory slot
+  */
+#define SD_PRESENT        ((uint8_t)0x01)
+#define SD_NOT_PRESENT    ((uint8_t)0x00)
+
+
+/**
+  * @brief  Commands: CMDxx = CMD-number | 0x40
+  */
+#define SD_CMD_GO_IDLE_STATE          0   /*!< CMD0 = 0x40 */
+#define SD_CMD_SEND_OP_COND           1   /*!< CMD1 = 0x41 */
+#define SD_CMD_SEND_CSD               9   /*!< CMD9 = 0x49 */
+#define SD_CMD_SEND_CID               10  /*!< CMD10 = 0x4A */
+#define SD_CMD_STOP_TRANSMISSION      12  /*!< CMD12 = 0x4C */
+#define SD_CMD_SEND_STATUS            13  /*!< CMD13 = 0x4D */
+#define SD_CMD_SET_BLOCKLEN           16  /*!< CMD16 = 0x50 */
+#define SD_CMD_READ_SINGLE_BLOCK      17  /*!< CMD17 = 0x51 */
+#define SD_CMD_READ_MULT_BLOCK        18  /*!< CMD18 = 0x52 */
+#define SD_CMD_SET_BLOCK_COUNT        23  /*!< CMD23 = 0x57 */
+#define SD_CMD_WRITE_SINGLE_BLOCK     24  /*!< CMD24 = 0x58 */
+#define SD_CMD_WRITE_MULT_BLOCK       25  /*!< CMD25 = 0x59 */
+#define SD_CMD_PROG_CSD               27  /*!< CMD27 = 0x5B */
+#define SD_CMD_SET_WRITE_PROT         28  /*!< CMD28 = 0x5C */
+#define SD_CMD_CLR_WRITE_PROT         29  /*!< CMD29 = 0x5D */
+#define SD_CMD_SEND_WRITE_PROT        30  /*!< CMD30 = 0x5E */
+#define SD_CMD_SD_ERASE_GRP_START     32  /*!< CMD32 = 0x60 */
+#define SD_CMD_SD_ERASE_GRP_END       33  /*!< CMD33 = 0x61 */
+#define SD_CMD_UNTAG_SECTOR           34  /*!< CMD34 = 0x62 */
+#define SD_CMD_ERASE_GRP_START        35  /*!< CMD35 = 0x63 */
+#define SD_CMD_ERASE_GRP_END          36  /*!< CMD36 = 0x64 */
+#define SD_CMD_UNTAG_ERASE_GROUP      37  /*!< CMD37 = 0x65 */
+#define SD_CMD_ERASE                  38  /*!< CMD38 = 0x66 */
+
+/**
+  * @}
+  */ 
+  
+/** @defgroup STM320518_EVAL_SPI_SD_Exported_Macros
+  * @{
+  */
+/** 
+  * @brief  Select SD Card: ChipSelect pin low   
+  */  
+#define SD_CS_LOW()     GPIO_ResetBits(SD_CS_GPIO_PORT, SD_CS_PIN)
+/** 
+  * @brief  Deselect SD Card: ChipSelect pin high   
+  */ 
+#define SD_CS_HIGH()    GPIO_SetBits(SD_CS_GPIO_PORT, SD_CS_PIN)
+/**
+  * @}
+  */ 
+
+/** @defgroup STM320518_EVAL_SPI_SD_Exported_Functions
+  * @{
+  */ 
+void SD_DeInit(void);  
+SD_Error SD_Init(void);
+uint8_t SD_Detect(void);
+SD_Error SD_GetCardInfo(SD_CardInfo *cardinfo);
+SD_Error SD_ReadBlock(uint8_t* pBuffer, uint32_t ReadAddr, uint16_t BlockSize);
+SD_Error SD_ReadMultiBlocks(uint8_t* pBuffer, uint32_t ReadAddr, uint16_t BlockSize, uint32_t NumberOfBlocks);
+SD_Error SD_WriteBlock(uint8_t* pBuffer, uint32_t WriteAddr, uint16_t BlockSize);
+SD_Error SD_WriteMultiBlocks(uint8_t* pBuffer, uint32_t WriteAddr, uint16_t BlockSize, uint32_t NumberOfBlocks);
+SD_Error SD_GetCSDRegister(SD_CSD* SD_csd);
+SD_Error SD_GetCIDRegister(SD_CID* SD_cid);
+
+void SD_SendCmd(uint8_t Cmd, uint32_t Arg, uint8_t Crc);
+SD_Error SD_GetResponse(uint8_t Response);
+uint8_t SD_GetDataResponse(void);
+SD_Error SD_GoIdleState(void);
+uint16_t SD_GetStatus(void);
+
+uint8_t SD_WriteByte(uint8_t byte);
+uint8_t SD_ReadByte(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM320518_EVAL_SPI_SD_H */
+/**
+  * @}
+  */
+
+/**
+  * @}
+  */
+
+/**
+  * @}
+  */
+
+/**
+  * @}
+  */
+
+/**
+  * @}
+  */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 208 - 0
stm32_f0_1/inc/stm32_eval_legacy.h

@@ -0,0 +1,208 @@
+/**
+  ******************************************************************************
+  * @file    stm32_eval_legacy.h
+  * @author  MCD Application Team
+  * @version V5.0.2
+  * @date    05-March-2012
+  * @brief   This file contains defines legacy for STM32 EVAL drivers.
+  ******************************************************************************
+  * @attention
+  *
+  * <h2><center>&copy; COPYRIGHT 2012 STMicroelectronics</center></h2>
+  *
+  * 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:
+  *
+  *        http://www.st.com/software_license_agreement_liberty_v2
+  *
+  * 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.
+  *
+  ******************************************************************************
+  */ 
+  
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32_EVAL_LEGACY_H
+#define __STM32_EVAL_LEGACY_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif 
+
+/* Includes ------------------------------------------------------------------*/
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+/* STM322xG_EVAL Defines Legacy */ 
+#ifdef USE_STM3220F_EVAL       
+  #define USE_STM322xG_EVAL
+#endif
+#define STM3220F_LCD_Init       STM322xG_LCD_Init
+
+/* Button Defines Legacy */ 
+#define Button_WAKEUP        BUTTON_WAKEUP
+#define Button_TAMPER        BUTTON_TAMPER
+#define Button_KEY           BUTTON_KEY
+#define Button_RIGHT         BUTTON_RIGHT
+#define Button_LEFT          BUTTON_LEFT
+#define Button_UP            BUTTON_UP
+#define Button_DOWN          BUTTON_DOWN
+#define Button_SEL           BUTTON_SEL
+#define Mode_GPIO            BUTTON_MODE_GPIO
+#define Mode_EXTI            BUTTON_MODE_EXTI
+#define Button_Mode_TypeDef  ButtonMode_TypeDef
+#define JOY_CENTER           JOY_SEL
+#define JOY_State_TypeDef    JOYState_TypeDef 
+
+/* LCD Defines Legacy */ 
+#define LCD_RSNWR_GPIO_CLK  LCD_NWR_GPIO_CLK
+#define LCD_SPI_GPIO_PORT   LCD_SPI_SCK_GPIO_PORT
+#define LCD_SPI_GPIO_CLK    LCD_SPI_SCK_GPIO_CLK
+#define R0                  LCD_REG_0
+#define R1                  LCD_REG_1
+#define R2                  LCD_REG_2
+#define R3                  LCD_REG_3
+#define R4                  LCD_REG_4
+#define R5                  LCD_REG_5
+#define R6                  LCD_REG_6
+#define R7                  LCD_REG_7
+#define R8                  LCD_REG_8
+#define R9                  LCD_REG_9
+#define R10                 LCD_REG_10
+#define R12                 LCD_REG_12
+#define R13                 LCD_REG_13
+#define R14                 LCD_REG_14
+#define R15                 LCD_REG_15
+#define R16                 LCD_REG_16
+#define R17                 LCD_REG_17
+#define R18                 LCD_REG_18
+#define R19                 LCD_REG_19
+#define R20                 LCD_REG_20
+#define R21                 LCD_REG_21
+#define R22                 LCD_REG_22
+#define R23                 LCD_REG_23
+#define R24                 LCD_REG_24
+#define R25                 LCD_REG_25
+#define R26                 LCD_REG_26
+#define R27                 LCD_REG_27
+#define R28                 LCD_REG_28
+#define R29                 LCD_REG_29
+#define R30                 LCD_REG_30
+#define R31                 LCD_REG_31
+#define R32                 LCD_REG_32
+#define R33                 LCD_REG_33
+#define R34                 LCD_REG_34
+#define R36                 LCD_REG_36
+#define R37                 LCD_REG_37
+#define R40                 LCD_REG_40
+#define R41                 LCD_REG_41
+#define R43                 LCD_REG_43
+#define R45                 LCD_REG_45
+#define R48                 LCD_REG_48
+#define R49                 LCD_REG_49
+#define R50                 LCD_REG_50
+#define R51                 LCD_REG_51
+#define R52                 LCD_REG_52
+#define R53                 LCD_REG_53
+#define R54                 LCD_REG_54
+#define R55                 LCD_REG_55
+#define R56                 LCD_REG_56
+#define R57                 LCD_REG_57
+#define R59                 LCD_REG_59
+#define R60                 LCD_REG_60
+#define R61                 LCD_REG_61
+#define R62                 LCD_REG_62
+#define R63                 LCD_REG_63
+#define R64                 LCD_REG_64
+#define R65                 LCD_REG_65
+#define R66                 LCD_REG_66
+#define R67                 LCD_REG_67
+#define R68                 LCD_REG_68
+#define R69                 LCD_REG_69
+#define R70                 LCD_REG_70
+#define R71                 LCD_REG_71
+#define R72                 LCD_REG_72
+#define R73                 LCD_REG_73
+#define R74                 LCD_REG_74
+#define R75                 LCD_REG_75
+#define R76                 LCD_REG_76
+#define R77                 LCD_REG_77
+#define R78                 LCD_REG_78
+#define R79                 LCD_REG_79
+#define R80                 LCD_REG_80
+#define R81                 LCD_REG_81
+#define R82                 LCD_REG_82
+#define R83                 LCD_REG_83
+#define R96                 LCD_REG_96
+#define R97                 LCD_REG_97
+#define R106                LCD_REG_106
+#define R118                LCD_REG_118
+#define R128                LCD_REG_128
+#define R129                LCD_REG_129
+#define R130                LCD_REG_130
+#define R131                LCD_REG_131
+#define R132                LCD_REG_132
+#define R133                LCD_REG_133
+#define R134                LCD_REG_134
+#define R135                LCD_REG_135
+#define R136                LCD_REG_136
+#define R137                LCD_REG_137
+#define R139                LCD_REG_139
+#define R140                LCD_REG_140
+#define R141                LCD_REG_141
+#define R143                LCD_REG_143
+#define R144                LCD_REG_144
+#define R145                LCD_REG_145
+#define R146                LCD_REG_146
+#define R147                LCD_REG_147
+#define R148                LCD_REG_148
+#define R149                LCD_REG_149
+#define R150                LCD_REG_150
+#define R151                LCD_REG_151
+#define R152                LCD_REG_152
+#define R153                LCD_REG_153
+#define R154                LCD_REG_154
+#define R157                LCD_REG_157
+#define R192                LCD_REG_192
+#define R193                LCD_REG_193
+#define R227                LCD_REG_227
+#define R229                LCD_REG_229
+#define R231                LCD_REG_231
+#define R239                LCD_REG_239
+#define White               LCD_COLOR_WHITE
+#define Black               LCD_COLOR_BLACK
+#define Grey                LCD_COLOR_GREY
+#define Blue                LCD_COLOR_BLUE
+#define Blue2               LCD_COLOR_BLUE2
+#define Red                 LCD_COLOR_RED
+#define Magenta             LCD_COLOR_MAGENTA
+#define Green               LCD_COLOR_GREEN
+#define Cyan                LCD_COLOR_CYAN
+#define Yellow              LCD_COLOR_YELLOW
+#define Line0               LCD_LINE_0
+#define Line1               LCD_LINE_1
+#define Line2               LCD_LINE_2
+#define Line3               LCD_LINE_3
+#define Line4               LCD_LINE_4
+#define Line5               LCD_LINE_5
+#define Line6               LCD_LINE_6
+#define Line7               LCD_LINE_7
+#define Line8               LCD_LINE_8
+#define Line9               LCD_LINE_9
+#define Horizontal          LCD_DIR_HORIZONTAL
+#define Vertical            LCD_DIR_VERTICAL
+
+/* Exported macro ------------------------------------------------------------*/
+/* Exported functions --------------------------------------------------------*/ 
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32_EVAL_LEGACY_H */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 648 - 0
stm32_f0_1/lib/stm320518_eval.c

@@ -0,0 +1,648 @@
+/**
+  ******************************************************************************
+  * @file    stm320518_eval.c
+  * @author  MCD Application Team
+  * @version V1.0.0
+  * @date    20-April-2012
+  * @brief   This file provides set of firmware functions to manage Leds, 
+  *          push-button and COM ports.
+  ******************************************************************************
+  * @attention
+  *
+  * <h2><center>&copy; COPYRIGHT 2012 STMicroelectronics</center></h2>
+  *
+  * 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:
+  *
+  *        http://www.st.com/software_license_agreement_liberty_v2
+  *
+  * 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.
+  *
+  ******************************************************************************
+  */
+  
+/* Includes ------------------------------------------------------------------*/
+#include "stm320518_eval.h"
+
+/** @addtogroup Utilities
+  * @{
+  */ 
+
+/** @addtogroup STM32_EVAL
+  * @{
+  */ 
+
+/** @addtogroup STM320518_EVAL
+  * @{
+  */   
+    
+/** @defgroup STM320518_EVAL_LOW_LEVEL 
+  * @brief This file provides firmware functions to manage Leds, push-buttons, 
+  *        COM ports, SD card on SPI and temperature sensor (LM75) available on 
+  *        STM320518-EVAL evaluation board from STMicroelectronics.
+  * @{
+  */ 
+
+/** @defgroup STM320518_EVAL_LOW_LEVEL_Private_TypesDefinitions
+  * @{
+  */ 
+/**
+  * @}
+  */ 
+
+
+/** @defgroup STM320518_EVAL_LOW_LEVEL_Private_Defines
+  * @{
+  */ 
+/**
+  * @}
+  */ 
+
+
+/** @defgroup STM320518_EVAL_LOW_LEVEL_Private_Macros
+  * @{
+  */ 
+/**
+  * @}
+  */ 
+
+
+/** @defgroup STM320518_EVAL_LOW_LEVEL_Private_Variables
+  * @{
+  */ 
+GPIO_TypeDef* GPIO_PORT[LEDn] = {LED1_GPIO_PORT, LED2_GPIO_PORT, LED3_GPIO_PORT,
+                                 LED4_GPIO_PORT};
+const uint16_t GPIO_PIN[LEDn] = {LED1_PIN, LED2_PIN, LED3_PIN,
+                                 LED4_PIN};
+const uint32_t GPIO_CLK[LEDn] = {LED1_GPIO_CLK, LED2_GPIO_CLK, LED3_GPIO_CLK,
+                                 LED4_GPIO_CLK};
+
+GPIO_TypeDef* BUTTON_PORT[BUTTONn] = {TAMPER_BUTTON_GPIO_PORT, KEY_BUTTON_GPIO_PORT, 
+                                      RIGHT_BUTTON_GPIO_PORT, LEFT_BUTTON_GPIO_PORT, 
+                                      UP_BUTTON_GPIO_PORT, DOWN_BUTTON_GPIO_PORT, 
+                                      SEL_BUTTON_GPIO_PORT}; 
+
+const uint16_t BUTTON_PIN[BUTTONn] = {TAMPER_BUTTON_PIN, KEY_BUTTON_PIN, 
+                                      RIGHT_BUTTON_PIN, LEFT_BUTTON_PIN, 
+                                      UP_BUTTON_PIN, DOWN_BUTTON_PIN, 
+                                      SEL_BUTTON_PIN}; 
+
+const uint32_t BUTTON_CLK[BUTTONn] = {TAMPER_BUTTON_GPIO_CLK, KEY_BUTTON_GPIO_CLK, 
+                                      RIGHT_BUTTON_GPIO_CLK, LEFT_BUTTON_GPIO_CLK, 
+                                      UP_BUTTON_GPIO_CLK, DOWN_BUTTON_GPIO_CLK, 
+                                      SEL_BUTTON_GPIO_CLK};
+
+const uint16_t BUTTON_EXTI_LINE[BUTTONn] = {TAMPER_BUTTON_EXTI_LINE, 
+                                            KEY_BUTTON_EXTI_LINE,
+                                            RIGHT_BUTTON_EXTI_LINE,
+                                            LEFT_BUTTON_EXTI_LINE,
+                                            UP_BUTTON_EXTI_LINE,
+                                            DOWN_BUTTON_EXTI_LINE,
+                                            SEL_BUTTON_EXTI_LINE};
+
+const uint16_t BUTTON_PORT_SOURCE[BUTTONn] = {TAMPER_BUTTON_EXTI_PORT_SOURCE, 
+                                              KEY_BUTTON_EXTI_PORT_SOURCE,
+                                              RIGHT_BUTTON_EXTI_PORT_SOURCE,
+                                              LEFT_BUTTON_EXTI_PORT_SOURCE,
+                                              UP_BUTTON_EXTI_PORT_SOURCE,
+                                              DOWN_BUTTON_EXTI_PORT_SOURCE,
+                                              SEL_BUTTON_EXTI_PORT_SOURCE};
+								 
+const uint16_t BUTTON_PIN_SOURCE[BUTTONn] = {TAMPER_BUTTON_EXTI_PIN_SOURCE, 
+                                             KEY_BUTTON_EXTI_PIN_SOURCE,
+                                             RIGHT_BUTTON_EXTI_PIN_SOURCE,
+                                             LEFT_BUTTON_EXTI_PIN_SOURCE,
+                                             UP_BUTTON_EXTI_PIN_SOURCE,
+                                             DOWN_BUTTON_EXTI_PIN_SOURCE,
+                                             SEL_BUTTON_EXTI_PIN_SOURCE}; 
+
+const uint16_t BUTTON_IRQn[BUTTONn] = {TAMPER_BUTTON_EXTI_IRQn, KEY_BUTTON_EXTI_IRQn, 
+                                       RIGHT_BUTTON_EXTI_IRQn, LEFT_BUTTON_EXTI_IRQn, 
+                                       UP_BUTTON_EXTI_IRQn, DOWN_BUTTON_EXTI_IRQn, 
+                                       SEL_BUTTON_EXTI_IRQn};
+
+USART_TypeDef* COM_USART[COMn] = {EVAL_COM1}; 
+
+GPIO_TypeDef* COM_TX_PORT[COMn] = {EVAL_COM1_TX_GPIO_PORT};
+ 
+GPIO_TypeDef* COM_RX_PORT[COMn] = {EVAL_COM1_RX_GPIO_PORT};
+
+const uint32_t COM_USART_CLK[COMn] = {EVAL_COM1_CLK};
+
+const uint32_t COM_TX_PORT_CLK[COMn] = {EVAL_COM1_TX_GPIO_CLK};
+ 
+const uint32_t COM_RX_PORT_CLK[COMn] = {EVAL_COM1_RX_GPIO_CLK};
+
+const uint16_t COM_TX_PIN[COMn] = {EVAL_COM1_TX_PIN};
+
+const uint16_t COM_RX_PIN[COMn] = {EVAL_COM1_RX_PIN};
+ 
+const uint16_t COM_TX_PIN_SOURCE[COMn] = {EVAL_COM1_TX_SOURCE};
+
+const uint16_t COM_RX_PIN_SOURCE[COMn] = {EVAL_COM1_RX_SOURCE};
+ 
+const uint16_t COM_TX_AF[COMn] = {EVAL_COM1_TX_AF};
+ 
+const uint16_t COM_RX_AF[COMn] = {EVAL_COM1_RX_AF};
+
+
+/**
+  * @}
+  */ 
+
+
+/** @defgroup STM320518_EVAL_LOW_LEVEL_Private_FunctionPrototypes
+  * @{
+  */ 
+
+/**
+  * @}
+  */ 
+
+/** @defgroup STM320518_EVAL_LOW_LEVEL_Private_Functions
+  * @{
+  */ 
+
+/**
+  * @brief  Configures LED GPIO.
+  * @param  Led: Specifies the Led to be configured. 
+  *          This parameter can be one of following parameters:
+  *            @arg LED1
+  *            @arg LED2
+  *            @arg LED3
+  *            @arg LED4
+  * @retval None
+  */
+void STM_EVAL_LEDInit(Led_TypeDef Led)
+{
+  GPIO_InitTypeDef  GPIO_InitStructure;
+  
+  /* Enable the GPIO_LED Clock */
+  RCC_AHBPeriphClockCmd(GPIO_CLK[Led], ENABLE);
+
+  /* Configure the GPIO_LED pin */
+  GPIO_InitStructure.GPIO_Pin = GPIO_PIN[Led];
+  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
+  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
+  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
+  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
+  GPIO_Init(GPIO_PORT[Led], &GPIO_InitStructure);
+  GPIO_PORT[Led]->BSRR = GPIO_PIN[Led];
+}
+
+/**
+  * @brief  Turns selected LED On.
+  * @param  Led: Specifies the Led to be set on. 
+  *          This parameter can be one of following parameters:
+  *            @arg LED1
+  *            @arg LED2
+  *            @arg LED3
+  *            @arg LED4  
+  * @retval None
+  */
+void STM_EVAL_LEDOn(Led_TypeDef Led)
+{
+  GPIO_PORT[Led]->BRR = GPIO_PIN[Led];
+}
+
+/**
+  * @brief  Turns selected LED Off.
+  * @param  Led: Specifies the Led to be set off. 
+  *          This parameter can be one of following parameters:
+  *            @arg LED1
+  *            @arg LED2
+  *            @arg LED3
+  *            @arg LED4 
+  * @retval None
+  */
+void STM_EVAL_LEDOff(Led_TypeDef Led)
+{
+  GPIO_PORT[Led]->BSRR = GPIO_PIN[Led];
+}
+
+/**
+  * @brief  Toggles the selected LED.
+  * @param  Led: Specifies the Led to be toggled. 
+  *          This parameter can be one of following parameters:
+  *            @arg LED1
+  *            @arg LED2
+  *            @arg LED3
+  *            @arg LED4  
+  * @retval None
+  */
+void STM_EVAL_LEDToggle(Led_TypeDef Led)
+{
+  GPIO_PORT[Led]->ODR ^= GPIO_PIN[Led];
+}
+
+/**
+  * @brief  Configures Button GPIO and EXTI Line.
+  * @param  Button: Specifies the Button to be configured.
+  *          This parameter can be one of following parameters:
+  *            @arg BUTTON_TAMPER: Tamper Push Button  
+  *            @arg BUTTON_KEY: Key Push Button
+  *            @arg BUTTON_RIGHT: Joystick Right Push Button 
+  *            @arg BUTTON_LEFT: Joystick Left Push Button 
+  *            @arg BUTTON_UP: Joystick Up Push Button 
+  *            @arg BUTTON_DOWN: Joystick Down Push Button
+  *            @arg BUTTON_SEL: Joystick Sel Push Button      
+  * @param  Button_Mode: Specifies Button mode.
+  *          This parameter can be one of following parameters:   
+  *            @arg BUTTON_MODE_GPIO: Button will be used as simple IO 
+  *            @arg BUTTON_MODE_EXTI: Button will be connected to EXTI line with interrupt
+  *                     generation capability
+  * @retval None
+  */
+void STM_EVAL_PBInit(Button_TypeDef Button, ButtonMode_TypeDef Button_Mode)
+{
+  GPIO_InitTypeDef GPIO_InitStructure;
+  EXTI_InitTypeDef EXTI_InitStructure;
+  NVIC_InitTypeDef NVIC_InitStructure;
+
+  /* Enable the BUTTON Clock */
+  RCC_AHBPeriphClockCmd(BUTTON_CLK[Button], ENABLE);
+  RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
+
+  /* Configure Button pin as input */
+  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
+  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
+  GPIO_InitStructure.GPIO_Pin = BUTTON_PIN[Button];
+  GPIO_Init(BUTTON_PORT[Button], &GPIO_InitStructure);
+
+  if (Button_Mode == BUTTON_MODE_EXTI)
+  {
+    /* Connect Button EXTI Line to Button GPIO Pin */
+    SYSCFG_EXTILineConfig(BUTTON_PORT_SOURCE[Button], BUTTON_PIN_SOURCE[Button]);
+
+    /* Configure Button EXTI line */
+    EXTI_InitStructure.EXTI_Line = BUTTON_EXTI_LINE[Button];
+    EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
+    if ((Button != BUTTON_TAMPER) && (Button != BUTTON_KEY))
+    {
+      EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
+    }
+    else
+    {
+      EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;    
+    }
+    EXTI_InitStructure.EXTI_LineCmd = ENABLE;
+    EXTI_Init(&EXTI_InitStructure);
+
+    /* Enable and set Button EXTI Interrupt to the lowest priority */
+    NVIC_InitStructure.NVIC_IRQChannel = BUTTON_IRQn[Button];
+    NVIC_InitStructure.NVIC_IRQChannelPriority = 0x03;
+    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
+
+    NVIC_Init(&NVIC_InitStructure); 
+  }
+}
+
+/**
+  * @brief  Returns the selected Button state.
+  * @param  Button: Specifies the Button to be checked.
+  *          This parameter can be one of following parameters:
+  *            @arg BUTTON_TAMPER: Tamper Push Button  
+  *            @arg BUTTON_KEY: Key Push Button 
+  *            @arg BUTTON_RIGHT: Joystick Right Push Button 
+  *            @arg BUTTON_LEFT: Joystick Left Push Button 
+  *            @arg BUTTON_UP: Joystick Up Push Button 
+  *            @arg BUTTON_DOWN: Joystick Down Push Button
+  *            @arg BUTTON_SEL: Joystick Sel Push Button     
+  * @retval The Button GPIO pin value.
+  */
+uint32_t STM_EVAL_PBGetState(Button_TypeDef Button)
+{
+  /* There is no Wakeup button on STM320518-EVAL. */
+  return GPIO_ReadInputDataBit(BUTTON_PORT[Button], BUTTON_PIN[Button]);
+}
+
+/**
+  * @brief  Configures COM port.
+  * @param  COM: Specifies the COM port to be configured.
+  *          This parameter can be one of following parameters:    
+  *            @arg COM1
+  * @param  USART_InitStruct: pointer to a USART_InitTypeDef structure that
+  *   contains the configuration information for the specified USART peripheral.
+  * @retval None
+  */
+void STM_EVAL_COMInit(COM_TypeDef COM, USART_InitTypeDef* USART_InitStruct)
+{
+  GPIO_InitTypeDef GPIO_InitStructure;
+
+  /* Enable GPIO clock */
+  RCC_AHBPeriphClockCmd(COM_TX_PORT_CLK[COM] | COM_RX_PORT_CLK[COM], ENABLE);
+
+  /* Enable USART clock */
+  RCC_APB2PeriphClockCmd(COM_USART_CLK[COM], ENABLE); 
+
+  /* Connect PXx to USARTx_Tx */
+  GPIO_PinAFConfig(COM_TX_PORT[COM], COM_TX_PIN_SOURCE[COM], COM_TX_AF[COM]);
+
+  /* Connect PXx to USARTx_Rx */
+  GPIO_PinAFConfig(COM_RX_PORT[COM], COM_RX_PIN_SOURCE[COM], COM_RX_AF[COM]);
+  
+  /* Configure USART Tx as alternate function push-pull */
+  GPIO_InitStructure.GPIO_Pin = COM_TX_PIN[COM];
+  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
+  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
+  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
+  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
+  GPIO_Init(COM_TX_PORT[COM], &GPIO_InitStructure);
+    
+  /* Configure USART Rx as alternate function push-pull */
+  GPIO_InitStructure.GPIO_Pin = COM_RX_PIN[COM];
+  GPIO_Init(COM_RX_PORT[COM], &GPIO_InitStructure);
+
+  /* USART configuration */
+  USART_Init(COM_USART[COM], USART_InitStruct);
+    
+  /* Enable USART */
+  USART_Cmd(COM_USART[COM], ENABLE);
+}
+
+/**
+  * @brief  DeInitializes the SPI interface.
+  * @param  None
+  * @retval None
+  */
+void SD_LowLevel_DeInit(void)
+{
+  GPIO_InitTypeDef  GPIO_InitStructure;
+  
+  SPI_Cmd(SD_SPI, DISABLE); /*!< SD_SPI disable */
+  SPI_I2S_DeInit(SD_SPI);   /*!< DeInitializes the SD_SPI */
+  
+  /*!< SD_SPI Periph clock disable */
+  RCC_APB2PeriphClockCmd(SD_SPI_CLK, DISABLE); 
+
+  /*!< Configure SD_SPI pins: SCK */
+  GPIO_InitStructure.GPIO_Pin = SD_SPI_SCK_PIN;
+  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
+  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
+  GPIO_Init(SD_SPI_SCK_GPIO_PORT, &GPIO_InitStructure);
+
+  /*!< Configure SD_SPI pins: MISO */
+  GPIO_InitStructure.GPIO_Pin = SD_SPI_MISO_PIN;
+  GPIO_Init(SD_SPI_MISO_GPIO_PORT, &GPIO_InitStructure);
+
+  /*!< Configure SD_SPI pins: MOSI */
+  GPIO_InitStructure.GPIO_Pin = SD_SPI_MOSI_PIN;
+  GPIO_Init(SD_SPI_MOSI_GPIO_PORT, &GPIO_InitStructure);
+
+  /*!< Configure SD_SPI_CS_PIN pin: SD Card CS pin */
+  GPIO_InitStructure.GPIO_Pin = SD_CS_PIN;
+  GPIO_Init(SD_CS_GPIO_PORT, &GPIO_InitStructure);
+
+  /*!< Configure SD_SPI_DETECT_PIN pin: SD Card detect pin */
+  GPIO_InitStructure.GPIO_Pin = SD_DETECT_PIN;
+  GPIO_Init(SD_DETECT_GPIO_PORT, &GPIO_InitStructure);
+}
+
+/**
+  * @brief  Initializes the SD Card and put it into StandBy State (Ready for 
+  *         data transfer).
+  * @param  None
+  * @retval None
+  */
+void SD_LowLevel_Init(void)
+{
+  GPIO_InitTypeDef  GPIO_InitStructure;
+  SPI_InitTypeDef   SPI_InitStructure;
+
+  /*!< SD_SPI_CS_GPIO, SD_SPI_MOSI_GPIO, SD_SPI_MISO_GPIO, SD_SPI_DETECT_GPIO 
+       and SD_SPI_SCK_GPIO Periph clock enable */
+  RCC_AHBPeriphClockCmd(SD_CS_GPIO_CLK | SD_SPI_MOSI_GPIO_CLK | SD_SPI_MISO_GPIO_CLK |
+                        SD_SPI_SCK_GPIO_CLK | SD_DETECT_GPIO_CLK, ENABLE);
+
+  /*!< SD_SPI Periph clock enable */
+  RCC_APB2PeriphClockCmd(SD_SPI_CLK, ENABLE); 
+
+  /*!< Configure SD_SPI pins: SCK */
+  GPIO_InitStructure.GPIO_Pin = SD_SPI_SCK_PIN;
+  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
+  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
+  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
+  GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_UP;
+  GPIO_Init(SD_SPI_SCK_GPIO_PORT, &GPIO_InitStructure);
+
+  /*!< Configure SD_SPI pins: MISO */
+  GPIO_InitStructure.GPIO_Pin = SD_SPI_MISO_PIN;
+  GPIO_Init(SD_SPI_MISO_GPIO_PORT, &GPIO_InitStructure);
+
+  /*!< Configure SD_SPI pins: MOSI */
+  GPIO_InitStructure.GPIO_Pin = SD_SPI_MOSI_PIN;
+  GPIO_Init(SD_SPI_MOSI_GPIO_PORT, &GPIO_InitStructure);
+
+  /*!< Configure SD_SPI_CS_PIN pin: SD Card CS pin */
+  GPIO_InitStructure.GPIO_Pin = SD_CS_PIN;
+  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
+  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
+  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
+  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
+  GPIO_Init(SD_CS_GPIO_PORT, &GPIO_InitStructure);
+
+  /*!< Configure SD_SPI_DETECT_PIN pin: SD Card detect pin */
+  GPIO_InitStructure.GPIO_Pin = SD_DETECT_PIN;
+  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
+  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
+  GPIO_Init(SD_DETECT_GPIO_PORT, &GPIO_InitStructure);
+
+  /* Connect PXx to SD_SPI_SCK */
+  GPIO_PinAFConfig(SD_SPI_SCK_GPIO_PORT, SD_SPI_SCK_SOURCE, SD_SPI_SCK_AF);
+
+  /* Connect PXx to SD_SPI_MISO */
+  GPIO_PinAFConfig(SD_SPI_MISO_GPIO_PORT, SD_SPI_MISO_SOURCE, SD_SPI_MISO_AF); 
+
+  /* Connect PXx to SD_SPI_MOSI */
+  GPIO_PinAFConfig(SD_SPI_MOSI_GPIO_PORT, SD_SPI_MOSI_SOURCE, SD_SPI_MOSI_AF);  
+  
+  /*!< SD_SPI Config */
+  SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
+  SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
+  SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;
+  SPI_InitStructure.SPI_CPOL = SPI_CPOL_High;
+  SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge;
+  SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
+  SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_2;
+
+  SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
+  SPI_InitStructure.SPI_CRCPolynomial = 7;
+  SPI_Init(SD_SPI, &SPI_InitStructure);
+  
+  SPI_RxFIFOThresholdConfig(SD_SPI, SPI_RxFIFOThreshold_QF);
+  
+  SPI_Cmd(SD_SPI, ENABLE); /*!< SD_SPI enable */
+}
+
+/**
+  * @brief  DeInitializes the LM75_I2C.
+  * @param  None
+  * @retval None
+  */
+void LM75_LowLevel_DeInit(void)
+{
+  GPIO_InitTypeDef  GPIO_InitStructure;
+
+  /*!< Disable LM75_I2C */
+  I2C_Cmd(LM75_I2C, DISABLE);
+  
+  /*!< DeInitializes the LM75_I2C */
+  I2C_DeInit(LM75_I2C);
+  
+  /*!< LM75_I2C Periph clock disable */
+  RCC_APB1PeriphClockCmd(LM75_I2C_CLK, DISABLE);
+    
+  /*!< Configure LM75_I2C pins: SCL */
+  GPIO_InitStructure.GPIO_Pin = LM75_I2C_SCL_PIN;
+  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
+  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
+  GPIO_Init(LM75_I2C_SCL_GPIO_PORT, &GPIO_InitStructure);
+
+  /*!< Configure LM75_I2C pins: SDA */
+  GPIO_InitStructure.GPIO_Pin = LM75_I2C_SDA_PIN;
+  GPIO_Init(LM75_I2C_SDA_GPIO_PORT, &GPIO_InitStructure);
+
+  /*!< Configure LM75_I2C pin: SMBUS ALERT */
+  GPIO_InitStructure.GPIO_Pin = LM75_I2C_SMBUSALERT_PIN;
+  GPIO_Init(LM75_I2C_SMBUSALERT_GPIO_PORT, &GPIO_InitStructure);
+}
+
+/**
+  * @brief  Initializes the LM75_I2C..
+  * @param  None
+  * @retval None
+  */
+void LM75_LowLevel_Init(void)
+{
+  GPIO_InitTypeDef  GPIO_InitStructure;
+
+  /*!< LM75_I2C Periph clock enable */
+  RCC_APB1PeriphClockCmd(LM75_I2C_CLK, ENABLE);
+    
+  /* Configure the I2C clock source. The clock is derived from the HSI */
+  RCC_I2CCLKConfig(RCC_I2C1CLK_HSI);
+