p3 fin
This commit is contained in:
BIN
P3_SETR2/BSP/B-L475E-IOT01_BSP_User_Manual.chm
Normal file
BIN
P3_SETR2/BSP/B-L475E-IOT01_BSP_User_Manual.chm
Normal file
Binary file not shown.
118
P3_SETR2/BSP/Release_Notes.html
Normal file
118
P3_SETR2/BSP/Release_Notes.html
Normal file
@@ -0,0 +1,118 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="generator" content="pandoc" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
|
||||
<title>Release Notes for B-L475E-IOT01A Board Drivers</title>
|
||||
<style type="text/css">
|
||||
code{white-space: pre-wrap;}
|
||||
span.smallcaps{font-variant: small-caps;}
|
||||
span.underline{text-decoration: underline;}
|
||||
div.column{display: inline-block; vertical-align: top; width: 50%;}
|
||||
</style>
|
||||
<link rel="stylesheet" href="_htmresc/mini-st.css" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
|
||||
<![endif]-->
|
||||
</head>
|
||||
<body>
|
||||
<div class="row">
|
||||
<div class="col-sm-12 col-lg-4">
|
||||
<div class="card fluid">
|
||||
<div class="sectione dark">
|
||||
<center>
|
||||
<h1 id="release-notes-for-b-l475e-iot01a-board-drivers"><small>Release Notes for</small> <mark>B-L475E-IOT01A Board Drivers</mark></h1>
|
||||
<p>Copyright © 2017 STMicroelectronics<br />
|
||||
</p>
|
||||
<a href="https://www.st.com" class="logo"><img src="_htmresc/st_logo.png" alt="ST logo" /></a>
|
||||
</center>
|
||||
</div>
|
||||
</div>
|
||||
<h1 id="license">License</h1>
|
||||
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
|
||||
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
|
||||
<h1 id="purpose">Purpose</h1>
|
||||
<p>This directory contains the board drivers to demonstrate the capabilities of the B-L475E-IOT01A Kit.</p>
|
||||
</div>
|
||||
<div class="col-sm-12 col-lg-8">
|
||||
<h1 id="update-history">Update History</h1>
|
||||
<div class="collapse">
|
||||
<input type="checkbox" id="collapse-section21" checked aria-hidden="true"> <label for="collapse-section21" aria-hidden="true">V1.1.6 / 22-November-2019</label>
|
||||
<div>
|
||||
<h2 id="main-changes">Main Changes</h2>
|
||||
<ul>
|
||||
<li>Enable the Sample Shift (SSHIFT) feature in <em>BSP_QSPI_Init()</em> to ensure the read data isn’t corrupted when prescaler is div/1</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="collapse">
|
||||
<input type="checkbox" id="collapse-section20" aria-hidden="true"> <label for="collapse-section20" aria-hidden="true">V1.1.5 / 18-October-2019</label>
|
||||
<div>
|
||||
<h2 id="main-changes-1">Main Changes</h2>
|
||||
<ul>
|
||||
<li>Minor update in release notes format</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="collapse">
|
||||
<input type="checkbox" id="collapse-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V1.1.4 / 03-April-2019</label>
|
||||
<div>
|
||||
<h2 id="main-changes-2">Main Changes</h2>
|
||||
<ul>
|
||||
<li>Rewrite stm32l475e_iot01.c to correct B-L475E-IOT01_BSP_User_Manual.chm documentation issue</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="collapse">
|
||||
<input type="checkbox" id="collapse-section18" aria-hidden="true"> <label for="collapse-section18" aria-hidden="true">V1.1.3 / 27-July-2018</label>
|
||||
<div>
|
||||
<h2 id="main-changes-3">Main Changes</h2>
|
||||
<ul>
|
||||
<li>Release notes update to new format</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="collapse">
|
||||
<input type="checkbox" id="collapse-section17" aria-hidden="true"> <label for="collapse-section17" aria-hidden="true">V1.1.2 / 20-April-2018</label>
|
||||
<div>
|
||||
<h2 id="main-changes-4">Main Changes</h2>
|
||||
<ul>
|
||||
<li>Header functions description cleanup</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="collapse">
|
||||
<input type="checkbox" id="collapse-section16" aria-hidden="true"> <label for="collapse-section16" aria-hidden="true">V1.1.1 / 13-October-2017</label>
|
||||
<div>
|
||||
<h2 id="main-changes-5">Main Changes</h2>
|
||||
<ul>
|
||||
<li>Fix compilation warning with armcc –gnu</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="collapse">
|
||||
<input type="checkbox" id="collapse-section15" aria-hidden="true"> <label for="collapse-section15" aria-hidden="true">V1.1.0 / 21-April-2017</label>
|
||||
<div>
|
||||
<h2 id="main-changes-6">Main Changes</h2>
|
||||
<ul>
|
||||
<li>Add support of NFC via M24SR component.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="collapse">
|
||||
<input type="checkbox" id="collapse-section12" aria-hidden="true"> <label for="collapse-section12" aria-hidden="true">V1.0.0 / 17-March-2017</label>
|
||||
<div>
|
||||
<h2 id="main-changes-7">Main Changes</h2>
|
||||
<ul>
|
||||
<li>First official release of <strong>B-L475E-IOT01</strong> BSP drivers</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<footer class="sticky">
|
||||
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
1700
P3_SETR2/BSP/_htmresc/mini-st.css
Normal file
1700
P3_SETR2/BSP/_htmresc/mini-st.css
Normal file
File diff suppressed because it is too large
Load Diff
BIN
P3_SETR2/BSP/_htmresc/st_logo.png
Normal file
BIN
P3_SETR2/BSP/_htmresc/st_logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
806
P3_SETR2/BSP/stm32l475e_iot01.c
Normal file
806
P3_SETR2/BSP/stm32l475e_iot01.c
Normal file
@@ -0,0 +1,806 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32l475e_iot01.c
|
||||
* @author MCD Application Team
|
||||
* @brief STM32L475E-IOT01 board support package
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2017 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32l475e_iot01.h"
|
||||
|
||||
/** @defgroup BSP BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32L475E_IOT01 STM32L475E_IOT01
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32L475E_IOT01_LOW_LEVEL LOW LEVEL
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32L475E_IOT01_LOW_LEVEL_Private_Defines LOW LEVEL Private Def
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief STM32L475E IOT01 BSP Driver version number
|
||||
*/
|
||||
#define __STM32L475E_IOT01_BSP_VERSION_MAIN (0x01) /*!< [31:24] main version */
|
||||
#define __STM32L475E_IOT01_BSP_VERSION_SUB1 (0x01) /*!< [23:16] sub1 version */
|
||||
#define __STM32L475E_IOT01_BSP_VERSION_SUB2 (0x06) /*!< [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)\
|
||||
|(__STM32L475E_IOT01_BSP_VERSION_SUB1 << 16)\
|
||||
|(__STM32L475E_IOT01_BSP_VERSION_SUB2 << 8 )\
|
||||
|(__STM32L475E_IOT01_BSP_VERSION_RC))
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32L475E_IOT01_LOW_LEVEL_Private_Variables LOW LEVEL Variables
|
||||
* @{
|
||||
*/
|
||||
|
||||
const uint32_t GPIO_PIN[LEDn] = {LED2_PIN};
|
||||
|
||||
|
||||
GPIO_TypeDef* GPIO_PORT[LEDn] = {LED2_GPIO_PORT};
|
||||
|
||||
|
||||
GPIO_TypeDef* BUTTON_PORT[BUTTONn] = {USER_BUTTON_GPIO_PORT};
|
||||
|
||||
const uint16_t BUTTON_PIN[BUTTONn] = {USER_BUTTON_PIN};
|
||||
|
||||
const uint16_t BUTTON_IRQn[BUTTONn] = {USER_BUTTON_EXTI_IRQn};
|
||||
|
||||
USART_TypeDef* COM_USART[COMn] = {DISCOVERY_COM1};
|
||||
|
||||
GPIO_TypeDef* COM_TX_PORT[COMn] = {DISCOVERY_COM1_TX_GPIO_PORT};
|
||||
|
||||
GPIO_TypeDef* COM_RX_PORT[COMn] = {DISCOVERY_COM1_RX_GPIO_PORT};
|
||||
|
||||
const uint16_t COM_TX_PIN[COMn] = {DISCOVERY_COM1_TX_PIN};
|
||||
|
||||
const uint16_t COM_RX_PIN[COMn] = {DISCOVERY_COM1_RX_PIN};
|
||||
|
||||
const uint16_t COM_TX_AF[COMn] = {DISCOVERY_COM1_TX_AF};
|
||||
|
||||
const uint16_t COM_RX_AF[COMn] = {DISCOVERY_COM1_RX_AF};
|
||||
|
||||
I2C_HandleTypeDef hI2cHandler;
|
||||
UART_HandleTypeDef hDiscoUart;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/** @defgroup STM32L475E_IOT01_LOW_LEVEL_Private_FunctionPrototypes LOW LEVEL Private Function Prototypes
|
||||
* @{
|
||||
*/
|
||||
static void I2Cx_MspInit(I2C_HandleTypeDef *i2c_handler);
|
||||
static void I2Cx_MspDeInit(I2C_HandleTypeDef *i2c_handler);
|
||||
static void I2Cx_Init(I2C_HandleTypeDef *i2c_handler);
|
||||
static void I2Cx_DeInit(I2C_HandleTypeDef *i2c_handler);
|
||||
static HAL_StatusTypeDef I2Cx_ReadMultiple(I2C_HandleTypeDef *i2c_handler, uint8_t Addr, uint16_t Reg, uint16_t MemAddSize, uint8_t *Buffer, uint16_t Length);
|
||||
static HAL_StatusTypeDef I2Cx_WriteMultiple(I2C_HandleTypeDef *i2c_handler, uint8_t Addr, uint16_t Reg, uint16_t MemAddSize, uint8_t *Buffer, uint16_t Length);
|
||||
static HAL_StatusTypeDef I2Cx_IsDeviceReady(I2C_HandleTypeDef *i2c_handler, uint16_t DevAddress, uint32_t Trials);
|
||||
static void I2Cx_Error(I2C_HandleTypeDef *i2c_handler, uint8_t Addr);
|
||||
|
||||
/* Sensors IO functions */
|
||||
void SENSOR_IO_Init(void);
|
||||
void SENSOR_IO_DeInit(void);
|
||||
void SENSOR_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value);
|
||||
uint8_t SENSOR_IO_Read(uint8_t Addr, uint8_t Reg);
|
||||
uint16_t SENSOR_IO_ReadMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length);
|
||||
void SENSOR_IO_WriteMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length);
|
||||
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);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32L475E_IOT01_LOW_LEVEL_Private_Functions LOW LEVEL Private Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief This method returns the STM32L475E IOT01 BSP Driver revision
|
||||
* @retval version 0xXYZR (8bits for each decimal, R for RC)
|
||||
*/
|
||||
uint32_t BSP_GetVersion(void)
|
||||
{
|
||||
return __STM32L475E_IOT01_BSP_VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initializes LED GPIO.
|
||||
* @param Led LED to be initialized.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg LED2
|
||||
*/
|
||||
void BSP_LED_Init(Led_TypeDef Led)
|
||||
{
|
||||
GPIO_InitTypeDef gpio_init_structure;
|
||||
|
||||
LEDx_GPIO_CLK_ENABLE(Led);
|
||||
/* Configure the GPIO_LED pin */
|
||||
gpio_init_structure.Pin = GPIO_PIN[Led];
|
||||
gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
gpio_init_structure.Pull = GPIO_NOPULL;
|
||||
gpio_init_structure.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
|
||||
HAL_GPIO_Init(GPIO_PORT[Led], &gpio_init_structure);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DeInitializes LED GPIO.
|
||||
* @param Led LED to be deinitialized.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg LED2
|
||||
*/
|
||||
void BSP_LED_DeInit(Led_TypeDef Led)
|
||||
{
|
||||
GPIO_InitTypeDef gpio_init_structure;
|
||||
|
||||
/* DeInit the GPIO_LED pin */
|
||||
gpio_init_structure.Pin = GPIO_PIN[Led];
|
||||
|
||||
/* Turn off LED */
|
||||
HAL_GPIO_WritePin(GPIO_PORT[Led], GPIO_PIN[Led], GPIO_PIN_RESET);
|
||||
HAL_GPIO_DeInit(GPIO_PORT[Led], gpio_init_structure.Pin);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Turns the selected LED On.
|
||||
* @param Led LED to be set on
|
||||
* This parameter can be one of the following values:
|
||||
* @arg LED2
|
||||
*/
|
||||
void BSP_LED_On(Led_TypeDef Led)
|
||||
{
|
||||
HAL_GPIO_WritePin(GPIO_PORT[Led], GPIO_PIN[Led], GPIO_PIN_SET);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Turns the selected LED Off.
|
||||
* @param Led LED to be set off
|
||||
* This parameter can be one of the following values:
|
||||
* @arg LED2
|
||||
*/
|
||||
void BSP_LED_Off(Led_TypeDef Led)
|
||||
{
|
||||
HAL_GPIO_WritePin(GPIO_PORT[Led], GPIO_PIN[Led], GPIO_PIN_RESET);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Toggles the selected LED.
|
||||
* @param Led LED to be toggled
|
||||
* This parameter can be one of the following values:
|
||||
* @arg LED2
|
||||
*/
|
||||
void BSP_LED_Toggle(Led_TypeDef Led)
|
||||
{
|
||||
HAL_GPIO_TogglePin(GPIO_PORT[Led], GPIO_PIN[Led]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initializes push button GPIO and EXTI Line.
|
||||
* @param Button Button to be configured
|
||||
* This parameter can be one of the following values:
|
||||
* @arg BUTTON_USER User Push Button
|
||||
* @param ButtonMode Button mode
|
||||
* This parameter can be one of the following values:
|
||||
* @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
|
||||
*/
|
||||
void BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef ButtonMode)
|
||||
{
|
||||
GPIO_InitTypeDef gpio_init_structure;
|
||||
|
||||
/* Enable the BUTTON clock */
|
||||
USER_BUTTON_GPIO_CLK_ENABLE();
|
||||
|
||||
if(ButtonMode == BUTTON_MODE_GPIO)
|
||||
{
|
||||
/* Configure Button pin as input */
|
||||
gpio_init_structure.Pin = BUTTON_PIN[Button];
|
||||
gpio_init_structure.Mode = GPIO_MODE_INPUT;
|
||||
gpio_init_structure.Pull = GPIO_PULLUP;
|
||||
gpio_init_structure.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
HAL_GPIO_Init(BUTTON_PORT[Button], &gpio_init_structure);
|
||||
}
|
||||
|
||||
if(ButtonMode == BUTTON_MODE_EXTI)
|
||||
{
|
||||
/* Configure Button pin as input with External interrupt */
|
||||
gpio_init_structure.Pin = BUTTON_PIN[Button];
|
||||
gpio_init_structure.Pull = GPIO_PULLUP;
|
||||
gpio_init_structure.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||
|
||||
gpio_init_structure.Mode = GPIO_MODE_IT_RISING;
|
||||
|
||||
HAL_GPIO_Init(BUTTON_PORT[Button], &gpio_init_structure);
|
||||
|
||||
/* Enable and set Button EXTI Interrupt to the lowest priority */
|
||||
HAL_NVIC_SetPriority((IRQn_Type)(BUTTON_IRQn[Button]), 0x0F, 0x00);
|
||||
HAL_NVIC_EnableIRQ((IRQn_Type)(BUTTON_IRQn[Button]));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DeInitializes push button.
|
||||
* @param Button Button to be configured
|
||||
* This parameter can be one of the following values:
|
||||
* @arg BUTTON_USER User Push Button
|
||||
* @note PB DeInit does not disable the GPIO clock
|
||||
*/
|
||||
void BSP_PB_DeInit(Button_TypeDef Button)
|
||||
{
|
||||
GPIO_InitTypeDef gpio_init_structure;
|
||||
|
||||
gpio_init_structure.Pin = BUTTON_PIN[Button];
|
||||
HAL_NVIC_DisableIRQ((IRQn_Type)(BUTTON_IRQn[Button]));
|
||||
HAL_GPIO_DeInit(BUTTON_PORT[Button], gpio_init_structure.Pin);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Returns the selected button state.
|
||||
* @param Button Button to be checked
|
||||
* This parameter can be one of the following values:
|
||||
* @arg BUTTON_USER User Push Button
|
||||
* @retval The Button GPIO pin value (GPIO_PIN_RESET = button pressed)
|
||||
*/
|
||||
uint32_t BSP_PB_GetState(Button_TypeDef Button)
|
||||
{
|
||||
return HAL_GPIO_ReadPin(BUTTON_PORT[Button], BUTTON_PIN[Button]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configures COM port.
|
||||
* @param COM COM port to be initialized.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg COM1
|
||||
* @param huart Pointer to a UART_HandleTypeDef structure that contains the
|
||||
* configuration information for the specified USART peripheral.
|
||||
*/
|
||||
void BSP_COM_Init(COM_TypeDef COM, UART_HandleTypeDef *huart)
|
||||
{
|
||||
GPIO_InitTypeDef gpio_init_structure;
|
||||
|
||||
/* Enable GPIO clock */
|
||||
DISCOVERY_COMx_TX_GPIO_CLK_ENABLE(COM);
|
||||
DISCOVERY_COMx_RX_GPIO_CLK_ENABLE(COM);
|
||||
|
||||
/* Enable USART clock */
|
||||
DISCOVERY_COMx_CLK_ENABLE(COM);
|
||||
|
||||
/* Configure USART Tx as alternate function */
|
||||
gpio_init_structure.Pin = COM_TX_PIN[COM];
|
||||
gpio_init_structure.Mode = GPIO_MODE_AF_PP;
|
||||
gpio_init_structure.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
gpio_init_structure.Pull = GPIO_NOPULL;
|
||||
gpio_init_structure.Alternate = COM_TX_AF[COM];
|
||||
HAL_GPIO_Init(COM_TX_PORT[COM], &gpio_init_structure);
|
||||
|
||||
/* Configure USART Rx as alternate function */
|
||||
gpio_init_structure.Pin = COM_RX_PIN[COM];
|
||||
gpio_init_structure.Mode = GPIO_MODE_AF_PP;
|
||||
gpio_init_structure.Alternate = COM_RX_AF[COM];
|
||||
HAL_GPIO_Init(COM_RX_PORT[COM], &gpio_init_structure);
|
||||
|
||||
/* USART configuration */
|
||||
huart->Instance = COM_USART[COM];
|
||||
HAL_UART_Init(huart);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DeInitializes COM port.
|
||||
* @param COM COM port to be deinitialized.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg COM1
|
||||
* @param huart Pointer to a UART_HandleTypeDef structure that contains the
|
||||
* configuration information for the specified USART peripheral.
|
||||
*/
|
||||
void BSP_COM_DeInit(COM_TypeDef COM, UART_HandleTypeDef *huart)
|
||||
{
|
||||
/* USART configuration */
|
||||
huart->Instance = COM_USART[COM];
|
||||
HAL_UART_DeInit(huart);
|
||||
|
||||
/* Enable USART clock */
|
||||
DISCOVERY_COMx_CLK_DISABLE(COM);
|
||||
|
||||
/* DeInit GPIO pins can be done in the application
|
||||
(by surcharging this __weak function) */
|
||||
|
||||
/* GPIO pins clock, FMC clock and DMA clock can be shut down in the application
|
||||
by surcharging this __weak function */
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
BUS OPERATIONS
|
||||
*******************************************************************************/
|
||||
|
||||
/******************************* I2C Routines *********************************/
|
||||
/**
|
||||
* @brief Initializes I2C MSP.
|
||||
* @param i2c_handler I2C handler
|
||||
* @retval None
|
||||
*/
|
||||
static void I2Cx_MspInit(I2C_HandleTypeDef *i2c_handler)
|
||||
{
|
||||
GPIO_InitTypeDef gpio_init_structure;
|
||||
|
||||
/*** Configure the GPIOs ***/
|
||||
/* Enable GPIO clock */
|
||||
DISCOVERY_I2Cx_SCL_SDA_GPIO_CLK_ENABLE();
|
||||
|
||||
/* Configure I2C Tx, Rx as alternate function */
|
||||
gpio_init_structure.Pin = DISCOVERY_I2Cx_SCL_PIN | DISCOVERY_I2Cx_SDA_PIN;
|
||||
gpio_init_structure.Mode = GPIO_MODE_AF_OD;
|
||||
gpio_init_structure.Pull = GPIO_PULLUP;
|
||||
gpio_init_structure.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||
gpio_init_structure.Alternate = DISCOVERY_I2Cx_SCL_SDA_AF;
|
||||
HAL_GPIO_Init(DISCOVERY_I2Cx_SCL_SDA_GPIO_PORT, &gpio_init_structure);
|
||||
|
||||
HAL_GPIO_Init(DISCOVERY_I2Cx_SCL_SDA_GPIO_PORT, &gpio_init_structure);
|
||||
|
||||
/*** Configure the I2C peripheral ***/
|
||||
/* Enable I2C clock */
|
||||
DISCOVERY_I2Cx_CLK_ENABLE();
|
||||
|
||||
/* Force the I2C peripheral clock reset */
|
||||
DISCOVERY_I2Cx_FORCE_RESET();
|
||||
|
||||
/* Release the I2C peripheral clock reset */
|
||||
DISCOVERY_I2Cx_RELEASE_RESET();
|
||||
|
||||
/* Enable and set I2Cx Interrupt to a lower priority */
|
||||
HAL_NVIC_SetPriority(DISCOVERY_I2Cx_EV_IRQn, 0x0F, 0);
|
||||
HAL_NVIC_EnableIRQ(DISCOVERY_I2Cx_EV_IRQn);
|
||||
|
||||
/* Enable and set I2Cx Interrupt to a lower priority */
|
||||
HAL_NVIC_SetPriority(DISCOVERY_I2Cx_ER_IRQn, 0x0F, 0);
|
||||
HAL_NVIC_EnableIRQ(DISCOVERY_I2Cx_ER_IRQn);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DeInitializes I2C MSP.
|
||||
* @param i2c_handler I2C handler
|
||||
* @retval None
|
||||
*/
|
||||
static void I2Cx_MspDeInit(I2C_HandleTypeDef *i2c_handler)
|
||||
{
|
||||
GPIO_InitTypeDef gpio_init_structure;
|
||||
|
||||
/* Configure I2C Tx, Rx as alternate function */
|
||||
gpio_init_structure.Pin = DISCOVERY_I2Cx_SCL_PIN | DISCOVERY_I2Cx_SDA_PIN;
|
||||
HAL_GPIO_DeInit(DISCOVERY_I2Cx_SCL_SDA_GPIO_PORT, gpio_init_structure.Pin);
|
||||
/* Disable GPIO clock */
|
||||
DISCOVERY_I2Cx_SCL_SDA_GPIO_CLK_DISABLE();
|
||||
|
||||
/* Disable I2C clock */
|
||||
DISCOVERY_I2Cx_CLK_DISABLE();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initializes I2C HAL.
|
||||
* @param i2c_handler I2C handler
|
||||
* @retval None
|
||||
*/
|
||||
static void I2Cx_Init(I2C_HandleTypeDef *i2c_handler)
|
||||
{
|
||||
/* I2C configuration */
|
||||
i2c_handler->Instance = DISCOVERY_I2Cx;
|
||||
i2c_handler->Init.Timing = DISCOVERY_I2Cx_TIMING;
|
||||
i2c_handler->Init.OwnAddress1 = 0;
|
||||
i2c_handler->Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
|
||||
i2c_handler->Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
|
||||
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);
|
||||
|
||||
/**Configure Analogue filter */
|
||||
HAL_I2CEx_ConfigAnalogFilter(i2c_handler, I2C_ANALOGFILTER_ENABLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DeInitializes I2C HAL.
|
||||
* @param i2c_handler I2C handler
|
||||
* @retval None
|
||||
*/
|
||||
static void I2Cx_DeInit(I2C_HandleTypeDef *i2c_handler)
|
||||
{ /* DeInit the I2C */
|
||||
I2Cx_MspDeInit(i2c_handler);
|
||||
HAL_I2C_DeInit(i2c_handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reads multiple data.
|
||||
* @param i2c_handler I2C handler
|
||||
* @param Addr I2C address
|
||||
* @param Reg Reg address
|
||||
* @param MemAddress memory address
|
||||
* @param Buffer Pointer to data buffer
|
||||
* @param Length Length of the data
|
||||
* @retval HAL status
|
||||
*/
|
||||
static HAL_StatusTypeDef I2Cx_ReadMultiple(I2C_HandleTypeDef *i2c_handler, uint8_t Addr, uint16_t Reg, uint16_t MemAddress, uint8_t *Buffer, uint16_t Length)
|
||||
{
|
||||
HAL_StatusTypeDef status = HAL_OK;
|
||||
|
||||
status = HAL_I2C_Mem_Read(i2c_handler, Addr, (uint16_t)Reg, MemAddress, Buffer, Length, 1000);
|
||||
|
||||
/* Check the communication status */
|
||||
if(status != HAL_OK)
|
||||
{
|
||||
/* I2C error occured */
|
||||
I2Cx_Error(i2c_handler, Addr);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Writes a value in a register of the device through BUS in using DMA mode.
|
||||
* @param i2c_handler I2C handler
|
||||
* @param Addr Device address on BUS Bus.
|
||||
* @param Reg The target register address to write
|
||||
* @param MemAddress memory address
|
||||
* @param Buffer The target register value to be written
|
||||
* @param Length buffer size to be written
|
||||
* @retval HAL status
|
||||
*/
|
||||
static HAL_StatusTypeDef I2Cx_WriteMultiple(I2C_HandleTypeDef *i2c_handler, uint8_t Addr, uint16_t Reg, uint16_t MemAddress, uint8_t *Buffer, uint16_t Length)
|
||||
{
|
||||
HAL_StatusTypeDef status = HAL_OK;
|
||||
|
||||
status = HAL_I2C_Mem_Write(i2c_handler, Addr, (uint16_t)Reg, MemAddress, Buffer, Length, 1000);
|
||||
|
||||
/* Check the communication status */
|
||||
if(status != HAL_OK)
|
||||
{
|
||||
/* Re-Initiaize the I2C Bus */
|
||||
I2Cx_Error(i2c_handler, Addr);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Checks if target device is ready for communication.
|
||||
* @note This function is used with Memory devices
|
||||
* @param i2c_handler I2C handler
|
||||
* @param DevAddress Target device address
|
||||
* @param Trials Number of trials
|
||||
* @retval HAL status
|
||||
*/
|
||||
static HAL_StatusTypeDef I2Cx_IsDeviceReady(I2C_HandleTypeDef *i2c_handler, uint16_t DevAddress, uint32_t Trials)
|
||||
{
|
||||
return (HAL_I2C_IsDeviceReady(i2c_handler, DevAddress, Trials, 1000));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Manages error callback by re-initializing I2C.
|
||||
* @param i2c_handler I2C handler
|
||||
* @param Addr I2C Address
|
||||
* @retval None
|
||||
*/
|
||||
static void I2Cx_Error(I2C_HandleTypeDef *i2c_handler, uint8_t Addr)
|
||||
{
|
||||
/* De-initialize the I2C communication bus */
|
||||
HAL_I2C_DeInit(i2c_handler);
|
||||
|
||||
/* Re-Initialize the I2C communication bus */
|
||||
I2Cx_Init(i2c_handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
LINK OPERATIONS
|
||||
*******************************************************************************/
|
||||
/******************************** LINK Sensors ********************************/
|
||||
|
||||
/**
|
||||
* @brief Initializes Sensors low level.
|
||||
* @retval None
|
||||
*/
|
||||
void SENSOR_IO_Init(void)
|
||||
{
|
||||
I2Cx_Init(&hI2cHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DeInitializes Sensors low level.
|
||||
* @retval None
|
||||
*/
|
||||
void SENSOR_IO_DeInit(void)
|
||||
{
|
||||
I2Cx_DeInit(&hI2cHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Writes a single data.
|
||||
* @param Addr I2C address
|
||||
* @param Reg Reg address
|
||||
* @param Value Data to be written
|
||||
* @retval None
|
||||
*/
|
||||
void SENSOR_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value)
|
||||
{
|
||||
I2Cx_WriteMultiple(&hI2cHandler, Addr, (uint16_t)Reg, I2C_MEMADD_SIZE_8BIT,(uint8_t*)&Value, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reads a single data.
|
||||
* @param Addr I2C address
|
||||
* @param Reg Reg address
|
||||
* @retval Data to be read
|
||||
*/
|
||||
uint8_t SENSOR_IO_Read(uint8_t Addr, uint8_t Reg)
|
||||
{
|
||||
uint8_t read_value = 0;
|
||||
|
||||
I2Cx_ReadMultiple(&hI2cHandler, Addr, Reg, I2C_MEMADD_SIZE_8BIT, (uint8_t*)&read_value, 1);
|
||||
|
||||
return read_value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reads multiple data with I2C communication
|
||||
* channel from TouchScreen.
|
||||
* @param Addr I2C address
|
||||
* @param Reg Register address
|
||||
* @param Buffer Pointer to data buffer
|
||||
* @param Length Length of the data
|
||||
* @retval HAL status
|
||||
*/
|
||||
uint16_t SENSOR_IO_ReadMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length)
|
||||
{
|
||||
return I2Cx_ReadMultiple(&hI2cHandler, Addr, (uint16_t)Reg, I2C_MEMADD_SIZE_8BIT, Buffer, Length);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Writes multiple data with I2C communication
|
||||
* channel from MCU to TouchScreen.
|
||||
* @param Addr I2C address
|
||||
* @param Reg Register address
|
||||
* @param Buffer Pointer to data buffer
|
||||
* @param Length Length of the data
|
||||
* @retval None
|
||||
*/
|
||||
void SENSOR_IO_WriteMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length)
|
||||
{
|
||||
I2Cx_WriteMultiple(&hI2cHandler, Addr, (uint16_t)Reg, I2C_MEMADD_SIZE_8BIT, Buffer, Length);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Checks if target device is ready for communication.
|
||||
* @note This function is used with Memory devices
|
||||
* @param DevAddress Target device address
|
||||
* @param Trials Number of trials
|
||||
* @retval HAL status
|
||||
*/
|
||||
HAL_StatusTypeDef SENSOR_IO_IsDeviceReady(uint16_t DevAddress, uint32_t Trials)
|
||||
{
|
||||
return (I2Cx_IsDeviceReady(&hI2cHandler, DevAddress, Trials));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Delay function used in Sensor low level driver.
|
||||
* @param Delay Delay in ms
|
||||
* @retval None
|
||||
*/
|
||||
void SENSOR_IO_Delay(uint32_t Delay)
|
||||
{
|
||||
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
|
||||
* @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
|
||||
* @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
|
||||
* @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
|
||||
* @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 sets 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 Delay function used in M24SR low level driver.
|
||||
* @param Delay Delay in ms
|
||||
* @retval None
|
||||
*/
|
||||
void NFC_IO_Delay(uint32_t Delay)
|
||||
{
|
||||
HAL_Delay(Delay);
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
257
P3_SETR2/BSP/stm32l475e_iot01.h
Normal file
257
P3_SETR2/BSP/stm32l475e_iot01.h
Normal file
@@ -0,0 +1,257 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32l475e_iot01.h
|
||||
* @author MCD Application Team
|
||||
* @brief STM32L475E IOT01 board support package
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2017 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __STM32L475E_IOT01_H
|
||||
#define __STM32L475E_IOT01_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32l4xx_hal.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32L475E_IOT01
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32L475E_IOT01_LOW_LEVEL
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32L475E_IOT01_LOW_LEVEL_Exported_Types LOW LEVEL Exported Types
|
||||
* @{
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
LED2 = 0,
|
||||
LED_GREEN = LED2,
|
||||
}Led_TypeDef;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
BUTTON_USER = 0
|
||||
}Button_TypeDef;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
BUTTON_MODE_GPIO = 0,
|
||||
BUTTON_MODE_EXTI = 1
|
||||
}ButtonMode_TypeDef;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
COM1 = 0,
|
||||
COM2 = 0,
|
||||
}COM_TypeDef;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32L475E_IOT01_LOW_LEVEL_Exported_Constants LOW LEVEL Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Define for STM32L475E_IOT01 board
|
||||
*/
|
||||
#if !defined (USE_STM32L475E_IOT01)
|
||||
#define USE_STM32L475E_IOT01
|
||||
#endif
|
||||
|
||||
#define LEDn ((uint8_t)1)
|
||||
|
||||
#define LED2_PIN GPIO_PIN_14
|
||||
#define LED2_GPIO_PORT GPIOB
|
||||
#define LED2_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
|
||||
#define LED2_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE()
|
||||
|
||||
|
||||
|
||||
#define LEDx_GPIO_CLK_ENABLE(__INDEX__) do{if((__INDEX__) == 0) LED2_GPIO_CLK_ENABLE();}while(0)
|
||||
|
||||
#define LEDx_GPIO_CLK_DISABLE(__INDEX__) do{if((__INDEX__) == 0) LED2_GPIO_CLK_DISABLE();}while(0)
|
||||
|
||||
/* Only one User/Wakeup button */
|
||||
#define BUTTONn ((uint8_t)1)
|
||||
|
||||
/**
|
||||
* @brief Wakeup push-button
|
||||
*/
|
||||
#define USER_BUTTON_PIN GPIO_PIN_13
|
||||
#define USER_BUTTON_GPIO_PORT GPIOC
|
||||
#define USER_BUTTON_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE()
|
||||
#define USER_BUTTON_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE()
|
||||
#define USER_BUTTON_EXTI_IRQn EXTI15_10_IRQn
|
||||
|
||||
/**
|
||||
* @brief NFC Gpio PINs
|
||||
*/
|
||||
#define NFC_GPIO_GPO_PIN GPIO_PIN_4
|
||||
#define NFC_GPIO_GPO_PIN_PORT GPIOE
|
||||
#define NFC_GPIO_RFDISABLE_PIN GPIO_PIN_2
|
||||
#define NFC_GPIO_RFDISABLE_PIN_PORT GPIOE
|
||||
#define NFC_GPIO_CLK_ENABLE() __HAL_RCC_GPIOE_CLK_ENABLE();
|
||||
#define NFC_GPIO_CLK_DISABLE() __HAL_RCC_GPIOE_CLK_DISABLE();
|
||||
|
||||
|
||||
#define COMn ((uint8_t)1)
|
||||
|
||||
/**
|
||||
* @brief Definition for COM port1, connected to USART1
|
||||
*/
|
||||
#define DISCOVERY_COM1 USART1
|
||||
#define DISCOVERY_COM1_CLK_ENABLE() __HAL_RCC_USART1_CLK_ENABLE()
|
||||
#define DISCOVERY_COM1_CLK_DISABLE() __HAL_RCC_USART1_CLK_DISABLE()
|
||||
|
||||
#define DISCOVERY_COM1_TX_PIN GPIO_PIN_6
|
||||
#define DISCOVERY_COM1_TX_GPIO_PORT GPIOB
|
||||
#define DISCOVERY_COM1_TX_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
|
||||
#define DISCOVERY_COM1_TX_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE()
|
||||
#define DISCOVERY_COM1_TX_AF GPIO_AF7_USART1
|
||||
|
||||
#define DISCOVERY_COM1_RX_PIN GPIO_PIN_7
|
||||
#define DISCOVERY_COM1_RX_GPIO_PORT GPIOB
|
||||
#define DISCOVERY_COM1_RX_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
|
||||
#define DISCOVERY_COM1_RX_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE()
|
||||
#define DISCOVERY_COM1_RX_AF GPIO_AF7_USART1
|
||||
|
||||
#define DISCOVERY_COM1_IRQn USART1_IRQn
|
||||
|
||||
|
||||
#define DISCOVERY_COMx_CLK_ENABLE(__INDEX__) do { if((__INDEX__) == COM1) {DISCOVERY_COM1_CLK_ENABLE();}} while(0)
|
||||
#define DISCOVERY_COMx_CLK_DISABLE(__INDEX__) do { if((__INDEX__) == COM1) {DISCOVERY_COM1_CLK_DISABLE();}} while(0)
|
||||
|
||||
#define DISCOVERY_COMx_TX_GPIO_CLK_ENABLE(__INDEX__) do { if((__INDEX__) == COM1) {DISCOVERY_COM1_TX_GPIO_CLK_ENABLE();}} while(0)
|
||||
#define DISCOVERY_COMx_TX_GPIO_CLK_DISABLE(__INDEX__) do { if((__INDEX__) == COM1) {DISCOVERY_COM1_TX_GPIO_CLK_DISABLE();}} while(0)
|
||||
|
||||
#define DISCOVERY_COMx_RX_GPIO_CLK_ENABLE(__INDEX__) do { if((__INDEX__) == COM1) {DISCOVERY_COM1_RX_GPIO_CLK_ENABLE();}} while(0)
|
||||
#define DISCOVERY_COMx_RX_GPIO_CLK_DISABLE(__INDEX__) do { if((__INDEX__) == COM1) {DISCOVERY_COM1_RX_GPIO_CLK_DISABLE();}} while(0)
|
||||
|
||||
|
||||
/* User can use this section to tailor I2Cx instance used and associated resources */
|
||||
/* Definition for I2Cx resources */
|
||||
#define DISCOVERY_I2Cx I2C2
|
||||
#define DISCOVERY_I2Cx_CLK_ENABLE() __HAL_RCC_I2C2_CLK_ENABLE()
|
||||
#define DISCOVERY_I2Cx_CLK_DISABLE() __HAL_RCC_I2C2_CLK_DISABLE()
|
||||
#define DISCOVERY_DMAx_CLK_ENABLE() __HAL_RCC_DMA1_CLK_ENABLE()
|
||||
#define DISCOVERY_I2Cx_SCL_SDA_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
|
||||
#define DISCOVERY_I2Cx_SCL_SDA_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE()
|
||||
|
||||
#define DISCOVERY_I2Cx_FORCE_RESET() __HAL_RCC_I2C2_FORCE_RESET()
|
||||
#define DISCOVERY_I2Cx_RELEASE_RESET() __HAL_RCC_I2C2_RELEASE_RESET()
|
||||
|
||||
/* Definition for I2Cx Pins */
|
||||
#define DISCOVERY_I2Cx_SCL_PIN GPIO_PIN_10
|
||||
#define DISCOVERY_I2Cx_SDA_PIN GPIO_PIN_11
|
||||
#define DISCOVERY_I2Cx_SCL_SDA_GPIO_PORT GPIOB
|
||||
#define DISCOVERY_I2Cx_SCL_SDA_AF GPIO_AF4_I2C2
|
||||
|
||||
/* I2C interrupt requests */
|
||||
#define DISCOVERY_I2Cx_EV_IRQn I2C2_EV_IRQn
|
||||
#define DISCOVERY_I2Cx_ER_IRQn I2C2_ER_IRQn
|
||||
|
||||
/* I2C clock speed configuration (in Hz)
|
||||
WARNING:
|
||||
Make sure that this define is not already declared in other files.
|
||||
It can be used in parallel by other modules. */
|
||||
#ifndef DISCOVERY_I2C_SPEED
|
||||
#define DISCOVERY_I2C_SPEED 100000
|
||||
#endif /* DISCOVERY_I2C_SPEED */
|
||||
|
||||
#ifndef DISCOVERY_I2Cx_TIMING
|
||||
#define DISCOVERY_I2Cx_TIMING ((uint32_t)0x00702681)
|
||||
#endif /* DISCOVERY_I2Cx_TIMING */
|
||||
|
||||
|
||||
/* I2C Sensors address */
|
||||
/* LPS22HB (Pressure) I2C Address */
|
||||
#define LPS22HB_I2C_ADDRESS (uint8_t)0xBA
|
||||
/* HTS221 (Humidity) I2C Address */
|
||||
#define HTS221_I2C_ADDRESS (uint8_t)0xBE
|
||||
|
||||
#ifdef USE_LPS22HB_TEMP
|
||||
/* LPS22HB Sensor hardware I2C address */
|
||||
#define TSENSOR_I2C_ADDRESS LPS22HB_I2C_ADDRESS
|
||||
#else /* USE_HTS221_TEMP */
|
||||
/* HTS221 Sensor hardware I2C address */
|
||||
#define TSENSOR_I2C_ADDRESS HTS221_I2C_ADDRESS
|
||||
#endif
|
||||
|
||||
/* NFC I2C address and specific config parameters */
|
||||
#define M24SR_I2C_ADDR (uint8_t) 0xAC /*!< M24SR address */
|
||||
#define NFC_I2C_STATUS_SUCCESS (uint16_t) 0x0000
|
||||
#define NFC_I2C_ERROR_TIMEOUT (uint16_t) 0x0011
|
||||
#define NFC_I2C_TIMEOUT_STD (uint32_t) 8 /* I2C Time out (ms), used to call Transmit/Receive HAL functions */
|
||||
#define NFC_I2C_TIMEOUT_MAX (uint32_t) 200 /* I2C Time out (ms), this is the maximum time needed by M24SR to complete any command */
|
||||
#define NFC_I2C_TRIALS (uint32_t) 1 /* In case M24SR will reply ACK failed allow to perform retry before returning error (HAL option not used) */
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* Exported macros -----------------------------------------------------------*/
|
||||
/* Private macros ------------------------------------------------------------*/
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
|
||||
/** @defgroup STM32L475E_IOT01_LOW_LEVEL_Exported_Functions LOW LEVEL Exported Functions
|
||||
* @{
|
||||
*/
|
||||
uint32_t BSP_GetVersion(void);
|
||||
void BSP_LED_Init(Led_TypeDef Led);
|
||||
void BSP_LED_DeInit(Led_TypeDef Led);
|
||||
void BSP_LED_On(Led_TypeDef Led);
|
||||
void BSP_LED_Off(Led_TypeDef Led);
|
||||
void BSP_LED_Toggle(Led_TypeDef Led);
|
||||
void BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef ButtonMode);
|
||||
void BSP_PB_DeInit(Button_TypeDef Button);
|
||||
uint32_t BSP_PB_GetState(Button_TypeDef Button);
|
||||
void BSP_COM_Init(COM_TypeDef COM, UART_HandleTypeDef *husart);
|
||||
void BSP_COM_DeInit(COM_TypeDef COM, UART_HandleTypeDef *huart);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __STM32L475E_IOT01_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
151
P3_SETR2/BSP/stm32l475e_iot01_accelero.c
Normal file
151
P3_SETR2/BSP/stm32l475e_iot01_accelero.c
Normal file
@@ -0,0 +1,151 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32l475e_iot01_accelero.c
|
||||
* @author MCD Application Team
|
||||
* @brief This file provides a set of functions needed to manage the accelerometer sensor
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2017 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32l475e_iot01_accelero.h"
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32L475E_IOT01
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32L475E_IOT01_ACCELERO ACCELERO
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32L475E_IOT01_ACCELERO_Private_Variables ACCELERO Private Variables
|
||||
* @{
|
||||
*/
|
||||
static ACCELERO_DrvTypeDef *AccelerometerDrv;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32L475E_IOT01_ACCELERO_Private_Functions ACCELERO Private Functions
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief Initialize the ACCELERO.
|
||||
* @retval ACCELERO_OK or ACCELERO_ERROR
|
||||
*/
|
||||
ACCELERO_StatusTypeDef BSP_ACCELERO_Init(void)
|
||||
{
|
||||
ACCELERO_StatusTypeDef ret = ACCELERO_OK;
|
||||
uint16_t ctrl = 0x0000;
|
||||
ACCELERO_InitTypeDef LSM6DSL_InitStructure;
|
||||
|
||||
if(Lsm6dslAccDrv.ReadID() != LSM6DSL_ACC_GYRO_WHO_AM_I)
|
||||
{
|
||||
ret = ACCELERO_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Initialize the ACCELERO accelerometer driver structure */
|
||||
AccelerometerDrv = &Lsm6dslAccDrv;
|
||||
|
||||
/* MEMS configuration ------------------------------------------------------*/
|
||||
/* Fill the ACCELERO accelerometer structure */
|
||||
LSM6DSL_InitStructure.AccOutput_DataRate = LSM6DSL_ODR_52Hz;
|
||||
LSM6DSL_InitStructure.Axes_Enable = 0;
|
||||
LSM6DSL_InitStructure.AccFull_Scale = LSM6DSL_ACC_FULLSCALE_2G;
|
||||
LSM6DSL_InitStructure.BlockData_Update = LSM6DSL_BDU_BLOCK_UPDATE;
|
||||
LSM6DSL_InitStructure.High_Resolution = 0;
|
||||
LSM6DSL_InitStructure.Communication_Mode = 0;
|
||||
|
||||
/* Configure MEMS: data rate, full scale */
|
||||
ctrl = (LSM6DSL_InitStructure.AccOutput_DataRate | LSM6DSL_InitStructure.AccFull_Scale);
|
||||
|
||||
/* Configure MEMS: BDU and Auto-increment for multi read/write */
|
||||
ctrl |= ((LSM6DSL_InitStructure.BlockData_Update | LSM6DSL_ACC_GYRO_IF_INC_ENABLED) << 8);
|
||||
|
||||
/* Configure the ACCELERO accelerometer main parameters */
|
||||
AccelerometerDrv->Init(ctrl);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DeInitialize the ACCELERO.
|
||||
* @retval None.
|
||||
*/
|
||||
void BSP_ACCELERO_DeInit(void)
|
||||
{
|
||||
/* DeInitialize the accelerometer IO interfaces */
|
||||
if(AccelerometerDrv != NULL)
|
||||
{
|
||||
if(AccelerometerDrv->DeInit != NULL)
|
||||
{
|
||||
AccelerometerDrv->DeInit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set/Unset the ACCELERO in low power mode.
|
||||
* @param status 0 means disable Low Power Mode, otherwise Low Power Mode is enabled
|
||||
* @retval None
|
||||
*/
|
||||
void BSP_ACCELERO_LowPower(uint16_t status)
|
||||
{
|
||||
/* Set/Unset the ACCELERO in low power mode */
|
||||
if(AccelerometerDrv != NULL)
|
||||
{
|
||||
if(AccelerometerDrv->LowPower != NULL)
|
||||
{
|
||||
AccelerometerDrv->LowPower(status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get XYZ acceleration values.
|
||||
* @param pDataXYZ Pointer on 3 angular accelerations table with
|
||||
* pDataXYZ[0] = X axis, pDataXYZ[1] = Y axis, pDataXYZ[2] = Z axis
|
||||
* @retval None
|
||||
*/
|
||||
void BSP_ACCELERO_AccGetXYZ(int16_t *pDataXYZ)
|
||||
{
|
||||
if(AccelerometerDrv != NULL)
|
||||
{
|
||||
if(AccelerometerDrv->GetXYZ != NULL)
|
||||
{
|
||||
AccelerometerDrv->GetXYZ(pDataXYZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
89
P3_SETR2/BSP/stm32l475e_iot01_accelero.h
Normal file
89
P3_SETR2/BSP/stm32l475e_iot01_accelero.h
Normal file
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32l475e_iot01_accelero.h
|
||||
* @author MCD Application Team
|
||||
* @brief This file provides a set of functions needed to manage the accelerometer sensor
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2017 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __STM32L475E_IOT01_ACCELERO_H
|
||||
#define __STM32L475E_IOT01_ACCELERO_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32l475e_iot01.h"
|
||||
/* Include Accelero component driver */
|
||||
#include "../Components/lsm6dsl/lsm6dsl.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32L475E_IOT01
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32L475E_IOT01_ACCELERO
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32L475_DISCOVERY_ACCELERO_Exported_Types ACCELERO Exported Types
|
||||
* @{
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ACCELERO_OK = 0,
|
||||
ACCELERO_ERROR = 1,
|
||||
ACCELERO_TIMEOUT = 2
|
||||
}
|
||||
ACCELERO_StatusTypeDef;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32L475E_IOT01_ACCELERO_Exported_Functions ACCELERO Exported Functions
|
||||
* @{
|
||||
*/
|
||||
/* Sensor Configuration Functions */
|
||||
ACCELERO_StatusTypeDef BSP_ACCELERO_Init(void);
|
||||
void BSP_ACCELERO_DeInit(void);
|
||||
void BSP_ACCELERO_LowPower(uint16_t status); /* 0 Means Disable Low Power Mode, otherwise Low Power Mode is enabled */
|
||||
void BSP_ACCELERO_AccGetXYZ(int16_t *pDataXYZ);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __STM32L475E_IOT01_ACCELERO_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
155
P3_SETR2/BSP/stm32l475e_iot01_gyro.c
Normal file
155
P3_SETR2/BSP/stm32l475e_iot01_gyro.c
Normal file
@@ -0,0 +1,155 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32l475e_iot01_gyro.c
|
||||
* @author MCD Application Team
|
||||
* @brief This file provides a set of functions needed to manage the gyroscope sensor
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2017 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32l475e_iot01_gyro.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32L475E_IOT01
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32L475E_IOT01_GYROSCOPE GYROSCOPE
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32L475E_IOT01_GYROSCOPE_Private_Variables GYROSCOPE Private Variables
|
||||
* @{
|
||||
*/
|
||||
static GYRO_DrvTypeDef *GyroscopeDrv;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup STM32L475E_IOT01_GYROSCOPE_Private_Functions GYROSCOPE Private Functions
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief Initialize Gyroscope.
|
||||
* @retval GYRO_OK or GYRO_ERROR
|
||||
*/
|
||||
uint8_t BSP_GYRO_Init(void)
|
||||
{
|
||||
uint8_t ret = GYRO_ERROR;
|
||||
uint16_t ctrl = 0x0000;
|
||||
GYRO_InitTypeDef LSM6DSL_InitStructure;
|
||||
|
||||
if(Lsm6dslGyroDrv.ReadID() != LSM6DSL_ACC_GYRO_WHO_AM_I)
|
||||
{
|
||||
ret = GYRO_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Initialize the gyroscope driver structure */
|
||||
GyroscopeDrv = &Lsm6dslGyroDrv;
|
||||
|
||||
/* Configure Mems : data rate, power mode, full scale and axes */
|
||||
LSM6DSL_InitStructure.Power_Mode = 0;
|
||||
LSM6DSL_InitStructure.Output_DataRate = LSM6DSL_ODR_52Hz;
|
||||
LSM6DSL_InitStructure.Axes_Enable = 0;
|
||||
LSM6DSL_InitStructure.Band_Width = 0;
|
||||
LSM6DSL_InitStructure.BlockData_Update = LSM6DSL_BDU_BLOCK_UPDATE;
|
||||
LSM6DSL_InitStructure.Endianness = 0;
|
||||
LSM6DSL_InitStructure.Full_Scale = LSM6DSL_GYRO_FS_2000;
|
||||
|
||||
/* Configure MEMS: data rate, full scale */
|
||||
ctrl = (LSM6DSL_InitStructure.Full_Scale | LSM6DSL_InitStructure.Output_DataRate);
|
||||
|
||||
/* Configure MEMS: BDU and Auto-increment for multi read/write */
|
||||
ctrl |= ((LSM6DSL_InitStructure.BlockData_Update | LSM6DSL_ACC_GYRO_IF_INC_ENABLED) << 8);
|
||||
|
||||
/* Initialize component */
|
||||
GyroscopeDrv->Init(ctrl);
|
||||
|
||||
ret = GYRO_OK;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief DeInitialize Gyroscope.
|
||||
*/
|
||||
void BSP_GYRO_DeInit(void)
|
||||
{
|
||||
/* DeInitialize the Gyroscope IO interfaces */
|
||||
if(GyroscopeDrv != NULL)
|
||||
{
|
||||
if(GyroscopeDrv->DeInit!= NULL)
|
||||
{
|
||||
GyroscopeDrv->DeInit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Set/Unset Gyroscope in low power mode.
|
||||
* @param status 0 means disable Low Power Mode, otherwise Low Power Mode is enabled
|
||||
*/
|
||||
void BSP_GYRO_LowPower(uint16_t status)
|
||||
{
|
||||
/* Set/Unset component in low-power mode */
|
||||
if(GyroscopeDrv != NULL)
|
||||
{
|
||||
if(GyroscopeDrv->LowPower!= NULL)
|
||||
{
|
||||
GyroscopeDrv->LowPower(status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get XYZ angular acceleration from the Gyroscope.
|
||||
* @param pfData: pointer on floating array
|
||||
*/
|
||||
void BSP_GYRO_GetXYZ(float* pfData)
|
||||
{
|
||||
if(GyroscopeDrv != NULL)
|
||||
{
|
||||
if(GyroscopeDrv->GetXYZ!= NULL)
|
||||
{
|
||||
GyroscopeDrv->GetXYZ(pfData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
88
P3_SETR2/BSP/stm32l475e_iot01_gyro.h
Normal file
88
P3_SETR2/BSP/stm32l475e_iot01_gyro.h
Normal file
@@ -0,0 +1,88 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32l475e_iot01_gyro.h
|
||||
* @author MCD Application Team
|
||||
* @brief This file contains definitions for the stm32l475e_iot01_gyro.c
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2017 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __STM32L475E_IOT01_GYRO_H
|
||||
#define __STM32L475E_IOT01_GYRO_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32l475e_iot01.h"
|
||||
/* Include Gyro component driver */
|
||||
#include "../Components/lsm6dsl/lsm6dsl.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32L475E_IOT01
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32L475E_IOT01_GYROSCOPE
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32L475_IOT01_GYROSCOPE_Exported_Constants GYROSCOPE Exported Constants
|
||||
* @{
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GYRO_OK = 0,
|
||||
GYRO_ERROR = 1,
|
||||
GYRO_TIMEOUT = 2
|
||||
}
|
||||
GYRO_StatusTypeDef;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32L475E_IOT01_GYROSCOPE_Exported_Functions GYROSCOPE Exported Functions
|
||||
* @{
|
||||
*/
|
||||
uint8_t BSP_GYRO_Init(void);
|
||||
void BSP_GYRO_DeInit(void);
|
||||
void BSP_GYRO_LowPower(uint16_t status); /* 0 Means Disable Low Power Mode, otherwise Low Power Mode is enabled */
|
||||
void BSP_GYRO_GetXYZ(float* pfData);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __STM32L475E_IOT01_GYRO_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
102
P3_SETR2/BSP/stm32l475e_iot01_hsensor.c
Normal file
102
P3_SETR2/BSP/stm32l475e_iot01_hsensor.c
Normal file
@@ -0,0 +1,102 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32l475e_iot01_hsensor.c
|
||||
* @author MCD Application Team
|
||||
* @brief This file provides a set of functions needed to manage the humidity sensor
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2017 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32l475e_iot01_hsensor.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32L475E_IOT01
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32L475E_IOT01_HUMIDITY HUMIDITY
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32L475E_IOT01_HUMIDITY_Private_Variables HUMIDITY Private Variables
|
||||
* @{
|
||||
*/
|
||||
static HSENSOR_DrvTypeDef *Hsensor_drv;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32L475E_IOT01_HUMIDITY_Private_Functions HUMIDITY Private Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Initializes peripherals used by the I2C Humidity Sensor driver.
|
||||
* @retval HSENSOR status
|
||||
*/
|
||||
uint32_t BSP_HSENSOR_Init(void)
|
||||
{
|
||||
uint32_t ret;
|
||||
|
||||
if(HTS221_H_Drv.ReadID(HTS221_I2C_ADDRESS) != HTS221_WHO_AM_I_VAL)
|
||||
{
|
||||
ret = HSENSOR_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
Hsensor_drv = &HTS221_H_Drv;
|
||||
/* HSENSOR Init */
|
||||
Hsensor_drv->Init(HTS221_I2C_ADDRESS);
|
||||
ret = HSENSOR_OK;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read ID of HTS221.
|
||||
* @retval HTS221 ID value.
|
||||
*/
|
||||
uint8_t BSP_HSENSOR_ReadID(void)
|
||||
{
|
||||
return Hsensor_drv->ReadID(HTS221_I2C_ADDRESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read Humidity register of HTS221.
|
||||
* @retval HTS221 measured humidity value.
|
||||
*/
|
||||
float BSP_HSENSOR_ReadHumidity(void)
|
||||
{
|
||||
return Hsensor_drv->ReadHumidity(HTS221_I2C_ADDRESS);
|
||||
}
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
91
P3_SETR2/BSP/stm32l475e_iot01_hsensor.h
Normal file
91
P3_SETR2/BSP/stm32l475e_iot01_hsensor.h
Normal file
@@ -0,0 +1,91 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32l475e_iot01_hsensor.h
|
||||
* @author MCD Application Team
|
||||
* @brief This file provides a set of functions needed to manage the humidity sensor
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2017 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __STM32L475E_IOT01_HSENSOR_H
|
||||
#define __STM32L475E_IOT01_HSENSOR_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32l475e_iot01.h"
|
||||
#include "../Components/hts221/hts221.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32L475E_IOT01
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32L475E_IOT01_HUMIDITY
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/** @defgroup STM32L475E_IOT01_HUMIDITY_Exported_Types HUMIDITY Exported Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief HSENSOR Status
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
HSENSOR_OK = 0,
|
||||
HSENSOR_ERROR
|
||||
}HSENSOR_Status_TypDef;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32L475E_IOT01_HUMIDITY_Exported_Functions HUMIDITY Exported Functions
|
||||
* @{
|
||||
*/
|
||||
/* Sensor Configuration Functions */
|
||||
uint32_t BSP_HSENSOR_Init(void);
|
||||
uint8_t BSP_HSENSOR_ReadID(void);
|
||||
float BSP_HSENSOR_ReadHumidity(void);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* __STM32L475E_IOT01_HSENSOR_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
141
P3_SETR2/BSP/stm32l475e_iot01_magneto.c
Normal file
141
P3_SETR2/BSP/stm32l475e_iot01_magneto.c
Normal file
@@ -0,0 +1,141 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32l475e_iot01_magneto.c
|
||||
* @author MCD Application Team
|
||||
* @brief This file provides a set of functions needed to manage the magnetometer sensor
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2017 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32l475e_iot01_magneto.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32L475E_IOT01
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32L475E_IOT01_MAGNETO MAGNETO
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32L475E_IOT01_MAGNETO_Private_Variables MAGNETO Private Variables
|
||||
* @{
|
||||
*/
|
||||
static MAGNETO_DrvTypeDef *MagnetoDrv;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup STM32L475E_IOT01_MAGNETO_Private_Functions MAGNETO Private Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Initialize a magnetometer sensor
|
||||
* @retval COMPONENT_ERROR in case of failure
|
||||
*/
|
||||
MAGNETO_StatusTypeDef BSP_MAGNETO_Init(void)
|
||||
{
|
||||
MAGNETO_StatusTypeDef ret = MAGNETO_OK;
|
||||
MAGNETO_InitTypeDef LIS3MDL_InitStructureMag;
|
||||
|
||||
if(Lis3mdlMagDrv.ReadID() != I_AM_LIS3MDL)
|
||||
{
|
||||
ret = MAGNETO_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Initialize the MAGNETO magnetometer driver structure */
|
||||
MagnetoDrv = &Lis3mdlMagDrv;
|
||||
|
||||
/* MEMS configuration ------------------------------------------------------*/
|
||||
/* Fill the MAGNETO magnetometer structure */
|
||||
LIS3MDL_InitStructureMag.Register1 = LIS3MDL_MAG_TEMPSENSOR_DISABLE | LIS3MDL_MAG_OM_XY_HIGH | LIS3MDL_MAG_ODR_40_HZ;
|
||||
LIS3MDL_InitStructureMag.Register2 = LIS3MDL_MAG_FS_4_GA | LIS3MDL_MAG_REBOOT_DEFAULT | LIS3MDL_MAG_SOFT_RESET_DEFAULT;
|
||||
LIS3MDL_InitStructureMag.Register3 = LIS3MDL_MAG_CONFIG_NORMAL_MODE | LIS3MDL_MAG_CONTINUOUS_MODE;
|
||||
LIS3MDL_InitStructureMag.Register4 = LIS3MDL_MAG_OM_Z_HIGH | LIS3MDL_MAG_BLE_LSB;
|
||||
LIS3MDL_InitStructureMag.Register5 = LIS3MDL_MAG_BDU_MSBLSB;
|
||||
/* Configure the MAGNETO magnetometer main parameters */
|
||||
MagnetoDrv->Init(LIS3MDL_InitStructureMag);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DeInitialize the MAGNETO.
|
||||
*/
|
||||
void BSP_MAGNETO_DeInit(void)
|
||||
{
|
||||
/* DeInitialize the magnetometer IO interfaces */
|
||||
if(MagnetoDrv != NULL)
|
||||
{
|
||||
if(MagnetoDrv->DeInit != NULL)
|
||||
{
|
||||
MagnetoDrv->DeInit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set/Unset the MAGNETO in low power mode.
|
||||
*/
|
||||
void BSP_MAGNETO_LowPower(uint16_t status)
|
||||
{
|
||||
/* Put the magnetometer in low power mode */
|
||||
if(MagnetoDrv != NULL)
|
||||
{
|
||||
if(MagnetoDrv->LowPower != NULL)
|
||||
{
|
||||
MagnetoDrv->LowPower(status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get XYZ magnetometer values.
|
||||
* @param pDataXYZ Pointer on 3 magnetometer values table with
|
||||
* pDataXYZ[0] = X axis, pDataXYZ[1] = Y axis, pDataXYZ[2] = Z axis
|
||||
*/
|
||||
void BSP_MAGNETO_GetXYZ(int16_t *pDataXYZ)
|
||||
{
|
||||
if(MagnetoDrv != NULL)
|
||||
{
|
||||
if(MagnetoDrv->GetXYZ != NULL)
|
||||
{
|
||||
MagnetoDrv->GetXYZ(pDataXYZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
89
P3_SETR2/BSP/stm32l475e_iot01_magneto.h
Normal file
89
P3_SETR2/BSP/stm32l475e_iot01_magneto.h
Normal file
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32l475e_iot01_magneto.h
|
||||
* @author MCD Application Team
|
||||
* @brief This file provides a set of functions needed to manage the magnetometer sensor
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2017 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __STM32L475E_IOT01_MAGNETO_H
|
||||
#define __STM32L475E_IOT01_MAGNETO_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32l475e_iot01.h"
|
||||
/* Include Magnetometer component driver */
|
||||
#include "../Components/lis3mdl/lis3mdl.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32L475E_IOT01
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32L475E_IOT01_MAGNETO
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32L475_IOT01_MAGNETO_Exported_Types MAGNETO Exported Types
|
||||
* @{
|
||||
*/
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
typedef enum
|
||||
{
|
||||
MAGNETO_OK = 0,
|
||||
MAGNETO_ERROR = 1,
|
||||
MAGNETO_TIMEOUT = 2
|
||||
}
|
||||
MAGNETO_StatusTypeDef;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32L475E_IOT01_MAGNETO_Exported_Functions MAGNETO Exported Functions
|
||||
* @{
|
||||
*/
|
||||
MAGNETO_StatusTypeDef BSP_MAGNETO_Init(void);
|
||||
void BSP_MAGNETO_DeInit(void);
|
||||
void BSP_MAGNETO_LowPower(uint16_t status); /* 0 Means Disable Low Power Mode, otherwise Low Power Mode is enabled */
|
||||
void BSP_MAGNETO_GetXYZ(int16_t *pDataXYZ);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __STM32L475E_IOT01_MAGNETO_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
103
P3_SETR2/BSP/stm32l475e_iot01_psensor.c
Normal file
103
P3_SETR2/BSP/stm32l475e_iot01_psensor.c
Normal file
@@ -0,0 +1,103 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32l475e_iot01_psensor.c
|
||||
* @author MCD Application Team
|
||||
* @brief This file provides a set of functions needed to manage the pressure sensor
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2017 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32l475e_iot01_psensor.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32L475E_IOT01
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32L475E_IOT01_PRESSURE PRESSURE
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32L475E_IOT01_PRESSURE_Private_Variables PRESSURE Private Variables
|
||||
* @{
|
||||
*/
|
||||
static PSENSOR_DrvTypeDef *Psensor_drv;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32L475E_IOT01_PRESSURE_Private_Functions PRESSURE Private Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Initializes peripherals used by the I2C Pressure Sensor driver.
|
||||
* @retval PSENSOR status
|
||||
*/
|
||||
uint32_t BSP_PSENSOR_Init(void)
|
||||
{
|
||||
uint32_t ret;
|
||||
|
||||
if(LPS22HB_P_Drv.ReadID(LPS22HB_I2C_ADDRESS) != LPS22HB_WHO_AM_I_VAL)
|
||||
{
|
||||
ret = PSENSOR_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
Psensor_drv = &LPS22HB_P_Drv;
|
||||
|
||||
/* PSENSOR Init */
|
||||
Psensor_drv->Init(LPS22HB_I2C_ADDRESS);
|
||||
ret = PSENSOR_OK;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read ID of LPS22HB.
|
||||
* @retval LPS22HB ID value.
|
||||
*/
|
||||
uint8_t BSP_PSENSOR_ReadID(void)
|
||||
{
|
||||
return Psensor_drv->ReadID(LPS22HB_I2C_ADDRESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read Pressure register of LPS22HB.
|
||||
* @retval LPS22HB measured pressure value.
|
||||
*/
|
||||
float BSP_PSENSOR_ReadPressure(void)
|
||||
{
|
||||
return Psensor_drv->ReadPressure(LPS22HB_I2C_ADDRESS);
|
||||
}
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
91
P3_SETR2/BSP/stm32l475e_iot01_psensor.h
Normal file
91
P3_SETR2/BSP/stm32l475e_iot01_psensor.h
Normal file
@@ -0,0 +1,91 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32l475e_iot01_psensor.h
|
||||
* @author MCD Application Team
|
||||
* @brief This file provides a set of functions needed to manage the pressure sensor
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2017 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __STM32L475E_IOT01_PSENSOR_H
|
||||
#define __STM32L475E_IOT01_PSENSOR_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32l475e_iot01.h"
|
||||
#include "../Components/lps22hb/lps22hb.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32L475E_IOT01
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32L475E_IOT01_PRESSURE
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/** @defgroup STM32L475E_IOT01_PRESSURE_Exported_Types PRESSURE Exported Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief PSENSOR Status
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PSENSOR_OK = 0,
|
||||
PSENSOR_ERROR
|
||||
}PSENSOR_Status_TypDef;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32L475E_IOT01_PRESSURE_Exported_Functions PRESSURE Exported Functions
|
||||
* @{
|
||||
*/
|
||||
/* Sensor Configuration Functions */
|
||||
uint32_t BSP_PSENSOR_Init(void);
|
||||
uint8_t BSP_PSENSOR_ReadID(void);
|
||||
float BSP_PSENSOR_ReadPressure(void);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __STM32L475E_IOT01_PSENSOR_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
1108
P3_SETR2/BSP/stm32l475e_iot01_qspi.c
Normal file
1108
P3_SETR2/BSP/stm32l475e_iot01_qspi.c
Normal file
File diff suppressed because it is too large
Load Diff
120
P3_SETR2/BSP/stm32l475e_iot01_qspi.h
Normal file
120
P3_SETR2/BSP/stm32l475e_iot01_qspi.h
Normal file
@@ -0,0 +1,120 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32l475e_iot01_qspi.h
|
||||
* @author MCD Application Team
|
||||
* @brief This file contains the common defines and functions prototypes for
|
||||
* the stm32l475e_iot01_qspi.c driver.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2017 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __STM32L475E_IOT01_QSPI_H
|
||||
#define __STM32L475E_IOT01_QSPI_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32l4xx_hal.h"
|
||||
#include "../Components/mx25r6435f/mx25r6435f.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32L475E_IOT01
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32L475E_IOT01_QSPI
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/** @defgroup STM32L475E_IOT01_QSPI_Exported_Constants QSPI Exported Constants
|
||||
* @{
|
||||
*/
|
||||
/* QSPI Error codes */
|
||||
#define QSPI_OK ((uint8_t)0x00)
|
||||
#define QSPI_ERROR ((uint8_t)0x01)
|
||||
#define QSPI_BUSY ((uint8_t)0x02)
|
||||
#define QSPI_NOT_SUPPORTED ((uint8_t)0x04)
|
||||
#define QSPI_SUSPENDED ((uint8_t)0x08)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/** @defgroup STM32L475E_IOT01_QSPI_Exported_Types QSPI Exported Types
|
||||
* @{
|
||||
*/
|
||||
/* QSPI Info */
|
||||
typedef struct {
|
||||
uint32_t FlashSize; /*!< Size of the flash */
|
||||
uint32_t EraseSectorSize; /*!< Size of sectors for the erase operation */
|
||||
uint32_t EraseSectorsNumber; /*!< Number of sectors for the erase operation */
|
||||
uint32_t ProgPageSize; /*!< Size of pages for the program operation */
|
||||
uint32_t ProgPagesNumber; /*!< Number of pages for the program operation */
|
||||
} QSPI_Info;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/** @defgroup STM32L475E_IOT01_QSPI_Exported_Functions QSPI Exported Functions
|
||||
* @{
|
||||
*/
|
||||
uint8_t BSP_QSPI_Init (void);
|
||||
uint8_t BSP_QSPI_DeInit (void);
|
||||
uint8_t BSP_QSPI_Read (uint8_t* pData, uint32_t ReadAddr, uint32_t Size);
|
||||
uint8_t BSP_QSPI_Write (uint8_t* pData, uint32_t WriteAddr, uint32_t Size);
|
||||
uint8_t BSP_QSPI_Erase_Block (uint32_t BlockAddress);
|
||||
uint8_t BSP_QSPI_Erase_Sector (uint32_t Sector);
|
||||
uint8_t BSP_QSPI_Erase_Chip (void);
|
||||
uint8_t BSP_QSPI_GetStatus (void);
|
||||
uint8_t BSP_QSPI_GetInfo (QSPI_Info* pInfo);
|
||||
uint8_t BSP_QSPI_EnableMemoryMappedMode(void);
|
||||
uint8_t BSP_QSPI_SuspendErase (void);
|
||||
uint8_t BSP_QSPI_ResumeErase (void);
|
||||
uint8_t BSP_QSPI_EnterDeepPowerDown (void);
|
||||
uint8_t BSP_QSPI_LeaveDeepPowerDown (void);
|
||||
|
||||
void BSP_QSPI_MspInit(void);
|
||||
void BSP_QSPI_MspDeInit(void);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __STM32L475E_IOT01_QSPI_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
96
P3_SETR2/BSP/stm32l475e_iot01_tsensor.c
Normal file
96
P3_SETR2/BSP/stm32l475e_iot01_tsensor.c
Normal file
@@ -0,0 +1,96 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32l475e_iot01_tsensor.c
|
||||
* @author MCD Application Team
|
||||
* @brief This file provides a set of functions needed to manage the temperature sensor
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2017 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32l475e_iot01_tsensor.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32L475E_IOT01
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32L475E_IOT01_TEMPERATURE TEMPERATURE
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32L475E_IOT01_TEMPERATURE_Private_Variables TEMPERATURE Private Variables
|
||||
* @{
|
||||
*/
|
||||
static TSENSOR_DrvTypeDef *tsensor_drv;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup STM32L475E_IOT01_TEMPERATURE_Private_Functions TEMPERATURE Private Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Initializes peripherals used by the I2C Temperature Sensor driver.
|
||||
* @retval TSENSOR status
|
||||
*/
|
||||
uint32_t BSP_TSENSOR_Init(void)
|
||||
{
|
||||
uint8_t ret = TSENSOR_ERROR;
|
||||
|
||||
#ifdef USE_LPS22HB_TEMP
|
||||
tsensor_drv = &LPS22HB_T_Drv;
|
||||
#else /* USE_HTS221_TEMP */
|
||||
tsensor_drv = &HTS221_T_Drv;
|
||||
#endif
|
||||
|
||||
/* Low level init */
|
||||
SENSOR_IO_Init();
|
||||
|
||||
/* TSENSOR Init */
|
||||
tsensor_drv->Init(TSENSOR_I2C_ADDRESS, NULL);
|
||||
|
||||
ret = TSENSOR_OK;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read Temperature register of TS751.
|
||||
* @retval STTS751 measured temperature value.
|
||||
*/
|
||||
float BSP_TSENSOR_ReadTemp(void)
|
||||
{
|
||||
return tsensor_drv->ReadTemp(TSENSOR_I2C_ADDRESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
97
P3_SETR2/BSP/stm32l475e_iot01_tsensor.h
Normal file
97
P3_SETR2/BSP/stm32l475e_iot01_tsensor.h
Normal file
@@ -0,0 +1,97 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32l475e_iot01_tsensor.h
|
||||
* @author MCD Application Team
|
||||
* @brief This file provides a set of functions needed to manage the temperature sensor
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2017 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __STM32L475E_IOT01_TSENSOR_H
|
||||
#define __STM32L475E_IOT01_TSENSOR_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32l475e_iot01.h"
|
||||
#ifdef USE_LPS22HB_TEMP
|
||||
#include "../Components/lps22hb/lps22hb.h"
|
||||
#else /* USE_HTS221_TEMP */
|
||||
#include "../Components/hts221/hts221.h"
|
||||
#endif
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32L475E_IOT01
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32L475E_IOT01_TEMPERATURE
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup STM32L475E_IOT01_TEMPERATURE_Exported_Types TEMPERATURE Exported Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief TSENSOR Status
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
TSENSOR_OK = 0,
|
||||
TSENSOR_ERROR
|
||||
}TSENSOR_Status_TypDef;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup STM32L475E_IOT01_TEMPERATURE_Exported_Functions TEMPERATURE Exported Constants
|
||||
* @{
|
||||
*/
|
||||
/* Exported macros -----------------------------------------------------------*/
|
||||
/* Private macros ------------------------------------------------------------*/
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/* Sensor Configuration Functions */
|
||||
uint32_t BSP_TSENSOR_Init(void);
|
||||
float BSP_TSENSOR_ReadTemp(void);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* __STM32L475E_IOT01_TSENSOR_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
Reference in New Issue
Block a user