--ll
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -166,58 +166,7 @@ static const tFlashSector flashLayout[] =
|
|||||||
{ 0x08004800, 0x00800, 9}, /* flash sector 9 - 2kb */
|
{ 0x08004800, 0x00800, 9}, /* flash sector 9 - 2kb */
|
||||||
{ 0x08005000, 0x00800, 10}, /* flash sector 10 - 2kb */
|
{ 0x08005000, 0x00800, 10}, /* flash sector 10 - 2kb */
|
||||||
{ 0x08005800, 0x00800, 11}, /* flash sector 11 - 2kb */
|
{ 0x08005800, 0x00800, 11}, /* flash sector 11 - 2kb */
|
||||||
{ 0x08006000, 0x00800, 12}, /* flash sector 12 - 2kb */
|
/* flash sector 7 - 2kb */
|
||||||
{ 0x08006800, 0x00800, 13}, /* flash sector 13 - 2kb */
|
|
||||||
{ 0x08007000, 0x00800, 14}, /* flash sector 14 - 2kb */
|
|
||||||
{ 0x08007800, 0x00800, 15}, /* flash sector 15 - 2kb */
|
|
||||||
{ 0x08008000, 0x00800, 16}, /* flash sector 9 - 2kb */
|
|
||||||
{ 0x08008800, 0x00800, 17}, /* flash sector 10 - 2kb */
|
|
||||||
{ 0x08009000, 0x00800, 18}, /* flash sector 11 - 2kb */
|
|
||||||
{ 0x08009800, 0x00800, 19}, /* flash sector 12 - 2kb */
|
|
||||||
{ 0x0800A000, 0x00800, 20}, /* flash sector 13 - 2kb */
|
|
||||||
{ 0x0800A800, 0x00800, 21}, /* flash sector 14 - 2kb */
|
|
||||||
{ 0x0800B000, 0x00800, 22}, /* flash sector 15 - 2kb */
|
|
||||||
{ 0x0800B800, 0x00800, 23}, /* flash sector 8 - 2kb */
|
|
||||||
{ 0x0800C000, 0x00800, 24}, /* flash sector 9 - 2kb */
|
|
||||||
{ 0x0800C800, 0x00800, 25}, /* flash sector 10 - 2kb */
|
|
||||||
{ 0x0800D000, 0x00800, 26}, /* flash sector 11 - 2kb */
|
|
||||||
{ 0x0800D800, 0x00800, 27}, /* flash sector 12 - 2kb */
|
|
||||||
{ 0x0800E000, 0x00800, 28}, /* flash sector 13 - 2kb */
|
|
||||||
{ 0x0800E800, 0x00800, 29}, /* flash sector 14 - 2kb */
|
|
||||||
{ 0x0800F000, 0x00800, 30}, /* flash sector 15 - 2kb */
|
|
||||||
{ 0x0800F800, 0x00800, 31}, /* flash sector 8 - 2kb */
|
|
||||||
{ 0x08010000, 0x00800, 32}, /* flash sector 9 - 2kb */
|
|
||||||
{ 0x08010800, 0x00800, 33}, /* flash sector 10 - 2kb */
|
|
||||||
{ 0x08011000, 0x00800, 34}, /* flash sector 11 - 2kb */
|
|
||||||
{ 0x08011800, 0x00800, 35}, /* flash sector 12 - 2kb */
|
|
||||||
{ 0x08012000, 0x00800, 36}, /* flash sector 13 - 2kb */
|
|
||||||
{ 0x08012800, 0x00800, 37}, /* flash sector 14 - 2kb */
|
|
||||||
{ 0x08013000, 0x00800, 38}, /* flash sector 15 - 2kb */
|
|
||||||
{ 0x08013800, 0x08000, 39}, /* flash sector 17 - 32kb */
|
|
||||||
{ 0x08014000, 0x08000, 40}, /* flash sector 18 - 32kb */
|
|
||||||
{ 0x08014800, 0x08000, 41}, /* flash sector 17 - 32kb */
|
|
||||||
{ 0x08015000, 0x08000, 42}, /* flash sector 18 - 32kb */
|
|
||||||
{ 0x08015800, 0x08000, 43}, /* flash sector 17 - 32kb */
|
|
||||||
{ 0x08016000, 0x08000, 44}, /* flash sector 18 - 32kb */
|
|
||||||
{ 0x08016800, 0x08000, 45}, /* flash sector 17 - 32kb */
|
|
||||||
{ 0x08017000, 0x08000, 46}, /* flash sector 18 - 32kb */
|
|
||||||
{ 0x08017800, 0x00800, 47}, /* flash sector 4 - reserved for bootloader */
|
|
||||||
{ 0x08018000, 0x00800, 48}, /* flash sector 5 - 2kb */
|
|
||||||
{ 0x08018800, 0x00800, 49}, /* flash sector 6 - 2kb */
|
|
||||||
{ 0x08019000, 0x00800, 50}, /* flash sector 7 - 2kb */
|
|
||||||
{ 0x08019800, 0x00800, 51}, /* flash sector 8 - 2kb */
|
|
||||||
{ 0x0801A000, 0x00800, 52}, /* flash sector 9 - 2kb */
|
|
||||||
{ 0x0801A800, 0x00800, 53}, /* flash sector 10 - 2kb */
|
|
||||||
{ 0x0801B000, 0x00800, 54}, /* flash sector 11 - 2kb */
|
|
||||||
{ 0x0801B800, 0x00800, 55}, /* flash sector 12 - 2kb */
|
|
||||||
{ 0x0801C000, 0x00800, 56}, /* flash sector 13 - 2kb */
|
|
||||||
{ 0x0801C800, 0x00800, 57}, /* flash sector 14 - 2kb */
|
|
||||||
{ 0x0801D000, 0x00800, 58}, /* flash sector 15 - 2kb */
|
|
||||||
{ 0x0801D800, 0x00800, 59}, /* flash sector 4 - reserved for bootloader */
|
|
||||||
{ 0x0801E000, 0x00800, 60}, /* flash sector 5 - 2kb */
|
|
||||||
{ 0x0801E800, 0x00800, 61}, /* flash sector 6 - 2kb */
|
|
||||||
{ 0x0801F000, 0x00800, 62}, /* flash sector 7 - 2kb */
|
|
||||||
{ 0x0801F800, 0x00800, 63} /* flash sector 7 - 2kb */
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -234,7 +234,7 @@ blt_bool NvmVerifyChecksumHook(void)
|
|||||||
|
|
||||||
if (calculateROM_CRC32(FLASH_AREA_FULLPROG, &crcCalculated) == BLT_TRUE)
|
if (calculateROM_CRC32(FLASH_AREA_FULLPROG, &crcCalculated) == BLT_TRUE)
|
||||||
{
|
{
|
||||||
if (crcCalculated = crcInFlash )
|
if (crcCalculated == crcInFlash )
|
||||||
{
|
{
|
||||||
return BLT_TRUE;
|
return BLT_TRUE;
|
||||||
}
|
}
|
||||||
|
|||||||
50
Boot/Core/Inc/i2c.h
Normal file
50
Boot/Core/Inc/i2c.h
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file i2c.h
|
||||||
|
* @brief This file contains all the function prototypes for
|
||||||
|
* the i2c.c file
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2023 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef __I2C_H__
|
||||||
|
#define __I2C_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Includes */
|
||||||
|
|
||||||
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Private defines */
|
||||||
|
|
||||||
|
/* USER CODE END Private defines */
|
||||||
|
|
||||||
|
void MX_I2C2_Init(void);
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Prototypes */
|
||||||
|
|
||||||
|
/* USER CODE END Prototypes */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __I2C_H__ */
|
||||||
|
|
||||||
@@ -28,8 +28,9 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "stm32g0xx_hal.h"
|
||||||
|
|
||||||
#include "stm32g0xx_ll_crc.h"
|
#include "stm32g0xx_ll_i2c.h"
|
||||||
#include "stm32g0xx_ll_rcc.h"
|
#include "stm32g0xx_ll_rcc.h"
|
||||||
#include "stm32g0xx_ll_bus.h"
|
#include "stm32g0xx_ll_bus.h"
|
||||||
#include "stm32g0xx_ll_system.h"
|
#include "stm32g0xx_ll_system.h"
|
||||||
@@ -38,13 +39,10 @@ extern "C" {
|
|||||||
#include "stm32g0xx_ll_utils.h"
|
#include "stm32g0xx_ll_utils.h"
|
||||||
#include "stm32g0xx_ll_pwr.h"
|
#include "stm32g0xx_ll_pwr.h"
|
||||||
#include "stm32g0xx_ll_dma.h"
|
#include "stm32g0xx_ll_dma.h"
|
||||||
|
#include "stm32g0xx_ll_tim.h"
|
||||||
#include "stm32g0xx_ll_usart.h"
|
#include "stm32g0xx_ll_usart.h"
|
||||||
#include "stm32g0xx_ll_gpio.h"
|
#include "stm32g0xx_ll_gpio.h"
|
||||||
|
|
||||||
#if defined(USE_FULL_ASSERT)
|
|
||||||
#include "stm32_assert.h"
|
|
||||||
#endif /* USE_FULL_ASSERT */
|
|
||||||
|
|
||||||
/* Private includes ----------------------------------------------------------*/
|
/* Private includes ----------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN Includes */
|
/* USER CODE BEGIN Includes */
|
||||||
|
|
||||||
@@ -75,6 +73,8 @@ void Error_Handler(void);
|
|||||||
/* Private defines -----------------------------------------------------------*/
|
/* Private defines -----------------------------------------------------------*/
|
||||||
#define READER_EN_Pin LL_GPIO_PIN_5
|
#define READER_EN_Pin LL_GPIO_PIN_5
|
||||||
#define READER_EN_GPIO_Port GPIOA
|
#define READER_EN_GPIO_Port GPIOA
|
||||||
|
#define ZUMMER_PINOUT_Pin LL_GPIO_PIN_5
|
||||||
|
#define ZUMMER_PINOUT_GPIO_Port GPIOB
|
||||||
|
|
||||||
/* USER CODE BEGIN Private defines */
|
/* USER CODE BEGIN Private defines */
|
||||||
|
|
||||||
|
|||||||
@@ -37,12 +37,13 @@ extern "C" {
|
|||||||
/* #define HAL_ADC_MODULE_ENABLED */
|
/* #define HAL_ADC_MODULE_ENABLED */
|
||||||
/* #define HAL_CEC_MODULE_ENABLED */
|
/* #define HAL_CEC_MODULE_ENABLED */
|
||||||
/* #define HAL_COMP_MODULE_ENABLED */
|
/* #define HAL_COMP_MODULE_ENABLED */
|
||||||
#define HAL_CRC_MODULE_ENABLED
|
#define HAL_CRC_MODULE_ENABLED
|
||||||
/* #define HAL_CRYP_MODULE_ENABLED */
|
/* #define HAL_CRYP_MODULE_ENABLED */
|
||||||
/* #define HAL_DAC_MODULE_ENABLED */
|
/* #define HAL_DAC_MODULE_ENABLED */
|
||||||
/* #define HAL_EXTI_MODULE_ENABLED */
|
/* #define HAL_EXTI_MODULE_ENABLED */
|
||||||
/* #define HAL_FDCAN_MODULE_ENABLED */
|
/* #define HAL_FDCAN_MODULE_ENABLED */
|
||||||
/* #define HAL_HCD_MODULE_ENABLED */
|
/* #define HAL_HCD_MODULE_ENABLED */
|
||||||
|
/* #define HAL_I2C_MODULE_ENABLED */
|
||||||
/* #define HAL_I2S_MODULE_ENABLED */
|
/* #define HAL_I2S_MODULE_ENABLED */
|
||||||
/* #define HAL_IWDG_MODULE_ENABLED */
|
/* #define HAL_IWDG_MODULE_ENABLED */
|
||||||
/* #define HAL_IRDA_MODULE_ENABLED */
|
/* #define HAL_IRDA_MODULE_ENABLED */
|
||||||
@@ -53,13 +54,17 @@ extern "C" {
|
|||||||
/* #define HAL_SMARTCARD_MODULE_ENABLED */
|
/* #define HAL_SMARTCARD_MODULE_ENABLED */
|
||||||
/* #define HAL_SMBUS_MODULE_ENABLED */
|
/* #define HAL_SMBUS_MODULE_ENABLED */
|
||||||
/* #define HAL_SPI_MODULE_ENABLED */
|
/* #define HAL_SPI_MODULE_ENABLED */
|
||||||
|
/* #define HAL_TIM_MODULE_ENABLED */
|
||||||
/* #define HAL_UART_MODULE_ENABLED */
|
/* #define HAL_UART_MODULE_ENABLED */
|
||||||
/* #define HAL_USART_MODULE_ENABLED */
|
/* #define HAL_USART_MODULE_ENABLED */
|
||||||
/* #define HAL_WWDG_MODULE_ENABLED */
|
/* #define HAL_WWDG_MODULE_ENABLED */
|
||||||
#define HAL_GPIO_MODULE_ENABLED
|
#define HAL_GPIO_MODULE_ENABLED
|
||||||
|
#define HAL_EXTI_MODULE_ENABLED
|
||||||
#define HAL_FLASH_MODULE_ENABLED
|
#define HAL_DMA_MODULE_ENABLED
|
||||||
#define HAL_RCC_MODULE_ENABLED
|
#define HAL_RCC_MODULE_ENABLED
|
||||||
|
#define HAL_FLASH_MODULE_ENABLED
|
||||||
|
#define HAL_PWR_MODULE_ENABLED
|
||||||
|
#define HAL_CORTEX_MODULE_ENABLED
|
||||||
|
|
||||||
/* ########################## Register Callbacks selection ############################## */
|
/* ########################## Register Callbacks selection ############################## */
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -32,8 +32,6 @@ extern "C" {
|
|||||||
|
|
||||||
/* USER CODE END Includes */
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
extern TIM_HandleTypeDef htim3;
|
|
||||||
|
|
||||||
/* USER CODE BEGIN Private defines */
|
/* USER CODE BEGIN Private defines */
|
||||||
|
|
||||||
/* USER CODE END Private defines */
|
/* USER CODE END Private defines */
|
||||||
|
|||||||
65
Boot/Core/Src/crc.c
Normal file
65
Boot/Core/Src/crc.c
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file crc.c
|
||||||
|
* @brief This file provides code for the configuration
|
||||||
|
* of the CRC instances.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2023 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "crc.h"
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 0 */
|
||||||
|
|
||||||
|
/* USER CODE END 0 */
|
||||||
|
|
||||||
|
|
||||||
|
/* CRC init function */
|
||||||
|
|
||||||
|
|
||||||
|
void HAL_CRC_MspInit(CRC_HandleTypeDef* crcHandle)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(crcHandle->Instance==CRC)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN CRC_MspInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END CRC_MspInit 0 */
|
||||||
|
/* CRC clock enable */
|
||||||
|
__HAL_RCC_CRC_CLK_ENABLE();
|
||||||
|
/* USER CODE BEGIN CRC_MspInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END CRC_MspInit 1 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HAL_CRC_MspDeInit(CRC_HandleTypeDef* crcHandle)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(crcHandle->Instance==CRC)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN CRC_MspDeInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END CRC_MspDeInit 0 */
|
||||||
|
/* Peripheral clock disable */
|
||||||
|
__HAL_RCC_CRC_CLK_DISABLE();
|
||||||
|
/* USER CODE BEGIN CRC_MspDeInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END CRC_MspDeInit 1 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 1 */
|
||||||
|
|
||||||
|
/* USER CODE END 1 */
|
||||||
@@ -57,6 +57,7 @@ void MX_GPIO_Init(void)
|
|||||||
LL_GPIO_ResetOutputPin(READER_EN_GPIO_Port, READER_EN_Pin);
|
LL_GPIO_ResetOutputPin(READER_EN_GPIO_Port, READER_EN_Pin);
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
LL_GPIO_ResetOutputPin(ZUMMER_PINOUT_GPIO_Port, ZUMMER_PINOUT_Pin);
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
LL_EXTI_SetEXTISource(LL_EXTI_CONFIG_PORTA, LL_EXTI_CONFIG_LINE0);
|
LL_EXTI_SetEXTISource(LL_EXTI_CONFIG_PORTA, LL_EXTI_CONFIG_LINE0);
|
||||||
@@ -107,7 +108,12 @@ void MX_GPIO_Init(void)
|
|||||||
LL_GPIO_Init(READER_EN_GPIO_Port, &GPIO_InitStruct);
|
LL_GPIO_Init(READER_EN_GPIO_Port, &GPIO_InitStruct);
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
GPIO_InitStruct.Pin = ZUMMER_PINOUT_Pin;
|
||||||
|
GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;
|
||||||
|
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;
|
||||||
|
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
||||||
|
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
||||||
|
LL_GPIO_Init(ZUMMER_PINOUT_GPIO_Port, &GPIO_InitStruct);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
90
Boot/Core/Src/i2c.c
Normal file
90
Boot/Core/Src/i2c.c
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file i2c.c
|
||||||
|
* @brief This file provides code for the configuration
|
||||||
|
* of the I2C instances.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2023 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "i2c.h"
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 0 */
|
||||||
|
|
||||||
|
/* USER CODE END 0 */
|
||||||
|
|
||||||
|
/* I2C2 init function */
|
||||||
|
void MX_I2C2_Init(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* USER CODE BEGIN I2C2_Init 0 */
|
||||||
|
|
||||||
|
/* USER CODE END I2C2_Init 0 */
|
||||||
|
|
||||||
|
LL_I2C_InitTypeDef I2C_InitStruct = {0};
|
||||||
|
|
||||||
|
LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||||
|
|
||||||
|
LL_IOP_GRP1_EnableClock(LL_IOP_GRP1_PERIPH_GPIOA);
|
||||||
|
/**I2C2 GPIO Configuration
|
||||||
|
PA11 [PA9] ------> I2C2_SCL
|
||||||
|
PA12 [PA10] ------> I2C2_SDA
|
||||||
|
*/
|
||||||
|
GPIO_InitStruct.Pin = LL_GPIO_PIN_11;
|
||||||
|
GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
|
||||||
|
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;
|
||||||
|
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_OPENDRAIN;
|
||||||
|
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
||||||
|
GPIO_InitStruct.Alternate = LL_GPIO_AF_6;
|
||||||
|
LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
GPIO_InitStruct.Pin = LL_GPIO_PIN_12;
|
||||||
|
GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
|
||||||
|
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;
|
||||||
|
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_OPENDRAIN;
|
||||||
|
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
||||||
|
GPIO_InitStruct.Alternate = LL_GPIO_AF_6;
|
||||||
|
LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/* Peripheral clock enable */
|
||||||
|
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_I2C2);
|
||||||
|
|
||||||
|
/* USER CODE BEGIN I2C2_Init 1 */
|
||||||
|
|
||||||
|
/* USER CODE END I2C2_Init 1 */
|
||||||
|
|
||||||
|
/** I2C Initialization
|
||||||
|
*/
|
||||||
|
I2C_InitStruct.PeripheralMode = LL_I2C_MODE_I2C;
|
||||||
|
I2C_InitStruct.Timing = 0x10707DBC;
|
||||||
|
I2C_InitStruct.AnalogFilter = LL_I2C_ANALOGFILTER_ENABLE;
|
||||||
|
I2C_InitStruct.DigitalFilter = 0;
|
||||||
|
I2C_InitStruct.OwnAddress1 = 0;
|
||||||
|
I2C_InitStruct.TypeAcknowledge = LL_I2C_ACK;
|
||||||
|
I2C_InitStruct.OwnAddrSize = LL_I2C_OWNADDRESS1_7BIT;
|
||||||
|
LL_I2C_Init(I2C2, &I2C_InitStruct);
|
||||||
|
LL_I2C_EnableAutoEndMode(I2C2);
|
||||||
|
LL_I2C_SetOwnAddress2(I2C2, 0, LL_I2C_OWNADDRESS2_NOMASK);
|
||||||
|
LL_I2C_DisableOwnAddress2(I2C2);
|
||||||
|
LL_I2C_DisableGeneralCall(I2C2);
|
||||||
|
LL_I2C_EnableClockStretching(I2C2);
|
||||||
|
/* USER CODE BEGIN I2C2_Init 2 */
|
||||||
|
|
||||||
|
/* USER CODE END I2C2_Init 2 */
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 1 */
|
||||||
|
|
||||||
|
/* USER CODE END 1 */
|
||||||
@@ -20,6 +20,8 @@
|
|||||||
/* Includes ------------------------------------------------------------------*/
|
/* Includes ------------------------------------------------------------------*/
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "crc.h"
|
#include "crc.h"
|
||||||
|
#include "i2c.h"
|
||||||
|
#include "tim.h"
|
||||||
#include "usart.h"
|
#include "usart.h"
|
||||||
#include "gpio.h"
|
#include "gpio.h"
|
||||||
|
|
||||||
@@ -72,15 +74,7 @@ int main(void)
|
|||||||
/* MCU Configuration--------------------------------------------------------*/
|
/* MCU Configuration--------------------------------------------------------*/
|
||||||
|
|
||||||
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
|
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
|
||||||
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_SYSCFG);
|
HAL_Init();
|
||||||
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_PWR);
|
|
||||||
|
|
||||||
/* SysTick_IRQn interrupt configuration */
|
|
||||||
NVIC_SetPriority(SysTick_IRQn, 3);
|
|
||||||
|
|
||||||
/** Disable the internal Pull-Up in Dead Battery pins of UCPD peripheral
|
|
||||||
*/
|
|
||||||
LL_SYSCFG_DisableDBATT(LL_SYSCFG_UCPD1_STROBE | LL_SYSCFG_UCPD2_STROBE);
|
|
||||||
|
|
||||||
/* USER CODE BEGIN Init */
|
/* USER CODE BEGIN Init */
|
||||||
|
|
||||||
@@ -94,7 +88,8 @@ int main(void)
|
|||||||
/* USER CODE END SysInit */
|
/* USER CODE END SysInit */
|
||||||
|
|
||||||
/* Initialize all configured peripherals */
|
/* Initialize all configured peripherals */
|
||||||
//MX_GPIO_Init();
|
MX_GPIO_Init();
|
||||||
|
|
||||||
MX_USART1_UART_Init();
|
MX_USART1_UART_Init();
|
||||||
MX_USART2_UART_Init();
|
MX_USART2_UART_Init();
|
||||||
MX_CRC_Init();
|
MX_CRC_Init();
|
||||||
@@ -152,9 +147,14 @@ void SystemClock_Config(void)
|
|||||||
|
|
||||||
/* Set APB1 prescaler*/
|
/* Set APB1 prescaler*/
|
||||||
LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_1);
|
LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_1);
|
||||||
LL_Init1msTick(64000000);
|
|
||||||
/* Update CMSIS variable (which can be updated also through SystemCoreClockUpdate function) */
|
/* Update CMSIS variable (which can be updated also through SystemCoreClockUpdate function) */
|
||||||
LL_SetSystemCoreClock(64000000);
|
LL_SetSystemCoreClock(64000000);
|
||||||
|
|
||||||
|
/* Update the time base */
|
||||||
|
if (HAL_InitTick (TICK_INT_PRIORITY) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* USER CODE BEGIN 4 */
|
/* USER CODE BEGIN 4 */
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ void SysTick_Handler(void)
|
|||||||
/* USER CODE BEGIN SysTick_IRQn 0 */
|
/* USER CODE BEGIN SysTick_IRQn 0 */
|
||||||
|
|
||||||
/* USER CODE END SysTick_IRQn 0 */
|
/* USER CODE END SysTick_IRQn 0 */
|
||||||
|
HAL_IncTick();
|
||||||
/* USER CODE BEGIN SysTick_IRQn 1 */
|
/* USER CODE BEGIN SysTick_IRQn 1 */
|
||||||
|
|
||||||
/* USER CODE END SysTick_IRQn 1 */
|
/* USER CODE END SysTick_IRQn 1 */
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/* USER CODE END Header */
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "tim.h"
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 0 */
|
||||||
|
/* USER CODE END 0 */
|
||||||
|
|
||||||
|
/* TIM3 init function */
|
||||||
|
void MX_TIM3_Init(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* USER CODE BEGIN TIM3_Init 0 */
|
||||||
|
/* USER CODE END TIM3_Init 0 */
|
||||||
|
|
||||||
|
LL_TIM_InitTypeDef TIM_InitStruct = {0};
|
||||||
|
|
||||||
|
LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||||
|
|
||||||
|
/* Peripheral clock enable */
|
||||||
|
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM3);
|
||||||
|
|
||||||
|
LL_IOP_GRP1_EnableClock(LL_IOP_GRP1_PERIPH_GPIOB);
|
||||||
|
/**TIM3 GPIO Configuration
|
||||||
|
PB4 ------> TIM3_CH1
|
||||||
|
*/
|
||||||
|
GPIO_InitStruct.Pin = LL_GPIO_PIN_4;
|
||||||
|
GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
|
||||||
|
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;
|
||||||
|
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
||||||
|
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
||||||
|
GPIO_InitStruct.Alternate = LL_GPIO_AF_1;
|
||||||
|
LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/* USER CODE BEGIN TIM3_Init 1 */
|
||||||
|
/* USER CODE END TIM3_Init 1 */
|
||||||
|
TIM_InitStruct.Prescaler = 0;
|
||||||
|
TIM_InitStruct.CounterMode = LL_TIM_COUNTERMODE_UP;
|
||||||
|
TIM_InitStruct.Autoreload = 65535;
|
||||||
|
TIM_InitStruct.ClockDivision = LL_TIM_CLOCKDIVISION_DIV1;
|
||||||
|
LL_TIM_Init(TIM3, &TIM_InitStruct);
|
||||||
|
LL_TIM_DisableARRPreload(TIM3);
|
||||||
|
LL_TIM_SetTriggerOutput(TIM3, LL_TIM_TRGO_RESET);
|
||||||
|
LL_TIM_DisableMasterSlaveMode(TIM3);
|
||||||
|
LL_TIM_IC_SetActiveInput(TIM3, LL_TIM_CHANNEL_CH1, LL_TIM_ACTIVEINPUT_DIRECTTI);
|
||||||
|
LL_TIM_IC_SetPrescaler(TIM3, LL_TIM_CHANNEL_CH1, LL_TIM_ICPSC_DIV1);
|
||||||
|
LL_TIM_IC_SetFilter(TIM3, LL_TIM_CHANNEL_CH1, LL_TIM_IC_FILTER_FDIV1);
|
||||||
|
LL_TIM_IC_SetPolarity(TIM3, LL_TIM_CHANNEL_CH1, LL_TIM_IC_POLARITY_RISING);
|
||||||
|
/* USER CODE BEGIN TIM3_Init 2 */
|
||||||
|
/* USER CODE END TIM3_Init 2 */
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 1 */
|
||||||
|
/* USER CODE END 1 */
|
||||||
|
|||||||
@@ -1,839 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file stm32g0xx_hal_i2c.h
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @brief Header file of I2C HAL module.
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* Copyright (c) 2018 STMicroelectronics.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This software is licensed under terms that can be found in the LICENSE file
|
|
||||||
* in the root directory of this software component.
|
|
||||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
|
||||||
#ifndef STM32G0xx_HAL_I2C_H
|
|
||||||
#define STM32G0xx_HAL_I2C_H
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
#include "stm32g0xx_hal_def.h"
|
|
||||||
|
|
||||||
/** @addtogroup STM32G0xx_HAL_Driver
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup I2C
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Exported types ------------------------------------------------------------*/
|
|
||||||
/** @defgroup I2C_Exported_Types I2C Exported Types
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_Configuration_Structure_definition I2C Configuration Structure definition
|
|
||||||
* @brief I2C Configuration Structure definition
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
uint32_t Timing; /*!< Specifies the I2C_TIMINGR_register value.
|
|
||||||
This parameter calculated by referring to I2C initialization section
|
|
||||||
in Reference manual */
|
|
||||||
|
|
||||||
uint32_t OwnAddress1; /*!< Specifies the first device own address.
|
|
||||||
This parameter can be a 7-bit or 10-bit address. */
|
|
||||||
|
|
||||||
uint32_t AddressingMode; /*!< Specifies if 7-bit or 10-bit addressing mode is selected.
|
|
||||||
This parameter can be a value of @ref I2C_ADDRESSING_MODE */
|
|
||||||
|
|
||||||
uint32_t DualAddressMode; /*!< Specifies if dual addressing mode is selected.
|
|
||||||
This parameter can be a value of @ref I2C_DUAL_ADDRESSING_MODE */
|
|
||||||
|
|
||||||
uint32_t OwnAddress2; /*!< Specifies the second device own address if dual addressing mode is selected
|
|
||||||
This parameter can be a 7-bit address. */
|
|
||||||
|
|
||||||
uint32_t OwnAddress2Masks; /*!< Specifies the acknowledge mask address second device own address if dual addressing
|
|
||||||
mode is selected.
|
|
||||||
This parameter can be a value of @ref I2C_OWN_ADDRESS2_MASKS */
|
|
||||||
|
|
||||||
uint32_t GeneralCallMode; /*!< Specifies if general call mode is selected.
|
|
||||||
This parameter can be a value of @ref I2C_GENERAL_CALL_ADDRESSING_MODE */
|
|
||||||
|
|
||||||
uint32_t NoStretchMode; /*!< Specifies if nostretch mode is selected.
|
|
||||||
This parameter can be a value of @ref I2C_NOSTRETCH_MODE */
|
|
||||||
|
|
||||||
} I2C_InitTypeDef;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup HAL_state_structure_definition HAL state structure definition
|
|
||||||
* @brief HAL State structure definition
|
|
||||||
* @note HAL I2C State value coding follow below described bitmap :\n
|
|
||||||
* b7-b6 Error information\n
|
|
||||||
* 00 : No Error\n
|
|
||||||
* 01 : Abort (Abort user request on going)\n
|
|
||||||
* 10 : Timeout\n
|
|
||||||
* 11 : Error\n
|
|
||||||
* b5 Peripheral initialization status\n
|
|
||||||
* 0 : Reset (peripheral not initialized)\n
|
|
||||||
* 1 : Init done (peripheral initialized and ready to use. HAL I2C Init function called)\n
|
|
||||||
* b4 (not used)\n
|
|
||||||
* x : Should be set to 0\n
|
|
||||||
* b3\n
|
|
||||||
* 0 : Ready or Busy (No Listen mode ongoing)\n
|
|
||||||
* 1 : Listen (peripheral in Address Listen Mode)\n
|
|
||||||
* b2 Intrinsic process state\n
|
|
||||||
* 0 : Ready\n
|
|
||||||
* 1 : Busy (peripheral busy with some configuration or internal operations)\n
|
|
||||||
* b1 Rx state\n
|
|
||||||
* 0 : Ready (no Rx operation ongoing)\n
|
|
||||||
* 1 : Busy (Rx operation ongoing)\n
|
|
||||||
* b0 Tx state\n
|
|
||||||
* 0 : Ready (no Tx operation ongoing)\n
|
|
||||||
* 1 : Busy (Tx operation ongoing)
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
HAL_I2C_STATE_RESET = 0x00U, /*!< Peripheral is not yet Initialized */
|
|
||||||
HAL_I2C_STATE_READY = 0x20U, /*!< Peripheral Initialized and ready for use */
|
|
||||||
HAL_I2C_STATE_BUSY = 0x24U, /*!< An internal process is ongoing */
|
|
||||||
HAL_I2C_STATE_BUSY_TX = 0x21U, /*!< Data Transmission process is ongoing */
|
|
||||||
HAL_I2C_STATE_BUSY_RX = 0x22U, /*!< Data Reception process is ongoing */
|
|
||||||
HAL_I2C_STATE_LISTEN = 0x28U, /*!< Address Listen Mode is ongoing */
|
|
||||||
HAL_I2C_STATE_BUSY_TX_LISTEN = 0x29U, /*!< Address Listen Mode and Data Transmission
|
|
||||||
process is ongoing */
|
|
||||||
HAL_I2C_STATE_BUSY_RX_LISTEN = 0x2AU, /*!< Address Listen Mode and Data Reception
|
|
||||||
process is ongoing */
|
|
||||||
HAL_I2C_STATE_ABORT = 0x60U, /*!< Abort user request ongoing */
|
|
||||||
HAL_I2C_STATE_TIMEOUT = 0xA0U, /*!< Timeout state */
|
|
||||||
HAL_I2C_STATE_ERROR = 0xE0U /*!< Error */
|
|
||||||
|
|
||||||
} HAL_I2C_StateTypeDef;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup HAL_mode_structure_definition HAL mode structure definition
|
|
||||||
* @brief HAL Mode structure definition
|
|
||||||
* @note HAL I2C Mode value coding follow below described bitmap :\n
|
|
||||||
* b7 (not used)\n
|
|
||||||
* x : Should be set to 0\n
|
|
||||||
* b6\n
|
|
||||||
* 0 : None\n
|
|
||||||
* 1 : Memory (HAL I2C communication is in Memory Mode)\n
|
|
||||||
* b5\n
|
|
||||||
* 0 : None\n
|
|
||||||
* 1 : Slave (HAL I2C communication is in Slave Mode)\n
|
|
||||||
* b4\n
|
|
||||||
* 0 : None\n
|
|
||||||
* 1 : Master (HAL I2C communication is in Master Mode)\n
|
|
||||||
* b3-b2-b1-b0 (not used)\n
|
|
||||||
* xxxx : Should be set to 0000
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
HAL_I2C_MODE_NONE = 0x00U, /*!< No I2C communication on going */
|
|
||||||
HAL_I2C_MODE_MASTER = 0x10U, /*!< I2C communication is in Master Mode */
|
|
||||||
HAL_I2C_MODE_SLAVE = 0x20U, /*!< I2C communication is in Slave Mode */
|
|
||||||
HAL_I2C_MODE_MEM = 0x40U /*!< I2C communication is in Memory Mode */
|
|
||||||
|
|
||||||
} HAL_I2C_ModeTypeDef;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_Error_Code_definition I2C Error Code definition
|
|
||||||
* @brief I2C Error Code definition
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define HAL_I2C_ERROR_NONE (0x00000000U) /*!< No error */
|
|
||||||
#define HAL_I2C_ERROR_BERR (0x00000001U) /*!< BERR error */
|
|
||||||
#define HAL_I2C_ERROR_ARLO (0x00000002U) /*!< ARLO error */
|
|
||||||
#define HAL_I2C_ERROR_AF (0x00000004U) /*!< ACKF error */
|
|
||||||
#define HAL_I2C_ERROR_OVR (0x00000008U) /*!< OVR error */
|
|
||||||
#define HAL_I2C_ERROR_DMA (0x00000010U) /*!< DMA transfer error */
|
|
||||||
#define HAL_I2C_ERROR_TIMEOUT (0x00000020U) /*!< Timeout error */
|
|
||||||
#define HAL_I2C_ERROR_SIZE (0x00000040U) /*!< Size Management error */
|
|
||||||
#define HAL_I2C_ERROR_DMA_PARAM (0x00000080U) /*!< DMA Parameter Error */
|
|
||||||
#if (USE_HAL_I2C_REGISTER_CALLBACKS == 1)
|
|
||||||
#define HAL_I2C_ERROR_INVALID_CALLBACK (0x00000100U) /*!< Invalid Callback error */
|
|
||||||
#endif /* USE_HAL_I2C_REGISTER_CALLBACKS */
|
|
||||||
#define HAL_I2C_ERROR_INVALID_PARAM (0x00000200U) /*!< Invalid Parameters error */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_handle_Structure_definition I2C handle Structure definition
|
|
||||||
* @brief I2C handle Structure definition
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
typedef struct __I2C_HandleTypeDef
|
|
||||||
{
|
|
||||||
I2C_TypeDef *Instance; /*!< I2C registers base address */
|
|
||||||
|
|
||||||
I2C_InitTypeDef Init; /*!< I2C communication parameters */
|
|
||||||
|
|
||||||
uint8_t *pBuffPtr; /*!< Pointer to I2C transfer buffer */
|
|
||||||
|
|
||||||
uint16_t XferSize; /*!< I2C transfer size */
|
|
||||||
|
|
||||||
__IO uint16_t XferCount; /*!< I2C transfer counter */
|
|
||||||
|
|
||||||
__IO uint32_t XferOptions; /*!< I2C sequantial transfer options, this parameter can
|
|
||||||
be a value of @ref I2C_XFEROPTIONS */
|
|
||||||
|
|
||||||
__IO uint32_t PreviousState; /*!< I2C communication Previous state */
|
|
||||||
|
|
||||||
HAL_StatusTypeDef(*XferISR)(struct __I2C_HandleTypeDef *hi2c, uint32_t ITFlags, uint32_t ITSources);
|
|
||||||
/*!< I2C transfer IRQ handler function pointer */
|
|
||||||
|
|
||||||
DMA_HandleTypeDef *hdmatx; /*!< I2C Tx DMA handle parameters */
|
|
||||||
|
|
||||||
DMA_HandleTypeDef *hdmarx; /*!< I2C Rx DMA handle parameters */
|
|
||||||
|
|
||||||
HAL_LockTypeDef Lock; /*!< I2C locking object */
|
|
||||||
|
|
||||||
__IO HAL_I2C_StateTypeDef State; /*!< I2C communication state */
|
|
||||||
|
|
||||||
__IO HAL_I2C_ModeTypeDef Mode; /*!< I2C communication mode */
|
|
||||||
|
|
||||||
__IO uint32_t ErrorCode; /*!< I2C Error code */
|
|
||||||
|
|
||||||
__IO uint32_t AddrEventCount; /*!< I2C Address Event counter */
|
|
||||||
|
|
||||||
__IO uint32_t Devaddress; /*!< I2C Target device address */
|
|
||||||
|
|
||||||
__IO uint32_t Memaddress; /*!< I2C Target memory address */
|
|
||||||
|
|
||||||
#if (USE_HAL_I2C_REGISTER_CALLBACKS == 1)
|
|
||||||
void (* MasterTxCpltCallback)(struct __I2C_HandleTypeDef *hi2c);
|
|
||||||
/*!< I2C Master Tx Transfer completed callback */
|
|
||||||
void (* MasterRxCpltCallback)(struct __I2C_HandleTypeDef *hi2c);
|
|
||||||
/*!< I2C Master Rx Transfer completed callback */
|
|
||||||
void (* SlaveTxCpltCallback)(struct __I2C_HandleTypeDef *hi2c);
|
|
||||||
/*!< I2C Slave Tx Transfer completed callback */
|
|
||||||
void (* SlaveRxCpltCallback)(struct __I2C_HandleTypeDef *hi2c);
|
|
||||||
/*!< I2C Slave Rx Transfer completed callback */
|
|
||||||
void (* ListenCpltCallback)(struct __I2C_HandleTypeDef *hi2c);
|
|
||||||
/*!< I2C Listen Complete callback */
|
|
||||||
void (* MemTxCpltCallback)(struct __I2C_HandleTypeDef *hi2c);
|
|
||||||
/*!< I2C Memory Tx Transfer completed callback */
|
|
||||||
void (* MemRxCpltCallback)(struct __I2C_HandleTypeDef *hi2c);
|
|
||||||
/*!< I2C Memory Rx Transfer completed callback */
|
|
||||||
void (* ErrorCallback)(struct __I2C_HandleTypeDef *hi2c);
|
|
||||||
/*!< I2C Error callback */
|
|
||||||
void (* AbortCpltCallback)(struct __I2C_HandleTypeDef *hi2c);
|
|
||||||
/*!< I2C Abort callback */
|
|
||||||
|
|
||||||
void (* AddrCallback)(struct __I2C_HandleTypeDef *hi2c, uint8_t TransferDirection, uint16_t AddrMatchCode);
|
|
||||||
/*!< I2C Slave Address Match callback */
|
|
||||||
|
|
||||||
void (* MspInitCallback)(struct __I2C_HandleTypeDef *hi2c);
|
|
||||||
/*!< I2C Msp Init callback */
|
|
||||||
void (* MspDeInitCallback)(struct __I2C_HandleTypeDef *hi2c);
|
|
||||||
/*!< I2C Msp DeInit callback */
|
|
||||||
|
|
||||||
#endif /* USE_HAL_I2C_REGISTER_CALLBACKS */
|
|
||||||
} I2C_HandleTypeDef;
|
|
||||||
|
|
||||||
#if (USE_HAL_I2C_REGISTER_CALLBACKS == 1)
|
|
||||||
/**
|
|
||||||
* @brief HAL I2C Callback ID enumeration definition
|
|
||||||
*/
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
HAL_I2C_MASTER_TX_COMPLETE_CB_ID = 0x00U, /*!< I2C Master Tx Transfer completed callback ID */
|
|
||||||
HAL_I2C_MASTER_RX_COMPLETE_CB_ID = 0x01U, /*!< I2C Master Rx Transfer completed callback ID */
|
|
||||||
HAL_I2C_SLAVE_TX_COMPLETE_CB_ID = 0x02U, /*!< I2C Slave Tx Transfer completed callback ID */
|
|
||||||
HAL_I2C_SLAVE_RX_COMPLETE_CB_ID = 0x03U, /*!< I2C Slave Rx Transfer completed callback ID */
|
|
||||||
HAL_I2C_LISTEN_COMPLETE_CB_ID = 0x04U, /*!< I2C Listen Complete callback ID */
|
|
||||||
HAL_I2C_MEM_TX_COMPLETE_CB_ID = 0x05U, /*!< I2C Memory Tx Transfer callback ID */
|
|
||||||
HAL_I2C_MEM_RX_COMPLETE_CB_ID = 0x06U, /*!< I2C Memory Rx Transfer completed callback ID */
|
|
||||||
HAL_I2C_ERROR_CB_ID = 0x07U, /*!< I2C Error callback ID */
|
|
||||||
HAL_I2C_ABORT_CB_ID = 0x08U, /*!< I2C Abort callback ID */
|
|
||||||
|
|
||||||
HAL_I2C_MSPINIT_CB_ID = 0x09U, /*!< I2C Msp Init callback ID */
|
|
||||||
HAL_I2C_MSPDEINIT_CB_ID = 0x0AU /*!< I2C Msp DeInit callback ID */
|
|
||||||
|
|
||||||
} HAL_I2C_CallbackIDTypeDef;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief HAL I2C Callback pointer definition
|
|
||||||
*/
|
|
||||||
typedef void (*pI2C_CallbackTypeDef)(I2C_HandleTypeDef *hi2c);
|
|
||||||
/*!< pointer to an I2C callback function */
|
|
||||||
typedef void (*pI2C_AddrCallbackTypeDef)(I2C_HandleTypeDef *hi2c, uint8_t TransferDirection,
|
|
||||||
uint16_t AddrMatchCode);
|
|
||||||
/*!< pointer to an I2C Address Match callback function */
|
|
||||||
|
|
||||||
#endif /* USE_HAL_I2C_REGISTER_CALLBACKS */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
/* Exported constants --------------------------------------------------------*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_Exported_Constants I2C Exported Constants
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_XFEROPTIONS I2C Sequential Transfer Options
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define I2C_FIRST_FRAME ((uint32_t)I2C_SOFTEND_MODE)
|
|
||||||
#define I2C_FIRST_AND_NEXT_FRAME ((uint32_t)(I2C_RELOAD_MODE | I2C_SOFTEND_MODE))
|
|
||||||
#define I2C_NEXT_FRAME ((uint32_t)(I2C_RELOAD_MODE | I2C_SOFTEND_MODE))
|
|
||||||
#define I2C_FIRST_AND_LAST_FRAME ((uint32_t)I2C_AUTOEND_MODE)
|
|
||||||
#define I2C_LAST_FRAME ((uint32_t)I2C_AUTOEND_MODE)
|
|
||||||
#define I2C_LAST_FRAME_NO_STOP ((uint32_t)I2C_SOFTEND_MODE)
|
|
||||||
|
|
||||||
/* List of XferOptions in usage of :
|
|
||||||
* 1- Restart condition in all use cases (direction change or not)
|
|
||||||
*/
|
|
||||||
#define I2C_OTHER_FRAME (0x000000AAU)
|
|
||||||
#define I2C_OTHER_AND_LAST_FRAME (0x0000AA00U)
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_ADDRESSING_MODE I2C Addressing Mode
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define I2C_ADDRESSINGMODE_7BIT (0x00000001U)
|
|
||||||
#define I2C_ADDRESSINGMODE_10BIT (0x00000002U)
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_DUAL_ADDRESSING_MODE I2C Dual Addressing Mode
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define I2C_DUALADDRESS_DISABLE (0x00000000U)
|
|
||||||
#define I2C_DUALADDRESS_ENABLE I2C_OAR2_OA2EN
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_OWN_ADDRESS2_MASKS I2C Own Address2 Masks
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define I2C_OA2_NOMASK ((uint8_t)0x00U)
|
|
||||||
#define I2C_OA2_MASK01 ((uint8_t)0x01U)
|
|
||||||
#define I2C_OA2_MASK02 ((uint8_t)0x02U)
|
|
||||||
#define I2C_OA2_MASK03 ((uint8_t)0x03U)
|
|
||||||
#define I2C_OA2_MASK04 ((uint8_t)0x04U)
|
|
||||||
#define I2C_OA2_MASK05 ((uint8_t)0x05U)
|
|
||||||
#define I2C_OA2_MASK06 ((uint8_t)0x06U)
|
|
||||||
#define I2C_OA2_MASK07 ((uint8_t)0x07U)
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_GENERAL_CALL_ADDRESSING_MODE I2C General Call Addressing Mode
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define I2C_GENERALCALL_DISABLE (0x00000000U)
|
|
||||||
#define I2C_GENERALCALL_ENABLE I2C_CR1_GCEN
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_NOSTRETCH_MODE I2C No-Stretch Mode
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define I2C_NOSTRETCH_DISABLE (0x00000000U)
|
|
||||||
#define I2C_NOSTRETCH_ENABLE I2C_CR1_NOSTRETCH
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_MEMORY_ADDRESS_SIZE I2C Memory Address Size
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define I2C_MEMADD_SIZE_8BIT (0x00000001U)
|
|
||||||
#define I2C_MEMADD_SIZE_16BIT (0x00000002U)
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_XFERDIRECTION I2C Transfer Direction Master Point of View
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define I2C_DIRECTION_TRANSMIT (0x00000000U)
|
|
||||||
#define I2C_DIRECTION_RECEIVE (0x00000001U)
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_RELOAD_END_MODE I2C Reload End Mode
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define I2C_RELOAD_MODE I2C_CR2_RELOAD
|
|
||||||
#define I2C_AUTOEND_MODE I2C_CR2_AUTOEND
|
|
||||||
#define I2C_SOFTEND_MODE (0x00000000U)
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_START_STOP_MODE I2C Start or Stop Mode
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define I2C_NO_STARTSTOP (0x00000000U)
|
|
||||||
#define I2C_GENERATE_STOP (uint32_t)(0x80000000U | I2C_CR2_STOP)
|
|
||||||
#define I2C_GENERATE_START_READ (uint32_t)(0x80000000U | I2C_CR2_START | I2C_CR2_RD_WRN)
|
|
||||||
#define I2C_GENERATE_START_WRITE (uint32_t)(0x80000000U | I2C_CR2_START)
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_Interrupt_configuration_definition I2C Interrupt configuration definition
|
|
||||||
* @brief I2C Interrupt definition
|
|
||||||
* Elements values convention: 0xXXXXXXXX
|
|
||||||
* - XXXXXXXX : Interrupt control mask
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define I2C_IT_ERRI I2C_CR1_ERRIE
|
|
||||||
#define I2C_IT_TCI I2C_CR1_TCIE
|
|
||||||
#define I2C_IT_STOPI I2C_CR1_STOPIE
|
|
||||||
#define I2C_IT_NACKI I2C_CR1_NACKIE
|
|
||||||
#define I2C_IT_ADDRI I2C_CR1_ADDRIE
|
|
||||||
#define I2C_IT_RXI I2C_CR1_RXIE
|
|
||||||
#define I2C_IT_TXI I2C_CR1_TXIE
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_Flag_definition I2C Flag definition
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define I2C_FLAG_TXE I2C_ISR_TXE
|
|
||||||
#define I2C_FLAG_TXIS I2C_ISR_TXIS
|
|
||||||
#define I2C_FLAG_RXNE I2C_ISR_RXNE
|
|
||||||
#define I2C_FLAG_ADDR I2C_ISR_ADDR
|
|
||||||
#define I2C_FLAG_AF I2C_ISR_NACKF
|
|
||||||
#define I2C_FLAG_STOPF I2C_ISR_STOPF
|
|
||||||
#define I2C_FLAG_TC I2C_ISR_TC
|
|
||||||
#define I2C_FLAG_TCR I2C_ISR_TCR
|
|
||||||
#define I2C_FLAG_BERR I2C_ISR_BERR
|
|
||||||
#define I2C_FLAG_ARLO I2C_ISR_ARLO
|
|
||||||
#define I2C_FLAG_OVR I2C_ISR_OVR
|
|
||||||
#define I2C_FLAG_PECERR I2C_ISR_PECERR
|
|
||||||
#define I2C_FLAG_TIMEOUT I2C_ISR_TIMEOUT
|
|
||||||
#define I2C_FLAG_ALERT I2C_ISR_ALERT
|
|
||||||
#define I2C_FLAG_BUSY I2C_ISR_BUSY
|
|
||||||
#define I2C_FLAG_DIR I2C_ISR_DIR
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Exported macros -----------------------------------------------------------*/
|
|
||||||
|
|
||||||
/** @defgroup I2C_Exported_Macros I2C Exported Macros
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @brief Reset I2C handle state.
|
|
||||||
* @param __HANDLE__ specifies the I2C Handle.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#if (USE_HAL_I2C_REGISTER_CALLBACKS == 1)
|
|
||||||
#define __HAL_I2C_RESET_HANDLE_STATE(__HANDLE__) do{ \
|
|
||||||
(__HANDLE__)->State = HAL_I2C_STATE_RESET; \
|
|
||||||
(__HANDLE__)->MspInitCallback = NULL; \
|
|
||||||
(__HANDLE__)->MspDeInitCallback = NULL; \
|
|
||||||
} while(0)
|
|
||||||
#else
|
|
||||||
#define __HAL_I2C_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_I2C_STATE_RESET)
|
|
||||||
#endif /* USE_HAL_I2C_REGISTER_CALLBACKS */
|
|
||||||
|
|
||||||
/** @brief Enable the specified I2C interrupt.
|
|
||||||
* @param __HANDLE__ specifies the I2C Handle.
|
|
||||||
* @param __INTERRUPT__ specifies the interrupt source to enable.
|
|
||||||
* This parameter can be one of the following values:
|
|
||||||
* @arg @ref I2C_IT_ERRI Errors interrupt enable
|
|
||||||
* @arg @ref I2C_IT_TCI Transfer complete interrupt enable
|
|
||||||
* @arg @ref I2C_IT_STOPI STOP detection interrupt enable
|
|
||||||
* @arg @ref I2C_IT_NACKI NACK received interrupt enable
|
|
||||||
* @arg @ref I2C_IT_ADDRI Address match interrupt enable
|
|
||||||
* @arg @ref I2C_IT_RXI RX interrupt enable
|
|
||||||
* @arg @ref I2C_IT_TXI TX interrupt enable
|
|
||||||
*
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define __HAL_I2C_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR1 |= (__INTERRUPT__))
|
|
||||||
|
|
||||||
/** @brief Disable the specified I2C interrupt.
|
|
||||||
* @param __HANDLE__ specifies the I2C Handle.
|
|
||||||
* @param __INTERRUPT__ specifies the interrupt source to disable.
|
|
||||||
* This parameter can be one of the following values:
|
|
||||||
* @arg @ref I2C_IT_ERRI Errors interrupt enable
|
|
||||||
* @arg @ref I2C_IT_TCI Transfer complete interrupt enable
|
|
||||||
* @arg @ref I2C_IT_STOPI STOP detection interrupt enable
|
|
||||||
* @arg @ref I2C_IT_NACKI NACK received interrupt enable
|
|
||||||
* @arg @ref I2C_IT_ADDRI Address match interrupt enable
|
|
||||||
* @arg @ref I2C_IT_RXI RX interrupt enable
|
|
||||||
* @arg @ref I2C_IT_TXI TX interrupt enable
|
|
||||||
*
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define __HAL_I2C_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR1 &= (~(__INTERRUPT__)))
|
|
||||||
|
|
||||||
/** @brief Check whether the specified I2C interrupt source is enabled or not.
|
|
||||||
* @param __HANDLE__ specifies the I2C Handle.
|
|
||||||
* @param __INTERRUPT__ specifies the I2C interrupt source to check.
|
|
||||||
* This parameter can be one of the following values:
|
|
||||||
* @arg @ref I2C_IT_ERRI Errors interrupt enable
|
|
||||||
* @arg @ref I2C_IT_TCI Transfer complete interrupt enable
|
|
||||||
* @arg @ref I2C_IT_STOPI STOP detection interrupt enable
|
|
||||||
* @arg @ref I2C_IT_NACKI NACK received interrupt enable
|
|
||||||
* @arg @ref I2C_IT_ADDRI Address match interrupt enable
|
|
||||||
* @arg @ref I2C_IT_RXI RX interrupt enable
|
|
||||||
* @arg @ref I2C_IT_TXI TX interrupt enable
|
|
||||||
*
|
|
||||||
* @retval The new state of __INTERRUPT__ (SET or RESET).
|
|
||||||
*/
|
|
||||||
#define __HAL_I2C_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->CR1 & \
|
|
||||||
(__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
|
|
||||||
|
|
||||||
/** @brief Check whether the specified I2C flag is set or not.
|
|
||||||
* @param __HANDLE__ specifies the I2C Handle.
|
|
||||||
* @param __FLAG__ specifies the flag to check.
|
|
||||||
* This parameter can be one of the following values:
|
|
||||||
* @arg @ref I2C_FLAG_TXE Transmit data register empty
|
|
||||||
* @arg @ref I2C_FLAG_TXIS Transmit interrupt status
|
|
||||||
* @arg @ref I2C_FLAG_RXNE Receive data register not empty
|
|
||||||
* @arg @ref I2C_FLAG_ADDR Address matched (slave mode)
|
|
||||||
* @arg @ref I2C_FLAG_AF Acknowledge failure received flag
|
|
||||||
* @arg @ref I2C_FLAG_STOPF STOP detection flag
|
|
||||||
* @arg @ref I2C_FLAG_TC Transfer complete (master mode)
|
|
||||||
* @arg @ref I2C_FLAG_TCR Transfer complete reload
|
|
||||||
* @arg @ref I2C_FLAG_BERR Bus error
|
|
||||||
* @arg @ref I2C_FLAG_ARLO Arbitration lost
|
|
||||||
* @arg @ref I2C_FLAG_OVR Overrun/Underrun
|
|
||||||
* @arg @ref I2C_FLAG_PECERR PEC error in reception
|
|
||||||
* @arg @ref I2C_FLAG_TIMEOUT Timeout or Tlow detection flag
|
|
||||||
* @arg @ref I2C_FLAG_ALERT SMBus alert
|
|
||||||
* @arg @ref I2C_FLAG_BUSY Bus busy
|
|
||||||
* @arg @ref I2C_FLAG_DIR Transfer direction (slave mode)
|
|
||||||
*
|
|
||||||
* @retval The new state of __FLAG__ (SET or RESET).
|
|
||||||
*/
|
|
||||||
#define I2C_FLAG_MASK (0x0001FFFFU)
|
|
||||||
#define __HAL_I2C_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & \
|
|
||||||
(__FLAG__)) == (__FLAG__)) ? SET : RESET)
|
|
||||||
|
|
||||||
/** @brief Clear the I2C pending flags which are cleared by writing 1 in a specific bit.
|
|
||||||
* @param __HANDLE__ specifies the I2C Handle.
|
|
||||||
* @param __FLAG__ specifies the flag to clear.
|
|
||||||
* This parameter can be any combination of the following values:
|
|
||||||
* @arg @ref I2C_FLAG_TXE Transmit data register empty
|
|
||||||
* @arg @ref I2C_FLAG_ADDR Address matched (slave mode)
|
|
||||||
* @arg @ref I2C_FLAG_AF Acknowledge failure received flag
|
|
||||||
* @arg @ref I2C_FLAG_STOPF STOP detection flag
|
|
||||||
* @arg @ref I2C_FLAG_BERR Bus error
|
|
||||||
* @arg @ref I2C_FLAG_ARLO Arbitration lost
|
|
||||||
* @arg @ref I2C_FLAG_OVR Overrun/Underrun
|
|
||||||
* @arg @ref I2C_FLAG_PECERR PEC error in reception
|
|
||||||
* @arg @ref I2C_FLAG_TIMEOUT Timeout or Tlow detection flag
|
|
||||||
* @arg @ref I2C_FLAG_ALERT SMBus alert
|
|
||||||
*
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define __HAL_I2C_CLEAR_FLAG(__HANDLE__, __FLAG__) (((__FLAG__) == I2C_FLAG_TXE) ? \
|
|
||||||
((__HANDLE__)->Instance->ISR |= (__FLAG__)) : \
|
|
||||||
((__HANDLE__)->Instance->ICR = (__FLAG__)))
|
|
||||||
|
|
||||||
/** @brief Enable the specified I2C peripheral.
|
|
||||||
* @param __HANDLE__ specifies the I2C Handle.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define __HAL_I2C_ENABLE(__HANDLE__) (SET_BIT((__HANDLE__)->Instance->CR1, I2C_CR1_PE))
|
|
||||||
|
|
||||||
/** @brief Disable the specified I2C peripheral.
|
|
||||||
* @param __HANDLE__ specifies the I2C Handle.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define __HAL_I2C_DISABLE(__HANDLE__) (CLEAR_BIT((__HANDLE__)->Instance->CR1, I2C_CR1_PE))
|
|
||||||
|
|
||||||
/** @brief Generate a Non-Acknowledge I2C peripheral in Slave mode.
|
|
||||||
* @param __HANDLE__ specifies the I2C Handle.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
#define __HAL_I2C_GENERATE_NACK(__HANDLE__) (SET_BIT((__HANDLE__)->Instance->CR2, I2C_CR2_NACK))
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Include I2C HAL Extended module */
|
|
||||||
#include "stm32g0xx_hal_i2c_ex.h"
|
|
||||||
|
|
||||||
/* Exported functions --------------------------------------------------------*/
|
|
||||||
/** @addtogroup I2C_Exported_Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup I2C_Exported_Functions_Group1 Initialization and de-initialization functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/* Initialization and de-initialization functions******************************/
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Init(I2C_HandleTypeDef *hi2c);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_DeInit(I2C_HandleTypeDef *hi2c);
|
|
||||||
void HAL_I2C_MspInit(I2C_HandleTypeDef *hi2c);
|
|
||||||
void HAL_I2C_MspDeInit(I2C_HandleTypeDef *hi2c);
|
|
||||||
|
|
||||||
/* Callbacks Register/UnRegister functions ***********************************/
|
|
||||||
#if (USE_HAL_I2C_REGISTER_CALLBACKS == 1)
|
|
||||||
HAL_StatusTypeDef HAL_I2C_RegisterCallback(I2C_HandleTypeDef *hi2c, HAL_I2C_CallbackIDTypeDef CallbackID,
|
|
||||||
pI2C_CallbackTypeDef pCallback);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_UnRegisterCallback(I2C_HandleTypeDef *hi2c, HAL_I2C_CallbackIDTypeDef CallbackID);
|
|
||||||
|
|
||||||
HAL_StatusTypeDef HAL_I2C_RegisterAddrCallback(I2C_HandleTypeDef *hi2c, pI2C_AddrCallbackTypeDef pCallback);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_UnRegisterAddrCallback(I2C_HandleTypeDef *hi2c);
|
|
||||||
#endif /* USE_HAL_I2C_REGISTER_CALLBACKS */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup I2C_Exported_Functions_Group2 Input and Output operation functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/* IO operation functions ****************************************************/
|
|
||||||
/******* Blocking mode: Polling */
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Master_Transmit(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData,
|
|
||||||
uint16_t Size, uint32_t Timeout);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Master_Receive(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData,
|
|
||||||
uint16_t Size, uint32_t Timeout);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Slave_Transmit(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size,
|
|
||||||
uint32_t Timeout);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Slave_Receive(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size,
|
|
||||||
uint32_t Timeout);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Mem_Write(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress,
|
|
||||||
uint16_t MemAddSize, uint8_t *pData, uint16_t Size, uint32_t Timeout);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Mem_Read(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress,
|
|
||||||
uint16_t MemAddSize, uint8_t *pData, uint16_t Size, uint32_t Timeout);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_IsDeviceReady(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint32_t Trials,
|
|
||||||
uint32_t Timeout);
|
|
||||||
|
|
||||||
/******* Non-Blocking mode: Interrupt */
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Master_Transmit_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData,
|
|
||||||
uint16_t Size);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Master_Receive_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData,
|
|
||||||
uint16_t Size);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Slave_Transmit_IT(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Slave_Receive_IT(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Mem_Write_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress,
|
|
||||||
uint16_t MemAddSize, uint8_t *pData, uint16_t Size);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Mem_Read_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress,
|
|
||||||
uint16_t MemAddSize, uint8_t *pData, uint16_t Size);
|
|
||||||
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Master_Seq_Transmit_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData,
|
|
||||||
uint16_t Size, uint32_t XferOptions);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Master_Seq_Receive_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData,
|
|
||||||
uint16_t Size, uint32_t XferOptions);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Slave_Seq_Transmit_IT(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size,
|
|
||||||
uint32_t XferOptions);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Slave_Seq_Receive_IT(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size,
|
|
||||||
uint32_t XferOptions);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_EnableListen_IT(I2C_HandleTypeDef *hi2c);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_DisableListen_IT(I2C_HandleTypeDef *hi2c);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Master_Abort_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress);
|
|
||||||
|
|
||||||
/******* Non-Blocking mode: DMA */
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Master_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData,
|
|
||||||
uint16_t Size);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Master_Receive_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData,
|
|
||||||
uint16_t Size);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Slave_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Slave_Receive_DMA(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Mem_Write_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress,
|
|
||||||
uint16_t MemAddSize, uint8_t *pData, uint16_t Size);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Mem_Read_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress,
|
|
||||||
uint16_t MemAddSize, uint8_t *pData, uint16_t Size);
|
|
||||||
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Master_Seq_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData,
|
|
||||||
uint16_t Size, uint32_t XferOptions);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Master_Seq_Receive_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData,
|
|
||||||
uint16_t Size, uint32_t XferOptions);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Slave_Seq_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size,
|
|
||||||
uint32_t XferOptions);
|
|
||||||
HAL_StatusTypeDef HAL_I2C_Slave_Seq_Receive_DMA(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size,
|
|
||||||
uint32_t XferOptions);
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup I2C_IRQ_Handler_and_Callbacks IRQ Handler and Callbacks
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/******* I2C IRQHandler and Callbacks used in non blocking modes (Interrupt and DMA) */
|
|
||||||
void HAL_I2C_EV_IRQHandler(I2C_HandleTypeDef *hi2c);
|
|
||||||
void HAL_I2C_ER_IRQHandler(I2C_HandleTypeDef *hi2c);
|
|
||||||
void HAL_I2C_MasterTxCpltCallback(I2C_HandleTypeDef *hi2c);
|
|
||||||
void HAL_I2C_MasterRxCpltCallback(I2C_HandleTypeDef *hi2c);
|
|
||||||
void HAL_I2C_SlaveTxCpltCallback(I2C_HandleTypeDef *hi2c);
|
|
||||||
void HAL_I2C_SlaveRxCpltCallback(I2C_HandleTypeDef *hi2c);
|
|
||||||
void HAL_I2C_AddrCallback(I2C_HandleTypeDef *hi2c, uint8_t TransferDirection, uint16_t AddrMatchCode);
|
|
||||||
void HAL_I2C_ListenCpltCallback(I2C_HandleTypeDef *hi2c);
|
|
||||||
void HAL_I2C_MemTxCpltCallback(I2C_HandleTypeDef *hi2c);
|
|
||||||
void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c);
|
|
||||||
void HAL_I2C_ErrorCallback(I2C_HandleTypeDef *hi2c);
|
|
||||||
void HAL_I2C_AbortCpltCallback(I2C_HandleTypeDef *hi2c);
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup I2C_Exported_Functions_Group3 Peripheral State, Mode and Error functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/* Peripheral State, Mode and Error functions *********************************/
|
|
||||||
HAL_I2C_StateTypeDef HAL_I2C_GetState(I2C_HandleTypeDef *hi2c);
|
|
||||||
HAL_I2C_ModeTypeDef HAL_I2C_GetMode(I2C_HandleTypeDef *hi2c);
|
|
||||||
uint32_t HAL_I2C_GetError(I2C_HandleTypeDef *hi2c);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Private constants ---------------------------------------------------------*/
|
|
||||||
/** @defgroup I2C_Private_Constants I2C Private Constants
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Private macros ------------------------------------------------------------*/
|
|
||||||
/** @defgroup I2C_Private_Macro I2C Private Macros
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define IS_I2C_ADDRESSING_MODE(MODE) (((MODE) == I2C_ADDRESSINGMODE_7BIT) || \
|
|
||||||
((MODE) == I2C_ADDRESSINGMODE_10BIT))
|
|
||||||
|
|
||||||
#define IS_I2C_DUAL_ADDRESS(ADDRESS) (((ADDRESS) == I2C_DUALADDRESS_DISABLE) || \
|
|
||||||
((ADDRESS) == I2C_DUALADDRESS_ENABLE))
|
|
||||||
|
|
||||||
#define IS_I2C_OWN_ADDRESS2_MASK(MASK) (((MASK) == I2C_OA2_NOMASK) || \
|
|
||||||
((MASK) == I2C_OA2_MASK01) || \
|
|
||||||
((MASK) == I2C_OA2_MASK02) || \
|
|
||||||
((MASK) == I2C_OA2_MASK03) || \
|
|
||||||
((MASK) == I2C_OA2_MASK04) || \
|
|
||||||
((MASK) == I2C_OA2_MASK05) || \
|
|
||||||
((MASK) == I2C_OA2_MASK06) || \
|
|
||||||
((MASK) == I2C_OA2_MASK07))
|
|
||||||
|
|
||||||
#define IS_I2C_GENERAL_CALL(CALL) (((CALL) == I2C_GENERALCALL_DISABLE) || \
|
|
||||||
((CALL) == I2C_GENERALCALL_ENABLE))
|
|
||||||
|
|
||||||
#define IS_I2C_NO_STRETCH(STRETCH) (((STRETCH) == I2C_NOSTRETCH_DISABLE) || \
|
|
||||||
((STRETCH) == I2C_NOSTRETCH_ENABLE))
|
|
||||||
|
|
||||||
#define IS_I2C_MEMADD_SIZE(SIZE) (((SIZE) == I2C_MEMADD_SIZE_8BIT) || \
|
|
||||||
((SIZE) == I2C_MEMADD_SIZE_16BIT))
|
|
||||||
|
|
||||||
#define IS_TRANSFER_MODE(MODE) (((MODE) == I2C_RELOAD_MODE) || \
|
|
||||||
((MODE) == I2C_AUTOEND_MODE) || \
|
|
||||||
((MODE) == I2C_SOFTEND_MODE))
|
|
||||||
|
|
||||||
#define IS_TRANSFER_REQUEST(REQUEST) (((REQUEST) == I2C_GENERATE_STOP) || \
|
|
||||||
((REQUEST) == I2C_GENERATE_START_READ) || \
|
|
||||||
((REQUEST) == I2C_GENERATE_START_WRITE) || \
|
|
||||||
((REQUEST) == I2C_NO_STARTSTOP))
|
|
||||||
|
|
||||||
#define IS_I2C_TRANSFER_OPTIONS_REQUEST(REQUEST) (((REQUEST) == I2C_FIRST_FRAME) || \
|
|
||||||
((REQUEST) == I2C_FIRST_AND_NEXT_FRAME) || \
|
|
||||||
((REQUEST) == I2C_NEXT_FRAME) || \
|
|
||||||
((REQUEST) == I2C_FIRST_AND_LAST_FRAME) || \
|
|
||||||
((REQUEST) == I2C_LAST_FRAME) || \
|
|
||||||
((REQUEST) == I2C_LAST_FRAME_NO_STOP) || \
|
|
||||||
IS_I2C_TRANSFER_OTHER_OPTIONS_REQUEST(REQUEST))
|
|
||||||
|
|
||||||
#define IS_I2C_TRANSFER_OTHER_OPTIONS_REQUEST(REQUEST) (((REQUEST) == I2C_OTHER_FRAME) || \
|
|
||||||
((REQUEST) == I2C_OTHER_AND_LAST_FRAME))
|
|
||||||
|
|
||||||
#define I2C_RESET_CR2(__HANDLE__) ((__HANDLE__)->Instance->CR2 &= \
|
|
||||||
(uint32_t)~((uint32_t)(I2C_CR2_SADD | I2C_CR2_HEAD10R | \
|
|
||||||
I2C_CR2_NBYTES | I2C_CR2_RELOAD | \
|
|
||||||
I2C_CR2_RD_WRN)))
|
|
||||||
|
|
||||||
#define I2C_GET_ADDR_MATCH(__HANDLE__) ((uint16_t)(((__HANDLE__)->Instance->ISR & I2C_ISR_ADDCODE) \
|
|
||||||
>> 16U))
|
|
||||||
#define I2C_GET_DIR(__HANDLE__) ((uint8_t)(((__HANDLE__)->Instance->ISR & I2C_ISR_DIR) \
|
|
||||||
>> 16U))
|
|
||||||
#define I2C_GET_STOP_MODE(__HANDLE__) ((__HANDLE__)->Instance->CR2 & I2C_CR2_AUTOEND)
|
|
||||||
#define I2C_GET_OWN_ADDRESS1(__HANDLE__) ((uint16_t)((__HANDLE__)->Instance->OAR1 & I2C_OAR1_OA1))
|
|
||||||
#define I2C_GET_OWN_ADDRESS2(__HANDLE__) ((uint16_t)((__HANDLE__)->Instance->OAR2 & I2C_OAR2_OA2))
|
|
||||||
|
|
||||||
#define IS_I2C_OWN_ADDRESS1(ADDRESS1) ((ADDRESS1) <= 0x000003FFU)
|
|
||||||
#define IS_I2C_OWN_ADDRESS2(ADDRESS2) ((ADDRESS2) <= (uint16_t)0x00FFU)
|
|
||||||
|
|
||||||
#define I2C_MEM_ADD_MSB(__ADDRESS__) ((uint8_t)((uint16_t)(((uint16_t)((__ADDRESS__) & \
|
|
||||||
(uint16_t)(0xFF00U))) >> 8U)))
|
|
||||||
#define I2C_MEM_ADD_LSB(__ADDRESS__) ((uint8_t)((uint16_t)((__ADDRESS__) & (uint16_t)(0x00FFU))))
|
|
||||||
|
|
||||||
#define I2C_GENERATE_START(__ADDMODE__,__ADDRESS__) (((__ADDMODE__) == I2C_ADDRESSINGMODE_7BIT) ? \
|
|
||||||
(uint32_t)((((uint32_t)(__ADDRESS__) & (I2C_CR2_SADD)) | \
|
|
||||||
(I2C_CR2_START) | (I2C_CR2_AUTOEND)) & \
|
|
||||||
(~I2C_CR2_RD_WRN)) : \
|
|
||||||
(uint32_t)((((uint32_t)(__ADDRESS__) & (I2C_CR2_SADD)) | \
|
|
||||||
(I2C_CR2_ADD10) | (I2C_CR2_START)) & \
|
|
||||||
(~I2C_CR2_RD_WRN)))
|
|
||||||
|
|
||||||
#define I2C_CHECK_FLAG(__ISR__, __FLAG__) ((((__ISR__) & ((__FLAG__) & I2C_FLAG_MASK)) == \
|
|
||||||
((__FLAG__) & I2C_FLAG_MASK)) ? SET : RESET)
|
|
||||||
#define I2C_CHECK_IT_SOURCE(__CR1__, __IT__) ((((__CR1__) & (__IT__)) == (__IT__)) ? SET : RESET)
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Private Functions ---------------------------------------------------------*/
|
|
||||||
/** @defgroup I2C_Private_Functions I2C Private Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/* Private functions are defined in stm32g0xx_hal_i2c.c file */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* STM32G0xx_HAL_I2C_H */
|
|
||||||
@@ -1,177 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file stm32g0xx_hal_i2c_ex.h
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @brief Header file of I2C HAL Extended module.
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* Copyright (c) 2018 STMicroelectronics.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This software is licensed under terms that can be found in the LICENSE file
|
|
||||||
* in the root directory of this software component.
|
|
||||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
|
||||||
#ifndef STM32G0xx_HAL_I2C_EX_H
|
|
||||||
#define STM32G0xx_HAL_I2C_EX_H
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
#include "stm32g0xx_hal_def.h"
|
|
||||||
|
|
||||||
/** @addtogroup STM32G0xx_HAL_Driver
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup I2CEx
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Exported types ------------------------------------------------------------*/
|
|
||||||
/* Exported constants --------------------------------------------------------*/
|
|
||||||
/** @defgroup I2CEx_Exported_Constants I2C Extended Exported Constants
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2CEx_Analog_Filter I2C Extended Analog Filter
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define I2C_ANALOGFILTER_ENABLE 0x00000000U
|
|
||||||
#define I2C_ANALOGFILTER_DISABLE I2C_CR1_ANFOFF
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2CEx_FastModePlus I2C Extended Fast Mode Plus
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define I2C_FMP_NOT_SUPPORTED 0xAAAA0000U /*!< Fast Mode Plus not supported */
|
|
||||||
#define I2C_FASTMODEPLUS_PA9 SYSCFG_CFGR1_I2C_PA9_FMP /*!< Enable Fast Mode Plus on PA9 */
|
|
||||||
#define I2C_FASTMODEPLUS_PA10 SYSCFG_CFGR1_I2C_PA10_FMP /*!< Enable Fast Mode Plus on PA10 */
|
|
||||||
#define I2C_FASTMODEPLUS_PB6 SYSCFG_CFGR1_I2C_PB6_FMP /*!< Enable Fast Mode Plus on PB6 */
|
|
||||||
#define I2C_FASTMODEPLUS_PB7 SYSCFG_CFGR1_I2C_PB7_FMP /*!< Enable Fast Mode Plus on PB7 */
|
|
||||||
#define I2C_FASTMODEPLUS_PB8 SYSCFG_CFGR1_I2C_PB8_FMP /*!< Enable Fast Mode Plus on PB8 */
|
|
||||||
#define I2C_FASTMODEPLUS_PB9 SYSCFG_CFGR1_I2C_PB9_FMP /*!< Enable Fast Mode Plus on PB9 */
|
|
||||||
#define I2C_FASTMODEPLUS_I2C1 SYSCFG_CFGR1_I2C1_FMP /*!< Enable Fast Mode Plus on I2C1 pins */
|
|
||||||
#define I2C_FASTMODEPLUS_I2C2 SYSCFG_CFGR1_I2C2_FMP /*!< Enable Fast Mode Plus on I2C2 pins */
|
|
||||||
#if defined(SYSCFG_CFGR1_I2C3_FMP)
|
|
||||||
#define I2C_FASTMODEPLUS_I2C3 SYSCFG_CFGR1_I2C3_FMP /*!< Enable Fast Mode Plus on I2C3 pins */
|
|
||||||
#else
|
|
||||||
#define I2C_FASTMODEPLUS_I2C3 (uint32_t)(0x00000400U | I2C_FMP_NOT_SUPPORTED) /*!< Fast Mode Plus I2C3 not supported */
|
|
||||||
#endif /* SYSCFG_CFGR1_I2C3_FMP */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Exported macro ------------------------------------------------------------*/
|
|
||||||
/** @defgroup I2CEx_Exported_Macros I2C Extended Exported Macros
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Exported functions --------------------------------------------------------*/
|
|
||||||
/** @addtogroup I2CEx_Exported_Functions I2C Extended Exported Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup I2CEx_Exported_Functions_Group1 Filter Mode Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/* Peripheral Control functions ************************************************/
|
|
||||||
HAL_StatusTypeDef HAL_I2CEx_ConfigAnalogFilter(I2C_HandleTypeDef *hi2c, uint32_t AnalogFilter);
|
|
||||||
HAL_StatusTypeDef HAL_I2CEx_ConfigDigitalFilter(I2C_HandleTypeDef *hi2c, uint32_t DigitalFilter);
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup I2CEx_Exported_Functions_Group2 WakeUp Mode Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
HAL_StatusTypeDef HAL_I2CEx_EnableWakeUp(I2C_HandleTypeDef *hi2c);
|
|
||||||
HAL_StatusTypeDef HAL_I2CEx_DisableWakeUp(I2C_HandleTypeDef *hi2c);
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup I2CEx_Exported_Functions_Group3 Fast Mode Plus Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
void HAL_I2CEx_EnableFastModePlus(uint32_t ConfigFastModePlus);
|
|
||||||
void HAL_I2CEx_DisableFastModePlus(uint32_t ConfigFastModePlus);
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Private constants ---------------------------------------------------------*/
|
|
||||||
/** @defgroup I2CEx_Private_Constants I2C Extended Private Constants
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Private macros ------------------------------------------------------------*/
|
|
||||||
/** @defgroup I2CEx_Private_Macro I2C Extended Private Macros
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define IS_I2C_ANALOG_FILTER(FILTER) (((FILTER) == I2C_ANALOGFILTER_ENABLE) || \
|
|
||||||
((FILTER) == I2C_ANALOGFILTER_DISABLE))
|
|
||||||
|
|
||||||
#define IS_I2C_DIGITAL_FILTER(FILTER) ((FILTER) <= 0x0000000FU)
|
|
||||||
|
|
||||||
#define IS_I2C_FASTMODEPLUS(__CONFIG__) ((((__CONFIG__) & I2C_FMP_NOT_SUPPORTED) != I2C_FMP_NOT_SUPPORTED) && \
|
|
||||||
((((__CONFIG__) & (I2C_FASTMODEPLUS_PA9)) == I2C_FASTMODEPLUS_PA9) || \
|
|
||||||
(((__CONFIG__) & (I2C_FASTMODEPLUS_PA10)) == I2C_FASTMODEPLUS_PA10) || \
|
|
||||||
(((__CONFIG__) & (I2C_FASTMODEPLUS_PB6)) == I2C_FASTMODEPLUS_PB6) || \
|
|
||||||
(((__CONFIG__) & (I2C_FASTMODEPLUS_PB7)) == I2C_FASTMODEPLUS_PB7) || \
|
|
||||||
(((__CONFIG__) & (I2C_FASTMODEPLUS_PB8)) == I2C_FASTMODEPLUS_PB8) || \
|
|
||||||
(((__CONFIG__) & (I2C_FASTMODEPLUS_PB9)) == I2C_FASTMODEPLUS_PB9) || \
|
|
||||||
(((__CONFIG__) & (I2C_FASTMODEPLUS_I2C1)) == I2C_FASTMODEPLUS_I2C1) || \
|
|
||||||
(((__CONFIG__) & (I2C_FASTMODEPLUS_I2C2)) == I2C_FASTMODEPLUS_I2C2) || \
|
|
||||||
(((__CONFIG__) & (I2C_FASTMODEPLUS_I2C3)) == I2C_FASTMODEPLUS_I2C3)))
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Private Functions ---------------------------------------------------------*/
|
|
||||||
/** @defgroup I2CEx_Private_Functions I2C Extended Private Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
/* Private functions are defined in stm32g0xx_hal_i2c_ex.c file */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* STM32G0xx_HAL_I2C_EX_H */
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,364 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file stm32g0xx_hal_i2c_ex.c
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @brief I2C Extended HAL module driver.
|
|
||||||
* This file provides firmware functions to manage the following
|
|
||||||
* functionalities of I2C Extended peripheral:
|
|
||||||
* + Filter Mode Functions
|
|
||||||
* + WakeUp Mode Functions
|
|
||||||
* + FastModePlus Functions
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* Copyright (c) 2018 STMicroelectronics.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This software is licensed under terms that can be found in the LICENSE file
|
|
||||||
* in the root directory of this software component.
|
|
||||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
@verbatim
|
|
||||||
==============================================================================
|
|
||||||
##### I2C peripheral Extended features #####
|
|
||||||
==============================================================================
|
|
||||||
|
|
||||||
[..] Comparing to other previous devices, the I2C interface for STM32G0xx
|
|
||||||
devices contains the following additional features
|
|
||||||
|
|
||||||
(+) Possibility to disable or enable Analog Noise Filter
|
|
||||||
(+) Use of a configured Digital Noise Filter
|
|
||||||
(+) Disable or enable wakeup from Stop mode(s)
|
|
||||||
(+) Disable or enable Fast Mode Plus
|
|
||||||
|
|
||||||
##### How to use this driver #####
|
|
||||||
==============================================================================
|
|
||||||
[..] This driver provides functions to configure Noise Filter and Wake Up Feature
|
|
||||||
(#) Configure I2C Analog noise filter using the function HAL_I2CEx_ConfigAnalogFilter()
|
|
||||||
(#) Configure I2C Digital noise filter using the function HAL_I2CEx_ConfigDigitalFilter()
|
|
||||||
(#) Configure the enable or disable of I2C Wake Up Mode using the functions :
|
|
||||||
(++) HAL_I2CEx_EnableWakeUp()
|
|
||||||
(++) HAL_I2CEx_DisableWakeUp()
|
|
||||||
(#) Configure the enable or disable of fast mode plus driving capability using the functions :
|
|
||||||
(++) HAL_I2CEx_EnableFastModePlus()
|
|
||||||
(++) HAL_I2CEx_DisableFastModePlus()
|
|
||||||
@endverbatim
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
#include "stm32g0xx_hal.h"
|
|
||||||
|
|
||||||
/** @addtogroup STM32G0xx_HAL_Driver
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2CEx I2CEx
|
|
||||||
* @brief I2C Extended HAL module driver
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAL_I2C_MODULE_ENABLED
|
|
||||||
|
|
||||||
/* Private typedef -----------------------------------------------------------*/
|
|
||||||
/* Private define ------------------------------------------------------------*/
|
|
||||||
/* Private macro -------------------------------------------------------------*/
|
|
||||||
/* Private variables ---------------------------------------------------------*/
|
|
||||||
/* Private function prototypes -----------------------------------------------*/
|
|
||||||
/* Private functions ---------------------------------------------------------*/
|
|
||||||
|
|
||||||
/** @defgroup I2CEx_Exported_Functions I2C Extended Exported Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2CEx_Exported_Functions_Group1 Filter Mode Functions
|
|
||||||
* @brief Filter Mode Functions
|
|
||||||
*
|
|
||||||
@verbatim
|
|
||||||
===============================================================================
|
|
||||||
##### Filter Mode Functions #####
|
|
||||||
===============================================================================
|
|
||||||
[..] This section provides functions allowing to:
|
|
||||||
(+) Configure Noise Filters
|
|
||||||
|
|
||||||
@endverbatim
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Configure I2C Analog noise filter.
|
|
||||||
* @param hi2c Pointer to a I2C_HandleTypeDef structure that contains
|
|
||||||
* the configuration information for the specified I2Cx peripheral.
|
|
||||||
* @param AnalogFilter New state of the Analog filter.
|
|
||||||
* @retval HAL status
|
|
||||||
*/
|
|
||||||
HAL_StatusTypeDef HAL_I2CEx_ConfigAnalogFilter(I2C_HandleTypeDef *hi2c, uint32_t AnalogFilter)
|
|
||||||
{
|
|
||||||
/* Check the parameters */
|
|
||||||
assert_param(IS_I2C_ALL_INSTANCE(hi2c->Instance));
|
|
||||||
assert_param(IS_I2C_ANALOG_FILTER(AnalogFilter));
|
|
||||||
|
|
||||||
if (hi2c->State == HAL_I2C_STATE_READY)
|
|
||||||
{
|
|
||||||
/* Process Locked */
|
|
||||||
__HAL_LOCK(hi2c);
|
|
||||||
|
|
||||||
hi2c->State = HAL_I2C_STATE_BUSY;
|
|
||||||
|
|
||||||
/* Disable the selected I2C peripheral */
|
|
||||||
__HAL_I2C_DISABLE(hi2c);
|
|
||||||
|
|
||||||
/* Reset I2Cx ANOFF bit */
|
|
||||||
hi2c->Instance->CR1 &= ~(I2C_CR1_ANFOFF);
|
|
||||||
|
|
||||||
/* Set analog filter bit*/
|
|
||||||
hi2c->Instance->CR1 |= AnalogFilter;
|
|
||||||
|
|
||||||
__HAL_I2C_ENABLE(hi2c);
|
|
||||||
|
|
||||||
hi2c->State = HAL_I2C_STATE_READY;
|
|
||||||
|
|
||||||
/* Process Unlocked */
|
|
||||||
__HAL_UNLOCK(hi2c);
|
|
||||||
|
|
||||||
return HAL_OK;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return HAL_BUSY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Configure I2C Digital noise filter.
|
|
||||||
* @param hi2c Pointer to a I2C_HandleTypeDef structure that contains
|
|
||||||
* the configuration information for the specified I2Cx peripheral.
|
|
||||||
* @param DigitalFilter Coefficient of digital noise filter between Min_Data=0x00 and Max_Data=0x0F.
|
|
||||||
* @retval HAL status
|
|
||||||
*/
|
|
||||||
HAL_StatusTypeDef HAL_I2CEx_ConfigDigitalFilter(I2C_HandleTypeDef *hi2c, uint32_t DigitalFilter)
|
|
||||||
{
|
|
||||||
uint32_t tmpreg;
|
|
||||||
|
|
||||||
/* Check the parameters */
|
|
||||||
assert_param(IS_I2C_ALL_INSTANCE(hi2c->Instance));
|
|
||||||
assert_param(IS_I2C_DIGITAL_FILTER(DigitalFilter));
|
|
||||||
|
|
||||||
if (hi2c->State == HAL_I2C_STATE_READY)
|
|
||||||
{
|
|
||||||
/* Process Locked */
|
|
||||||
__HAL_LOCK(hi2c);
|
|
||||||
|
|
||||||
hi2c->State = HAL_I2C_STATE_BUSY;
|
|
||||||
|
|
||||||
/* Disable the selected I2C peripheral */
|
|
||||||
__HAL_I2C_DISABLE(hi2c);
|
|
||||||
|
|
||||||
/* Get the old register value */
|
|
||||||
tmpreg = hi2c->Instance->CR1;
|
|
||||||
|
|
||||||
/* Reset I2Cx DNF bits [11:8] */
|
|
||||||
tmpreg &= ~(I2C_CR1_DNF);
|
|
||||||
|
|
||||||
/* Set I2Cx DNF coefficient */
|
|
||||||
tmpreg |= DigitalFilter << 8U;
|
|
||||||
|
|
||||||
/* Store the new register value */
|
|
||||||
hi2c->Instance->CR1 = tmpreg;
|
|
||||||
|
|
||||||
__HAL_I2C_ENABLE(hi2c);
|
|
||||||
|
|
||||||
hi2c->State = HAL_I2C_STATE_READY;
|
|
||||||
|
|
||||||
/* Process Unlocked */
|
|
||||||
__HAL_UNLOCK(hi2c);
|
|
||||||
|
|
||||||
return HAL_OK;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return HAL_BUSY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2CEx_Exported_Functions_Group2 WakeUp Mode Functions
|
|
||||||
* @brief WakeUp Mode Functions
|
|
||||||
*
|
|
||||||
@verbatim
|
|
||||||
===============================================================================
|
|
||||||
##### WakeUp Mode Functions #####
|
|
||||||
===============================================================================
|
|
||||||
[..] This section provides functions allowing to:
|
|
||||||
(+) Configure Wake Up Feature
|
|
||||||
|
|
||||||
@endverbatim
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Enable I2C wakeup from Stop mode(s).
|
|
||||||
* @param hi2c Pointer to a I2C_HandleTypeDef structure that contains
|
|
||||||
* the configuration information for the specified I2Cx peripheral.
|
|
||||||
* @retval HAL status
|
|
||||||
*/
|
|
||||||
HAL_StatusTypeDef HAL_I2CEx_EnableWakeUp(I2C_HandleTypeDef *hi2c)
|
|
||||||
{
|
|
||||||
/* Check the parameters */
|
|
||||||
assert_param(IS_I2C_WAKEUP_FROMSTOP_INSTANCE(hi2c->Instance));
|
|
||||||
|
|
||||||
if (hi2c->State == HAL_I2C_STATE_READY)
|
|
||||||
{
|
|
||||||
/* Process Locked */
|
|
||||||
__HAL_LOCK(hi2c);
|
|
||||||
|
|
||||||
hi2c->State = HAL_I2C_STATE_BUSY;
|
|
||||||
|
|
||||||
/* Disable the selected I2C peripheral */
|
|
||||||
__HAL_I2C_DISABLE(hi2c);
|
|
||||||
|
|
||||||
/* Enable wakeup from stop mode */
|
|
||||||
hi2c->Instance->CR1 |= I2C_CR1_WUPEN;
|
|
||||||
|
|
||||||
__HAL_I2C_ENABLE(hi2c);
|
|
||||||
|
|
||||||
hi2c->State = HAL_I2C_STATE_READY;
|
|
||||||
|
|
||||||
/* Process Unlocked */
|
|
||||||
__HAL_UNLOCK(hi2c);
|
|
||||||
|
|
||||||
return HAL_OK;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return HAL_BUSY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Disable I2C wakeup from Stop mode(s).
|
|
||||||
* @param hi2c Pointer to a I2C_HandleTypeDef structure that contains
|
|
||||||
* the configuration information for the specified I2Cx peripheral.
|
|
||||||
* @retval HAL status
|
|
||||||
*/
|
|
||||||
HAL_StatusTypeDef HAL_I2CEx_DisableWakeUp(I2C_HandleTypeDef *hi2c)
|
|
||||||
{
|
|
||||||
/* Check the parameters */
|
|
||||||
assert_param(IS_I2C_WAKEUP_FROMSTOP_INSTANCE(hi2c->Instance));
|
|
||||||
|
|
||||||
if (hi2c->State == HAL_I2C_STATE_READY)
|
|
||||||
{
|
|
||||||
/* Process Locked */
|
|
||||||
__HAL_LOCK(hi2c);
|
|
||||||
|
|
||||||
hi2c->State = HAL_I2C_STATE_BUSY;
|
|
||||||
|
|
||||||
/* Disable the selected I2C peripheral */
|
|
||||||
__HAL_I2C_DISABLE(hi2c);
|
|
||||||
|
|
||||||
/* Enable wakeup from stop mode */
|
|
||||||
hi2c->Instance->CR1 &= ~(I2C_CR1_WUPEN);
|
|
||||||
|
|
||||||
__HAL_I2C_ENABLE(hi2c);
|
|
||||||
|
|
||||||
hi2c->State = HAL_I2C_STATE_READY;
|
|
||||||
|
|
||||||
/* Process Unlocked */
|
|
||||||
__HAL_UNLOCK(hi2c);
|
|
||||||
|
|
||||||
return HAL_OK;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return HAL_BUSY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @defgroup I2CEx_Exported_Functions_Group3 Fast Mode Plus Functions
|
|
||||||
* @brief Fast Mode Plus Functions
|
|
||||||
*
|
|
||||||
@verbatim
|
|
||||||
===============================================================================
|
|
||||||
##### Fast Mode Plus Functions #####
|
|
||||||
===============================================================================
|
|
||||||
[..] This section provides functions allowing to:
|
|
||||||
(+) Configure Fast Mode Plus
|
|
||||||
|
|
||||||
@endverbatim
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Enable the I2C fast mode plus driving capability.
|
|
||||||
* @param ConfigFastModePlus Selects the pin.
|
|
||||||
* This parameter can be one of the @ref I2CEx_FastModePlus values
|
|
||||||
* @note For I2C1, fast mode plus driving capability can be enabled on all selected
|
|
||||||
* I2C1 pins using I2C_FASTMODEPLUS_I2C1 parameter or independently
|
|
||||||
* on each one of the following pins PB6, PB7, PB8 and PB9.
|
|
||||||
* @note For remaining I2C1 pins (PA14, PA15...) fast mode plus driving capability
|
|
||||||
* can be enabled only by using I2C_FASTMODEPLUS_I2C1 parameter.
|
|
||||||
* @note For all I2C2 pins fast mode plus driving capability can be enabled
|
|
||||||
* only by using I2C_FASTMODEPLUS_I2C2 parameter.
|
|
||||||
* @note For all I2C3 pins fast mode plus driving capability can be enabled
|
|
||||||
* only by using I2C_FASTMODEPLUS_I2C3 parameter.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_I2CEx_EnableFastModePlus(uint32_t ConfigFastModePlus)
|
|
||||||
{
|
|
||||||
/* Check the parameter */
|
|
||||||
assert_param(IS_I2C_FASTMODEPLUS(ConfigFastModePlus));
|
|
||||||
|
|
||||||
/* Enable SYSCFG clock */
|
|
||||||
__HAL_RCC_SYSCFG_CLK_ENABLE();
|
|
||||||
|
|
||||||
/* Enable fast mode plus driving capability for selected pin */
|
|
||||||
SET_BIT(SYSCFG->CFGR1, (uint32_t)ConfigFastModePlus);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Disable the I2C fast mode plus driving capability.
|
|
||||||
* @param ConfigFastModePlus Selects the pin.
|
|
||||||
* This parameter can be one of the @ref I2CEx_FastModePlus values
|
|
||||||
* @note For I2C1, fast mode plus driving capability can be disabled on all selected
|
|
||||||
* I2C1 pins using I2C_FASTMODEPLUS_I2C1 parameter or independently
|
|
||||||
* on each one of the following pins PB6, PB7, PB8 and PB9.
|
|
||||||
* @note For remaining I2C1 pins (PA14, PA15...) fast mode plus driving capability
|
|
||||||
* can be disabled only by using I2C_FASTMODEPLUS_I2C1 parameter.
|
|
||||||
* @note For all I2C2 pins fast mode plus driving capability can be disabled
|
|
||||||
* only by using I2C_FASTMODEPLUS_I2C2 parameter.
|
|
||||||
* @note For all I2C3 pins fast mode plus driving capability can be disabled
|
|
||||||
* only by using I2C_FASTMODEPLUS_I2C3 parameter.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void HAL_I2CEx_DisableFastModePlus(uint32_t ConfigFastModePlus)
|
|
||||||
{
|
|
||||||
/* Check the parameter */
|
|
||||||
assert_param(IS_I2C_FASTMODEPLUS(ConfigFastModePlus));
|
|
||||||
|
|
||||||
/* Enable SYSCFG clock */
|
|
||||||
__HAL_RCC_SYSCFG_CLK_ENABLE();
|
|
||||||
|
|
||||||
/* Disable fast mode plus driving capability for selected pin */
|
|
||||||
CLEAR_BIT(SYSCFG->CFGR1, (uint32_t)ConfigFastModePlus);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#endif /* HAL_I2C_MODULE_ENABLED */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
@@ -1,103 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file stm32g0xx_ll_crc.c
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @brief CRC LL module driver.
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* Copyright (c) 2018 STMicroelectronics.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This software is licensed under terms that can be found in the LICENSE file
|
|
||||||
* in the root directory of this software component.
|
|
||||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
#if defined(USE_FULL_LL_DRIVER)
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
#include "stm32g0xx_ll_crc.h"
|
|
||||||
#include "stm32g0xx_ll_bus.h"
|
|
||||||
|
|
||||||
#ifdef USE_FULL_ASSERT
|
|
||||||
#include "stm32_assert.h"
|
|
||||||
#else
|
|
||||||
#define assert_param(expr) ((void)0U)
|
|
||||||
#endif /* USE_FULL_ASSERT */
|
|
||||||
|
|
||||||
/** @addtogroup STM32G0xx_LL_Driver
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined (CRC)
|
|
||||||
|
|
||||||
/** @addtogroup CRC_LL
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Private types -------------------------------------------------------------*/
|
|
||||||
/* Private variables ---------------------------------------------------------*/
|
|
||||||
/* Private constants ---------------------------------------------------------*/
|
|
||||||
/* Private macros ------------------------------------------------------------*/
|
|
||||||
/* Private function prototypes -----------------------------------------------*/
|
|
||||||
|
|
||||||
/* Exported functions --------------------------------------------------------*/
|
|
||||||
/** @addtogroup CRC_LL_Exported_Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup CRC_LL_EF_Init
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief De-initialize CRC registers (Registers restored to their default values).
|
|
||||||
* @param CRCx CRC Instance
|
|
||||||
* @retval An ErrorStatus enumeration value:
|
|
||||||
* - SUCCESS: CRC registers are de-initialized
|
|
||||||
* - ERROR: CRC registers are not de-initialized
|
|
||||||
*/
|
|
||||||
ErrorStatus LL_CRC_DeInit(CRC_TypeDef *CRCx)
|
|
||||||
{
|
|
||||||
ErrorStatus status = SUCCESS;
|
|
||||||
|
|
||||||
/* Check the parameters */
|
|
||||||
assert_param(IS_CRC_ALL_INSTANCE(CRCx));
|
|
||||||
|
|
||||||
if (CRCx == CRC)
|
|
||||||
{
|
|
||||||
/* Force CRC reset */
|
|
||||||
LL_AHB1_GRP1_ForceReset(LL_AHB1_GRP1_PERIPH_CRC);
|
|
||||||
|
|
||||||
/* Release CRC reset */
|
|
||||||
LL_AHB1_GRP1_ReleaseReset(LL_AHB1_GRP1_PERIPH_CRC);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
status = ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (status);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#endif /* defined (CRC) */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#endif /* USE_FULL_LL_DRIVER */
|
|
||||||
234
Boot/Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_i2c.c
Normal file
234
Boot/Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_i2c.c
Normal file
@@ -0,0 +1,234 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file stm32g0xx_ll_i2c.c
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @brief I2C LL module driver.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2018 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
#if defined(USE_FULL_LL_DRIVER)
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "stm32g0xx_ll_i2c.h"
|
||||||
|
#include "stm32g0xx_ll_bus.h"
|
||||||
|
#ifdef USE_FULL_ASSERT
|
||||||
|
#include "stm32_assert.h"
|
||||||
|
#else
|
||||||
|
#define assert_param(expr) ((void)0U)
|
||||||
|
#endif /* USE_FULL_ASSERT */
|
||||||
|
|
||||||
|
/** @addtogroup STM32G0xx_LL_Driver
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined (I2C1) || defined (I2C2) || defined (I2C3)
|
||||||
|
|
||||||
|
/** @defgroup I2C_LL I2C
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Private types -------------------------------------------------------------*/
|
||||||
|
/* Private variables ---------------------------------------------------------*/
|
||||||
|
/* Private constants ---------------------------------------------------------*/
|
||||||
|
/* Private macros ------------------------------------------------------------*/
|
||||||
|
/** @addtogroup I2C_LL_Private_Macros
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define IS_LL_I2C_PERIPHERAL_MODE(__VALUE__) (((__VALUE__) == LL_I2C_MODE_I2C) || \
|
||||||
|
((__VALUE__) == LL_I2C_MODE_SMBUS_HOST) || \
|
||||||
|
((__VALUE__) == LL_I2C_MODE_SMBUS_DEVICE) || \
|
||||||
|
((__VALUE__) == LL_I2C_MODE_SMBUS_DEVICE_ARP))
|
||||||
|
|
||||||
|
#define IS_LL_I2C_ANALOG_FILTER(__VALUE__) (((__VALUE__) == LL_I2C_ANALOGFILTER_ENABLE) || \
|
||||||
|
((__VALUE__) == LL_I2C_ANALOGFILTER_DISABLE))
|
||||||
|
|
||||||
|
#define IS_LL_I2C_DIGITAL_FILTER(__VALUE__) ((__VALUE__) <= 0x0000000FU)
|
||||||
|
|
||||||
|
#define IS_LL_I2C_OWN_ADDRESS1(__VALUE__) ((__VALUE__) <= 0x000003FFU)
|
||||||
|
|
||||||
|
#define IS_LL_I2C_TYPE_ACKNOWLEDGE(__VALUE__) (((__VALUE__) == LL_I2C_ACK) || \
|
||||||
|
((__VALUE__) == LL_I2C_NACK))
|
||||||
|
|
||||||
|
#define IS_LL_I2C_OWN_ADDRSIZE(__VALUE__) (((__VALUE__) == LL_I2C_OWNADDRESS1_7BIT) || \
|
||||||
|
((__VALUE__) == LL_I2C_OWNADDRESS1_10BIT))
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Private function prototypes -----------------------------------------------*/
|
||||||
|
|
||||||
|
/* Exported functions --------------------------------------------------------*/
|
||||||
|
/** @addtogroup I2C_LL_Exported_Functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @addtogroup I2C_LL_EF_Init
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief De-initialize the I2C registers to their default reset values.
|
||||||
|
* @param I2Cx I2C Instance.
|
||||||
|
* @retval An ErrorStatus enumeration value:
|
||||||
|
* - SUCCESS: I2C registers are de-initialized
|
||||||
|
* - ERROR: I2C registers are not de-initialized
|
||||||
|
*/
|
||||||
|
ErrorStatus LL_I2C_DeInit(I2C_TypeDef *I2Cx)
|
||||||
|
{
|
||||||
|
ErrorStatus status = SUCCESS;
|
||||||
|
|
||||||
|
/* Check the I2C Instance I2Cx */
|
||||||
|
assert_param(IS_I2C_ALL_INSTANCE(I2Cx));
|
||||||
|
|
||||||
|
if (I2Cx == I2C1)
|
||||||
|
{
|
||||||
|
/* Force reset of I2C clock */
|
||||||
|
LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_I2C1);
|
||||||
|
|
||||||
|
/* Release reset of I2C clock */
|
||||||
|
LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_I2C1);
|
||||||
|
}
|
||||||
|
else if (I2Cx == I2C2)
|
||||||
|
{
|
||||||
|
/* Force reset of I2C clock */
|
||||||
|
LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_I2C2);
|
||||||
|
|
||||||
|
/* Release reset of I2C clock */
|
||||||
|
LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_I2C2);
|
||||||
|
|
||||||
|
}
|
||||||
|
#if defined(I2C3)
|
||||||
|
else if (I2Cx == I2C3)
|
||||||
|
{
|
||||||
|
/* Force reset of I2C clock */
|
||||||
|
LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_I2C3);
|
||||||
|
|
||||||
|
/* Release reset of I2C clock */
|
||||||
|
LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_I2C3);
|
||||||
|
}
|
||||||
|
#endif /* I2C3 */
|
||||||
|
else
|
||||||
|
{
|
||||||
|
status = ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Initialize the I2C registers according to the specified parameters in I2C_InitStruct.
|
||||||
|
* @param I2Cx I2C Instance.
|
||||||
|
* @param I2C_InitStruct pointer to a @ref LL_I2C_InitTypeDef structure.
|
||||||
|
* @retval An ErrorStatus enumeration value:
|
||||||
|
* - SUCCESS: I2C registers are initialized
|
||||||
|
* - ERROR: Not applicable
|
||||||
|
*/
|
||||||
|
ErrorStatus LL_I2C_Init(I2C_TypeDef *I2Cx, LL_I2C_InitTypeDef *I2C_InitStruct)
|
||||||
|
{
|
||||||
|
/* Check the I2C Instance I2Cx */
|
||||||
|
assert_param(IS_I2C_ALL_INSTANCE(I2Cx));
|
||||||
|
|
||||||
|
/* Check the I2C parameters from I2C_InitStruct */
|
||||||
|
assert_param(IS_LL_I2C_PERIPHERAL_MODE(I2C_InitStruct->PeripheralMode));
|
||||||
|
assert_param(IS_LL_I2C_ANALOG_FILTER(I2C_InitStruct->AnalogFilter));
|
||||||
|
assert_param(IS_LL_I2C_DIGITAL_FILTER(I2C_InitStruct->DigitalFilter));
|
||||||
|
assert_param(IS_LL_I2C_OWN_ADDRESS1(I2C_InitStruct->OwnAddress1));
|
||||||
|
assert_param(IS_LL_I2C_TYPE_ACKNOWLEDGE(I2C_InitStruct->TypeAcknowledge));
|
||||||
|
assert_param(IS_LL_I2C_OWN_ADDRSIZE(I2C_InitStruct->OwnAddrSize));
|
||||||
|
|
||||||
|
/* Disable the selected I2Cx Peripheral */
|
||||||
|
LL_I2C_Disable(I2Cx);
|
||||||
|
|
||||||
|
/*---------------------------- I2Cx CR1 Configuration ------------------------
|
||||||
|
* Configure the analog and digital noise filters with parameters :
|
||||||
|
* - AnalogFilter: I2C_CR1_ANFOFF bit
|
||||||
|
* - DigitalFilter: I2C_CR1_DNF[3:0] bits
|
||||||
|
*/
|
||||||
|
LL_I2C_ConfigFilters(I2Cx, I2C_InitStruct->AnalogFilter, I2C_InitStruct->DigitalFilter);
|
||||||
|
|
||||||
|
/*---------------------------- I2Cx TIMINGR Configuration --------------------
|
||||||
|
* Configure the SDA setup, hold time and the SCL high, low period with parameter :
|
||||||
|
* - Timing: I2C_TIMINGR_PRESC[3:0], I2C_TIMINGR_SCLDEL[3:0], I2C_TIMINGR_SDADEL[3:0],
|
||||||
|
* I2C_TIMINGR_SCLH[7:0] and I2C_TIMINGR_SCLL[7:0] bits
|
||||||
|
*/
|
||||||
|
LL_I2C_SetTiming(I2Cx, I2C_InitStruct->Timing);
|
||||||
|
|
||||||
|
/* Enable the selected I2Cx Peripheral */
|
||||||
|
LL_I2C_Enable(I2Cx);
|
||||||
|
|
||||||
|
/*---------------------------- I2Cx OAR1 Configuration -----------------------
|
||||||
|
* Disable, Configure and Enable I2Cx device own address 1 with parameters :
|
||||||
|
* - OwnAddress1: I2C_OAR1_OA1[9:0] bits
|
||||||
|
* - OwnAddrSize: I2C_OAR1_OA1MODE bit
|
||||||
|
*/
|
||||||
|
LL_I2C_DisableOwnAddress1(I2Cx);
|
||||||
|
LL_I2C_SetOwnAddress1(I2Cx, I2C_InitStruct->OwnAddress1, I2C_InitStruct->OwnAddrSize);
|
||||||
|
|
||||||
|
/* OwnAdress1 == 0 is reserved for General Call address */
|
||||||
|
if (I2C_InitStruct->OwnAddress1 != 0U)
|
||||||
|
{
|
||||||
|
LL_I2C_EnableOwnAddress1(I2Cx);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------- I2Cx MODE Configuration -----------------------
|
||||||
|
* Configure I2Cx peripheral mode with parameter :
|
||||||
|
* - PeripheralMode: I2C_CR1_SMBDEN and I2C_CR1_SMBHEN bits
|
||||||
|
*/
|
||||||
|
LL_I2C_SetMode(I2Cx, I2C_InitStruct->PeripheralMode);
|
||||||
|
|
||||||
|
/*---------------------------- I2Cx CR2 Configuration ------------------------
|
||||||
|
* Configure the ACKnowledge or Non ACKnowledge condition
|
||||||
|
* after the address receive match code or next received byte with parameter :
|
||||||
|
* - TypeAcknowledge: I2C_CR2_NACK bit
|
||||||
|
*/
|
||||||
|
LL_I2C_AcknowledgeNextData(I2Cx, I2C_InitStruct->TypeAcknowledge);
|
||||||
|
|
||||||
|
return SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set each @ref LL_I2C_InitTypeDef field to default value.
|
||||||
|
* @param I2C_InitStruct Pointer to a @ref LL_I2C_InitTypeDef structure.
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void LL_I2C_StructInit(LL_I2C_InitTypeDef *I2C_InitStruct)
|
||||||
|
{
|
||||||
|
/* Set I2C_InitStruct fields to default values */
|
||||||
|
I2C_InitStruct->PeripheralMode = LL_I2C_MODE_I2C;
|
||||||
|
I2C_InitStruct->Timing = 0U;
|
||||||
|
I2C_InitStruct->AnalogFilter = LL_I2C_ANALOGFILTER_ENABLE;
|
||||||
|
I2C_InitStruct->DigitalFilter = 0U;
|
||||||
|
I2C_InitStruct->OwnAddress1 = 0U;
|
||||||
|
I2C_InitStruct->TypeAcknowledge = LL_I2C_NACK;
|
||||||
|
I2C_InitStruct->OwnAddrSize = LL_I2C_OWNADDRESS1_7BIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endif /* I2C1 || I2C2 || I2C3 */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endif /* USE_FULL_LL_DRIVER */
|
||||||
@@ -1,82 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* @file stm32g0xx_ll_pwr.c
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @brief PWR LL module driver.
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* Copyright (c) 2018 STMicroelectronics.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This software is licensed under terms that can be found in the LICENSE file
|
|
||||||
* in the root directory of this software component.
|
|
||||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
#if defined(USE_FULL_LL_DRIVER)
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
#include "stm32g0xx_ll_pwr.h"
|
|
||||||
#include "stm32g0xx_ll_bus.h"
|
|
||||||
|
|
||||||
/** @addtogroup STM32G0xx_LL_Driver
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined(PWR)
|
|
||||||
|
|
||||||
/** @defgroup PWR_LL PWR
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Private types -------------------------------------------------------------*/
|
|
||||||
/* Private variables ---------------------------------------------------------*/
|
|
||||||
/* Private constants ---------------------------------------------------------*/
|
|
||||||
/* Private macros ------------------------------------------------------------*/
|
|
||||||
/* Private function prototypes -----------------------------------------------*/
|
|
||||||
|
|
||||||
/* Exported functions --------------------------------------------------------*/
|
|
||||||
/** @addtogroup PWR_LL_Exported_Functions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @addtogroup PWR_LL_EF_Init
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief De-initialize the PWR registers to their default reset values.
|
|
||||||
* @retval An ErrorStatus enumeration value:
|
|
||||||
* - SUCCESS: PWR registers are de-initialized
|
|
||||||
* - ERROR: not applicable
|
|
||||||
*/
|
|
||||||
ErrorStatus LL_PWR_DeInit(void)
|
|
||||||
{
|
|
||||||
/* Force reset of PWR clock */
|
|
||||||
LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_PWR);
|
|
||||||
|
|
||||||
/* Release reset of PWR clock */
|
|
||||||
LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_PWR);
|
|
||||||
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
#endif /* defined(PWR) */
|
|
||||||
/**
|
|
||||||
* @}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#endif /* USE_FULL_LL_DRIVER */
|
|
||||||
1369
Boot/Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_tim.c
Normal file
1369
Boot/Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_tim.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -4,17 +4,20 @@ CAD.pinconfig=
|
|||||||
CAD.provider=
|
CAD.provider=
|
||||||
File.Version=6
|
File.Version=6
|
||||||
GPIO.groupedBy=Group By Peripherals
|
GPIO.groupedBy=Group By Peripherals
|
||||||
|
I2C2.IPParameters=Timing
|
||||||
|
I2C2.Timing=0x10707DBC
|
||||||
KeepUserPlacement=false
|
KeepUserPlacement=false
|
||||||
Mcu.CPN=STM32G070CBT6
|
Mcu.CPN=STM32G070CBT6
|
||||||
Mcu.Family=STM32G0
|
Mcu.Family=STM32G0
|
||||||
Mcu.IP0=I2C2
|
Mcu.IP0=CRC
|
||||||
Mcu.IP1=NVIC
|
Mcu.IP1=I2C2
|
||||||
Mcu.IP2=RCC
|
Mcu.IP2=NVIC
|
||||||
Mcu.IP3=SYS
|
Mcu.IP3=RCC
|
||||||
Mcu.IP4=TIM3
|
Mcu.IP4=SYS
|
||||||
Mcu.IP5=USART1
|
Mcu.IP5=TIM3
|
||||||
Mcu.IP6=USART2
|
Mcu.IP6=USART1
|
||||||
Mcu.IPNb=7
|
Mcu.IP7=USART2
|
||||||
|
Mcu.IPNb=8
|
||||||
Mcu.Name=STM32G070CBTx
|
Mcu.Name=STM32G070CBTx
|
||||||
Mcu.Package=LQFP48
|
Mcu.Package=LQFP48
|
||||||
Mcu.Pin0=PF0-OSC_IN (PF0)
|
Mcu.Pin0=PF0-OSC_IN (PF0)
|
||||||
@@ -25,8 +28,9 @@ Mcu.Pin12=PB4
|
|||||||
Mcu.Pin13=PB5
|
Mcu.Pin13=PB5
|
||||||
Mcu.Pin14=PB6
|
Mcu.Pin14=PB6
|
||||||
Mcu.Pin15=PB7
|
Mcu.Pin15=PB7
|
||||||
Mcu.Pin16=VP_SYS_VS_Systick
|
Mcu.Pin16=VP_CRC_VS_CRC
|
||||||
Mcu.Pin17=VP_SYS_VS_DBSignals
|
Mcu.Pin17=VP_SYS_VS_Systick
|
||||||
|
Mcu.Pin18=VP_SYS_VS_DBSignals
|
||||||
Mcu.Pin2=PA0
|
Mcu.Pin2=PA0
|
||||||
Mcu.Pin3=PA1
|
Mcu.Pin3=PA1
|
||||||
Mcu.Pin4=PA2
|
Mcu.Pin4=PA2
|
||||||
@@ -35,7 +39,7 @@ Mcu.Pin6=PA4
|
|||||||
Mcu.Pin7=PA5
|
Mcu.Pin7=PA5
|
||||||
Mcu.Pin8=PA11 [PA9]
|
Mcu.Pin8=PA11 [PA9]
|
||||||
Mcu.Pin9=PA12 [PA10]
|
Mcu.Pin9=PA12 [PA10]
|
||||||
Mcu.PinsNb=18
|
Mcu.PinsNb=19
|
||||||
Mcu.ThirdPartyNb=0
|
Mcu.ThirdPartyNb=0
|
||||||
Mcu.UserConstants=
|
Mcu.UserConstants=
|
||||||
Mcu.UserName=STM32G070CBTx
|
Mcu.UserName=STM32G070CBTx
|
||||||
@@ -118,30 +122,32 @@ ProjectManager.StackSize=0x400
|
|||||||
ProjectManager.TargetToolchain=STM32CubeIDE
|
ProjectManager.TargetToolchain=STM32CubeIDE
|
||||||
ProjectManager.ToolChainLocation=
|
ProjectManager.ToolChainLocation=
|
||||||
ProjectManager.UnderRoot=true
|
ProjectManager.UnderRoot=true
|
||||||
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_I2C2_Init-I2C2-false-HAL-true,4-MX_TIM3_Init-TIM3-false-HAL-true,5-MX_USART1_UART_Init-USART1-false-LL-true,6-MX_USART2_UART_Init-USART2-false-LL-true
|
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-LL-false,2-MX_GPIO_Init-GPIO-false-LL-true,3-MX_I2C2_Init-I2C2-false-LL-true,4-MX_TIM3_Init-TIM3-false-LL-true,5-MX_USART1_UART_Init-USART1-false-LL-true,6-MX_USART2_UART_Init-USART2-false-LL-true,7-MX_CRC_Init-CRC-false-HAL-true
|
||||||
RCC.AHBFreq_Value=16000000
|
RCC.ADCFreq_Value=64000000
|
||||||
RCC.APBFreq_Value=16000000
|
RCC.AHBFreq_Value=64000000
|
||||||
RCC.APBTimFreq_Value=16000000
|
RCC.APBFreq_Value=64000000
|
||||||
RCC.CortexFreq_Value=16000000
|
RCC.APBTimFreq_Value=64000000
|
||||||
|
RCC.CortexFreq_Value=64000000
|
||||||
RCC.EXTERNAL_CLOCK_VALUE=48000
|
RCC.EXTERNAL_CLOCK_VALUE=48000
|
||||||
RCC.FCLKCortexFreq_Value=16000000
|
RCC.FCLKCortexFreq_Value=64000000
|
||||||
RCC.FamilyName=M
|
RCC.FamilyName=M
|
||||||
RCC.HCLKFreq_Value=16000000
|
RCC.HCLKFreq_Value=64000000
|
||||||
RCC.HSE_VALUE=8000000
|
RCC.HSE_VALUE=8000000
|
||||||
RCC.HSI_VALUE=16000000
|
RCC.HSI_VALUE=16000000
|
||||||
RCC.I2C1Freq_Value=16000000
|
RCC.I2C1Freq_Value=64000000
|
||||||
RCC.I2S1Freq_Value=16000000
|
RCC.I2S1Freq_Value=64000000
|
||||||
RCC.IPParameters=AHBFreq_Value,APBFreq_Value,APBTimFreq_Value,CortexFreq_Value,EXTERNAL_CLOCK_VALUE,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI_VALUE,I2C1Freq_Value,I2S1Freq_Value,LSCOPinFreq_Value,LSE_VALUE,LSI_VALUE,MCO1PinFreq_Value,PLLPoutputFreq_Value,PLLRCLKFreq_Value,PWRFreq_Value,SYSCLKFreq_VALUE,USART1Freq_Value,USART2Freq_Value,VCOInputFreq_Value,VCOOutputFreq_Value
|
RCC.IPParameters=ADCFreq_Value,AHBFreq_Value,APBFreq_Value,APBTimFreq_Value,CortexFreq_Value,EXTERNAL_CLOCK_VALUE,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI_VALUE,I2C1Freq_Value,I2S1Freq_Value,LSCOPinFreq_Value,LSE_VALUE,LSI_VALUE,MCO1PinFreq_Value,PLLPoutputFreq_Value,PLLRCLKFreq_Value,PWRFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,USART1Freq_Value,USART2Freq_Value,VCOInputFreq_Value,VCOOutputFreq_Value
|
||||||
RCC.LSCOPinFreq_Value=32000
|
RCC.LSCOPinFreq_Value=32000
|
||||||
RCC.LSE_VALUE=32768
|
RCC.LSE_VALUE=32768
|
||||||
RCC.LSI_VALUE=32000
|
RCC.LSI_VALUE=32000
|
||||||
RCC.MCO1PinFreq_Value=16000000
|
RCC.MCO1PinFreq_Value=64000000
|
||||||
RCC.PLLPoutputFreq_Value=64000000
|
RCC.PLLPoutputFreq_Value=64000000
|
||||||
RCC.PLLRCLKFreq_Value=64000000
|
RCC.PLLRCLKFreq_Value=64000000
|
||||||
RCC.PWRFreq_Value=16000000
|
RCC.PWRFreq_Value=64000000
|
||||||
RCC.SYSCLKFreq_VALUE=16000000
|
RCC.SYSCLKFreq_VALUE=64000000
|
||||||
RCC.USART1Freq_Value=16000000
|
RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK
|
||||||
RCC.USART2Freq_Value=16000000
|
RCC.USART1Freq_Value=64000000
|
||||||
|
RCC.USART2Freq_Value=64000000
|
||||||
RCC.VCOInputFreq_Value=16000000
|
RCC.VCOInputFreq_Value=16000000
|
||||||
RCC.VCOOutputFreq_Value=128000000
|
RCC.VCOOutputFreq_Value=128000000
|
||||||
SH.GPXTI0.0=GPIO_EXTI0
|
SH.GPXTI0.0=GPIO_EXTI0
|
||||||
@@ -159,6 +165,8 @@ USART1.VirtualMode-Asynchronous=VM_ASYNC
|
|||||||
USART2.BaudRate=9600
|
USART2.BaudRate=9600
|
||||||
USART2.IPParameters=VirtualMode-Asynchronous,BaudRate
|
USART2.IPParameters=VirtualMode-Asynchronous,BaudRate
|
||||||
USART2.VirtualMode-Asynchronous=VM_ASYNC
|
USART2.VirtualMode-Asynchronous=VM_ASYNC
|
||||||
|
VP_CRC_VS_CRC.Mode=CRC_Activate
|
||||||
|
VP_CRC_VS_CRC.Signal=CRC_VS_CRC
|
||||||
VP_SYS_VS_DBSignals.Mode=DisableDeadBatterySignals
|
VP_SYS_VS_DBSignals.Mode=DisableDeadBatterySignals
|
||||||
VP_SYS_VS_DBSignals.Signal=SYS_VS_DBSignals
|
VP_SYS_VS_DBSignals.Signal=SYS_VS_DBSignals
|
||||||
VP_SYS_VS_Systick.Mode=SysTick
|
VP_SYS_VS_Systick.Mode=SysTick
|
||||||
|
|||||||
9
memory_map.inc
Normal file
9
memory_map.inc
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
_flash_eeprom_emu_size = 0x1000;
|
||||||
|
_flash_eeprom_emu_address = 0x801f000;
|
||||||
|
_flash_supporting_area_size = 0x4;
|
||||||
|
_flash_supporting_area_address = 0x801effc;
|
||||||
|
_flash_main_prog_size = 0x1cffc;
|
||||||
|
_flash_main_prog_address = 0x8002000;
|
||||||
|
_flash_boot_size = 0x2000;
|
||||||
|
_flash_boot_address = 0x8000000;
|
||||||
9
memory_map_debug.inc
Normal file
9
memory_map_debug.inc
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
_flash_eeprom_emu_size = 0x1000;
|
||||||
|
_flash_eeprom_emu_address = 0x801f000;
|
||||||
|
_flash_supporting_area_size = 0x4;
|
||||||
|
_flash_supporting_area_address = 0x801effc;
|
||||||
|
_flash_main_prog_size = 0x1effc;
|
||||||
|
_flash_main_prog_address = 0x8000000;
|
||||||
|
_flash_boot_size = 0x0;
|
||||||
|
_flash_boot_address = 0x8000000;
|
||||||
Reference in New Issue
Block a user