Contains the BSP driver for the B-L475E-IOT01 board.

Dependents:   mbed-os-example-ble-Thermometer DISCO_L475VG_IOT01-Telegram-BOT DISCO_L475VG_IOT01-sche_cheveux DISCO_L475VG_IOT01-QSPI_FLASH_FILE_SYSTEM ... more

https://os.mbed.com/platforms/ST-Discovery-L475E-IOT01A/

Revision:
5:0c70bc6d2dc0
Parent:
4:137bb367ba50
Child:
6:9dfa42666f03
--- a/Drivers/BSP/B-L475E-IOT01/stm32l475e_iot01.c	Fri Apr 14 13:09:54 2017 +0200
+++ b/Drivers/BSP/B-L475E-IOT01/stm32l475e_iot01.c	Tue May 02 16:56:17 2017 +0200
@@ -2,8 +2,8 @@
   ******************************************************************************
   * @file    stm32l475e_iot01.c
   * @author  MCD Application Team
-  * @version V1.0.0
-  * @date    17-March-2017
+  * @version V1.1.0
+  * @date    21-April-2017
   * @brief   STM32L475E-IOT01 board support package
   ******************************************************************************
   * @attention
@@ -47,6 +47,7 @@
 
 /* Includes ------------------------------------------------------------------*/
 #include "stm32l475e_iot01.h"
+
 /** @defgroup BSP BSP
   * @{
   */ 
@@ -63,10 +64,10 @@
   * @{
   */
 /**
- * @brief STM32L475E IOT01 BSP Driver version number V1.0.0
+ * @brief STM32L475E IOT01 BSP Driver version number V1.1.0
    */
 #define __STM32L475E_IOT01_BSP_VERSION_MAIN   (0x01) /*!< [31:24] main version */
-#define __STM32L475E_IOT01_BSP_VERSION_SUB1   (0x00) /*!< [23:16] sub1 version */
+#define __STM32L475E_IOT01_BSP_VERSION_SUB1   (0x01) /*!< [23:16] sub1 version */
 #define __STM32L475E_IOT01_BSP_VERSION_SUB2   (0x00) /*!< [15:8]  sub2 version */
 #define __STM32L475E_IOT01_BSP_VERSION_RC     (0x00) /*!< [7:0]  release candidate */
 #define __STM32L475E_IOT01_BSP_VERSION        ((__STM32L475E_IOT01_BSP_VERSION_MAIN << 24)\
@@ -109,6 +110,7 @@
 
 I2C_HandleTypeDef hI2cHandler;
 UART_HandleTypeDef hDiscoUart;
+
 /**
   * @}
   */
@@ -134,6 +136,15 @@
 HAL_StatusTypeDef SENSOR_IO_IsDeviceReady(uint16_t DevAddress, uint32_t Trials);
 void     SENSOR_IO_Delay(uint32_t Delay);
 
+void     NFC_IO_Init(uint8_t GpoIrqEnable);
+void     NFC_IO_DeInit(void);
+uint16_t NFC_IO_ReadMultiple (uint8_t Addr, uint8_t *pBuffer, uint16_t Length );
+uint16_t NFC_IO_WriteMultiple (uint8_t Addr, uint8_t *pBuffer, uint16_t Length);
+uint16_t NFC_IO_IsDeviceReady (uint8_t Addr, uint32_t Trials);
+void     NFC_IO_ReadState(uint8_t * pPinState);
+void     NFC_IO_RfDisable(uint8_t PinState);
+void     NFC_IO_Delay(uint32_t Delay);
+
 /**
   * @}
   */
@@ -441,7 +452,7 @@
   i2c_handler->Init.OwnAddress2      = 0;
   i2c_handler->Init.GeneralCallMode  = I2C_GENERALCALL_DISABLE;
   i2c_handler->Init.NoStretchMode    = I2C_NOSTRETCH_DISABLE;
-  
+
   /* Init the I2C */
   I2Cx_MspInit(i2c_handler);
   HAL_I2C_Init(i2c_handler);
@@ -644,6 +655,171 @@
   HAL_Delay(Delay);
 }
 
+/******************************** LINK NFC ********************************/
+
+/**
+  * @brief  Initializes Sensors low level.
+  * @param  GpoIrqEnable: 0x0 is disable, otherwise enabled  
+  * @retval None
+  */
+void NFC_IO_Init(uint8_t GpoIrqEnable)
+{
+  GPIO_InitTypeDef GPIO_InitStruct;
+
+  /* I2C init */
+  I2Cx_Init(&hI2cHandler);
+  
+  /* GPIO Ports Clock Enable */
+  NFC_GPIO_CLK_ENABLE();
+  
+  /* Configure GPIO pins for GPO (PE4) */
+  if(GpoIrqEnable == 0)
+  {
+    GPIO_InitStruct.Pin = NFC_GPIO_GPO_PIN;
+    GPIO_InitStruct.Mode = GPIO_MODE_INPUT; 
+    GPIO_InitStruct.Pull = GPIO_PULLUP;
+    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
+    HAL_GPIO_Init(NFC_GPIO_GPO_PIN_PORT, &GPIO_InitStruct);
+  }
+  else
+  {
+    GPIO_InitStruct.Pin = NFC_GPIO_GPO_PIN;
+    GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
+    GPIO_InitStruct.Pull = GPIO_PULLUP;
+    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
+    HAL_GPIO_Init(NFC_GPIO_GPO_PIN_PORT, &GPIO_InitStruct);
+    /* Enable and set EXTI4_IRQn Interrupt to the lowest priority */
+    HAL_NVIC_SetPriority(EXTI4_IRQn, 3, 0);
+    HAL_NVIC_EnableIRQ(EXTI4_IRQn);    
+  }
+  
+  /* Configure GPIO pins for DISABLE (PE2)*/
+  GPIO_InitStruct.Pin = NFC_GPIO_RFDISABLE_PIN;
+  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
+  GPIO_InitStruct.Pull = GPIO_NOPULL;
+  HAL_GPIO_Init(NFC_GPIO_RFDISABLE_PIN_PORT, &GPIO_InitStruct);
+}
+
+/**
+  * @brief  DeInitializes Sensors low level.
+  * @retval None
+  */
+void NFC_IO_DeInit(void)
+{
+  I2Cx_DeInit(&hI2cHandler);
+}
+
+/**
+  * @brief  This functions reads a response of the M24SR device
+  * @param  Addr: M24SR I2C address   (do we really need to add??)
+  * @param  pBuffer : Pointer on the buffer to retrieve M24SR response
+  * @param  Length: Length of the data
+  * @retval Status: Success or Timeout
+  */
+uint16_t NFC_IO_ReadMultiple (uint8_t Addr, uint8_t *pBuffer, uint16_t Length )
+{
+  uint16_t status ;
+    
+    /* Before calling this function M24SR must be ready: check to detect potential issues */
+  status = NFC_IO_IsDeviceReady(Addr, NFC_I2C_TRIALS);
+  if (status != NFC_I2C_STATUS_SUCCESS)
+  {
+    return NFC_I2C_ERROR_TIMEOUT;
+  } 
+    
+  if( HAL_I2C_Master_Receive(&hI2cHandler, Addr, (uint8_t*)pBuffer, Length, NFC_I2C_TIMEOUT_STD) != HAL_OK)
+  {
+    return NFC_I2C_ERROR_TIMEOUT;
+  }
+    
+  return NFC_I2C_STATUS_SUCCESS;    
+}
+
+/**
+  * @brief  This functions sends the command buffer 
+  * @param  Addr: M24SR I2C address   (do we really need to add??)
+  * @param  pBuffer : pointer to the buffer to send to the M24SR
+  * @param  Length: Length of the data
+  * @retval Status: Success or Timeout
+  */
+uint16_t  NFC_IO_WriteMultiple (uint8_t Addr, uint8_t *pBuffer, uint16_t Length) 
+{
+  uint16_t status ;
+    
+  /* Before calling this function M24SR must be ready: check to detect potential issues */
+  status = NFC_IO_IsDeviceReady(Addr, NFC_I2C_TRIALS);
+  if (status != NFC_I2C_STATUS_SUCCESS)
+  {
+    return NFC_I2C_ERROR_TIMEOUT;
+  } 
+    
+  if( HAL_I2C_Master_Transmit(&hI2cHandler, Addr, (uint8_t*)pBuffer, Length, NFC_I2C_TIMEOUT_STD) != HAL_OK)    
+  {
+    return NFC_I2C_ERROR_TIMEOUT;
+  }
+
+  return NFC_I2C_STATUS_SUCCESS;
+}
+
+/**
+  * @brief  Checks if target device is ready for communication.
+  * @param  Addr: M24SR I2C address   (do we really need to add??)
+  * @param  Trials: Number of trials (currently not present in M24sr)
+  * @retval Status: Success or Timeout
+  */
+uint16_t   NFC_IO_IsDeviceReady (uint8_t Addr, uint32_t Trials)
+{
+    HAL_StatusTypeDef status;
+    uint32_t tickstart = 0;
+    uint32_t currenttick = 0;
+    
+    /* Get tick */
+    tickstart = HAL_GetTick();
+    
+    /* Wait until M24SR is ready or timeout occurs */
+    do
+    {
+        status = HAL_I2C_IsDeviceReady(&hI2cHandler, Addr, Trials, NFC_I2C_TIMEOUT_STD);
+        currenttick = HAL_GetTick();
+    } while( ( (currenttick - tickstart) < NFC_I2C_TIMEOUT_MAX) && (status != HAL_OK) );
+    
+    if (status != HAL_OK)
+    {
+        return NFC_I2C_ERROR_TIMEOUT;
+    } 
+
+    return NFC_I2C_STATUS_SUCCESS;
+}
+
+/**
+  * @brief  This function read the state of the M24SR GPO
+  * @param  none
+  * @retval GPIO_PinState : state of the M24SR GPO
+  */
+void NFC_IO_ReadState(uint8_t * pPinState)
+{
+  *pPinState = (uint8_t)HAL_GPIO_ReadPin(NFC_GPIO_GPO_PIN_PORT,NFC_GPIO_GPO_PIN);
+}
+
+/**
+  * @brief  This function set the state of the M24SR RF disable pin
+  * @param  PinState: put RF disable pin of M24SR in PinState (1 or 0)
+  */
+void NFC_IO_RfDisable(uint8_t PinState)
+{
+  HAL_GPIO_WritePin(NFC_GPIO_RFDISABLE_PIN_PORT,NFC_GPIO_RFDISABLE_PIN,(GPIO_PinState)PinState);
+}
+
+/**
+  * @brief  This function wait the time given in param (in milisecond)
+  * @param  Delay: Delay in ms
+  * @retval None
+  */
+void NFC_IO_Delay(uint32_t Delay)
+{
+  HAL_Delay(Delay);
+}
+
 /**
   * @}
   */