Deepti AST
/
Environmental_sheild_F4
Environmental_Shield_F4_API
Fork of Environmental_sheild_F4 by
BSP/Nucleo-F401RE/nucleo-f401re.c@2:e88266f73a67, 2014-08-14 (annotated)
- Committer:
- Deepti
- Date:
- Thu Aug 14 05:25:37 2014 +0000
- Revision:
- 2:e88266f73a67
- Parent:
- 0:c3c9b1c8e3cb
Environmental_Shield_F4_API
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
manoj123 | 0:c3c9b1c8e3cb | 1 | /** |
manoj123 | 0:c3c9b1c8e3cb | 2 | ****************************************************************************** |
manoj123 | 0:c3c9b1c8e3cb | 3 | * @file nucleo-f401re.c |
manoj123 | 0:c3c9b1c8e3cb | 4 | * @author MCD Application Team |
manoj123 | 0:c3c9b1c8e3cb | 5 | * @version V1.0.0 |
manoj123 | 0:c3c9b1c8e3cb | 6 | * @date 22-April-2014 |
manoj123 | 0:c3c9b1c8e3cb | 7 | * @brief This file provides set of firmware functions to manage: |
manoj123 | 0:c3c9b1c8e3cb | 8 | * - LEDs and push-button available on NUCLEO-F401RE Kit |
manoj123 | 0:c3c9b1c8e3cb | 9 | * from STMicroelectronics |
manoj123 | 0:c3c9b1c8e3cb | 10 | ****************************************************************************** |
manoj123 | 0:c3c9b1c8e3cb | 11 | * @attention |
manoj123 | 0:c3c9b1c8e3cb | 12 | * |
manoj123 | 0:c3c9b1c8e3cb | 13 | * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> |
manoj123 | 0:c3c9b1c8e3cb | 14 | * |
manoj123 | 0:c3c9b1c8e3cb | 15 | * Redistribution and use in source and binary forms, with or without modification, |
manoj123 | 0:c3c9b1c8e3cb | 16 | * are permitted provided that the following conditions are met: |
manoj123 | 0:c3c9b1c8e3cb | 17 | * 1. Redistributions of source code must retain the above copyright notice, |
manoj123 | 0:c3c9b1c8e3cb | 18 | * this list of conditions and the following disclaimer. |
manoj123 | 0:c3c9b1c8e3cb | 19 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
manoj123 | 0:c3c9b1c8e3cb | 20 | * this list of conditions and the following disclaimer in the documentation |
manoj123 | 0:c3c9b1c8e3cb | 21 | * and/or other materials provided with the distribution. |
manoj123 | 0:c3c9b1c8e3cb | 22 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
manoj123 | 0:c3c9b1c8e3cb | 23 | * may be used to endorse or promote products derived from this software |
manoj123 | 0:c3c9b1c8e3cb | 24 | * without specific prior written permission. |
manoj123 | 0:c3c9b1c8e3cb | 25 | * |
manoj123 | 0:c3c9b1c8e3cb | 26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
manoj123 | 0:c3c9b1c8e3cb | 27 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
manoj123 | 0:c3c9b1c8e3cb | 28 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
manoj123 | 0:c3c9b1c8e3cb | 29 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
manoj123 | 0:c3c9b1c8e3cb | 30 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
manoj123 | 0:c3c9b1c8e3cb | 31 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
manoj123 | 0:c3c9b1c8e3cb | 32 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
manoj123 | 0:c3c9b1c8e3cb | 33 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
manoj123 | 0:c3c9b1c8e3cb | 34 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
manoj123 | 0:c3c9b1c8e3cb | 35 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
manoj123 | 0:c3c9b1c8e3cb | 36 | * |
manoj123 | 0:c3c9b1c8e3cb | 37 | ****************************************************************************** |
manoj123 | 0:c3c9b1c8e3cb | 38 | */ |
manoj123 | 0:c3c9b1c8e3cb | 39 | |
manoj123 | 0:c3c9b1c8e3cb | 40 | /* Includes ------------------------------------------------------------------*/ |
manoj123 | 0:c3c9b1c8e3cb | 41 | #include "nucleo-f401re.h" |
manoj123 | 0:c3c9b1c8e3cb | 42 | //#include "cmsis_os.h" |
manoj123 | 0:c3c9b1c8e3cb | 43 | //#include "stm32f4xx_hal.h" |
manoj123 | 0:c3c9b1c8e3cb | 44 | //#include "stm32f4xx_hal_i2c.h" |
manoj123 | 0:c3c9b1c8e3cb | 45 | //#include "stm32f4xx_hal_i2c_ex.h" |
manoj123 | 0:c3c9b1c8e3cb | 46 | |
manoj123 | 0:c3c9b1c8e3cb | 47 | |
manoj123 | 0:c3c9b1c8e3cb | 48 | /** @addtogroup BSP |
manoj123 | 0:c3c9b1c8e3cb | 49 | * @{ |
manoj123 | 0:c3c9b1c8e3cb | 50 | */ |
manoj123 | 0:c3c9b1c8e3cb | 51 | |
manoj123 | 0:c3c9b1c8e3cb | 52 | /** @addtogroup NUCLEO_F401RE |
manoj123 | 0:c3c9b1c8e3cb | 53 | * @{ |
manoj123 | 0:c3c9b1c8e3cb | 54 | */ |
manoj123 | 0:c3c9b1c8e3cb | 55 | |
manoj123 | 0:c3c9b1c8e3cb | 56 | /** @addtogroup NUCLEO_F401RE_LOW_LEVEL |
manoj123 | 0:c3c9b1c8e3cb | 57 | * @brief This file provides set of firmware functions to manage Leds and push-button |
manoj123 | 0:c3c9b1c8e3cb | 58 | * available on NUCLEO-F401RE Kit from STMicroelectronics. |
manoj123 | 0:c3c9b1c8e3cb | 59 | * @{ |
manoj123 | 0:c3c9b1c8e3cb | 60 | */ |
manoj123 | 0:c3c9b1c8e3cb | 61 | |
manoj123 | 0:c3c9b1c8e3cb | 62 | /** @defgroup NUCLEO_F401RE_LOW_LEVEL_Private_TypesDefinitions |
manoj123 | 0:c3c9b1c8e3cb | 63 | * @{ |
manoj123 | 0:c3c9b1c8e3cb | 64 | */ |
manoj123 | 0:c3c9b1c8e3cb | 65 | /** |
manoj123 | 0:c3c9b1c8e3cb | 66 | * @} |
manoj123 | 0:c3c9b1c8e3cb | 67 | */ |
manoj123 | 0:c3c9b1c8e3cb | 68 | |
manoj123 | 0:c3c9b1c8e3cb | 69 | |
manoj123 | 0:c3c9b1c8e3cb | 70 | /** @defgroup NUCLEO_F401RE_LOW_LEVEL_Private_Defines |
manoj123 | 0:c3c9b1c8e3cb | 71 | * @{ |
manoj123 | 0:c3c9b1c8e3cb | 72 | */ |
manoj123 | 0:c3c9b1c8e3cb | 73 | |
manoj123 | 0:c3c9b1c8e3cb | 74 | /** |
manoj123 | 0:c3c9b1c8e3cb | 75 | * @brief STM32L0XX NUCLEO BSP Driver version number V1.0.0 |
manoj123 | 0:c3c9b1c8e3cb | 76 | */ |
manoj123 | 0:c3c9b1c8e3cb | 77 | #define __NUCLEO_F401RE_BSP_VERSION_MAIN (0x01) /*!< [31:24] main version */ |
manoj123 | 0:c3c9b1c8e3cb | 78 | #define __NUCLEO_F401RE_BSP_VERSION_SUB1 (0x00) /*!< [23:16] sub1 version */ |
manoj123 | 0:c3c9b1c8e3cb | 79 | #define __NUCLEO_F401RE_BSP_VERSION_SUB2 (0x00) /*!< [15:8] sub2 version */ |
manoj123 | 0:c3c9b1c8e3cb | 80 | #define __NUCLEO_F401RE_BSP_VERSION_RC (0x00) /*!< [7:0] release candidate */ |
manoj123 | 0:c3c9b1c8e3cb | 81 | #define __NUCLEO_F401RE_BSP_VERSION ((__NUCLEO_F401RE_BSP_VERSION_MAIN << 24)\ |
manoj123 | 0:c3c9b1c8e3cb | 82 | |(__NUCLEO_F401RE_BSP_VERSION_SUB1 << 16)\ |
manoj123 | 0:c3c9b1c8e3cb | 83 | |(__NUCLEO_F401RE_BSP_VERSION_SUB2 << 8 )\ |
manoj123 | 0:c3c9b1c8e3cb | 84 | |(__NUCLEO_F401RE_BSP_VERSION_RC)) |
manoj123 | 0:c3c9b1c8e3cb | 85 | |
manoj123 | 0:c3c9b1c8e3cb | 86 | /** |
manoj123 | 0:c3c9b1c8e3cb | 87 | * @brief LINK SD Card |
manoj123 | 0:c3c9b1c8e3cb | 88 | */ |
manoj123 | 0:c3c9b1c8e3cb | 89 | #define SD_DUMMY_BYTE 0xFF |
manoj123 | 0:c3c9b1c8e3cb | 90 | #define SD_NO_RESPONSE_EXPECTED 0x80 |
manoj123 | 0:c3c9b1c8e3cb | 91 | |
manoj123 | 0:c3c9b1c8e3cb | 92 | /** |
manoj123 | 0:c3c9b1c8e3cb | 93 | * @} |
manoj123 | 0:c3c9b1c8e3cb | 94 | */ |
manoj123 | 0:c3c9b1c8e3cb | 95 | |
manoj123 | 0:c3c9b1c8e3cb | 96 | /** @defgroup NUCLEO_F401RE_LOW_LEVEL_Private_Macros |
manoj123 | 0:c3c9b1c8e3cb | 97 | * @{ |
manoj123 | 0:c3c9b1c8e3cb | 98 | */ |
manoj123 | 0:c3c9b1c8e3cb | 99 | /** |
manoj123 | 0:c3c9b1c8e3cb | 100 | * @} |
manoj123 | 0:c3c9b1c8e3cb | 101 | */ |
manoj123 | 0:c3c9b1c8e3cb | 102 | |
manoj123 | 0:c3c9b1c8e3cb | 103 | /** @defgroup NUCLEO_F401RE_LOW_LEVEL_Private_Variables |
manoj123 | 0:c3c9b1c8e3cb | 104 | * @{ |
manoj123 | 0:c3c9b1c8e3cb | 105 | */ |
manoj123 | 0:c3c9b1c8e3cb | 106 | GPIO_TypeDef* GPIO_PORT[LEDn] = {LED2_GPIO_PORT}; |
manoj123 | 0:c3c9b1c8e3cb | 107 | |
manoj123 | 0:c3c9b1c8e3cb | 108 | const uint16_t GPIO_PIN[LEDn] = {LED2_PIN}; |
manoj123 | 0:c3c9b1c8e3cb | 109 | |
manoj123 | 0:c3c9b1c8e3cb | 110 | GPIO_TypeDef* BUTTON_PORT[BUTTONn] = {KEY_BUTTON_GPIO_PORT}; |
manoj123 | 0:c3c9b1c8e3cb | 111 | const uint16_t BUTTON_PIN[BUTTONn] = {KEY_BUTTON_PIN}; |
manoj123 | 0:c3c9b1c8e3cb | 112 | const uint16_t BUTTON_IRQn[BUTTONn] = {KEY_BUTTON_EXTI_IRQn}; |
manoj123 | 0:c3c9b1c8e3cb | 113 | |
manoj123 | 0:c3c9b1c8e3cb | 114 | /** |
manoj123 | 0:c3c9b1c8e3cb | 115 | * @brief BUS variables |
manoj123 | 0:c3c9b1c8e3cb | 116 | */ |
manoj123 | 0:c3c9b1c8e3cb | 117 | |
manoj123 | 0:c3c9b1c8e3cb | 118 | //uint32_t SpixTimeout = NUCLEO_SPIx_TIMEOUT_MAX; /*<! Value of Timeout when SPI communication fails */ |
manoj123 | 0:c3c9b1c8e3cb | 119 | //static SPI_HandleTypeDef hnucleo_Spi; |
manoj123 | 0:c3c9b1c8e3cb | 120 | //static ADC_HandleTypeDef hnucleo_Adc; |
manoj123 | 0:c3c9b1c8e3cb | 121 | |
manoj123 | 0:c3c9b1c8e3cb | 122 | /* ADC channel configuration structure declaration */ |
manoj123 | 0:c3c9b1c8e3cb | 123 | //static ADC_ChannelConfTypeDef sConfig; |
manoj123 | 0:c3c9b1c8e3cb | 124 | |
manoj123 | 0:c3c9b1c8e3cb | 125 | /** |
manoj123 | 0:c3c9b1c8e3cb | 126 | * @} |
manoj123 | 0:c3c9b1c8e3cb | 127 | */ |
manoj123 | 0:c3c9b1c8e3cb | 128 | |
manoj123 | 0:c3c9b1c8e3cb | 129 | uint32_t I2C_SHIELDS_Timeout = NUCLEO_I2C_SHIELDS_TIMEOUT_MAX; /*<! Value of Timeout when I2C communication fails */ |
manoj123 | 0:c3c9b1c8e3cb | 130 | |
manoj123 | 0:c3c9b1c8e3cb | 131 | static I2C_HandleTypeDef I2C_SHIELDS_Handle; |
manoj123 | 0:c3c9b1c8e3cb | 132 | |
manoj123 | 0:c3c9b1c8e3cb | 133 | //osMutexId I2C1_Mutex_id = 0; |
manoj123 | 0:c3c9b1c8e3cb | 134 | |
manoj123 | 0:c3c9b1c8e3cb | 135 | /** @defgroup NUCLEO_F401RE_LOW_LEVEL_Private_FunctionPrototypes |
manoj123 | 0:c3c9b1c8e3cb | 136 | * @{ |
manoj123 | 0:c3c9b1c8e3cb | 137 | */ |
manoj123 | 0:c3c9b1c8e3cb | 138 | |
manoj123 | 0:c3c9b1c8e3cb | 139 | /* Link function for PRESSURE peripheral */ |
manoj123 | 0:c3c9b1c8e3cb | 140 | void PRESSURE_IO_Init(void); |
manoj123 | 0:c3c9b1c8e3cb | 141 | void PRESSURE_IO_ITConfig(void); |
manoj123 | 0:c3c9b1c8e3cb | 142 | void PRESSURE_IO_Write(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t WriteAddr, uint16_t NumByteToWrite); |
manoj123 | 0:c3c9b1c8e3cb | 143 | void PRESSURE_IO_Read(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr, uint16_t NumByteToRead); |
manoj123 | 0:c3c9b1c8e3cb | 144 | |
manoj123 | 0:c3c9b1c8e3cb | 145 | /* Link function for UV peripheral */ |
manoj123 | 0:c3c9b1c8e3cb | 146 | void UV_IO_Init(void); |
manoj123 | 0:c3c9b1c8e3cb | 147 | void UV_IO_ITConfig(void); |
manoj123 | 0:c3c9b1c8e3cb | 148 | void UV_IO_Write(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t WriteAddr, uint16_t NumByteToWrite); |
manoj123 | 0:c3c9b1c8e3cb | 149 | void UV_IO_Read(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr, uint16_t NumByteToRead); |
manoj123 | 0:c3c9b1c8e3cb | 150 | |
manoj123 | 0:c3c9b1c8e3cb | 151 | /* Link function for HUM_TEMP peripheral */ |
manoj123 | 0:c3c9b1c8e3cb | 152 | void HUM_TEMP_IO_Init(void); |
manoj123 | 0:c3c9b1c8e3cb | 153 | void HUM_TEMP_IO_ITConfig(void); |
manoj123 | 0:c3c9b1c8e3cb | 154 | void HUM_TEMP_IO_Write(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t WriteAddr, uint16_t NumByteToWrite); |
manoj123 | 0:c3c9b1c8e3cb | 155 | void HUM_TEMP_IO_Read(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr, uint16_t NumByteToRead); |
manoj123 | 0:c3c9b1c8e3cb | 156 | |
manoj123 | 0:c3c9b1c8e3cb | 157 | |
manoj123 | 0:c3c9b1c8e3cb | 158 | static void I2C_SHIELDS_MspInit(void); |
manoj123 | 0:c3c9b1c8e3cb | 159 | static void I2C_SHIELDS_Error(uint8_t Addr); |
manoj123 | 0:c3c9b1c8e3cb | 160 | |
manoj123 | 0:c3c9b1c8e3cb | 161 | /** |
manoj123 | 0:c3c9b1c8e3cb | 162 | * @} |
manoj123 | 0:c3c9b1c8e3cb | 163 | */ |
manoj123 | 0:c3c9b1c8e3cb | 164 | |
manoj123 | 0:c3c9b1c8e3cb | 165 | /** @defgroup NUCLEO_F401RE_LOW_LEVEL_Private_Functions |
manoj123 | 0:c3c9b1c8e3cb | 166 | * @{ |
manoj123 | 0:c3c9b1c8e3cb | 167 | */ |
manoj123 | 0:c3c9b1c8e3cb | 168 | |
manoj123 | 0:c3c9b1c8e3cb | 169 | /** |
manoj123 | 0:c3c9b1c8e3cb | 170 | * @brief This method returns the STM32L0XX NUCLEO BSP Driver revision |
manoj123 | 0:c3c9b1c8e3cb | 171 | * @param None |
manoj123 | 0:c3c9b1c8e3cb | 172 | * @retval version : 0xXYZR (8bits for each decimal, R for RC) |
manoj123 | 0:c3c9b1c8e3cb | 173 | */ |
manoj123 | 0:c3c9b1c8e3cb | 174 | uint32_t BSP_GetVersion(void) |
manoj123 | 0:c3c9b1c8e3cb | 175 | { |
manoj123 | 0:c3c9b1c8e3cb | 176 | return __NUCLEO_F401RE_BSP_VERSION; |
manoj123 | 0:c3c9b1c8e3cb | 177 | } |
manoj123 | 0:c3c9b1c8e3cb | 178 | |
manoj123 | 0:c3c9b1c8e3cb | 179 | |
manoj123 | 0:c3c9b1c8e3cb | 180 | /** |
manoj123 | 0:c3c9b1c8e3cb | 181 | * @brief Configures Button GPIO and EXTI Line. |
manoj123 | 0:c3c9b1c8e3cb | 182 | * @param Button: Specifies the Button to be configured. |
manoj123 | 0:c3c9b1c8e3cb | 183 | * This parameter should be: BUTTON_KEY |
manoj123 | 0:c3c9b1c8e3cb | 184 | * @param ButtonMode: Specifies Button mode. |
manoj123 | 0:c3c9b1c8e3cb | 185 | * This parameter can be one of following parameters: |
manoj123 | 0:c3c9b1c8e3cb | 186 | * @arg BUTTON_MODE_GPIO: Button will be used as simple IO |
manoj123 | 0:c3c9b1c8e3cb | 187 | * @arg BUTTON_MODE_EXTI: Button will be connected to EXTI line with interrupt |
manoj123 | 0:c3c9b1c8e3cb | 188 | * generation capability |
manoj123 | 0:c3c9b1c8e3cb | 189 | * @retval None |
manoj123 | 0:c3c9b1c8e3cb | 190 | */ |
manoj123 | 0:c3c9b1c8e3cb | 191 | void BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef Button_Mode) |
manoj123 | 0:c3c9b1c8e3cb | 192 | { |
manoj123 | 0:c3c9b1c8e3cb | 193 | GPIO_InitTypeDef GPIO_InitStruct; |
manoj123 | 0:c3c9b1c8e3cb | 194 | |
manoj123 | 0:c3c9b1c8e3cb | 195 | /* Enable the BUTTON Clock */ |
manoj123 | 0:c3c9b1c8e3cb | 196 | BUTTONx_GPIO_CLK_ENABLE(Button); |
manoj123 | 0:c3c9b1c8e3cb | 197 | __SYSCFG_CLK_ENABLE(); |
manoj123 | 0:c3c9b1c8e3cb | 198 | |
manoj123 | 0:c3c9b1c8e3cb | 199 | if(Button_Mode == BUTTON_MODE_GPIO) |
manoj123 | 0:c3c9b1c8e3cb | 200 | { |
manoj123 | 0:c3c9b1c8e3cb | 201 | /* Configure Button pin as input */ |
manoj123 | 0:c3c9b1c8e3cb | 202 | GPIO_InitStruct.Pin = BUTTON_PIN[Button]; |
manoj123 | 0:c3c9b1c8e3cb | 203 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT; |
manoj123 | 0:c3c9b1c8e3cb | 204 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
manoj123 | 0:c3c9b1c8e3cb | 205 | GPIO_InitStruct.Speed = GPIO_SPEED_FAST; |
manoj123 | 0:c3c9b1c8e3cb | 206 | |
manoj123 | 0:c3c9b1c8e3cb | 207 | HAL_GPIO_Init(BUTTON_PORT[Button], &GPIO_InitStruct); |
manoj123 | 0:c3c9b1c8e3cb | 208 | } |
manoj123 | 0:c3c9b1c8e3cb | 209 | |
manoj123 | 0:c3c9b1c8e3cb | 210 | if(Button_Mode == BUTTON_MODE_EXTI) |
manoj123 | 0:c3c9b1c8e3cb | 211 | { |
manoj123 | 0:c3c9b1c8e3cb | 212 | /* Configure Button pin as input with External interrupt */ |
manoj123 | 0:c3c9b1c8e3cb | 213 | GPIO_InitStruct.Pin = BUTTON_PIN[Button]; |
manoj123 | 0:c3c9b1c8e3cb | 214 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
manoj123 | 0:c3c9b1c8e3cb | 215 | GPIO_InitStruct.Speed = GPIO_SPEED_FAST; |
manoj123 | 0:c3c9b1c8e3cb | 216 | GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; |
manoj123 | 0:c3c9b1c8e3cb | 217 | HAL_GPIO_Init(BUTTON_PORT[Button], &GPIO_InitStruct); |
manoj123 | 0:c3c9b1c8e3cb | 218 | |
manoj123 | 0:c3c9b1c8e3cb | 219 | /* Enable and set Button EXTI Interrupt to the lowest priority */ |
manoj123 | 0:c3c9b1c8e3cb | 220 | NVIC_SetPriority((IRQn_Type)(BUTTON_IRQn[Button]), 0x03); |
manoj123 | 0:c3c9b1c8e3cb | 221 | HAL_NVIC_EnableIRQ((IRQn_Type)(BUTTON_IRQn[Button])); |
manoj123 | 0:c3c9b1c8e3cb | 222 | } |
manoj123 | 0:c3c9b1c8e3cb | 223 | } |
manoj123 | 0:c3c9b1c8e3cb | 224 | |
manoj123 | 0:c3c9b1c8e3cb | 225 | /** |
manoj123 | 0:c3c9b1c8e3cb | 226 | * @brief Returns the selected Button state. |
manoj123 | 0:c3c9b1c8e3cb | 227 | * @param Button: Specifies the Button to be checked. |
manoj123 | 0:c3c9b1c8e3cb | 228 | * This parameter should be: BUTTON_KEY |
manoj123 | 0:c3c9b1c8e3cb | 229 | * @retval The Button GPIO pin value. |
manoj123 | 0:c3c9b1c8e3cb | 230 | */ |
manoj123 | 0:c3c9b1c8e3cb | 231 | uint32_t BSP_PB_GetState(Button_TypeDef Button) |
manoj123 | 0:c3c9b1c8e3cb | 232 | { |
manoj123 | 0:c3c9b1c8e3cb | 233 | return HAL_GPIO_ReadPin(BUTTON_PORT[Button], BUTTON_PIN[Button]); |
manoj123 | 0:c3c9b1c8e3cb | 234 | } |
manoj123 | 0:c3c9b1c8e3cb | 235 | |
manoj123 | 0:c3c9b1c8e3cb | 236 | /******************************* I2C Routines**********************************/ |
manoj123 | 0:c3c9b1c8e3cb | 237 | /** |
manoj123 | 0:c3c9b1c8e3cb | 238 | * @brief Configures I2C interface. |
manoj123 | 0:c3c9b1c8e3cb | 239 | * @param None |
manoj123 | 0:c3c9b1c8e3cb | 240 | * @retval None |
manoj123 | 0:c3c9b1c8e3cb | 241 | */ |
manoj123 | 0:c3c9b1c8e3cb | 242 | static void I2C_SHIELDS_Init(void) |
manoj123 | 0:c3c9b1c8e3cb | 243 | { |
manoj123 | 0:c3c9b1c8e3cb | 244 | if(HAL_I2C_GetState(&I2C_SHIELDS_Handle) == HAL_I2C_STATE_RESET) |
manoj123 | 0:c3c9b1c8e3cb | 245 | { |
manoj123 | 0:c3c9b1c8e3cb | 246 | /* I2C_SHIELDS peripheral configuration */ |
manoj123 | 0:c3c9b1c8e3cb | 247 | I2C_SHIELDS_Handle.Init.ClockSpeed = NUCLEO_I2C_SHIELDS_SPEED; |
manoj123 | 0:c3c9b1c8e3cb | 248 | I2C_SHIELDS_Handle.Init.DutyCycle = I2C_DUTYCYCLE_2; |
manoj123 | 0:c3c9b1c8e3cb | 249 | I2C_SHIELDS_Handle.Init.OwnAddress1 = 0x33; |
manoj123 | 0:c3c9b1c8e3cb | 250 | I2C_SHIELDS_Handle.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT; |
manoj123 | 0:c3c9b1c8e3cb | 251 | I2C_SHIELDS_Handle.Instance = NUCLEO_I2C_SHIELDS; |
manoj123 | 0:c3c9b1c8e3cb | 252 | |
manoj123 | 0:c3c9b1c8e3cb | 253 | /* Init the I2C */ |
manoj123 | 0:c3c9b1c8e3cb | 254 | I2C_SHIELDS_MspInit(); |
manoj123 | 0:c3c9b1c8e3cb | 255 | HAL_I2C_Init(&I2C_SHIELDS_Handle); |
manoj123 | 0:c3c9b1c8e3cb | 256 | } |
manoj123 | 0:c3c9b1c8e3cb | 257 | } |
manoj123 | 0:c3c9b1c8e3cb | 258 | |
manoj123 | 0:c3c9b1c8e3cb | 259 | /** |
manoj123 | 0:c3c9b1c8e3cb | 260 | * @brief Write a value in a register of the device through BUS. |
manoj123 | 0:c3c9b1c8e3cb | 261 | * @param Addr: Device address on BUS Bus. |
manoj123 | 0:c3c9b1c8e3cb | 262 | * @param Reg: The target register address to write |
manoj123 | 0:c3c9b1c8e3cb | 263 | * @param Value: The target register value to be written |
manoj123 | 0:c3c9b1c8e3cb | 264 | * @retval HAL status |
manoj123 | 0:c3c9b1c8e3cb | 265 | */ |
manoj123 | 0:c3c9b1c8e3cb | 266 | |
manoj123 | 0:c3c9b1c8e3cb | 267 | static void I2C_SHIELDS_WriteData(uint8_t* pBuffer, uint8_t Addr, uint8_t Reg, uint16_t Size) |
manoj123 | 0:c3c9b1c8e3cb | 268 | { |
manoj123 | 0:c3c9b1c8e3cb | 269 | HAL_StatusTypeDef status = HAL_OK; |
manoj123 | 0:c3c9b1c8e3cb | 270 | |
manoj123 | 0:c3c9b1c8e3cb | 271 | status = HAL_I2C_Mem_Write(&I2C_SHIELDS_Handle, Addr, (uint16_t)Reg, I2C_MEMADD_SIZE_8BIT, pBuffer, Size, I2C_SHIELDS_Timeout); |
manoj123 | 0:c3c9b1c8e3cb | 272 | |
manoj123 | 0:c3c9b1c8e3cb | 273 | /* Check the communication status */ |
manoj123 | 0:c3c9b1c8e3cb | 274 | if(status != HAL_OK) |
manoj123 | 0:c3c9b1c8e3cb | 275 | { |
manoj123 | 0:c3c9b1c8e3cb | 276 | /* Execute user timeout callback */ |
manoj123 | 0:c3c9b1c8e3cb | 277 | I2C_SHIELDS_Error(Addr); |
manoj123 | 0:c3c9b1c8e3cb | 278 | } |
manoj123 | 0:c3c9b1c8e3cb | 279 | } |
manoj123 | 0:c3c9b1c8e3cb | 280 | |
manoj123 | 0:c3c9b1c8e3cb | 281 | /** |
manoj123 | 0:c3c9b1c8e3cb | 282 | * @brief Read a register of the device through BUS |
manoj123 | 0:c3c9b1c8e3cb | 283 | * @param Addr: Device address on BUS . |
manoj123 | 0:c3c9b1c8e3cb | 284 | * @param Reg: The target register address to read |
manoj123 | 0:c3c9b1c8e3cb | 285 | * @retval HAL status |
manoj123 | 0:c3c9b1c8e3cb | 286 | */ |
manoj123 | 0:c3c9b1c8e3cb | 287 | static void I2C_SHIELDS_ReadData(uint8_t* pBuffer, uint8_t Addr, uint8_t Reg, uint16_t Size) |
manoj123 | 0:c3c9b1c8e3cb | 288 | { |
manoj123 | 0:c3c9b1c8e3cb | 289 | HAL_StatusTypeDef status = HAL_OK; |
manoj123 | 0:c3c9b1c8e3cb | 290 | |
manoj123 | 0:c3c9b1c8e3cb | 291 | status = HAL_I2C_Mem_Read(&I2C_SHIELDS_Handle, Addr, (uint16_t)Reg, I2C_MEMADD_SIZE_8BIT, pBuffer, Size, I2C_SHIELDS_Timeout); |
manoj123 | 0:c3c9b1c8e3cb | 292 | |
manoj123 | 0:c3c9b1c8e3cb | 293 | /* Check the communication status */ |
manoj123 | 0:c3c9b1c8e3cb | 294 | if(status != HAL_OK) |
manoj123 | 0:c3c9b1c8e3cb | 295 | { |
manoj123 | 0:c3c9b1c8e3cb | 296 | /* Execute user timeout callback */ |
manoj123 | 0:c3c9b1c8e3cb | 297 | I2C_SHIELDS_Error(Addr); |
manoj123 | 0:c3c9b1c8e3cb | 298 | } |
manoj123 | 0:c3c9b1c8e3cb | 299 | |
manoj123 | 0:c3c9b1c8e3cb | 300 | } |
manoj123 | 0:c3c9b1c8e3cb | 301 | |
manoj123 | 0:c3c9b1c8e3cb | 302 | /** |
manoj123 | 0:c3c9b1c8e3cb | 303 | * @brief Manages error callback by re-initializing I2C. |
manoj123 | 0:c3c9b1c8e3cb | 304 | * @param Addr: I2C Address |
manoj123 | 0:c3c9b1c8e3cb | 305 | * @retval None |
manoj123 | 0:c3c9b1c8e3cb | 306 | */ |
manoj123 | 0:c3c9b1c8e3cb | 307 | static void I2C_SHIELDS_Error(uint8_t Addr) |
manoj123 | 0:c3c9b1c8e3cb | 308 | { |
manoj123 | 0:c3c9b1c8e3cb | 309 | /* De-initialize the I2C comunication bus */ |
manoj123 | 0:c3c9b1c8e3cb | 310 | HAL_I2C_DeInit(&I2C_SHIELDS_Handle); |
manoj123 | 0:c3c9b1c8e3cb | 311 | |
manoj123 | 0:c3c9b1c8e3cb | 312 | /* Re-Initiaize the I2C comunication bus */ |
manoj123 | 0:c3c9b1c8e3cb | 313 | I2C_SHIELDS_Init(); |
manoj123 | 0:c3c9b1c8e3cb | 314 | } |
manoj123 | 0:c3c9b1c8e3cb | 315 | |
manoj123 | 0:c3c9b1c8e3cb | 316 | /** |
manoj123 | 0:c3c9b1c8e3cb | 317 | * @brief I2C MSP Initialization |
manoj123 | 0:c3c9b1c8e3cb | 318 | * @param None |
manoj123 | 0:c3c9b1c8e3cb | 319 | * @retval None |
manoj123 | 0:c3c9b1c8e3cb | 320 | */ |
manoj123 | 0:c3c9b1c8e3cb | 321 | static void I2C_SHIELDS_MspInit(void) |
manoj123 | 0:c3c9b1c8e3cb | 322 | { |
manoj123 | 0:c3c9b1c8e3cb | 323 | GPIO_InitTypeDef GPIO_InitStruct; |
manoj123 | 0:c3c9b1c8e3cb | 324 | |
manoj123 | 0:c3c9b1c8e3cb | 325 | /*if(!NUCLEO_I2C_SHIELDS_MUTEX) { |
manoj123 | 0:c3c9b1c8e3cb | 326 | NUCLEO_I2C_SHIELDS_MUTEX = osMutexCreate(0); |
manoj123 | 0:c3c9b1c8e3cb | 327 | }*/ |
manoj123 | 0:c3c9b1c8e3cb | 328 | /* Enable I2C GPIO clocks */ |
manoj123 | 0:c3c9b1c8e3cb | 329 | NUCLEO_I2C_SHIELDS_SCL_SDA_GPIO_CLK_ENABLE(); |
manoj123 | 0:c3c9b1c8e3cb | 330 | |
manoj123 | 0:c3c9b1c8e3cb | 331 | /* I2C_SHIELDS SCL and SDA pins configuration -------------------------------------*/ |
manoj123 | 0:c3c9b1c8e3cb | 332 | GPIO_InitStruct.Pin = NUCLEO_I2C_SHIELDS_SCL_PIN | NUCLEO_I2C_SHIELDS_SDA_PIN; |
manoj123 | 0:c3c9b1c8e3cb | 333 | GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; |
manoj123 | 0:c3c9b1c8e3cb | 334 | GPIO_InitStruct.Speed = GPIO_SPEED_FAST; |
manoj123 | 0:c3c9b1c8e3cb | 335 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
manoj123 | 0:c3c9b1c8e3cb | 336 | GPIO_InitStruct.Alternate = NUCLEO_I2C_SHIELDS_SCL_SDA_AF; |
manoj123 | 0:c3c9b1c8e3cb | 337 | HAL_GPIO_Init(NUCLEO_I2C_SHIELDS_SCL_SDA_GPIO_PORT, &GPIO_InitStruct); |
manoj123 | 0:c3c9b1c8e3cb | 338 | |
manoj123 | 0:c3c9b1c8e3cb | 339 | /* Enable the I2C_SHIELDS peripheral clock */ |
manoj123 | 0:c3c9b1c8e3cb | 340 | NUCLEO_I2C_SHIELDS_CLK_ENABLE(); |
manoj123 | 0:c3c9b1c8e3cb | 341 | |
manoj123 | 0:c3c9b1c8e3cb | 342 | /* Force the I2C peripheral clock reset */ |
manoj123 | 0:c3c9b1c8e3cb | 343 | NUCLEO_I2C_SHIELDS_FORCE_RESET(); |
manoj123 | 0:c3c9b1c8e3cb | 344 | |
manoj123 | 0:c3c9b1c8e3cb | 345 | /* Release the I2C peripheral clock reset */ |
manoj123 | 0:c3c9b1c8e3cb | 346 | NUCLEO_I2C_SHIELDS_RELEASE_RESET(); |
manoj123 | 0:c3c9b1c8e3cb | 347 | |
manoj123 | 0:c3c9b1c8e3cb | 348 | /* Enable and set I2C_SHIELDS Interrupt to the highest priority */ |
manoj123 | 0:c3c9b1c8e3cb | 349 | HAL_NVIC_SetPriority(NUCLEO_I2C_SHIELDS_EV_IRQn, 0, 0); |
manoj123 | 0:c3c9b1c8e3cb | 350 | HAL_NVIC_EnableIRQ(NUCLEO_I2C_SHIELDS_EV_IRQn); |
manoj123 | 0:c3c9b1c8e3cb | 351 | |
manoj123 | 0:c3c9b1c8e3cb | 352 | /* Enable and set I2C_SHIELDS Interrupt to the highest priority */ |
manoj123 | 0:c3c9b1c8e3cb | 353 | HAL_NVIC_SetPriority(NUCLEO_I2C_SHIELDS_ER_IRQn, 0, 0); |
manoj123 | 0:c3c9b1c8e3cb | 354 | HAL_NVIC_EnableIRQ(NUCLEO_I2C_SHIELDS_ER_IRQn); |
manoj123 | 0:c3c9b1c8e3cb | 355 | } |
manoj123 | 0:c3c9b1c8e3cb | 356 | |
manoj123 | 0:c3c9b1c8e3cb | 357 | |
manoj123 | 0:c3c9b1c8e3cb | 358 | /********************************* LINK PRESSURE *****************************/ |
manoj123 | 0:c3c9b1c8e3cb | 359 | /** |
manoj123 | 0:c3c9b1c8e3cb | 360 | * @brief Configures Pressure I2C interface. |
manoj123 | 0:c3c9b1c8e3cb | 361 | * @param None |
manoj123 | 0:c3c9b1c8e3cb | 362 | * @retval None |
manoj123 | 0:c3c9b1c8e3cb | 363 | */ |
manoj123 | 0:c3c9b1c8e3cb | 364 | void PRESSURE_IO_Init(void) |
manoj123 | 0:c3c9b1c8e3cb | 365 | { |
manoj123 | 0:c3c9b1c8e3cb | 366 | I2C_SHIELDS_Init(); |
manoj123 | 0:c3c9b1c8e3cb | 367 | } |
manoj123 | 0:c3c9b1c8e3cb | 368 | |
manoj123 | 0:c3c9b1c8e3cb | 369 | /** |
manoj123 | 0:c3c9b1c8e3cb | 370 | * @brief Writes a buffer to the Pressure sensor. |
manoj123 | 0:c3c9b1c8e3cb | 371 | * @param pBuffer: pointer to data to be written. |
manoj123 | 0:c3c9b1c8e3cb | 372 | * @param DeviceAddr: specifies the slave address to be programmed. |
manoj123 | 0:c3c9b1c8e3cb | 373 | * @param RegisterAddr: specifies the Pressure register to be written. |
manoj123 | 0:c3c9b1c8e3cb | 374 | * @param NumByteToWrite: number of bytes to be written. |
manoj123 | 0:c3c9b1c8e3cb | 375 | * @retval None. |
manoj123 | 0:c3c9b1c8e3cb | 376 | */ |
manoj123 | 0:c3c9b1c8e3cb | 377 | void PRESSURE_IO_Write(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr, uint16_t NumByteToWrite) |
manoj123 | 0:c3c9b1c8e3cb | 378 | { |
manoj123 | 0:c3c9b1c8e3cb | 379 | //NUCLEO_I2C_SHIELDS_MUTEX_TAKE(); |
manoj123 | 0:c3c9b1c8e3cb | 380 | /* call I2C_SHIELDS Read data bus function */ |
manoj123 | 0:c3c9b1c8e3cb | 381 | I2C_SHIELDS_WriteData(pBuffer, DeviceAddr, RegisterAddr, NumByteToWrite); |
manoj123 | 0:c3c9b1c8e3cb | 382 | //NUCLEO_I2C_SHIELDS_MUTEX_RELEASE(); |
manoj123 | 0:c3c9b1c8e3cb | 383 | } |
manoj123 | 0:c3c9b1c8e3cb | 384 | |
manoj123 | 0:c3c9b1c8e3cb | 385 | /** |
manoj123 | 0:c3c9b1c8e3cb | 386 | * @brief Reads a buffer from the Pressure sensor. |
manoj123 | 0:c3c9b1c8e3cb | 387 | * @param pBuffer: pointer to data to be read. |
manoj123 | 0:c3c9b1c8e3cb | 388 | * @param DeviceAddr: specifies the address of the device. |
manoj123 | 0:c3c9b1c8e3cb | 389 | * @param RegisterAddr: specifies the Pressure internal address register to read from. |
manoj123 | 0:c3c9b1c8e3cb | 390 | * @param NumByteToRead: number of bytes to be read. |
manoj123 | 0:c3c9b1c8e3cb | 391 | * @retval None. |
manoj123 | 0:c3c9b1c8e3cb | 392 | */ |
manoj123 | 0:c3c9b1c8e3cb | 393 | void PRESSURE_IO_Read(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr, uint16_t NumByteToRead) |
manoj123 | 0:c3c9b1c8e3cb | 394 | { |
manoj123 | 0:c3c9b1c8e3cb | 395 | //NUCLEO_I2C_SHIELDS_MUTEX_TAKE(); |
manoj123 | 0:c3c9b1c8e3cb | 396 | /* call I2C_SHIELDS Read data bus function */ |
manoj123 | 0:c3c9b1c8e3cb | 397 | I2C_SHIELDS_ReadData(pBuffer, DeviceAddr, RegisterAddr, NumByteToRead); |
manoj123 | 0:c3c9b1c8e3cb | 398 | //NUCLEO_I2C_SHIELDS_MUTEX_RELEASE(); |
manoj123 | 0:c3c9b1c8e3cb | 399 | } |
manoj123 | 0:c3c9b1c8e3cb | 400 | |
manoj123 | 0:c3c9b1c8e3cb | 401 | |
manoj123 | 0:c3c9b1c8e3cb | 402 | |
manoj123 | 0:c3c9b1c8e3cb | 403 | |
manoj123 | 0:c3c9b1c8e3cb | 404 | /********************************* LINK UVI *****************************/ |
manoj123 | 0:c3c9b1c8e3cb | 405 | /** |
manoj123 | 0:c3c9b1c8e3cb | 406 | * @brief Configures Uvi I2C interface. |
manoj123 | 0:c3c9b1c8e3cb | 407 | * @param None |
manoj123 | 0:c3c9b1c8e3cb | 408 | * @retval None |
manoj123 | 0:c3c9b1c8e3cb | 409 | */ |
manoj123 | 0:c3c9b1c8e3cb | 410 | void UV_IO_Init(void) |
manoj123 | 0:c3c9b1c8e3cb | 411 | { |
manoj123 | 0:c3c9b1c8e3cb | 412 | I2C_SHIELDS_Init(); |
manoj123 | 0:c3c9b1c8e3cb | 413 | } |
manoj123 | 0:c3c9b1c8e3cb | 414 | |
manoj123 | 0:c3c9b1c8e3cb | 415 | /** |
manoj123 | 0:c3c9b1c8e3cb | 416 | * @brief Writes a buffer to the Uvi sensor. |
manoj123 | 0:c3c9b1c8e3cb | 417 | * @param pBuffer: pointer to data to be written. |
manoj123 | 0:c3c9b1c8e3cb | 418 | * @param DeviceAddr: specifies the slave address to be programmed. |
manoj123 | 0:c3c9b1c8e3cb | 419 | * @param RegisterAddr: specifies the Pressure register to be written. |
manoj123 | 0:c3c9b1c8e3cb | 420 | * @param NumByteToWrite: number of bytes to be written. |
manoj123 | 0:c3c9b1c8e3cb | 421 | * @retval None. |
manoj123 | 0:c3c9b1c8e3cb | 422 | */ |
manoj123 | 0:c3c9b1c8e3cb | 423 | void UV_IO_Write(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr, uint16_t NumByteToWrite) |
manoj123 | 0:c3c9b1c8e3cb | 424 | { |
manoj123 | 0:c3c9b1c8e3cb | 425 | //NUCLEO_I2C_SHIELDS_MUTEX_TAKE(); |
manoj123 | 0:c3c9b1c8e3cb | 426 | /* call I2C_SHIELDS Read data bus function */ |
manoj123 | 0:c3c9b1c8e3cb | 427 | I2C_SHIELDS_WriteData(pBuffer, DeviceAddr, RegisterAddr, NumByteToWrite); |
manoj123 | 0:c3c9b1c8e3cb | 428 | //NUCLEO_I2C_SHIELDS_MUTEX_RELEASE(); |
manoj123 | 0:c3c9b1c8e3cb | 429 | } |
manoj123 | 0:c3c9b1c8e3cb | 430 | |
manoj123 | 0:c3c9b1c8e3cb | 431 | /** |
manoj123 | 0:c3c9b1c8e3cb | 432 | * @brief Reads a buffer from the Uvi sensor. |
manoj123 | 0:c3c9b1c8e3cb | 433 | * @param pBuffer: pointer to data to be read. |
manoj123 | 0:c3c9b1c8e3cb | 434 | * @param DeviceAddr: specifies the address of the device. |
manoj123 | 0:c3c9b1c8e3cb | 435 | * @param RegisterAddr: specifies the Pressure internal address register to read from. |
manoj123 | 0:c3c9b1c8e3cb | 436 | * @param NumByteToRead: number of bytes to be read. |
manoj123 | 0:c3c9b1c8e3cb | 437 | * @retval None. |
manoj123 | 0:c3c9b1c8e3cb | 438 | */ |
manoj123 | 0:c3c9b1c8e3cb | 439 | void UV_IO_Read(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr, uint16_t NumByteToRead) |
manoj123 | 0:c3c9b1c8e3cb | 440 | { |
manoj123 | 0:c3c9b1c8e3cb | 441 | //NUCLEO_I2C_SHIELDS_MUTEX_TAKE(); |
manoj123 | 0:c3c9b1c8e3cb | 442 | /* call I2C_SHIELDS Read data bus function */ |
manoj123 | 0:c3c9b1c8e3cb | 443 | I2C_SHIELDS_ReadData(pBuffer, DeviceAddr, RegisterAddr, NumByteToRead); |
manoj123 | 0:c3c9b1c8e3cb | 444 | //NUCLEO_I2C_SHIELDS_MUTEX_RELEASE(); |
manoj123 | 0:c3c9b1c8e3cb | 445 | } |
manoj123 | 0:c3c9b1c8e3cb | 446 | |
manoj123 | 0:c3c9b1c8e3cb | 447 | |
manoj123 | 0:c3c9b1c8e3cb | 448 | |
manoj123 | 0:c3c9b1c8e3cb | 449 | |
manoj123 | 0:c3c9b1c8e3cb | 450 | |
manoj123 | 0:c3c9b1c8e3cb | 451 | /********************************* LINK HUM_TEMP *****************************/ |
manoj123 | 0:c3c9b1c8e3cb | 452 | /** |
manoj123 | 0:c3c9b1c8e3cb | 453 | * @brief Configures Uvi I2C interface. |
manoj123 | 0:c3c9b1c8e3cb | 454 | * @param None |
manoj123 | 0:c3c9b1c8e3cb | 455 | * @retval None |
manoj123 | 0:c3c9b1c8e3cb | 456 | */ |
manoj123 | 0:c3c9b1c8e3cb | 457 | void HUM_TEMP_IO_Init(void) |
manoj123 | 0:c3c9b1c8e3cb | 458 | { |
manoj123 | 0:c3c9b1c8e3cb | 459 | I2C_SHIELDS_Init(); |
manoj123 | 0:c3c9b1c8e3cb | 460 | } |
manoj123 | 0:c3c9b1c8e3cb | 461 | |
manoj123 | 0:c3c9b1c8e3cb | 462 | /** |
manoj123 | 0:c3c9b1c8e3cb | 463 | * @brief Writes a buffer to the Uvi sensor. |
manoj123 | 0:c3c9b1c8e3cb | 464 | * @param pBuffer: pointer to data to be written. |
manoj123 | 0:c3c9b1c8e3cb | 465 | * @param DeviceAddr: specifies the slave address to be programmed. |
manoj123 | 0:c3c9b1c8e3cb | 466 | * @param RegisterAddr: specifies the Pressure register to be written. |
manoj123 | 0:c3c9b1c8e3cb | 467 | * @param NumByteToWrite: number of bytes to be written. |
manoj123 | 0:c3c9b1c8e3cb | 468 | * @retval None. |
manoj123 | 0:c3c9b1c8e3cb | 469 | */ |
manoj123 | 0:c3c9b1c8e3cb | 470 | void HUM_TEMP_IO_Write(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr, uint16_t NumByteToWrite) |
manoj123 | 0:c3c9b1c8e3cb | 471 | { |
manoj123 | 0:c3c9b1c8e3cb | 472 | //NUCLEO_I2C_SHIELDS_MUTEX_TAKE(); |
manoj123 | 0:c3c9b1c8e3cb | 473 | /* call I2C_SHIELDS Read data bus function */ |
manoj123 | 0:c3c9b1c8e3cb | 474 | I2C_SHIELDS_WriteData(pBuffer, DeviceAddr, RegisterAddr, NumByteToWrite); |
manoj123 | 0:c3c9b1c8e3cb | 475 | //NUCLEO_I2C_SHIELDS_MUTEX_RELEASE(); |
manoj123 | 0:c3c9b1c8e3cb | 476 | } |
manoj123 | 0:c3c9b1c8e3cb | 477 | |
manoj123 | 0:c3c9b1c8e3cb | 478 | /** |
manoj123 | 0:c3c9b1c8e3cb | 479 | * @brief Reads a buffer from the Uvi sensor. |
manoj123 | 0:c3c9b1c8e3cb | 480 | * @param pBuffer: pointer to data to be read. |
manoj123 | 0:c3c9b1c8e3cb | 481 | * @param DeviceAddr: specifies the address of the device. |
manoj123 | 0:c3c9b1c8e3cb | 482 | * @param RegisterAddr: specifies the Pressure internal address register to read from. |
manoj123 | 0:c3c9b1c8e3cb | 483 | * @param NumByteToRead: number of bytes to be read. |
manoj123 | 0:c3c9b1c8e3cb | 484 | * @retval None. |
manoj123 | 0:c3c9b1c8e3cb | 485 | */ |
manoj123 | 0:c3c9b1c8e3cb | 486 | void HUM_TEMP_IO_Read(uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr, uint16_t NumByteToRead) |
manoj123 | 0:c3c9b1c8e3cb | 487 | { |
manoj123 | 0:c3c9b1c8e3cb | 488 | //NUCLEO_I2C_SHIELDS_MUTEX_TAKE(); |
manoj123 | 0:c3c9b1c8e3cb | 489 | /* call I2C_SHIELDS Read data bus function */ |
manoj123 | 0:c3c9b1c8e3cb | 490 | I2C_SHIELDS_ReadData(pBuffer, DeviceAddr, RegisterAddr, NumByteToRead); |
manoj123 | 0:c3c9b1c8e3cb | 491 | //NUCLEO_I2C_SHIELDS_MUTEX_RELEASE(); |
manoj123 | 0:c3c9b1c8e3cb | 492 | } |
manoj123 | 0:c3c9b1c8e3cb | 493 | |
manoj123 | 0:c3c9b1c8e3cb | 494 | /** |
manoj123 | 0:c3c9b1c8e3cb | 495 | * @} |
manoj123 | 0:c3c9b1c8e3cb | 496 | */ |
manoj123 | 0:c3c9b1c8e3cb | 497 | |
manoj123 | 0:c3c9b1c8e3cb | 498 | /** |
manoj123 | 0:c3c9b1c8e3cb | 499 | * @} |
manoj123 | 0:c3c9b1c8e3cb | 500 | */ |
manoj123 | 0:c3c9b1c8e3cb | 501 | |
manoj123 | 0:c3c9b1c8e3cb | 502 | /** |
manoj123 | 0:c3c9b1c8e3cb | 503 | * @} |
manoj123 | 0:c3c9b1c8e3cb | 504 | */ |
manoj123 | 0:c3c9b1c8e3cb | 505 | |
manoj123 | 0:c3c9b1c8e3cb | 506 | /** |
manoj123 | 0:c3c9b1c8e3cb | 507 | * @} |
manoj123 | 0:c3c9b1c8e3cb | 508 | */ |
manoj123 | 0:c3c9b1c8e3cb | 509 | |
manoj123 | 0:c3c9b1c8e3cb | 510 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
manoj123 | 0:c3c9b1c8e3cb | 511 |