Добавлен таргет проект для PY32F002A
This commit is contained in:
@@ -38,6 +38,22 @@ extern "C" {
|
||||
#define GPIO_LED_3 GPIO_PIN_5
|
||||
#define GPIO_LED_4 GPIO_PIN_4
|
||||
|
||||
|
||||
#ifdef PY32F002Bx5
|
||||
#define TIM_MB TIM14
|
||||
#define __HAL_DBGMCU_FREEZE_TIM_MB __HAL_DBGMCU_FREEZE_TIM14
|
||||
#define __HAL_RCC_TIM_MB_CLK_ENABLE __HAL_RCC_TIM14_CLK_ENABLE
|
||||
#define TIM_MB_IRQn TIM14_IRQn
|
||||
#define TIM_MB_IRQHandler TIM14_IRQHandler
|
||||
#endif
|
||||
#ifdef PY32F002Ax5
|
||||
#define TIM_MB TIM16
|
||||
#define __HAL_DBGMCU_FREEZE_TIM_MB __HAL_DBGMCU_FREEZE_TIM16
|
||||
#define __HAL_RCC_TIM_MB_CLK_ENABLE __HAL_RCC_TIM16_CLK_ENABLE
|
||||
#define TIM_MB_IRQn TIM16_IRQn
|
||||
#define TIM_MB_IRQHandler TIM16_IRQHandler
|
||||
#endif
|
||||
|
||||
/* Exported variables prototypes ---------------------------------------------*/
|
||||
/* Exported functions prototypes ---------------------------------------------*/
|
||||
void Error_Handler(void);
|
||||
|
||||
222
py_project/Core/Inc/py32f0xx_hal_conf.h
Normal file
222
py_project/Core/Inc/py32f0xx_hal_conf.h
Normal file
@@ -0,0 +1,222 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file py32f0xx_hal_conf.h
|
||||
* @author MCU Application Team
|
||||
* @Version V1.0.0
|
||||
* @Date
|
||||
* @brief HAL configuration file.
|
||||
******************************************************************************
|
||||
**/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __PY32F0xx_HAL_CONF_H
|
||||
#define __PY32F0xx_HAL_CONF_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
||||
/* ########################## Module Selection ############################## */
|
||||
/**
|
||||
* @brief This is the list of modules to be used in the HAL driver
|
||||
*/
|
||||
#define HAL_MODULE_ENABLED
|
||||
#define HAL_RCC_MODULE_ENABLED
|
||||
//#define HAL_ADC_MODULE_ENABLED
|
||||
//#define HAL_CRC_MODULE_ENABLED
|
||||
//#define HAL_COMP_MODULE_ENABLED
|
||||
#define HAL_FLASH_MODULE_ENABLED
|
||||
#define HAL_GPIO_MODULE_ENABLED
|
||||
#define HAL_IWDG_MODULE_ENABLED
|
||||
#define HAL_TIM_MODULE_ENABLED
|
||||
//#define HAL_LPTIM_MODULE_ENABLED
|
||||
#define HAL_PWR_MODULE_ENABLED
|
||||
//#define HAL_I2C_MODULE_ENABLED
|
||||
#define HAL_UART_MODULE_ENABLED
|
||||
#define HAL_USART_MODULE_ENABLED
|
||||
//#define HAL_SPI_MODULE_ENABLED
|
||||
//#define HAL_EXTI_MODULE_ENABLED
|
||||
#define HAL_CORTEX_MODULE_ENABLED
|
||||
|
||||
/* ########################## Oscillator Values adaptation ####################*/
|
||||
|
||||
#if !defined (HSI_VALUE)
|
||||
#define HSI_VALUE ((uint32_t)8000000) /*!< Value of the Internal oscillator in Hz */
|
||||
#endif /* HSI_VALUE */
|
||||
|
||||
/**
|
||||
* @brief Adjust the value of External High Speed oscillator (HXT) used in your application.
|
||||
* This value is used by the RCC HAL module to compute the system frequency
|
||||
*/
|
||||
#if !defined (HSE_VALUE)
|
||||
#define HSE_VALUE ((uint32_t)24000000) /*!< Value of the External oscillator in Hz */
|
||||
#endif /* HSE_VALUE */
|
||||
|
||||
#if !defined (HSE_STARTUP_TIMEOUT)
|
||||
#define HSE_STARTUP_TIMEOUT ((uint32_t)200) /*!< Time out for HXT start up, in ms */
|
||||
#endif /* HSE_STARTUP_TIMEOUT */
|
||||
|
||||
/**
|
||||
* @brief Internal Low Speed Internal oscillator (LIRC) value.
|
||||
*/
|
||||
#if !defined (LSI_VALUE)
|
||||
#define LSI_VALUE 32768U /*!< LIRC Typical Value in Hz */
|
||||
#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
|
||||
The real value may vary depending on the variations
|
||||
in voltage and temperature. */
|
||||
|
||||
/**
|
||||
* @brief Adjust the value of External Low Speed oscillator (LXT) used in your application.
|
||||
* This value is used by the RCC HAL module to compute the system frequency
|
||||
*/
|
||||
#if !defined (LSE_VALUE)
|
||||
#define LSE_VALUE ((uint32_t)32768) /*!< Value of the External oscillator in Hz*/
|
||||
#endif /* LSE_VALUE */
|
||||
|
||||
|
||||
|
||||
#if !defined (LSE_STARTUP_TIMEOUT)
|
||||
#define LSE_STARTUP_TIMEOUT ((uint32_t)5000) /*!< Time out for LXT start up, in ms */
|
||||
#endif /* LSE_STARTUP_TIMEOUT */
|
||||
|
||||
/* Tip: To avoid modifying this file each time you need to use different HSE,
|
||||
=== you can define the HSE value in your toolchain compiler preprocessor. */
|
||||
|
||||
/* ########################### System Configuration ######################### */
|
||||
/**
|
||||
* @brief This is the HAL system configuration section
|
||||
*/
|
||||
#define VDD_VALUE ((uint32_t)3300) /*!< Value of VDD in mv */
|
||||
#define PRIORITY_HIGHEST 0
|
||||
#define PRIORITY_HIGH 1
|
||||
#define PRIORITY_LOW 2
|
||||
#define PRIORITY_LOWEST 3
|
||||
#define TICK_INT_PRIORITY ((uint32_t)PRIORITY_LOWEST) /*!< tick interrupt priority (lowest by default) */
|
||||
#define USE_RTOS 0
|
||||
#define PREFETCH_ENABLE 1
|
||||
|
||||
/* ########################## Assert Selection ############################## */
|
||||
/**
|
||||
* @brief Uncomment the line below to expanse the "assert_param" macro in the
|
||||
* HAL drivers code
|
||||
*/
|
||||
/* #define USE_FULL_ASSERT 1U */
|
||||
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Include module's header file
|
||||
*/
|
||||
|
||||
|
||||
#ifdef HAL_MODULE_ENABLED
|
||||
#include "py32f0xx_hal.h"
|
||||
#endif /* HAL_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_RCC_MODULE_ENABLED
|
||||
#include "py32f0xx_hal_rcc.h"
|
||||
#endif /* HAL_RCC_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_EXTI_MODULE_ENABLED
|
||||
#include "py32f0xx_hal_exti.h"
|
||||
#endif /* HAL_EXTI_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_GPIO_MODULE_ENABLED
|
||||
#include "py32f0xx_hal_gpio.h"
|
||||
#endif /* HAL_GPIO_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_CORTEX_MODULE_ENABLED
|
||||
#include "py32f0xx_hal_cortex.h"
|
||||
#endif /* HAL_CORTEX_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_DMA_MODULE_ENABLED
|
||||
#include "py32f0xx_hal_dma.h"
|
||||
#endif /* HAL_DMA_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_ADC_MODULE_ENABLED
|
||||
#include "py32f0xx_hal_adc.h"
|
||||
#endif /* HAL_ADC_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_CRC_MODULE_ENABLED
|
||||
#include "py32f0xx_hal_crc.h"
|
||||
#endif /* HAL_CRC_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_COMP_MODULE_ENABLED
|
||||
#include "py32f0xx_hal_comp.h"
|
||||
#endif /* HAL_COMP_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_FLASH_MODULE_ENABLED
|
||||
#include "py32f0xx_hal_flash.h"
|
||||
#endif /* HAL_FLASH_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_I2C_MODULE_ENABLED
|
||||
#include "py32f0xx_hal_i2c.h"
|
||||
#endif /* HAL_I2C_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_IWDG_MODULE_ENABLED
|
||||
#include "py32f0xx_hal_iwdg.h"
|
||||
#endif /* HAL_IWDG_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_PWR_MODULE_ENABLED
|
||||
#include "py32f0xx_hal_pwr.h"
|
||||
#endif /* HAL_PWR_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_RTC_MODULE_ENABLED
|
||||
#include "py32f0xx_hal_rtc.h"
|
||||
#endif /* HAL_RTC_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_SPI_MODULE_ENABLED
|
||||
#include "py32f0xx_hal_spi.h"
|
||||
#endif /* HAL_SPI_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_TIM_MODULE_ENABLED
|
||||
#include "py32f0xx_hal_tim.h"
|
||||
#endif /* HAL_TIM_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_LPTIM_MODULE_ENABLED
|
||||
#include "py32f0xx_hal_lptim.h"
|
||||
#endif /* HAL_LPTIM_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_UART_MODULE_ENABLED
|
||||
#include "py32f0xx_hal_uart.h"
|
||||
#endif /* HAL_UART_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_WWDG_MODULE_ENABLED
|
||||
#include "py32f0xx_hal_wwdg.h"
|
||||
#endif /* HAL_WWDG_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_LED_MODULE_ENABLED
|
||||
#include "py32f0xx_hal_led.h"
|
||||
#endif /* HAL_LED_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_USART_MODULE_ENABLED
|
||||
#include "py32f0xx_hal_usart.h"
|
||||
#endif /* HAL_USART_MODULE_ENABLED */
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
#ifdef USE_FULL_ASSERT
|
||||
/**
|
||||
* @brief The assert_param macro is used for function's parameters check.
|
||||
* @param expr: If expr is false, it calls assert_failed function
|
||||
* which reports the name of the source file and the source
|
||||
* line number of the call that failed.
|
||||
* If expr is true, it returns no value.
|
||||
* @retval None
|
||||
*/
|
||||
#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
void assert_failed(uint8_t* file, uint32_t line);
|
||||
#else
|
||||
#define assert_param(expr) ((void)0U)
|
||||
#endif /* USE_FULL_ASSERT */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __PY32F0xx_HAL_CONF_H */
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ extern TIM_HandleTypeDef htim14;
|
||||
/* USER CODE END Private defines */
|
||||
|
||||
void MX_TIM1_Init(void);
|
||||
void MX_TIM14_Init(void);
|
||||
void MX_TIMMB_Init(void);
|
||||
|
||||
/* USER CODE BEGIN Prototypes */
|
||||
|
||||
|
||||
@@ -288,9 +288,9 @@ RS_StatusTypeDef RS_Abort(RS_HandleTypeDef *hRS, RS_AbortTypeDef AbortMode)
|
||||
|
||||
if(hRS->sRS_Timeout) // if timeout setted
|
||||
{
|
||||
TIM14->DIER &= ~(TIM_IT_UPDATE);
|
||||
TIM_MB->DIER &= ~(TIM_IT_UPDATE);
|
||||
/* Disable the Peripheral */
|
||||
TIM14->CR1 &= ~(TIM_CR1_CEN);
|
||||
TIM_MB->CR1 &= ~(TIM_CR1_CEN);
|
||||
}
|
||||
|
||||
if((AbortMode&ABORT_RS) == 0x00)
|
||||
@@ -414,9 +414,9 @@ RS_StatusTypeDef RS_UART_RxCpltCallback(RS_HandleTypeDef *hRS)
|
||||
|
||||
if(hRS->sRS_Timeout) // if timeout setted
|
||||
{
|
||||
TIM14->DIER &= ~(TIM_IT_UPDATE);
|
||||
TIM_MB->DIER &= ~(TIM_IT_UPDATE);
|
||||
/* Disable the Peripheral */
|
||||
TIM14->CR1 &= ~(TIM_CR1_CEN);
|
||||
TIM_MB->CR1 &= ~(TIM_CR1_CEN);
|
||||
}
|
||||
|
||||
// parse received data
|
||||
@@ -447,9 +447,9 @@ RS_StatusTypeDef RS_UART_RxCpltCallback(RS_HandleTypeDef *hRS)
|
||||
|
||||
if(hRS->sRS_Timeout) // if timeout setted
|
||||
{
|
||||
TIM14->DIER &= ~(TIM_IT_UPDATE);
|
||||
TIM_MB->DIER &= ~(TIM_IT_UPDATE);
|
||||
/* Disable the Peripheral */
|
||||
TIM14->CR1 &= ~(TIM_CR1_CEN);
|
||||
TIM_MB->CR1 &= ~(TIM_CR1_CEN);
|
||||
}
|
||||
|
||||
// parse received data
|
||||
@@ -503,9 +503,9 @@ void RS_UART_Handler(RS_HandleTypeDef *hRS)
|
||||
if(hRS->sRS_Timeout) // if timeout setted
|
||||
if((hRS->huart->RxXferCount+1 == hRS->huart->RxXferSize) && RS_Is_RX_Busy(hRS)) // if first byte is received and receive is active
|
||||
{
|
||||
TIM14->DIER |= (TIM_IT_UPDATE);
|
||||
TIM_MB->DIER |= (TIM_IT_UPDATE);
|
||||
/* Disable the Peripheral */
|
||||
TIM14->CR1 |= (TIM_CR1_CEN);
|
||||
TIM_MB->CR1 |= (TIM_CR1_CEN);
|
||||
RS_Set_RX_Active_Flags(hRS);
|
||||
}
|
||||
|
||||
@@ -540,11 +540,11 @@ void RS_UART_Handler(RS_HandleTypeDef *hRS)
|
||||
*/
|
||||
void RS_TIM_Handler(RS_HandleTypeDef *hRS)
|
||||
{
|
||||
TIM14->SR = ~(TIM_IT_UPDATE);
|
||||
TIM_MB->SR = ~(TIM_IT_UPDATE);
|
||||
/* Disable the TIM Update interrupt */
|
||||
TIM14->DIER &= ~(TIM_IT_UPDATE);
|
||||
TIM_MB->DIER &= ~(TIM_IT_UPDATE);
|
||||
/* Disable the Peripheral */
|
||||
TIM14->CR1 &= ~(TIM_CR1_CEN);
|
||||
TIM_MB->CR1 &= ~(TIM_CR1_CEN);
|
||||
|
||||
RS_Abort(hRS, ABORT_RS);
|
||||
|
||||
|
||||
@@ -43,7 +43,6 @@ void MX_GPIO_Init(void)
|
||||
/* GPIO Ports Clock Enable */
|
||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||
|
||||
|
||||
/* Íàñòðîéêà ïèíà PB0 (OneWire) */
|
||||
|
||||
@@ -43,7 +43,7 @@ int main(void)
|
||||
{
|
||||
__HAL_DBGMCU_FREEZE_IWDG();
|
||||
__HAL_DBGMCU_FREEZE_TIM1();
|
||||
__HAL_DBGMCU_FREEZE_TIM14();
|
||||
__HAL_DBGMCU_FREEZE_TIM_MB();
|
||||
/* Reset of all peripherals, Initializes the Systick. */
|
||||
HAL_Init();
|
||||
|
||||
@@ -53,7 +53,7 @@ int main(void)
|
||||
// MX_IWDG_Init();
|
||||
MX_GPIO_Init();
|
||||
MX_TIM1_Init();
|
||||
MX_TIM14_Init();
|
||||
MX_TIMMB_Init();
|
||||
MX_USART1_UART_Init();
|
||||
|
||||
|
||||
@@ -115,16 +115,23 @@ static void APP_SystemClockConfig(void)
|
||||
RCC->ICSCR |= (RCC_HSICALIBRATION_24MHz << RCC_ICSCR_HSI_TRIM_Pos);
|
||||
|
||||
/* Îòêëþ÷åíèå LSI è LSE */
|
||||
#ifdef RCC_LSE_SUPPORT
|
||||
RCC->CSR &= ~RCC_CSR_LSION;
|
||||
RCC->BDCR &= ~RCC_BDCR_LSEON;
|
||||
|
||||
#endif
|
||||
/* Îòêëþ÷åíèå áàéïàñà HSE */
|
||||
RCC->CR &= ~RCC_HSE_BYPASS_DISABLE;
|
||||
RCC->CR &= ~0x00000000U;
|
||||
|
||||
/* Óñòàíîâêà èñòî÷íèêà ñèñòåìíîé òàêòîâîé ÷àñòîòû */
|
||||
RCC->CFGR &= ~RCC_CFGR_SW;
|
||||
#ifdef PY32F002Bx5
|
||||
RCC->CFGR |= RCC_SYSCLKSOURCE_HSISYS;
|
||||
while ((RCC->CFGR & RCC_CFGR_SWS) != RCC_SYSCLKSOURCE_HSISYS);
|
||||
#endif
|
||||
#ifdef PY32F002Ax5
|
||||
RCC->CFGR |= RCC_SYSCLKSOURCE_HSI;
|
||||
while ((RCC->CFGR & RCC_CFGR_SWS) != RCC_SYSCLKSOURCE_HSI);
|
||||
#endif
|
||||
|
||||
/* Óñòàíîâêà äåëèòåëåé */
|
||||
RCC->CFGR &= ~(RCC_CFGR_HPRE | RCC_CFGR_PPRE_1);
|
||||
|
||||
@@ -88,7 +88,7 @@ void USART1_IRQHandler(void)
|
||||
/**
|
||||
* @brief This function handles TIM2 global interrupt.
|
||||
*/
|
||||
void TIM14_IRQHandler(void)
|
||||
void TIM_MB_IRQHandler(void)
|
||||
{
|
||||
/* USER CODE BEGIN TIM2_IRQn 0 */
|
||||
RS_TIM_Handler(&hmodbus1);
|
||||
|
||||
@@ -98,36 +98,38 @@ void MX_TIM1_Init(void)
|
||||
}
|
||||
|
||||
/* TIM2 init function */
|
||||
void MX_TIM14_Init(void)
|
||||
void MX_TIMMB_Init(void)
|
||||
{
|
||||
|
||||
// Включение тактирования TIM1
|
||||
__HAL_RCC_TIM14_CLK_ENABLE();
|
||||
__HAL_RCC_TIM_MB_CLK_ENABLE();
|
||||
|
||||
// Установка предделителя (Prescaler)
|
||||
TIM14->PSC = 24-1;
|
||||
TIM_MB->PSC = 24-1;
|
||||
|
||||
// Установка режима счета вверх
|
||||
TIM14->CR1 &= ~TIM_CR1_DIR;
|
||||
TIM_MB->CR1 &= ~TIM_CR1_DIR;
|
||||
|
||||
// Установка периода (ARR - Auto-reload register) на 50 миллисекунд
|
||||
TIM14->ARR = 50000;
|
||||
TIM_MB->ARR = 50000;
|
||||
|
||||
// Установка делителя частоты (Clock Division)
|
||||
TIM14->CR1 &= ~TIM_CR1_CKD;
|
||||
TIM_MB->CR1 &= ~TIM_CR1_CKD;
|
||||
|
||||
// Отключение режима предзагрузки
|
||||
TIM14->CR1 &= ~TIM_CR1_ARPE;
|
||||
TIM_MB->CR1 &= ~TIM_CR1_ARPE;
|
||||
|
||||
// Выбор внутреннего источника тактирования
|
||||
TIM14->SMCR &= ~TIM_SMCR_SMS;
|
||||
TIM_MB->SMCR &= ~TIM_SMCR_SMS;
|
||||
|
||||
// Настройка триггерного выхода (TRGO)
|
||||
TIM14->CR2 &= ~TIM_CR2_MMS;
|
||||
TIM_MB->CR2 &= ~TIM_CR2_MMS;
|
||||
|
||||
// Отключение режима Master/Slave
|
||||
TIM14->SMCR &= ~TIM_SMCR_MSM;
|
||||
TIM_MB->SMCR &= ~TIM_SMCR_MSM;
|
||||
|
||||
HAL_NVIC_SetPriority(TIM_MB_IRQn, 0, 0);
|
||||
HAL_NVIC_EnableIRQ(TIM_MB_IRQn);
|
||||
// /* USER CODE BEGIN TIM2_Init 0 */
|
||||
|
||||
// /* USER CODE END TIM2_Init 0 */
|
||||
@@ -138,7 +140,7 @@ void MX_TIM14_Init(void)
|
||||
// /* USER CODE BEGIN TIM2_Init 1 */
|
||||
|
||||
// /* USER CODE END TIM2_Init 1 */
|
||||
// htim14.Instance = TIM14;
|
||||
// htim14.Instance = TIM_MB;
|
||||
// htim14.Init.Prescaler = (24) - 1;
|
||||
// htim14.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||
// htim14.Init.Period = 50000;
|
||||
@@ -164,69 +166,6 @@ void MX_TIM14_Init(void)
|
||||
// /* USER CODE END TIM2_Init 2 */
|
||||
|
||||
}
|
||||
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle)
|
||||
{
|
||||
|
||||
if(tim_baseHandle->Instance==TIM1)
|
||||
{
|
||||
/* USER CODE BEGIN TIM1_MspInit 0 */
|
||||
|
||||
/* USER CODE END TIM1_MspInit 0 */
|
||||
/* TIM1 clock enable */
|
||||
__HAL_RCC_TIM1_CLK_ENABLE();
|
||||
/* USER CODE BEGIN TIM1_MspInit 1 */
|
||||
|
||||
/* USER CODE END TIM1_MspInit 1 */
|
||||
}
|
||||
else if(tim_baseHandle->Instance==TIM14)
|
||||
{
|
||||
/* USER CODE BEGIN TIM14_MspInit 0 */
|
||||
|
||||
/* USER CODE END TIM14_MspInit 0 */
|
||||
/* TIM14 clock enable */
|
||||
__HAL_RCC_TIM14_CLK_ENABLE();
|
||||
|
||||
/* TIM14 interrupt Init */
|
||||
HAL_NVIC_SetPriority(TIM14_IRQn, 0, 0);
|
||||
HAL_NVIC_EnableIRQ(TIM14_IRQn);
|
||||
/* USER CODE BEGIN TIM14_MspInit 1 */
|
||||
|
||||
/* USER CODE END TIM14_MspInit 1 */
|
||||
}
|
||||
}
|
||||
|
||||
void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* tim_baseHandle)
|
||||
{
|
||||
|
||||
if(tim_baseHandle->Instance==TIM1)
|
||||
{
|
||||
/* USER CODE BEGIN TIM1_MspDeInit 0 */
|
||||
|
||||
/* USER CODE END TIM1_MspDeInit 0 */
|
||||
/* Peripheral clock disable */
|
||||
__HAL_RCC_TIM1_CLK_DISABLE();
|
||||
|
||||
/* TIM1 interrupt Deinit */
|
||||
HAL_NVIC_DisableIRQ(TIM1_BRK_UP_TRG_COM_IRQn);
|
||||
/* USER CODE BEGIN TIM1_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END TIM1_MspDeInit 1 */
|
||||
}
|
||||
else if(tim_baseHandle->Instance==TIM14)
|
||||
{
|
||||
/* USER CODE BEGIN TIM14_MspDeInit 0 */
|
||||
|
||||
/* USER CODE END TIM14_MspDeInit 0 */
|
||||
/* TIM14 clock disable */
|
||||
__HAL_RCC_TIM14_CLK_DISABLE();
|
||||
|
||||
/* TIM14 interrupt Deinit */
|
||||
HAL_NVIC_DisableIRQ(TIM14_IRQn);
|
||||
/* USER CODE BEGIN TIM14_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END TIM14_MspDeInit 1 */
|
||||
}
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
|
||||
296
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal.h
Normal file
296
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal.h
Normal file
@@ -0,0 +1,296 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file py32f0xx_hal.h
|
||||
* @author MCU Application Team
|
||||
* @brief This file contains all the functions prototypes for the HAL
|
||||
* module driver.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) Puya Semiconductor Co.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __PY32F0xx_HAL_H
|
||||
#define __PY32F0xx_HAL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "py32f0xx_hal_conf.h"
|
||||
|
||||
/** @addtogroup PY32F0xx_HAL_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup HAL
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
||||
/** @defgroup HAL_Exported_Constants HAL Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup HAL_TICK_FREQ Tick Frequency
|
||||
* @{
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
HAL_TICK_FREQ_10HZ = 100U,
|
||||
HAL_TICK_FREQ_100HZ = 10U,
|
||||
HAL_TICK_FREQ_1KHZ = 1U,
|
||||
HAL_TICK_FREQ_DEFAULT = HAL_TICK_FREQ_1KHZ
|
||||
} HAL_TickFreqTypeDef;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
extern uint32_t uwTickPrio;
|
||||
extern uint32_t uwTickFreq;
|
||||
/** @defgroup SYSCFG_Exported_Constants SYSCFG Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup SYSCFG_BootMode Boot Mode
|
||||
* @{
|
||||
*/
|
||||
#define SYSCFG_BOOT_MAINFLASH 0x00000000U /*!< Main Flash memory mapped at 0x0000 0000 */
|
||||
#define SYSCFG_BOOT_SYSTEMFLASH SYSCFG_CFGR1_MEM_MODE_0 /*!< System Flash memory mapped at 0x0000 0000 */
|
||||
#define SYSCFG_BOOT_SRAM (SYSCFG_CFGR1_MEM_MODE_1 | SYSCFG_CFGR1_MEM_MODE_0) /*!< Embedded SRAM mapped at 0x0000 0000 */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/** @defgroup HAL_Exported_Macros HAL Exported Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup DBGMCU_Freeze_Unfreeze Freeze Unfreeze Peripherals in Debug mode
|
||||
* @brief Freeze/Unfreeze Peripherals in Debug mode
|
||||
* Note:
|
||||
* Debug registers DBGMCU_IDCODE and DBGMCU_CR are accessible only in
|
||||
* debug mode (not accessible by the user software in normal mode).
|
||||
* Refer to errata sheet of these devices for more details.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Peripherals on APB1 */
|
||||
|
||||
/* Exported macros -----------------------------------------------------------*/
|
||||
/** @defgroup HAL_Exported_Macros HAL Exported Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup HAL_Freeze_Unfreeze_Peripherals HAL Freeze Unfreeze Peripherals
|
||||
* @brief Freeze/Unfreeze Peripherals in Debug mode
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#if defined(DBGMCU_APB_FZ1_DBG_RTC_STOP)
|
||||
#define __HAL_DBGMCU_FREEZE_RTC() (DBGMCU->APBFZ1 |= (DBGMCU_APB_FZ1_DBG_RTC_STOP))
|
||||
#define __HAL_DBGMCU_UNFREEZE_RTC() (DBGMCU->APBFZ1 &= ~(DBGMCU_APB_FZ1_DBG_RTC_STOP))
|
||||
#endif /* DBGMCU_APB_FZ_DBG_RTC_STOP */
|
||||
|
||||
#if defined(DBGMCU_APB_FZ1_DBG_I2C_SMBUS_TIMEOUT)
|
||||
#define __HAL_DBGMCU_FREEZE_I2C_TIMEOUT() (DBGMCU->APBFZ1 |= (DBGMCU_APB_FZ1_DBG_I2C_SMBUS_TIMEOUT))
|
||||
#define __HAL_DBGMCU_UNFREEZE_I2C_TIMEOUT() (DBGMCU->APBFZ1 &= ~(DBGMCU_APB_FZ1_DBG_I2C_SMBUS_TIMEOUT))
|
||||
#endif /* DBGMCU_APB_FZ_DBG_I2C_SMBUS_TIMEOUT */
|
||||
|
||||
#if defined(DBGMCU_APB_FZ1_DBG_IWDG_STOP)
|
||||
#define __HAL_DBGMCU_FREEZE_IWDG() (DBGMCU->APBFZ1 |= (DBGMCU_APB_FZ1_DBG_IWDG_STOP))
|
||||
#define __HAL_DBGMCU_UNFREEZE_IWDG() (DBGMCU->APBFZ1 &= ~(DBGMCU_APB_FZ1_DBG_IWDG_STOP))
|
||||
#endif /* DBGMCU_APB_FZ_DBG_IWDG_STOP */
|
||||
|
||||
#if defined(DBGMCU_APB_FZ1_DBG_WWDG_STOP)
|
||||
#define __HAL_DBGMCU_FREEZE_WWDG() (DBGMCU->APBFZ1 |= (DBGMCU_APB_FZ1_DBG_WWDG_STOP))
|
||||
#define __HAL_DBGMCU_UNFREEZE_WWDG() (DBGMCU->APBFZ1 &= ~(DBGMCU_APB_FZ1_DBG_WWDG_STOP))
|
||||
#endif /* DBGMCU_APB_FZ_DBG_WWDG_STOP */
|
||||
|
||||
#if defined(DBGMCU_APB_FZ1_DBG_TIM2_STOP)
|
||||
#define __HAL_DBGMCU_FREEZE_TIM2() (DBGMCU->APBFZ1 |= (DBGMCU_APB_FZ1_DBG_TIM2_STOP))
|
||||
#define __HAL_DBGMCU_UNFREEZE_TIM2() (DBGMCU->APBFZ1 &= ~(DBGMCU_APB_FZ1_DBG_TIM2_STOP))
|
||||
#endif /* DBGMCU_APB_FZ_DBG_TIM2_STOP */
|
||||
|
||||
#if defined(DBGMCU_APB_FZ1_DBG_TIM3_STOP)
|
||||
#define __HAL_DBGMCU_FREEZE_TIM3() (DBGMCU->APBFZ1 |= (DBGMCU_APB_FZ1_DBG_TIM3_STOP))
|
||||
#define __HAL_DBGMCU_UNFREEZE_TIM3() (DBGMCU->APBFZ1 &= ~(DBGMCU_APB_FZ1_DBG_TIM3_STOP))
|
||||
#endif /* DBGMCU_APB_FZ_DBG_TIM3_STOP */
|
||||
|
||||
#if defined(DBGMCU_APB_FZ1_DBG_TIM6_STOP)
|
||||
#define __HAL_DBGMCU_FREEZE_TIM6() (DBGMCU->APBFZ1 |= (DBGMCU_APB_FZ1_DBG_TIM6_STOP))
|
||||
#define __HAL_DBGMCU_UNFREEZE_TIM6() (DBGMCU->APBFZ1 &= ~(DBGMCU_APB_FZ1_DBG_TIM6_STOP))
|
||||
#endif /* DBGMCU_APB_FZ_DBG_TIM6_STOP */
|
||||
|
||||
#if defined(DBGMCU_APB_FZ1_DBG_TIM7_STOP)
|
||||
#define __HAL_DBGMCU_FREEZE_TIM7() (DBGMCU->APBFZ1 |= (DBGMCU_APB_FZ1_DBG_TIM7_STOP))
|
||||
#define __HAL_DBGMCU_UNFREEZE_TIM7() (DBGMCU->APBFZ1 &= ~(DBGMCU_APB_FZ1_DBG_TIM7_STOP))
|
||||
#endif /* DBGMCU_APB_FZ_DBG_TIM7_STOP */
|
||||
|
||||
#if defined(DBGMCU_APB_FZ1_DBG_TIM14_STOP)
|
||||
#define __HAL_DBGMCU_FREEZE_TIM14() (DBGMCU->APBFZ1 |= (DBGMCU_APB_FZ1_DBG_TIM14_STOP))
|
||||
#define __HAL_DBGMCU_UNFREEZE_TIM14() (DBGMCU->APBFZ1 &= ~(DBGMCU_APB_FZ1_DBG_TIM14_STOP))
|
||||
#endif /* DBGMCU_APB_FZ_DBG_TIM14_STOP */
|
||||
|
||||
#if defined(DBGMCU_APB_FZ2_DBG_TIM1_STOP)
|
||||
#define __HAL_DBGMCU_FREEZE_TIM1() (DBGMCU->APBFZ2 |= (DBGMCU_APB_FZ2_DBG_TIM1_STOP))
|
||||
#define __HAL_DBGMCU_UNFREEZE_TIM1() (DBGMCU->APBFZ2 &= ~(DBGMCU_APB_FZ2_DBG_TIM1_STOP))
|
||||
#endif /* DBGMCU_APB_FZ_DBG_TIM1_STOP */
|
||||
|
||||
#if defined(DBGMCU_APB_FZ2_DBG_TIM15_STOP)
|
||||
#define __HAL_DBGMCU_FREEZE_TIM15() (DBGMCU->APBFZ2 |= (DBGMCU_APB_FZ2_DBG_TIM15_STOP))
|
||||
#define __HAL_DBGMCU_UNFREEZE_TIM15() (DBGMCU->APBFZ2 &= ~(DBGMCU_APB_FZ2_DBG_TIM15_STOP))
|
||||
#endif /* DBGMCU_APB_FZ2_DBG_TIM15_STOP */
|
||||
|
||||
#if defined(DBGMCU_APB_FZ2_DBG_TIM16_STOP)
|
||||
#define __HAL_DBGMCU_FREEZE_TIM16() (DBGMCU->APBFZ2 |= (DBGMCU_APB_FZ2_DBG_TIM16_STOP))
|
||||
#define __HAL_DBGMCU_UNFREEZE_TIM16() (DBGMCU->APBFZ2 &= ~(DBGMCU_APB_FZ2_DBG_TIM16_STOP))
|
||||
#endif /* DBGMCU_APB_FZ_DBG_TIM16_STOP */
|
||||
|
||||
#if defined(DBGMCU_APB_FZ2_DBG_TIM17_STOP)
|
||||
#define __HAL_DBGMCU_FREEZE_TIM17() (DBGMCU->APBFZ2 |= (DBGMCU_APB_FZ2_DBG_TIM17_STOP))
|
||||
#define __HAL_DBGMCU_UNFREEZE_TIM17() (DBGMCU->APBFZ2 &= ~(DBGMCU_APB_FZ2_DBG_TIM17_STOP))
|
||||
#endif /* DBGMCU_APB_FZ_DBG_TIM17_STOP */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup HAL_Private_Macros HAL Private Macros
|
||||
* @{
|
||||
*/
|
||||
#define IS_TICKFREQ(FREQ) (((FREQ) == HAL_TICK_FREQ_10HZ) || \
|
||||
((FREQ) == HAL_TICK_FREQ_100HZ) || \
|
||||
((FREQ) == HAL_TICK_FREQ_1KHZ))
|
||||
|
||||
|
||||
/** @brief SYSCFG Break Cortex-M0+ Lockup lock.
|
||||
* Enables and locks the connection of Cortex-M0+ LOCKUP (Hardfault) output to TIM1/15/16/17 Break input
|
||||
* @note The selected configuration is locked and can be unlocked only by system reset.
|
||||
*/
|
||||
#define __HAL_SYSCFG_BREAK_LOCKUP_LOCK() SET_BIT(SYSCFG->CFGR2, SYSCFG_CFGR2_LOCKUP_LOCK)
|
||||
#if defined(SYSCFG_CFGR2_PVD_LOCK)
|
||||
/** @brief SYSCFG Break PVD lock.
|
||||
* Enables and locks the PVD connection with Timer1/15/16/17 Break input, as well as the PVDE and PLS[2:0] in the PWR_CR register
|
||||
* @note The selected configuration is locked and can be unlocked only by system reset
|
||||
*/
|
||||
#define __HAL_SYSCFG_BREAK_PVD_LOCK() SET_BIT(SYSCFG->CFGR2, SYSCFG_CFGR2_PVD_LOCK)
|
||||
#endif
|
||||
#if defined(SYSCFG_CFGR2_COMP1_BRK_TIM1)
|
||||
/** @brief SYSCFG COMP1 AS TIMx break.
|
||||
* COMP1 as Timer1Break input
|
||||
* @note The selected configuration is locked and can be unlocked only by system reset
|
||||
*/
|
||||
#define __HAL_SYSCFG_COMP1_BREAK_TIM1() SET_BIT(SYSCFG->CFGR2, SYSCFG_CFGR2_COMP1_BRK_TIM1)
|
||||
#endif
|
||||
#if defined(SYSCFG_CFGR2_COMP2_BRK_TIM1)
|
||||
#define __HAL_SYSCFG_COMP2_BREAK_TIM1() SET_BIT(SYSCFG->CFGR2, SYSCFG_CFGR2_COMP2_BRK_TIM1)
|
||||
#endif
|
||||
#if defined(SYSCFG_CFGR2_COMP1_BRK_TIM16)
|
||||
#define __HAL_SYSCFG_COMP1_BREAK_TIM16() SET_BIT(SYSCFG->CFGR2, SYSCFG_CFGR2_COMP1_BRK_TIM16)
|
||||
#endif
|
||||
#if defined(SYSCFG_CFGR2_COMP2_BRK_TIM16)
|
||||
#define __HAL_SYSCFG_COMP2_BREAK_TIM16() SET_BIT(SYSCFG->CFGR2, SYSCFG_CFGR2_COMP2_BRK_TIM16)
|
||||
#endif
|
||||
#if defined(SYSCFG_CFGR2_COMP1_BRK_TIM17)
|
||||
#define __HAL_SYSCFG_COMP1_BREAK_TIM17() SET_BIT(SYSCFG->CFGR2, SYSCFG_CFGR2_COMP1_BRK_TIM17)
|
||||
#endif
|
||||
#if defined(SYSCFG_CFGR2_COMP2_BRK_TIM17)
|
||||
#define __HAL_SYSCFG_COMP2_BREAK_TIM17() SET_BIT(SYSCFG->CFGR2, SYSCFG_CFGR2_COMP2_BRK_TIM17)
|
||||
#endif
|
||||
|
||||
|
||||
/* Initialization and de-initialization functions ******************************/
|
||||
HAL_StatusTypeDef HAL_Init(void);
|
||||
HAL_StatusTypeDef HAL_DeInit(void);
|
||||
void HAL_MspInit(void);
|
||||
void HAL_MspDeInit(void);
|
||||
HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup HAL_Exported_Functions_Group2
|
||||
* @{
|
||||
*/
|
||||
/* Peripheral Control functions ************************************************/
|
||||
void HAL_IncTick(void);
|
||||
void HAL_Delay(uint32_t Delay);
|
||||
uint32_t HAL_GetTick(void);
|
||||
uint32_t HAL_GetTickPrio(void);
|
||||
HAL_StatusTypeDef HAL_SetTickFreq(uint32_t Freq);
|
||||
uint32_t HAL_GetTickFreq(void);
|
||||
void HAL_SuspendTick(void);
|
||||
void HAL_ResumeTick(void);
|
||||
uint32_t HAL_GetHalVersion(void);
|
||||
uint32_t HAL_GetREVID(void);
|
||||
uint32_t HAL_GetDEVID(void);
|
||||
uint32_t HAL_GetUIDw0(void);
|
||||
uint32_t HAL_GetUIDw1(void);
|
||||
uint32_t HAL_GetUIDw2(void);
|
||||
void HAL_DBGMCU_EnableDBGSleepMode(void);
|
||||
void HAL_DBGMCU_DisableDBGSleepMode(void);
|
||||
void HAL_DBGMCU_EnableDBGStopMode(void);
|
||||
void HAL_DBGMCU_DisableDBGStopMode(void);
|
||||
#if (defined(DMA)||defined(DMA1))
|
||||
void HAL_SYSCFG_DMA_Req(uint32_t Requset);
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/* Private types -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/** @defgroup HAL_Private_Variables HAL Private Variables
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
/** @defgroup HAL_Private_Constants HAL Private Constants
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/* Private macros ------------------------------------------------------------*/
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __PY32F0xx_HAL_H */
|
||||
|
||||
/************************ (C) COPYRIGHT Puya *****END OF FILE****/
|
||||
1107
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_adc.h
Normal file
1107
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_adc.h
Normal file
@@ -0,0 +1,1107 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file py32f0xx_hal_adc.h
|
||||
* @author MCU Application Team
|
||||
* @brief Header file containing functions prototypes of ADC HAL library.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) Puya Semiconductor Co.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __PY32F0xx_HAL_ADC_H
|
||||
#define __PY32F0xx_HAL_ADC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "py32f0xx_hal_def.h"
|
||||
|
||||
/** @addtogroup PY32F0xx_HAL_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup ADC
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/** @defgroup ADC_Exported_Types ADC Exported Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Structure definition of ADC initialization and regular group
|
||||
* @note The setting of these parameters with function HAL_ADC_Init() is conditioned to ADC state.
|
||||
* ADC state can be either:
|
||||
* - For all parameters: ADC disabled (this is the only possible ADC state to modify parameter 'ClockPrescaler')
|
||||
* - For all parameters except 'ClockPrescaler' and 'resolution': ADC enabled without conversion on going on regular group.
|
||||
* If ADC is not in the appropriate state to modify some parameters, these parameters setting is bypassed
|
||||
* without error reporting (as it can be the expected behaviour in case of intended action to update another parameter (which fulfills the ADC state condition) on the fly).
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t ClockPrescaler; /*!< Select ADC clock source (synchronous clock derived from APB clock or asynchronous clock derived from ADC dedicated HSI RC oscillator 14MHz) and clock prescaler.
|
||||
This parameter can be a value of @ref ADC_ClockPrescaler
|
||||
Note: In case of usage of the ADC dedicated HSI RC oscillator, it must be preliminarily enabled at RCC top level.
|
||||
Note: This parameter can be modified only if the ADC is disabled */
|
||||
uint32_t Resolution; /*!< Configures the ADC resolution.
|
||||
This parameter can be a value of @ref ADC_Resolution */
|
||||
uint32_t DataAlign; /*!< Specifies whether the ADC data alignment is left or right.
|
||||
This parameter can be a value of @ref ADC_Data_align */
|
||||
uint32_t ScanConvMode; /*!< Configures the sequencer of regular group.
|
||||
This parameter can be associated to parameter 'DiscontinuousConvMode' to have main sequence subdivided in successive parts.
|
||||
Sequencer is automatically enabled if several channels are set (sequencer cannot be disabled, as it can be the case on other PY32 devices):
|
||||
If only 1 channel is set: Conversion is performed in single mode.
|
||||
If several channels are set: Conversions are performed in sequence mode (ranks defined by each channel number: channel 0 fixed on rank 0, channel 1 fixed on rank1, ...).
|
||||
Scan direction can be set to forward (from channel 0 to channel 12) or backward (from channel 18 to channel 0).
|
||||
This parameter can be a value of @ref ADC_Scan_mode */
|
||||
uint32_t EOCSelection; /*!< Specifies what EOC (End Of Conversion) flag is used for conversion by polling and interruption: end of conversion of each rank or complete sequence.
|
||||
This parameter can be a value of @ref ADC_EOCSelection. */
|
||||
FunctionalState LowPowerAutoWait; /*!< Selects the dynamic low power Auto Delay: new conversion start only when the previous
|
||||
conversion (for regular group) has been treated by user software, using function HAL_ADC_GetValue().
|
||||
This feature automatically adapts the ADC conversions trigs to the speed of the system that reads the data. Moreover, this avoids risk of overrun for low frequency applications.
|
||||
This parameter can be set to ENABLE or DISABLE.
|
||||
Note: Do not use with interruption or DMA (HAL_ADC_Start_IT(), HAL_ADC_Start_DMA()) since they have to clear immediately the EOC flag to free the IRQ vector sequencer.
|
||||
Do use with polling: 1. Start conversion with HAL_ADC_Start(), 2. Later on, when conversion data is needed: use HAL_ADC_PollForConversion() to ensure that conversion is completed
|
||||
and use HAL_ADC_GetValue() to retrieve conversion result and trig another conversion. */
|
||||
FunctionalState ContinuousConvMode; /*!< Specifies whether the conversion is performed in single mode (one conversion) or continuous mode for regular group,
|
||||
after the selected trigger occurred (software start or external trigger).
|
||||
This parameter can be set to ENABLE or DISABLE. */
|
||||
FunctionalState DiscontinuousConvMode; /*!< Specifies whether the conversions sequence of regular group is performed in Complete-sequence/Discontinuous-sequence (main sequence subdivided in successive parts).
|
||||
Discontinuous mode is used only if sequencer is enabled (parameter 'ScanConvMode'). If sequencer is disabled, this parameter is discarded.
|
||||
Discontinuous mode can be enabled only if continuous mode is disabled. If continuous mode is enabled, this parameter setting is discarded.
|
||||
This parameter can be set to ENABLE or DISABLE
|
||||
Note: Number of discontinuous ranks increment is fixed to one-by-one. */
|
||||
uint32_t ExternalTrigConv; /*!< Selects the external event used to trigger the conversion start of regular group.
|
||||
If set to ADC_SOFTWARE_START, external triggers are disabled.
|
||||
This parameter can be a value of @ref ADC_External_trigger_source_Regular */
|
||||
uint32_t ExternalTrigConvEdge; /*!< Selects the external trigger edge of regular group.
|
||||
If trigger is set to ADC_SOFTWARE_START, this parameter is discarded.
|
||||
This parameter can be a value of @ref ADC_External_trigger_edge_Regular */
|
||||
#if (defined(DMA) || defined(DMA1))
|
||||
FunctionalState DMAContinuousRequests; /*!< Specifies whether the DMA requests are performed in one shot mode (DMA transfer stop when number of conversions is reached)
|
||||
or in Continuous mode (DMA transfer unlimited, whatever number of conversions).
|
||||
Note: In continuous mode, DMA must be configured in circular mode. Otherwise an overrun will be triggered when DMA buffer maximum pointer is reached.
|
||||
This parameter can be set to ENABLE or DISABLE. */
|
||||
#endif
|
||||
uint32_t Overrun; /*!< Select the behaviour in case of overrun: data preserved or overwritten
|
||||
This parameter has an effect on regular group only, including in DMA mode.
|
||||
This parameter can be a value of @ref ADC_Overrun */
|
||||
uint32_t SamplingTimeCommon; /*!< Sampling time value to be set for the selected channel.
|
||||
Unit: ADC clock cycles
|
||||
Conversion time is the addition of sampling time and processing time (12.5 ADC clock cycles at ADC resolution 12 bits, 10.5 cycles at 10 bits, 8.5 cycles at 8 bits, 6.5 cycles at 6 bits).
|
||||
Note: On PY32F0 devices, the sampling time setting is common to all channels. On some other PY32 devices, this parameter in channel wise and is located into ADC channel initialization structure.
|
||||
This parameter can be a value of @ref ADC_sampling_times
|
||||
Note: In case of usage of internal measurement channels (VrefInt/TempSensor),
|
||||
sampling time constraints must be respected (sampling time can be adjusted in function of ADC clock frequency and sampling time setting)
|
||||
Refer to device datasheet for timings values, parameters TS_vrefint, TS_temp (values rough order: 5us to 17us). */
|
||||
} ADC_InitTypeDef;
|
||||
|
||||
/**
|
||||
* @brief Structure definition of ADC channel for regular group
|
||||
* @note The setting of these parameters with function HAL_ADC_ConfigChannel() is conditioned to ADC state.
|
||||
* ADC state can be either:
|
||||
* - For all parameters: ADC disabled or enabled without conversion on going on regular group.
|
||||
* If ADC is not in the appropriate state to modify some parameters, these parameters setting is bypassed
|
||||
* without error reporting (as it can be the expected behaviour in case of intended action to update another parameter (which fulfills the ADC state condition) on the fly).
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t Channel; /*!< Specifies the channel to configure into ADC regular group.
|
||||
This parameter can be a value of @ref ADC_channels
|
||||
Note: Depending on devices, some channels may not be available on package pins. Refer to device datasheet for channels availability. */
|
||||
uint32_t Rank; /*!< Add or remove the channel from ADC regular group sequencer.
|
||||
On PY32F0 devices, number of ranks in the sequence is defined by number of channels enabled, rank of each channel is defined by channel number (channel 0 fixed on rank 0, channel 1 fixed on rank1, ...)..
|
||||
Despite the channel rank is fixed, this parameter allow an additional possibility: to remove the selected rank (selected channel) from sequencer.
|
||||
This parameter can be a value of @ref ADC_rank */
|
||||
uint32_t SamplingTime; /*!< Sampling time value to be set for the selected channel.
|
||||
Unit: ADC clock cycles
|
||||
Conversion time is the addition of sampling time and processing time (12.5 ADC clock cycles at ADC resolution 12 bits, 10.5 cycles at 10 bits, 8.5 cycles at 8 bits, 6.5 cycles at 6 bits).
|
||||
This parameter can be a value of @ref ADC_sampling_times
|
||||
Caution: this setting impacts the entire regular group. Therefore, call of HAL_ADC_ConfigChannel() to configure a channel can impact the configuration of other channels previously set.
|
||||
Caution: Obsolete parameter. Use parameter "SamplingTimeCommon" in ADC initialization structure.
|
||||
If parameter "SamplingTimeCommon" is set to a valid sampling time, parameter "SamplingTime" is discarded.
|
||||
Note: In case of usage of internal measurement channels (VrefInt/TempSensor),
|
||||
sampling time constraints must be respected (sampling time can be adjusted in function of ADC clock frequency and sampling time setting)
|
||||
Refer to device datasheet for timings values, parameters TS_vrefint, TS_temp (values rough order: 5us to 17us). */
|
||||
} ADC_ChannelConfTypeDef;
|
||||
|
||||
/**
|
||||
* @brief Structure definition of ADC analog watchdog
|
||||
* @note The setting of these parameters with function HAL_ADC_AnalogWDGConfig() is conditioned to ADC state.
|
||||
* ADC state can be either: ADC disabled or ADC enabled without conversion on going on regular group.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t WatchdogMode; /*!< Configures the ADC analog watchdog mode: single/all/none channels.
|
||||
This parameter can be a value of @ref ADC_analog_watchdog_mode. */
|
||||
uint32_t Channel; /*!< Selects which ADC channel to monitor by analog watchdog.
|
||||
This parameter has an effect only if parameter 'WatchdogMode' is configured on single channel. Only 1 channel can be monitored.
|
||||
This parameter can be a value of @ref ADC_channels. */
|
||||
FunctionalState ITMode; /*!< Specifies whether the analog watchdog is configured in interrupt or polling mode.
|
||||
This parameter can be set to ENABLE or DISABLE */
|
||||
uint32_t HighThreshold; /*!< Configures the ADC analog watchdog High threshold value.
|
||||
Depending of ADC resolution selected (12, 10, 8 or 6 bits), this parameter must be a number between Min_Data = 0x000 and Max_Data = 0xFFF, 0x3FF, 0xFF or 0x3F respectively. */
|
||||
uint32_t LowThreshold; /*!< Configures the ADC analog watchdog High threshold value.
|
||||
Depending of ADC resolution selected (12, 10, 8 or 6 bits), this parameter must be a number between Min_Data = 0x000 and Max_Data = 0xFFF, 0x3FF, 0xFF or 0x3F respectively. */
|
||||
} ADC_AnalogWDGConfTypeDef;
|
||||
|
||||
/**
|
||||
* @brief HAL ADC state machine: ADC states definition (bitfields)
|
||||
* @note ADC state machine is managed by bitfields, state must be compared
|
||||
* with bit by bit.
|
||||
* For example:
|
||||
* " if (HAL_IS_BIT_SET(HAL_ADC_GetState(hadc1), HAL_ADC_STATE_REG_BUSY)) "
|
||||
* " if (HAL_IS_BIT_SET(HAL_ADC_GetState(hadc1), HAL_ADC_STATE_AWD1) ) "
|
||||
*/
|
||||
/* States of ADC global scope */
|
||||
#define HAL_ADC_STATE_RESET (0x00000000U) /*!< ADC not yet initialized or disabled */
|
||||
#define HAL_ADC_STATE_READY (0x00000001U) /*!< ADC peripheral ready for use */
|
||||
#define HAL_ADC_STATE_BUSY_INTERNAL (0x00000002U) /*!< ADC is busy to internal process (initialization, calibration) */
|
||||
#define HAL_ADC_STATE_TIMEOUT (0x00000004U) /*!< TimeOut occurrence */
|
||||
|
||||
/* States of ADC errors */
|
||||
#define HAL_ADC_STATE_ERROR_INTERNAL (0x00000010U) /*!< Internal error occurrence */
|
||||
#define HAL_ADC_STATE_ERROR_CONFIG (0x00000020U) /*!< Configuration error occurrence */
|
||||
#define HAL_ADC_STATE_ERROR_DMA (0x00000040U) /*!< DMA error occurrence */
|
||||
|
||||
/* States of ADC group regular */
|
||||
#define HAL_ADC_STATE_REG_BUSY (0x00000100U) /*!< A conversion on group regular is ongoing or can occur (either by continuous mode,
|
||||
external trigger, low power auto power-on, multimode ADC master control) */
|
||||
#define HAL_ADC_STATE_REG_EOC (0x00000200U) /*!< Conversion data available on group regular */
|
||||
#define HAL_ADC_STATE_REG_OVR (0x00000400U) /*!< Overrun occurrence */
|
||||
#define HAL_ADC_STATE_REG_EOSMP (0x00000800U) /*!< Not available on PY32F0 device: End Of Sampling flag raised */
|
||||
|
||||
/* States of ADC group injected */
|
||||
#define HAL_ADC_STATE_INJ_BUSY (0x00001000U) /*!< Not available on PY32F0 device: A conversion on group injected is ongoing or can occur (either by auto-injection mode,
|
||||
external trigger, low power auto power-on, multimode ADC master control) */
|
||||
#define HAL_ADC_STATE_INJ_EOC (0x00002000U) /*!< Not available on PY32F0 device: Conversion data available on group injected */
|
||||
#define HAL_ADC_STATE_INJ_JQOVF (0x00004000U) /*!< Not available on PY32F0 device: Not available on PY32F0 device: Injected queue overflow occurrence */
|
||||
|
||||
/* States of ADC analog watchdogs */
|
||||
#define HAL_ADC_STATE_AWD1 (0x00010000U) /*!< Out-of-window occurrence of analog watchdog 1 */
|
||||
#define HAL_ADC_STATE_AWD2 (0x00020000U) /*!< Not available on PY32F0 device: Out-of-window occurrence of analog watchdog 2 */
|
||||
#define HAL_ADC_STATE_AWD3 (0x00040000U) /*!< Not available on PY32F0 device: Out-of-window occurrence of analog watchdog 3 */
|
||||
|
||||
/* States of ADC multi-mode */
|
||||
#define HAL_ADC_STATE_MULTIMODE_SLAVE (0x00100000U) /*!< Not available on PY32F0 device: ADC in multimode slave state, controlled by another ADC master ( */
|
||||
|
||||
/* ADC Temperature Scale Value */
|
||||
#define HAL_ADC_TSCAL1 (*(uint32_t *)(0x1fff0f14)) /*!< Temperature Scale1 */
|
||||
#define HAL_ADC_TSCAL2 (*(uint32_t *)(0x1fff0f18)) /*!< Temperature Scale2 */
|
||||
|
||||
/**
|
||||
* @brief ADC handle Structure definition
|
||||
*/
|
||||
typedef struct __ADC_HandleTypeDef
|
||||
{
|
||||
ADC_TypeDef *Instance; /*!< Register base address */
|
||||
|
||||
ADC_InitTypeDef Init; /*!< ADC required parameters */
|
||||
#if (defined(DMA) || defined(DMA1))
|
||||
DMA_HandleTypeDef *DMA_Handle; /*!< Pointer DMA Handler */
|
||||
#endif
|
||||
|
||||
HAL_LockTypeDef Lock; /*!< ADC locking object */
|
||||
|
||||
__IO uint32_t State; /*!< ADC communication state (bitmap of ADC states) */
|
||||
|
||||
__IO uint32_t ErrorCode; /*!< ADC Error code */
|
||||
|
||||
|
||||
#if (USE_HAL_ADC_REGISTER_CALLBACKS == 1)
|
||||
void (* ConvCpltCallback)(struct __ADC_HandleTypeDef *hadc); /*!< ADC conversion complete callback */
|
||||
void (* ConvHalfCpltCallback)(struct __ADC_HandleTypeDef *hadc); /*!< ADC conversion DMA half-transfer callback */
|
||||
void (* LevelOutOfWindowCallback)(struct __ADC_HandleTypeDef *hadc); /*!< ADC analog watchdog 1 callback */
|
||||
void (* ErrorCallback)(struct __ADC_HandleTypeDef *hadc); /*!< ADC error callback */
|
||||
void (* MspInitCallback)(struct __ADC_HandleTypeDef *hadc); /*!< ADC Msp Init callback */
|
||||
void (* MspDeInitCallback)(struct __ADC_HandleTypeDef *hadc); /*!< ADC Msp DeInit callback */
|
||||
#endif /* USE_HAL_ADC_REGISTER_CALLBACKS */
|
||||
} ADC_HandleTypeDef;
|
||||
|
||||
#if (USE_HAL_ADC_REGISTER_CALLBACKS == 1)
|
||||
/**
|
||||
* @brief HAL ADC Callback ID enumeration definition
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
HAL_ADC_CONVERSION_COMPLETE_CB_ID = 0x00U, /*!< ADC conversion complete callback ID */
|
||||
HAL_ADC_CONVERSION_HALF_CB_ID = 0x01U, /*!< ADC conversion DMA half-transfer callback ID */
|
||||
HAL_ADC_LEVEL_OUT_OF_WINDOW_1_CB_ID = 0x02U, /*!< ADC analog watchdog 1 callback ID */
|
||||
HAL_ADC_ERROR_CB_ID = 0x03U, /*!< ADC error callback ID */
|
||||
HAL_ADC_INJ_CONVERSION_COMPLETE_CB_ID = 0x04U, /*!< ADC group injected conversion complete callback ID */
|
||||
HAL_ADC_MSPINIT_CB_ID = 0x09U, /*!< ADC Msp Init callback ID */
|
||||
HAL_ADC_MSPDEINIT_CB_ID = 0x0AU /*!< ADC Msp DeInit callback ID */
|
||||
} HAL_ADC_CallbackIDTypeDef;
|
||||
|
||||
/**
|
||||
* @brief HAL ADC Callback pointer definition
|
||||
*/
|
||||
typedef void (*pADC_CallbackTypeDef)(ADC_HandleTypeDef *hadc); /*!< pointer to a ADC callback function */
|
||||
|
||||
#endif /* USE_HAL_ADC_REGISTER_CALLBACKS */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
||||
/** @defgroup ADC_Exported_Constants ADC Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_Error_Code ADC Error Code
|
||||
* @{
|
||||
*/
|
||||
#define HAL_ADC_ERROR_NONE (0x00U) /*!< No error */
|
||||
#define HAL_ADC_ERROR_INTERNAL (0x01U) /*!< ADC IP internal error: if problem of clocking,
|
||||
enable/disable, erroneous state */
|
||||
#define HAL_ADC_ERROR_OVR (0x02U) /*!< Overrun error */
|
||||
#if (defined(DMA) || defined(DMA1))
|
||||
#define HAL_ADC_ERROR_DMA (0x04U) /*!< DMA transfer error */
|
||||
#endif
|
||||
|
||||
#if (USE_HAL_ADC_REGISTER_CALLBACKS == 1)
|
||||
#define HAL_ADC_ERROR_INVALID_CALLBACK (0x10U) /*!< Invalid Callback error */
|
||||
#endif /* USE_HAL_ADC_REGISTER_CALLBACKS */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_ClockPrescaler ADC ClockPrescaler
|
||||
* @{
|
||||
*/
|
||||
#define ADC_CLOCK_SYNC_PCLK_DIV1 (0x00000000U) /*!< ADC synchronous clock derived from APB clock divided by a prescaler of 1 */
|
||||
#define ADC_CLOCK_SYNC_PCLK_DIV2 ((uint32_t)ADC_CFGR2_CKMODE_0) /*!< ADC synchronous clock derived from APB clock divided by a prescaler of 2 */
|
||||
#define ADC_CLOCK_SYNC_PCLK_DIV4 ((uint32_t)ADC_CFGR2_CKMODE_1) /*!< ADC synchronous clock derived from APB clock divided by a prescaler of 4 */
|
||||
#define ADC_CLOCK_SYNC_PCLK_DIV8 ((uint32_t)(ADC_CFGR2_CKMODE_0 | ADC_CFGR2_CKMODE_1)) /*!< ADC synchronous clock derived from APB clock divided by a prescaler of 8 */
|
||||
#define ADC_CLOCK_SYNC_PCLK_DIV16 ((uint32_t)ADC_CFGR2_CKMODE_2) /*!< ADC synchronous clock derived from APB clock divided by a prescaler of 16 */
|
||||
#define ADC_CLOCK_SYNC_PCLK_DIV32 ((uint32_t)(ADC_CFGR2_CKMODE_0 | ADC_CFGR2_CKMODE_2)) /*!< ADC synchronous clock derived from APB clock divided by a prescaler of 32 */
|
||||
#define ADC_CLOCK_SYNC_PCLK_DIV64 ((uint32_t)(ADC_CFGR2_CKMODE_1 | ADC_CFGR2_CKMODE_2)) /*!< ADC synchronous clock derived from APB clock divided by a prescaler of 64 */
|
||||
#define ADC_CLOCK_ASYNC_HSI_DIV1 ((uint32_t)ADC_CFGR2_CKMODE_3) /*!< ADC asynchronous clock derived from ADC dedicated HSI */
|
||||
#define ADC_CLOCK_ASYNC_HSI_DIV2 ((uint32_t)(ADC_CFGR2_CKMODE_0 | ADC_CFGR2_CKMODE_3)) /*!< ADC asynchronous clock derived from HSI clock divided by a prescaler of 2 */
|
||||
#define ADC_CLOCK_ASYNC_HSI_DIV4 ((uint32_t)(ADC_CFGR2_CKMODE_1 | ADC_CFGR2_CKMODE_3)) /*!< ADC asynchronous clock derived from HSI clock divided by a prescaler of 4 */
|
||||
#define ADC_CLOCK_ASYNC_HSI_DIV8 ((uint32_t)(ADC_CFGR2_CKMODE_0 | ADC_CFGR2_CKMODE_1 | ADC_CFGR2_CKMODE_3)) /*!< ADC asynchronous clock derived from HSI clock divided by a prescaler of 8 */
|
||||
#define ADC_CLOCK_ASYNC_HSI_DIV16 ((uint32_t)(ADC_CFGR2_CKMODE_2 | ADC_CFGR2_CKMODE_3)) /*!< ADC asynchronous clock derived from HSI clock divided by a prescaler of 16 */
|
||||
#define ADC_CLOCK_ASYNC_HSI_DIV32 ((uint32_t)(ADC_CFGR2_CKMODE_0 | ADC_CFGR2_CKMODE_2 | ADC_CFGR2_CKMODE_3)) /*!< ADC asynchronous clock derived from HSI clock divided by a prescaler of 32 */
|
||||
#define ADC_CLOCK_ASYNC_HSI_DIV64 ((uint32_t)(ADC_CFGR2_CKMODE_1 | ADC_CFGR2_CKMODE_2 | ADC_CFGR2_CKMODE_3)) /*!< ADC asynchronous clock derived from HSI clock divided by a prescaler of 64 */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_Resolution ADC Resolution
|
||||
* @{
|
||||
*/
|
||||
#define ADC_RESOLUTION_12B (0x00000000U) /*!< ADC 12-bit resolution */
|
||||
#define ADC_RESOLUTION_10B ((uint32_t)ADC_CFGR1_RESSEL_0) /*!< ADC 10-bit resolution */
|
||||
#define ADC_RESOLUTION_8B ((uint32_t)ADC_CFGR1_RESSEL_1) /*!< ADC 8-bit resolution */
|
||||
#define ADC_RESOLUTION_6B ((uint32_t)ADC_CFGR1_RESSEL) /*!< ADC 6-bit resolution */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_Data_align ADC Data_align
|
||||
* @{
|
||||
*/
|
||||
#define ADC_DATAALIGN_RIGHT (0x00000000U)
|
||||
#define ADC_DATAALIGN_LEFT ((uint32_t)ADC_CFGR1_ALIGN)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_Scan_mode ADC Scan mode
|
||||
* @{
|
||||
*/
|
||||
/* Note: Scan mode values must be compatible with other PY32 devices having */
|
||||
/* a configurable sequencer. */
|
||||
/* Scan direction setting values are defined by taking in account */
|
||||
/* already defined values for other PY32 devices: */
|
||||
/* ADC_SCAN_DISABLE (0x00000000U) */
|
||||
/* ADC_SCAN_ENABLE (0x00000001U) */
|
||||
/* Scan direction forward is considered as default setting equivalent */
|
||||
/* to scan enable. */
|
||||
/* Scan direction backward is considered as additional setting. */
|
||||
/* In case of migration from another PY32 device, the user will be */
|
||||
/* warned of change of setting choices with assert check. */
|
||||
#define ADC_SCAN_DIRECTION_FORWARD (0x00000001U) /*!< Scan direction forward: from channel 0 to channel 12 */
|
||||
#define ADC_SCAN_DIRECTION_BACKWARD (0x00000002U) /*!< Scan direction backward: from channel 12 to channel 0 */
|
||||
|
||||
#define ADC_SCAN_ENABLE ADC_SCAN_DIRECTION_FORWARD /* For compatibility with other PY32 devices */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_External_trigger_edge_Regular ADC External trigger edge Regular
|
||||
* @{
|
||||
*/
|
||||
#define ADC_EXTERNALTRIGCONVEDGE_NONE (0x00000000U)
|
||||
#define ADC_EXTERNALTRIGCONVEDGE_RISING ((uint32_t)ADC_CFGR1_EXTEN_0)
|
||||
#define ADC_EXTERNALTRIGCONVEDGE_FALLING ((uint32_t)ADC_CFGR1_EXTEN_1)
|
||||
#define ADC_EXTERNALTRIGCONVEDGE_RISINGFALLING ((uint32_t)ADC_CFGR1_EXTEN)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_EOCSelection ADC EOCSelection
|
||||
* @{
|
||||
*/
|
||||
#define ADC_EOC_SINGLE_CONV ((uint32_t) ADC_ISR_EOC)
|
||||
#define ADC_EOC_SEQ_CONV ((uint32_t) ADC_ISR_EOSEQ)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_Overrun ADC Overrun
|
||||
* @{
|
||||
*/
|
||||
#define ADC_OVR_DATA_OVERWRITTEN (0x00000000U)
|
||||
#define ADC_OVR_DATA_PRESERVED (0x00000001U)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_rank ADC rank
|
||||
* @{
|
||||
*/
|
||||
#define ADC_RANK_CHANNEL_NUMBER (0x00001000U) /*!< Enable the rank of the selected channels. Number of ranks in the sequence is defined by number of channels enabled, rank of each channel is defined by channel number (channel 0 fixed on rank 0, channel 1 fixed on rank1, ...) */
|
||||
#define ADC_RANK_NONE (0x00001001U) /*!< Disable the selected rank (selected channel) from sequencer */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_sampling_times ADC sampling times
|
||||
* @{
|
||||
*/
|
||||
#define ADC_SAMPLETIME_3CYCLES_5 (0x00000000U) /*!< Sampling time 3.5 ADC clock cycles */
|
||||
#define ADC_SAMPLETIME_5CYCLES_5 ((uint32_t) ADC_SMPR_SMP_0) /*!< Sampling time 5.5 ADC clock cycles */
|
||||
#define ADC_SAMPLETIME_7CYCLES_5 ((uint32_t) ADC_SMPR_SMP_1) /*!< Sampling time 7.5 ADC clock cycles */
|
||||
#define ADC_SAMPLETIME_13CYCLES_5 ((uint32_t) (ADC_SMPR_SMP_1 | ADC_SMPR_SMP_0)) /*!< Sampling time 13.5 ADC clock cycles */
|
||||
#define ADC_SAMPLETIME_28CYCLES_5 ((uint32_t) ADC_SMPR_SMP_2) /*!< Sampling time 28.5 ADC clock cycles */
|
||||
#define ADC_SAMPLETIME_41CYCLES_5 ((uint32_t) (ADC_SMPR_SMP_2 | ADC_SMPR_SMP_0)) /*!< Sampling time 41.5 ADC clock cycles */
|
||||
#define ADC_SAMPLETIME_71CYCLES_5 ((uint32_t)(ADC_SMPR_SMP_2 | ADC_SMPR_SMP_1)) /*!< Sampling time 71.5 ADC clock cycles */
|
||||
#define ADC_SAMPLETIME_239CYCLES_5 ((uint32_t) ADC_SMPR_SMP) /*!< Sampling time 239.5 ADC clock cycles */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_analog_watchdog_mode ADC analog watchdog mode
|
||||
* @{
|
||||
*/
|
||||
#define ADC_ANALOGWATCHDOG_NONE ( 0x00000000U)
|
||||
#define ADC_ANALOGWATCHDOG_SINGLE_REG ((uint32_t)(ADC_CFGR1_AWDSGL | ADC_CFGR1_AWDEN))
|
||||
#define ADC_ANALOGWATCHDOG_ALL_REG ((uint32_t) ADC_CFGR1_AWDEN)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_Event_type ADC Event type
|
||||
* @{
|
||||
*/
|
||||
#define ADC_AWD_EVENT ((uint32_t)ADC_FLAG_AWD) /*!< ADC Analog watchdog 1 event */
|
||||
#define ADC_OVR_EVENT ((uint32_t)ADC_FLAG_OVR) /*!< ADC overrun event */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_interrupts_definition ADC interrupts definition
|
||||
* @{
|
||||
*/
|
||||
#define ADC_IT_AWD ADC_IER_AWDIE /*!< ADC Analog watchdog interrupt source */
|
||||
#define ADC_IT_OVR ADC_IER_OVRIE /*!< ADC overrun interrupt source */
|
||||
#define ADC_IT_EOS ADC_IER_EOSEQIE /*!< ADC End of Regular sequence of Conversions interrupt source */
|
||||
#define ADC_IT_EOC ADC_IER_EOCIE /*!< ADC End of Regular Conversion interrupt source */
|
||||
#define ADC_IT_EOSMP ADC_IER_EOSMPIE /*!< ADC End of Sampling interrupt source */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_flags_definition ADC flags definition
|
||||
* @{
|
||||
*/
|
||||
#define ADC_FLAG_AWD ADC_ISR_AWD /*!< ADC Analog watchdog flag */
|
||||
#define ADC_FLAG_OVR ADC_ISR_OVR /*!< ADC overrun flag */
|
||||
#define ADC_FLAG_EOS ADC_ISR_EOSEQ /*!< ADC End of Regular sequence of Conversions flag */
|
||||
#define ADC_FLAG_EOC ADC_ISR_EOC /*!< ADC End of Regular Conversion flag */
|
||||
#define ADC_FLAG_EOSMP ADC_ISR_EOSMP /*!< ADC End of Sampling flag */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
|
||||
/** @addtogroup ADC_Private_Constants ADC Private Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_Internal_HAL_driver_Ext_trig_src_Regular ADC Internal HAL driver Ext trig src Regular
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* List of external triggers of regular group for ADC1: */
|
||||
/* (used internally by HAL driver. To not use into HAL structure parameters) */
|
||||
#define ADC1_2_EXTERNALTRIG_T1_TRGO (0x00000000U)
|
||||
#define ADC1_2_EXTERNALTRIG_T1_CC4 ((uint32_t)ADC_CFGR1_EXTSEL_0)
|
||||
#define ADC1_2_EXTERNALTRIG_T3_TRGO ((uint32_t)(ADC_CFGR1_EXTSEL_1 | ADC_CFGR1_EXTSEL_0))
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Combination of all post-conversion flags bits: EOC/EOS, OVR, AWD */
|
||||
#define ADC_FLAG_POSTCONV_ALL (ADC_FLAG_AWD | ADC_FLAG_OVR | ADC_FLAG_EOS | ADC_FLAG_EOC)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_Exported_Constants ADC Exported Constants
|
||||
* @{
|
||||
*/
|
||||
#define ADC_CCR_ALL (ADC_CCR_TSEN | ADC_CCR_VREFEN)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_channels ADC channels
|
||||
* @{
|
||||
*/
|
||||
/* Note: Depending on devices, some channels may not be available on package */
|
||||
/* pins. Refer to device datasheet for channels availability. */
|
||||
/* Note: Channels are used by bitfields for setting of channel selection */
|
||||
/* (register ADC_CHSELR) and used by number for setting of analog */
|
||||
/* watchdog channel (bits AWDCH in register ADC_CFGR1). */
|
||||
/* Channels are defined with decimal numbers and converted them to */
|
||||
/* bitfields when needed. */
|
||||
#define ADC_CHANNEL_0 (0x00000000U)
|
||||
#define ADC_CHANNEL_1 (0x00000001U)
|
||||
#define ADC_CHANNEL_2 (0x00000002U)
|
||||
#define ADC_CHANNEL_3 (0x00000003U)
|
||||
#define ADC_CHANNEL_4 (0x00000004U)
|
||||
#define ADC_CHANNEL_5 (0x00000005U)
|
||||
#define ADC_CHANNEL_6 (0x00000006U)
|
||||
#define ADC_CHANNEL_7 (0x00000007U)
|
||||
#define ADC_CHANNEL_8 (0x00000008U)
|
||||
#define ADC_CHANNEL_9 (0x00000009U)
|
||||
#define ADC_CHANNEL_11 (0x0000000BU)
|
||||
#define ADC_CHANNEL_12 (0x0000000CU)
|
||||
|
||||
#define ADC_CHANNEL_TEMPSENSOR ADC_CHANNEL_11
|
||||
#define ADC_CHANNEL_VREFINT ADC_CHANNEL_12
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_External_trigger_source_Regular ADC External trigger source Regular
|
||||
* @{
|
||||
*/
|
||||
/* List of external triggers with generic trigger name, sorted by trigger */
|
||||
/* name: */
|
||||
/* External triggers of regular group for ADC1 */
|
||||
#define ADC_EXTERNALTRIGCONV_T1_TRGO ADC1_2_EXTERNALTRIG_T1_TRGO
|
||||
#define ADC_EXTERNALTRIGCONV_T1_CC4 ADC1_2_EXTERNALTRIG_T1_CC4
|
||||
#define ADC_EXTERNALTRIGCONV_T3_TRGO ADC1_2_EXTERNALTRIG_T3_TRGO
|
||||
#define ADC_SOFTWARE_START (ADC_CFGR1_EXTSEL + 1U)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
|
||||
/** @defgroup ADC_Exported_Macros ADC Exported Macros
|
||||
* @{
|
||||
*/
|
||||
/* Macro for internal HAL driver usage, and possibly can be used into code of */
|
||||
/* final user. */
|
||||
|
||||
/**
|
||||
* @brief Enable the ADC peripheral
|
||||
* @param __HANDLE__ ADC handle
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_ADC_ENABLE(__HANDLE__) \
|
||||
((__HANDLE__)->Instance->CR |= ADC_CR_ADEN)
|
||||
|
||||
/**
|
||||
* @brief Disable the ADC peripheral
|
||||
* @param __HANDLE__ ADC handle
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_ADC_DISABLE(__HANDLE__) \
|
||||
do{ \
|
||||
(__HANDLE__)->Instance->CR &= ~ADC_CR_ADEN; \
|
||||
__HAL_ADC_CLEAR_FLAG((__HANDLE__), (ADC_FLAG_EOSMP/* | ADC_FLAG_RDY*/)); \
|
||||
} while(0)
|
||||
|
||||
/**
|
||||
* @brief Enable the ADC end of conversion interrupt.
|
||||
* @param __HANDLE__ ADC handle
|
||||
* @param __INTERRUPT__ ADC Interrupt
|
||||
* This parameter can be any combination of the following values:
|
||||
* @arg ADC_IT_EOC: ADC End of Regular Conversion interrupt source
|
||||
* @arg ADC_IT_EOS: ADC End of Regular sequence of Conversions interrupt source
|
||||
* @arg ADC_IT_AWD: ADC Analog watchdog interrupt source
|
||||
* @arg ADC_IT_OVR: ADC overrun interrupt source
|
||||
* @arg ADC_IT_EOSMP: ADC End of Sampling interrupt source
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_ADC_ENABLE_IT(__HANDLE__, __INTERRUPT__) \
|
||||
(((__HANDLE__)->Instance->IER) |= (__INTERRUPT__))
|
||||
|
||||
/**
|
||||
* @brief Disable the ADC end of conversion interrupt.
|
||||
* @param __HANDLE__ ADC handle
|
||||
* @param __INTERRUPT__ ADC Interrupt
|
||||
* This parameter can be any combination of the following values:
|
||||
* @arg ADC_IT_EOC: ADC End of Regular Conversion interrupt source
|
||||
* @arg ADC_IT_EOS: ADC End of Regular sequence of Conversions interrupt source
|
||||
* @arg ADC_IT_AWD: ADC Analog watchdog interrupt source
|
||||
* @arg ADC_IT_OVR: ADC overrun interrupt source
|
||||
* @arg ADC_IT_EOSMP: ADC End of Sampling interrupt source
|
||||
* @arg ADC_IT_RDY: ADC Ready interrupt source
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_ADC_DISABLE_IT(__HANDLE__, __INTERRUPT__) \
|
||||
(((__HANDLE__)->Instance->IER) &= ~(__INTERRUPT__))
|
||||
|
||||
/** @brief Checks if the specified ADC interrupt source is enabled or disabled.
|
||||
* @param __HANDLE__ ADC handle
|
||||
* @param __INTERRUPT__ ADC interrupt source to check
|
||||
* This parameter can be any combination of the following values:
|
||||
* @arg ADC_IT_EOC: ADC End of Regular Conversion interrupt source
|
||||
* @arg ADC_IT_EOS: ADC End of Regular sequence of Conversions interrupt source
|
||||
* @arg ADC_IT_AWD: ADC Analog watchdog interrupt source
|
||||
* @arg ADC_IT_OVR: ADC overrun interrupt source
|
||||
* @arg ADC_IT_EOSMP: ADC End of Sampling interrupt source
|
||||
* @arg ADC_IT_RDY: ADC Ready interrupt source
|
||||
* @retval State ofinterruption (SET or RESET)
|
||||
*/
|
||||
#define __HAL_ADC_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) \
|
||||
(((__HANDLE__)->Instance->IER & (__INTERRUPT__)) == (__INTERRUPT__))
|
||||
|
||||
/**
|
||||
* @brief Get the selected ADC's flag status.
|
||||
* @param __HANDLE__ ADC handle
|
||||
* @param __FLAG__ ADC flag
|
||||
* This parameter can be any combination of the following values:
|
||||
* @arg ADC_FLAG_EOC: ADC End of Regular conversion flag
|
||||
* @arg ADC_FLAG_EOS: ADC End of Regular sequence of Conversions flag
|
||||
* @arg ADC_FLAG_AWD: ADC Analog watchdog flag
|
||||
* @arg ADC_FLAG_OVR: ADC overrun flag
|
||||
* @arg ADC_FLAG_EOSMP: ADC End of Sampling flag
|
||||
* @arg ADC_FLAG_RDY: ADC Ready flag
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_ADC_GET_FLAG(__HANDLE__, __FLAG__) \
|
||||
((((__HANDLE__)->Instance->ISR) & (__FLAG__)) == (__FLAG__))
|
||||
|
||||
/**
|
||||
* @brief Clear the ADC's pending flags
|
||||
* @param __HANDLE__ ADC handle
|
||||
* @param __FLAG__ ADC flag
|
||||
* This parameter can be any combination of the following values:
|
||||
* @arg ADC_FLAG_EOC: ADC End of Regular conversion flag
|
||||
* @arg ADC_FLAG_EOS: ADC End of Regular sequence of Conversions flag
|
||||
* @arg ADC_FLAG_AWD: ADC Analog watchdog flag
|
||||
* @arg ADC_FLAG_OVR: ADC overrun flag
|
||||
* @arg ADC_FLAG_EOSMP: ADC End of Sampling flag
|
||||
* @arg ADC_FLAG_RDY: ADC Ready flag
|
||||
* @retval None
|
||||
*/
|
||||
/* Note: bit cleared bit by writing 1 (writing 0 has no effect on any bit of register ISR) */
|
||||
#define __HAL_ADC_CLEAR_FLAG(__HANDLE__, __FLAG__) \
|
||||
(((__HANDLE__)->Instance->ISR) = (__FLAG__))
|
||||
|
||||
/** @brief Reset ADC handle state
|
||||
* @param __HANDLE__ ADC handle
|
||||
* @retval None
|
||||
*/
|
||||
#if (USE_HAL_ADC_REGISTER_CALLBACKS == 1)
|
||||
#define __HAL_ADC_RESET_HANDLE_STATE(__HANDLE__) \
|
||||
do{ \
|
||||
(__HANDLE__)->State = HAL_ADC_STATE_RESET; \
|
||||
(__HANDLE__)->MspInitCallback = NULL; \
|
||||
(__HANDLE__)->MspDeInitCallback = NULL; \
|
||||
} while(0)
|
||||
#else
|
||||
#define __HAL_ADC_RESET_HANDLE_STATE(__HANDLE__) \
|
||||
((__HANDLE__)->State = HAL_ADC_STATE_RESET)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
|
||||
/** @defgroup ADC_Private_Macros ADC Private Macros
|
||||
* @{
|
||||
*/
|
||||
/* Macro reserved for internal HAL driver usage, not intended to be used in */
|
||||
/* code of final user. */
|
||||
|
||||
|
||||
/**
|
||||
* @brief Verification of hardware constraints before ADC can be enabled
|
||||
* @param __HANDLE__ ADC handle
|
||||
* @retval SET (ADC can be enabled) or RESET (ADC cannot be enabled)
|
||||
*/
|
||||
#define ADC_ENABLING_CONDITIONS(__HANDLE__) \
|
||||
(( ( ((__HANDLE__)->Instance->CR) & \
|
||||
(ADC_CR_ADCAL | ADC_CR_ADSTP | ADC_CR_ADSTART | ADC_CR_ADEN) \
|
||||
) == RESET \
|
||||
) ? SET : RESET)
|
||||
|
||||
/**
|
||||
* @brief Verification of hardware constraints before ADC can be disabled
|
||||
* @param __HANDLE__ ADC handle
|
||||
* @retval SET (ADC can be disabled) or RESET (ADC cannot be disabled)
|
||||
*/
|
||||
#define ADC_DISABLING_CONDITIONS(__HANDLE__) \
|
||||
(( ( ((__HANDLE__)->Instance->CR) & \
|
||||
(ADC_CR_ADSTART | ADC_CR_ADEN)) == ADC_CR_ADEN \
|
||||
) ? SET : RESET)
|
||||
|
||||
/**
|
||||
* @brief Verification of ADC state: enabled or disabled
|
||||
* @param __HANDLE__ ADC handle
|
||||
* @retval SET (ADC enabled) or RESET (ADC disabled)
|
||||
*/
|
||||
/* Note: If low power mode AutoPowerOff is enabled, power-on/off phases are */
|
||||
/* performed automatically by hardware and flag ADC_FLAG_RDY is not */
|
||||
/* set. */
|
||||
#define ADC_IS_ENABLE(__HANDLE__) ((( ((((hadc)->Instance->CR) & (ADC_CR_ADEN)) == ADC_CR_ADEN) ) ) ? SET : RESET)
|
||||
|
||||
/**
|
||||
* @brief Test if conversion trigger of regular group is software start
|
||||
* or external trigger.
|
||||
* @param __HANDLE__ ADC handle
|
||||
* @retval SET (software start) or RESET (external trigger)
|
||||
*/
|
||||
#define ADC_IS_SOFTWARE_START_REGULAR(__HANDLE__) \
|
||||
(((__HANDLE__)->Instance->CFGR1 & ADC_CFGR1_EXTEN) == RESET)
|
||||
|
||||
/**
|
||||
* @brief Check if no conversion on going on regular group
|
||||
* @param __HANDLE__ ADC handle
|
||||
* @retval SET (conversion is on going) or RESET (no conversion is on going)
|
||||
*/
|
||||
#define ADC_IS_CONVERSION_ONGOING_REGULAR(__HANDLE__) \
|
||||
(( (((__HANDLE__)->Instance->CR) & ADC_CR_ADSTART) == RESET \
|
||||
) ? RESET : SET)
|
||||
|
||||
/**
|
||||
* @brief Returns resolution bits in CFGR1 register: RES[1:0].
|
||||
* Returned value is among parameters to @ref ADC_Resolution.
|
||||
* @param __HANDLE__ ADC handle
|
||||
* @retval None
|
||||
*/
|
||||
#define ADC_GET_RESOLUTION(__HANDLE__) \
|
||||
(((__HANDLE__)->Instance->CFGR1) & ADC_CFGR1_RESSEL)
|
||||
|
||||
/**
|
||||
* @brief Returns ADC sample time bits in SMPR register: SMP[2:0].
|
||||
* Returned value is among parameters to @ref ADC_Resolution.
|
||||
* @param __HANDLE__ ADC handle
|
||||
* @retval None
|
||||
*/
|
||||
#define ADC_GET_SAMPLINGTIME(__HANDLE__) \
|
||||
(((__HANDLE__)->Instance->SMPR) & ADC_SMPR_SMP)
|
||||
|
||||
/**
|
||||
* @brief Simultaneously clears and sets specific bits of the handle State
|
||||
* @note: ADC_STATE_CLR_SET() macro is merely aliased to generic macro MODIFY_REG(),
|
||||
* the first parameter is the ADC handle State, the second parameter is the
|
||||
* bit field to clear, the third and last parameter is the bit field to set.
|
||||
* @retval None
|
||||
*/
|
||||
#define ADC_STATE_CLR_SET MODIFY_REG
|
||||
|
||||
/**
|
||||
* @brief Clear ADC error code (set it to error code: "no error")
|
||||
* @param __HANDLE__ ADC handle
|
||||
* @retval None
|
||||
*/
|
||||
#define ADC_CLEAR_ERRORCODE(__HANDLE__) \
|
||||
((__HANDLE__)->ErrorCode = HAL_ADC_ERROR_NONE)
|
||||
|
||||
|
||||
/**
|
||||
* @brief Configure the channel number into channel selection register
|
||||
* @param _CHANNEL_ ADC Channel
|
||||
* @retval None
|
||||
*/
|
||||
#define ADC_CHSELR_CHANNEL(_CHANNEL_) \
|
||||
( 1U << (_CHANNEL_))
|
||||
|
||||
/**
|
||||
* @brief Set the ADC's sample time
|
||||
* @param _SAMPLETIME_ Sample time parameter.
|
||||
* @retval None
|
||||
*/
|
||||
#define ADC_SMPR_SET(_SAMPLETIME_) \
|
||||
((_SAMPLETIME_) & (ADC_SMPR_SMP))
|
||||
|
||||
/**
|
||||
* @brief Set the Analog Watchdog 1 channel.
|
||||
* @param _CHANNEL_ channel to be monitored by Analog Watchdog 1.
|
||||
* @retval None
|
||||
*/
|
||||
#define ADC_CFGR_AWDCH(_CHANNEL_) \
|
||||
((_CHANNEL_) << 26U)
|
||||
|
||||
/**
|
||||
* @brief Enable ADC discontinuous conversion mode for regular group
|
||||
* @param _REG_DISCONTINUOUS_MODE_ Regular discontinuous mode.
|
||||
* @retval None
|
||||
*/
|
||||
#define ADC_CFGR1_REG_DISCCONTINUOUS(_REG_DISCONTINUOUS_MODE_) \
|
||||
((_REG_DISCONTINUOUS_MODE_) << 16U)
|
||||
|
||||
/**
|
||||
* @brief Enable the ADC auto delay mode.
|
||||
* @param _AUTOWAIT_ Auto delay bit enable or disable.
|
||||
* @retval None
|
||||
*/
|
||||
#define ADC_CFGR1_AUTOWAIT(_AUTOWAIT_) \
|
||||
((_AUTOWAIT_) << 14U)
|
||||
|
||||
/**
|
||||
* @brief Enable ADC continuous conversion mode.
|
||||
* @param _CONTINUOUS_MODE_ Continuous mode.
|
||||
* @retval None
|
||||
*/
|
||||
#define ADC_CFGR1_CONTINUOUS(_CONTINUOUS_MODE_) \
|
||||
((_CONTINUOUS_MODE_) << 13U)
|
||||
|
||||
/**
|
||||
* @brief Enable ADC overrun mode.
|
||||
* @param _OVERRUN_MODE_ Overrun mode.
|
||||
* @retval Overun bit setting to be programmed into CFGR register
|
||||
*/
|
||||
#define ADC_CFGR1_OVERRUN(_OVERRUN_MODE_) \
|
||||
( ( (_OVERRUN_MODE_) != (ADC_OVR_DATA_PRESERVED) \
|
||||
)? (ADC_CFGR1_OVRMOD) : (0x00000000) \
|
||||
)
|
||||
|
||||
/**
|
||||
* @brief Enable ADC scan mode to convert multiple ranks with sequencer.
|
||||
* @param _SCAN_MODE_ Scan conversion mode.
|
||||
* @retval None
|
||||
*/
|
||||
#define ADC_SCANDIR(_SCAN_MODE_) \
|
||||
( ( (_SCAN_MODE_) == (ADC_SCAN_DIRECTION_BACKWARD) \
|
||||
)? (ADC_CFGR1_SCANDIR) : (0x00000000) \
|
||||
)
|
||||
|
||||
#if (defined(DMA) || defined(DMA1))
|
||||
/**
|
||||
* @brief Enable the ADC DMA continuous request.
|
||||
* @param _DMACONTREQ_MODE_ DMA continuous request mode.
|
||||
* @retval None
|
||||
*/
|
||||
#define ADC_CFGR1_DMACONTREQ(_DMACONTREQ_MODE_) \
|
||||
((_DMACONTREQ_MODE_) << 1U)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Configure the analog watchdog high threshold into register TR.
|
||||
* @param _Threshold_ Threshold value
|
||||
* @retval None
|
||||
*/
|
||||
#define ADC_TRX_HIGHTHRESHOLD(_Threshold_) \
|
||||
((_Threshold_) << 16U)
|
||||
|
||||
|
||||
/** @defgroup ADCEx_Private_Macros ADCEx Private Macros
|
||||
* @{
|
||||
*/
|
||||
/* Macro reserved for internal HAL driver usage, not intended to be used in */
|
||||
/* code of final user. */
|
||||
|
||||
/**
|
||||
* @brief Test if the selected ADC channel is an internal channel
|
||||
* VrefInt/TempSensor
|
||||
* Note:
|
||||
* @param __CHANNEL__ ADC channel
|
||||
* @retval None
|
||||
*/
|
||||
|
||||
#define ADC_IS_CHANNEL_INTERNAL(__CHANNEL__) \
|
||||
(((__CHANNEL__) == ADC_CHANNEL_TEMPSENSOR) || \
|
||||
((__CHANNEL__) == ADC_CHANNEL_VREFINT) \
|
||||
)
|
||||
|
||||
/**
|
||||
* @brief Select the internal measurement path to be enabled/disabled
|
||||
* corresponding to the selected ADC internal channel
|
||||
* VrefInt/TempSensor.
|
||||
* Note:
|
||||
* @param __CHANNEL__ ADC channel
|
||||
* @retval Bit of register ADC_CCR
|
||||
*/
|
||||
|
||||
#define ADC_CHANNEL_INTERNAL_PATH(__CHANNEL__) \
|
||||
(( (__CHANNEL__) == ADC_CHANNEL_TEMPSENSOR \
|
||||
)? \
|
||||
(ADC_CCR_TSEN) \
|
||||
: \
|
||||
(ADC_CCR_VREFEN) \
|
||||
)
|
||||
|
||||
/**
|
||||
* @brief Shift the AWD threshold in function of the selected ADC resolution.
|
||||
* Thresholds have to be left-aligned on bit 11, the LSB (right bits) are set to 0.
|
||||
* If resolution 12 bits, no shift.
|
||||
* If resolution 10 bits, shift of 2 ranks on the left.
|
||||
* If resolution 8 bits, shift of 4 ranks on the left.
|
||||
* If resolution 6 bits, shift of 6 ranks on the left.
|
||||
* therefore, shift = (12 - resolution) = 12 - (12- (((RES[1:0]) >> 3)*2))
|
||||
* @param __HANDLE__ ADC handle
|
||||
* @param _Threshold_ Value to be shifted
|
||||
* @retval None
|
||||
*/
|
||||
#define ADC_AWD1THRESHOLD_SHIFT_RESOLUTION(__HANDLE__, _Threshold_) \
|
||||
((_Threshold_) << ((((__HANDLE__)->Instance->CFGR1 & ADC_CFGR1_RESSEL) >> 3U)*2))
|
||||
|
||||
|
||||
#define IS_ADC_CLOCKPRESCALER(ADC_CLOCK) (((ADC_CLOCK) == ADC_CLOCK_SYNC_PCLK_DIV1) || \
|
||||
((ADC_CLOCK) == ADC_CLOCK_SYNC_PCLK_DIV2) || \
|
||||
((ADC_CLOCK) == ADC_CLOCK_SYNC_PCLK_DIV4) || \
|
||||
((ADC_CLOCK) == ADC_CLOCK_SYNC_PCLK_DIV8) || \
|
||||
((ADC_CLOCK) == ADC_CLOCK_SYNC_PCLK_DIV16) || \
|
||||
((ADC_CLOCK) == ADC_CLOCK_SYNC_PCLK_DIV32) || \
|
||||
((ADC_CLOCK) == ADC_CLOCK_SYNC_PCLK_DIV64) || \
|
||||
((ADC_CLOCK) == ADC_CLOCK_ASYNC_HSI_DIV1) || \
|
||||
((ADC_CLOCK) == ADC_CLOCK_ASYNC_HSI_DIV2) || \
|
||||
((ADC_CLOCK) == ADC_CLOCK_ASYNC_HSI_DIV4) || \
|
||||
((ADC_CLOCK) == ADC_CLOCK_ASYNC_HSI_DIV8) || \
|
||||
((ADC_CLOCK) == ADC_CLOCK_ASYNC_HSI_DIV16) || \
|
||||
((ADC_CLOCK) == ADC_CLOCK_ASYNC_HSI_DIV32) || \
|
||||
((ADC_CLOCK) == ADC_CLOCK_ASYNC_HSI_DIV64) )
|
||||
|
||||
#define IS_ADC_RESOLUTION(RESOLUTION) (((RESOLUTION) == ADC_RESOLUTION_12B) || \
|
||||
((RESOLUTION) == ADC_RESOLUTION_10B) || \
|
||||
((RESOLUTION) == ADC_RESOLUTION_8B) || \
|
||||
((RESOLUTION) == ADC_RESOLUTION_6B) )
|
||||
|
||||
#define IS_ADC_DATA_ALIGN(ALIGN) (((ALIGN) == ADC_DATAALIGN_RIGHT) || \
|
||||
((ALIGN) == ADC_DATAALIGN_LEFT) )
|
||||
|
||||
#define IS_ADC_SCAN_MODE(SCAN_MODE) (((SCAN_MODE) == ADC_SCAN_DIRECTION_FORWARD) || \
|
||||
((SCAN_MODE) == ADC_SCAN_DIRECTION_BACKWARD)|| \
|
||||
((SCAN_MODE) == 0))
|
||||
|
||||
#define IS_ADC_EXTTRIG_EDGE(EDGE) (((EDGE) == ADC_EXTERNALTRIGCONVEDGE_NONE) || \
|
||||
((EDGE) == ADC_EXTERNALTRIGCONVEDGE_RISING) || \
|
||||
((EDGE) == ADC_EXTERNALTRIGCONVEDGE_FALLING) || \
|
||||
((EDGE) == ADC_EXTERNALTRIGCONVEDGE_RISINGFALLING) )
|
||||
|
||||
#define IS_ADC_EOC_SELECTION(EOC_SELECTION) (((EOC_SELECTION) == ADC_EOC_SINGLE_CONV) || \
|
||||
((EOC_SELECTION) == ADC_EOC_SEQ_CONV) )
|
||||
|
||||
#define IS_ADC_OVERRUN(OVR) (((OVR) == ADC_OVR_DATA_PRESERVED) || \
|
||||
((OVR) == ADC_OVR_DATA_OVERWRITTEN) )
|
||||
|
||||
#define IS_ADC_RANK(WATCHDOG) (((WATCHDOG) == ADC_RANK_CHANNEL_NUMBER) || \
|
||||
((WATCHDOG) == ADC_RANK_NONE) )
|
||||
|
||||
#define IS_ADC_SAMPLE_TIME(TIME) (((TIME) == ADC_SAMPLETIME_3CYCLES_5) || \
|
||||
((TIME) == ADC_SAMPLETIME_5CYCLES_5) || \
|
||||
((TIME) == ADC_SAMPLETIME_7CYCLES_5) || \
|
||||
((TIME) == ADC_SAMPLETIME_13CYCLES_5) || \
|
||||
((TIME) == ADC_SAMPLETIME_28CYCLES_5) || \
|
||||
((TIME) == ADC_SAMPLETIME_41CYCLES_5) || \
|
||||
((TIME) == ADC_SAMPLETIME_71CYCLES_5) || \
|
||||
((TIME) == ADC_SAMPLETIME_239CYCLES_5) )
|
||||
|
||||
#define IS_ADC_ANALOG_WATCHDOG_MODE(WATCHDOG) (((WATCHDOG) == ADC_ANALOGWATCHDOG_NONE) || \
|
||||
((WATCHDOG) == ADC_ANALOGWATCHDOG_SINGLE_REG) || \
|
||||
((WATCHDOG) == ADC_ANALOGWATCHDOG_ALL_REG) )
|
||||
|
||||
#define IS_ADC_EVENT_TYPE(EVENT) (((EVENT) == ADC_AWD_EVENT) || \
|
||||
((EVENT) == ADC_OVR_EVENT) )
|
||||
|
||||
#define IS_ADC_EXTTRIG(REGTRIG) (((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_TRGO) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC4) || \
|
||||
((REGTRIG) == ADC_EXTERNALTRIGCONV_T3_TRGO) || \
|
||||
((REGTRIG) == ADC_SOFTWARE_START))
|
||||
|
||||
#define IS_ADC_CHANNEL(CHANNEL) (((CHANNEL) == ADC_CHANNEL_0) || \
|
||||
((CHANNEL) == ADC_CHANNEL_1) || \
|
||||
((CHANNEL) == ADC_CHANNEL_2) || \
|
||||
((CHANNEL) == ADC_CHANNEL_3) || \
|
||||
((CHANNEL) == ADC_CHANNEL_4) || \
|
||||
((CHANNEL) == ADC_CHANNEL_5) || \
|
||||
((CHANNEL) == ADC_CHANNEL_6) || \
|
||||
((CHANNEL) == ADC_CHANNEL_7) || \
|
||||
((CHANNEL) == ADC_CHANNEL_8) || \
|
||||
((CHANNEL) == ADC_CHANNEL_9) || \
|
||||
((CHANNEL) == ADC_CHANNEL_TEMPSENSOR) || \
|
||||
((CHANNEL) == ADC_CHANNEL_VREFINT) )
|
||||
|
||||
/** @defgroup ADC_range_verification ADC range verification
|
||||
* in function of ADC resolution selected (12, 10, 8 or 6 bits)
|
||||
* @{
|
||||
*/
|
||||
#define IS_ADC_RANGE(RESOLUTION, ADC_VALUE) \
|
||||
((((RESOLUTION) == ADC_RESOLUTION_12B) && ((ADC_VALUE) <= (0x0FFFU))) || \
|
||||
(((RESOLUTION) == ADC_RESOLUTION_10B) && ((ADC_VALUE) <= (0x03FFU))) || \
|
||||
(((RESOLUTION) == ADC_RESOLUTION_8B) && ((ADC_VALUE) <= (0x00FFU))) || \
|
||||
(((RESOLUTION) == ADC_RESOLUTION_6B) && ((ADC_VALUE) <= (0x003FU))) )
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_regular_rank_verification ADC regular rank verification
|
||||
* @{
|
||||
*/
|
||||
#define IS_ADC_REGULAR_RANK(RANK) (((RANK) >= (1U)) && ((RANK) <= (16U)))
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Include ADC HAL Extension module */
|
||||
#include "py32f0xx_hal_adc_ex.h"
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/** @addtogroup ADC_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup ADC_Exported_Functions_Group1
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/* Initialization and de-initialization functions **********************************/
|
||||
HAL_StatusTypeDef HAL_ADC_Init(ADC_HandleTypeDef* hadc);
|
||||
HAL_StatusTypeDef HAL_ADC_DeInit(ADC_HandleTypeDef *hadc);
|
||||
void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc);
|
||||
void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc);
|
||||
|
||||
#if (USE_HAL_ADC_REGISTER_CALLBACKS == 1)
|
||||
/* Callbacks Register/UnRegister functions ***********************************/
|
||||
HAL_StatusTypeDef HAL_ADC_RegisterCallback(ADC_HandleTypeDef *hadc, HAL_ADC_CallbackIDTypeDef CallbackID, pADC_CallbackTypeDef pCallback);
|
||||
HAL_StatusTypeDef HAL_ADC_UnRegisterCallback(ADC_HandleTypeDef *hadc, HAL_ADC_CallbackIDTypeDef CallbackID);
|
||||
#endif /* USE_HAL_ADC_REGISTER_CALLBACKS */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* IO operation functions *****************************************************/
|
||||
|
||||
/** @addtogroup ADC_Exported_Functions_Group2
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/* Blocking mode: Polling */
|
||||
HAL_StatusTypeDef HAL_ADC_Start(ADC_HandleTypeDef* hadc);
|
||||
HAL_StatusTypeDef HAL_ADC_Stop(ADC_HandleTypeDef* hadc);
|
||||
HAL_StatusTypeDef HAL_ADC_PollForConversion(ADC_HandleTypeDef* hadc, uint32_t Timeout);
|
||||
HAL_StatusTypeDef HAL_ADC_PollForEvent(ADC_HandleTypeDef* hadc, uint32_t EventType, uint32_t Timeout);
|
||||
|
||||
/* Non-blocking mode: Interruption */
|
||||
HAL_StatusTypeDef HAL_ADC_Start_IT(ADC_HandleTypeDef* hadc);
|
||||
HAL_StatusTypeDef HAL_ADC_Stop_IT(ADC_HandleTypeDef* hadc);
|
||||
|
||||
#if (defined(DMA) || defined(DMA1))
|
||||
/* Non-blocking mode: DMA */
|
||||
HAL_StatusTypeDef HAL_ADC_Start_DMA(ADC_HandleTypeDef* hadc, uint32_t* pData, uint32_t Length);
|
||||
HAL_StatusTypeDef HAL_ADC_Stop_DMA(ADC_HandleTypeDef* hadc);
|
||||
#endif
|
||||
|
||||
/* ADC retrieve conversion value intended to be used with polling or interruption */
|
||||
uint32_t HAL_ADC_GetValue(ADC_HandleTypeDef* hadc);
|
||||
|
||||
/* ADC IRQHandler and Callbacks used in non-blocking modes (Interruption and DMA) */
|
||||
void HAL_ADC_IRQHandler(ADC_HandleTypeDef* hadc);
|
||||
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc);
|
||||
void HAL_ADC_ConvHalfCpltCallback(ADC_HandleTypeDef* hadc);
|
||||
void HAL_ADC_LevelOutOfWindowCallback(ADC_HandleTypeDef* hadc);
|
||||
void HAL_ADC_ErrorCallback(ADC_HandleTypeDef *hadc);
|
||||
|
||||
/* ADC Calibration */
|
||||
HAL_StatusTypeDef HAL_ADC_Calibration_Start(ADC_HandleTypeDef* hadc);
|
||||
#define HAL_ADCEx_Calibration_Start HAL_ADC_Calibration_Start
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/* Peripheral Control functions ***********************************************/
|
||||
/** @addtogroup ADC_Exported_Functions_Group3
|
||||
* @{
|
||||
*/
|
||||
HAL_StatusTypeDef HAL_ADC_ConfigChannel(ADC_HandleTypeDef* hadc, ADC_ChannelConfTypeDef* sConfig);
|
||||
HAL_StatusTypeDef HAL_ADC_AnalogWDGConfig(ADC_HandleTypeDef* hadc, ADC_AnalogWDGConfTypeDef* AnalogWDGConfig);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/* Peripheral State functions *************************************************/
|
||||
/** @addtogroup ADC_Exported_Functions_Group4
|
||||
* @{
|
||||
*/
|
||||
uint32_t HAL_ADC_GetState(ADC_HandleTypeDef* hadc);
|
||||
uint32_t HAL_ADC_GetError(ADC_HandleTypeDef *hadc);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* __PY32F0xx_HAL_ADC_H */
|
||||
|
||||
/************************ (C) COPYRIGHT Puya *****END OF FILE****/
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file py32f0xx_hal_adc_ex.h
|
||||
* @author MCU Application Team
|
||||
* @brief Header file of ADC HAL Extension module.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) Puya Semiconductor Co.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __PY32F0xx_HAL_ADC_EX_H
|
||||
#define __PY32F0xx_HAL_ADC_EX_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "py32f0xx_hal_def.h"
|
||||
|
||||
/** @addtogroup PY32F0xx_HAL_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup ADCEx
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
|
||||
/* Private macros ------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __PY32F0xx_HAL_ADC_EX_H */
|
||||
|
||||
|
||||
/************************ (C) COPYRIGHT Puya *****END OF FILE****/
|
||||
|
||||
755
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_comp.h
Normal file
755
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_comp.h
Normal file
@@ -0,0 +1,755 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file py32f0xx_hal_comp.h
|
||||
* @author MCU Application Team
|
||||
* @brief Header file of COMP HAL module.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) Puya Semiconductor Co.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __PY32F0xx_HAL_COMP_H
|
||||
#define __PY32F0xx_HAL_COMP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "py32f0xx_hal_def.h"
|
||||
#include "py32f0xx_ll_exti.h"
|
||||
|
||||
/** @addtogroup PY32F0xx_HAL_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @addtogroup COMP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/** @defgroup COMP_Exported_Types COMP Exported Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief COMP Init structure definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
|
||||
uint32_t WindowMode; /*!< Set window mode of a pair of comparators instances
|
||||
(2 consecutive instances odd and even COMP<x> and COMP<x+1>).
|
||||
Note: HAL COMP driver allows to set window mode from any COMP instance of the pair of COMP instances composing window mode.
|
||||
This parameter can be a value of @ref COMP_WindowMode */
|
||||
|
||||
uint32_t Mode; /*!< Set comparator operating mode to adjust power and speed.
|
||||
Note: For the characteristics of comparator power modes
|
||||
(propagation delay and power consumption), refer to device datasheet.
|
||||
This parameter can be a value of @ref COMP_PowerMode */
|
||||
|
||||
uint32_t InputPlus; /*!< Set comparator input plus (non-inverting input).
|
||||
This parameter can be a value of @ref COMP_InputPlus */
|
||||
|
||||
uint32_t InputMinus; /*!< Set comparator input minus (inverting input).
|
||||
This parameter can be a value of @ref COMP_InputMinus */
|
||||
|
||||
uint32_t Hysteresis; /*!< Set comparator hysteresis mode of the input minus.
|
||||
This parameter can be a value of @ref COMP_Hysteresis */
|
||||
|
||||
uint32_t OutputPol; /*!< Set comparator output polarity.
|
||||
This parameter can be a value of @ref COMP_OutputPolarity */
|
||||
|
||||
uint32_t DigitalFilter; /*!< Specifies the digital filter. the filter is prohibited
|
||||
when the value is zero.
|
||||
This parameter must be a number between 0 and 0xFFFF */
|
||||
|
||||
uint32_t TriggerMode; /*!< Set the comparator output triggering External Interrupt Line (EXTI).
|
||||
This parameter can be a value of @ref COMP_EXTI_TriggerMode */
|
||||
|
||||
} COMP_InitTypeDef;
|
||||
|
||||
/**
|
||||
* @brief HAL COMP state machine: HAL COMP states definition
|
||||
*/
|
||||
#define COMP_STATE_BITFIELD_LOCK (0x10U)
|
||||
typedef enum
|
||||
{
|
||||
HAL_COMP_STATE_RESET = 0x00U, /*!< COMP not yet initialized */
|
||||
HAL_COMP_STATE_RESET_LOCKED = (HAL_COMP_STATE_RESET | COMP_STATE_BITFIELD_LOCK), /*!< COMP not yet initialized and configuration is locked */
|
||||
HAL_COMP_STATE_READY = 0x01U, /*!< COMP initialized and ready for use */
|
||||
HAL_COMP_STATE_READY_LOCKED = (HAL_COMP_STATE_READY | COMP_STATE_BITFIELD_LOCK), /*!< COMP initialized but configuration is locked */
|
||||
HAL_COMP_STATE_BUSY = 0x02U, /*!< COMP is running */
|
||||
HAL_COMP_STATE_BUSY_LOCKED = (HAL_COMP_STATE_BUSY | COMP_STATE_BITFIELD_LOCK) /*!< COMP is running and configuration is locked */
|
||||
} HAL_COMP_StateTypeDef;
|
||||
|
||||
/**
|
||||
* @brief COMP Handle Structure definition
|
||||
*/
|
||||
#if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
|
||||
typedef struct __COMP_HandleTypeDef
|
||||
#else
|
||||
typedef struct
|
||||
#endif
|
||||
{
|
||||
COMP_TypeDef *Instance; /*!< Register base address */
|
||||
COMP_InitTypeDef Init; /*!< COMP required parameters */
|
||||
HAL_LockTypeDef Lock; /*!< Locking object */
|
||||
__IO HAL_COMP_StateTypeDef State; /*!< COMP communication state */
|
||||
__IO uint32_t ErrorCode; /*!< COMP error code */
|
||||
#if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
|
||||
void (* TriggerCallback)(struct __COMP_HandleTypeDef *hcomp); /*!< COMP trigger callback */
|
||||
void (* MspInitCallback)(struct __COMP_HandleTypeDef *hcomp); /*!< COMP Msp Init callback */
|
||||
void (* MspDeInitCallback)(struct __COMP_HandleTypeDef *hcomp); /*!< COMP Msp DeInit callback */
|
||||
#endif /* USE_HAL_COMP_REGISTER_CALLBACKS */
|
||||
} COMP_HandleTypeDef;
|
||||
|
||||
#if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
|
||||
/**
|
||||
* @brief HAL COMP Callback ID enumeration definition
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
HAL_COMP_TRIGGER_CB_ID = 0x00U, /*!< COMP trigger callback ID */
|
||||
HAL_COMP_MSPINIT_CB_ID = 0x01U, /*!< COMP Msp Init callback ID */
|
||||
HAL_COMP_MSPDEINIT_CB_ID = 0x02U /*!< COMP Msp DeInit callback ID */
|
||||
} HAL_COMP_CallbackIDTypeDef;
|
||||
|
||||
/**
|
||||
* @brief HAL COMP Callback pointer definition
|
||||
*/
|
||||
typedef void (*pCOMP_CallbackTypeDef)(COMP_HandleTypeDef *hcomp); /*!< pointer to a COMP callback function */
|
||||
|
||||
#endif /* USE_HAL_COMP_REGISTER_CALLBACKS */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/** @defgroup COMP_Exported_Constants COMP Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup COMP_Error_Code COMP Error Code
|
||||
* @{
|
||||
*/
|
||||
#define HAL_COMP_ERROR_NONE (0x00UL) /*!< No error */
|
||||
#if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
|
||||
#define HAL_COMP_ERROR_INVALID_CALLBACK (0x01UL) /*!< Invalid Callback error */
|
||||
#endif /* USE_HAL_COMP_REGISTER_CALLBACKS */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup COMP_WindowMode COMP Window Mode
|
||||
* @{
|
||||
*/
|
||||
#define COMP_WINDOWMODE_DISABLE (0x00000000UL) /*!< Window mode disable: Comparators instances pair COMP1 and COMP2 are independent */
|
||||
#define COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON (COMP_CSR_WINMODE) /*!< Window mode enable: Comparators instances pair COMP1 and COMP2 have their input plus connected together. The common input is COMP1 input plus (COMP2 input plus is no more accessible). */
|
||||
#define COMP_WINDOWMODE_COMP2_INPUT_PLUS_COMMON (COMP_CSR_WINMODE | COMP_WINDOWMODE_COMP2) /*!< Window mode enable: Comparators instances pair COMP1 and COMP2 have their input plus connected together. The common input is COMP2 input plus (COMP1 input plus is no more accessible). */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup COMP_PowerMode COMP power mode
|
||||
* @{
|
||||
*/
|
||||
/* Note: For the characteristics of comparator power modes */
|
||||
/* (propagation delay and power consumption), */
|
||||
/* refer to device datasheet. */
|
||||
#define COMP_POWERMODE_HIGHSPEED (0x00000000UL) /*!< High Speed */
|
||||
#define COMP_POWERMODE_MEDIUMSPEED (COMP_CSR_PWRMODE_0) /*!< Medium Speed */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup COMP_InputPlus COMP input plus (non-inverting input)
|
||||
* @{
|
||||
*/
|
||||
#define COMP_INPUT_PLUS_IO1 (0x00000000UL) /*!< Comparator input plus connected to IO1 (pin PB8 for COMP1, pin PB4 for COMP2) */
|
||||
#define COMP_INPUT_PLUS_IO2 (COMP_CSR_INPSEL_0) /*!< Comparator input plus connected to IO2 (pin PB2 for COMP1, pin PB6 for COMP2) */
|
||||
#define COMP_INPUT_PLUS_IO3 (COMP_CSR_INPSEL_1) /*!< Comparator input plus connected to IO3 (pin PA1 for COMP1, pin PA3 for COMP2) */
|
||||
#define COMP_INPUT_PLUS_IO4 (COMP_CSR_INPSEL_1 | COMP_CSR_INPSEL_0) /*!< Comparator input plus connected to IO4 (Reserved for COMP1, pin PF3 for COMP2) */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup COMP_InputMinus COMP input minus (inverting input)
|
||||
* @{
|
||||
*/
|
||||
#define COMP_INPUT_MINUS_1_4VREFINT (0x00000000UL) /*!< Comparator input minus connected to 1/4 VrefInt */
|
||||
#define COMP_INPUT_MINUS_1_2VREFINT ( COMP_CSR_INMSEL_0) /*!< Comparator input minus connected to 1/2 VrefInt */
|
||||
#define COMP_INPUT_MINUS_3_4VREFINT ( COMP_CSR_INMSEL_1 ) /*!< Comparator input minus connected to 3/4 VrefInt */
|
||||
#define COMP_INPUT_MINUS_VREFINT ( COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0) /*!< Comparator input minus connected to VrefInt */
|
||||
#define COMP_INPUT_MINUS_VCC ( COMP_CSR_INMSEL_2 ) /*!< Comparator input minus connected to VCC */
|
||||
#define COMP_INPUT_MINUS_TS ( COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_0) /*!< Comparator input minus connected to temperature sensor */
|
||||
#define COMP_INPUT_MINUS_IO1 ( COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_1 ) /*!< Comparator input minus connected to IO1 (pin PB1 for COMP1, pin PB3 for COMP2) */
|
||||
#define COMP_INPUT_MINUS_IO2 ( COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0) /*!< Comparator input minus connected to IO2 (Reserved for COMP1, pin PB7 for COMP2) */
|
||||
#define COMP_INPUT_MINUS_IO3 (COMP_CSR_INMSEL_3 ) /*!< Comparator input minus connected to IO3 (pin PA0 for COMP1, pin PA2 for COMP2) */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup COMP_Hysteresis COMP hysteresis
|
||||
* @{
|
||||
*/
|
||||
#define COMP_HYSTERESIS_DISABLE (0x00000000UL) /*!< No hysteresis */
|
||||
#define COMP_HYSTERESIS_ENABLE (COMP_CSR_HYST) /*!< Hysteresis enable */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup COMP_OutputPolarity COMP output Polarity
|
||||
* @{
|
||||
*/
|
||||
#define COMP_OUTPUTPOL_NONINVERTED (0x00000000UL) /*!< COMP output level is not inverted (comparator output is high when the input plus is at a higher voltage than the input minus) */
|
||||
#define COMP_OUTPUTPOL_INVERTED (COMP_CSR_POLARITY) /*!< COMP output level is inverted (comparator output is low when the input plus is at a higher voltage than the input minus) */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup COMP_OutputLevel COMP Output Level
|
||||
* @{
|
||||
*/
|
||||
/* Note: Comparator output level values are fixed to "0" and "1", */
|
||||
/* corresponding COMP register bit is managed by HAL function to match */
|
||||
/* with these values (independently of bit position in register). */
|
||||
|
||||
/* When output polarity is not inverted, comparator output is low when
|
||||
the input plus is at a lower voltage than the input minus */
|
||||
#define COMP_OUTPUT_LEVEL_LOW (0x00000000UL)
|
||||
/* When output polarity is not inverted, comparator output is high when
|
||||
the input plus is at a higher voltage than the input minus */
|
||||
#define COMP_OUTPUT_LEVEL_HIGH (0x00000001UL)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup COMP_EXTI_TriggerMode COMP output to EXTI
|
||||
* @{
|
||||
*/
|
||||
#define COMP_TRIGGERMODE_NONE (0x00000000UL) /*!< Comparator output triggering no External Interrupt Line */
|
||||
#define COMP_TRIGGERMODE_IT_RISING (COMP_EXTI_IT | COMP_EXTI_RISING) /*!< Comparator output triggering External Interrupt Line event with interruption, on rising edge */
|
||||
#define COMP_TRIGGERMODE_IT_FALLING (COMP_EXTI_IT | COMP_EXTI_FALLING) /*!< Comparator output triggering External Interrupt Line event with interruption, on falling edge */
|
||||
#define COMP_TRIGGERMODE_IT_RISING_FALLING (COMP_EXTI_IT | COMP_EXTI_RISING | COMP_EXTI_FALLING) /*!< Comparator output triggering External Interrupt Line event with interruption, on both rising and falling edges */
|
||||
#define COMP_TRIGGERMODE_EVENT_RISING (COMP_EXTI_EVENT | COMP_EXTI_RISING) /*!< Comparator output triggering External Interrupt Line event only (without interruption), on rising edge */
|
||||
#define COMP_TRIGGERMODE_EVENT_FALLING (COMP_EXTI_EVENT | COMP_EXTI_FALLING) /*!< Comparator output triggering External Interrupt Line event only (without interruption), on falling edge */
|
||||
#define COMP_TRIGGERMODE_EVENT_RISING_FALLING (COMP_EXTI_EVENT | COMP_EXTI_RISING | COMP_EXTI_FALLING) /*!< Comparator output triggering External Interrupt Line event only (without interruption), on both rising and falling edges */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/** @defgroup COMP_Exported_Macros COMP Exported Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup COMP_Handle_Management COMP Handle Management
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @brief Reset COMP handle state.
|
||||
* @param __HANDLE__ COMP handle
|
||||
* @retval None
|
||||
*/
|
||||
#if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
|
||||
#define __HAL_COMP_RESET_HANDLE_STATE(__HANDLE__) do{ \
|
||||
(__HANDLE__)->State = HAL_COMP_STATE_RESET; \
|
||||
(__HANDLE__)->MspInitCallback = NULL; \
|
||||
(__HANDLE__)->MspDeInitCallback = NULL; \
|
||||
} while(0)
|
||||
#else
|
||||
#define __HAL_COMP_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_COMP_STATE_RESET)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Clear COMP error code (set it to no error code "HAL_COMP_ERROR_NONE").
|
||||
* @param __HANDLE__ COMP handle
|
||||
* @retval None
|
||||
*/
|
||||
#define COMP_CLEAR_ERRORCODE(__HANDLE__) ((__HANDLE__)->ErrorCode = HAL_COMP_ERROR_NONE)
|
||||
|
||||
/**
|
||||
* @brief Enable the specified comparator.
|
||||
* @param __HANDLE__ COMP handle
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_COMP_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_EN)
|
||||
|
||||
/**
|
||||
* @brief Disable the specified comparator.
|
||||
* @param __HANDLE__ COMP handle
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_COMP_DISABLE(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_EN)
|
||||
|
||||
/**
|
||||
* @brief Lock the specified comparator configuration.
|
||||
* @note Using this macro induce HAL COMP handle state machine being no
|
||||
* more in line with COMP instance state.
|
||||
* To keep HAL COMP handle state machine updated, it is recommended
|
||||
* to use function "HAL_COMP_Lock')".
|
||||
* @param __HANDLE__ COMP handle
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_COMP_LOCK(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_LOCK)
|
||||
|
||||
/**
|
||||
* @brief Check whether the specified comparator is locked.
|
||||
* @param __HANDLE__ COMP handle
|
||||
* @retval Value 0 if COMP instance is not locked, value 1 if COMP instance is locked
|
||||
*/
|
||||
#define __HAL_COMP_IS_LOCKED(__HANDLE__) (READ_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_LOCK) == COMP_CSR_LOCK)
|
||||
|
||||
/**
|
||||
* @brief Disable vrefint input.
|
||||
* @param __HANDLE__ COMP handle
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_COMP_DISABLE_SCALER(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_SCALER_EN)
|
||||
|
||||
/**
|
||||
* @brief Check whether the vrefint input is enabled.
|
||||
* @param __HANDLE__ COMP handle
|
||||
* @retval Value 0 if COMP instance is not locked, value 1 if COMP instance is locked
|
||||
*/
|
||||
#define __HAL_COMP_IS_ENABLED_SCALER(__HANDLE__) (READ_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_SCALER_EN) == COMP_CSR_SCALER_EN)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup COMP_Exti_Management COMP external interrupt line management
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Enable the COMP1 EXTI line rising edge trigger.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_COMP_COMP1_EXTI_ENABLE_RISING_EDGE() LL_EXTI_EnableRisingTrig(COMP_EXTI_LINE_COMP1)
|
||||
|
||||
/**
|
||||
* @brief Disable the COMP1 EXTI line rising edge trigger.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_COMP_COMP1_EXTI_DISABLE_RISING_EDGE() LL_EXTI_DisableRisingTrig(COMP_EXTI_LINE_COMP1)
|
||||
|
||||
/**
|
||||
* @brief Enable the COMP1 EXTI line falling edge trigger.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_COMP_COMP1_EXTI_ENABLE_FALLING_EDGE() LL_EXTI_EnableFallingTrig(COMP_EXTI_LINE_COMP1)
|
||||
|
||||
/**
|
||||
* @brief Disable the COMP1 EXTI line falling edge trigger.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_COMP_COMP1_EXTI_DISABLE_FALLING_EDGE() LL_EXTI_DisableFallingTrig(COMP_EXTI_LINE_COMP1)
|
||||
|
||||
/**
|
||||
* @brief Enable the COMP1 EXTI line rising & falling edge trigger.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_COMP_COMP1_EXTI_ENABLE_RISING_FALLING_EDGE() do { \
|
||||
LL_EXTI_EnableRisingTrig(COMP_EXTI_LINE_COMP1); \
|
||||
LL_EXTI_EnableFallingTrig(COMP_EXTI_LINE_COMP1); \
|
||||
} while(0)
|
||||
|
||||
/**
|
||||
* @brief Disable the COMP1 EXTI line rising & falling edge trigger.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_COMP_COMP1_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
|
||||
LL_EXTI_DisableRisingTrig(COMP_EXTI_LINE_COMP1); \
|
||||
LL_EXTI_DisableFallingTrig(COMP_EXTI_LINE_COMP1); \
|
||||
} while(0)
|
||||
|
||||
/**
|
||||
* @brief Enable the COMP1 EXTI line in interrupt mode.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_COMP_COMP1_EXTI_ENABLE_IT() LL_EXTI_EnableIT(COMP_EXTI_LINE_COMP1)
|
||||
|
||||
/**
|
||||
* @brief Disable the COMP1 EXTI line in interrupt mode.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_COMP_COMP1_EXTI_DISABLE_IT() LL_EXTI_DisableIT(COMP_EXTI_LINE_COMP1)
|
||||
|
||||
/**
|
||||
* @brief Generate a software interrupt on the COMP1 EXTI line.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_COMP_COMP1_EXTI_GENERATE_SWIT() LL_EXTI_GenerateSWI(COMP_EXTI_LINE_COMP1)
|
||||
|
||||
/**
|
||||
* @brief Enable the COMP1 EXTI line in event mode.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_COMP_COMP1_EXTI_ENABLE_EVENT() LL_EXTI_EnableEvent(COMP_EXTI_LINE_COMP1)
|
||||
|
||||
/**
|
||||
* @brief Disable the COMP1 EXTI line in event mode.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_COMP_COMP1_EXTI_DISABLE_EVENT() LL_EXTI_DisableEvent(COMP_EXTI_LINE_COMP1)
|
||||
|
||||
/**
|
||||
* @brief Check whether the COMP1 EXTI line rising flag is set.
|
||||
* @retval RESET or SET
|
||||
*/
|
||||
#define __HAL_COMP_COMP1_EXTI_GET_RISING_FLAG() LL_EXTI_IsActiveRisingFlag(COMP_EXTI_LINE_COMP1)
|
||||
|
||||
/**
|
||||
* @brief Clear the COMP1 EXTI rising flag.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_COMP_COMP1_EXTI_CLEAR_RISING_FLAG() LL_EXTI_ClearRisingFlag(COMP_EXTI_LINE_COMP1)
|
||||
|
||||
/**
|
||||
* @brief Check whether the COMP1 EXTI line falling flag is set.
|
||||
* @retval RESET or SET
|
||||
*/
|
||||
#define __HAL_COMP_COMP1_EXTI_GET_FALLING_FLAG() LL_EXTI_IsActiveFallingFlag(COMP_EXTI_LINE_COMP1)
|
||||
|
||||
/**
|
||||
* @brief Clear the COMP1 EXTI falling flag.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_COMP_COMP1_EXTI_CLEAR_FALLING_FLAG() LL_EXTI_ClearFallingFlag(COMP_EXTI_LINE_COMP1)
|
||||
|
||||
/**
|
||||
* @brief Enable the COMP2 EXTI line rising edge trigger.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_COMP_COMP2_EXTI_ENABLE_RISING_EDGE() LL_EXTI_EnableRisingTrig(COMP_EXTI_LINE_COMP2)
|
||||
|
||||
/**
|
||||
* @brief Disable the COMP2 EXTI line rising edge trigger.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_COMP_COMP2_EXTI_DISABLE_RISING_EDGE() LL_EXTI_DisableRisingTrig(COMP_EXTI_LINE_COMP2)
|
||||
|
||||
/**
|
||||
* @brief Enable the COMP2 EXTI line falling edge trigger.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_COMP_COMP2_EXTI_ENABLE_FALLING_EDGE() LL_EXTI_EnableFallingTrig(COMP_EXTI_LINE_COMP2)
|
||||
|
||||
/**
|
||||
* @brief Disable the COMP2 EXTI line falling edge trigger.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_COMP_COMP2_EXTI_DISABLE_FALLING_EDGE() LL_EXTI_DisableFallingTrig(COMP_EXTI_LINE_COMP2)
|
||||
|
||||
/**
|
||||
* @brief Enable the COMP2 EXTI line rising & falling edge trigger.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_COMP_COMP2_EXTI_ENABLE_RISING_FALLING_EDGE() do { \
|
||||
LL_EXTI_EnableRisingTrig(COMP_EXTI_LINE_COMP2); \
|
||||
LL_EXTI_EnableFallingTrig(COMP_EXTI_LINE_COMP2); \
|
||||
} while(0)
|
||||
|
||||
/**
|
||||
* @brief Disable the COMP2 EXTI line rising & falling edge trigger.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_COMP_COMP2_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
|
||||
LL_EXTI_DisableRisingTrig(COMP_EXTI_LINE_COMP2); \
|
||||
LL_EXTI_DisableFallingTrig(COMP_EXTI_LINE_COMP2); \
|
||||
} while(0)
|
||||
|
||||
/**
|
||||
* @brief Enable the COMP2 EXTI line in interrupt mode.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_COMP_COMP2_EXTI_ENABLE_IT() LL_EXTI_EnableIT(COMP_EXTI_LINE_COMP2)
|
||||
|
||||
/**
|
||||
* @brief Disable the COMP2 EXTI line in interrupt mode.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_COMP_COMP2_EXTI_DISABLE_IT() LL_EXTI_DisableIT(COMP_EXTI_LINE_COMP2)
|
||||
|
||||
/**
|
||||
* @brief Generate a software interrupt on the COMP2 EXTI line.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_COMP_COMP2_EXTI_GENERATE_SWIT() LL_EXTI_GenerateSWI(COMP_EXTI_LINE_COMP2)
|
||||
|
||||
/**
|
||||
* @brief Enable the COMP2 EXTI line in event mode.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_COMP_COMP2_EXTI_ENABLE_EVENT() LL_EXTI_EnableEvent(COMP_EXTI_LINE_COMP2)
|
||||
|
||||
/**
|
||||
* @brief Disable the COMP2 EXTI line in event mode.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_COMP_COMP2_EXTI_DISABLE_EVENT() LL_EXTI_DisableEvent(COMP_EXTI_LINE_COMP2)
|
||||
|
||||
/**
|
||||
* @brief Check whether the COMP2 EXTI line rising flag is set.
|
||||
* @retval RESET or SET
|
||||
*/
|
||||
#define __HAL_COMP_COMP2_EXTI_GET_RISING_FLAG() LL_EXTI_IsActiveRisingFlag(COMP_EXTI_LINE_COMP2)
|
||||
|
||||
/**
|
||||
* @brief Clear the COMP2 EXTI rising flag.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_COMP_COMP2_EXTI_CLEAR_RISING_FLAG() LL_EXTI_ClearRisingFlag(COMP_EXTI_LINE_COMP2)
|
||||
|
||||
/**
|
||||
* @brief Check whether the COMP2 EXTI line falling flag is set.
|
||||
* @retval RESET or SET
|
||||
*/
|
||||
#define __HAL_COMP_COMP2_EXTI_GET_FALLING_FLAG() LL_EXTI_IsActiveFallingFlag(COMP_EXTI_LINE_COMP2)
|
||||
|
||||
/**
|
||||
* @brief Clear the COMP2 EXTI falling flag.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_COMP_COMP2_EXTI_CLEAR_FALLING_FLAG() LL_EXTI_ClearFallingFlag(COMP_EXTI_LINE_COMP2)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/* Private types -------------------------------------------------------------*/
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
/** @defgroup COMP_Private_Constants COMP Private Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup COMP_WindowMode_Instance_Differentiator COMP window mode instance differentiator
|
||||
* @{
|
||||
*/
|
||||
#define COMP_WINDOWMODE_COMP2 0x00001000U /*!< COMP window mode using common input of COMP instance: COMP2 */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup COMP_ExtiLine COMP EXTI Lines
|
||||
* @{
|
||||
*/
|
||||
#define COMP_EXTI_LINE_COMP1 (EXTI_IMR_IM17) /*!< EXTI line 17 connected to COMP1 output */
|
||||
#define COMP_EXTI_LINE_COMP2 (EXTI_IMR_IM18) /*!< EXTI line 18 connected to COMP2 output */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup COMP_ExtiLine COMP EXTI Lines
|
||||
* @{
|
||||
*/
|
||||
#define COMP_EXTI_IT (0x00000001UL) /*!< EXTI line event with interruption */
|
||||
#define COMP_EXTI_EVENT (0x00000002UL) /*!< EXTI line event only (without interruption) */
|
||||
#define COMP_EXTI_RISING (0x00000010UL) /*!< EXTI line event on rising edge */
|
||||
#define COMP_EXTI_FALLING (0x00000020UL) /*!< EXTI line event on falling edge */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Private macros ------------------------------------------------------------*/
|
||||
/** @defgroup COMP_Private_Macros COMP Private Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup COMP_GET_EXTI_LINE COMP private macros to get EXTI line associated with comparators
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief Get the specified EXTI line for a comparator instance.
|
||||
* @param __INSTANCE__ specifies the COMP instance.
|
||||
* @retval value of @ref COMP_ExtiLine
|
||||
*/
|
||||
#define COMP_GET_EXTI_LINE(__INSTANCE__) (((__INSTANCE__) == COMP1) ? COMP_EXTI_LINE_COMP1 \
|
||||
: COMP_EXTI_LINE_COMP2)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup COMP_IS_COMP_Definitions COMP private macros to check input parameters
|
||||
* @{
|
||||
*/
|
||||
#define IS_COMP_WINDOWMODE(__WINDOWMODE__) (((__WINDOWMODE__) == COMP_WINDOWMODE_DISABLE) || \
|
||||
((__WINDOWMODE__) == COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON)|| \
|
||||
((__WINDOWMODE__) == COMP_WINDOWMODE_COMP2_INPUT_PLUS_COMMON) )
|
||||
|
||||
#define IS_COMP_WINDOWOUTPUT(__WINDOWOUTPUT__) (((__WINDOWOUTPUT__) == COMP_WINDOWOUTPUT_EACH_COMP) || \
|
||||
((__WINDOWOUTPUT__) == COMP_WINDOWOUTPUT_COMP1) || \
|
||||
((__WINDOWOUTPUT__) == COMP_WINDOWOUTPUT_COMP2) || \
|
||||
((__WINDOWOUTPUT__) == COMP_WINDOWOUTPUT_BOTH) )
|
||||
|
||||
#define IS_COMP_POWERMODE(__POWERMODE__) (((__POWERMODE__) == COMP_POWERMODE_HIGHSPEED) || \
|
||||
((__POWERMODE__) == COMP_POWERMODE_MEDIUMSPEED) )
|
||||
|
||||
#define IS_COMP_INPUT_PLUS(__COMP_INSTANCE__, __INPUT_PLUS__) (((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO1) || \
|
||||
((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO2) || \
|
||||
((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO3) || \
|
||||
((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO4))
|
||||
|
||||
#define IS_COMP_INPUT_MINUS(__COMP_INSTANCE__, __INPUT_MINUS__) (((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_4VREFINT) || \
|
||||
((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_2VREFINT) || \
|
||||
((__INPUT_MINUS__) == COMP_INPUT_MINUS_3_4VREFINT) || \
|
||||
((__INPUT_MINUS__) == COMP_INPUT_MINUS_VREFINT) || \
|
||||
((__INPUT_MINUS__) == COMP_INPUT_MINUS_VCC) || \
|
||||
((__INPUT_MINUS__) == COMP_INPUT_MINUS_TS) || \
|
||||
((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO1) || \
|
||||
((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO2) || \
|
||||
((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO3))
|
||||
|
||||
#define IS_COMP_INPUT_MINUS_VREFINT(__INPUT_MINUS__) (((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_4VREFINT) || \
|
||||
((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_2VREFINT) || \
|
||||
((__INPUT_MINUS__) == COMP_INPUT_MINUS_3_4VREFINT) || \
|
||||
((__INPUT_MINUS__) == COMP_INPUT_MINUS_VREFINT))
|
||||
|
||||
#define IS_COMP_HYSTERESIS(__HYSTERESIS__) (((__HYSTERESIS__) == COMP_HYSTERESIS_DISABLE) || \
|
||||
((__HYSTERESIS__) == COMP_HYSTERESIS_ENABLE))
|
||||
|
||||
#define IS_COMP_OUTPUTPOL(__POL__) (((__POL__) == COMP_OUTPUTPOL_NONINVERTED) || \
|
||||
((__POL__) == COMP_OUTPUTPOL_INVERTED))
|
||||
|
||||
#define IS_COMP_BLANKINGSRCE(__OUTPUT_BLANKING_SOURCE__) \
|
||||
( ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE) \
|
||||
|| ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC4) \
|
||||
|| ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5) \
|
||||
|| ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC3) \
|
||||
|| ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3) \
|
||||
|| ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM15_OC2) \
|
||||
)
|
||||
|
||||
/* Note: Output blanking source common to all COMP instances */
|
||||
/* Macro kept for compatibility with other PY32 series */
|
||||
#define IS_COMP_BLANKINGSRC_INSTANCE(__INSTANCE__, __OUTPUT_BLANKING_SOURCE__) \
|
||||
(IS_COMP_BLANKINGSRCE(__OUTPUT_BLANKING_SOURCE__))
|
||||
|
||||
|
||||
#define IS_COMP_TRIGGERMODE(__MODE__) (((__MODE__) == COMP_TRIGGERMODE_NONE) || \
|
||||
((__MODE__) == COMP_TRIGGERMODE_IT_RISING) || \
|
||||
((__MODE__) == COMP_TRIGGERMODE_IT_FALLING) || \
|
||||
((__MODE__) == COMP_TRIGGERMODE_IT_RISING_FALLING) || \
|
||||
((__MODE__) == COMP_TRIGGERMODE_EVENT_RISING) || \
|
||||
((__MODE__) == COMP_TRIGGERMODE_EVENT_FALLING) || \
|
||||
((__MODE__) == COMP_TRIGGERMODE_EVENT_RISING_FALLING))
|
||||
|
||||
#define IS_COMP_OUTPUT_LEVEL(__OUTPUT_LEVEL__) (((__OUTPUT_LEVEL__) == COMP_OUTPUT_LEVEL_LOW) || \
|
||||
((__OUTPUT_LEVEL__) == COMP_OUTPUT_LEVEL_HIGH))
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/** @addtogroup COMP_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup COMP_Exported_Functions_Group1
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Initialization and de-initialization functions **********************************/
|
||||
HAL_StatusTypeDef HAL_COMP_Init(COMP_HandleTypeDef *hcomp);
|
||||
HAL_StatusTypeDef HAL_COMP_DeInit(COMP_HandleTypeDef *hcomp);
|
||||
void HAL_COMP_MspInit(COMP_HandleTypeDef *hcomp);
|
||||
void HAL_COMP_MspDeInit(COMP_HandleTypeDef *hcomp);
|
||||
|
||||
#if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
|
||||
/* Callbacks Register/UnRegister functions ***********************************/
|
||||
HAL_StatusTypeDef HAL_COMP_RegisterCallback(COMP_HandleTypeDef *hcomp, HAL_COMP_CallbackIDTypeDef CallbackID,
|
||||
pCOMP_CallbackTypeDef pCallback);
|
||||
HAL_StatusTypeDef HAL_COMP_UnRegisterCallback(COMP_HandleTypeDef *hcomp, HAL_COMP_CallbackIDTypeDef CallbackID);
|
||||
#endif /* USE_HAL_COMP_REGISTER_CALLBACKS */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* IO operation functions *****************************************************/
|
||||
/** @addtogroup COMP_Exported_Functions_Group2
|
||||
* @{
|
||||
*/
|
||||
HAL_StatusTypeDef HAL_COMP_Start(COMP_HandleTypeDef *hcomp);
|
||||
HAL_StatusTypeDef HAL_COMP_Stop(COMP_HandleTypeDef *hcomp);
|
||||
void HAL_COMP_IRQHandler(COMP_HandleTypeDef *hcomp);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Peripheral Control functions ************************************************/
|
||||
/** @addtogroup COMP_Exported_Functions_Group3
|
||||
* @{
|
||||
*/
|
||||
HAL_StatusTypeDef HAL_COMP_Lock(COMP_HandleTypeDef *hcomp);
|
||||
uint32_t HAL_COMP_GetOutputLevel(COMP_HandleTypeDef *hcomp);
|
||||
/* Callback in interrupt mode */
|
||||
void HAL_COMP_TriggerCallback(COMP_HandleTypeDef *hcomp);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Peripheral State functions **************************************************/
|
||||
/** @addtogroup COMP_Exported_Functions_Group4
|
||||
* @{
|
||||
*/
|
||||
HAL_COMP_StateTypeDef HAL_COMP_GetState(COMP_HandleTypeDef *hcomp);
|
||||
uint32_t HAL_COMP_GetError(COMP_HandleTypeDef *hcomp);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* PY32F0xx_HAL_COMP_H */
|
||||
|
||||
/************************ (C) COPYRIGHT Puya *****END OF FILE****/
|
||||
146
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_cortex.h
Normal file
146
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_cortex.h
Normal file
@@ -0,0 +1,146 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file py32f0xx_hal_cortex.h
|
||||
* @author MCU Application Team
|
||||
* @brief Header file of CORTEX HAL module.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) Puya Semiconductor Co.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __PY32F0xx_HAL_CORTEX_H
|
||||
#define __PY32F0xx_HAL_CORTEX_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "py32f0xx_hal_def.h"
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
||||
/** @defgroup CORTEX_Exported_Constants CORTEX Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup CORTEX_SysTick_clock_source CORTEX SysTick clock source
|
||||
* @{
|
||||
*/
|
||||
#define SYSTICK_CLKSOURCE_HCLK_DIV8 0x00000000U
|
||||
#define SYSTICK_CLKSOURCE_HCLK 0x00000004U
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Exported macros -----------------------------------------------------------*/
|
||||
/** @defgroup CORTEX_Exported_Macros CORTEX Exported Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/** @defgroup CORTEX_Exported_Functions CORTEX Exported Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup CORTEX_Exported_Functions_Group1 Initialization and Configuration functions
|
||||
* @brief Initialization and Configuration functions
|
||||
* @{
|
||||
*/
|
||||
/* Initialization and Configuration functions *****************************/
|
||||
void HAL_NVIC_SetPriority(IRQn_Type IRQn,uint32_t PreemptPriority, uint32_t SubPriority);
|
||||
void HAL_NVIC_EnableIRQ(IRQn_Type IRQn);
|
||||
void HAL_NVIC_DisableIRQ(IRQn_Type IRQn);
|
||||
void HAL_NVIC_SystemReset(void);
|
||||
uint32_t HAL_SYSTICK_Config(uint32_t TicksNumb);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup CORTEX_Exported_Functions_Group2 Peripheral Control functions
|
||||
* @brief Cortex control functions
|
||||
* @{
|
||||
*/
|
||||
/* Peripheral Control functions *************************************************/
|
||||
uint32_t HAL_NVIC_GetPriority(IRQn_Type IRQn);
|
||||
uint32_t HAL_NVIC_GetPendingIRQ(IRQn_Type IRQn);
|
||||
void HAL_NVIC_SetPendingIRQ(IRQn_Type IRQn);
|
||||
void HAL_NVIC_ClearPendingIRQ(IRQn_Type IRQn);
|
||||
void HAL_SYSTICK_CLKSourceConfig(uint32_t CLKSource);
|
||||
void HAL_SYSTICK_IRQHandler(void);
|
||||
void HAL_SYSTICK_Callback(void);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Private types -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
/* Private macros ------------------------------------------------------------*/
|
||||
/** @defgroup CORTEX_Private_Macros CORTEX Private Macros
|
||||
* @{
|
||||
*/
|
||||
#define IS_NVIC_PREEMPTION_PRIORITY(PRIORITY) ((PRIORITY) < 0x4U)
|
||||
|
||||
#define IS_NVIC_DEVICE_IRQ(IRQ) ((IRQ) > SysTick_IRQn)
|
||||
|
||||
#define IS_SYSTICK_CLK_SOURCE(SOURCE) (((SOURCE) == SYSTICK_CLKSOURCE_HCLK) || \
|
||||
((SOURCE) == SYSTICK_CLKSOURCE_HCLK_DIV8))
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __PY32F0xx_HAL_CORTEX_H */
|
||||
|
||||
|
||||
/************************ (C) COPYRIGHT Puya *****END OF FILE****/
|
||||
|
||||
187
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_crc.h
Normal file
187
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_crc.h
Normal file
@@ -0,0 +1,187 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file py32f0xx_hal_crc.h
|
||||
* @author MCU Application Team
|
||||
* @brief Header file of CRC HAL module.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) Puya Semiconductor Co.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __PY32F0xx_HAL_CRC_H
|
||||
#define __PY32F0xx_HAL_CRC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "py32f0xx_hal_def.h"
|
||||
|
||||
/** @addtogroup PY32F0xx_HAL_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup CRC
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/** @defgroup CRC_Exported_Types CRC Exported Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief CRC HAL State Structure definition
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
HAL_CRC_STATE_RESET = 0x00U, /*!< CRC not yet initialized or disabled */
|
||||
HAL_CRC_STATE_READY = 0x01U, /*!< CRC initialized and ready for use */
|
||||
HAL_CRC_STATE_BUSY = 0x02U, /*!< CRC internal process is ongoing */
|
||||
HAL_CRC_STATE_TIMEOUT = 0x03U, /*!< CRC timeout state */
|
||||
HAL_CRC_STATE_ERROR = 0x04U /*!< CRC error state */
|
||||
} HAL_CRC_StateTypeDef;
|
||||
|
||||
|
||||
/**
|
||||
* @brief CRC Handle Structure definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
CRC_TypeDef *Instance; /*!< Register base address */
|
||||
|
||||
HAL_LockTypeDef Lock; /*!< CRC Locking object */
|
||||
|
||||
__IO HAL_CRC_StateTypeDef State; /*!< CRC communication state */
|
||||
|
||||
} CRC_HandleTypeDef;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/** @defgroup CRC_Exported_Constants CRC Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported macros -----------------------------------------------------------*/
|
||||
/** @defgroup CRC_Exported_Macros CRC Exported Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @brief Reset CRC handle state.
|
||||
* @param __HANDLE__ CRC handle.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_CRC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_CRC_STATE_RESET)
|
||||
|
||||
/**
|
||||
* @brief Reset CRC Data Register.
|
||||
* @param __HANDLE__ CRC handle
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_CRC_DR_RESET(__HANDLE__) ((__HANDLE__)->Instance->CR |= CRC_CR_RESET)
|
||||
|
||||
/**
|
||||
* @brief Store data in the Independent Data (ID) register.
|
||||
* @param __HANDLE__ CRC handle
|
||||
* @param __VALUE__ Value to be stored in the ID register
|
||||
* @note Refer to the Reference Manual to get the authorized __VALUE__ length in bits
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_CRC_SET_IDR(__HANDLE__, __VALUE__) (WRITE_REG((__HANDLE__)->Instance->IDR, (__VALUE__)))
|
||||
|
||||
/**
|
||||
* @brief Return the data stored in the Independent Data (ID) register.
|
||||
* @param __HANDLE__ CRC handle
|
||||
* @note Refer to the Reference Manual to get the authorized __VALUE__ length in bits
|
||||
* @retval Value of the ID register
|
||||
*/
|
||||
#define __HAL_CRC_GET_IDR(__HANDLE__) (((__HANDLE__)->Instance->IDR) & CRC_IDR_IDR)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/* Private macros --------------------------------------------------------*/
|
||||
/** @defgroup CRC_Private_Macros CRC Private Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/** @defgroup CRC_Exported_Functions CRC Exported Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Initialization and de-initialization functions ****************************/
|
||||
/** @defgroup CRC_Exported_Functions_Group1 Initialization and de-initialization functions
|
||||
* @{
|
||||
*/
|
||||
HAL_StatusTypeDef HAL_CRC_Init(CRC_HandleTypeDef *hcrc);
|
||||
HAL_StatusTypeDef HAL_CRC_DeInit(CRC_HandleTypeDef *hcrc);
|
||||
void HAL_CRC_MspInit(CRC_HandleTypeDef *hcrc);
|
||||
void HAL_CRC_MspDeInit(CRC_HandleTypeDef *hcrc);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Peripheral Control functions ***********************************************/
|
||||
/** @defgroup CRC_Exported_Functions_Group2 Peripheral Control functions
|
||||
* @{
|
||||
*/
|
||||
uint32_t HAL_CRC_Accumulate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t BufferLength);
|
||||
uint32_t HAL_CRC_Calculate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t BufferLength);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Peripheral State and Error functions ***************************************/
|
||||
/** @defgroup CRC_Exported_Functions_Group3 Peripheral State functions
|
||||
* @{
|
||||
*/
|
||||
HAL_CRC_StateTypeDef HAL_CRC_GetState(CRC_HandleTypeDef *hcrc);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __PY32F0xx_HAL_CRC_H */
|
||||
|
||||
/************************ (C) COPYRIGHT Puya *****END OF FILE****/
|
||||
207
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_def.h
Normal file
207
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_def.h
Normal file
@@ -0,0 +1,207 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file py32f0xx_hal_def.h
|
||||
* @author MCU Application Team
|
||||
* @Version V1.0.0
|
||||
* @Date
|
||||
* @brief This file contains HAL common defines, enumeration, macros and
|
||||
* structures definitions.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) Puya Semiconductor Co.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __PY32F0xx_HAL_DEF
|
||||
#define __PY32F0xx_HAL_DEF
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "py32f0xx.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief HAL Status structures definition
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
HAL_OK = 0x00U,
|
||||
HAL_ERROR = 0x01U,
|
||||
HAL_BUSY = 0x02U,
|
||||
HAL_TIMEOUT = 0x03U
|
||||
} HAL_StatusTypeDef;
|
||||
|
||||
/**
|
||||
* @brief HAL Lock structures definition
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
HAL_UNLOCKED = 0x00U,
|
||||
HAL_LOCKED = 0x01U
|
||||
} HAL_LockTypeDef;
|
||||
|
||||
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
#define HAL_MAX_DELAY 0xFFFFFFFFU
|
||||
|
||||
#define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) != 0U)
|
||||
#define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == 0U)
|
||||
|
||||
#if (defined(DMA) || defined(DMA1))
|
||||
#define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__) \
|
||||
do{ \
|
||||
(__HANDLE__)->__PPP_DMA_FIELD__ = &(__DMA_HANDLE__); \
|
||||
(__DMA_HANDLE__).Parent = (__HANDLE__); \
|
||||
} while(0U)
|
||||
#endif
|
||||
|
||||
#define UNUSED(X) (void)X /* To avoid gcc/g++ warnings */
|
||||
|
||||
/** @brief Reset the Handle's State field.
|
||||
* @param __HANDLE__: specifies the Peripheral Handle.
|
||||
* @note This macro can be used for the following purpose:
|
||||
* - When the Handle is declared as local variable; before passing it as parameter
|
||||
* to HAL_PPP_Init() for the first time, it is mandatory to use this macro
|
||||
* to set to 0 the Handle's "State" field.
|
||||
* Otherwise, "State" field may have any random value and the first time the function
|
||||
* HAL_PPP_Init() is called, the low level hardware initialization will be missed
|
||||
* (i.e. HAL_PPP_MspInit() will not be executed).
|
||||
* - When there is a need to reconfigure the low level hardware: instead of calling
|
||||
* HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init().
|
||||
* In this later function, when the Handle's "State" field is set to 0, it will execute the function
|
||||
* HAL_PPP_MspInit() which will reconfigure the low level hardware.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0U)
|
||||
|
||||
#if (USE_RTOS == 1U)
|
||||
/* Reserved for future use */
|
||||
#error "USE_RTOS should be 0 in the current HAL release"
|
||||
#else
|
||||
#define __HAL_LOCK(__HANDLE__) \
|
||||
do{ \
|
||||
if((__HANDLE__)->Lock == HAL_LOCKED) \
|
||||
{ \
|
||||
return HAL_BUSY; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
(__HANDLE__)->Lock = HAL_LOCKED; \
|
||||
} \
|
||||
}while (0U)
|
||||
|
||||
#define __HAL_UNLOCK(__HANDLE__) \
|
||||
do{ \
|
||||
(__HANDLE__)->Lock = HAL_UNLOCKED; \
|
||||
}while (0U)
|
||||
#endif /* USE_RTOS */
|
||||
|
||||
#if defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */
|
||||
#ifndef __weak
|
||||
#define __weak __attribute__((weak))
|
||||
#endif /* __weak */
|
||||
#ifndef __packed
|
||||
#define __packed __attribute__((__packed__))
|
||||
#endif /* __packed */
|
||||
#endif /* __GNUC__ */
|
||||
|
||||
|
||||
/* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */
|
||||
#if defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */
|
||||
#ifndef __ALIGN_END
|
||||
#define __ALIGN_END __attribute__ ((aligned (4)))
|
||||
#endif /* __ALIGN_END */
|
||||
#ifndef __ALIGN_BEGIN
|
||||
#define __ALIGN_BEGIN
|
||||
#endif /* __ALIGN_BEGIN */
|
||||
#else
|
||||
#ifndef __ALIGN_END
|
||||
#define __ALIGN_END
|
||||
#endif /* __ALIGN_END */
|
||||
#ifndef __ALIGN_BEGIN
|
||||
#if defined (__CC_ARM) /* ARM Compiler */
|
||||
#define __ALIGN_BEGIN __align(4)
|
||||
#elif defined (__ICCARM__) /* IAR Compiler */
|
||||
#define __ALIGN_BEGIN
|
||||
#endif /* __CC_ARM */
|
||||
#endif /* __ALIGN_BEGIN */
|
||||
#endif /* __GNUC__ */
|
||||
|
||||
|
||||
/**
|
||||
* @brief __RAM_FUNC definition
|
||||
*/
|
||||
#if defined ( __CC_ARM )
|
||||
/* ARM Compiler
|
||||
------------
|
||||
RAM functions are defined using the toolchain options.
|
||||
Functions that are executed in RAM should reside in a separate source module.
|
||||
Using the 'Options for File' dialog you can simply change the 'Code / Const'
|
||||
area of a module to a memory space in physical RAM.
|
||||
Available memory areas are declared in the 'Target' tab of the 'Options for Target'
|
||||
dialog.
|
||||
*/
|
||||
#define __RAM_FUNC
|
||||
|
||||
#elif defined ( __ICCARM__ )
|
||||
/* ICCARM Compiler
|
||||
---------------
|
||||
RAM functions are defined using a specific toolchain keyword "__ramfunc".
|
||||
*/
|
||||
#define __RAM_FUNC __ramfunc
|
||||
|
||||
#elif defined ( __GNUC__ )
|
||||
/* GNU Compiler
|
||||
------------
|
||||
RAM functions are defined using a specific toolchain attribute
|
||||
"__attribute__((section(".RamFunc")))".
|
||||
*/
|
||||
#define __RAM_FUNC __attribute__((section(".RamFunc")))
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief __NOINLINE definition
|
||||
*/
|
||||
#if defined ( __CC_ARM ) || defined ( __GNUC__ )
|
||||
/* ARM & GNUCompiler
|
||||
----------------
|
||||
*/
|
||||
#define __NOINLINE __attribute__ ( (noinline) )
|
||||
|
||||
#elif defined ( __ICCARM__ )
|
||||
/* ICCARM Compiler
|
||||
---------------
|
||||
*/
|
||||
#define __NOINLINE _Pragma("optimize = no_inline")
|
||||
|
||||
#endif
|
||||
#if defined (USE_HAL_DRIVER)
|
||||
#include "py32f0xx_hal.h"
|
||||
#endif /* USE_HAL_DRIVER */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ___PY32F0xx_HAL_DEF */
|
||||
|
||||
|
||||
494
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_dma.h
Normal file
494
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_dma.h
Normal file
@@ -0,0 +1,494 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file py32f0xx_hal_dma.h
|
||||
* @author MCU Application Team
|
||||
* @brief Header file of DMA HAL module.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) Puya Semiconductor Co.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __PY32F0xx_HAL_DMA_H
|
||||
#define __PY32F0xx_HAL_DMA_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "py32f0xx_hal_def.h"
|
||||
|
||||
/** @addtogroup PY32F0xx_HAL_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup DMA
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
|
||||
/** @defgroup DMA_Exported_Types DMA Exported Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief DMA Configuration Structure definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t Direction; /*!< Specifies if the data will be transferred from memory to peripheral,
|
||||
from memory to memory or from peripheral to memory.
|
||||
This parameter can be a value of @ref DMA_Data_transfer_direction */
|
||||
|
||||
uint32_t PeriphInc; /*!< Specifies whether the Peripheral address register should be incremented or not.
|
||||
This parameter can be a value of @ref DMA_Peripheral_incremented_mode */
|
||||
|
||||
uint32_t MemInc; /*!< Specifies whether the memory address register should be incremented or not.
|
||||
This parameter can be a value of @ref DMA_Memory_incremented_mode */
|
||||
|
||||
uint32_t PeriphDataAlignment; /*!< Specifies the Peripheral data width.
|
||||
This parameter can be a value of @ref DMA_Peripheral_data_size */
|
||||
|
||||
uint32_t MemDataAlignment; /*!< Specifies the Memory data width.
|
||||
This parameter can be a value of @ref DMA_Memory_data_size */
|
||||
|
||||
uint32_t Mode; /*!< Specifies the operation mode of the DMAy Channelx.
|
||||
This parameter can be a value of @ref DMA_mode
|
||||
@note The circular buffer mode cannot be used if the memory-to-memory
|
||||
data transfer is configured on the selected Channel */
|
||||
|
||||
uint32_t Priority; /*!< Specifies the software priority for the DMAy Channelx.
|
||||
This parameter can be a value of @ref DMA_Priority_level */
|
||||
} DMA_InitTypeDef;
|
||||
|
||||
/**
|
||||
* @brief HAL DMA State structures definition
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
HAL_DMA_STATE_RESET = 0x00U, /*!< DMA not yet initialized or disabled */
|
||||
HAL_DMA_STATE_READY = 0x01U, /*!< DMA initialized and ready for use */
|
||||
HAL_DMA_STATE_BUSY = 0x02U, /*!< DMA process is ongoing */
|
||||
HAL_DMA_STATE_TIMEOUT = 0x03U /*!< DMA timeout state */
|
||||
} HAL_DMA_StateTypeDef;
|
||||
|
||||
/**
|
||||
* @brief HAL DMA Error Code structure definition
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
HAL_DMA_FULL_TRANSFER = 0x00U, /*!< Full transfer */
|
||||
HAL_DMA_HALF_TRANSFER = 0x01U /*!< Half Transfer */
|
||||
} HAL_DMA_LevelCompleteTypeDef;
|
||||
|
||||
/**
|
||||
* @brief HAL DMA Callback ID structure definition
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
HAL_DMA_XFER_CPLT_CB_ID = 0x00U, /*!< Full transfer */
|
||||
HAL_DMA_XFER_HALFCPLT_CB_ID = 0x01U, /*!< Half transfer */
|
||||
HAL_DMA_XFER_ERROR_CB_ID = 0x02U, /*!< Error */
|
||||
HAL_DMA_XFER_ABORT_CB_ID = 0x03U, /*!< Abort */
|
||||
HAL_DMA_XFER_ALL_CB_ID = 0x04U /*!< All */
|
||||
|
||||
} HAL_DMA_CallbackIDTypeDef;
|
||||
|
||||
/**
|
||||
* @brief DMA handle Structure definition
|
||||
*/
|
||||
typedef struct __DMA_HandleTypeDef
|
||||
{
|
||||
DMA_Channel_TypeDef *Instance; /*!< Register base address */
|
||||
|
||||
DMA_InitTypeDef Init; /*!< DMA communication parameters */
|
||||
|
||||
HAL_LockTypeDef Lock; /*!< DMA locking object */
|
||||
|
||||
__IO HAL_DMA_StateTypeDef State; /*!< DMA transfer state */
|
||||
|
||||
void *Parent; /*!< Parent object state */
|
||||
|
||||
void (* XferCpltCallback)( struct __DMA_HandleTypeDef * hdma); /*!< DMA transfer complete callback */
|
||||
|
||||
void (* XferHalfCpltCallback)( struct __DMA_HandleTypeDef * hdma); /*!< DMA Half transfer complete callback */
|
||||
|
||||
void (* XferErrorCallback)( struct __DMA_HandleTypeDef * hdma); /*!< DMA transfer error callback */
|
||||
|
||||
void (* XferAbortCallback)( struct __DMA_HandleTypeDef * hdma); /*!< DMA transfer abort callback */
|
||||
|
||||
__IO uint32_t ErrorCode; /*!< DMA Error code */
|
||||
|
||||
DMA_TypeDef *DmaBaseAddress; /*!< DMA Channel Base Address */
|
||||
|
||||
uint32_t ChannelIndex; /*!< DMA Channel Index */
|
||||
} DMA_HandleTypeDef;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
||||
/** @defgroup DMA_Exported_Constants DMA Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup DMA_Error_Code DMA Error Code
|
||||
* @{
|
||||
*/
|
||||
#define HAL_DMA_ERROR_NONE (0x00000000U) /*!< No error */
|
||||
#define HAL_DMA_ERROR_TE (0x00000001U) /*!< Transfer error */
|
||||
#define HAL_DMA_ERROR_NO_XFER (0x00000004U) /*!< no ongoin transfer */
|
||||
#define HAL_DMA_ERROR_TIMEOUT (0x00000020U) /*!< Timeout error */
|
||||
#define HAL_DMA_ERROR_NOT_SUPPORTED (0x00000100U) /*!< Not supported mode */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup DMA_Data_transfer_direction DMA Data transfer direction
|
||||
* @{
|
||||
*/
|
||||
#define DMA_PERIPH_TO_MEMORY (0x00000000U) /*!< Peripheral to memory direction */
|
||||
#define DMA_MEMORY_TO_PERIPH ((uint32_t)DMA_CCR_DIR) /*!< Memory to peripheral direction */
|
||||
#define DMA_MEMORY_TO_MEMORY ((uint32_t)(DMA_CCR_MEM2MEM)) /*!< Memory to memory direction */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup DMA_Peripheral_incremented_mode DMA Peripheral incremented mode
|
||||
* @{
|
||||
*/
|
||||
#define DMA_PINC_ENABLE ((uint32_t)DMA_CCR_PINC) /*!< Peripheral increment mode Enable */
|
||||
#define DMA_PINC_DISABLE (0x00000000U) /*!< Peripheral increment mode Disable */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup DMA_Memory_incremented_mode DMA Memory incremented mode
|
||||
* @{
|
||||
*/
|
||||
#define DMA_MINC_ENABLE ((uint32_t)DMA_CCR_MINC) /*!< Memory increment mode Enable */
|
||||
#define DMA_MINC_DISABLE (0x00000000U) /*!< Memory increment mode Disable */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup DMA_Peripheral_data_size DMA Peripheral data size
|
||||
* @{
|
||||
*/
|
||||
#define DMA_PDATAALIGN_BYTE (0x00000000U) /*!< Peripheral data alignment : Byte */
|
||||
#define DMA_PDATAALIGN_HALFWORD ((uint32_t)DMA_CCR_PSIZE_0) /*!< Peripheral data alignment : HalfWord */
|
||||
#define DMA_PDATAALIGN_WORD ((uint32_t)DMA_CCR_PSIZE_1) /*!< Peripheral data alignment : Word */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup DMA_Memory_data_size DMA Memory data size
|
||||
* @{
|
||||
*/
|
||||
#define DMA_MDATAALIGN_BYTE (0x00000000U) /*!< Memory data alignment : Byte */
|
||||
#define DMA_MDATAALIGN_HALFWORD ((uint32_t)DMA_CCR_MSIZE_0) /*!< Memory data alignment : HalfWord */
|
||||
#define DMA_MDATAALIGN_WORD ((uint32_t)DMA_CCR_MSIZE_1) /*!< Memory data alignment : Word */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup DMA_mode DMA mode
|
||||
* @{
|
||||
*/
|
||||
#define DMA_NORMAL (0x00000000U) /*!< Normal Mode */
|
||||
#define DMA_CIRCULAR ((uint32_t)DMA_CCR_CIRC) /*!< Circular Mode */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup DMA_Priority_level DMA Priority level
|
||||
* @{
|
||||
*/
|
||||
#define DMA_PRIORITY_LOW (0x00000000U) /*!< Priority level : Low */
|
||||
#define DMA_PRIORITY_MEDIUM ((uint32_t)DMA_CCR_PL_0) /*!< Priority level : Medium */
|
||||
#define DMA_PRIORITY_HIGH ((uint32_t)DMA_CCR_PL_1) /*!< Priority level : High */
|
||||
#define DMA_PRIORITY_VERY_HIGH ((uint32_t)DMA_CCR_PL) /*!< Priority level : Very_High */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup DMA_interrupt_enable_definitions DMA interrupt enable definitions
|
||||
* @{
|
||||
*/
|
||||
#define DMA_IT_TC ((uint32_t)DMA_CCR_TCIE)
|
||||
#define DMA_IT_HT ((uint32_t)DMA_CCR_HTIE)
|
||||
#define DMA_IT_TE ((uint32_t)DMA_CCR_TEIE)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup DMA_flag_definitions DMA flag definitions
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define DMA_FLAG_GL1 (0x00000001U) /*!< Channel 1 global interrupt flag */
|
||||
#define DMA_FLAG_TC1 (0x00000002U) /*!< Channel 1 transfer complete flag */
|
||||
#define DMA_FLAG_HT1 (0x00000004U) /*!< Channel 1 half transfer flag */
|
||||
#define DMA_FLAG_TE1 (0x00000008U) /*!< Channel 1 transfer error flag */
|
||||
#define DMA_FLAG_GL2 (0x00000010U) /*!< Channel 2 global interrupt flag */
|
||||
#define DMA_FLAG_TC2 (0x00000020U) /*!< Channel 2 transfer complete flag */
|
||||
#define DMA_FLAG_HT2 (0x00000040U) /*!< Channel 2 half transfer flag */
|
||||
#define DMA_FLAG_TE2 (0x00000080U) /*!< Channel 2 transfer error flag */
|
||||
#define DMA_FLAG_GL3 (0x00000100U) /*!< Channel 3 global interrupt flag */
|
||||
#define DMA_FLAG_TC3 (0x00000200U) /*!< Channel 3 transfer complete flag */
|
||||
#define DMA_FLAG_HT3 (0x00000400U) /*!< Channel 3 half transfer flag */
|
||||
#define DMA_FLAG_TE3 (0x00000800U) /*!< Channel 3 transfer error flag */
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/** @defgroup DMA_Channel_map DMA Channel map
|
||||
* @{
|
||||
*/
|
||||
#define DMA_CHANNEL_MAP_ADC 0x00000000U
|
||||
#define DMA_CHANNEL_MAP_SPI1_TX 0x00000001U
|
||||
#define DMA_CHANNEL_MAP_SPI1_RX 0x00000002U
|
||||
#define DMA_CHANNEL_MAP_SPI2_TX 0x00000003U
|
||||
#define DMA_CHANNEL_MAP_SPI2_RX 0x00000004U
|
||||
#define DMA_CHANNEL_MAP_USART1_TX 0x00000005U
|
||||
#define DMA_CHANNEL_MAP_USART1_RX 0x00000006U
|
||||
#define DMA_CHANNEL_MAP_USART2_TX 0x00000007U
|
||||
#define DMA_CHANNEL_MAP_USART2_RX 0x00000008U
|
||||
#define DMA_CHANNEL_MAP_I2C_TX 0x00000009U
|
||||
#define DMA_CHANNEL_MAP_I2C_RX 0x0000000AU
|
||||
#define DMA_CHANNEL_MAP_TIM1_CH1 0x0000000BU
|
||||
#define DMA_CHANNEL_MAP_TIM1_CH2 0x0000000CU
|
||||
#define DMA_CHANNEL_MAP_TIM1_CH3 0x0000000DU
|
||||
#define DMA_CHANNEL_MAP_TIM1_CH4 0x0000000EU
|
||||
#define DMA_CHANNEL_MAP_TIM1_COM 0x0000000FU
|
||||
#define DMA_CHANNEL_MAP_TIM1_UP 0x00000010U
|
||||
#define DMA_CHANNEL_MAP_TIM1_TRIG 0x00000011U
|
||||
#define DMA_CHANNEL_MAP_TIM3_CH1 0x00000012U
|
||||
#define DMA_CHANNEL_MAP_TIM3_CH3 0x00000013U
|
||||
#define DMA_CHANNEL_MAP_TIM3_CH4 0x00000014U
|
||||
#define DMA_CHANNEL_MAP_TIM3_TRIG 0x00000015U
|
||||
#define DMA_CHANNEL_MAP_TIM3_UP 0x00000016U
|
||||
|
||||
#define DMA_CHANNEL_MAP_TIM16_CH1 0x00000018U
|
||||
#define DMA_CHANNEL_MAP_TIM16_UP 0x00000019U
|
||||
#define DMA_CHANNEL_MAP_TIM17_CH1 0x0000001AU
|
||||
#define DMA_CHANNEL_MAP_TIM17_UP 0x0000001BU
|
||||
|
||||
#define DMA_CHANNEL_MAP_END 0x0000001CU
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/** @defgroup DMA_Exported_Macros DMA Exported Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @brief Reset DMA handle state
|
||||
* @param __HANDLE__ DMA handle.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_DMA_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_DMA_STATE_RESET)
|
||||
|
||||
/**
|
||||
* @brief Enable the specified DMA Channel.
|
||||
* @param __HANDLE__ DMA handle
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_DMA_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CCR |= DMA_CCR_EN)
|
||||
|
||||
/**
|
||||
* @brief Disable the specified DMA Channel.
|
||||
* @param __HANDLE__ DMA handle
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_DMA_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CCR &= ~DMA_CCR_EN)
|
||||
|
||||
|
||||
/* Interrupt & Flag management */
|
||||
|
||||
/**
|
||||
* @brief Enables the specified DMA Channel interrupts.
|
||||
* @param __HANDLE__ DMA handle
|
||||
* @param __INTERRUPT__ specifies the DMA interrupt sources to be enabled or disabled.
|
||||
* This parameter can be any combination of the following values:
|
||||
* @arg DMA_IT_TC: Transfer complete interrupt mask
|
||||
* @arg DMA_IT_HT: Half transfer complete interrupt mask
|
||||
* @arg DMA_IT_TE: Transfer error interrupt mask
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_DMA_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CCR |= (__INTERRUPT__))
|
||||
|
||||
/**
|
||||
* @brief Disables the specified DMA Channel interrupts.
|
||||
* @param __HANDLE__ DMA handle
|
||||
* @param __INTERRUPT__ specifies the DMA interrupt sources to be enabled or disabled.
|
||||
* This parameter can be any combination of the following values:
|
||||
* @arg DMA_IT_TC: Transfer complete interrupt mask
|
||||
* @arg DMA_IT_HT: Half transfer complete interrupt mask
|
||||
* @arg DMA_IT_TE: Transfer error interrupt mask
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_DMA_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CCR &= ~(__INTERRUPT__))
|
||||
|
||||
/**
|
||||
* @brief Checks whether the specified DMA Channel interrupt is enabled or disabled.
|
||||
* @param __HANDLE__ DMA handle
|
||||
* @param __INTERRUPT__ specifies the DMA interrupt source to check.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg DMA_IT_TC: Transfer complete interrupt mask
|
||||
* @arg DMA_IT_HT: Half transfer complete interrupt mask
|
||||
* @arg DMA_IT_TE: Transfer error interrupt mask
|
||||
* @retval The state of DMA_IT (SET or RESET).
|
||||
*/
|
||||
#define __HAL_DMA_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CCR & (__INTERRUPT__)))
|
||||
|
||||
/**
|
||||
* @brief Returns the number of remaining data units in the current DMAy Channelx transfer.
|
||||
* @param __HANDLE__ DMA handle
|
||||
*
|
||||
* @retval The number of remaining data units in the current DMA Channel transfer.
|
||||
*/
|
||||
#define __HAL_DMA_GET_COUNTER(__HANDLE__) ((__HANDLE__)->Instance->CNDTR)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Include DMA HAL Extension module */
|
||||
#include "py32f0xx_hal_dma_ex.h"
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/** @addtogroup DMA_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup DMA_Exported_Functions_Group1
|
||||
* @{
|
||||
*/
|
||||
/* Initialization and de-initialization functions *****************************/
|
||||
HAL_StatusTypeDef HAL_DMA_Init(DMA_HandleTypeDef *hdma);
|
||||
HAL_StatusTypeDef HAL_DMA_DeInit (DMA_HandleTypeDef *hdma);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup DMA_Exported_Functions_Group2
|
||||
* @{
|
||||
*/
|
||||
/* Input and Output operation functions *****************************************************/
|
||||
HAL_StatusTypeDef HAL_DMA_Start (DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength);
|
||||
HAL_StatusTypeDef HAL_DMA_Start_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength);
|
||||
HAL_StatusTypeDef HAL_DMA_Abort(DMA_HandleTypeDef *hdma);
|
||||
HAL_StatusTypeDef HAL_DMA_Abort_IT(DMA_HandleTypeDef *hdma);
|
||||
HAL_StatusTypeDef HAL_DMA_PollForTransfer(DMA_HandleTypeDef *hdma, uint32_t CompleteLevel, uint32_t Timeout);
|
||||
void HAL_DMA_IRQHandler(DMA_HandleTypeDef *hdma);
|
||||
HAL_StatusTypeDef HAL_DMA_RegisterCallback(DMA_HandleTypeDef *hdma, HAL_DMA_CallbackIDTypeDef CallbackID, void (* pCallback)( DMA_HandleTypeDef * _hdma));
|
||||
HAL_StatusTypeDef HAL_DMA_UnRegisterCallback(DMA_HandleTypeDef *hdma, HAL_DMA_CallbackIDTypeDef CallbackID);
|
||||
void HAL_DMA_ChannelMap(DMA_HandleTypeDef *hdma, uint32_t MapReqNum);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup DMA_Exported_Functions_Group3
|
||||
* @{
|
||||
*/
|
||||
/* Peripheral State and Error functions ***************************************/
|
||||
HAL_DMA_StateTypeDef HAL_DMA_GetState(DMA_HandleTypeDef *hdma);
|
||||
uint32_t HAL_DMA_GetError(DMA_HandleTypeDef *hdma);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup DMA_Private_Macros
|
||||
* @{
|
||||
*/
|
||||
#define IS_DMA_DIRECTION(DIRECTION) (((DIRECTION) == DMA_PERIPH_TO_MEMORY ) || \
|
||||
((DIRECTION) == DMA_MEMORY_TO_PERIPH) || \
|
||||
((DIRECTION) == DMA_MEMORY_TO_MEMORY))
|
||||
#define IS_DMA_PERIPHERAL_INC_STATE(STATE) (((STATE) == DMA_PINC_ENABLE) || \
|
||||
((STATE) == DMA_PINC_DISABLE))
|
||||
|
||||
#define IS_DMA_MEMORY_INC_STATE(STATE) (((STATE) == DMA_MINC_ENABLE) || \
|
||||
((STATE) == DMA_MINC_DISABLE))
|
||||
|
||||
#define IS_DMA_PERIPHERAL_DATA_SIZE(SIZE) (((SIZE) == DMA_PDATAALIGN_BYTE) || \
|
||||
((SIZE) == DMA_PDATAALIGN_HALFWORD) || \
|
||||
((SIZE) == DMA_PDATAALIGN_WORD))
|
||||
|
||||
#define IS_DMA_MEMORY_DATA_SIZE(SIZE) (((SIZE) == DMA_MDATAALIGN_BYTE) || \
|
||||
((SIZE) == DMA_MDATAALIGN_HALFWORD) || \
|
||||
((SIZE) == DMA_MDATAALIGN_WORD ))
|
||||
|
||||
#define IS_DMA_MODE(MODE) (((MODE) == DMA_NORMAL ) || \
|
||||
((MODE) == DMA_CIRCULAR))
|
||||
#define IS_DMA_PRIORITY(PRIORITY) (((PRIORITY) == DMA_PRIORITY_LOW ) || \
|
||||
((PRIORITY) == DMA_PRIORITY_MEDIUM) || \
|
||||
((PRIORITY) == DMA_PRIORITY_HIGH) || \
|
||||
((PRIORITY) == DMA_PRIORITY_VERY_HIGH))
|
||||
#define IS_DMA_BUFFER_SIZE(SIZE) (((SIZE) >= 0x1U) && ((SIZE) < 0x10000U))
|
||||
|
||||
|
||||
#define IS_DMA_MAP_VALUE(VALUE) (VALUE < DMA_CHANNEL_MAP_END)
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __PY32F0xx_HAL_DMA_H */
|
||||
|
||||
/************************ (C) COPYRIGHT Puya *****END OF FILE****/
|
||||
|
||||
140
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_dma_ex.h
Normal file
140
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_dma_ex.h
Normal file
@@ -0,0 +1,140 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file py32f0xx_hal_dma_ex.h
|
||||
* @author MCU Application Team
|
||||
* @brief Header file of DMA HAL extension module.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) Puya Semiconductor Co.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __PY32F0xx_HAL_DMA_EX_H
|
||||
#define __PY32F0xx_HAL_DMA_EX_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "py32f0xx_hal_def.h"
|
||||
|
||||
/** @addtogroup PY32F0xx_HAL_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup DMAEx DMAEx
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/** @defgroup DMAEx_Exported_Macros DMA Extended Exported Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Returns the current DMA Channel transfer complete flag.
|
||||
* @param __HANDLE__: DMA handle
|
||||
* @retval The specified transfer complete flag index.
|
||||
*/
|
||||
#define __HAL_DMA_GET_TC_FLAG_INDEX(__HANDLE__) \
|
||||
(((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel1))? DMA_FLAG_TC1 :\
|
||||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel2))? DMA_FLAG_TC2 :\
|
||||
DMA_FLAG_TC3)
|
||||
|
||||
/**
|
||||
* @brief Return the current DMA Channel half transfer complete flag.
|
||||
* @param __HANDLE__: DMA handle
|
||||
* @retval The specified half transfer complete flag index.
|
||||
*/
|
||||
#define __HAL_DMA_GET_HT_FLAG_INDEX(__HANDLE__)\
|
||||
(((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel1))? DMA_FLAG_HT1 :\
|
||||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel2))? DMA_FLAG_HT2 :\
|
||||
DMA_FLAG_HT3)
|
||||
|
||||
/**
|
||||
* @brief Return the current DMA Channel transfer error flag.
|
||||
* @param __HANDLE__: DMA handle
|
||||
* @retval The specified transfer error flag index.
|
||||
*/
|
||||
#define __HAL_DMA_GET_TE_FLAG_INDEX(__HANDLE__)\
|
||||
(((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel1))? DMA_FLAG_TE1 :\
|
||||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel2))? DMA_FLAG_TE2 :\
|
||||
DMA_FLAG_TE3)
|
||||
|
||||
/**
|
||||
* @brief Return the current DMA Channel Global interrupt flag.
|
||||
* @param __HANDLE__: DMA handle
|
||||
* @retval The specified transfer error flag index.
|
||||
*/
|
||||
#define __HAL_DMA_GET_GI_FLAG_INDEX(__HANDLE__)\
|
||||
(((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel1))? DMA_FLAG_GL1 :\
|
||||
((uint32_t)((__HANDLE__)->Instance) == ((uint32_t)DMA1_Channel2))? DMA_FLAG_GL2 :\
|
||||
DMA_FLAG_GL3)
|
||||
|
||||
/**
|
||||
* @brief Get the DMA Channel pending flags.
|
||||
* @param __HANDLE__: DMA handle
|
||||
* @param __FLAG__: Get the specified flag.
|
||||
* This parameter can be any combination of the following values:
|
||||
* @arg DMA_FLAG_TCx: Transfer complete flag
|
||||
* @arg DMA_FLAG_HTx: Half transfer complete flag
|
||||
* @arg DMA_FLAG_TEx: Transfer error flag
|
||||
* @arg DMA_FLAG_GLx: Global interrupt flag
|
||||
* Where x can be 1_7 to select the DMA Channel flag.
|
||||
* @retval The state of FLAG (SET or RESET).
|
||||
*/
|
||||
|
||||
#define __HAL_DMA_GET_FLAG(__HANDLE__, __FLAG__) (DMA1->ISR & (__FLAG__))
|
||||
|
||||
/**
|
||||
* @brief Clear the DMA Channel pending flags.
|
||||
* @param __HANDLE__: DMA handle
|
||||
* @param __FLAG__: specifies the flag to clear.
|
||||
* This parameter can be any combination of the following values:
|
||||
* @arg DMA_FLAG_TCx: Transfer complete flag
|
||||
* @arg DMA_FLAG_HTx: Half transfer complete flag
|
||||
* @arg DMA_FLAG_TEx: Transfer error flag
|
||||
* @arg DMA_FLAG_GLx: Global interrupt flag
|
||||
* Where x can be 1_7 to select the DMA Channel flag.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_DMA_CLEAR_FLAG(__HANDLE__, __FLAG__) (DMA1->IFCR = (__FLAG__))
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/************************ (C) COPYRIGHT Puya *****END OF FILE****/
|
||||
319
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_exti.h
Normal file
319
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_exti.h
Normal file
@@ -0,0 +1,319 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file py32f0xx_hal_exti.h
|
||||
* @author MCU Application Team
|
||||
* @brief Header file of EXTI HAL module.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) Puya Semiconductor Co.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __PY32F0xx_HAL_EXTI_H
|
||||
#define __PY32F0xx_HAL_EXTI_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "py32f0xx_hal_def.h"
|
||||
|
||||
/** @addtogroup PY32F0xx_HAL_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup EXTI EXTI
|
||||
* @brief EXTI HAL module driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
|
||||
/** @defgroup EXTI_Exported_Types EXTI Exported Types
|
||||
* @{
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
HAL_EXTI_COMMON_CB_ID = 0x00U,
|
||||
} EXTI_CallbackIDTypeDef;
|
||||
|
||||
|
||||
/**
|
||||
* @brief EXTI Handle structure definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t Line; /*!< Exti line number */
|
||||
void (* PendingCallback)(void); /*!< Exti pending callback */
|
||||
} EXTI_HandleTypeDef;
|
||||
|
||||
/**
|
||||
* @brief EXTI Configuration structure definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t Line; /*!< The Exti line to be configured. This parameter
|
||||
can be a value of @ref EXTI_Line */
|
||||
uint32_t Mode; /*!< The Exit Mode to be configured for a core.
|
||||
This parameter can be a combination of @ref EXTI_Mode */
|
||||
uint32_t Trigger; /*!< The Exti Trigger to be configured. This parameter
|
||||
can be a value of @ref EXTI_Trigger */
|
||||
uint32_t GPIOSel; /*!< The Exti GPIO multiplexer selection to be configured.
|
||||
This parameter is only possible for line 0 to 15. It
|
||||
can be a value of @ref EXTI_GPIOSel */
|
||||
} EXTI_ConfigTypeDef;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/** @defgroup EXTI_Exported_Constants EXTI Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup EXTI_Line EXTI Line
|
||||
* @{
|
||||
*/
|
||||
#define EXTI_LINE_0 (EXTI_GPIO | EXTI_REG1 | 0x00u)
|
||||
#define EXTI_LINE_1 (EXTI_GPIO | EXTI_REG1 | 0x01u)
|
||||
#define EXTI_LINE_2 (EXTI_GPIO | EXTI_REG1 | 0x02u)
|
||||
#define EXTI_LINE_3 (EXTI_GPIO | EXTI_REG1 | 0x03u)
|
||||
#define EXTI_LINE_4 (EXTI_GPIO | EXTI_REG1 | 0x04u)
|
||||
#define EXTI_LINE_5 (EXTI_GPIO | EXTI_REG1 | 0x05u)
|
||||
#define EXTI_LINE_6 (EXTI_GPIO | EXTI_REG1 | 0x06u)
|
||||
#define EXTI_LINE_7 (EXTI_GPIO | EXTI_REG1 | 0x07u)
|
||||
#define EXTI_LINE_8 (EXTI_GPIO | EXTI_REG1 | 0x08u)
|
||||
#define EXTI_LINE_9 (EXTI_GPIO | EXTI_REG1 | 0x09u)
|
||||
#define EXTI_LINE_10 (EXTI_GPIO | EXTI_REG1 | 0x0Au)
|
||||
#define EXTI_LINE_11 (EXTI_GPIO | EXTI_REG1 | 0x0Bu)
|
||||
#define EXTI_LINE_12 (EXTI_GPIO | EXTI_REG1 | 0x0Cu)
|
||||
#define EXTI_LINE_13 (EXTI_GPIO | EXTI_REG1 | 0x0Du)
|
||||
#define EXTI_LINE_14 (EXTI_GPIO | EXTI_REG1 | 0x0Eu)
|
||||
#define EXTI_LINE_15 (EXTI_GPIO | EXTI_REG1 | 0x0Fu)
|
||||
#define EXTI_LINE_16 (EXTI_CONFIG | EXTI_REG1 | 0x10u)
|
||||
#if defined(COMP1)
|
||||
#define EXTI_LINE_17 (EXTI_CONFIG | EXTI_REG1 | 0x11u)
|
||||
#else
|
||||
#define EXTI_LINE_17 (EXTI_RESERVED | EXTI_REG1 | 0x11u)
|
||||
#endif
|
||||
#if defined(COMP2)
|
||||
#define EXTI_LINE_18 (EXTI_CONFIG | EXTI_REG1 | 0x12u)
|
||||
#else
|
||||
#define EXTI_LINE_18 (EXTI_RESERVED | EXTI_REG1 | 0x12u)
|
||||
#endif
|
||||
#if defined(RTC)
|
||||
#define EXTI_LINE_19 (EXTI_DIRECT | EXTI_REG1 | 0x13u)
|
||||
#else
|
||||
#define EXTI_LINE_19 (EXTI_RESERVED | EXTI_REG1 | 0x13u)
|
||||
#endif
|
||||
#define EXTI_LINE_20 (EXTI_RESERVED | EXTI_REG1 | 0x14u)
|
||||
#define EXTI_LINE_21 (EXTI_RESERVED | EXTI_REG1 | 0x15u)
|
||||
#define EXTI_LINE_22 (EXTI_RESERVED | EXTI_REG1 | 0x16u)
|
||||
#define EXTI_LINE_23 (EXTI_RESERVED | EXTI_REG1 | 0x17u)
|
||||
#define EXTI_LINE_24 (EXTI_RESERVED | EXTI_REG1 | 0x18u)
|
||||
#define EXTI_LINE_25 (EXTI_RESERVED | EXTI_REG1 | 0x19u)
|
||||
#define EXTI_LINE_26 (EXTI_RESERVED | EXTI_REG1 | 0x1Au)
|
||||
#define EXTI_LINE_27 (EXTI_RESERVED | EXTI_REG1 | 0x1Bu)
|
||||
#define EXTI_LINE_28 (EXTI_RESERVED | EXTI_REG1 | 0x1Cu)
|
||||
#if defined(LPTIM)
|
||||
#define EXTI_LINE_29 (EXTI_DIRECT | EXTI_REG1 | 0x1Du)
|
||||
#else
|
||||
#define EXTI_LINE_29 (EXTI_RESERVED | EXTI_REG1 | 0x1Du)
|
||||
#endif
|
||||
#define EXTI_LINE_30 (EXTI_RESERVED | EXTI_REG1 | 0x1Eu)
|
||||
#define EXTI_LINE_31 (EXTI_RESERVED | EXTI_REG1 | 0x1Fu)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup EXTI_Mode EXTI Mode
|
||||
* @{
|
||||
*/
|
||||
#define EXTI_MODE_NONE 0x00000000u
|
||||
#define EXTI_MODE_INTERRUPT 0x00000001u
|
||||
#define EXTI_MODE_EVENT 0x00000002u
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup EXTI_Trigger EXTI Trigger
|
||||
* @{
|
||||
*/
|
||||
#define EXTI_TRIGGER_NONE 0x00000000u
|
||||
#define EXTI_TRIGGER_RISING 0x00000001u
|
||||
#define EXTI_TRIGGER_FALLING 0x00000002u
|
||||
#define EXTI_TRIGGER_RISING_FALLING (EXTI_TRIGGER_RISING | EXTI_TRIGGER_FALLING)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup EXTI_GPIOSel EXTI GPIOSel
|
||||
* @brief
|
||||
* @{
|
||||
*/
|
||||
#define EXTI_GPIOA 0x00000000u
|
||||
#define EXTI_GPIOB 0x00000001u
|
||||
#define EXTI_GPIOF 0x00000002u
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/** @defgroup EXTI_Exported_Macros EXTI Exported Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Private constants --------------------------------------------------------*/
|
||||
/** @defgroup EXTI_Private_Constants EXTI Private Constants
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief EXTI Line property definition
|
||||
*/
|
||||
#define EXTI_PROPERTY_SHIFT 24u
|
||||
#define EXTI_DIRECT (0x01uL << EXTI_PROPERTY_SHIFT)
|
||||
#define EXTI_CONFIG (0x02uL << EXTI_PROPERTY_SHIFT)
|
||||
#define EXTI_GPIO ((0x04uL << EXTI_PROPERTY_SHIFT) | EXTI_CONFIG)
|
||||
#define EXTI_RESERVED (0x08uL << EXTI_PROPERTY_SHIFT)
|
||||
#define EXTI_PROPERTY_MASK (EXTI_DIRECT | EXTI_CONFIG | EXTI_GPIO)
|
||||
|
||||
/**
|
||||
* @brief EXTI Register and bit usage
|
||||
*/
|
||||
#define EXTI_REG_SHIFT 16u
|
||||
#define EXTI_REG1 (0x00uL << EXTI_REG_SHIFT)
|
||||
#define EXTI_REG2 (0x01uL << EXTI_REG_SHIFT)
|
||||
#define EXTI_REG_MASK (EXTI_REG1 | EXTI_REG2)
|
||||
#define EXTI_PIN_MASK 0x0000001Fu
|
||||
|
||||
/**
|
||||
* @brief EXTI Mask for interrupt & event mode
|
||||
*/
|
||||
#define EXTI_MODE_MASK (EXTI_MODE_EVENT | EXTI_MODE_INTERRUPT)
|
||||
|
||||
/**
|
||||
* @brief EXTI Mask for trigger possibilities
|
||||
*/
|
||||
#define EXTI_TRIGGER_MASK (EXTI_TRIGGER_RISING | EXTI_TRIGGER_FALLING)
|
||||
|
||||
/**
|
||||
* @brief EXTI Line number
|
||||
*/
|
||||
#if defined(EXTI_IMR2_IM33)
|
||||
#define EXTI_LINE_NB 34uL
|
||||
#else
|
||||
#define EXTI_LINE_NB 32uL
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Private macros ------------------------------------------------------------*/
|
||||
/** @defgroup EXTI_Private_Macros EXTI Private Macros
|
||||
* @{
|
||||
*/
|
||||
#define IS_EXTI_LINE(__LINE__) ((((__LINE__) & ~(EXTI_PROPERTY_MASK | EXTI_REG_MASK | EXTI_PIN_MASK)) == 0x00u) && \
|
||||
((((__LINE__) & EXTI_PROPERTY_MASK) == EXTI_DIRECT) || \
|
||||
(((__LINE__) & EXTI_PROPERTY_MASK) == EXTI_CONFIG) || \
|
||||
(((__LINE__) & EXTI_PROPERTY_MASK) == EXTI_GPIO)) && \
|
||||
(((__LINE__) & (EXTI_REG_MASK | EXTI_PIN_MASK)) < \
|
||||
(((EXTI_LINE_NB / 32u) << EXTI_REG_SHIFT) | (EXTI_LINE_NB % 32u))))
|
||||
|
||||
#define IS_EXTI_MODE(__LINE__) ((((__LINE__) & EXTI_MODE_MASK) != 0x00u) && \
|
||||
(((__LINE__) & ~EXTI_MODE_MASK) == 0x00u))
|
||||
|
||||
#define IS_EXTI_TRIGGER(__LINE__) (((__LINE__) & ~EXTI_TRIGGER_MASK) == 0x00u)
|
||||
|
||||
#define IS_EXTI_PENDING_EDGE(__LINE__) (((__LINE__) == EXTI_TRIGGER_RISING) || \
|
||||
((__LINE__) == EXTI_TRIGGER_FALLING))
|
||||
|
||||
#define IS_EXTI_CONFIG_LINE(__LINE__) (((__LINE__) & EXTI_CONFIG) != 0x00u)
|
||||
|
||||
#define IS_EXTI_GPIO_PORT(__PORT__) (((__PORT__) == EXTI_GPIOA) || \
|
||||
((__PORT__) == EXTI_GPIOB) || \
|
||||
((__PORT__) == EXTI_GPIOF))
|
||||
|
||||
#define IS_EXTI_GPIO_PIN(__PIN__) ((__PIN__) < 16u)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/** @defgroup EXTI_Exported_Functions EXTI Exported Functions
|
||||
* @brief EXTI Exported Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup EXTI_Exported_Functions_Group1 Configuration functions
|
||||
* @brief Configuration functions
|
||||
* @{
|
||||
*/
|
||||
/* Configuration functions ****************************************************/
|
||||
HAL_StatusTypeDef HAL_EXTI_SetConfigLine(EXTI_HandleTypeDef *hexti, EXTI_ConfigTypeDef *pExtiConfig);
|
||||
HAL_StatusTypeDef HAL_EXTI_GetConfigLine(EXTI_HandleTypeDef *hexti, EXTI_ConfigTypeDef *pExtiConfig);
|
||||
HAL_StatusTypeDef HAL_EXTI_ClearConfigLine(EXTI_HandleTypeDef *hexti);
|
||||
HAL_StatusTypeDef HAL_EXTI_RegisterCallback(EXTI_HandleTypeDef *hexti, EXTI_CallbackIDTypeDef CallbackID, void (*pPendingCbfn)(void));
|
||||
HAL_StatusTypeDef HAL_EXTI_GetHandle(EXTI_HandleTypeDef *hexti, uint32_t ExtiLine);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup EXTI_Exported_Functions_Group2 IO operation functions
|
||||
* @brief IO operation functions
|
||||
* @{
|
||||
*/
|
||||
/* IO operation functions *****************************************************/
|
||||
void HAL_EXTI_IRQHandler(EXTI_HandleTypeDef *hexti);
|
||||
uint32_t HAL_EXTI_GetPending(EXTI_HandleTypeDef *hexti, uint32_t Edge);
|
||||
void HAL_EXTI_ClearPending(EXTI_HandleTypeDef *hexti);
|
||||
void HAL_EXTI_GenerateSWI(EXTI_HandleTypeDef *hexti);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __PY32F0xx_HAL_EXTI_H */
|
||||
|
||||
/************************ (C) COPYRIGHT Puya *****END OF FILE****/
|
||||
658
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_flash.h
Normal file
658
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_flash.h
Normal file
@@ -0,0 +1,658 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file py32f0xx_hal_flash.h
|
||||
* @author MCU Application Team
|
||||
* @brief Header file of FLASH HAL module.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) Puya Semiconductor Co.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __PY32F0xx_HAL_FLASH_H
|
||||
#define __PY32F0xx_HAL_FLASH_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "py32f0xx_hal_def.h"
|
||||
|
||||
/** @addtogroup PY32F0xx_HAL_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup FLASH
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/** @defgroup FLASH_Exported_Types FLASH Exported Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief FLASH Erase structure definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t TypeErase; /*!< Mass erase or page erase.
|
||||
This parameter can be a value of @ref FLASH_Type_Erase */
|
||||
uint32_t PageAddress; /*!< PageAdress: Initial FLASH page address to erase when mass erase and sector erase is disabled
|
||||
This parameter must be a number between Min_Data = FLASH_BASE and Max_Data = FLASH_END */
|
||||
uint32_t NbPages; /*!< Number of pages to be erased.
|
||||
This parameter must be a value between 1 and (FLASH_PAGE_NB - value of initial page)*/
|
||||
uint32_t SectorAddress; /*!< PageAdress: Initial FLASH page address to erase when mass erase and page erase is disabled
|
||||
This parameter must be a number between Min_Data = FLASH_BASE and Max_Data = FLASH_BANK1_END */
|
||||
uint32_t NbSectors; /*!< Number of sectors to be erased.
|
||||
This parameter must be a value between 1 and (FLASH_SECTOR_NB - value of initial sector)*/
|
||||
|
||||
} FLASH_EraseInitTypeDef;
|
||||
|
||||
/**
|
||||
* @brief FLASH Option Bytes PROGRAM structure definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t OptionType; /*!< OptionType: Option byte to be configured.
|
||||
This parameter can be a value of @ref FLASH_Option_Type */
|
||||
|
||||
uint32_t WRPSector; /*!< WRPSector: This bitfield specifies the sector (s) which are write protected.
|
||||
This parameter can be a combination of @ref FLASH_Option_Bytes_Write_Protection */
|
||||
|
||||
uint32_t SDKStartAddr; /*!< SDK Start address (used for FLASH_SDKR). It represents first address of start block
|
||||
to protect. Make sure this parameter is multiple of SDK granularity: 2048 Bytes.*/
|
||||
|
||||
uint32_t SDKEndAddr; /*!< SDK End address (used for FLASH_SDKR). It represents first address of end block
|
||||
to protect. Make sure this parameter is multiple of SDK granularity: 2048 Bytes.*/
|
||||
|
||||
uint32_t RDPLevel; /*!< RDPLevel: Set the read protection level.
|
||||
This parameter can be a value of @ref FLASH_OB_Read_Protection */
|
||||
|
||||
uint32_t USERType; /*!< User option byte(s) to be configured (used for OPTIONBYTE_USER).
|
||||
This parameter can be a combination of @ref FLASH_OB_USER_Type */
|
||||
|
||||
uint32_t USERConfig; /*!< Value of the user option byte (used for OPTIONBYTE_USER).
|
||||
This parameter can be a combination of
|
||||
@ref FLASH_OB_USER_BOR_ENABLE,
|
||||
@ref FLASH_OB_USER_BOR_LEVEL,
|
||||
@ref FLASH_OB_USER_RESET_CONFIG,
|
||||
@ref FLASH_OB_USER_IWDG_SW,
|
||||
@ref FLASH_OB_USER_WWDG_SW,
|
||||
@ref FLASH_OB_USER_nBOOT1 */
|
||||
} FLASH_OBProgramInitTypeDef;
|
||||
|
||||
/**
|
||||
* @brief FLASH handle Structure definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
HAL_LockTypeDef Lock; /* FLASH locking object */
|
||||
uint32_t ErrorCode; /* FLASH error code */
|
||||
uint32_t ProcedureOnGoing; /* Internal variable to indicate which procedure is ongoing or not in IT context */
|
||||
uint32_t Address; /* Internal variable to save address selected for program in IT context */
|
||||
uint32_t PageOrSector; /* Internal variable to define the current page or sector which is erasing in IT context */
|
||||
uint32_t NbPagesSectorsToErase; /* Internal variable to save the remaining pages to erase in IT context */
|
||||
} FLASH_ProcessTypeDef;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/** @defgroup FLASH_Exported_Constants FLASH Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup FLASH_Latency FLASH Latency
|
||||
* @{
|
||||
*/
|
||||
#define FLASH_LATENCY_0 0x00000000UL /*!< FLASH Zero wait state */
|
||||
#define FLASH_LATENCY_1 FLASH_ACR_LATENCY /*!< FLASH One wait state */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup FLASH_Type_Erase FLASH erase type
|
||||
* @{
|
||||
*/
|
||||
#define FLASH_TYPEERASE_MASSERASE (0x01U) /*!<Flash mass erase activation*/
|
||||
#define FLASH_TYPEERASE_PAGEERASE (0x02U) /*!<Flash Pages erase activation*/
|
||||
#define FLASH_TYPEERASE_SECTORERASE (0x03U)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup FLASH_Flags FLASH Flags Definition
|
||||
* @{
|
||||
*/
|
||||
#define FLASH_FLAG_BSY FLASH_SR_BSY /*!< FLASH Operation Busy flag */
|
||||
#define FLASH_FLAG_OPTVERR FLASH_SR_OPTVERR /*!< FLASH Option validity error flag */
|
||||
#define FLASH_FLAG_WRPERR FLASH_SR_WRPERR /*!< FLASH Write protection error flag */
|
||||
#define FLASH_FLAG_EOP FLASH_SR_EOP /*!< FLASH End of operation flag */
|
||||
|
||||
#define FLASH_FLAG_ALL_ERRORS (FLASH_FLAG_WRPERR | FLASH_FLAG_OPTVERR)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup FLASH_Interrupt_definition FLASH Interrupts Definition
|
||||
* @brief FLASH Interrupt definition
|
||||
* @{
|
||||
*/
|
||||
#define FLASH_IT_EOP FLASH_CR_EOPIE /*!< End of FLASH Operation Interrupt source */
|
||||
#define FLASH_IT_OPERR FLASH_CR_ERRIE /*!< Error Interrupt source */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup FLASH_Error FLASH Error
|
||||
* @{
|
||||
*/
|
||||
#define HAL_FLASH_ERROR_NONE 0x00000000U
|
||||
#define HAL_FLASH_ERROR_WRP FLASH_FLAG_WRPERR
|
||||
#define HAL_FLASH_ERROR_OPTV FLASH_FLAG_OPTVERR
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup FLASH_PROGRAM_ERASE_CLOCK FLASH Program and Erase Clock
|
||||
* @{
|
||||
*/
|
||||
#define FLASH_PROGRAM_ERASE_CLOCK_4MHZ 0x00000000U /*!< 4MHz */
|
||||
#define FLASH_PROGRAM_ERASE_CLOCK_8MHZ 0x00000001U /*!< 8MHz */
|
||||
#define FLASH_PROGRAM_ERASE_CLOCK_16MHZ 0x00000002U /*!< 16MHz */
|
||||
#define FLASH_PROGRAM_ERASE_CLOCK_22p12MHZ 0x00000003U /*!< 22.12MHz */
|
||||
#define FLASH_PROGRAM_ERASE_CLOCK_24MHZ 0x00000004U /*!< 24MHz */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup FLASH_Option_Bytes_Write_Protection FLASH Option Bytes Write Protection
|
||||
* @{
|
||||
*/
|
||||
#define OB_WRP_SECTOR_0 ((uint32_t)0x00000001U) /* Write protection of Sector0 */
|
||||
#define OB_WRP_SECTOR_1 ((uint32_t)0x00000002U) /* Write protection of Sector1 */
|
||||
#define OB_WRP_SECTOR_2 ((uint32_t)0x00000004U) /* Write protection of Sector2 */
|
||||
#define OB_WRP_SECTOR_3 ((uint32_t)0x00000008U) /* Write protection of Sector3 */
|
||||
#define OB_WRP_SECTOR_4 ((uint32_t)0x00000010U) /* Write protection of Sector4 */
|
||||
#define OB_WRP_SECTOR_5 ((uint32_t)0x00000020U) /* Write protection of Sector5 */
|
||||
#define OB_WRP_SECTOR_6 ((uint32_t)0x00000040U) /* Write protection of Sector6 */
|
||||
#define OB_WRP_SECTOR_7 ((uint32_t)0x00000080U) /* Write protection of Sector7 */
|
||||
#define OB_WRP_SECTOR_8 ((uint32_t)0x00000100U) /* Write protection of Sector8 */
|
||||
#define OB_WRP_SECTOR_9 ((uint32_t)0x00000200U) /* Write protection of Sector9 */
|
||||
#define OB_WRP_SECTOR_10 ((uint32_t)0x00000400U) /* Write protection of Sector10 */
|
||||
#define OB_WRP_SECTOR_11 ((uint32_t)0x00000800U) /* Write protection of Sector11 */
|
||||
#define OB_WRP_SECTOR_12 ((uint32_t)0x00001000U) /* Write protection of Sector12 */
|
||||
#define OB_WRP_SECTOR_13 ((uint32_t)0x00002000U) /* Write protection of Sector13 */
|
||||
#define OB_WRP_SECTOR_14 ((uint32_t)0x00004000U) /* Write protection of Sector14 */
|
||||
#define OB_WRP_SECTOR_15 ((uint32_t)0x00008000U) /* Write protection of Sector15 */
|
||||
|
||||
#define OB_WRP_Pages0to31 ((uint32_t)0x00000001U) /* Write protection from page0 to page31 */
|
||||
#define OB_WRP_Pages32to63 ((uint32_t)0x00000002U) /* Write protection from page32 to page63 */
|
||||
#define OB_WRP_Pages64to95 ((uint32_t)0x00000004U) /* Write protection from page64 to page95 */
|
||||
#define OB_WRP_Pages96to127 ((uint32_t)0x00000008U) /* Write protection from page96 to page127 */
|
||||
#define OB_WRP_Pages128to159 ((uint32_t)0x00000010U) /* Write protection from page128 to page159 */
|
||||
#define OB_WRP_Pages160to191 ((uint32_t)0x00000020U) /* Write protection from page160 to page191 */
|
||||
#define OB_WRP_Pages192to223 ((uint32_t)0x00000040U) /* Write protection from page192 to page223 */
|
||||
#define OB_WRP_Pages224to255 ((uint32_t)0x00000080U) /* Write protection from page224 to page255 */
|
||||
#define OB_WRP_Pages256to287 ((uint32_t)0x00000100U) /* Write protection from page256 to page287 */
|
||||
#define OB_WRP_Pages288to319 ((uint32_t)0x00000200U) /* Write protection from page288 to page319 */
|
||||
#define OB_WRP_Pages320to351 ((uint32_t)0x00000400U) /* Write protection from page320 to page351 */
|
||||
#define OB_WRP_Pages352to383 ((uint32_t)0x00000800U) /* Write protection from page352 to page383 */
|
||||
#define OB_WRP_Pages384to415 ((uint32_t)0x00001000U) /* Write protection from page384 to page415 */
|
||||
#define OB_WRP_Pages416to447 ((uint32_t)0x00002000U) /* Write protection from page416 to page447 */
|
||||
#define OB_WRP_Pages448to479 ((uint32_t)0x00004000U) /* Write protection from page448 to page479 */
|
||||
#define OB_WRP_Pages480to511 ((uint32_t)0x00008000U) /* Write protection from page480 to page511 */
|
||||
|
||||
#define OB_WRP_AllPages ((uint32_t)0x0000FFFFU) /*!< Write protection of all Sectors */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup FLASH_OB_Read_Protection FLASH Option Bytes Read Protection
|
||||
* @{
|
||||
*/
|
||||
#define OB_RDP_LEVEL_0 ((uint8_t)0xAAU)
|
||||
#define OB_RDP_LEVEL_1 ((uint8_t)0x55U)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup FLASH_OB_USER_Type FLASH User Option Type
|
||||
* @{
|
||||
*/
|
||||
#define OB_USER_BOR_EN FLASH_OPTR_BOR_EN
|
||||
#define OB_USER_BOR_LEV FLASH_OPTR_BOR_LEV
|
||||
#define OB_USER_IWDG_SW FLASH_OPTR_IWDG_SW
|
||||
#if defined(FLASH_OPTR_WWDG_SW)
|
||||
#define OB_USER_WWDG_SW FLASH_OPTR_WWDG_SW
|
||||
#endif
|
||||
#define OB_USER_NRST_MODE FLASH_OPTR_NRST_MODE
|
||||
#define OB_USER_nBOOT1 FLASH_OPTR_nBOOT1
|
||||
#if defined(FLASH_OPTR_WWDG_SW)
|
||||
#define OB_USER_ALL (OB_USER_BOR_EN | OB_USER_BOR_LEV | OB_USER_IWDG_SW | \
|
||||
OB_USER_WWDG_SW | OB_USER_NRST_MODE | OB_USER_nBOOT1)
|
||||
#else
|
||||
#define OB_USER_ALL (OB_USER_BOR_EN | OB_USER_BOR_LEV | OB_USER_IWDG_SW | \
|
||||
OB_USER_NRST_MODE | OB_USER_nBOOT1)
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup FLASH_Type_Program FLASH type program
|
||||
* @{
|
||||
*/
|
||||
#define FLASH_TYPEPROGRAM_PAGE (0x01U) /*!<Program 128bytes at a specified address.*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup FLASH_OB_USER_BOR_ENABLE FLASH Option Bytes BOR Level
|
||||
* @{
|
||||
*/
|
||||
#define OB_BOR_DISABLE 0x00000000U /*!< BOR Reset set to default */
|
||||
#define OB_BOR_ENABLE FLASH_OPTR_BOR_EN /*!< Use option byte to define BOR thresholds */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup FLASH_OB_USER_BOR_LEVEL FLASH Option Bytes BOR Level
|
||||
* @{
|
||||
*/
|
||||
#define OB_BOR_LEVEL_1p7_1p8 ((uint32_t)0x0000U) /*!< BOR Reset threshold levels for 1.7V - 1.8V VDD power supply */
|
||||
#define OB_BOR_LEVEL_1p9_2p0 ((uint32_t)FLASH_OPTR_BOR_LEV_0) /*!< BOR Reset threshold levels for 1.9V - 2.0V VDD power supply */
|
||||
#define OB_BOR_LEVEL_2p1_2p2 ((uint32_t)FLASH_OPTR_BOR_LEV_1) /*!< BOR Reset threshold levels for 2.1V - 2.2V VDD power supply */
|
||||
#define OB_BOR_LEVEL_2p3_2p4 ((uint32_t)(FLASH_OPTR_BOR_LEV_0 | FLASH_OPTR_BOR_LEV_1)) /*!< BOR Reset threshold levels for 2.3V - 2.4V VDD power supply */
|
||||
#define OB_BOR_LEVEL_2p5_2p6 ((uint32_t)FLASH_OPTR_BOR_LEV_2) /*!< BOR Reset threshold levels for 2.5V - 2.6V VDD power supply */
|
||||
#define OB_BOR_LEVEL_2p7_2p8 ((uint32_t)(FLASH_OPTR_BOR_LEV_0 | FLASH_OPTR_BOR_LEV_2)) /*!< BOR Reset threshold levels for 2.7V - 2.8V VDD power supply */
|
||||
#define OB_BOR_LEVEL_2p9_3p0 ((uint32_t)(FLASH_OPTR_BOR_LEV_1 | FLASH_OPTR_BOR_LEV_2)) /*!< BOR Reset threshold levels for 2.9V - 3.0V VDD power supply */
|
||||
#define OB_BOR_LEVEL_3p1_3p2 ((uint32_t)(FLASH_OPTR_BOR_LEV_0 | FLASH_OPTR_BOR_LEV_1 | FLASH_OPTR_BOR_LEV_2)) /*!< BOR Reset threshold levels for 3.1V - 3.2V VDD power supply */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup FLASH_Option_Type FLASH Option Type
|
||||
* @{
|
||||
*/
|
||||
#define OPTIONBYTE_WRP ((uint32_t)0x01U) /*!<WRP option byte configuration*/
|
||||
#define OPTIONBYTE_SDK ((uint32_t)0x02U) /*!<SDK option byte configuration*/
|
||||
#define OPTIONBYTE_RDP ((uint32_t)0x04U) /*!<RDP option byte configuration*/
|
||||
#define OPTIONBYTE_USER ((uint32_t)0x08U) /*!<USER option byte configuration*/
|
||||
#define OPTIONBYTE_ALL (OPTIONBYTE_WRP | \
|
||||
OPTIONBYTE_SDK | \
|
||||
OPTIONBYTE_RDP | \
|
||||
OPTIONBYTE_USER)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup FLASH_WRP_State FLASH WRP State
|
||||
* @{
|
||||
*/
|
||||
#define OB_WRPSTATE_DISABLE ((uint32_t)0x00U) /*!<Disable the write protection of the desired sectors*/
|
||||
#define OB_WRPSTATE_ENABLE ((uint32_t)0x01U) /*!<Enable the write protection of the desired sectors*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup FLASH_OB_USER_IWDG_SW FLASH Option Bytes IWatchdog
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define OB_IWDG_SW FLASH_OPTR_IWDG_SW /*!< Software IWDG selected */
|
||||
#define OB_IWDG_HW 0x00000000U /*!< Hardware IWDG selected */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#if defined(FLASH_OPTR_WWDG_SW)
|
||||
/** @defgroup FLASH_OB_USER_WWDG_SW FLASH Option Bytes WWatchdog
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define OB_WWDG_SW FLASH_OPTR_WWDG_SW /*!< Software WWDG selected */
|
||||
#define OB_WWDG_HW 0x00000000U /*!< Hardware WWDG selected */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup FLASH_OB_USER_RESET_CONFIG FLASH Option Bytes User reset config bit
|
||||
* @{
|
||||
*/
|
||||
#define OB_RESET_MODE_RESET 0x00000000U /*!< Reset pin is in Reset input mode only */
|
||||
#define OB_RESET_MODE_GPIO FLASH_OPTR_NRST_MODE /*!< Reset pin is in GPIO mode mode only */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup FLASH_OB_USER_nBOOT1 FLASH Option Bytes BOOT Bit1 Setup
|
||||
* @{
|
||||
*/
|
||||
#define OB_BOOT1_SRAM 0x00000000U /*!< BOOT Bit 1 Reset */
|
||||
#define OB_BOOT1_SYSTEM FLASH_OPTR_nBOOT1 /*!< BOOT Bit 1 Set */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported macros -----------------------------------------------------------*/
|
||||
/** @defgroup FLASH_Exported_Macros FLASH Exported Macros
|
||||
* @brief macros to control FLASH features
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Set the FLASH Latency.
|
||||
* @param __LATENCY__ FLASH Latency
|
||||
* This parameter can be one of the following values :
|
||||
*
|
||||
* @arg @ref FLASH_ACR_LATENCY FLASH One wait state
|
||||
*
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_FLASH_SET_LATENCY(__LATENCY__) MODIFY_REG(FLASH->ACR, FLASH_ACR_LATENCY, (__LATENCY__))
|
||||
|
||||
/**
|
||||
* @brief Get the FLASH Latency.
|
||||
* @retval FLASH Latency
|
||||
* Returned value can be one of the following values :
|
||||
* @arg @ref FLASH_LATENCY_0 FLASH Zero wait state
|
||||
* @arg @ref FLASH_LATENCY_1 FLASH One wait state
|
||||
*
|
||||
*/
|
||||
#define __HAL_FLASH_GET_LATENCY() READ_BIT(FLASH->ACR, FLASH_ACR_LATENCY)
|
||||
|
||||
/** @defgroup FLASH_Interrupt FLASH Interrupts Macros
|
||||
* @brief macros to handle FLASH interrupts
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Enable the specified FLASH interrupt.
|
||||
* @param __INTERRUPT__ FLASH interrupt
|
||||
* This parameter can be any combination of the following values:
|
||||
* @arg @ref FLASH_IT_EOP End of FLASH Operation Interrupt
|
||||
* @arg @ref FLASH_IT_OPERR Error Interrupt
|
||||
* @note (*) availability depends on devices
|
||||
* @retval none
|
||||
*/
|
||||
#define __HAL_FLASH_ENABLE_IT(__INTERRUPT__) SET_BIT(FLASH->CR, (__INTERRUPT__))
|
||||
|
||||
/**
|
||||
* @brief Disable the specified FLASH interrupt.
|
||||
* @param __INTERRUPT__ FLASH interrupt
|
||||
* This parameter can be any combination of the following values:
|
||||
* @arg @ref FLASH_IT_EOP End of FLASH Operation Interrupt
|
||||
* @arg @ref FLASH_IT_OPERR Error Interrupt
|
||||
* @note (*) availability depends on devices
|
||||
* @retval none
|
||||
*/
|
||||
#define __HAL_FLASH_DISABLE_IT(__INTERRUPT__) CLEAR_BIT(FLASH->CR, (__INTERRUPT__))
|
||||
|
||||
/**
|
||||
* @brief Check whether the specified FLASH flag is set or not.
|
||||
* @param __FLAG__ specifies the FLASH flag to check.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg @ref FLASH_FLAG_EOP FLASH End of Operation flag
|
||||
* @arg @ref FLASH_FLAG_WRPERR FLASH Write protection error flag
|
||||
* @arg @ref FLASH_FLAG_OPTVERR FLASH Option validity error flag
|
||||
* @arg @ref FLASH_FLAG_BSY FLASH write/erase operations in progress flag
|
||||
* @arg @ref FLASH_FLAG_ALL_ERRORS FLASH All errors flags
|
||||
* @note (*) availability depends on devices
|
||||
* @retval The new state of FLASH_FLAG (SET or RESET).
|
||||
*/
|
||||
#define __HAL_FLASH_GET_FLAG(__FLAG__) (READ_BIT(FLASH->SR, (__FLAG__)) == (__FLAG__))
|
||||
|
||||
/**
|
||||
* @brief Clear the FLASHs pending flags.
|
||||
* @param __FLAG__ specifies the FLASH flags to clear.
|
||||
* This parameter can be any combination of the following values:
|
||||
* @arg @ref FLASH_FLAG_EOP FLASH End of Operation flag
|
||||
* @arg @ref FLASH_FLAG_WRPERR FLASH Write protection error flag
|
||||
* @arg @ref FLASH_FLAG_OPTVERR FLASH Option validity error flag
|
||||
* @arg @ref FLASH_FLAG_ALL_ERRORS FLASH All errors flags
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_FLASH_CLEAR_FLAG(__FLAG__) do { WRITE_REG(FLASH->SR, (__FLAG__)); \
|
||||
} while(0U)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#define __HAL_FLASH_TIME_REG_SET(__EPPARA0__,__EPPARA1__,__EPPARA2__,__EPPARA3__,__EPPARA4__) \
|
||||
do { \
|
||||
FLASH->TS0 = (__EPPARA0__)&0xFF; \
|
||||
FLASH->TS1 = ((__EPPARA0__)>>16)&0x1FF; \
|
||||
FLASH->TS3 = ((__EPPARA0__)>>8)&0xFF; \
|
||||
FLASH->TS2P = (__EPPARA1__)&0xFF; \
|
||||
FLASH->TPS3 = ((__EPPARA1__)>>16)&0x7FF; \
|
||||
FLASH->PERTPE = (__EPPARA2__)&0x1FFFF; \
|
||||
FLASH->SMERTPE = (__EPPARA3__)&0x1FFFF; \
|
||||
FLASH->PRGTPE = (__EPPARA4__)&0xFFFF; \
|
||||
FLASH->PRETPE = ((__EPPARA4__)>>16)&0x3FFF; \
|
||||
} while(0U)
|
||||
|
||||
#define __HAL_FLASH_IS_INVALID_TIMMING_SEQUENCE(_INDEX_) (((FLASH->TS0) != ((*(uint32_t *)(_FlashTimmingParam[_INDEX_]))&0xFF)) || \
|
||||
((FLASH->TS1) != (((*(uint32_t *)(_FlashTimmingParam[_INDEX_]))>>16)&0x1FF)) || \
|
||||
((FLASH->TS3) != (((*(uint32_t *)(_FlashTimmingParam[_INDEX_]))>>8)&0xFF)) || \
|
||||
((FLASH->TS2P) != ((*(uint32_t *)(_FlashTimmingParam[_INDEX_]+4))&0xFF)) || \
|
||||
((FLASH->TPS3) != (((*(uint32_t *)(_FlashTimmingParam[_INDEX_]+4))>>16)&0x7FF)) || \
|
||||
((FLASH->PERTPE) != ((*(uint32_t *)(_FlashTimmingParam[_INDEX_]+8))&0x1FFFF)) || \
|
||||
((FLASH->SMERTPE) != ((*(uint32_t *)(_FlashTimmingParam[_INDEX_]+12))&0x1FFFF)) || \
|
||||
((FLASH->PRGTPE) != ((*(uint32_t *)(_FlashTimmingParam[_INDEX_]+16))&0xFFFF)) || \
|
||||
((FLASH->PRETPE) != (((*(uint32_t *)(_FlashTimmingParam[_INDEX_]+16))>>16)&0x3FFF)))
|
||||
|
||||
#define __HAL_FLASH_TIMMING_SEQUENCE_CONFIG() do{ \
|
||||
uint32_t tmpreg = (RCC->ICSCR & RCC_ICSCR_HSI_FS) >> RCC_ICSCR_HSI_FS_Pos; \
|
||||
if (__HAL_FLASH_IS_INVALID_TIMMING_SEQUENCE(tmpreg)) \
|
||||
{ \
|
||||
__HAL_FLASH_TIME_REG_SET((*(uint32_t *)(_FlashTimmingParam[tmpreg])), \
|
||||
(*(uint32_t *)(_FlashTimmingParam[tmpreg]+4)), \
|
||||
(*(uint32_t *)(_FlashTimmingParam[tmpreg]+8)), \
|
||||
(*(uint32_t *)(_FlashTimmingParam[tmpreg]+12)), \
|
||||
(*(uint32_t *)(_FlashTimmingParam[tmpreg]+16))); \
|
||||
} \
|
||||
}while(0U)
|
||||
|
||||
/* Include FLASH HAL Extended module */
|
||||
/* Exported variables --------------------------------------------------------*/
|
||||
/** @defgroup FLASH_Exported_Variables FLASH Exported Variables
|
||||
* @{
|
||||
*/
|
||||
extern FLASH_ProcessTypeDef pFlash;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/** @addtogroup FLASH_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Program operation functions ***********************************************/
|
||||
/** @addtogroup FLASH_Exported_Functions_Group1
|
||||
* @{
|
||||
*/
|
||||
HAL_StatusTypeDef HAL_FLASH_Program(uint32_t TypeProgram, uint32_t Address, uint32_t *DataAddr );
|
||||
HAL_StatusTypeDef HAL_FLASH_Program_IT(uint32_t TypeProgram, uint32_t Address, uint32_t *DataAddr);
|
||||
HAL_StatusTypeDef HAL_FLASH_PageProgram(uint32_t Address, uint32_t *DataAddr );
|
||||
HAL_StatusTypeDef HAL_FLASH_PageProgram_IT(uint32_t Address, uint32_t *DataAddr);
|
||||
/* FLASH IRQ handler method */
|
||||
void HAL_FLASH_IRQHandler(void);
|
||||
/* Callbacks in non blocking modes */
|
||||
void HAL_FLASH_EndOfOperationCallback(uint32_t ReturnValue);
|
||||
void HAL_FLASH_OperationErrorCallback(uint32_t ReturnValue);
|
||||
HAL_StatusTypeDef HAL_FLASH_Erase(FLASH_EraseInitTypeDef *pEraseInit, uint32_t *PageError);
|
||||
HAL_StatusTypeDef HAL_FLASH_Erase_IT(FLASH_EraseInitTypeDef *pEraseInit);
|
||||
|
||||
#define HAL_FLASHEx_Erase HAL_FLASH_Erase
|
||||
#define HAL_FLASHEx_Erase_IT HAL_FLASH_Erase_IT
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Peripheral Control functions **********************************************/
|
||||
/** @addtogroup FLASH_Exported_Functions_Group2
|
||||
* @{
|
||||
*/
|
||||
HAL_StatusTypeDef HAL_FLASH_Unlock(void);
|
||||
HAL_StatusTypeDef HAL_FLASH_Lock(void);
|
||||
/* Option bytes control */
|
||||
HAL_StatusTypeDef HAL_FLASH_OB_Unlock(void);
|
||||
HAL_StatusTypeDef HAL_FLASH_OB_Lock(void);
|
||||
HAL_StatusTypeDef HAL_FLASH_OB_Launch(void);
|
||||
HAL_StatusTypeDef HAL_FLASH_OBProgram(FLASH_OBProgramInitTypeDef *pOBInit);
|
||||
void HAL_FLASH_OBGetConfig(FLASH_OBProgramInitTypeDef *pOBInit);
|
||||
HAL_StatusTypeDef HAL_FLASH_OB_RDP_LevelConfig(uint8_t ReadProtectLevel);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Peripheral State functions ************************************************/
|
||||
/** @addtogroup FLASH_Exported_Functions_Group3
|
||||
* @{
|
||||
*/
|
||||
uint32_t HAL_FLASH_GetError(void);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Private types --------------------------------------------------------*/
|
||||
/** @defgroup FLASH_Private_types FLASH Private Types
|
||||
* @{
|
||||
*/
|
||||
HAL_StatusTypeDef FLASH_WaitForLastOperation(uint32_t Timeout);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Private constants --------------------------------------------------------*/
|
||||
/** @defgroup FLASH_Private_Constants FLASH Private Constants
|
||||
* @{
|
||||
*/
|
||||
#define FLASH_TIMEOUT_VALUE 1000U /*!< FLASH Execution Timeout, 1 s */
|
||||
|
||||
#define FLASH_TYPENONE 0x00000000U /*!< No Programmation Procedure On Going */
|
||||
|
||||
#define FLASH_FLAG_SR_ERROR (FLASH_FLAG_OPTVERR | FLASH_FLAG_WRPERR) /*!< All SR error flags */
|
||||
|
||||
#define FLASH_FLAG_SR_CLEAR (FLASH_FLAG_SR_ERROR | FLASH_SR_EOP)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Private macros ------------------------------------------------------------*/
|
||||
/** @defgroup FLASH_Private_Macros FLASH Private Macros
|
||||
* @{
|
||||
*/
|
||||
#define IS_FLASH_MAIN_MEM_ADDRESS(__ADDRESS__) (((__ADDRESS__) >= (FLASH_BASE)) && ((__ADDRESS__) <= (FLASH_BASE + FLASH_SIZE - 1UL)))
|
||||
|
||||
#define IS_FLASH_PROGRAM_MAIN_MEM_ADDRESS(__ADDRESS__) (((__ADDRESS__) >= (FLASH_BASE)) && ((__ADDRESS__) <= (FLASH_BASE + FLASH_SIZE - 8UL)))
|
||||
|
||||
#define IS_FLASH_PROGRAM_ADDRESS(__ADDRESS__) (IS_FLASH_PROGRAM_MAIN_MEM_ADDRESS(__ADDRESS__))
|
||||
|
||||
#define IS_FLASH_NB_PAGES(__ADDRESS__, __VALUE__) (((__ADDRESS__) >= (FLASH_BASE)) && ((__ADDRESS__ + (__VALUE__*FLASH_PAGE_SIZE)) <= (FLASH_BASE + FLASH_SIZE - 1UL)))
|
||||
|
||||
#define IS_FLASH_NB_SECTORS(__ADDRESS__, __VALUE__) (((__ADDRESS__) >= (FLASH_BASE)) && ((__ADDRESS__ + (__VALUE__*FLASH_SECTOR_SIZE)) <= (FLASH_BASE + FLASH_SIZE - 1UL)))
|
||||
|
||||
#define IS_FLASH_FAST_PROGRAM_ADDRESS(__ADDRESS__) (((__ADDRESS__) >= (FLASH_BASE)) && ((__ADDRESS__) <= (FLASH_BASE + FLASH_SIZE - 256UL)))
|
||||
|
||||
#define IS_FLASH_PAGE(__PAGE__) ((__PAGE__) < FLASH_PAGE_NB)
|
||||
|
||||
#define IS_FLASH_BANK(__BANK__) ((__BANK__) == 0x00UL)
|
||||
|
||||
#define IS_FLASH_TYPEERASE(__VALUE__) (((__VALUE__) == FLASH_TYPEERASE_PAGEERASE) || \
|
||||
((__VALUE__) == FLASH_TYPEERASE_SECTORERASE) || \
|
||||
((__VALUE__) == FLASH_TYPEERASE_MASSERASE))
|
||||
|
||||
#define IS_FLASH_TYPEPROGRAM(__VALUE__) ((__VALUE__) == FLASH_TYPEPROGRAM_PAGE)
|
||||
|
||||
#define IS_FLASH_TIMECONFIG_CLOCK(__VALUE__) (((__VALUE__) == FLASH_PROGRAM_ERASE_CLOCK_4MHZ) || \
|
||||
((__VALUE__) == FLASH_PROGRAM_ERASE_CLOCK_8MHZ) || \
|
||||
((__VALUE__) == FLASH_PROGRAM_ERASE_CLOCK_16MHZ) || \
|
||||
((__VALUE__) == FLASH_PROGRAM_ERASE_CLOCK_22p12MHZ) || \
|
||||
((__VALUE__) == FLASH_PROGRAM_ERASE_CLOCK_24MHZ))
|
||||
|
||||
#define IS_OPTIONBYTE(__VALUE__) ((((__VALUE__) & OPTIONBYTE_ALL) != 0x00U) && \
|
||||
(((__VALUE__) & ~OPTIONBYTE_ALL) == 0x00U))
|
||||
|
||||
#define IS_OB_RDP_LEVEL(__LEVEL__) (((__LEVEL__) == OB_RDP_LEVEL_0) ||\
|
||||
((__LEVEL__) == OB_RDP_LEVEL_1))
|
||||
|
||||
#define IS_OB_USER_TYPE(__TYPE__) ((((__TYPE__) & OB_USER_ALL) != 0x00U) && \
|
||||
(((__TYPE__) & ~OB_USER_ALL) == 0x00U))
|
||||
|
||||
#define IS_OB_USER_CONFIG(__TYPE__,__CONFIG__) ((~(__TYPE__) & (__CONFIG__)) == 0x00U)
|
||||
|
||||
#if defined(FLASH_PCROP_SUPPORT)
|
||||
#define IS_OB_PCROP_CONFIG(__CONFIG__) (((__CONFIG__) & ~(OB_PCROP_ZONE_A | OB_PCROP_ZONE_B | OB_PCROP_RDP_ERASE)) == 0x00U)
|
||||
#endif
|
||||
|
||||
#if defined(FLASH_SECURABLE_MEMORY_SUPPORT)
|
||||
#define IS_OB_SEC_BOOT_LOCK(__VALUE__) (((__VALUE__) == OB_BOOT_ENTRY_FORCED_NONE) || ((__VALUE__) == OB_BOOT_ENTRY_FORCED_FLASH))
|
||||
|
||||
#define IS_OB_SEC_SIZE(__VALUE__) ((__VALUE__) < (FLASH_PAGE_NB + 1U))
|
||||
#endif
|
||||
|
||||
#define IS_FLASH_LATENCY(__LATENCY__) (((__LATENCY__) == FLASH_LATENCY_0) || \
|
||||
((__LATENCY__) == FLASH_LATENCY_1))
|
||||
|
||||
#define IS_WRPSTATE(__VALUE__) (((__VALUE__) == OB_WRPSTATE_DISABLE) || \
|
||||
((__VALUE__) == OB_WRPSTATE_ENABLE))
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __PY32F0xx_HAL_FLASH_H */
|
||||
|
||||
/************************ (C) COPYRIGHT Puya *****END OF FILE****/
|
||||
@@ -0,0 +1,122 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file py32f0xx_hal_flash_ex.h
|
||||
* @author MCU Application Team
|
||||
* @brief Header file of FLASH HAL Extended module.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) Puya Semiconductor Co.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __PY32F0xx_HAL_FLASH_EX_H
|
||||
#define __PY32F0xx_HAL_FLASH_EX_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "py32f0xx_hal_def.h"
|
||||
|
||||
/** @addtogroup PY32F0xx_HAL_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup FLASHEx
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/** @defgroup FLASHEx_Exported_Constants FLASH Exported Constants
|
||||
* @{
|
||||
*/
|
||||
/** @defgroup FLASHEx_Empty_Check FLASHEx Empty Check
|
||||
* @{
|
||||
*/
|
||||
#define FLASH_PROG_NOT_EMPTY 0x00000000u /*!< 1st location in Flash is programmed */
|
||||
#define FLASH_PROG_EMPTY FLASH_ACR_PROGEMPTY /*!< 1st location in Flash is empty */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/** @addtogroup FLASHEx_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Extended Program operation functions *************************************/
|
||||
/** @addtogroup FLASHEx_Exported_Functions_Group1
|
||||
* @{
|
||||
*/
|
||||
HAL_StatusTypeDef HAL_FLASHEx_Erase(FLASH_EraseInitTypeDef *pEraseInit, uint32_t *PageError);
|
||||
HAL_StatusTypeDef HAL_FLASHEx_Erase_IT(FLASH_EraseInitTypeDef *pEraseInit);
|
||||
void HAL_FLASHEx_EnableDebugger(void);
|
||||
void HAL_FLASHEx_DisableDebugger(void);
|
||||
uint32_t HAL_FLASHEx_FlashEmptyCheck(void);
|
||||
void HAL_FLASHEx_ForceFlashEmpty(uint32_t FlashEmpty);
|
||||
#if defined(FLASH_SECURABLE_MEMORY_SUPPORT)
|
||||
void HAL_FLASHEx_EnableSecMemProtection(uint32_t Bank);
|
||||
#endif
|
||||
HAL_StatusTypeDef HAL_FLASHEx_OBProgram(FLASH_OBProgramInitTypeDef *pOBInit);
|
||||
void HAL_FLASHEx_OBGetConfig(FLASH_OBProgramInitTypeDef *pOBInit);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Private macros ------------------------------------------------------------*/
|
||||
/** @defgroup FLASHEx_Private_Constants FLASHEx Private Constants
|
||||
* @{
|
||||
*/
|
||||
#define FLASH_PCROP_GRANULARITY_OFFSET 9u /*!< FLASH Code Readout Protection granularity offset */
|
||||
#define FLASH_PCROP_GRANULARITY (1UL << FLASH_PCROP_GRANULARITY_OFFSET) /*!< FLASH Code Readout Protection granularity, 512 Bytes */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup FLASHEx_Private_Macros FLASHEx Private Macros
|
||||
* @{
|
||||
*/
|
||||
#define IS_FLASH_EMPTY_CHECK(__VALUE__) (((__VALUE__) == FLASH_PROG_EMPTY) || ((__VALUE__) == FLASH_PROG_NOT_EMPTY))
|
||||
void FLASH_PageErase(uint32_t Page);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __PY32F0xx_HAL_FLASH_EX_H */
|
||||
|
||||
/************************ (C) COPYRIGHT Puya *****END OF FILE****/
|
||||
305
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_gpio.h
Normal file
305
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_gpio.h
Normal file
@@ -0,0 +1,305 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file py32f0xx_hal_gpio.h
|
||||
* @author MCU Application Team
|
||||
* @brief Header file of GPIO HAL module.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) Puya Semiconductor Co.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __PY32F0xx_HAL_GPIO_H
|
||||
#define __PY32F0xx_HAL_GPIO_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "py32f0xx_hal_def.h"
|
||||
|
||||
/** @addtogroup PY32F0xx_HAL_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup GPIO GPIO
|
||||
* @brief GPIO HAL module driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
|
||||
/** @defgroup GPIO_Exported_Types GPIO Exported Types
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief GPIO Init structure definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t Pin; /*!< Specifies the GPIO pins to be configured.
|
||||
This parameter can be any value of @ref GPIO_pins */
|
||||
|
||||
uint32_t Mode; /*!< Specifies the operating mode for the selected pins.
|
||||
This parameter can be a value of @ref GPIO_mode */
|
||||
|
||||
uint32_t Pull; /*!< Specifies the Pull-Up or Pull-Down activation for the selected pins.
|
||||
This parameter can be a value of @ref GPIO_pull */
|
||||
|
||||
uint32_t Speed; /*!< Specifies the speed for the selected pins.
|
||||
This parameter can be a value of @ref GPIO_speed */
|
||||
|
||||
uint32_t Alternate; /*!< Peripheral to be connected to the selected pins
|
||||
This parameter can be a value of @ref GPIOEx_Alternate_function_selection */
|
||||
} GPIO_InitTypeDef;
|
||||
|
||||
/**
|
||||
* @brief GPIO Bit SET and Bit RESET enumeration
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GPIO_PIN_RESET = 0U,
|
||||
GPIO_PIN_SET
|
||||
} GPIO_PinState;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/** @defgroup GPIO_Exported_Constants GPIO Exported Constants
|
||||
* @{
|
||||
*/
|
||||
/** @defgroup GPIO_pins GPIO pins
|
||||
* @{
|
||||
*/
|
||||
#define GPIO_PIN_0 ((uint16_t)0x0001) /* Pin 0 selected */
|
||||
#define GPIO_PIN_1 ((uint16_t)0x0002) /* Pin 1 selected */
|
||||
#define GPIO_PIN_2 ((uint16_t)0x0004) /* Pin 2 selected */
|
||||
#define GPIO_PIN_3 ((uint16_t)0x0008) /* Pin 3 selected */
|
||||
#define GPIO_PIN_4 ((uint16_t)0x0010) /* Pin 4 selected */
|
||||
#define GPIO_PIN_5 ((uint16_t)0x0020) /* Pin 5 selected */
|
||||
#define GPIO_PIN_6 ((uint16_t)0x0040) /* Pin 6 selected */
|
||||
#define GPIO_PIN_7 ((uint16_t)0x0080) /* Pin 7 selected */
|
||||
#define GPIO_PIN_8 ((uint16_t)0x0100) /* Pin 8 selected */
|
||||
#define GPIO_PIN_9 ((uint16_t)0x0200) /* Pin 9 selected */
|
||||
#define GPIO_PIN_10 ((uint16_t)0x0400) /* Pin 10 selected */
|
||||
#define GPIO_PIN_11 ((uint16_t)0x0800) /* Pin 11 selected */
|
||||
#define GPIO_PIN_12 ((uint16_t)0x1000) /* Pin 12 selected */
|
||||
#define GPIO_PIN_13 ((uint16_t)0x2000) /* Pin 13 selected */
|
||||
#define GPIO_PIN_14 ((uint16_t)0x4000) /* Pin 14 selected */
|
||||
#define GPIO_PIN_15 ((uint16_t)0x8000) /* Pin 15 selected */
|
||||
#define GPIO_PIN_All ((uint16_t)0xFFFF) /* All pins selected */
|
||||
|
||||
#define GPIO_PIN_MASK (0x0000FFFFu) /* PIN mask for assert test */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup GPIO_mode GPIO mode
|
||||
* @brief GPIO Configuration Mode
|
||||
* Elements values convention: 0xX0yz00YZ
|
||||
* - X : GPIO mode or EXTI Mode
|
||||
* - y : External IT or Event trigger detection
|
||||
* - z : IO configuration on External IT or Event
|
||||
* - Y : Output type (Push Pull or Open Drain)
|
||||
* - Z : IO Direction mode (Input, Output, Alternate or Analog)
|
||||
* @{
|
||||
*/
|
||||
#define GPIO_MODE_INPUT (0x00000000u) /*!< Input Floating Mode */
|
||||
#define GPIO_MODE_OUTPUT_PP (0x00000001u) /*!< Output Push Pull Mode */
|
||||
#define GPIO_MODE_OUTPUT_OD (0x00000011u) /*!< Output Open Drain Mode */
|
||||
#define GPIO_MODE_AF_PP (0x00000002u) /*!< Alternate Function Push Pull Mode */
|
||||
#define GPIO_MODE_AF_OD (0x00000012u) /*!< Alternate Function Open Drain Mode */
|
||||
#define GPIO_MODE_ANALOG (0x00000003u) /*!< Analog Mode */
|
||||
#define GPIO_MODE_IT_RISING (0x10110000u) /*!< External Interrupt Mode with Rising edge trigger detection */
|
||||
#define GPIO_MODE_IT_FALLING (0x10210000u) /*!< External Interrupt Mode with Falling edge trigger detection */
|
||||
#define GPIO_MODE_IT_RISING_FALLING (0x10310000u) /*!< External Interrupt Mode with Rising/Falling edge trigger detection */
|
||||
#define GPIO_MODE_EVT_RISING (0x10120000u) /*!< External Event Mode with Rising edge trigger detection */
|
||||
#define GPIO_MODE_EVT_FALLING (0x10220000u) /*!< External Event Mode with Falling edge trigger detection */
|
||||
#define GPIO_MODE_EVT_RISING_FALLING (0x10320000u) /*!< External Event Mode with Rising/Falling edge trigger detection */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup GPIO_speed GPIO speed
|
||||
* @brief GPIO Output Maximum frequency
|
||||
* @{
|
||||
*/
|
||||
#define GPIO_SPEED_FREQ_LOW (0x00000000u) /*!< Low speed */
|
||||
#define GPIO_SPEED_FREQ_MEDIUM (0x00000001u) /*!< Medium speed */
|
||||
#define GPIO_SPEED_FREQ_HIGH (0x00000002u) /*!< High speed */
|
||||
#define GPIO_SPEED_FREQ_VERY_HIGH (0x00000003u) /*!< Very high speed */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup GPIO_pull GPIO pull
|
||||
* @brief GPIO Pull-Up or Pull-Down Activation
|
||||
* @{
|
||||
*/
|
||||
#define GPIO_NOPULL (0x00000000u) /*!< No Pull-up or Pull-down activation */
|
||||
#define GPIO_PULLUP (0x00000001u) /*!< Pull-up activation */
|
||||
#define GPIO_PULLDOWN (0x00000002u) /*!< Pull-down activation */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/** @defgroup GPIO_Exported_Macros GPIO Exported Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Check whether the specified EXTI line flag is set or not.
|
||||
* @param __EXTI_LINE__ specifies the EXTI line flag to check.
|
||||
* This parameter can be GPIO_PIN_x where x can be(0..15)
|
||||
* @retval The new state of __EXTI_LINE__ (SET or RESET).
|
||||
*/
|
||||
#define __HAL_GPIO_EXTI_GET_FLAG(__EXTI_LINE__) (EXTI->PR & (__EXTI_LINE__))
|
||||
|
||||
/**
|
||||
* @brief Clear the EXTI's line pending flags.
|
||||
* @param __EXTI_LINE__ specifies the EXTI lines flags to clear.
|
||||
* This parameter can be any combination of GPIO_PIN_x where x can be (0..15)
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_GPIO_EXTI_CLEAR_FLAG(__EXTI_LINE__) (EXTI->PR = (__EXTI_LINE__))
|
||||
|
||||
/**
|
||||
* @brief Check whether the specified EXTI line is asserted or not.
|
||||
* @param __EXTI_LINE__ specifies the EXTI line to check.
|
||||
* This parameter can be GPIO_PIN_x where x can be(0..15)
|
||||
* @retval The new state of __EXTI_LINE__ (SET or RESET).
|
||||
*/
|
||||
#define __HAL_GPIO_EXTI_GET_IT(__EXTI_LINE__) (EXTI->PR & (__EXTI_LINE__))
|
||||
|
||||
/**
|
||||
* @brief Clear the EXTI's line pending bits.
|
||||
* @param __EXTI_LINE__ specifies the EXTI lines to clear.
|
||||
* This parameter can be any combination of GPIO_PIN_x where x can be (0..15)
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_GPIO_EXTI_CLEAR_IT(__EXTI_LINE__) (EXTI->PR = (__EXTI_LINE__))
|
||||
|
||||
/**
|
||||
* @brief Generate a Software interrupt on selected EXTI line.
|
||||
* @param __EXTI_LINE__ specifies the EXTI line to check.
|
||||
* This parameter can be GPIO_PIN_x where x can be(0..15)
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_GPIO_EXTI_GENERATE_SWIT(__EXTI_LINE__) (EXTI->SWIER |= (__EXTI_LINE__))
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Private macros ------------------------------------------------------------*/
|
||||
/** @defgroup GPIO_Private_Macros GPIO Private Macros
|
||||
* @{
|
||||
*/
|
||||
#define IS_GPIO_PIN_ACTION(ACTION) (((ACTION) == GPIO_PIN_RESET) || ((ACTION) == GPIO_PIN_SET))
|
||||
|
||||
#define IS_GPIO_PIN(__PIN__) ((((uint32_t)(__PIN__) & GPIO_PIN_MASK) != 0x00u) &&\
|
||||
(((uint32_t)(__PIN__) & ~GPIO_PIN_MASK) == 0x00u))
|
||||
|
||||
#define IS_GPIO_MODE(__MODE__) (((__MODE__) == GPIO_MODE_INPUT) ||\
|
||||
((__MODE__) == GPIO_MODE_OUTPUT_PP) ||\
|
||||
((__MODE__) == GPIO_MODE_OUTPUT_OD) ||\
|
||||
((__MODE__) == GPIO_MODE_AF_PP) ||\
|
||||
((__MODE__) == GPIO_MODE_AF_OD) ||\
|
||||
((__MODE__) == GPIO_MODE_IT_RISING) ||\
|
||||
((__MODE__) == GPIO_MODE_IT_FALLING) ||\
|
||||
((__MODE__) == GPIO_MODE_IT_RISING_FALLING) ||\
|
||||
((__MODE__) == GPIO_MODE_EVT_RISING) ||\
|
||||
((__MODE__) == GPIO_MODE_EVT_FALLING) ||\
|
||||
((__MODE__) == GPIO_MODE_EVT_RISING_FALLING) ||\
|
||||
((__MODE__) == GPIO_MODE_ANALOG))
|
||||
|
||||
#define IS_GPIO_SPEED(__SPEED__) (((__SPEED__) == GPIO_SPEED_FREQ_LOW) ||\
|
||||
((__SPEED__) == GPIO_SPEED_FREQ_MEDIUM) ||\
|
||||
((__SPEED__) == GPIO_SPEED_FREQ_HIGH) ||\
|
||||
((__SPEED__) == GPIO_SPEED_FREQ_VERY_HIGH))
|
||||
|
||||
#define IS_GPIO_PULL(__PULL__) (((__PULL__) == GPIO_NOPULL) ||\
|
||||
((__PULL__) == GPIO_PULLUP) || \
|
||||
((__PULL__) == GPIO_PULLDOWN))
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Include GPIO HAL Extended module */
|
||||
#include "py32f0xx_hal_gpio_ex.h"
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/** @defgroup GPIO_Exported_Functions GPIO Exported Functions
|
||||
* @brief GPIO Exported Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup GPIO_Exported_Functions_Group1 Initialization/de-initialization functions
|
||||
* @brief Initialization and Configuration functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Initialization and de-initialization functions *****************************/
|
||||
void HAL_GPIO_Init(GPIO_TypeDef *GPIOx, GPIO_InitTypeDef *GPIO_Init);
|
||||
void HAL_GPIO_DeInit(GPIO_TypeDef *GPIOx, uint32_t GPIO_Pin);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup GPIO_Exported_Functions_Group2 IO operation functions
|
||||
* @brief IO operation functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* IO operation functions *****************************************************/
|
||||
GPIO_PinState HAL_GPIO_ReadPin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin);
|
||||
void HAL_GPIO_WritePin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState);
|
||||
void HAL_GPIO_TogglePin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin);
|
||||
HAL_StatusTypeDef HAL_GPIO_LockPin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin);
|
||||
void HAL_GPIO_EXTI_IRQHandler(uint16_t GPIO_Pin);
|
||||
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __PY32F0xx_HAL_GPIO_H */
|
||||
|
||||
/************************ (C) COPYRIGHT Puya *****END OF FILE****/
|
||||
@@ -0,0 +1,278 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file py32f0xx_hal_gpio_ex.h
|
||||
* @author MCU Application Team
|
||||
* @brief Header file of GPIO HAL Extended module.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) Puya Semiconductor Co.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __PY32F0xx_HAL_GPIO_EX_H
|
||||
#define __PY32F0xx_HAL_GPIO_EX_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "py32f0xx_hal_def.h"
|
||||
|
||||
/** @addtogroup PY32F0xx_HAL_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup GPIOEx GPIOEx
|
||||
* @brief GPIO Extended HAL module driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/** @defgroup GPIOEx_Exported_Constants GPIOEx Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup GPIOEx_Alternate_function_selection GPIOEx Alternate function selection
|
||||
* @{
|
||||
*/
|
||||
/*------------------------- PY32F0xx ------------------------*/
|
||||
#if (defined(PY32F003PRE)|| defined(PY32F030PRE))
|
||||
/**
|
||||
* @brief AF 0 selection
|
||||
*/
|
||||
|
||||
#define GPIO_AF0_SWJ ((uint8_t)0x00) /*!< SWJ (SWD) Alternate Function mapping */
|
||||
#define GPIO_AF0_SPI1 ((uint8_t)0x00) /*!< SPI1 Alternate Function mapping */
|
||||
#define GPIO_AF0_SPI2 ((uint8_t)0x00) /*!< SPI2 Alternate Function mapping */
|
||||
#define GPIO_AF0_TIM14 ((uint8_t)0x00) /*!< TIM_MB Alternate Function mapping */
|
||||
#define GPIO_AF0_USART1 ((uint8_t)0x00) /*!< USART1 Alternate Function mapping */
|
||||
|
||||
/**
|
||||
* @brief AF 1 selection
|
||||
*/
|
||||
|
||||
#define GPIO_AF1_IR ((uint8_t)0x01) /*!< IR Alternate Function mapping */
|
||||
#define GPIO_AF1_SPI2 ((uint8_t)0x01) /*!< SPI2 Alternate Function mapping */
|
||||
#define GPIO_AF1_TIM1 ((uint8_t)0x01) /*!< TIM1 Alternate Function mapping */
|
||||
#define GPIO_AF1_TIM3 ((uint8_t)0x01) /*!< TIM3 Alternate Function mapping */
|
||||
#define GPIO_AF1_USART1 ((uint8_t)0x01) /*!< USART1 Alternate Function mapping */
|
||||
|
||||
/**
|
||||
* @brief AF 2 selection
|
||||
*/
|
||||
#define GPIO_AF2_SPI2 ((uint8_t)0x02) /*!< SPI2 Alternate Function mapping */
|
||||
#define GPIO_AF2_TIM1 ((uint8_t)0x02) /*!< TIM1 Alternate Function mapping */
|
||||
#define GPIO_AF2_TIM14 ((uint8_t)0x02) /*!< TIM_MB Alternate Function mapping */
|
||||
#define GPIO_AF2_TIM16 ((uint8_t)0x02) /*!< TIM16 Alternate Function mapping */
|
||||
#define GPIO_AF2_TIM17 ((uint8_t)0x02) /*!< TIM17 Alternate Function mapping */
|
||||
|
||||
/**
|
||||
* @brief AF 3 selection
|
||||
*/
|
||||
#define GPIO_AF3_LED ((uint8_t)0x03U) /*!< AF3: LED Alternate Function mapping */
|
||||
#define GPIO_AF3_USART1 ((uint8_t)0x03U) /*!< AF3: USART1 Alternate Function mapping */
|
||||
#define GPIO_AF3_USART2 ((uint8_t)0x03U) /*!< AF3: USART2 Alternate Function mapping */
|
||||
#define GPIO_AF3_SPI2 ((uint8_t)0x03U) /*!< AF3: SPI2 Alternate Function mapping */
|
||||
/**
|
||||
* @brief AF 4 selection
|
||||
*/
|
||||
|
||||
#define GPIO_AF4_TIM14 ((uint8_t)0x04) /*!< TIM_MB Alternate Function mapping */
|
||||
#define GPIO_AF4_USART2 ((uint8_t)0x04) /*!< USART2 Alternate Function mapping */
|
||||
/**
|
||||
* @brief AF 5 selection
|
||||
*/
|
||||
#define GPIO_AF5_LPTIM ((uint8_t)0x05) /*!< LPTIM1 Alternate Function mapping */
|
||||
#define GPIO_AF5_USART2 ((uint8_t)0x05) /*!< USART2 Alternate Function mapping */
|
||||
#define GPIO_AF5_EVENTOUT ((uint8_t)0x05) /*!< EVENTOUT Alternate Function mapping */
|
||||
#define GPIO_AF5_TIM16 ((uint8_t)0x05) /*!< TIM16 Alternate Function mapping */
|
||||
#define GPIO_AF5_TIM17 ((uint8_t)0x05) /*!< TIM17 Alternate Function mapping */
|
||||
#define GPIO_AF5_MCO ((uint8_t)0x05) /*!< MCO Alternate Function mapping */
|
||||
/**
|
||||
* @brief AF 6 selection
|
||||
*/
|
||||
#define GPIO_AF6_I2C ((uint8_t)0x06) /*!< I2C1 Alternate Function mapping */
|
||||
#define GPIO_AF6_LED ((uint8_t)0x06U) /*!< AF6: LED Alternate Function mapping */
|
||||
#define GPIO_AF6_MCO ((uint8_t)0x06) /*!< MCO Alternate Function mapping */
|
||||
#define GPIO_AF6_EVENTOUT ((uint8_t)0x06U) /*!< AF6: EVENTOUT Alternate Function mapping */
|
||||
/**
|
||||
* @brief AF 7 selection
|
||||
*/
|
||||
#define GPIO_AF7_EVENTOUT ((uint8_t)0x07) /*!< EVENTOUT Alternate Function mapping */
|
||||
#define GPIO_AF7_COMP1 ((uint8_t)0x07U) /*!< AF7: COMP1 Alternate Function mapping */
|
||||
#define GPIO_AF7_COMP2 ((uint8_t)0x07U) /*!< AF7: COMP2 Alternate Function mapping */
|
||||
/**
|
||||
* @brief AF 8 selection
|
||||
*/
|
||||
#define GPIO_AF8_USART1 ((uint8_t)0x08U) /*!< AF8: USART1 Alternate Function mapping */
|
||||
/**
|
||||
* @brief AF 9 selection
|
||||
*/
|
||||
#define GPIO_AF9_USART2 ((uint8_t)0x09) /*!< USART2 Alternate Function mapping */
|
||||
/**
|
||||
* @brief AF 10 selection
|
||||
*/
|
||||
#define GPIO_AF10_SPI1 ((uint8_t)0x0A) /*!< SPI2 Alternate Function mapping */
|
||||
/**
|
||||
* @brief AF 11 selection
|
||||
*/
|
||||
#define GPIO_AF11_SPI2 ((uint8_t)0x0B) /*!< SPI2 Alternate Function mapping */
|
||||
/**
|
||||
* @brief AF 12 selection
|
||||
*/
|
||||
#define GPIO_AF12_I2C ((uint8_t)0x0C) /*!< I2C1 Alternate Function mapping */
|
||||
/**
|
||||
* @brief AF 13 selection
|
||||
*/
|
||||
#define GPIO_AF13_TIM1 ((uint8_t)0x0D) /*!< TIM1 Alternate Function mapping */
|
||||
#define GPIO_AF13_TIM3 ((uint8_t)0x0D) /*!< TIM3 Alternate Function mapping */
|
||||
#define GPIO_AF13_TIM14 ((uint8_t)0x0D) /*!< TIM_MB Alternate Function mapping */
|
||||
#define GPIO_AF13_TIM17 ((uint8_t)0x0D) /*!< TIM17 Alternate Function mapping */
|
||||
|
||||
/**
|
||||
* @brief AF 14 selection
|
||||
*/
|
||||
#define GPIO_AF14_TIM1 ((uint8_t)0x0E) /*!< TIM1 Alternate Function mapping */
|
||||
/**
|
||||
* @brief AF 15 selection
|
||||
*/
|
||||
#define GPIO_AF15_RTCOUT ((uint8_t)0x0fU)
|
||||
#define GPIO_AF15_MCO ((uint8_t)0x0FU) /*!< MCO Alternate Function mapping */
|
||||
#define GPIO_AF15_IR ((uint8_t)0x0FU) /*!< IR Alternate Function mapping */
|
||||
#define IS_GPIO_AF(AF) ((AF) <= (uint8_t)0x0f)
|
||||
|
||||
#elif defined(PY32F002APRE)
|
||||
/**
|
||||
* @brief AF 0 selection
|
||||
*/
|
||||
|
||||
#define GPIO_AF0_SWJ ((uint8_t)0x00) /*!< SWJ (SWD) Alternate Function mapping */
|
||||
#define GPIO_AF0_SPI1 ((uint8_t)0x00) /*!< SPI1 Alternate Function mapping */
|
||||
#define GPIO_AF0_USART1 ((uint8_t)0x00) /*!< USART1 Alternate Function mapping */
|
||||
|
||||
/**
|
||||
* @brief AF 1 selection
|
||||
*/
|
||||
|
||||
#define GPIO_AF1_IR ((uint8_t)0x01) /*!< IR Alternate Function mapping */
|
||||
#define GPIO_AF1_TIM1 ((uint8_t)0x01) /*!< TIM1 Alternate Function mapping */
|
||||
#define GPIO_AF1_USART1 ((uint8_t)0x01) /*!< USART1 Alternate Function mapping */
|
||||
|
||||
/**
|
||||
* @brief AF 2 selection
|
||||
*/
|
||||
#define GPIO_AF2_TIM1 ((uint8_t)0x02) /*!< TIM1 Alternate Function mapping */
|
||||
#define GPIO_AF2_TIM16 ((uint8_t)0x02) /*!< TIM16 Alternate Function mapping */
|
||||
|
||||
/**
|
||||
* @brief AF 3 selection
|
||||
*/
|
||||
#define GPIO_AF3_USART1 ((uint8_t)0x03U) /*!< AF3: USART1 Alternate Function mapping */
|
||||
/**
|
||||
* @brief AF 4 selection
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief AF 5 selection
|
||||
*/
|
||||
#define GPIO_AF5_LPTIM ((uint8_t)0x05) /*!< LPTIM1 Alternate Function mapping */
|
||||
#define GPIO_AF5_EVENTOUT ((uint8_t)0x05) /*!< EVENTOUT Alternate Function mapping */
|
||||
#define GPIO_AF5_TIM16 ((uint8_t)0x05) /*!< TIM16 Alternate Function mapping */
|
||||
#define GPIO_AF5_MCO ((uint8_t)0x05) /*!< MCO Alternate Function mapping */
|
||||
/**
|
||||
* @brief AF 6 selection
|
||||
*/
|
||||
#define GPIO_AF6_I2C ((uint8_t)0x06) /*!< I2C1 Alternate Function mapping */
|
||||
#define GPIO_AF6_MCO ((uint8_t)0x06) /*!< MCO Alternate Function mapping */
|
||||
#define GPIO_AF6_EVENTOUT ((uint8_t)0x06U) /*!< AF6: EVENTOUT Alternate Function mapping */
|
||||
/**
|
||||
* @brief AF 7 selection
|
||||
*/
|
||||
#define GPIO_AF7_EVENTOUT ((uint8_t)0x07) /*!< EVENTOUT Alternate Function mapping */
|
||||
/**
|
||||
* @brief AF 8 selection
|
||||
*/
|
||||
#define GPIO_AF8_USART1 ((uint8_t)0x08U) /*!< AF8: USART1 Alternate Function mapping */
|
||||
/**
|
||||
* @brief AF 9 selection
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief AF 10 selection
|
||||
*/
|
||||
#define GPIO_AF10_SPI1 ((uint8_t)0x0A) /*!< SPI2 Alternate Function mapping */
|
||||
/**
|
||||
* @brief AF 11 selection
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief AF 12 selection
|
||||
*/
|
||||
#define GPIO_AF12_I2C ((uint8_t)0x0C) /*!< I2C1 Alternate Function mapping */
|
||||
/**
|
||||
* @brief AF 13 selection
|
||||
*/
|
||||
#define GPIO_AF13_TIM1 ((uint8_t)0x0D) /*!< TIM1 Alternate Function mapping */
|
||||
|
||||
/**
|
||||
* @brief AF 14 selection
|
||||
*/
|
||||
#define GPIO_AF14_TIM1 ((uint8_t)0x0E) /*!< TIM1 Alternate Function mapping */
|
||||
/**
|
||||
* @brief AF 15 selection
|
||||
*/
|
||||
#define GPIO_AF15_MCO ((uint8_t)0x0FU) /*!< MCO Alternate Function mapping */
|
||||
#define GPIO_AF15_IR ((uint8_t)0x0FU) /*!< IR Alternate Function mapping */
|
||||
#define IS_GPIO_AF(AF) ((AF) <= (uint8_t)0x0f)
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#define GPIO_GET_INDEX(__GPIOx__) (((__GPIOx__) == (GPIOA))? 0uL :\
|
||||
((__GPIOx__) == (GPIOB))? 1uL : 2uL)
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __PY32F0xx_HAL_GPIO_EX_H */
|
||||
|
||||
/************************ (C) COPYRIGHT Puya *****END OF FILE****/
|
||||
715
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_i2c.h
Normal file
715
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_i2c.h
Normal file
@@ -0,0 +1,715 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file py32f0xx_hal_i2c.h
|
||||
* @author MCU Application Team
|
||||
* @brief Header file of I2C HAL module.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) Puya Semiconductor Co.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __PY32F0xx_HAL_I2C_H
|
||||
#define __PY32F0xx_HAL_I2C_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "py32f0xx_hal_def.h"
|
||||
|
||||
/** @addtogroup PY32F1xx_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 ClockSpeed; /*!< Specifies the clock frequency.
|
||||
This parameter must be set to a value lower than 400kHz */
|
||||
|
||||
uint32_t DutyCycle; /*!< Specifies the I2C fast mode duty cycle.
|
||||
This parameter can be a value of @ref I2C_duty_cycle_in_fast_mode */
|
||||
|
||||
uint32_t OwnAddress1; /*!< Specifies the first device own address.
|
||||
This parameter can be a 7-bit or 10-bit address. */
|
||||
|
||||
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 :
|
||||
* b7-b6 Error information
|
||||
* 00 : No Error
|
||||
* 01 : Abort (Abort user request on going)
|
||||
* 10 : Timeout
|
||||
* 11 : Error
|
||||
* b5 Peripheral initilisation status
|
||||
* 0 : Reset (Peripheral not initialized)
|
||||
* 1 : Init done (Peripheral initialized and ready to use. HAL I2C Init function called)
|
||||
* b4 (not used)
|
||||
* x : Should be set to 0
|
||||
* b3
|
||||
* 0 : Ready or Busy (No Listen mode ongoing)
|
||||
* 1 : Listen (Peripheral in Address Listen Mode)
|
||||
* b2 Intrinsic process state
|
||||
* 0 : Ready
|
||||
* 1 : Busy (Peripheral busy with some configuration or internal operations)
|
||||
* b1 Rx state
|
||||
* 0 : Ready (no Rx operation ongoing)
|
||||
* 1 : Busy (Rx operation ongoing)
|
||||
* b0 Tx state
|
||||
* 0 : Ready (no Tx operation ongoing)
|
||||
* 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 /*!< AF error */
|
||||
#define HAL_I2C_ERROR_OVR 0x00000008U /*!< OVR error */
|
||||
#if (defined(DMA1) || defined(DMA))
|
||||
#define HAL_I2C_ERROR_DMA 0x00000010U /*!< DMA transfer error */
|
||||
#define HAL_I2C_ERROR_DMA_PARAM 0x00000080U /*!< DMA Parameter Error */
|
||||
#endif /* DMA1 or DMA */
|
||||
#define HAL_I2C_ERROR_TIMEOUT 0x00000020U /*!< Timeout Error */
|
||||
#define HAL_I2C_ERROR_SIZE 0x00000040U /*!< Size Management error */
|
||||
#if (USE_HAL_I2C_REGISTER_CALLBACKS == 1)
|
||||
#define HAL_I2C_ERROR_INVALID_CALLBACK 0x00000100U /*!< Invalid Callback error */
|
||||
#endif /* USE_HAL_I2C_REGISTER_CALLBACKS */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @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 transfer options */
|
||||
|
||||
__IO uint32_t PreviousState; /*!< I2C communication Previous state and mode
|
||||
context for internal usage */
|
||||
#if (defined(DMA1) || defined(DMA))
|
||||
DMA_HandleTypeDef *hdmatx; /*!< I2C Tx DMA handle parameters */
|
||||
|
||||
DMA_HandleTypeDef *hdmarx; /*!< I2C Rx DMA handle parameters */
|
||||
#endif /* DMA1 or DMA */
|
||||
|
||||
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 Devaddress; /*!< I2C Target device address */
|
||||
|
||||
__IO uint32_t Memaddress; /*!< I2C Target memory address */
|
||||
|
||||
__IO uint32_t MemaddSize; /*!< I2C Target memory address size */
|
||||
|
||||
__IO uint32_t EventCount; /*!< I2C Event counter */
|
||||
|
||||
|
||||
#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_duty_cycle_in_fast_mode I2C duty cycle in fast mode
|
||||
* @{
|
||||
*/
|
||||
#define I2C_DUTYCYCLE_2 0x00000000U
|
||||
#define I2C_DUTYCYCLE_16_9 I2C_CCR_DUTY
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup I2C_general_call_addressing_mode I2C general call addressing mode
|
||||
* @{
|
||||
*/
|
||||
#define I2C_GENERALCALL_DISABLE 0x00000000U
|
||||
#define I2C_GENERALCALL_ENABLE I2C_CR1_ENGC
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup I2C_nostretch_mode I2C nostretch 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 0x00000010U
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup I2C_XferDirection_definition I2C XferDirection definition
|
||||
* @{
|
||||
*/
|
||||
#define I2C_DIRECTION_RECEIVE 0x00000000U
|
||||
#define I2C_DIRECTION_TRANSMIT 0x00000001U
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup I2C_XferOptions_definition I2C XferOptions definition
|
||||
* @{
|
||||
*/
|
||||
#define I2C_FIRST_FRAME 0x00000001U
|
||||
#define I2C_FIRST_AND_NEXT_FRAME 0x00000002U
|
||||
#define I2C_NEXT_FRAME 0x00000004U
|
||||
#define I2C_FIRST_AND_LAST_FRAME 0x00000008U
|
||||
#define I2C_LAST_FRAME_NO_STOP 0x00000010U
|
||||
#define I2C_LAST_FRAME 0x00000020U
|
||||
|
||||
/* List of XferOptions in usage of :
|
||||
* 1- Restart condition in all use cases (direction change or not)
|
||||
*/
|
||||
#define I2C_OTHER_FRAME (0x00AA0000U)
|
||||
#define I2C_OTHER_AND_LAST_FRAME (0xAA000000U)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup I2C_Interrupt_configuration_definition I2C Interrupt configuration definition
|
||||
* @brief I2C Interrupt definition
|
||||
* Elements values convention: 0xXXXXXXXX
|
||||
* - XXXXXXXX : Interrupt control mask
|
||||
* @{
|
||||
*/
|
||||
#define I2C_IT_BUF I2C_CR2_ITBUFEN
|
||||
#define I2C_IT_EVT I2C_CR2_ITEVTEN
|
||||
#define I2C_IT_ERR I2C_CR2_ITERREN
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup I2C_Flag_definition I2C Flag definition
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define I2C_FLAG_OVR 0x00010800U
|
||||
#define I2C_FLAG_AF 0x00010400U
|
||||
#define I2C_FLAG_ARLO 0x00010200U
|
||||
#define I2C_FLAG_BERR 0x00010100U
|
||||
#define I2C_FLAG_TXE 0x00010080U
|
||||
#define I2C_FLAG_RXNE 0x00010040U
|
||||
#define I2C_FLAG_STOPF 0x00010010U
|
||||
#define I2C_FLAG_ADD10 0x00010008U
|
||||
#define I2C_FLAG_BTF 0x00010004U
|
||||
#define I2C_FLAG_ADDR 0x00010002U
|
||||
#define I2C_FLAG_SB 0x00010001U
|
||||
#define I2C_FLAG_DUALF 0x00100080U
|
||||
#define I2C_FLAG_GENCALL 0x00100010U
|
||||
#define I2C_FLAG_TRA 0x00100004U
|
||||
#define I2C_FLAG_BUSY 0x00100002U
|
||||
#define I2C_FLAG_MSL 0x00100001U
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* 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
|
||||
|
||||
/** @brief Enable or disable the specified I2C interrupts.
|
||||
* @param __HANDLE__ specifies the I2C Handle.
|
||||
* @param __INTERRUPT__ specifies the interrupt source to enable or disable.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg I2C_IT_BUF: Buffer interrupt enable
|
||||
* @arg I2C_IT_EVT: Event interrupt enable
|
||||
* @arg I2C_IT_ERR: Error interrupt enable
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_I2C_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BIT((__HANDLE__)->Instance->CR2,(__INTERRUPT__))
|
||||
#define __HAL_I2C_DISABLE_IT(__HANDLE__, __INTERRUPT__) CLEAR_BIT((__HANDLE__)->Instance->CR2, (__INTERRUPT__))
|
||||
|
||||
/** @brief Checks if the specified I2C interrupt source is enabled or disabled.
|
||||
* @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 I2C_IT_BUF: Buffer interrupt enable
|
||||
* @arg I2C_IT_EVT: Event interrupt enable
|
||||
* @arg I2C_IT_ERR: Error interrupt enable
|
||||
* @retval The new state of __INTERRUPT__ (TRUE or FALSE).
|
||||
*/
|
||||
#define __HAL_I2C_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->CR2 & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
|
||||
|
||||
/** @brief Checks 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 I2C_FLAG_OVR: Overrun/Underrun flag
|
||||
* @arg I2C_FLAG_AF: Acknowledge failure flag
|
||||
* @arg I2C_FLAG_ARLO: Arbitration lost flag
|
||||
* @arg I2C_FLAG_BERR: Bus error flag
|
||||
* @arg I2C_FLAG_TXE: Data register empty flag
|
||||
* @arg I2C_FLAG_RXNE: Data register not empty flag
|
||||
* @arg I2C_FLAG_STOPF: Stop detection flag
|
||||
* @arg I2C_FLAG_ADD10: 10-bit header sent flag
|
||||
* @arg I2C_FLAG_BTF: Byte transfer finished flag
|
||||
* @arg I2C_FLAG_ADDR: Address sent flag
|
||||
* Address matched flag
|
||||
* @arg I2C_FLAG_SB: Start bit flag
|
||||
* @arg I2C_FLAG_DUALF: Dual flag
|
||||
* @arg I2C_FLAG_GENCALL: General call header flag
|
||||
* @arg I2C_FLAG_TRA: Transmitter/Receiver flag
|
||||
* @arg I2C_FLAG_BUSY: Bus busy flag
|
||||
* @arg I2C_FLAG_MSL: Master/Slave flag
|
||||
* @retval The new state of __FLAG__ (TRUE or FALSE).
|
||||
*/
|
||||
#define __HAL_I2C_GET_FLAG(__HANDLE__, __FLAG__) ((((uint8_t)((__FLAG__) >> 16U)) == 0x01U) ? \
|
||||
(((((__HANDLE__)->Instance->SR1) & ((__FLAG__) & I2C_FLAG_MASK)) == ((__FLAG__) & I2C_FLAG_MASK)) ? SET : RESET) : \
|
||||
(((((__HANDLE__)->Instance->SR2) & ((__FLAG__) & I2C_FLAG_MASK)) == ((__FLAG__) & I2C_FLAG_MASK)) ? SET : RESET))
|
||||
|
||||
/** @brief Clears the I2C pending flags which are cleared by writing 0 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 I2C_FLAG_OVR: Overrun/Underrun flag (Slave mode)
|
||||
* @arg I2C_FLAG_AF: Acknowledge failure flag
|
||||
* @arg I2C_FLAG_ARLO: Arbitration lost flag (Master mode)
|
||||
* @arg I2C_FLAG_BERR: Bus error flag
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_I2C_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR1 = ~((__FLAG__) & I2C_FLAG_MASK))
|
||||
|
||||
/** @brief Clears the I2C ADDR pending flag.
|
||||
* @param __HANDLE__ specifies the I2C Handle.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_I2C_CLEAR_ADDRFLAG(__HANDLE__) \
|
||||
do{ \
|
||||
__IO uint32_t tmpreg = 0x00U; \
|
||||
tmpreg = (__HANDLE__)->Instance->SR1; \
|
||||
tmpreg = (__HANDLE__)->Instance->SR2; \
|
||||
UNUSED(tmpreg); \
|
||||
} while(0)
|
||||
|
||||
/** @brief Clears the I2C STOPF pending flag.
|
||||
* @param __HANDLE__ specifies the I2C Handle.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_I2C_CLEAR_STOPFLAG(__HANDLE__) \
|
||||
do{ \
|
||||
__IO uint32_t tmpreg = 0x00U; \
|
||||
tmpreg = (__HANDLE__)->Instance->SR1; \
|
||||
SET_BIT((__HANDLE__)->Instance->CR1, I2C_CR1_PE); \
|
||||
UNUSED(tmpreg); \
|
||||
} while(0)
|
||||
|
||||
/** @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)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* 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);
|
||||
|
||||
#if (defined(DMA1) || defined(DMA))
|
||||
/******* 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);
|
||||
#endif /* DMA1 or DMA */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @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 types -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
/** @defgroup I2C_Private_Constants I2C Private Constants
|
||||
* @{
|
||||
*/
|
||||
#define I2C_FLAG_MASK 0x0000FFFFU
|
||||
#define I2C_MIN_PCLK_FREQ_STANDARD 2000000U /*!< 2 MHz */
|
||||
#define I2C_MIN_PCLK_FREQ_FAST 4000000U /*!< 4 MHz */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Private macros ------------------------------------------------------------*/
|
||||
/** @defgroup I2C_Private_Macros I2C Private Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define I2C_MIN_PCLK_FREQ(__PCLK__, __SPEED__) (((__SPEED__) <= 100000U) ? ((__PCLK__) < I2C_MIN_PCLK_FREQ_STANDARD) : ((__PCLK__) < I2C_MIN_PCLK_FREQ_FAST))
|
||||
#define I2C_CCR_CALCULATION(__PCLK__, __SPEED__, __COEFF__) (((((__PCLK__) - 1U)/((__SPEED__) * (__COEFF__))) + 1U) & I2C_CCR_CCR)
|
||||
#define I2C_FREQRANGE(__PCLK__) ((__PCLK__)/1000000U)
|
||||
#define I2C_RISE_TIME(__FREQRANGE__, __SPEED__) (((__SPEED__) <= 100000U) ? ((__FREQRANGE__) + 1U) : ((((__FREQRANGE__) * 300U) / 1000U) + 1U))
|
||||
#define I2C_SPEED_STANDARD(__PCLK__, __SPEED__) ((I2C_CCR_CALCULATION((__PCLK__), (__SPEED__), 2U) < 4U)? 4U:I2C_CCR_CALCULATION((__PCLK__), (__SPEED__), 2U))
|
||||
#define I2C_SPEED_FAST(__PCLK__, __SPEED__, __DUTYCYCLE__) (((__DUTYCYCLE__) == I2C_DUTYCYCLE_2)? I2C_CCR_CALCULATION((__PCLK__), (__SPEED__), 3U) : (I2C_CCR_CALCULATION((__PCLK__), (__SPEED__), 25U) | I2C_DUTYCYCLE_16_9))
|
||||
#define I2C_SPEED(__PCLK__, __SPEED__, __DUTYCYCLE__) (((__SPEED__) <= 100000U)? (I2C_SPEED_STANDARD((__PCLK__), (__SPEED__))) : \
|
||||
((I2C_SPEED_FAST((__PCLK__), (__SPEED__), (__DUTYCYCLE__)) & I2C_CCR_CCR) == 0U)? 1U : \
|
||||
((I2C_SPEED_FAST((__PCLK__), (__SPEED__), (__DUTYCYCLE__))) | I2C_CCR_FS))
|
||||
|
||||
#define I2C_7BIT_ADD_WRITE(__ADDRESS__) ((uint8_t)((__ADDRESS__) & (uint8_t)(~0x01)))
|
||||
#define I2C_7BIT_ADD_READ(__ADDRESS__) ((uint8_t)((__ADDRESS__) | 0x01))
|
||||
|
||||
#define I2C_10BIT_ADDRESS(__ADDRESS__) ((uint8_t)((uint16_t)((__ADDRESS__) & (uint16_t)0x00FF)))
|
||||
#define I2C_10BIT_HEADER_WRITE(__ADDRESS__) ((uint8_t)((uint16_t)((uint16_t)(((uint16_t)((__ADDRESS__) & (uint16_t)0x0300)) >> 7) | (uint16_t)0x00F0)))
|
||||
#define I2C_10BIT_HEADER_READ(__ADDRESS__) ((uint8_t)((uint16_t)((uint16_t)(((uint16_t)((__ADDRESS__) & (uint16_t)0x0300)) >> 7) | (uint16_t)(0x00F1))))
|
||||
|
||||
#define I2C_MEM_ADD_MSB(__ADDRESS__) ((uint8_t)((uint16_t)(((uint16_t)((__ADDRESS__) & (uint16_t)0xFF00)) >> 8)))
|
||||
#define I2C_MEM_ADD_LSB(__ADDRESS__) ((uint8_t)((uint16_t)((__ADDRESS__) & (uint16_t)0x00FF)))
|
||||
|
||||
/** @defgroup I2C_IS_RTC_Definitions I2C Private macros to check input parameters
|
||||
* @{
|
||||
*/
|
||||
#define IS_I2C_DUTY_CYCLE(CYCLE) (((CYCLE) == I2C_DUTYCYCLE_2) || \
|
||||
((CYCLE) == I2C_DUTYCYCLE_16_9))
|
||||
#define IS_I2C_ADDRESSING_MODE(ADDRESS) (((ADDRESS) == I2C_ADDRESSINGMODE_7BIT) || \
|
||||
((ADDRESS) == I2C_ADDRESSINGMODE_10BIT))
|
||||
#define IS_I2C_DUAL_ADDRESS(ADDRESS) (((ADDRESS) == I2C_DUALADDRESS_DISABLE) || \
|
||||
((ADDRESS) == I2C_DUALADDRESS_ENABLE))
|
||||
#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_I2C_CLOCK_SPEED(SPEED) (((SPEED) > 0U) && ((SPEED) <= 400000U))
|
||||
#define IS_I2C_OWN_ADDRESS1(ADDRESS1) (((ADDRESS1) & 0xFFFFFC00U) == 0U)
|
||||
#define IS_I2C_OWN_ADDRESS2(ADDRESS2) (((ADDRESS2) & 0xFFFFFF01U) == 0U)
|
||||
#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_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
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* __PY32F0xx_HAL_I2C_H */
|
||||
|
||||
/************************ (C) COPYRIGHT Puya *****END OF FILE****/
|
||||
675
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_irda.h
Normal file
675
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_irda.h
Normal file
@@ -0,0 +1,675 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file py32f0xx_hal_irda.h
|
||||
* @author MCU Application Team
|
||||
* @brief Header file of IRDA HAL module.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) Puya Semiconductor Co.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __PY32F0xx_HAL_IRDA_H
|
||||
#define __PY32F0xx_HAL_IRDA_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "py32f0xx_hal_def.h"
|
||||
|
||||
/** @addtogroup PY32F0xx_HAL_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup IRDA
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/** @defgroup IRDA_Exported_Types IRDA Exported Types
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief IRDA Init Structure definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t BaudRate; /*!< This member configures the IRDA communication baud rate.
|
||||
The baud rate is computed using the following formula:
|
||||
- IntegerDivider = ((PCLKx) / (16 * (hirda->Init.BaudRate)))
|
||||
- FractionalDivider = ((IntegerDivider - ((uint32_t) IntegerDivider)) * 16) + 0.5 */
|
||||
|
||||
uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame.
|
||||
This parameter can be a value of @ref IRDA_Word_Length */
|
||||
|
||||
uint32_t Parity; /*!< Specifies the parity mode.
|
||||
This parameter can be a value of @ref IRDA_Parity
|
||||
@note When parity is enabled, the computed parity is inserted
|
||||
at the MSB position of the transmitted data (9th bit when
|
||||
the word length is set to 9 data bits; 8th bit when the
|
||||
word length is set to 8 data bits). */
|
||||
|
||||
uint32_t Mode; /*!< Specifies whether the Receive or Transmit mode is enabled or disabled.
|
||||
This parameter can be a value of @ref IRDA_Mode */
|
||||
|
||||
uint8_t Prescaler; /*!< Specifies the Prescaler value to be programmed
|
||||
in the IrDA low-power Baud Register, for defining pulse width on which
|
||||
burst acceptance/rejection will be decided. This value is used as divisor
|
||||
of system clock to achieve required pulse width. */
|
||||
|
||||
uint32_t IrDAMode; /*!< Specifies the IrDA mode
|
||||
This parameter can be a value of @ref IRDA_Low_Power */
|
||||
} IRDA_InitTypeDef;
|
||||
|
||||
/**
|
||||
* @brief HAL IRDA State structures definition
|
||||
* @note HAL IRDA State value is a combination of 2 different substates: gState and RxState.
|
||||
* - gState contains IRDA state information related to global Handle management
|
||||
* and also information related to Tx operations.
|
||||
* gState value coding follow below described bitmap :
|
||||
* b7-b6 Error information
|
||||
* 00 : No Error
|
||||
* 01 : (Not Used)
|
||||
* 10 : Timeout
|
||||
* 11 : Error
|
||||
* b5 IP initilisation status
|
||||
* 0 : Reset (IP not initialized)
|
||||
* 1 : Init done (IP not initialized. HAL IRDA Init function already called)
|
||||
* b4-b3 (not used)
|
||||
* xx : Should be set to 00
|
||||
* b2 Intrinsic process state
|
||||
* 0 : Ready
|
||||
* 1 : Busy (IP busy with some configuration or internal operations)
|
||||
* b1 (not used)
|
||||
* x : Should be set to 0
|
||||
* b0 Tx state
|
||||
* 0 : Ready (no Tx operation ongoing)
|
||||
* 1 : Busy (Tx operation ongoing)
|
||||
* - RxState contains information related to Rx operations.
|
||||
* RxState value coding follow below described bitmap :
|
||||
* b7-b6 (not used)
|
||||
* xx : Should be set to 00
|
||||
* b5 IP initilisation status
|
||||
* 0 : Reset (IP not initialized)
|
||||
* 1 : Init done (IP not initialized)
|
||||
* b4-b2 (not used)
|
||||
* xxx : Should be set to 000
|
||||
* b1 Rx state
|
||||
* 0 : Ready (no Rx operation ongoing)
|
||||
* 1 : Busy (Rx operation ongoing)
|
||||
* b0 (not used)
|
||||
* x : Should be set to 0.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
HAL_IRDA_STATE_RESET = 0x00U, /*!< Peripheral is not yet Initialized
|
||||
Value is allowed for gState and RxState */
|
||||
HAL_IRDA_STATE_READY = 0x20U, /*!< Peripheral Initialized and ready for use
|
||||
Value is allowed for gState and RxState */
|
||||
HAL_IRDA_STATE_BUSY = 0x24U, /*!< An internal process is ongoing
|
||||
Value is allowed for gState only */
|
||||
HAL_IRDA_STATE_BUSY_TX = 0x21U, /*!< Data Transmission process is ongoing
|
||||
Value is allowed for gState only */
|
||||
HAL_IRDA_STATE_BUSY_RX = 0x22U, /*!< Data Reception process is ongoing
|
||||
Value is allowed for RxState only */
|
||||
HAL_IRDA_STATE_BUSY_TX_RX = 0x23U, /*!< Data Transmission and Reception process is ongoing
|
||||
Not to be used for neither gState nor RxState.
|
||||
Value is result of combination (Or) between gState and RxState values */
|
||||
HAL_IRDA_STATE_TIMEOUT = 0xA0U, /*!< Timeout state
|
||||
Value is allowed for gState only */
|
||||
HAL_IRDA_STATE_ERROR = 0xE0U /*!< Error
|
||||
Value is allowed for gState only */
|
||||
} HAL_IRDA_StateTypeDef;
|
||||
|
||||
/**
|
||||
* @brief IRDA handle Structure definition
|
||||
*/
|
||||
#if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
|
||||
typedef struct __IRDA_HandleTypeDef
|
||||
#else
|
||||
typedef struct
|
||||
#endif /* USE_HAL_IRDA_REGISTER_CALLBACKS */
|
||||
{
|
||||
USART_TypeDef *Instance; /*!< USART registers base address */
|
||||
|
||||
IRDA_InitTypeDef Init; /*!< IRDA communication parameters */
|
||||
|
||||
uint8_t *pTxBuffPtr; /*!< Pointer to IRDA Tx transfer Buffer */
|
||||
|
||||
uint16_t TxXferSize; /*!< IRDA Tx Transfer size */
|
||||
|
||||
__IO uint16_t TxXferCount; /*!< IRDA Tx Transfer Counter */
|
||||
|
||||
uint8_t *pRxBuffPtr; /*!< Pointer to IRDA Rx transfer Buffer */
|
||||
|
||||
uint16_t RxXferSize; /*!< IRDA Rx Transfer size */
|
||||
|
||||
__IO uint16_t RxXferCount; /*!< IRDA Rx Transfer Counter */
|
||||
|
||||
DMA_HandleTypeDef *hdmatx; /*!< IRDA Tx DMA Handle parameters */
|
||||
|
||||
DMA_HandleTypeDef *hdmarx; /*!< IRDA Rx DMA Handle parameters */
|
||||
|
||||
HAL_LockTypeDef Lock; /*!< Locking object */
|
||||
|
||||
__IO HAL_IRDA_StateTypeDef gState; /*!< IRDA state information related to global Handle management
|
||||
and also related to Tx operations.
|
||||
This parameter can be a value of @ref HAL_IRDA_StateTypeDef */
|
||||
|
||||
__IO HAL_IRDA_StateTypeDef RxState; /*!< IRDA state information related to Rx operations.
|
||||
This parameter can be a value of @ref HAL_IRDA_StateTypeDef */
|
||||
|
||||
__IO uint32_t ErrorCode; /*!< IRDA Error code */
|
||||
|
||||
#if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
|
||||
void (* TxHalfCpltCallback)(struct __IRDA_HandleTypeDef *hirda); /*!< IRDA Tx Half Complete Callback */
|
||||
|
||||
void (* TxCpltCallback)(struct __IRDA_HandleTypeDef *hirda); /*!< IRDA Tx Complete Callback */
|
||||
|
||||
void (* RxHalfCpltCallback)(struct __IRDA_HandleTypeDef *hirda); /*!< IRDA Rx Half Complete Callback */
|
||||
|
||||
void (* RxCpltCallback)(struct __IRDA_HandleTypeDef *hirda); /*!< IRDA Rx Complete Callback */
|
||||
|
||||
void (* ErrorCallback)(struct __IRDA_HandleTypeDef *hirda); /*!< IRDA Error Callback */
|
||||
|
||||
void (* AbortCpltCallback)(struct __IRDA_HandleTypeDef *hirda); /*!< IRDA Abort Complete Callback */
|
||||
|
||||
void (* AbortTransmitCpltCallback)(struct __IRDA_HandleTypeDef *hirda); /*!< IRDA Abort Transmit Complete Callback */
|
||||
|
||||
void (* AbortReceiveCpltCallback)(struct __IRDA_HandleTypeDef *hirda); /*!< IRDA Abort Receive Complete Callback */
|
||||
|
||||
|
||||
void (* MspInitCallback)(struct __IRDA_HandleTypeDef *hirda); /*!< IRDA Msp Init callback */
|
||||
|
||||
void (* MspDeInitCallback)(struct __IRDA_HandleTypeDef *hirda); /*!< IRDA Msp DeInit callback */
|
||||
#endif /* USE_HAL_IRDA_REGISTER_CALLBACKS */
|
||||
|
||||
} IRDA_HandleTypeDef;
|
||||
|
||||
#if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
|
||||
/**
|
||||
* @brief HAL IRDA Callback ID enumeration definition
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
HAL_IRDA_TX_HALFCOMPLETE_CB_ID = 0x00U, /*!< IRDA Tx Half Complete Callback ID */
|
||||
HAL_IRDA_TX_COMPLETE_CB_ID = 0x01U, /*!< IRDA Tx Complete Callback ID */
|
||||
HAL_IRDA_RX_HALFCOMPLETE_CB_ID = 0x02U, /*!< IRDA Rx Half Complete Callback ID */
|
||||
HAL_IRDA_RX_COMPLETE_CB_ID = 0x03U, /*!< IRDA Rx Complete Callback ID */
|
||||
HAL_IRDA_ERROR_CB_ID = 0x04U, /*!< IRDA Error Callback ID */
|
||||
HAL_IRDA_ABORT_COMPLETE_CB_ID = 0x05U, /*!< IRDA Abort Complete Callback ID */
|
||||
HAL_IRDA_ABORT_TRANSMIT_COMPLETE_CB_ID = 0x06U, /*!< IRDA Abort Transmit Complete Callback ID */
|
||||
HAL_IRDA_ABORT_RECEIVE_COMPLETE_CB_ID = 0x07U, /*!< IRDA Abort Receive Complete Callback ID */
|
||||
|
||||
HAL_IRDA_MSPINIT_CB_ID = 0x08U, /*!< IRDA MspInit callback ID */
|
||||
HAL_IRDA_MSPDEINIT_CB_ID = 0x09U /*!< IRDA MspDeInit callback ID */
|
||||
|
||||
} HAL_IRDA_CallbackIDTypeDef;
|
||||
|
||||
/**
|
||||
* @brief HAL IRDA Callback pointer definition
|
||||
*/
|
||||
typedef void (*pIRDA_CallbackTypeDef)(IRDA_HandleTypeDef *hirda); /*!< pointer to an IRDA callback function */
|
||||
|
||||
#endif /* USE_HAL_IRDA_REGISTER_CALLBACKS */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/** @defgroup IRDA_Exported_Constants IRDA Exported constants
|
||||
* @{
|
||||
*/
|
||||
/** @defgroup IRDA_Error_Code IRDA Error Code
|
||||
* @{
|
||||
*/
|
||||
#define HAL_IRDA_ERROR_NONE 0x00000000U /*!< No error */
|
||||
#define HAL_IRDA_ERROR_PE 0x00000001U /*!< Parity error */
|
||||
#define HAL_IRDA_ERROR_NE 0x00000002U /*!< Noise error */
|
||||
#define HAL_IRDA_ERROR_FE 0x00000004U /*!< Frame error */
|
||||
#define HAL_IRDA_ERROR_ORE 0x00000008U /*!< Overrun error */
|
||||
#define HAL_IRDA_ERROR_DMA 0x00000010U /*!< DMA transfer error */
|
||||
#if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
|
||||
#define HAL_IRDA_ERROR_INVALID_CALLBACK ((uint32_t)0x00000020U) /*!< Invalid Callback error */
|
||||
#endif /* USE_HAL_IRDA_REGISTER_CALLBACKS */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup IRDA_Word_Length IRDA Word Length
|
||||
* @{
|
||||
*/
|
||||
#define IRDA_WORDLENGTH_8B 0x00000000U
|
||||
#define IRDA_WORDLENGTH_9B ((uint32_t)USART_CR1_M)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup IRDA_Parity IRDA Parity
|
||||
* @{
|
||||
*/
|
||||
#define IRDA_PARITY_NONE 0x00000000U
|
||||
#define IRDA_PARITY_EVEN ((uint32_t)USART_CR1_PCE)
|
||||
#define IRDA_PARITY_ODD ((uint32_t)(USART_CR1_PCE | USART_CR1_PS))
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup IRDA_Mode IRDA Transfer Mode
|
||||
* @{
|
||||
*/
|
||||
#define IRDA_MODE_RX ((uint32_t)USART_CR1_RE)
|
||||
#define IRDA_MODE_TX ((uint32_t)USART_CR1_TE)
|
||||
#define IRDA_MODE_TX_RX ((uint32_t)(USART_CR1_TE |USART_CR1_RE))
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup IRDA_Low_Power IRDA Low Power
|
||||
* @{
|
||||
*/
|
||||
#define IRDA_POWERMODE_LOWPOWER ((uint32_t)USART_CR3_IRLP)
|
||||
#define IRDA_POWERMODE_NORMAL 0x00000000U
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup IRDA_Flags IRDA Flags
|
||||
* Elements values convention: 0xXXXX
|
||||
* - 0xXXXX : Flag mask in the SR register
|
||||
* @{
|
||||
*/
|
||||
#define IRDA_FLAG_TXE ((uint32_t)USART_SR_TXE)
|
||||
#define IRDA_FLAG_TC ((uint32_t)USART_SR_TC)
|
||||
#define IRDA_FLAG_RXNE ((uint32_t)USART_SR_RXNE)
|
||||
#define IRDA_FLAG_IDLE ((uint32_t)USART_SR_IDLE)
|
||||
#define IRDA_FLAG_ORE ((uint32_t)USART_SR_ORE)
|
||||
#define IRDA_FLAG_NE ((uint32_t)USART_SR_NE)
|
||||
#define IRDA_FLAG_FE ((uint32_t)USART_SR_FE)
|
||||
#define IRDA_FLAG_PE ((uint32_t)USART_SR_PE)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup IRDA_Interrupt_definition IRDA Interrupt Definitions
|
||||
* Elements values convention: 0xY000XXXX
|
||||
* - XXXX : Interrupt mask in the XX register
|
||||
* - Y : Interrupt source register (2bits)
|
||||
* - 01: CR1 register
|
||||
* - 10: CR2 register
|
||||
* - 11: CR3 register
|
||||
* @{
|
||||
*/
|
||||
#define IRDA_IT_PE ((uint32_t)(IRDA_CR1_REG_INDEX << 28U | USART_CR1_PEIE))
|
||||
#define IRDA_IT_TXE ((uint32_t)(IRDA_CR1_REG_INDEX << 28U | USART_CR1_TXEIE))
|
||||
#define IRDA_IT_TC ((uint32_t)(IRDA_CR1_REG_INDEX << 28U | USART_CR1_TCIE))
|
||||
#define IRDA_IT_RXNE ((uint32_t)(IRDA_CR1_REG_INDEX << 28U | USART_CR1_RXNEIE))
|
||||
#define IRDA_IT_IDLE ((uint32_t)(IRDA_CR1_REG_INDEX << 28U | USART_CR1_IDLEIE))
|
||||
|
||||
#define IRDA_IT_LBD ((uint32_t)(IRDA_CR2_REG_INDEX << 28U | USART_CR2_LBDIE))
|
||||
|
||||
#define IRDA_IT_CTS ((uint32_t)(IRDA_CR3_REG_INDEX << 28U | USART_CR3_CTSIE))
|
||||
#define IRDA_IT_ERR ((uint32_t)(IRDA_CR3_REG_INDEX << 28U | USART_CR3_EIE))
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/** @defgroup IRDA_Exported_Macros IRDA Exported Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @brief Reset IRDA handle gstate & RxState
|
||||
* @param __HANDLE__ specifies the IRDA Handle.
|
||||
* IRDA Handle selects the USARTx or UARTy peripheral
|
||||
* (USART,UART availability and x,y values depending on device).
|
||||
* @retval None
|
||||
*/
|
||||
#if USE_HAL_IRDA_REGISTER_CALLBACKS == 1
|
||||
#define __HAL_IRDA_RESET_HANDLE_STATE(__HANDLE__) do{ \
|
||||
(__HANDLE__)->gState = HAL_IRDA_STATE_RESET; \
|
||||
(__HANDLE__)->RxState = HAL_IRDA_STATE_RESET; \
|
||||
(__HANDLE__)->MspInitCallback = NULL; \
|
||||
(__HANDLE__)->MspDeInitCallback = NULL; \
|
||||
} while(0U)
|
||||
#else
|
||||
#define __HAL_IRDA_RESET_HANDLE_STATE(__HANDLE__) do{ \
|
||||
(__HANDLE__)->gState = HAL_IRDA_STATE_RESET; \
|
||||
(__HANDLE__)->RxState = HAL_IRDA_STATE_RESET; \
|
||||
} while(0U)
|
||||
#endif /*USE_HAL_IRDA_REGISTER_CALLBACKS */
|
||||
|
||||
/** @brief Flush the IRDA DR register
|
||||
* @param __HANDLE__ specifies the IRDA Handle.
|
||||
* IRDA Handle selects the USARTx or UARTy peripheral
|
||||
* (USART,UART availability and x,y values depending on device).
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_IRDA_FLUSH_DRREGISTER(__HANDLE__) ((__HANDLE__)->Instance->DR)
|
||||
|
||||
/** @brief Check whether the specified IRDA flag is set or not.
|
||||
* @param __HANDLE__ specifies the IRDA Handle.
|
||||
* IRDA Handle selects the USARTx or UARTy peripheral
|
||||
* (USART,UART availability and x,y values depending on device).
|
||||
* @param __FLAG__ specifies the flag to check.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg IRDA_FLAG_TXE: Transmit data register empty flag
|
||||
* @arg IRDA_FLAG_TC: Transmission Complete flag
|
||||
* @arg IRDA_FLAG_RXNE: Receive data register not empty flag
|
||||
* @arg IRDA_FLAG_IDLE: Idle Line detection flag
|
||||
* @arg IRDA_FLAG_ORE: OverRun Error flag
|
||||
* @arg IRDA_FLAG_NE: Noise Error flag
|
||||
* @arg IRDA_FLAG_FE: Framing Error flag
|
||||
* @arg IRDA_FLAG_PE: Parity Error flag
|
||||
* @retval The new state of __FLAG__ (TRUE or FALSE).
|
||||
*/
|
||||
#define __HAL_IRDA_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__))
|
||||
|
||||
/** @brief Clear the specified IRDA pending flag.
|
||||
* @param __HANDLE__ specifies the IRDA Handle.
|
||||
* IRDA Handle selects the USARTx or UARTy peripheral
|
||||
* (USART,UART availability and x,y values depending on device).
|
||||
* @param __FLAG__ specifies the flag to check.
|
||||
* This parameter can be any combination of the following values:
|
||||
* @arg IRDA_FLAG_TC: Transmission Complete flag.
|
||||
* @arg IRDA_FLAG_RXNE: Receive data register not empty flag.
|
||||
*
|
||||
* @note PE (Parity error), FE (Framing error), NE (Noise error), ORE (OverRun
|
||||
* error) and IDLE (Idle line detected) flags are cleared by software
|
||||
* sequence: a read operation to USART_SR register followed by a read
|
||||
* operation to USART_DR register.
|
||||
* @note RXNE flag can be also cleared by a read to the USART_DR register.
|
||||
* @note TC flag can be also cleared by software sequence: a read operation to
|
||||
* USART_SR register followed by a write operation to USART_DR register.
|
||||
* @note TXE flag is cleared only by a write to the USART_DR register.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_IRDA_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR = ~(__FLAG__))
|
||||
|
||||
/** @brief Clear the IRDA PE pending flag.
|
||||
* @param __HANDLE__ specifies the IRDA Handle.
|
||||
* IRDA Handle selects the USARTx or UARTy peripheral
|
||||
* (USART,UART availability and x,y values depending on device).
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__) \
|
||||
do{ \
|
||||
__IO uint32_t tmpreg = 0x00U; \
|
||||
tmpreg = (__HANDLE__)->Instance->SR; \
|
||||
tmpreg = (__HANDLE__)->Instance->DR; \
|
||||
UNUSED(tmpreg); \
|
||||
} while(0U)
|
||||
|
||||
/** @brief Clear the IRDA FE pending flag.
|
||||
* @param __HANDLE__ specifies the IRDA Handle.
|
||||
* IRDA Handle selects the USARTx or UARTy peripheral
|
||||
* (USART,UART availability and x,y values depending on device).
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_IRDA_CLEAR_FEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__)
|
||||
|
||||
/** @brief Clear the IRDA NE pending flag.
|
||||
* @param __HANDLE__ specifies the IRDA Handle.
|
||||
* IRDA Handle selects the USARTx or UARTy peripheral
|
||||
* (USART,UART availability and x,y values depending on device).
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_IRDA_CLEAR_NEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__)
|
||||
|
||||
/** @brief Clear the IRDA ORE pending flag.
|
||||
* @param __HANDLE__ specifies the IRDA Handle.
|
||||
* IRDA Handle selects the USARTx or UARTy peripheral
|
||||
* (USART,UART availability and x,y values depending on device).
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_IRDA_CLEAR_OREFLAG(__HANDLE__) __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__)
|
||||
|
||||
/** @brief Clear the IRDA IDLE pending flag.
|
||||
* @param __HANDLE__ specifies the IRDA Handle.
|
||||
* IRDA Handle selects the USARTx or UARTy peripheral
|
||||
* (USART,UART availability and x,y values depending on device).
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_IRDA_CLEAR_IDLEFLAG(__HANDLE__) __HAL_IRDA_CLEAR_PEFLAG(__HANDLE__)
|
||||
|
||||
/** @brief Enable the specified IRDA interrupt.
|
||||
* @param __HANDLE__ specifies the IRDA Handle.
|
||||
* IRDA Handle selects the USARTx or UARTy peripheral
|
||||
* (USART,UART availability and x,y values depending on device).
|
||||
* @param __INTERRUPT__ specifies the IRDA interrupt source to enable.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg IRDA_IT_TXE: Transmit Data Register empty interrupt
|
||||
* @arg IRDA_IT_TC: Transmission complete interrupt
|
||||
* @arg IRDA_IT_RXNE: Receive Data register not empty interrupt
|
||||
* @arg IRDA_IT_IDLE: Idle line detection interrupt
|
||||
* @arg IRDA_IT_PE: Parity Error interrupt
|
||||
* @arg IRDA_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_IRDA_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28U) == IRDA_CR1_REG_INDEX)? ((__HANDLE__)->Instance->CR1 |= ((__INTERRUPT__) & IRDA_IT_MASK)): \
|
||||
(((__INTERRUPT__) >> 28U) == IRDA_CR2_REG_INDEX)? ((__HANDLE__)->Instance->CR2 |= ((__INTERRUPT__) & IRDA_IT_MASK)): \
|
||||
((__HANDLE__)->Instance->CR3 |= ((__INTERRUPT__) & IRDA_IT_MASK)))
|
||||
/** @brief Disable the specified IRDA interrupt.
|
||||
* @param __HANDLE__ specifies the IRDA Handle.
|
||||
* IRDA Handle selects the USARTx or UARTy peripheral
|
||||
* (USART,UART availability and x,y values depending on device).
|
||||
* @param __INTERRUPT__ specifies the IRDA interrupt source to disable.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg IRDA_IT_TXE: Transmit Data Register empty interrupt
|
||||
* @arg IRDA_IT_TC: Transmission complete interrupt
|
||||
* @arg IRDA_IT_RXNE: Receive Data register not empty interrupt
|
||||
* @arg IRDA_IT_IDLE: Idle line detection interrupt
|
||||
* @arg IRDA_IT_PE: Parity Error interrupt
|
||||
* @arg IRDA_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_IRDA_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28U) == IRDA_CR1_REG_INDEX)? ((__HANDLE__)->Instance->CR1 &= ~((__INTERRUPT__) & IRDA_IT_MASK)): \
|
||||
(((__INTERRUPT__) >> 28U) == IRDA_CR2_REG_INDEX)? ((__HANDLE__)->Instance->CR2 &= ~((__INTERRUPT__) & IRDA_IT_MASK)): \
|
||||
((__HANDLE__)->Instance->CR3 &= ~ ((__INTERRUPT__) & IRDA_IT_MASK)))
|
||||
|
||||
/** @brief Check whether the specified IRDA interrupt has occurred or not.
|
||||
* @param __HANDLE__ specifies the IRDA Handle.
|
||||
* IRDA Handle selects the USARTx or UARTy peripheral
|
||||
* (USART,UART availability and x,y values depending on device).
|
||||
* @param __IT__ specifies the IRDA interrupt source to check.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg IRDA_IT_TXE: Transmit Data Register empty interrupt
|
||||
* @arg IRDA_IT_TC: Transmission complete interrupt
|
||||
* @arg IRDA_IT_RXNE: Receive Data register not empty interrupt
|
||||
* @arg IRDA_IT_IDLE: Idle line detection interrupt
|
||||
* @arg IRDA_IT_ERR: Error interrupt
|
||||
* @arg IRDA_IT_PE: Parity Error interrupt
|
||||
* @retval The new state of __IT__ (TRUE or FALSE).
|
||||
*/
|
||||
#define __HAL_IRDA_GET_IT_SOURCE(__HANDLE__, __IT__) (((((__IT__) >> 28U) == IRDA_CR1_REG_INDEX)? (__HANDLE__)->Instance->CR1:(((((uint32_t)(__IT__)) >> 28U) == IRDA_CR2_REG_INDEX)? \
|
||||
(__HANDLE__)->Instance->CR2 : (__HANDLE__)->Instance->CR3)) & (((uint32_t)(__IT__)) & IRDA_IT_MASK))
|
||||
|
||||
/** @brief Enable UART/USART associated to IRDA Handle
|
||||
* @param __HANDLE__ specifies the IRDA Handle.
|
||||
* IRDA Handle selects the USARTx or UARTy peripheral
|
||||
* (USART,UART availability and x,y values depending on device).
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_IRDA_ENABLE(__HANDLE__) (SET_BIT((__HANDLE__)->Instance->CR1, USART_CR1_UE))
|
||||
|
||||
/** @brief Disable UART/USART associated to IRDA Handle
|
||||
* @param __HANDLE__ specifies the IRDA Handle.
|
||||
* IRDA Handle selects the USARTx or UARTy peripheral
|
||||
* (USART,UART availability and x,y values depending on device).
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_IRDA_DISABLE(__HANDLE__) (CLEAR_BIT((__HANDLE__)->Instance->CR1, USART_CR1_UE))
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/** @addtogroup IRDA_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup IRDA_Exported_Functions_Group1
|
||||
* @{
|
||||
*/
|
||||
/* Initialization/de-initialization functions **********************************/
|
||||
HAL_StatusTypeDef HAL_IRDA_Init(IRDA_HandleTypeDef *hirda);
|
||||
HAL_StatusTypeDef HAL_IRDA_DeInit(IRDA_HandleTypeDef *hirda);
|
||||
void HAL_IRDA_MspInit(IRDA_HandleTypeDef *hirda);
|
||||
void HAL_IRDA_MspDeInit(IRDA_HandleTypeDef *hirda);
|
||||
|
||||
#if (USE_HAL_IRDA_REGISTER_CALLBACKS == 1)
|
||||
/* Callbacks Register/UnRegister functions ***********************************/
|
||||
HAL_StatusTypeDef HAL_IRDA_RegisterCallback(IRDA_HandleTypeDef *hirda, HAL_IRDA_CallbackIDTypeDef CallbackID, pIRDA_CallbackTypeDef pCallback);
|
||||
HAL_StatusTypeDef HAL_IRDA_UnRegisterCallback(IRDA_HandleTypeDef *hirda, HAL_IRDA_CallbackIDTypeDef CallbackID);
|
||||
#endif /* USE_HAL_IRDA_REGISTER_CALLBACKS */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup IRDA_Exported_Functions_Group2
|
||||
* @{
|
||||
*/
|
||||
/* IO operation functions *******************************************************/
|
||||
HAL_StatusTypeDef HAL_IRDA_Transmit(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size, uint32_t Timeout);
|
||||
HAL_StatusTypeDef HAL_IRDA_Receive(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size, uint32_t Timeout);
|
||||
HAL_StatusTypeDef HAL_IRDA_Transmit_IT(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size);
|
||||
HAL_StatusTypeDef HAL_IRDA_Receive_IT(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size);
|
||||
HAL_StatusTypeDef HAL_IRDA_Transmit_DMA(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size);
|
||||
HAL_StatusTypeDef HAL_IRDA_Receive_DMA(IRDA_HandleTypeDef *hirda, uint8_t *pData, uint16_t Size);
|
||||
HAL_StatusTypeDef HAL_IRDA_DMAPause(IRDA_HandleTypeDef *hirda);
|
||||
HAL_StatusTypeDef HAL_IRDA_DMAResume(IRDA_HandleTypeDef *hirda);
|
||||
HAL_StatusTypeDef HAL_IRDA_DMAStop(IRDA_HandleTypeDef *hirda);
|
||||
/* Transfer Abort functions */
|
||||
HAL_StatusTypeDef HAL_IRDA_Abort(IRDA_HandleTypeDef *hirda);
|
||||
HAL_StatusTypeDef HAL_IRDA_AbortTransmit(IRDA_HandleTypeDef *hirda);
|
||||
HAL_StatusTypeDef HAL_IRDA_AbortReceive(IRDA_HandleTypeDef *hirda);
|
||||
HAL_StatusTypeDef HAL_IRDA_Abort_IT(IRDA_HandleTypeDef *hirda);
|
||||
HAL_StatusTypeDef HAL_IRDA_AbortTransmit_IT(IRDA_HandleTypeDef *hirda);
|
||||
HAL_StatusTypeDef HAL_IRDA_AbortReceive_IT(IRDA_HandleTypeDef *hirda);
|
||||
|
||||
void HAL_IRDA_IRQHandler(IRDA_HandleTypeDef *hirda);
|
||||
void HAL_IRDA_TxCpltCallback(IRDA_HandleTypeDef *hirda);
|
||||
void HAL_IRDA_RxCpltCallback(IRDA_HandleTypeDef *hirda);
|
||||
void HAL_IRDA_TxHalfCpltCallback(IRDA_HandleTypeDef *hirda);
|
||||
void HAL_IRDA_RxHalfCpltCallback(IRDA_HandleTypeDef *hirda);
|
||||
void HAL_IRDA_ErrorCallback(IRDA_HandleTypeDef *hirda);
|
||||
void HAL_IRDA_AbortCpltCallback(IRDA_HandleTypeDef *hirda);
|
||||
void HAL_IRDA_AbortTransmitCpltCallback(IRDA_HandleTypeDef *hirda);
|
||||
void HAL_IRDA_AbortReceiveCpltCallback(IRDA_HandleTypeDef *hirda);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup IRDA_Exported_Functions_Group3
|
||||
* @{
|
||||
*/
|
||||
/* Peripheral State functions **************************************************/
|
||||
HAL_IRDA_StateTypeDef HAL_IRDA_GetState(IRDA_HandleTypeDef *hirda);
|
||||
uint32_t HAL_IRDA_GetError(IRDA_HandleTypeDef *hirda);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Private types -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
/** @defgroup IRDA_Private_Constants IRDA Private Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @brief IRDA interruptions flag mask
|
||||
*
|
||||
*/
|
||||
#define IRDA_IT_MASK ((uint32_t) USART_CR1_PEIE | USART_CR1_TXEIE | USART_CR1_TCIE | USART_CR1_RXNEIE | \
|
||||
USART_CR1_IDLEIE | USART_CR2_LBDIE | USART_CR3_CTSIE | USART_CR3_EIE )
|
||||
|
||||
#define IRDA_CR1_REG_INDEX 1U
|
||||
#define IRDA_CR2_REG_INDEX 2U
|
||||
#define IRDA_CR3_REG_INDEX 3U
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Private macros --------------------------------------------------------*/
|
||||
/** @defgroup IRDA_Private_Macros IRDA Private Macros
|
||||
* @{
|
||||
*/
|
||||
#define IS_IRDA_WORD_LENGTH(LENGTH) (((LENGTH) == IRDA_WORDLENGTH_8B) || \
|
||||
((LENGTH) == IRDA_WORDLENGTH_9B))
|
||||
|
||||
#define IS_IRDA_PARITY(PARITY) (((PARITY) == IRDA_PARITY_NONE) || \
|
||||
((PARITY) == IRDA_PARITY_EVEN) || \
|
||||
((PARITY) == IRDA_PARITY_ODD))
|
||||
|
||||
#define IS_IRDA_MODE(MODE) ((((MODE) & 0x0000FFF3U) == 0x00U) && ((MODE) != 0x00000000U))
|
||||
|
||||
#define IS_IRDA_POWERMODE(MODE) (((MODE) == IRDA_POWERMODE_LOWPOWER) || \
|
||||
((MODE) == IRDA_POWERMODE_NORMAL))
|
||||
|
||||
#define IS_IRDA_BAUDRATE(BAUDRATE) ((BAUDRATE) < 115201U)
|
||||
|
||||
#define IRDA_DIV(_PCLK_, _BAUD_) (((_PCLK_)*25U)/(4U*(_BAUD_)))
|
||||
|
||||
#define IRDA_DIVMANT(_PCLK_, _BAUD_) (IRDA_DIV((_PCLK_), (_BAUD_))/100U)
|
||||
|
||||
#define IRDA_DIVFRAQ(_PCLK_, _BAUD_) (((IRDA_DIV((_PCLK_), (_BAUD_)) - (IRDA_DIVMANT((_PCLK_), (_BAUD_)) * 100U)) * 16U + 50U) / 100U)
|
||||
|
||||
/* UART BRR = mantissa + overflow + fraction
|
||||
= (UART DIVMANT << 4) + (UART DIVFRAQ & 0xF0) + (UART DIVFRAQ & 0x0FU) */
|
||||
#define IRDA_BRR(_PCLK_, _BAUD_) (((IRDA_DIVMANT((_PCLK_), (_BAUD_)) << 4U) + \
|
||||
(IRDA_DIVFRAQ((_PCLK_), (_BAUD_)) & 0xF0U)) + \
|
||||
(IRDA_DIVFRAQ((_PCLK_), (_BAUD_)) & 0x0FU))
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
/** @defgroup IRDA_Private_Functions IRDA Private Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __PY32F0xx_HAL_IRDA_H */
|
||||
|
||||
/************************ (C) COPYRIGHT Puya *****END OF FILE****/
|
||||
221
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_iwdg.h
Normal file
221
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_iwdg.h
Normal file
@@ -0,0 +1,221 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file py32f0xx_hal_iwdg.h
|
||||
* @author MCU Application Team
|
||||
* @brief Header file of IWDG HAL module.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) Puya Semiconductor Co.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __PY32F0xx_HAL_IWDG_H
|
||||
#define __PY32F0xx_HAL_IWDG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "py32f0xx_hal_def.h"
|
||||
|
||||
/** @addtogroup PY32F0xx_HAL_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup IWDG
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/** @defgroup IWDG_Exported_Types IWDG Exported Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief IWDG Init structure definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t Prescaler; /*!< Select the prescaler of the IWDG.
|
||||
This parameter can be a value of @ref IWDG_Prescaler */
|
||||
|
||||
uint32_t Reload; /*!< Specifies the IWDG down-counter reload value.
|
||||
This parameter must be a number between Min_Data = 0 and Max_Data = 0x0FFF */
|
||||
|
||||
} IWDG_InitTypeDef;
|
||||
|
||||
/**
|
||||
* @brief IWDG Handle Structure definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
IWDG_TypeDef *Instance; /*!< Register base address */
|
||||
|
||||
IWDG_InitTypeDef Init; /*!< IWDG required parameters */
|
||||
|
||||
} IWDG_HandleTypeDef;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/** @defgroup IWDG_Exported_Constants IWDG Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup IWDG_Prescaler IWDG Prescaler
|
||||
* @{
|
||||
*/
|
||||
#define IWDG_PRESCALER_4 0x00000000U /*!< IWDG prescaler set to 4 */
|
||||
#define IWDG_PRESCALER_8 IWDG_PR_PR_0 /*!< IWDG prescaler set to 8 */
|
||||
#define IWDG_PRESCALER_16 IWDG_PR_PR_1 /*!< IWDG prescaler set to 16 */
|
||||
#define IWDG_PRESCALER_32 (IWDG_PR_PR_1 | IWDG_PR_PR_0) /*!< IWDG prescaler set to 32 */
|
||||
#define IWDG_PRESCALER_64 IWDG_PR_PR_2 /*!< IWDG prescaler set to 64 */
|
||||
#define IWDG_PRESCALER_128 (IWDG_PR_PR_2 | IWDG_PR_PR_0) /*!< IWDG prescaler set to 128 */
|
||||
#define IWDG_PRESCALER_256 (IWDG_PR_PR_2 | IWDG_PR_PR_1) /*!< IWDG prescaler set to 256 */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/* Exported macros -----------------------------------------------------------*/
|
||||
/** @defgroup IWDG_Exported_Macros IWDG Exported Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Enable the IWDG peripheral.
|
||||
* @param __HANDLE__ IWDG handle
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_IWDG_START(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_ENABLE)
|
||||
|
||||
/**
|
||||
* @brief Reload IWDG counter with value defined in the reload register
|
||||
* (write access to IWDG_PR & IWDG_RLR registers disabled).
|
||||
* @param __HANDLE__ IWDG handle
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_IWDG_RELOAD_COUNTER(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_RELOAD)
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/** @defgroup IWDG_Exported_Functions IWDG Exported Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup IWDG_Exported_Functions_Group1 Initialization and Start functions
|
||||
* @{
|
||||
*/
|
||||
/* Initialization/Start functions ********************************************/
|
||||
HAL_StatusTypeDef HAL_IWDG_Init(IWDG_HandleTypeDef *hiwdg);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup IWDG_Exported_Functions_Group2 IO operation functions
|
||||
* @{
|
||||
*/
|
||||
/* I/O operation functions ****************************************************/
|
||||
HAL_StatusTypeDef HAL_IWDG_Refresh(IWDG_HandleTypeDef *hiwdg);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
/** @defgroup IWDG_Private_Constants IWDG Private Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief IWDG Key Register BitMask
|
||||
*/
|
||||
#define IWDG_KEY_RELOAD 0x0000AAAAU /*!< IWDG Reload Counter Enable */
|
||||
#define IWDG_KEY_ENABLE 0x0000CCCCU /*!< IWDG Peripheral Enable */
|
||||
#define IWDG_KEY_WRITE_ACCESS_ENABLE 0x00005555U /*!< IWDG KR Write Access Enable */
|
||||
#define IWDG_KEY_WRITE_ACCESS_DISABLE 0x00000000U /*!< IWDG KR Write Access Disable */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Private macros ------------------------------------------------------------*/
|
||||
/** @defgroup IWDG_Private_Macros IWDG Private Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Enable write access to IWDG_PR and IWDG_RLR registers.
|
||||
* @param __HANDLE__ IWDG handle
|
||||
* @retval None
|
||||
*/
|
||||
#define IWDG_ENABLE_WRITE_ACCESS(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_WRITE_ACCESS_ENABLE)
|
||||
|
||||
/**
|
||||
* @brief Disable write access to IWDG_PR and IWDG_RLR registers.
|
||||
* @param __HANDLE__ IWDG handle
|
||||
* @retval None
|
||||
*/
|
||||
#define IWDG_DISABLE_WRITE_ACCESS(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_WRITE_ACCESS_DISABLE)
|
||||
|
||||
/**
|
||||
* @brief Check IWDG prescaler value.
|
||||
* @param __PRESCALER__ IWDG prescaler value
|
||||
* @retval None
|
||||
*/
|
||||
#define IS_IWDG_PRESCALER(__PRESCALER__) (((__PRESCALER__) == IWDG_PRESCALER_4) || \
|
||||
((__PRESCALER__) == IWDG_PRESCALER_8) || \
|
||||
((__PRESCALER__) == IWDG_PRESCALER_16) || \
|
||||
((__PRESCALER__) == IWDG_PRESCALER_32) || \
|
||||
((__PRESCALER__) == IWDG_PRESCALER_64) || \
|
||||
((__PRESCALER__) == IWDG_PRESCALER_128)|| \
|
||||
((__PRESCALER__) == IWDG_PRESCALER_256))
|
||||
|
||||
/**
|
||||
* @brief Check IWDG reload value.
|
||||
* @param __RELOAD__ IWDG reload value
|
||||
* @retval None
|
||||
*/
|
||||
#define IS_IWDG_RELOAD(__RELOAD__) ((__RELOAD__) <= IWDG_RLR_RL)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __PY32F0xx_HAL_IWDG_H */
|
||||
|
||||
/************************ (C) COPYRIGHT Puya *****END OF FILE****/
|
||||
189
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_led.h
Normal file
189
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_led.h
Normal file
@@ -0,0 +1,189 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file py32f0xx_hal_led.h
|
||||
* @author MCU Application Team
|
||||
* @brief Header file of LED HAL module.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) Puya Semiconductor Co.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __PY32F0xx_HAL_LED_H
|
||||
#define __PY32F0xx_HAL_LED_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "py32f0xx_hal_def.h"
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief LED Init Structure definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t ComDrive; /*!< Specifies the LED COM drive capability.
|
||||
This parameter can be a value of @ref LED_COMDrive */
|
||||
|
||||
uint32_t Prescaler; /*!< Specifies the prescaler value used to divide the LED clock.
|
||||
This parameter can be a number between Min_Data = 0x00(div1) and Max_Data = 0xFF(div256) */
|
||||
|
||||
uint32_t ComNum; /*!< Specifies the number of COM open.
|
||||
This parameter can be a number between Min_Data = 0(1COM) and Max_Data = 3(4COM) */
|
||||
|
||||
uint32_t LightTime; /*!< Specifies LED Lighting time.
|
||||
This parameter can be a number between Min_Data = 1 and Max_Data = 0xFF */
|
||||
|
||||
uint32_t DeadTime; /*!< Specifies LED Dead time.
|
||||
This parameter can be a number between Min_Data = 1 and Max_Data = 0xFF */
|
||||
|
||||
} LED_InitTypeDef;
|
||||
|
||||
/**
|
||||
* @brief HAL LED State structures definition
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
HAL_LED_STATE_RESET = 0x00U, /*!< Peripheral is not yet Initialized */
|
||||
HAL_LED_STATE_READY = 0x01U, /*!< Peripheral Initialized and ready for use */
|
||||
HAL_LED_STATE_BUSY = 0x02U, /*!< an internal process is ongoing */
|
||||
HAL_LED_STATE_TIMEOUT = 0x03U, /*!< Timeout state */
|
||||
HAL_LED_STATE_ERROR = 0x04U /*!< Error */
|
||||
}HAL_LED_StateTypeDef;
|
||||
|
||||
#if (USE_HAL_LED_REGISTER_CALLBACKS == 1)
|
||||
typedef struct __LED_HandleTypeDef
|
||||
#else
|
||||
typedef struct
|
||||
#endif
|
||||
{
|
||||
LED_TypeDef *Instance;
|
||||
|
||||
LED_InitTypeDef Init;
|
||||
|
||||
HAL_LockTypeDef Lock; /* Locking object */
|
||||
|
||||
__IO HAL_LED_StateTypeDef State; /* LED communication state */
|
||||
|
||||
#if (USE_HAL_LED_REGISTER_CALLBACKS == 1)
|
||||
void (* MspInitCallback)(struct __LED_HandleTypeDef *hled);
|
||||
|
||||
void (* LightComplateCallback)(struct __LED_HandleTypeDef *hled);
|
||||
#endif
|
||||
} LED_HandleTypeDef;
|
||||
|
||||
#define __HAL_LED_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CR, LED_CR_LEDON)
|
||||
|
||||
/** @brief Disable the specified LED peripheral.
|
||||
* @param __HANDLE__ specifies the LED Handle.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_LED_DISABLE(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->CR, LED_CR_LEDON)
|
||||
|
||||
#define __HAL_LED_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->IR = (__FLAG__))
|
||||
|
||||
#define __HAL_LED_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BIT((__HANDLE__)->Instance->CR, (__INTERRUPT__))
|
||||
|
||||
/** @defgroup LED_Display_Value LED display value
|
||||
* @{
|
||||
*/
|
||||
#define LED_DISP_NONE 0x00
|
||||
#define LED_DISP_FULL 0xFF
|
||||
|
||||
#define LED_DISP_0 0x3F
|
||||
#define LED_DISP_1 0x06
|
||||
#define LED_DISP_2 0x5B
|
||||
#define LED_DISP_3 0x4F
|
||||
#define LED_DISP_4 0x66
|
||||
#define LED_DISP_5 0x6D
|
||||
#define LED_DISP_6 0x7D
|
||||
#define LED_DISP_7 0x07
|
||||
#define LED_DISP_8 0x7F
|
||||
#define LED_DISP_9 0x6F
|
||||
#define LED_DISP_A 0x77
|
||||
#define LED_DISP_B 0x7C
|
||||
#define LED_DISP_C 0x39
|
||||
#define LED_DISP_D 0x5E
|
||||
#define LED_DISP_E 0x79
|
||||
#define LED_DISP_F 0x71
|
||||
#define LED_DISP_H 0x76
|
||||
#define LED_DISP_P 0x73
|
||||
#define LED_DISP_U 0x3E
|
||||
#define LED_DISP_DOT 0x80
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup LED_COM_Select LED COM Select
|
||||
* @{
|
||||
*/
|
||||
#define LED_COM0 (0x01<<0)
|
||||
#define LED_COM1 (0x01<<1)
|
||||
#define LED_COM2 (0x01<<2)
|
||||
#define LED_COM3 (0x01<<3)
|
||||
#define LED_COM_ALL (LED_COM0 | LED_COM1 | LED_COM2 | LED_COM3)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup LED_COMDrive LED COM Drive
|
||||
* @{
|
||||
*/
|
||||
#define LED_COMDRIVE_LOW 0
|
||||
#define LED_COMDRIVE_HIGH LED_CR_EHS
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Private macros ------------------------------------------------------------*/
|
||||
/** @defgroup EXTI_Private_Macros EXTI Private Macros
|
||||
* @{
|
||||
*/
|
||||
#define IS_LED_COM_DRIVE(__DRIVE__) (((__DRIVE__) == LED_COMDRIVE_LOW) || \
|
||||
((__DRIVE__) == LED_COMDRIVE_HIGH))
|
||||
|
||||
#define IS_LED_PRISCALER(__PRISCALER__) (((__PRISCALER__) >= 0x00u) && \
|
||||
((__PRISCALER__) <= 0xFF))
|
||||
|
||||
#define IS_LED_COM_NUM(__NUM__) (((__NUM__) >= 0x00u) && ((__NUM__) <= 0x3))
|
||||
|
||||
#define IS_LED_LIGHT_TIME(__TIME__) (((__TIME__) >= 0x1u) && ((__TIME__) <= 0xFF))
|
||||
|
||||
#define IS_LED_DEAD_TIME(__TIME__) (((__TIME__) >= 0x1u) && ((__TIME__) <= 0xFF))
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup LED_Exported_Functions_Group LED operation functions
|
||||
* @brief LED operation functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* LED operation functions *****************************************************/
|
||||
HAL_StatusTypeDef HAL_LED_Init(LED_HandleTypeDef *hled);
|
||||
void HAL_LED_MspInit(LED_HandleTypeDef *hled);
|
||||
HAL_StatusTypeDef HAL_LED_SetComDisplay(LED_HandleTypeDef *hled, uint8_t comCh, uint8_t data);
|
||||
void HAL_LED_LightCpltCallback(LED_HandleTypeDef *hled);
|
||||
void HAL_LED_IRQHandler(LED_HandleTypeDef *hled);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif
|
||||
410
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_lptim.h
Normal file
410
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_lptim.h
Normal file
@@ -0,0 +1,410 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file py32f0xx_hal_lptim.h
|
||||
* @author MCU Application Team
|
||||
* @brief Header file of LPTIM HAL module.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) Puya Semiconductor Co.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __PY32F0xx_HAL_LPTIM_H
|
||||
#define __PY32F0xx_HAL_LPTIM_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "py32f0xx_hal_def.h"
|
||||
|
||||
/** @addtogroup PY32F0xx_HAL_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if defined (LPTIM)
|
||||
|
||||
|
||||
/** @addtogroup LPTIM
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/** @defgroup LPTIM_Exported_Types LPTIM Exported Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief LPTIM Initialization Structure definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t Prescaler; /*!< Specifies the counter clock Prescaler.
|
||||
This parameter can be a value of @ref LPTIM_Clock_Prescaler */
|
||||
|
||||
uint32_t UpdateMode; /*!< Specifies whether to update immediately or after the end
|
||||
of current period.
|
||||
This parameter can be a value of @ref LPTIM_Updating_Mode */
|
||||
|
||||
} LPTIM_InitTypeDef;
|
||||
|
||||
/**
|
||||
* @brief HAL LPTIM State structure definition
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
HAL_LPTIM_STATE_RESET = 0x00U, /*!< Peripheral not yet initialized or disabled */
|
||||
HAL_LPTIM_STATE_READY = 0x01U, /*!< Peripheral Initialized and ready for use */
|
||||
HAL_LPTIM_STATE_BUSY = 0x02U, /*!< An internal process is ongoing */
|
||||
HAL_LPTIM_STATE_TIMEOUT = 0x03U, /*!< Timeout state */
|
||||
HAL_LPTIM_STATE_ERROR = 0x04U /*!< Internal Process is ongoing */
|
||||
} HAL_LPTIM_StateTypeDef;
|
||||
|
||||
/**
|
||||
* @brief LPTIM handle Structure definition
|
||||
*/
|
||||
#if (USE_HAL_LPTIM_REGISTER_CALLBACKS == 1)
|
||||
typedef struct __LPTIM_HandleTypeDef
|
||||
#else
|
||||
typedef struct
|
||||
#endif
|
||||
{
|
||||
LPTIM_TypeDef *Instance; /*!< Register base address */
|
||||
|
||||
LPTIM_InitTypeDef Init; /*!< LPTIM required parameters */
|
||||
|
||||
HAL_LockTypeDef Lock; /*!< LPTIM locking object */
|
||||
|
||||
__IO HAL_LPTIM_StateTypeDef State; /*!< LPTIM peripheral state */
|
||||
|
||||
#if (USE_HAL_LPTIM_REGISTER_CALLBACKS == 1)
|
||||
void (* MspInitCallback) (struct __LPTIM_HandleTypeDef *hlptim); /*!< LPTIM Base Msp Init Callback */
|
||||
void (* MspDeInitCallback) (struct __LPTIM_HandleTypeDef *hlptim); /*!< LPTIM Base Msp DeInit Callback */
|
||||
void (* AutoReloadMatchCallback) (struct __LPTIM_HandleTypeDef *hlptim); /*!< Auto-reload match Callback */
|
||||
#endif /* USE_HAL_LPTIM_REGISTER_CALLBACKS */
|
||||
} LPTIM_HandleTypeDef;
|
||||
|
||||
#if (USE_HAL_LPTIM_REGISTER_CALLBACKS == 1)
|
||||
/**
|
||||
* @brief HAL LPTIM Callback ID enumeration definition
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
HAL_LPTIM_MSPINIT_CB_ID = 0x00U, /*!< LPTIM Base Msp Init Callback ID */
|
||||
HAL_LPTIM_MSPDEINIT_CB_ID = 0x01U, /*!< LPTIM Base Msp DeInit Callback ID */
|
||||
HAL_LPTIM_AUTORELOAD_MATCH_CB_ID = 0x03U, /*!< Auto-reload match Callback ID */
|
||||
} HAL_LPTIM_CallbackIDTypeDef;
|
||||
|
||||
/**
|
||||
* @brief HAL TIM Callback pointer definition
|
||||
*/
|
||||
typedef void (*pLPTIM_CallbackTypeDef)(LPTIM_HandleTypeDef * hlptim); /*!< pointer to the LPTIM callback function */
|
||||
|
||||
#endif /* USE_HAL_LPTIM_REGISTER_CALLBACKS */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/** @defgroup LPTIM_Exported_Constants LPTIM Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup LPTIM_Clock_Prescaler LPTIM Clock Prescaler
|
||||
* @{
|
||||
*/
|
||||
#define LPTIM_PRESCALER_DIV1 0x00000000U
|
||||
#define LPTIM_PRESCALER_DIV2 LPTIM_CFGR_PRESC_0
|
||||
#define LPTIM_PRESCALER_DIV4 LPTIM_CFGR_PRESC_1
|
||||
#define LPTIM_PRESCALER_DIV8 (LPTIM_CFGR_PRESC_0 | LPTIM_CFGR_PRESC_1)
|
||||
#define LPTIM_PRESCALER_DIV16 LPTIM_CFGR_PRESC_2
|
||||
#define LPTIM_PRESCALER_DIV32 (LPTIM_CFGR_PRESC_0 | LPTIM_CFGR_PRESC_2)
|
||||
#define LPTIM_PRESCALER_DIV64 (LPTIM_CFGR_PRESC_1 | LPTIM_CFGR_PRESC_2)
|
||||
#define LPTIM_PRESCALER_DIV128 LPTIM_CFGR_PRESC
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup LPTIM_Updating_Mode LPTIM Updating Mode
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define LPTIM_UPDATE_IMMEDIATE 0x00000000U
|
||||
#define LPTIM_UPDATE_ENDOFPERIOD LPTIM_CFGR_PRELOAD
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup LPTIM_Flag_Definition LPTIM Flags Definition
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define LPTIM_FLAG_ARRM LPTIM_ISR_ARRM
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup LPTIM_Interrupts_Definition LPTIM Interrupts Definition
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define LPTIM_IT_ARRM LPTIM_IER_ARRMIE
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported macros -----------------------------------------------------------*/
|
||||
/** @defgroup LPTIM_Exported_Macros LPTIM Exported Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @brief Reset LPTIM handle state.
|
||||
* @param __HANDLE__ LPTIM handle
|
||||
* @retval None
|
||||
*/
|
||||
#if (USE_HAL_LPTIM_REGISTER_CALLBACKS == 1)
|
||||
#define __HAL_LPTIM_RESET_HANDLE_STATE(__HANDLE__) do { \
|
||||
(__HANDLE__)->State = HAL_LPTIM_STATE_RESET; \
|
||||
(__HANDLE__)->MspInitCallback = NULL; \
|
||||
(__HANDLE__)->MspDeInitCallback = NULL; \
|
||||
} while(0)
|
||||
#else
|
||||
#define __HAL_LPTIM_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_LPTIM_STATE_RESET)
|
||||
#endif /* USE_HAL_LPTIM_REGISTER_CALLBACKS */
|
||||
|
||||
/**
|
||||
* @brief Enable the LPTIM peripheral.
|
||||
* @param __HANDLE__ LPTIM handle
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_LPTIM_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (LPTIM_CR_ENABLE))
|
||||
|
||||
/**
|
||||
* @brief Disable the LPTIM peripheral.
|
||||
* @param __HANDLE__ LPTIM handle
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_LPTIM_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(LPTIM_CR_ENABLE))
|
||||
|
||||
/**
|
||||
* @brief Start the LPTIM peripheral in single mode.
|
||||
* @param __HANDLE__ LPTIM handle
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_LPTIM_START_SINGLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= LPTIM_CR_SNGSTRT)
|
||||
|
||||
/**
|
||||
* @brief Reset after read of the LPTIM Counter register in asynchronous mode.
|
||||
* @param __HANDLE__ LPTIM handle
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_LPTIM_RESET_COUNTER_AFTERREAD(__HANDLE__) ((__HANDLE__)->Instance->CR |= LPTIM_CR_RSTARE)
|
||||
|
||||
/**
|
||||
* @brief Write the passed parameter in the Autoreload register.
|
||||
* @param __HANDLE__ LPTIM handle
|
||||
* @param __VALUE__ Autoreload value
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_LPTIM_AUTORELOAD_SET(__HANDLE__ , __VALUE__) ((__HANDLE__)->Instance->ARR = (__VALUE__))
|
||||
|
||||
/**
|
||||
* @brief Check whether the specified LPTIM flag is set or not.
|
||||
* @param __HANDLE__ LPTIM handle
|
||||
* @param __FLAG__ LPTIM flag to check
|
||||
* This parameter can be a value of:
|
||||
* @arg LPTIM_FLAG_ARRM : Autoreload match Flag.
|
||||
* @retval The state of the specified flag (SET or RESET).
|
||||
*/
|
||||
#define __HAL_LPTIM_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR &(__FLAG__)) == (__FLAG__))
|
||||
|
||||
/**
|
||||
* @brief Clear the specified LPTIM flag.
|
||||
* @param __HANDLE__ LPTIM handle.
|
||||
* @param __FLAG__ LPTIM flag to clear.
|
||||
* This parameter can be a value of:
|
||||
* @arg LPTIM_FLAG_ARRM : Autoreload match Flag.
|
||||
* @retval None.
|
||||
*/
|
||||
#define __HAL_LPTIM_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__))
|
||||
|
||||
/**
|
||||
* @brief Enable the specified LPTIM interrupt.
|
||||
* @param __HANDLE__ LPTIM handle.
|
||||
* @param __INTERRUPT__ LPTIM interrupt to set.
|
||||
* This parameter can be a value of:
|
||||
* @arg LPTIM_IT_ARRM : Autoreload match Interrupt.
|
||||
* @retval None.
|
||||
*/
|
||||
#define __HAL_LPTIM_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER |= (__INTERRUPT__))
|
||||
|
||||
/**
|
||||
* @brief Disable the specified LPTIM interrupt.
|
||||
* @param __HANDLE__ LPTIM handle.
|
||||
* @param __INTERRUPT__ LPTIM interrupt to set.
|
||||
* This parameter can be a value of:
|
||||
* @arg LPTIM_IT_ARRM : Autoreload match Interrupt.
|
||||
* @retval None.
|
||||
*/
|
||||
#define __HAL_LPTIM_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER &= (~(__INTERRUPT__)))
|
||||
|
||||
/**
|
||||
* @brief Check whether the specified LPTIM interrupt source is enabled or not.
|
||||
* @param __HANDLE__ LPTIM handle.
|
||||
* @param __INTERRUPT__ LPTIM interrupt to check.
|
||||
* This parameter can be a value of:
|
||||
* @arg LPTIM_IT_ARRM : Autoreload match Interrupt.
|
||||
* @retval Interrupt status.
|
||||
*/
|
||||
|
||||
#define __HAL_LPTIM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->IER & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/** @defgroup LPTIM_Exported_Functions LPTIM Exported Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Initialization/de-initialization functions ********************************/
|
||||
HAL_StatusTypeDef HAL_LPTIM_Init(LPTIM_HandleTypeDef *hlptim);
|
||||
HAL_StatusTypeDef HAL_LPTIM_DeInit(LPTIM_HandleTypeDef *hlptim);
|
||||
|
||||
/* MSP functions *************************************************************/
|
||||
void HAL_LPTIM_MspInit(LPTIM_HandleTypeDef *hlptim);
|
||||
void HAL_LPTIM_MspDeInit(LPTIM_HandleTypeDef *hlptim);
|
||||
|
||||
/* ############################## Set once Mode ##############################*/
|
||||
/* Blocking mode: Polling */
|
||||
HAL_StatusTypeDef HAL_LPTIM_SetOnce_Start(LPTIM_HandleTypeDef *hlptim, uint32_t Period);
|
||||
HAL_StatusTypeDef HAL_LPTIM_SetOnce_Stop(LPTIM_HandleTypeDef *hlptim);
|
||||
/* Non-Blocking mode: Interrupt */
|
||||
HAL_StatusTypeDef HAL_LPTIM_SetOnce_Start_IT(LPTIM_HandleTypeDef *hlptim, uint32_t Period);
|
||||
HAL_StatusTypeDef HAL_LPTIM_SetOnce_Stop_IT(LPTIM_HandleTypeDef *hlptim);
|
||||
|
||||
/* Reading operation functions ************************************************/
|
||||
uint32_t HAL_LPTIM_ReadCounter(LPTIM_HandleTypeDef *hlptim);
|
||||
uint32_t HAL_LPTIM_ReadAutoReload(LPTIM_HandleTypeDef *hlptim);
|
||||
|
||||
/* LPTIM IRQ functions *******************************************************/
|
||||
void HAL_LPTIM_IRQHandler(LPTIM_HandleTypeDef *hlptim);
|
||||
|
||||
/* CallBack functions ********************************************************/
|
||||
void HAL_LPTIM_AutoReloadMatchCallback(LPTIM_HandleTypeDef *hlptim);
|
||||
|
||||
/* Callbacks Register/UnRegister functions ***********************************/
|
||||
#if (USE_HAL_LPTIM_REGISTER_CALLBACKS == 1)
|
||||
HAL_StatusTypeDef HAL_LPTIM_RegisterCallback(LPTIM_HandleTypeDef *lphtim, HAL_LPTIM_CallbackIDTypeDef CallbackID, pLPTIM_CallbackTypeDef pCallback);
|
||||
HAL_StatusTypeDef HAL_LPTIM_UnRegisterCallback(LPTIM_HandleTypeDef *lphtim, HAL_LPTIM_CallbackIDTypeDef CallbackID);
|
||||
#endif /* USE_HAL_LPTIM_REGISTER_CALLBACKS */
|
||||
|
||||
/* Peripheral State functions ************************************************/
|
||||
HAL_LPTIM_StateTypeDef HAL_LPTIM_GetState(LPTIM_HandleTypeDef *hlptim);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Private types -------------------------------------------------------------*/
|
||||
/** @defgroup LPTIM_Private_Types LPTIM Private Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/** @defgroup LPTIM_Private_Variables LPTIM Private Variables
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
/** @defgroup LPTIM_Private_Constants LPTIM Private Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Private macros ------------------------------------------------------------*/
|
||||
/** @defgroup LPTIM_Private_Macros LPTIM Private Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define IS_LPTIM_CLOCK_PRESCALER(__PRESCALER__) (((__PRESCALER__) == LPTIM_PRESCALER_DIV1 ) || \
|
||||
((__PRESCALER__) == LPTIM_PRESCALER_DIV2 ) || \
|
||||
((__PRESCALER__) == LPTIM_PRESCALER_DIV4 ) || \
|
||||
((__PRESCALER__) == LPTIM_PRESCALER_DIV8 ) || \
|
||||
((__PRESCALER__) == LPTIM_PRESCALER_DIV16 ) || \
|
||||
((__PRESCALER__) == LPTIM_PRESCALER_DIV32 ) || \
|
||||
((__PRESCALER__) == LPTIM_PRESCALER_DIV64 ) || \
|
||||
((__PRESCALER__) == LPTIM_PRESCALER_DIV128))
|
||||
|
||||
#define IS_LPTIM_CLOCK_PRESCALERDIV1(__PRESCALER__) ((__PRESCALER__) == LPTIM_PRESCALER_DIV1)
|
||||
|
||||
#define IS_LPTIM_UPDATE_MODE(__MODE__) (((__MODE__) == LPTIM_UPDATE_IMMEDIATE) || \
|
||||
((__MODE__) == LPTIM_UPDATE_ENDOFPERIOD))
|
||||
|
||||
#define IS_LPTIM_AUTORELOAD(__AUTORELOAD__) ((__AUTORELOAD__) <= 0x0000FFFFUL)
|
||||
|
||||
#define IS_LPTIM_PERIOD(__PERIOD__) ((__PERIOD__) <= 0x0000FFFFUL)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
/** @defgroup LPTIM_Private_Functions LPTIM Private Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* LPTIM1 || LPTIM2 */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __PY32F0xx_HAL_LPTIM_H */
|
||||
|
||||
/************************ (C) COPYRIGHT Puya *****END OF FILE****/
|
||||
402
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_pwr.h
Normal file
402
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_pwr.h
Normal file
@@ -0,0 +1,402 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file py32f0xx_hal_pwr.h
|
||||
* @author MCU Application Team
|
||||
* @brief Header file of PWR HAL module.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) Puya Semiconductor Co.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __PY32F0xx_HAL_PWR_H
|
||||
#define __PY32F0xx_HAL_PWR_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "py32f0xx_hal_def.h"
|
||||
|
||||
/** @addtogroup PY32F0xx_HAL_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup PWR PWR
|
||||
* @brief PWR HAL module driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/** @defgroup PWR_Exported_Types PWR Exported Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if defined(PWR_PVD_SUPPORT)
|
||||
/**
|
||||
* @brief PWR PVD configuration structure definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t PVDSource; /*!< PVDSource: Specifies the PVD detection source.
|
||||
This parameter can be a value of @ref PWR_PVD_Source. */
|
||||
|
||||
uint32_t PVDFilter; /*!< PVDFilter: Specifies the PVD input filter.
|
||||
This parameter can be a value of @ref PWR_PVD_Filter. */
|
||||
|
||||
uint32_t PVDLevel; /*!< PVDLevel: Specifies the PVD detection level.
|
||||
This parameter can be a value or a combination of
|
||||
@ref PWR_PVD_detection_level. */
|
||||
|
||||
uint32_t Mode; /*!< Mode: Specifies the operating mode for the selected pins.
|
||||
This parameter can be a value of @ref PWR_PVD_Mode. */
|
||||
} PWR_PVDTypeDef;
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/** @defgroup PWR_Exported_Constants PWR Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if defined(PWR_PVD_SUPPORT)
|
||||
/** @defgroup PWR_PVD_Source PWR PVD Source
|
||||
* @{
|
||||
*/
|
||||
#define PWR_PVD_SOURCE_VCC (0x00000000u) /*!< PVD detection source is Vcc */
|
||||
#define PWR_PVD_SOURCE_PB07 (PWR_CR2_SRCSEL) /*!< PVD detection source is PB07 */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup PWR_PVD_Filter PWR PVD Filter
|
||||
* @{
|
||||
*/
|
||||
#define PWR_PVD_FILTER_NONE (0x00000000u) /*!< PVD filter disable */
|
||||
#define PWR_PVD_FILTER_1CLOCK (PWR_CR2_FLTEN | 0x00000000u) /*!< PVD filter 1 clock */
|
||||
#define PWR_PVD_FILTER_2CLOCK (PWR_CR2_FLTEN | PWR_CR2_FLT_TIME_0) /*!< PVD filter 2 clock */
|
||||
#define PWR_PVD_FILTER_4CLOCK (PWR_CR2_FLTEN | PWR_CR2_FLT_TIME_1) /*!< PVD filter 4 clock */
|
||||
#define PWR_PVD_FILTER_16CLOCK (PWR_CR2_FLTEN | PWR_CR2_FLT_TIME_0 | PWR_CR2_FLT_TIME_1) /*!< PVD filter 16 clock */
|
||||
#define PWR_PVD_FILTER_64CLOCK (PWR_CR2_FLTEN | PWR_CR2_FLT_TIME_2) /*!< PVD filter 64 clock */
|
||||
#define PWR_PVD_FILTER_128CLOCK (PWR_CR2_FLTEN | PWR_CR2_FLT_TIME_2 | PWR_CR2_FLT_TIME_0) /*!< PVD filter 128 clock */
|
||||
#define PWR_PVD_FILTER_1024CLOCK (PWR_CR2_FLTEN | PWR_CR2_FLT_TIME_2 | PWR_CR2_FLT_TIME_1) /*!< PVD filter 1024 clock */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup PWR_PVD_detection_level Programmable Voltage Detection levels
|
||||
* @note see datasheet for selection voltage value
|
||||
* @{
|
||||
*/
|
||||
#define PWR_PVDLEVEL_0 (0x00000000u) /*!< same PVD threshold level 0 on rising & falling */
|
||||
#define PWR_PVDLEVEL_1 (PWR_CR2_PVDT_0) /*!< same PVD threshold level 1 on rising & falling */
|
||||
#define PWR_PVDLEVEL_2 (PWR_CR2_PVDT_1) /*!< same PVD threshold level 2 on rising & falling */
|
||||
#define PWR_PVDLEVEL_3 (PWR_CR2_PVDT_0 | PWR_CR2_PVDT_1) /*!< same PVD threshold level 3 on rising & falling */
|
||||
#define PWR_PVDLEVEL_4 (PWR_CR2_PVDT_2) /*!< same PVD threshold level 4 on rising & falling */
|
||||
#define PWR_PVDLEVEL_5 (PWR_CR2_PVDT_2 | PWR_CR2_PVDT_0) /*!< same PVD threshold level 5 on rising & falling */
|
||||
#define PWR_PVDLEVEL_6 (PWR_CR2_PVDT_2 | PWR_CR2_PVDT_1) /*!< same PVD threshold level 6 on rising & falling */
|
||||
#define PWR_PVDLEVEL_7 (PWR_CR2_PVDT_2 | PWR_CR2_PVDT_1 | PWR_CR2_PVDT_0) /*!< same PVD threshold level 7 on rising & falling */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup PWR_PVD_Mode PWR PVD interrupt and event mode
|
||||
* @{
|
||||
*/
|
||||
#define PWR_PVD_MODE_NORMAL (0x00000000u) /*!< basic mode is used */
|
||||
#define PWR_PVD_MODE_IT_RISING (0x00010001u) /*!< External Interrupt Mode with Rising edge trigger detection */
|
||||
#define PWR_PVD_MODE_IT_FALLING (0x00010002u) /*!< External Interrupt Mode with Falling edge trigger detection */
|
||||
#define PWR_PVD_MODE_IT_RISING_FALLING (0x00010003u) /*!< External Interrupt Mode with Rising/Falling edge trigger detection */
|
||||
#define PWR_PVD_MODE_EVENT_RISING (0x00020001u) /*!< Event Mode with Rising edge trigger detection */
|
||||
#define PWR_PVD_MODE_EVENT_FALLING (0x00020002u) /*!< Event Mode with Falling edge trigger detection */
|
||||
#define PWR_PVD_MODE_EVENT_RISING_FALLING (0x00020003u) /*!< Event Mode with Rising/Falling edge trigger detection */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup PWR_PVD_EXTI_LINE PWR PVD external interrupt line
|
||||
* @{
|
||||
*/
|
||||
#define PWR_EXTI_LINE_PVD (EXTI_IMR_IM16) /*!< External interrupt line 16 connected to PVD */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup PWR_PVD_EVENT_LINE PWR PVD event line
|
||||
* @{
|
||||
*/
|
||||
#define PWR_EVENT_LINE_PVD (EXTI_EMR_EM16) /*!< Event line 16 connected to PVD */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif
|
||||
|
||||
|
||||
/** @defgroup PWR_Regulator_state_in_SLEEP_STOP_mode PWR regulator mode
|
||||
* @{
|
||||
*/
|
||||
#define PWR_MAINREGULATOR_ON (0x00000000u) /*!< Regulator in main mode */
|
||||
#define PWR_LOWPOWERREGULATOR_ON PWR_CR1_LPR /*!< Regulator in low-power mode */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup PWR_SLEEP_mode_entry PWR SLEEP mode entry
|
||||
* @{
|
||||
*/
|
||||
#define PWR_SLEEPENTRY_WFI ((uint8_t)0x01u) /*!< Wait For Interruption instruction to enter Sleep mode */
|
||||
#define PWR_SLEEPENTRY_WFE ((uint8_t)0x02u) /*!< Wait For Event instruction to enter Sleep mode */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup PWR_STOP_mode_entry PWR STOP mode entry
|
||||
* @{
|
||||
*/
|
||||
#define PWR_STOPENTRY_WFI ((uint8_t)0x01u) /*!< Wait For Interruption instruction to enter Stop mode */
|
||||
#define PWR_STOPENTRY_WFE ((uint8_t)0x02u) /*!< Wait For Event instruction to enter Stop mode */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup PWR_Flag PWR Status Flags
|
||||
* @{
|
||||
*/
|
||||
#if defined(PWR_PVD_SUPPORT)
|
||||
#define PWR_FLAG_PVDO (PWR_SR_PVDO) /*!< Power Voltage Detector output */
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported macros -----------------------------------------------------------*/
|
||||
/** @defgroup PWR_Exported_Macros PWR Exported Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if defined(PWR_PVD_SUPPORT)
|
||||
/** @defgroup PWR_Exported_Macros PWR Exported Macros
|
||||
* @{
|
||||
*/
|
||||
/** @brief Check whether or not a specific PWR flag is set.
|
||||
* @param __FLAG__ specifies the flag to check.
|
||||
* This parameter can be one a combination of following values:
|
||||
* @arg PWR_FLAG_PVDO: Power Voltage Detector Output. Indicates whether
|
||||
* VDD voltage is below or above the selected PVD threshold.
|
||||
* @endif
|
||||
* @retval The new state of __FLAG__ (TRUE or FALSE).
|
||||
*/
|
||||
#define __HAL_PWR_GET_FLAG(__FLAG__) ((PWR->SR & (__FLAG__)) == (__FLAG__))
|
||||
|
||||
/**
|
||||
* @brief Enable the PVD Extended Interrupt Line.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_PWR_PVD_EXTI_ENABLE_IT() SET_BIT(EXTI->IMR, PWR_EXTI_LINE_PVD)
|
||||
|
||||
/**
|
||||
* @brief Disable the PVD Extended Interrupt Line.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_PWR_PVD_EXTI_DISABLE_IT() CLEAR_BIT(EXTI->IMR, PWR_EXTI_LINE_PVD)
|
||||
|
||||
/**
|
||||
* @brief Enable the PVD Event Line.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_PWR_PVD_EXTI_ENABLE_EVENT() SET_BIT(EXTI->EMR, PWR_EVENT_LINE_PVD)
|
||||
|
||||
/**
|
||||
* @brief Disable the PVD Event Line.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_PWR_PVD_EXTI_DISABLE_EVENT() CLEAR_BIT(EXTI->EMR, PWR_EVENT_LINE_PVD)
|
||||
|
||||
/**
|
||||
* @brief Enable the PVD Extended Interrupt Rising Trigger.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE() SET_BIT(EXTI->RTSR, PWR_EXTI_LINE_PVD)
|
||||
|
||||
/**
|
||||
* @brief Disable the PVD Extended Interrupt Rising Trigger.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE() CLEAR_BIT(EXTI->RTSR, PWR_EXTI_LINE_PVD)
|
||||
|
||||
/**
|
||||
* @brief Enable the PVD Extended Interrupt Falling Trigger.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE() SET_BIT(EXTI->FTSR, PWR_EXTI_LINE_PVD)
|
||||
|
||||
/**
|
||||
* @brief Disable the PVD Extended Interrupt Falling Trigger.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE() CLEAR_BIT(EXTI->FTSR, PWR_EXTI_LINE_PVD)
|
||||
|
||||
/**
|
||||
* @brief Enable the PVD Extended Interrupt Rising & Falling Trigger.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_PWR_PVD_EXTI_ENABLE_RISING_FALLING_EDGE() \
|
||||
do { \
|
||||
__HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE(); \
|
||||
__HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE(); \
|
||||
} while(0U)
|
||||
|
||||
/**
|
||||
* @brief Disable the PVD Extended Interrupt Rising & Falling Trigger.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_PWR_PVD_EXTI_DISABLE_RISING_FALLING_EDGE() \
|
||||
do { \
|
||||
__HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE(); \
|
||||
__HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE(); \
|
||||
} while(0U)
|
||||
|
||||
/**
|
||||
* @brief Generate a Software interrupt on selected EXTI line.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_PWR_PVD_EXTI_GENERATE_SWIT() SET_BIT(EXTI->SWIER, PWR_EXTI_LINE_PVD)
|
||||
|
||||
/**
|
||||
* @brief Check whether or not the PVD EXTI interrupt flag is set.
|
||||
* @retval EXTI PVD Line Status.
|
||||
*/
|
||||
#define __HAL_PWR_PVD_EXTI_GET_FLAG() (EXTI->PR & PWR_EXTI_LINE_PVD)
|
||||
|
||||
/**
|
||||
* @brief Clear the PVD EXTI interrupt flag.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_PWR_PVD_EXTI_CLEAR_FLAG() WRITE_REG(EXTI->PR, PWR_EXTI_LINE_PVD)
|
||||
#endif /* PWR_PVD_SUPPORT */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Private constants-------------------------------------------------------*/
|
||||
/** @defgroup PWREx_WUP_Polarity Shift to apply to retrieve polarity information from PWR_WAKEUP_PINy_xxx constants
|
||||
* @{
|
||||
*/
|
||||
#define PWR_WUP_POLARITY_SHIFT 0x08u /*!< Internal constant used to retrieve wakeup pin polariry */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Private macros --------------------------------------------------------*/
|
||||
/** @defgroup PWR_Private_Macros PWR Private Macros
|
||||
* @{
|
||||
*/
|
||||
#if defined(PWR_PVD_SUPPORT)
|
||||
#define IS_PWR_PVD_LEVEL(LEVEL) (((LEVEL) & ~(PWR_CR2_PVDT)) == 0x00000000u)
|
||||
|
||||
#define IS_PWR_PVD_MODE(MODE) (((MODE) == PWR_PVD_MODE_NORMAL) || \
|
||||
((MODE) == PWR_PVD_MODE_IT_RISING) || \
|
||||
((MODE) == PWR_PVD_MODE_IT_FALLING) || \
|
||||
((MODE) == PWR_PVD_MODE_IT_RISING_FALLING) || \
|
||||
((MODE) == PWR_PVD_MODE_EVENT_RISING) || \
|
||||
((MODE) == PWR_PVD_MODE_EVENT_FALLING) || \
|
||||
((MODE) == PWR_PVD_MODE_EVENT_RISING_FALLING))
|
||||
#endif
|
||||
|
||||
#define IS_PWR_REGULATOR(REGULATOR) (((REGULATOR) == PWR_MAINREGULATOR_ON) || \
|
||||
((REGULATOR) == PWR_LOWPOWERREGULATOR_ON))
|
||||
|
||||
#define IS_PWR_SLEEP_ENTRY(ENTRY) (((ENTRY) == PWR_SLEEPENTRY_WFI) || \
|
||||
((ENTRY) == PWR_SLEEPENTRY_WFE))
|
||||
|
||||
#define IS_PWR_STOP_ENTRY(ENTRY) (((ENTRY) == PWR_STOPENTRY_WFI) || \
|
||||
((ENTRY) == PWR_STOPENTRY_WFE))
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Include PWR HAL Extended module */
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/** @defgroup PWR_Exported_Functions PWR Exported Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup PWR_Exported_Functions_Group1 Initialization and de-initialization functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Initialization and de-initialization functions *******************************/
|
||||
void HAL_PWR_DeInit(void);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup PWR_Exported_Functions_Group2 Peripheral Control functions
|
||||
* @{
|
||||
*/
|
||||
/* Peripheral Control functions ************************************************/
|
||||
void HAL_PWR_EnableBkUpAccess(void);
|
||||
void HAL_PWR_DisableBkUpAccess(void);
|
||||
#if defined(PWR_PVD_SUPPORT)
|
||||
HAL_StatusTypeDef HAL_PWR_ConfigPVD(PWR_PVDTypeDef *sConfigPVD);
|
||||
void HAL_PWR_EnablePVD(void);
|
||||
void HAL_PWR_DisablePVD(void);
|
||||
#endif
|
||||
|
||||
/* Low Power modes configuration functions ************************************/
|
||||
void HAL_PWR_EnterSLEEPMode(uint8_t SLEEPEntry);
|
||||
void HAL_PWR_EnterSTOPMode(uint32_t Regulator, uint8_t STOPEntry);
|
||||
void HAL_PWR_EnableSleepOnExit(void);
|
||||
void HAL_PWR_DisableSleepOnExit(void);
|
||||
void HAL_PWR_EnableSEVOnPend(void);
|
||||
void HAL_PWR_DisableSEVOnPend(void);
|
||||
#if defined(PWR_PVD_SUPPORT)
|
||||
void HAL_PWR_PVD_IRQHandler(void);
|
||||
void HAL_PWR_PVD_Callback(void);
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* __PY32F0xx_HAL_PWR_H */
|
||||
|
||||
/************************ (C) COPYRIGHT Puya *****END OF FILE****/
|
||||
1761
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_rcc.h
Normal file
1761
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_rcc.h
Normal file
@@ -0,0 +1,1761 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file py32f0xx_hal_rcc.h
|
||||
* @author MCU Application Team
|
||||
* @brief Header file of RCC HAL module.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) Puya Semiconductor Co.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __PY32F0xx_HAL_RCC_H
|
||||
#define __PY32F0xx_HAL_RCC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "py32f0xx_hal_def.h"
|
||||
|
||||
/** @addtogroup PY32F0xx_HAL_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup RCC
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
/** @addtogroup RCC_Private_Constants
|
||||
* @{
|
||||
*/
|
||||
/* Defines used for Flags */
|
||||
#define CR_REG_INDEX 1U
|
||||
#define BDCR_REG_INDEX 2U
|
||||
#define CSR_REG_INDEX 3U
|
||||
|
||||
#define RCC_FLAG_MASK 0x1FU
|
||||
|
||||
/* Define used for IS_RCC_CLOCKTYPE() */
|
||||
#define RCC_CLOCKTYPE_ALL (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1) /*!< All clocktype to configure */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Private macros ------------------------------------------------------------*/
|
||||
/** @addtogroup RCC_Private_Macros
|
||||
* @{
|
||||
*/
|
||||
#if (defined(PY32F003PRE) || defined(PY32F002APRE))
|
||||
#define IS_RCC_OSCILLATORTYPE(__OSCILLATOR__) (((__OSCILLATOR__) == RCC_OSCILLATORTYPE_NONE) || \
|
||||
(((__OSCILLATOR__) & RCC_OSCILLATORTYPE_HSE) == RCC_OSCILLATORTYPE_HSE) || \
|
||||
(((__OSCILLATOR__) & RCC_OSCILLATORTYPE_HSI) == RCC_OSCILLATORTYPE_HSI) || \
|
||||
(((__OSCILLATOR__) & RCC_OSCILLATORTYPE_LSI) == RCC_OSCILLATORTYPE_LSI))
|
||||
#else
|
||||
#define IS_RCC_OSCILLATORTYPE(__OSCILLATOR__) (((__OSCILLATOR__) == RCC_OSCILLATORTYPE_NONE) || \
|
||||
(((__OSCILLATOR__) & RCC_OSCILLATORTYPE_HSE) == RCC_OSCILLATORTYPE_HSE) || \
|
||||
(((__OSCILLATOR__) & RCC_OSCILLATORTYPE_HSI) == RCC_OSCILLATORTYPE_HSI) || \
|
||||
(((__OSCILLATOR__) & RCC_OSCILLATORTYPE_LSI) == RCC_OSCILLATORTYPE_LSI) || \
|
||||
(((__OSCILLATOR__) & RCC_OSCILLATORTYPE_LSE) == RCC_OSCILLATORTYPE_LSE))
|
||||
#endif
|
||||
|
||||
#define IS_RCC_HSE(__HSE__) (((__HSE__) == RCC_HSE_OFF) || ((__HSE__) == RCC_HSE_ON) || \
|
||||
((__HSE__) == RCC_HSE_BYPASS))
|
||||
|
||||
#if defined(PY32F002APRE)
|
||||
#define IS_RCC_HSE_FREQ(__FREQ__) (((__FREQ__) == RCC_HSE_4_8MHz) || ((__FREQ__) == RCC_HSE_8_16MHz) || \
|
||||
((__FREQ__) == RCC_HSE_16_24MHz))
|
||||
#else
|
||||
#define IS_RCC_HSE_FREQ(__FREQ__) (((__FREQ__) == RCC_HSE_4_8MHz) || ((__FREQ__) == RCC_HSE_8_16MHz) || \
|
||||
((__FREQ__) == RCC_HSE_16_32MHz))
|
||||
#endif
|
||||
|
||||
#if defined(RCC_LSE_SUPPORT)
|
||||
#define IS_RCC_LSE(__LSE__) (((__LSE__) == RCC_LSE_OFF) || ((__LSE__) == RCC_LSE_ON) || \
|
||||
((__LSE__) == RCC_LSE_BYPASS))
|
||||
#endif
|
||||
|
||||
#define IS_RCC_HSI(__HSI__) (((__HSI__) == RCC_HSI_OFF) || ((__HSI__) == RCC_HSI_ON))
|
||||
|
||||
#if defined(PY32F002APRE)
|
||||
#define IS_RCC_HSI_CALIBRATION_VALUE(__VALUE__) ((__VALUE__) == RCC_HSICALIBRATION_8MHz || \
|
||||
(__VALUE__) == RCC_HSICALIBRATION_24MHz)
|
||||
#else
|
||||
#define IS_RCC_HSI_CALIBRATION_VALUE(__VALUE__) (((__VALUE__) == RCC_HSICALIBRATION_4MHz) || \
|
||||
((__VALUE__) == RCC_HSICALIBRATION_8MHz) || \
|
||||
((__VALUE__) == RCC_HSICALIBRATION_16MHz) || \
|
||||
((__VALUE__) == RCC_HSICALIBRATION_22p12MHz) || \
|
||||
((__VALUE__) == RCC_HSICALIBRATION_24MHz))
|
||||
#endif
|
||||
|
||||
#define IS_RCC_HSIDIV(__DIV__) (((__DIV__) == RCC_HSI_DIV1) || ((__DIV__) == RCC_HSI_DIV2) || \
|
||||
((__DIV__) == RCC_HSI_DIV4) || ((__DIV__) == RCC_HSI_DIV8) || \
|
||||
((__DIV__) == RCC_HSI_DIV16) || ((__DIV__) == RCC_HSI_DIV32)|| \
|
||||
((__DIV__) == RCC_HSI_DIV64) || ((__DIV__) == RCC_HSI_DIV128))
|
||||
|
||||
#define IS_RCC_LSI(__LSI__) (((__LSI__) == RCC_LSI_OFF) || ((__LSI__) == RCC_LSI_ON))
|
||||
|
||||
#if defined(RCC_PLL_SUPPORT)
|
||||
#define IS_RCC_PLL(__PLL__) (((__PLL__) == RCC_PLL_NONE) ||((__PLL__) == RCC_PLL_OFF) || \
|
||||
((__PLL__) == RCC_PLL_ON))
|
||||
|
||||
#define IS_RCC_PLLSOURCE(__SOURCE__) (((__SOURCE__) == RCC_PLLSOURCE_NONE) || \
|
||||
((__SOURCE__) == RCC_PLLSOURCE_HSI) || \
|
||||
((__SOURCE__) == RCC_PLLSOURCE_HSE))
|
||||
#endif
|
||||
|
||||
#define IS_RCC_CLOCKTYPE(__CLK__) ((((__CLK__) & RCC_CLOCKTYPE_ALL) != 0x00UL) && (((__CLK__) & ~RCC_CLOCKTYPE_ALL) == 0x00UL))
|
||||
|
||||
#if (defined(PY32F003PRE) || defined(PY32F002APRE))
|
||||
#define IS_RCC_SYSCLKSOURCE(__SOURCE__) (((__SOURCE__) == RCC_SYSCLKSOURCE_HSI) || \
|
||||
((__SOURCE__) == RCC_SYSCLKSOURCE_HSE) || \
|
||||
((__SOURCE__) == RCC_SYSCLKSOURCE_LSI))
|
||||
#else
|
||||
#define IS_RCC_SYSCLKSOURCE(__SOURCE__) (((__SOURCE__) == RCC_SYSCLKSOURCE_HSI) || \
|
||||
((__SOURCE__) == RCC_SYSCLKSOURCE_HSE) || \
|
||||
((__SOURCE__) == RCC_SYSCLKSOURCE_LSE) || \
|
||||
((__SOURCE__) == RCC_SYSCLKSOURCE_LSI) || \
|
||||
((__SOURCE__) == RCC_SYSCLKSOURCE_PLLCLK))
|
||||
#endif
|
||||
|
||||
#define IS_RCC_HCLK(__HCLK__) (((__HCLK__) == RCC_SYSCLK_DIV1) || ((__HCLK__) == RCC_SYSCLK_DIV2) || \
|
||||
((__HCLK__) == RCC_SYSCLK_DIV4) || ((__HCLK__) == RCC_SYSCLK_DIV8) || \
|
||||
((__HCLK__) == RCC_SYSCLK_DIV16) || ((__HCLK__) == RCC_SYSCLK_DIV64) || \
|
||||
((__HCLK__) == RCC_SYSCLK_DIV128) || ((__HCLK__) == RCC_SYSCLK_DIV256) || \
|
||||
((__HCLK__) == RCC_SYSCLK_DIV512))
|
||||
|
||||
#define IS_RCC_PCLK(__PCLK__) (((__PCLK__) == RCC_HCLK_DIV1) || ((__PCLK__) == RCC_HCLK_DIV2) || \
|
||||
((__PCLK__) == RCC_HCLK_DIV4) || ((__PCLK__) == RCC_HCLK_DIV8) || \
|
||||
((__PCLK__) == RCC_HCLK_DIV16))
|
||||
#if defined(RCC_LSE_SUPPORT)
|
||||
#define IS_RCC_RTCCLKSOURCE(__SOURCE__) (((__SOURCE__) == RCC_RTCCLKSOURCE_NONE) || \
|
||||
((__SOURCE__) == RCC_RTCCLKSOURCE_LSE) || \
|
||||
((__SOURCE__) == RCC_RTCCLKSOURCE_LSI) || \
|
||||
((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV128))
|
||||
#else
|
||||
#define IS_RCC_RTCCLKSOURCE(__SOURCE__) (((__SOURCE__) == RCC_RTCCLKSOURCE_NONE) || \
|
||||
((__SOURCE__) == RCC_RTCCLKSOURCE_LSI) || \
|
||||
((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV128))
|
||||
#endif
|
||||
|
||||
#define IS_RCC_MCO(__MCOX__) ((__MCOX__) == RCC_MCO1)
|
||||
|
||||
#if (defined(PY32F003PRE) || defined(PY32F002APRE))
|
||||
#define IS_RCC_MCO1SOURCE(__SOURCE__) (((__SOURCE__) == RCC_MCO1SOURCE_NOCLOCK) || \
|
||||
((__SOURCE__) == RCC_MCO1SOURCE_SYSCLK) || \
|
||||
((__SOURCE__) == RCC_MCO1SOURCE_HSI) || \
|
||||
((__SOURCE__) == RCC_MCO1SOURCE_HSE) || \
|
||||
((__SOURCE__) == RCC_MCO1SOURCE_LSI))
|
||||
#else
|
||||
#define IS_RCC_MCO1SOURCE(__SOURCE__) (((__SOURCE__) == RCC_MCO1SOURCE_NOCLOCK) || \
|
||||
((__SOURCE__) == RCC_MCO1SOURCE_SYSCLK) || \
|
||||
((__SOURCE__) == RCC_MCO1SOURCE_HSI) || \
|
||||
((__SOURCE__) == RCC_MCO1SOURCE_HSE) || \
|
||||
((__SOURCE__) == RCC_MCO1SOURCE_PLLCLK) || \
|
||||
((__SOURCE__) == RCC_MCO1SOURCE_LSI) || \
|
||||
((__SOURCE__) == RCC_MCO1SOURCE_LSE))
|
||||
#endif
|
||||
|
||||
#define IS_RCC_MCODIV(__DIV__) (((__DIV__) == RCC_MCODIV_1) || ((__DIV__) == RCC_MCODIV_2) || \
|
||||
((__DIV__) == RCC_MCODIV_4) || ((__DIV__) == RCC_MCODIV_8) || \
|
||||
((__DIV__) == RCC_MCODIV_16)|| ((__DIV__) == RCC_MCODIV_32) || \
|
||||
((__DIV__) == RCC_MCODIV_64)|| ((__DIV__) == RCC_MCODIV_128))
|
||||
#if defined(RCC_LSE_SUPPORT)
|
||||
#define IS_RCC_LSE_DRIVE(__DRIVE__) (((__DRIVE__) == RCC_LSEDRIVE_LOW) || \
|
||||
((__DRIVE__) == RCC_LSEDRIVE_MEDIUM) || \
|
||||
((__DRIVE__) == RCC_LSEDRIVE_HIGH))
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/** @defgroup RCC_Exported_Types RCC Exported Types
|
||||
* @{
|
||||
*/
|
||||
#if defined(RCC_PLL_SUPPORT)
|
||||
/**
|
||||
* @brief RCC PLL configuration structure definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t PLLState; /*!< The new state of the PLL.
|
||||
This parameter can be a value of @ref RCC_PLL_Config */
|
||||
|
||||
uint32_t PLLSource; /*!< RCC_PLLSource: PLL entry clock source.
|
||||
This parameter must be a value of @ref RCC_PLL_Clock_Source */
|
||||
|
||||
} RCC_PLLInitTypeDef;
|
||||
#endif
|
||||
/**
|
||||
* @brief RCC Internal/External Oscillator (HSE, HSI, LSE and LSI) configuration structure definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t OscillatorType; /*!< The oscillators to be configured.
|
||||
This parameter can be a value of @ref RCC_Oscillator_Type */
|
||||
|
||||
uint32_t HSEState; /*!< The new state of the HSE.
|
||||
This parameter can be a value of @ref RCC_HSE_Config */
|
||||
|
||||
uint32_t HSEFreq; /*!< The frequency range of the HSE.
|
||||
This parameter can be a value of @ref RCC_HSE_Freq */
|
||||
#if defined(RCC_LSE_SUPPORT)
|
||||
uint32_t LSEState; /*!< The new state of the LSE.
|
||||
This parameter can be a value of @ref RCC_LSE_Config */
|
||||
|
||||
uint32_t LSEDriver; /*!< The driver factor of the LSE.
|
||||
This parameter can be a value of @ref RCC_LSE_Driver */
|
||||
#endif
|
||||
uint32_t HSIState; /*!< The new state of the HSI.
|
||||
This parameter can be a value of @ref RCC_HSI_Config */
|
||||
|
||||
uint32_t HSIDiv; /*!< The division factor of the HSI.
|
||||
This parameter can be a value of @ref RCC_HSI_Div */
|
||||
|
||||
uint32_t HSICalibrationValue; /*!< The calibration trimming value (default is RCC_HSICALIBRATION_8MHz).
|
||||
This parameter can be a value of @ref RCC_HSI_Calibration */
|
||||
|
||||
uint32_t LSIState; /*!< The new state of the LSI.
|
||||
This parameter can be a value of @ref RCC_LSI_Config */
|
||||
#if defined(RCC_PLL_SUPPORT)
|
||||
RCC_PLLInitTypeDef PLL; /*!< Main PLL structure parameters */
|
||||
#endif
|
||||
|
||||
} RCC_OscInitTypeDef;
|
||||
|
||||
/**
|
||||
* @brief RCC System, AHB and APB busses clock configuration structure definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t ClockType; /*!< The clock to be configured.
|
||||
This parameter can be a combination of @ref RCC_System_Clock_Type */
|
||||
|
||||
uint32_t SYSCLKSource; /*!< The clock source used as system clock (SYSCLK).
|
||||
This parameter can be a value of @ref RCC_System_Clock_Source */
|
||||
|
||||
uint32_t AHBCLKDivider; /*!< The AHB clock (HCLK) divider. This clock is derived from the system clock (SYSCLK).
|
||||
This parameter can be a value of @ref RCC_AHB_Clock_Source */
|
||||
|
||||
uint32_t APB1CLKDivider; /*!< The APB1 clock (PCLK1) divider. This clock is derived from the AHB clock (HCLK).
|
||||
This parameter can be a value of @ref RCC_APB1_Clock_Source */
|
||||
|
||||
|
||||
} RCC_ClkInitTypeDef;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/** @defgroup RCC_Exported_Constants RCC Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup RCC_Timeout_Value Timeout Values
|
||||
* @{
|
||||
*/
|
||||
#define RCC_DBP_TIMEOUT_VALUE 2U /* 2 ms (minimum Tick + 1) */
|
||||
#if defined(RCC_LSE_SUPPORT)
|
||||
#define RCC_LSE_TIMEOUT_VALUE LSE_STARTUP_TIMEOUT /* LSE timeout in ms */
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup RCC_Oscillator_Type Oscillator Type
|
||||
* @{
|
||||
*/
|
||||
#define RCC_OSCILLATORTYPE_NONE 0x00000000U /*!< Oscillator configuration unchanged */
|
||||
#define RCC_OSCILLATORTYPE_HSE 0x00000001U /*!< HSE to configure */
|
||||
#define RCC_OSCILLATORTYPE_HSI 0x00000002U /*!< HSI to configure */
|
||||
#if defined(RCC_LSE_SUPPORT)
|
||||
#define RCC_OSCILLATORTYPE_LSE 0x00000004U /*!< LSE to configure */
|
||||
#endif
|
||||
#define RCC_OSCILLATORTYPE_LSI 0x00000008U /*!< LSI to configure */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup RCC_HSE_Config HSE Config
|
||||
* @{
|
||||
*/
|
||||
#define RCC_HSE_OFF 0x00000000U /*!< HSE clock deactivation */
|
||||
#define RCC_HSE_ON RCC_CR_HSEON /*!< HSE clock activation */
|
||||
#define RCC_HSE_BYPASS ((uint32_t)(RCC_CR_HSEBYP | RCC_CR_HSEON)) /*!< External clock source for HSE clock */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup RCC_HSE_Freq HSE Config
|
||||
* @{
|
||||
*/
|
||||
#define RCC_HSE_4_8MHz RCC_ECSCR_HSE_FREQ_0
|
||||
#define RCC_HSE_8_16MHz RCC_ECSCR_HSE_FREQ_1
|
||||
#if defined(PY32F002APRE)
|
||||
#define RCC_HSE_16_24MHz (RCC_ECSCR_HSE_FREQ_0 | RCC_ECSCR_HSE_FREQ_1)
|
||||
#else
|
||||
#define RCC_HSE_16_32MHz (RCC_ECSCR_HSE_FREQ_0 | RCC_ECSCR_HSE_FREQ_1)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#if defined(RCC_LSE_SUPPORT)
|
||||
/** @defgroup RCC_LSE_Config LSE Config
|
||||
* @{
|
||||
*/
|
||||
#define RCC_LSE_OFF 0x00000000U /*!< LSE clock deactivation */
|
||||
#define RCC_LSE_ON RCC_BDCR_LSEON /*!< LSE clock activation */
|
||||
#define RCC_LSE_BYPASS ((uint32_t)(RCC_BDCR_LSEBYP | RCC_BDCR_LSEON)) /*!< External clock source for LSE clock */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup RCC_LSE_Driver LSE Config
|
||||
* @{
|
||||
*/
|
||||
#define RCC_LSEDRIVE_LOW RCC_ECSCR_LSE_DRIVER_0 /*!< LSE low drive capability */
|
||||
#define RCC_LSEDRIVE_MEDIUM RCC_ECSCR_LSE_DRIVER_1 /*!< LSE medium drive capability */
|
||||
#define RCC_LSEDRIVE_HIGH (RCC_ECSCR_LSE_DRIVER_0 | RCC_ECSCR_LSE_DRIVER_1) /*!< LSE high drive capability */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif
|
||||
/** @defgroup RCC_HSI_Config HSI Config
|
||||
* @{
|
||||
*/
|
||||
#define RCC_HSI_OFF 0x00000000U /*!< HSI clock deactivation */
|
||||
#define RCC_HSI_ON RCC_CR_HSION /*!< HSI clock activation */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup RCC_HSI_Calibration HSI Calibration
|
||||
* @{
|
||||
*/
|
||||
#if defined(PY32F002APRE)
|
||||
#define RCC_HSICALIBRATION_8MHz ((0x1<<13) | ((*(uint32_t *)(0x1FFF0F04)) & 0x1FFF)) /*!< 8MHz HSI calibration trimming value */
|
||||
#define RCC_HSICALIBRATION_24MHz ((0x4<<13) | ((*(uint32_t *)(0x1FFF0F10)) & 0x1FFF)) /*!< 24MHz HSI calibration trimming value */
|
||||
#else
|
||||
#define RCC_HSICALIBRATION_4MHz ((0x0<<13) | ((*(uint32_t *)(0x1FFF0F00)) & 0x1FFF)) /*!< 4MHz HSI calibration trimming value */
|
||||
#define RCC_HSICALIBRATION_8MHz ((0x1<<13) | ((*(uint32_t *)(0x1FFF0F04)) & 0x1FFF)) /*!< 8MHz HSI calibration trimming value */
|
||||
#define RCC_HSICALIBRATION_16MHz ((0x2<<13) | ((*(uint32_t *)(0x1FFF0F08)) & 0x1FFF)) /*!< 16MHz HSI calibration trimming value */
|
||||
#define RCC_HSICALIBRATION_22p12MHz ((0x3<<13) | ((*(uint32_t *)(0x1FFF0F0C)) & 0x1FFF)) /*!< 22.12MHz HSI calibration trimming value */
|
||||
#define RCC_HSICALIBRATION_24MHz ((0x4<<13) | ((*(uint32_t *)(0x1FFF0F10)) & 0x1FFF)) /*!< 24MHz HSI calibration trimming value */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup RCC_HSI_Div HSI Div
|
||||
* @{
|
||||
*/
|
||||
#define RCC_HSI_DIV1 0x00000000U /*!< HSI clock is not divided */
|
||||
#define RCC_HSI_DIV2 RCC_CR_HSIDIV_0 /*!< HSI clock is divided by 2 */
|
||||
#define RCC_HSI_DIV4 RCC_CR_HSIDIV_1 /*!< HSI clock is divided by 4 */
|
||||
#define RCC_HSI_DIV8 (RCC_CR_HSIDIV_1|RCC_CR_HSIDIV_0) /*!< HSI clock is divided by 8 */
|
||||
#define RCC_HSI_DIV16 RCC_CR_HSIDIV_2 /*!< HSI clock is divided by 16 */
|
||||
#define RCC_HSI_DIV32 (RCC_CR_HSIDIV_2|RCC_CR_HSIDIV_0) /*!< HSI clock is divided by 32 */
|
||||
#define RCC_HSI_DIV64 (RCC_CR_HSIDIV_2|RCC_CR_HSIDIV_1) /*!< HSI clock is divided by 64 */
|
||||
#define RCC_HSI_DIV128 (RCC_CR_HSIDIV_2|RCC_CR_HSIDIV_1|RCC_CR_HSIDIV_0) /*!< HSI clock is divided by 128 */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup RCC_LSI_Config LSI Config
|
||||
* @{
|
||||
*/
|
||||
#define RCC_LSI_OFF 0x00000000U /*!< LSI clock deactivation */
|
||||
#define RCC_LSI_ON RCC_CSR_LSION /*!< LSI clock activation */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#if defined(RCC_PLL_SUPPORT)
|
||||
/** @defgroup RCC_PLL_Config PLL Config
|
||||
* @{
|
||||
*/
|
||||
#define RCC_PLL_NONE 0x00000000U /*!< PLL configuration unchanged */
|
||||
#define RCC_PLL_OFF 0x00000001U /*!< PLL deactivation */
|
||||
#define RCC_PLL_ON 0x00000002U /*!< PLL activation */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup RCC_PLL_Clock_Source PLL Clock Source
|
||||
* @{
|
||||
*/
|
||||
#define RCC_PLLSOURCE_NONE 0x00000000U /*!< No clock selected as PLL entry clock source */
|
||||
#define RCC_PLLSOURCE_HSI RCC_PLLCFGR_PLLSRC_HSI /*!< HSI clock selected as PLL entry clock source */
|
||||
#define RCC_PLLSOURCE_HSE RCC_PLLCFGR_PLLSRC_HSE /*!< HSE clock selected as PLL entry clock source */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif
|
||||
/** @defgroup RCC_System_Clock_Type System Clock Type
|
||||
* @{
|
||||
*/
|
||||
#define RCC_CLOCKTYPE_SYSCLK 0x00000001U /*!< SYSCLK to configure */
|
||||
#define RCC_CLOCKTYPE_HCLK 0x00000002U /*!< HCLK to configure */
|
||||
#define RCC_CLOCKTYPE_PCLK1 0x00000004U /*!< PCLK1 to configure */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup RCC_System_Clock_Source System Clock Source
|
||||
* @{
|
||||
*/
|
||||
#define RCC_SYSCLKSOURCE_HSI 0x00000000U /*!< HSI selection as system clock */
|
||||
#define RCC_SYSCLKSOURCE_HSE RCC_CFGR_SW_0 /*!< HSE selection as system clock */
|
||||
#if defined(RCC_PLL_SUPPORT)
|
||||
#define RCC_SYSCLKSOURCE_PLLCLK RCC_CFGR_SW_1 /*!< PLL selection as system clock */
|
||||
#endif
|
||||
#define RCC_SYSCLKSOURCE_LSI (RCC_CFGR_SW_1 | RCC_CFGR_SW_0) /*!< LSI selection as system clock */
|
||||
#if defined(RCC_LSE_SUPPORT)
|
||||
#define RCC_SYSCLKSOURCE_LSE RCC_CFGR_SW_2 /*!< LSE selection as system clock */
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup RCC_System_Clock_Source_Status System Clock Source Status
|
||||
* @{
|
||||
*/
|
||||
#define RCC_SYSCLKSOURCE_STATUS_HSI 0x00000000U /*!< HSI used as system clock */
|
||||
#define RCC_SYSCLKSOURCE_STATUS_HSE RCC_CFGR_SWS_0 /*!< HSE used as system clock */
|
||||
#if defined(RCC_PLL_SUPPORT)
|
||||
#define RCC_SYSCLKSOURCE_STATUS_PLLCLK RCC_CFGR_SWS_1 /*!< PLL used as system clock */
|
||||
#endif
|
||||
#define RCC_SYSCLKSOURCE_STATUS_LSI (RCC_CFGR_SWS_1 | RCC_CFGR_SWS_0) /*!< LSI used as system clock */
|
||||
#if defined(RCC_LSE_SUPPORT)
|
||||
#define RCC_SYSCLKSOURCE_STATUS_LSE RCC_CFGR_SWS_2 /*!< LSE used as system clock */
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup RCC_AHB_Clock_Source AHB Clock Source
|
||||
* @{
|
||||
*/
|
||||
#define RCC_SYSCLK_DIV1 0x00000000U /*!< SYSCLK not divided */
|
||||
#define RCC_SYSCLK_DIV2 RCC_CFGR_HPRE_3 /*!< SYSCLK divided by 2 */
|
||||
#define RCC_SYSCLK_DIV4 (RCC_CFGR_HPRE_3 | RCC_CFGR_HPRE_0) /*!< SYSCLK divided by 4 */
|
||||
#define RCC_SYSCLK_DIV8 (RCC_CFGR_HPRE_3 | RCC_CFGR_HPRE_1) /*!< SYSCLK divided by 8 */
|
||||
#define RCC_SYSCLK_DIV16 (RCC_CFGR_HPRE_3 | RCC_CFGR_HPRE_1 | RCC_CFGR_HPRE_0) /*!< SYSCLK divided by 16 */
|
||||
#define RCC_SYSCLK_DIV64 (RCC_CFGR_HPRE_3 | RCC_CFGR_HPRE_2) /*!< SYSCLK divided by 64 */
|
||||
#define RCC_SYSCLK_DIV128 (RCC_CFGR_HPRE_3 | RCC_CFGR_HPRE_2 | RCC_CFGR_HPRE_0) /*!< SYSCLK divided by 128 */
|
||||
#define RCC_SYSCLK_DIV256 (RCC_CFGR_HPRE_3 | RCC_CFGR_HPRE_2 | RCC_CFGR_HPRE_1) /*!< SYSCLK divided by 256 */
|
||||
#define RCC_SYSCLK_DIV512 (RCC_CFGR_HPRE_3 | RCC_CFGR_HPRE_2 | RCC_CFGR_HPRE_1 | RCC_CFGR_HPRE_0) /*!< SYSCLK divided by 512 */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup RCC_APB1_Clock_Source APB Clock Source
|
||||
* @{
|
||||
*/
|
||||
#define RCC_HCLK_DIV1 0x00000000U /*!< HCLK not divided */
|
||||
#define RCC_HCLK_DIV2 RCC_CFGR_PPRE_2 /*!< HCLK divided by 2 */
|
||||
#define RCC_HCLK_DIV4 (RCC_CFGR_PPRE_2 | RCC_CFGR_PPRE_0) /*!< HCLK divided by 4 */
|
||||
#define RCC_HCLK_DIV8 (RCC_CFGR_PPRE_2 | RCC_CFGR_PPRE_1) /*!< HCLK divided by 8 */
|
||||
#define RCC_HCLK_DIV16 (RCC_CFGR_PPRE_2 | RCC_CFGR_PPRE_1 | RCC_CFGR_PPRE_0) /*!< HCLK divided by 16 */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#if defined(RCC_BDCR_RTCSEL)
|
||||
/** @defgroup RCC_RTC_Clock_Source RTC Clock Source
|
||||
* @{
|
||||
*/
|
||||
#define RCC_RTCCLKSOURCE_NONE 0x00000000U /*!< No clock configured for RTC */
|
||||
#if defined(RCC_LSE_SUPPORT)
|
||||
#define RCC_RTCCLKSOURCE_LSE RCC_BDCR_RTCSEL_0 /*!< LSE oscillator clock used as RTC clock */
|
||||
#endif
|
||||
#define RCC_RTCCLKSOURCE_LSI RCC_BDCR_RTCSEL_1 /*!< LSI oscillator clock used as RTC clock */
|
||||
#define RCC_RTCCLKSOURCE_HSE_DIV128 RCC_BDCR_RTCSEL /*!< HSE oscillator clock divided by 32 used as RTC clock */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif
|
||||
|
||||
/** @defgroup RCC_MCO_Index MCO Index
|
||||
* @{
|
||||
*/
|
||||
#define RCC_MCO 0x00000000U
|
||||
#define RCC_MCO1 RCC_MCO /*!< PA08 MCO1 to be compliant with other families with 2 MCOs*/
|
||||
#define RCC_MCO2 0x00000001U /*!< Configure PA01 as the clock output. */
|
||||
#define RCC_MCO3 0x00000002U /*!< Configure PA05 as the clock output. */
|
||||
#define RCC_MCO4 0x00000003U /*!< Configure PA09 as the clock output. */
|
||||
#define RCC_MCO5 0x00000004U /*!< Configure PA13 as the clock output.Note:PA13 is SWD_SWDIO Pin */
|
||||
#define RCC_MCO6 0x00000005U /*!< Configure PA14 as the clock output.Note:PA14 is SWD_SWCLK Pin */
|
||||
#define RCC_MCO7 0x00000006U /*!< Configure PF02 as the clock output.Note:Defaults to the reset pin, Optionbyte needs to be configured */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup RCC_MCO1_Clock_Source MCO1 Clock Source
|
||||
* @{
|
||||
*/
|
||||
#define RCC_MCO1SOURCE_NOCLOCK 0x00000000U /*!< MCO1 output disabled, no clock on MCO1 */
|
||||
#define RCC_MCO1SOURCE_SYSCLK RCC_CFGR_MCOSEL_0 /*!< SYSCLK selection as MCO1 source */
|
||||
#define RCC_MCO1SOURCE_HSI10M RCC_CFGR_MCOSEL_1
|
||||
#define RCC_MCO1SOURCE_HSI (RCC_CFGR_MCOSEL_0| RCC_CFGR_MCOSEL_1) /*!< HSI selection as MCO1 source */
|
||||
#define RCC_MCO1SOURCE_HSE RCC_CFGR_MCOSEL_2 /*!< HSE selection as MCO1 source */
|
||||
#if defined(RCC_PLL_SUPPORT)
|
||||
#define RCC_MCO1SOURCE_PLLCLK (RCC_CFGR_MCOSEL_0|RCC_CFGR_MCOSEL_2) /*!< PLLCLK selection as MCO1 source */
|
||||
#endif
|
||||
#define RCC_MCO1SOURCE_LSI (RCC_CFGR_MCOSEL_1|RCC_CFGR_MCOSEL_2) /*!< LSI selection as MCO1 source */
|
||||
#if defined(RCC_LSE_SUPPORT)
|
||||
#define RCC_MCO1SOURCE_LSE (RCC_CFGR_MCOSEL_0|RCC_CFGR_MCOSEL_1|RCC_CFGR_MCOSEL_2) /*!< LSE selection as MCO1 source */
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup RCC_MCOx_Clock_Prescaler MCO1 Clock Prescaler
|
||||
* @{
|
||||
*/
|
||||
#define RCC_MCODIV_1 0x00000000U /*!< MCO not divided */
|
||||
#define RCC_MCODIV_2 RCC_CFGR_MCOPRE_0 /*!< MCO divided by 2 */
|
||||
#define RCC_MCODIV_4 RCC_CFGR_MCOPRE_1 /*!< MCO divided by 4 */
|
||||
#define RCC_MCODIV_8 (RCC_CFGR_MCOPRE_1 | RCC_CFGR_MCOPRE_0) /*!< MCO divided by 8 */
|
||||
#define RCC_MCODIV_16 RCC_CFGR_MCOPRE_2 /*!< MCO divided by 16 */
|
||||
#define RCC_MCODIV_32 (RCC_CFGR_MCOPRE_2 | RCC_CFGR_MCOPRE_0) /*!< MCO divided by 32 */
|
||||
#define RCC_MCODIV_64 (RCC_CFGR_MCOPRE_2 | RCC_CFGR_MCOPRE_1) /*!< MCO divided by 64 */
|
||||
#define RCC_MCODIV_128 (RCC_CFGR_MCOPRE_2 | RCC_CFGR_MCOPRE_1 | RCC_CFGR_MCOPRE_0) /*!< MCO divided by 128 */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup RCC_Interrupt Interrupts
|
||||
* @{
|
||||
*/
|
||||
#define RCC_IT_LSIRDY RCC_CIFR_LSIRDYF /*!< LSI Ready Interrupt flag */
|
||||
#if defined(RCC_LSE_SUPPORT)
|
||||
#define RCC_IT_LSERDY RCC_CIFR_LSERDYF /*!< LSE Ready Interrupt flag */
|
||||
#define RCC_IT_LSECSS RCC_CIFR_LSECSSF /*!< LSE Clock Security System Interrupt flag */
|
||||
#endif
|
||||
#define RCC_IT_HSIRDY RCC_CIFR_HSIRDYF /*!< HSI Ready Interrupt flag */
|
||||
#define RCC_IT_HSERDY RCC_CIFR_HSERDYF /*!< HSE Ready Interrupt flag */
|
||||
#if defined(RCC_PLL_SUPPORT)
|
||||
#define RCC_IT_PLLRDY RCC_CIFR_PLLRDYF /*!< PLL Ready Interrupt flag */
|
||||
#endif
|
||||
#define RCC_IT_CSS RCC_CIFR_CSSF /*!< HSE Clock Security System Interrupt flag */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup RCC_Flag Flags
|
||||
* Elements values convention: XXXYYYYYb
|
||||
* - YYYYY : Flag position in the register
|
||||
* - XXX : Register index
|
||||
* - 001: CR register
|
||||
* - 010: BDCR register
|
||||
* - 011: CSR register
|
||||
* @{
|
||||
*/
|
||||
/* Flags in the CR register */
|
||||
#define RCC_FLAG_HSIRDY ((CR_REG_INDEX << 5U) | RCC_CR_HSIRDY_Pos) /*!< HSI Ready flag */
|
||||
#define RCC_FLAG_HSERDY ((CR_REG_INDEX << 5U) | RCC_CR_HSERDY_Pos) /*!< HSE Ready flag */
|
||||
#if defined(RCC_PLL_SUPPORT)
|
||||
#define RCC_FLAG_PLLRDY ((CR_REG_INDEX << 5U) | RCC_CR_PLLRDY_Pos) /*!< PLL Ready flag */
|
||||
#endif
|
||||
|
||||
#if defined(RCC_LSE_SUPPORT)
|
||||
/* Flags in the BDCR register */
|
||||
#define RCC_FLAG_LSERDY ((BDCR_REG_INDEX << 5U) | RCC_BDCR_LSERDY_Pos) /*!< LSE Ready flag */
|
||||
#endif
|
||||
|
||||
/* Flags in the CSR register */
|
||||
#define RCC_FLAG_LSIRDY ((CSR_REG_INDEX << 5U) | RCC_CSR_LSIRDY_Pos) /*!< LSI Ready flag */
|
||||
#define RCC_FLAG_OBLRST ((CSR_REG_INDEX << 5U) | RCC_CSR_OBLRSTF_Pos) /*!< Option Byte Loader reset flag */
|
||||
#define RCC_FLAG_PINRST ((CSR_REG_INDEX << 5U) | RCC_CSR_PINRSTF_Pos) /*!< PIN reset flag */
|
||||
#define RCC_FLAG_PWRRST ((CSR_REG_INDEX << 5U) | RCC_CSR_PWRRSTF_Pos) /*!< BOR or POR/PDR reset flag */
|
||||
#define RCC_FLAG_SFTRST ((CSR_REG_INDEX << 5U) | RCC_CSR_SFTRSTF_Pos) /*!< Software Reset flag */
|
||||
#define RCC_FLAG_IWDGRST ((CSR_REG_INDEX << 5U) | RCC_CSR_IWDGRSTF_Pos) /*!< Independent Watchdog reset flag */
|
||||
#if defined(WWDG)
|
||||
#define RCC_FLAG_WWDGRST ((CSR_REG_INDEX << 5U) | RCC_CSR_WWDGRSTF_Pos) /*!< Window watchdog reset flag */
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported macros -----------------------------------------------------------*/
|
||||
|
||||
/** @defgroup RCC_Exported_Macros RCC Exported Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup RCC_AHB_Peripheral_Clock_Enable_Disable AHB Peripheral Clock Enable Disable
|
||||
* @brief Enable or disable the AHB peripheral clock.
|
||||
* @note After reset, the peripheral clock (used for registers read/write access)
|
||||
* is disabled and the application software has to enable this clock before
|
||||
* using it.
|
||||
* @{
|
||||
*/
|
||||
#if (defined(DMA) || defined(DMA1))
|
||||
#define __HAL_RCC_DMA_CLK_ENABLE() do { \
|
||||
__IO uint32_t tmpreg; \
|
||||
SET_BIT(RCC->AHBENR, RCC_AHBENR_DMAEN); \
|
||||
/* Delay after an RCC peripheral clock enabling */ \
|
||||
tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_DMAEN); \
|
||||
UNUSED(tmpreg); \
|
||||
} while(0U)
|
||||
#endif
|
||||
|
||||
#define __HAL_RCC_FLASH_CLK_ENABLE() do { \
|
||||
__IO uint32_t tmpreg; \
|
||||
SET_BIT(RCC->AHBENR, RCC_AHBENR_FLASHEN); \
|
||||
/* Delay after an RCC peripheral clock enabling */ \
|
||||
tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_FLASHEN); \
|
||||
UNUSED(tmpreg); \
|
||||
} while(0U)
|
||||
|
||||
#define __HAL_RCC_SRAM_CLK_ENABLE() do { \
|
||||
__IO uint32_t tmpreg; \
|
||||
SET_BIT(RCC->AHBENR, RCC_AHBENR_SRAMEN); \
|
||||
/* Delay after an RCC peripheral clock enabling */ \
|
||||
tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_SRAMEN); \
|
||||
UNUSED(tmpreg); \
|
||||
} while(0U)
|
||||
#define __HAL_RCC_CRC_CLK_ENABLE() do { \
|
||||
__IO uint32_t tmpreg; \
|
||||
SET_BIT(RCC->AHBENR, RCC_AHBENR_CRCEN); \
|
||||
/* Delay after an RCC peripheral clock enabling */ \
|
||||
tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_CRCEN); \
|
||||
UNUSED(tmpreg); \
|
||||
} while(0U)
|
||||
#if (defined(DMA) || defined(DMA1))
|
||||
#define __HAL_RCC_DMA_CLK_DISABLE() CLEAR_BIT(RCC->AHBENR, RCC_AHBENR_DMAEN)
|
||||
#endif
|
||||
#define __HAL_RCC_FLASH_CLK_DISABLE() CLEAR_BIT(RCC->AHBENR, RCC_AHBENR_FLASHEN)
|
||||
#define __HAL_RCC_SRAM_CLK_DISABLE() CLEAR_BIT(RCC->AHBENR, RCC_AHBENR_SRAMEN)
|
||||
#define __HAL_RCC_CRC_CLK_DISABLE() CLEAR_BIT(RCC->AHBENR, RCC_AHBENR_CRCEN)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup RCC_IOPORT_Clock_Enable_Disable IOPORT Clock Enable Disable
|
||||
* @brief Enable or disable the IO Ports clock.
|
||||
* @note After reset, the IO ports clock (used for registers read/write access)
|
||||
* is disabled and the application software has to enable this clock before
|
||||
* using it.
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define __HAL_RCC_GPIOA_CLK_ENABLE() do { \
|
||||
__IO uint32_t tmpreg; \
|
||||
SET_BIT(RCC->IOPENR, RCC_IOPENR_GPIOAEN); \
|
||||
/* Delay after an RCC peripheral clock enabling */ \
|
||||
tmpreg = READ_BIT(RCC->IOPENR, RCC_IOPENR_GPIOAEN); \
|
||||
UNUSED(tmpreg); \
|
||||
} while(0U)
|
||||
|
||||
#define __HAL_RCC_GPIOB_CLK_ENABLE() do { \
|
||||
__IO uint32_t tmpreg; \
|
||||
SET_BIT(RCC->IOPENR, RCC_IOPENR_GPIOBEN); \
|
||||
/* Delay after an RCC peripheral clock enabling */ \
|
||||
tmpreg = READ_BIT(RCC->IOPENR, RCC_IOPENR_GPIOBEN); \
|
||||
UNUSED(tmpreg); \
|
||||
} while(0U)
|
||||
|
||||
#define __HAL_RCC_GPIOF_CLK_ENABLE() do { \
|
||||
__IO uint32_t tmpreg; \
|
||||
SET_BIT(RCC->IOPENR, RCC_IOPENR_GPIOFEN); \
|
||||
/* Delay after an RCC peripheral clock enabling */ \
|
||||
tmpreg = READ_BIT(RCC->IOPENR, RCC_IOPENR_GPIOFEN); \
|
||||
UNUSED(tmpreg); \
|
||||
} while(0U)
|
||||
|
||||
#define __HAL_RCC_GPIOA_CLK_DISABLE() CLEAR_BIT(RCC->IOPENR, RCC_IOPENR_GPIOAEN)
|
||||
#define __HAL_RCC_GPIOB_CLK_DISABLE() CLEAR_BIT(RCC->IOPENR, RCC_IOPENR_GPIOBEN)
|
||||
#define __HAL_RCC_GPIOF_CLK_DISABLE() CLEAR_BIT(RCC->IOPENR, RCC_IOPENR_GPIOFEN)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup RCC_APB1_Clock_Enable_Disable APB1 Peripheral Clock Enable Disable
|
||||
* @brief Enable or disable the APB1 peripheral clock.
|
||||
* @note After reset, the peripheral clock (used for registers read/write access)
|
||||
* is disabled and the application software has to enable this clock before
|
||||
* using it.
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if defined(TIM3)
|
||||
#define __HAL_RCC_TIM3_CLK_ENABLE() do { \
|
||||
__IO uint32_t tmpreg; \
|
||||
SET_BIT(RCC->APBENR1, RCC_APBENR1_TIM3EN); \
|
||||
/* Delay after an RCC peripheral clock enabling */ \
|
||||
tmpreg = READ_BIT(RCC->APBENR1, RCC_APBENR1_TIM3EN); \
|
||||
UNUSED(tmpreg); \
|
||||
} while(0U)
|
||||
#endif
|
||||
|
||||
#if defined(RTC)
|
||||
#define __HAL_RCC_RTCAPB_CLK_ENABLE() do { \
|
||||
__IO uint32_t tmpreg; \
|
||||
SET_BIT(RCC->APBENR1, RCC_APBENR1_RTCAPBEN); \
|
||||
/* Delay after an RCC peripheral clock enabling */ \
|
||||
tmpreg = READ_BIT(RCC->APBENR1, RCC_APBENR1_RTCAPBEN); \
|
||||
UNUSED(tmpreg); \
|
||||
} while(0U)
|
||||
#endif
|
||||
|
||||
#if defined(WWDG)
|
||||
#define __HAL_RCC_WWDG_CLK_ENABLE() do { \
|
||||
__IO uint32_t tmpreg; \
|
||||
SET_BIT(RCC->APBENR1, RCC_APBENR1_WWDGEN); \
|
||||
/* Delay after an RCC peripheral clock enabling */ \
|
||||
tmpreg = READ_BIT(RCC->APBENR1, RCC_APBENR1_WWDGEN); \
|
||||
UNUSED(tmpreg); \
|
||||
} while(0U)
|
||||
#endif
|
||||
|
||||
#if defined(SPI2)
|
||||
#define __HAL_RCC_SPI2_CLK_ENABLE() do { \
|
||||
__IO uint32_t tmpreg; \
|
||||
SET_BIT(RCC->APBENR1, RCC_APBENR1_SPI2EN); \
|
||||
/* Delay after an RCC peripheral clock enabling */ \
|
||||
tmpreg = READ_BIT(RCC->APBENR1, RCC_APBENR1_SPI2EN); \
|
||||
UNUSED(tmpreg); \
|
||||
} while(0U)
|
||||
#endif
|
||||
|
||||
#if defined(USART2)
|
||||
#define __HAL_RCC_USART2_CLK_ENABLE() do { \
|
||||
__IO uint32_t tmpreg; \
|
||||
SET_BIT(RCC->APBENR1, RCC_APBENR1_USART2EN); \
|
||||
/* Delay after an RCC peripheral clock enabling */ \
|
||||
tmpreg = READ_BIT(RCC->APBENR1, RCC_APBENR1_USART2EN); \
|
||||
UNUSED(tmpreg); \
|
||||
} while(0U)
|
||||
#endif
|
||||
|
||||
#define __HAL_RCC_I2C_CLK_ENABLE() do { \
|
||||
__IO uint32_t tmpreg; \
|
||||
SET_BIT(RCC->APBENR1, RCC_APBENR1_I2CEN); \
|
||||
/* Delay after an RCC peripheral clock enabling */ \
|
||||
tmpreg = READ_BIT(RCC->APBENR1, RCC_APBENR1_I2CEN); \
|
||||
UNUSED(tmpreg); \
|
||||
} while(0U)
|
||||
|
||||
#define __HAL_RCC_DBGMCU_CLK_ENABLE() do { \
|
||||
__IO uint32_t tmpreg; \
|
||||
SET_BIT(RCC->APBENR1, RCC_APBENR1_DBGEN); \
|
||||
/* Delay after an RCC peripheral clock enabling */ \
|
||||
tmpreg = READ_BIT(RCC->APBENR1, RCC_APBENR1_DBGEN); \
|
||||
UNUSED(tmpreg); \
|
||||
} while(0U)
|
||||
|
||||
#define __HAL_RCC_PWR_CLK_ENABLE() do { \
|
||||
__IO uint32_t tmpreg; \
|
||||
SET_BIT(RCC->APBENR1, RCC_APBENR1_PWREN); \
|
||||
/* Delay after an RCC peripheral clock enabling */ \
|
||||
tmpreg = READ_BIT(RCC->APBENR1, RCC_APBENR1_PWREN); \
|
||||
UNUSED(tmpreg); \
|
||||
} while(0U)
|
||||
|
||||
#define __HAL_RCC_LPTIM_CLK_ENABLE() do { \
|
||||
__IO uint32_t tmpreg; \
|
||||
SET_BIT(RCC->APBENR1, RCC_APBENR1_LPTIMEN); \
|
||||
/* Delay after an RCC peripheral clock enabling */ \
|
||||
tmpreg = READ_BIT(RCC->APBENR1, RCC_APBENR1_LPTIMEN); \
|
||||
UNUSED(tmpreg); \
|
||||
} while(0U)
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup RCC_APB2_Clock_Enable_Disable APB2 Peripheral Clock Enable Disable
|
||||
* @brief Enable or disable the APB2 peripheral clock.
|
||||
* @note After reset, the peripheral clock (used for registers read/write access)
|
||||
* is disabled and the application software has to enable this clock before
|
||||
* using it.
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define __HAL_RCC_SYSCFG_CLK_ENABLE() do { \
|
||||
__IO uint32_t tmpreg; \
|
||||
SET_BIT(RCC->APBENR2, RCC_APBENR2_SYSCFGEN); \
|
||||
/* Delay after an RCC peripheral clock enabling */ \
|
||||
tmpreg = READ_BIT(RCC->APBENR2, RCC_APBENR2_SYSCFGEN); \
|
||||
UNUSED(tmpreg); \
|
||||
} while(0U)
|
||||
|
||||
#define __HAL_RCC_TIM1_CLK_ENABLE() do { \
|
||||
__IO uint32_t tmpreg; \
|
||||
SET_BIT(RCC->APBENR2, RCC_APBENR2_TIM1EN); \
|
||||
/* Delay after an RCC peripheral clock enabling */ \
|
||||
tmpreg = READ_BIT(RCC->APBENR2, RCC_APBENR2_TIM1EN); \
|
||||
UNUSED(tmpreg); \
|
||||
} while(0U)
|
||||
|
||||
#define __HAL_RCC_SPI1_CLK_ENABLE() do { \
|
||||
__IO uint32_t tmpreg; \
|
||||
SET_BIT(RCC->APBENR2, RCC_APBENR2_SPI1EN); \
|
||||
/* Delay after an RCC peripheral clock enabling */ \
|
||||
tmpreg = READ_BIT(RCC->APBENR2, RCC_APBENR2_SPI1EN); \
|
||||
UNUSED(tmpreg); \
|
||||
} while(0U)
|
||||
|
||||
#define __HAL_RCC_USART1_CLK_ENABLE() do { \
|
||||
__IO uint32_t tmpreg; \
|
||||
SET_BIT(RCC->APBENR2, RCC_APBENR2_USART1EN); \
|
||||
/* Delay after an RCC peripheral clock enabling */ \
|
||||
tmpreg = READ_BIT(RCC->APBENR2, RCC_APBENR2_USART1EN); \
|
||||
UNUSED(tmpreg); \
|
||||
} while(0U)
|
||||
#if defined(TIM_MB)
|
||||
#define __HAL_RCC_TIM14_CLK_ENABLE() do { \
|
||||
__IO uint32_t tmpreg; \
|
||||
SET_BIT(RCC->APBENR2, RCC_APBENR2_TIM14EN); \
|
||||
/* Delay after an RCC peripheral clock enabling */ \
|
||||
tmpreg = READ_BIT(RCC->APBENR2, RCC_APBENR2_TIM14EN); \
|
||||
UNUSED(tmpreg); \
|
||||
} while(0U)
|
||||
#endif
|
||||
|
||||
#define __HAL_RCC_TIM16_CLK_ENABLE() do { \
|
||||
__IO uint32_t tmpreg; \
|
||||
SET_BIT(RCC->APBENR2, RCC_APBENR2_TIM16EN); \
|
||||
/* Delay after an RCC peripheral clock enabling */ \
|
||||
tmpreg = READ_BIT(RCC->APBENR2, RCC_APBENR2_TIM16EN); \
|
||||
UNUSED(tmpreg); \
|
||||
} while(0U)
|
||||
#if defined(TIM17)
|
||||
#define __HAL_RCC_TIM17_CLK_ENABLE() do { \
|
||||
__IO uint32_t tmpreg; \
|
||||
SET_BIT(RCC->APBENR2, RCC_APBENR2_TIM17EN); \
|
||||
/* Delay after an RCC peripheral clock enabling */ \
|
||||
tmpreg = READ_BIT(RCC->APBENR2, RCC_APBENR2_TIM17EN); \
|
||||
UNUSED(tmpreg); \
|
||||
} while(0U)
|
||||
#endif
|
||||
|
||||
#define __HAL_RCC_ADC_CLK_ENABLE() do { \
|
||||
__IO uint32_t tmpreg; \
|
||||
SET_BIT(RCC->APBENR2, RCC_APBENR2_ADCEN); \
|
||||
/* Delay after an RCC peripheral clock enabling */ \
|
||||
tmpreg = READ_BIT(RCC->APBENR2, RCC_APBENR2_ADCEN); \
|
||||
UNUSED(tmpreg); \
|
||||
} while(0U)
|
||||
#if defined(COMP1)
|
||||
#define __HAL_RCC_COMP1_CLK_ENABLE() do { \
|
||||
__IO uint32_t tmpreg; \
|
||||
SET_BIT(RCC->APBENR2, RCC_APBENR2_COMP1EN); \
|
||||
/* Delay after an RCC peripheral clock enabling */ \
|
||||
tmpreg = READ_BIT(RCC->APBENR2, RCC_APBENR2_COMP1EN); \
|
||||
UNUSED(tmpreg); \
|
||||
} while(0U)
|
||||
#endif
|
||||
|
||||
#if defined(COMP2)
|
||||
#define __HAL_RCC_COMP2_CLK_ENABLE() do { \
|
||||
__IO uint32_t tmpreg; \
|
||||
SET_BIT(RCC->APBENR2, RCC_APBENR2_COMP2EN); \
|
||||
/* Delay after an RCC peripheral clock enabling */ \
|
||||
tmpreg = READ_BIT(RCC->APBENR2, RCC_APBENR2_COMP2EN); \
|
||||
UNUSED(tmpreg); \
|
||||
} while(0U)
|
||||
#endif
|
||||
|
||||
#if defined(LED)
|
||||
#define __HAL_RCC_LED_CLK_ENABLE() do { \
|
||||
__IO uint32_t tmpreg; \
|
||||
SET_BIT(RCC->APBENR2, RCC_APBENR2_LEDEN); \
|
||||
/* Delay after an RCC peripheral clock enabling */ \
|
||||
tmpreg = READ_BIT(RCC->APBENR2, RCC_APBENR2_LEDEN); \
|
||||
UNUSED(tmpreg); \
|
||||
} while(0U)
|
||||
#endif
|
||||
|
||||
#if defined(TIM3)
|
||||
#define __HAL_RCC_TIM3_CLK_DISABLE() CLEAR_BIT(RCC->APBENR1, RCC_APBENR1_TIM3EN)
|
||||
#endif
|
||||
#if defined(RTC)
|
||||
#define __HAL_RCC_RTCAPB_CLK_DISABLE() CLEAR_BIT(RCC->APBENR1, RCC_APBENR1_RTCAPBEN)
|
||||
#endif
|
||||
#if defined(SPI2)
|
||||
#define __HAL_RCC_SPI2_CLK_DISABLE() CLEAR_BIT(RCC->APBENR1, RCC_APBENR1_SPI2EN)
|
||||
#endif
|
||||
#if defined(USART2)
|
||||
#define __HAL_RCC_USART2_CLK_DISABLE() CLEAR_BIT(RCC->APBENR1, RCC_APBENR1_USART2EN)
|
||||
#endif
|
||||
#define __HAL_RCC_I2C_CLK_DISABLE() CLEAR_BIT(RCC->APBENR1, RCC_APBENR1_I2CEN)
|
||||
#define __HAL_RCC_DBGMCU_CLK_DISABLE() CLEAR_BIT(RCC->APBENR1, RCC_APBENR1_DBGEN)
|
||||
#define __HAL_RCC_PWR_CLK_DISABLE() CLEAR_BIT(RCC->APBENR1, RCC_APBENR1_PWREN)
|
||||
#define __HAL_RCC_LPTIM_CLK_DISABLE() CLEAR_BIT(RCC->APBENR1, RCC_APBENR1_LPTIMEN)
|
||||
|
||||
#define __HAL_RCC_SYSCFG_CLK_DISABLE() CLEAR_BIT(RCC->APBENR2, RCC_APBENR2_SYSCFGEN)
|
||||
#define __HAL_RCC_TIM1_CLK_DISABLE() CLEAR_BIT(RCC->APBENR2, RCC_APBENR2_TIM1EN)
|
||||
#define __HAL_RCC_SPI1_CLK_DISABLE() CLEAR_BIT(RCC->APBENR2, RCC_APBENR2_SPI1EN)
|
||||
#define __HAL_RCC_USART1_CLK_DISABLE() CLEAR_BIT(RCC->APBENR2, RCC_APBENR2_USART1EN)
|
||||
#if defined(TIM_MB)
|
||||
#define __HAL_RCC_TIM14_CLK_DISABLE() CLEAR_BIT(RCC->APBENR2, RCC_APBENR2_TIM14EN)
|
||||
#endif
|
||||
#define __HAL_RCC_TIM16_CLK_DISABLE() CLEAR_BIT(RCC->APBENR2, RCC_APBENR2_TIM16EN)
|
||||
#if defined(TIM17)
|
||||
#define __HAL_RCC_TIM17_CLK_DISABLE() CLEAR_BIT(RCC->APBENR2, RCC_APBENR2_TIM17EN)
|
||||
#endif
|
||||
#define __HAL_RCC_ADC_CLK_DISABLE() CLEAR_BIT(RCC->APBENR2, RCC_APBENR2_ADCEN)
|
||||
#if defined(COMP1)
|
||||
#define __HAL_RCC_COMP1_CLK_DISABLE() CLEAR_BIT(RCC->APBENR2, RCC_APBENR2_COMP1EN)
|
||||
#endif
|
||||
#if defined(COMP2)
|
||||
#define __HAL_RCC_COMP2_CLK_DISABLE() CLEAR_BIT(RCC->APBENR2, RCC_APBENR2_COMP2EN)
|
||||
#endif
|
||||
#if defined(LED)
|
||||
#define __HAL_RCC_LED_CLK_DISABLE() CLEAR_BIT(RCC->APBENR2, RCC_APBENR2_LEDEN)
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup RCC_AHB_Peripheral_Clock_Enabled_Disabled_Status AHB Peripheral Clock Enabled or Disabled Status
|
||||
* @brief Check whether the AHB peripheral clock is enabled or not.
|
||||
* @note After reset, the peripheral clock (used for registers read/write access)
|
||||
* is disabled and the application software has to enable this clock before
|
||||
* using it.
|
||||
* @{
|
||||
*/
|
||||
#if (defined(DMA) || defined(DMA1))
|
||||
#define __HAL_RCC_DMA_IS_CLK_ENABLED() (READ_BIT(RCC->AHBENR, RCC_AHBENR_DMAEN) != RESET)
|
||||
#endif
|
||||
#define __HAL_RCC_FLASH_IS_CLK_ENABLED() (READ_BIT(RCC->AHBENR, RCC_AHBENR_FLASHEN) != RESET)
|
||||
#define __HAL_RCC_CRC_IS_CLK_ENABLED() (READ_BIT(RCC->AHBENR, RCC_AHBENR_CRCEN) != RESET)
|
||||
|
||||
#if (defined(DMA) || defined(DMA1))
|
||||
#define __HAL_RCC_DMA_IS_CLK_DISABLED() (READ_BIT(RCC->AHBENR, RCC_AHBENR_DMAEN) == RESET)
|
||||
#endif
|
||||
#define __HAL_RCC_FLASH_IS_CLK_DISABLED() (READ_BIT(RCC->AHBENR, RCC_AHBENR_FLASHEN) == RESET)
|
||||
#define __HAL_RCC_CRC_IS_CLK_DISABLED() (READ_BIT(RCC->AHBENR, RCC_AHBENR_CRCEN) == RESET)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup RCC_IOPORT_Clock_Enabled_Disabled_Status IOPORT Clock Enabled or Disabled Status
|
||||
* @brief Check whether the IO Port clock is enabled or not.
|
||||
* @note After reset, the peripheral clock (used for registers read/write access)
|
||||
* is disabled and the application software has to enable this clock before
|
||||
* using it.
|
||||
* @{
|
||||
*/
|
||||
#define __HAL_RCC_GPIOA_IS_CLK_ENABLED() (READ_BIT(RCC->IOPENR, RCC_IOPENR_GPIOAEN) != RESET)
|
||||
#define __HAL_RCC_GPIOB_IS_CLK_ENABLED() (READ_BIT(RCC->IOPENR, RCC_IOPENR_GPIOBEN) != RESET)
|
||||
#define __HAL_RCC_GPIOF_IS_CLK_ENABLED() (READ_BIT(RCC->IOPENR, RCC_IOPENR_GPIOFEN) != RESET)
|
||||
|
||||
#define __HAL_RCC_GPIOA_IS_CLK_DISABLED() (READ_BIT(RCC->IOPENR, RCC_IOPENR_GPIOAEN) == RESET)
|
||||
#define __HAL_RCC_GPIOB_IS_CLK_DISABLED() (READ_BIT(RCC->IOPENR, RCC_IOPENR_GPIOBEN) == RESET)
|
||||
#define __HAL_RCC_GPIOF_IS_CLK_DISABLED() (READ_BIT(RCC->IOPENR, RCC_IOPENR_GPIOFEN) == RESET)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup RCC_APB1_Clock_Enabled_Disabled_Status APB1 Peripheral Clock Enabled or Disabled Status
|
||||
* @brief Check whether the APB1 peripheral clock is enabled or not.
|
||||
* @note After reset, the peripheral clock (used for registers read/write access)
|
||||
* is disabled and the application software has to enable this clock before
|
||||
* using it.
|
||||
* @{
|
||||
*/
|
||||
#if defined(TIM3)
|
||||
#define __HAL_RCC_TIM3_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_TIM3EN) != 0U)
|
||||
#endif
|
||||
#if defined(RTC)
|
||||
#define __HAL_RCC_RTCAPB_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_RTCAPBEN) != 0U)
|
||||
#endif
|
||||
#if defined(WWDG)
|
||||
#define __HAL_RCC_WWDG_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_WWDGEN) != 0U)
|
||||
#endif
|
||||
#if defined(SPI2)
|
||||
#define __HAL_RCC_SPI2_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_SPI2EN) != 0U)
|
||||
#endif
|
||||
#if defined(USART2)
|
||||
#define __HAL_RCC_USART2_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_USART2EN) != 0U)
|
||||
#endif
|
||||
#define __HAL_RCC_I2C_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_I2CEN) != 0U)
|
||||
#define __HAL_RCC_DBGMCU_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_DBGEN) != 0U)
|
||||
#define __HAL_RCC_PWR_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_PWREN) != 0U)
|
||||
#define __HAL_RCC_LPTIM_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_LPTIMEN) != 0U)
|
||||
|
||||
#if defined(TIM3)
|
||||
#define __HAL_RCC_TIM3_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_TIM3EN) == 0U)
|
||||
#endif
|
||||
#if defined(RTC)
|
||||
#define __HAL_RCC_RTCAPB_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_RTCAPBEN) == 0U)
|
||||
#endif
|
||||
#if defined(WWDG)
|
||||
#define __HAL_RCC_WWDG_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_WWDGEN) == 0U)
|
||||
#endif
|
||||
#if defined(SPI2)
|
||||
#define __HAL_RCC_SPI2_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_SPI2EN) == 0U)
|
||||
#endif
|
||||
#if defined(USART2)
|
||||
#define __HAL_RCC_USART2_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_USART2EN) == 0U)
|
||||
#endif
|
||||
#define __HAL_RCC_I2C1_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_I2CEN) == 0U)
|
||||
#define __HAL_RCC_DBGMCU_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_DBGEN) == 0U)
|
||||
#define __HAL_RCC_PWR_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_PWREN) == 0U)
|
||||
#define __HAL_RCC_LPTIM_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR1, RCC_APBENR1_LPTIMEN) == 0U)
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup RCC_APB2_Clock_Enabled_Disabled_Status APB2 Peripheral Clock Enabled or Disabled Status
|
||||
* @brief Check whether the APB2 peripheral clock is enabled or not.
|
||||
* @note After reset, the peripheral clock (used for registers read/write access)
|
||||
* is disabled and the application software has to enable this clock before
|
||||
* using it.
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define __HAL_RCC_SYSCFG_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR2, RCC_APBENR2_SYSCFGEN) != 0U)
|
||||
#define __HAL_RCC_TIM1_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR2, RCC_APBENR2_TIM1EN) != 0U)
|
||||
#define __HAL_RCC_SPI1_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR2, RCC_APBENR2_SPI1EN) != 0U)
|
||||
#define __HAL_RCC_USART1_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR2, RCC_APBENR2_USART1EN) != 0U)
|
||||
#if defined(TIM_MB)
|
||||
#define __HAL_RCC_TIM14_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR2, RCC_APBENR2_TIM14EN) != 0U)
|
||||
#endif
|
||||
#define __HAL_RCC_TIM16_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR2, RCC_APBENR2_TIM16EN) != 0U)
|
||||
#if defined(TIM17)
|
||||
#define __HAL_RCC_TIM17_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR2, RCC_APBENR2_TIM17EN) != 0U)
|
||||
#endif
|
||||
#define __HAL_RCC_ADC_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR2, RCC_APBENR2_ADCEN) != 0U)
|
||||
#if defined(COMP1)
|
||||
#define __HAL_RCC_COMP1_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR2, RCC_APBENR2_COMP1EN) != 0U)
|
||||
#endif
|
||||
#if defined(COMP2)
|
||||
#define __HAL_RCC_COMP2_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR2, RCC_APBENR2_COMP2EN) != 0U)
|
||||
#endif
|
||||
#if defined(LED)
|
||||
#define __HAL_RCC_LED_IS_CLK_ENABLED() (READ_BIT(RCC->APBENR2, RCC_APBENR2_LEDEN) != 0U)
|
||||
#endif
|
||||
|
||||
#define __HAL_RCC_SYSCFG_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR2, RCC_APBENR2_SYSCFGEN) == 0U)
|
||||
#define __HAL_RCC_TIM1_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR2, RCC_APBENR2_TIM1EN) == 0U)
|
||||
#define __HAL_RCC_SPI1_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR2, RCC_APBENR2_SPI1EN) == 0U)
|
||||
#define __HAL_RCC_USART1_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR2, RCC_APBENR2_USART1EN) == 0U)
|
||||
#if defined(TIM_MB)
|
||||
#define __HAL_RCC_TIM14_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR2, RCC_APBENR2_TIM14EN) == 0U)
|
||||
#endif
|
||||
#define __HAL_RCC_TIM16_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR2, RCC_APBENR2_TIM16EN) == 0U)
|
||||
#if defined(TIM17)
|
||||
#define __HAL_RCC_TIM17_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR2, RCC_APBENR2_TIM17EN) == 0U)
|
||||
#endif
|
||||
#define __HAL_RCC_ADC_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR2, RCC_APBENR2_ADCEN) == 0U)
|
||||
#if defined(COMP1)
|
||||
#define __HAL_RCC_COMP1_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR2, RCC_APBENR2_COMP1EN) == 0U)
|
||||
#endif
|
||||
#if defined(COMP2)
|
||||
#define __HAL_RCC_COMP2_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR2, RCC_APBENR2_COMP2EN) == 0U)
|
||||
#endif
|
||||
#if defined(LED)
|
||||
#define __HAL_RCC_LED_IS_CLK_DISABLED() (READ_BIT(RCC->APBENR2, RCC_APBENR2_LEDEN) == 0U)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup RCC_AHB_Force_Release_Reset AHB Peripheral Force Release Reset
|
||||
* @brief Force or release AHB1 peripheral reset.
|
||||
* @{
|
||||
*/
|
||||
#define __HAL_RCC_AHB_FORCE_RESET() WRITE_REG(RCC->AHBRSTR, 0xFFFFFFFFU)
|
||||
#if (defined(DMA) || defined(DMA1))
|
||||
#define __HAL_RCC_DMA_FORCE_RESET() SET_BIT(RCC->AHBRSTR, RCC_AHBRSTR_DMARST)
|
||||
#endif
|
||||
#define __HAL_RCC_FLASH_FORCE_RESET() SET_BIT(RCC->AHBRSTR, RCC_AHBRSTR_FLASHRST)
|
||||
#define __HAL_RCC_CRC_FORCE_RESET() SET_BIT(RCC->AHBRSTR, RCC_AHBRSTR_CRCRST)
|
||||
|
||||
#define __HAL_RCC_AHB_RELEASE_RESET() WRITE_REG(RCC->AHBRSTR, 0x00000000U)
|
||||
#if (defined(DMA) || defined(DMA1))
|
||||
#define __HAL_RCC_DMA_RELEASE_RESET() CLEAR_BIT(RCC->AHBRSTR, RCC_AHBRSTR_DMARST)
|
||||
#endif
|
||||
#define __HAL_RCC_FLASH_RELEASE_RESET() CLEAR_BIT(RCC->AHBRSTR, RCC_AHBRSTR_FLASHRST)
|
||||
#define __HAL_RCC_CRC_RELEASE_RESET() CLEAR_BIT(RCC->AHBRSTR, RCC_AHBRSTR_CRCRST)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup RCC_IOPORT_Force_Release_Reset IOPORT Force Release Reset
|
||||
* @brief Force or release IO Port reset.
|
||||
* @{
|
||||
*/
|
||||
#define __HAL_RCC_IOP_FORCE_RESET() WRITE_REG(RCC->IOPRSTR, 0xFFFFFFFFU)
|
||||
#define __HAL_RCC_GPIOA_FORCE_RESET() SET_BIT(RCC->IOPRSTR, RCC_IOPRSTR_GPIOARST)
|
||||
#define __HAL_RCC_GPIOB_FORCE_RESET() SET_BIT(RCC->IOPRSTR, RCC_IOPRSTR_GPIOBRST)
|
||||
#define __HAL_RCC_GPIOF_FORCE_RESET() SET_BIT(RCC->IOPRSTR, RCC_IOPRSTR_GPIOFRST)
|
||||
|
||||
#define __HAL_RCC_IOP_RELEASE_RESET() WRITE_REG(RCC->IOPRSTR, 0x00000000U)
|
||||
#define __HAL_RCC_GPIOA_RELEASE_RESET() CLEAR_BIT(RCC->IOPRSTR, RCC_IOPRSTR_GPIOARST)
|
||||
#define __HAL_RCC_GPIOB_RELEASE_RESET() CLEAR_BIT(RCC->IOPRSTR, RCC_IOPRSTR_GPIOBRST)
|
||||
#define __HAL_RCC_GPIOF_RELEASE_RESET() CLEAR_BIT(RCC->IOPRSTR, RCC_IOPRSTR_GPIOFRST)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup RCC_APB1_Force_Release_Reset APB1 Peripheral Force Release Reset
|
||||
* @brief Force or release APB1 peripheral reset.
|
||||
* @{
|
||||
*/
|
||||
#define __HAL_RCC_APB1_FORCE_RESET() WRITE_REG(RCC->APBRSTR1, 0xFFFFFFFFU)
|
||||
#if defined(TIM3)
|
||||
#define __HAL_RCC_TIM3_FORCE_RESET() SET_BIT(RCC->APBRSTR1, RCC_APBRSTR1_TIM3RST)
|
||||
#endif
|
||||
#if defined(SPI2)
|
||||
#define __HAL_RCC_SPI2_FORCE_RESET() SET_BIT(RCC->APBRSTR1, RCC_APBRSTR1_SPI2RST)
|
||||
#endif
|
||||
#if defined(USART2)
|
||||
#define __HAL_RCC_USART2_FORCE_RESET() SET_BIT(RCC->APBRSTR1, RCC_APBRSTR1_USART2RST)
|
||||
#endif
|
||||
#define __HAL_RCC_I2C_FORCE_RESET() SET_BIT(RCC->APBRSTR1, RCC_APBRSTR1_I2CRST)
|
||||
#define __HAL_RCC_DBGMCU_FORCE_RESET() SET_BIT(RCC->APBRSTR1, RCC_APBRSTR1_DBGRST)
|
||||
#define __HAL_RCC_PWR_FORCE_RESET() SET_BIT(RCC->APBRSTR1, RCC_APBRSTR1_PWRRST)
|
||||
#define __HAL_RCC_LPTIM_FORCE_RESET() SET_BIT(RCC->APBRSTR1, RCC_APBRSTR1_LPTIMRST)
|
||||
|
||||
#define __HAL_RCC_APB1_RELEASE_RESET() WRITE_REG(RCC->APBRSTR1, 0x00000000U)
|
||||
#if defined(TIM3)
|
||||
#define __HAL_RCC_TIM3_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR1, RCC_APBRSTR1_TIM3RST)
|
||||
#endif
|
||||
#if defined(SPI2)
|
||||
#define __HAL_RCC_SPI2_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR1, RCC_APBRSTR1_SPI2RST)
|
||||
#endif
|
||||
#if defined(USART2)
|
||||
#define __HAL_RCC_USART2_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR1, RCC_APBRSTR1_USART2RST)
|
||||
#endif
|
||||
#define __HAL_RCC_I2C_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR1, RCC_APBRSTR1_I2CRST)
|
||||
#define __HAL_RCC_DBGMCU_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR1, RCC_APBRSTR1_DBGRST)
|
||||
#define __HAL_RCC_PWR_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR1, RCC_APBRSTR1_PWRRST)
|
||||
#define __HAL_RCC_LPTIM_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR1, RCC_APBRSTR1_LPTIMRST)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup RCC_APB2_Force_Release_Reset APB2 Peripheral Force Release Reset
|
||||
* @brief Force or release APB2 peripheral reset.
|
||||
* @{
|
||||
*/
|
||||
#define __HAL_RCC_APB2_FORCE_RESET() WRITE_REG(RCC->APBRSTR2, 0xFFFFFFFFU)
|
||||
#define __HAL_RCC_SYSCFG_FORCE_RESET() SET_BIT(RCC->APBRSTR2, RCC_APBRSTR2_SYSCFGRST)
|
||||
#define __HAL_RCC_TIM1_FORCE_RESET() SET_BIT(RCC->APBRSTR2, RCC_APBRSTR2_TIM1RST)
|
||||
#define __HAL_RCC_SPI1_FORCE_RESET() SET_BIT(RCC->APBRSTR2, RCC_APBRSTR2_SPI1RST)
|
||||
#define __HAL_RCC_USART1_FORCE_RESET() SET_BIT(RCC->APBRSTR2, RCC_APBRSTR2_USART1RST)
|
||||
#if defined(TIM_MB)
|
||||
#define __HAL_RCC_TIM14_FORCE_RESET() SET_BIT(RCC->APBRSTR2, RCC_APBRSTR2_TIM14RST)
|
||||
#endif
|
||||
#define __HAL_RCC_TIM16_FORCE_RESET() SET_BIT(RCC->APBRSTR2, RCC_APBRSTR2_TIM16RST)
|
||||
#if defined(TIM17)
|
||||
#define __HAL_RCC_TIM17_FORCE_RESET() SET_BIT(RCC->APBRSTR2, RCC_APBRSTR2_TIM17RST)
|
||||
#endif
|
||||
#define __HAL_RCC_ADC_FORCE_RESET() SET_BIT(RCC->APBRSTR2, RCC_APBRSTR2_ADCRST)
|
||||
#if defined(COMP1)
|
||||
#define __HAL_RCC_COMP1_FORCE_RESET() SET_BIT(RCC->APBRSTR2, RCC_APBRSTR2_COMP1RST)
|
||||
#endif
|
||||
#if defined(COMP2)
|
||||
#define __HAL_RCC_COMP2_FORCE_RESET() SET_BIT(RCC->APBRSTR2, RCC_APBRSTR2_COMP2RST)
|
||||
#endif
|
||||
#if defined(LED)
|
||||
#define __HAL_RCC_LED_FORCE_RESET() SET_BIT(RCC->APBRSTR2, RCC_APBRSTR2_LEDRST)
|
||||
#endif
|
||||
|
||||
#define __HAL_RCC_APB2_RELEASE_RESET() WRITE_REG(RCC->APBRSTR2, 0x00U)
|
||||
#define __HAL_RCC_SYSCFG_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR2, RCC_APBRSTR2_SYSCFGRST)
|
||||
#define __HAL_RCC_TIM1_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR2, RCC_APBRSTR2_TIM1RST)
|
||||
#define __HAL_RCC_SPI1_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR2, RCC_APBRSTR2_SPI1RST)
|
||||
#define __HAL_RCC_USART1_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR2, RCC_APBRSTR2_USART1RST)
|
||||
#if defined(TIM_MB)
|
||||
#define __HAL_RCC_TIM14_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR2, RCC_APBRSTR2_TIM14RST)
|
||||
#endif
|
||||
#define __HAL_RCC_TIM16_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR2, RCC_APBRSTR2_TIM16RST)
|
||||
#if defined(TIM17)
|
||||
#define __HAL_RCC_TIM17_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR2, RCC_APBRSTR2_TIM17RST)
|
||||
#endif
|
||||
#define __HAL_RCC_ADC_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR2, RCC_APBRSTR2_ADCRST)
|
||||
#if defined(COMP1)
|
||||
#define __HAL_RCC_COMP1_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR2, RCC_APBRSTR2_COMP1RST)
|
||||
#endif
|
||||
#if defined(COMP2)
|
||||
#define __HAL_RCC_COMP2_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR2, RCC_APBRSTR2_COMP2RST)
|
||||
#endif
|
||||
#if defined(LED)
|
||||
#define __HAL_RCC_LED_RELEASE_RESET() CLEAR_BIT(RCC->APBRSTR2, RCC_APBRSTR2_LEDRST)
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup RCC_Backup_Domain_Reset RCC Backup Domain Reset
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @brief Macros to force or release the Backup domain reset.
|
||||
* @note This function resets the RTC peripheral (including the backup registers)
|
||||
* and the RTC clock source selection in RCC_BDCR register.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_RCC_BACKUPRESET_FORCE() SET_BIT(RCC->BDCR, RCC_BDCR_BDRST)
|
||||
|
||||
#define __HAL_RCC_BACKUPRESET_RELEASE() CLEAR_BIT(RCC->BDCR, RCC_BDCR_BDRST)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#if defined(RTC)
|
||||
/** @defgroup RCC_RTC_Clock_Configuration RCC RTC Clock Configuration
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @brief Macros to enable or disable the RTC clock.
|
||||
* @note As the RTC is in the Backup domain and write access is denied to
|
||||
* this domain after reset, you have to enable write access using
|
||||
* HAL_PWR_EnableBkUpAccess() function before to configure the RTC
|
||||
* (to be done once after reset).
|
||||
* @note These macros must be used after the RTC clock source was selected.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_RCC_RTC_ENABLE() SET_BIT(RCC->BDCR, RCC_BDCR_RTCEN)
|
||||
|
||||
#define __HAL_RCC_RTC_DISABLE() CLEAR_BIT(RCC->BDCR, RCC_BDCR_RTCEN)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif
|
||||
/** @defgroup RCC_Clock_Configuration RCC Clock Configuration
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @brief Macros to enable the Internal High Speed oscillator (HSI).
|
||||
* @note The HSI is stopped by hardware when entering STOP and STANDBY modes.
|
||||
* It is used (enabled by hardware) as system clock source after startup
|
||||
* from Reset, wakeup from STOP and STANDBY mode, or in case of failure
|
||||
* of the HSE used directly or indirectly as system clock (if the Clock
|
||||
* Security System CSS is enabled).
|
||||
* @note After enabling the HSI, the application software should wait on HSIRDY
|
||||
* flag to be set indicating that HSI clock is stable and can be used as
|
||||
* system clock source.
|
||||
* This parameter can be: ENABLE or DISABLE.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_RCC_HSI_ENABLE() SET_BIT(RCC->CR, RCC_CR_HSION)
|
||||
|
||||
/** @brief Macros to disable the Internal High Speed oscillator (HSI).
|
||||
* @note HSI can not be stopped if it is used as system clock source. In this case,
|
||||
* you have to select another source of the system clock then stop the HSI.
|
||||
* @note When the HSI is stopped, HSIRDY flag goes low after 6 HSI oscillator
|
||||
* clock cycles.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_RCC_HSI_DISABLE() CLEAR_BIT(RCC->CR, RCC_CR_HSION)
|
||||
|
||||
/** @brief Macro to adjust the Internal High Speed oscillator (HSI) calibration value.
|
||||
* @note The calibration is used to compensate for the variations in voltage
|
||||
* and temperature that influence the frequency of the internal HSI RC.
|
||||
* @param __HSICALIBRATIONVALUE__ specifies the calibration trimming value
|
||||
* (default is RCC_HSICALIBRATION_DEFAULT).
|
||||
* This parameter must be a number between 0 and 127.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_RCC_HSI_CALIBRATIONVALUE_ADJUST(__HSICALIBRATIONVALUE__) \
|
||||
MODIFY_REG(RCC->ICSCR, (RCC_ICSCR_HSI_FS_Msk|RCC_ICSCR_HSI_TRIM), (uint32_t)(__HSICALIBRATIONVALUE__) << RCC_ICSCR_HSI_TRIM_Pos)
|
||||
|
||||
/** @brief Macro to configure the HSISYS clock.
|
||||
* @param __HSIDIV__ specifies the HSI division factor.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg @ref RCC_HSI_DIV1 HSI clock source is divided by 1
|
||||
* @arg @ref RCC_HSI_DIV2 HSI clock source is divided by 2
|
||||
* @arg @ref RCC_HSI_DIV4 HSI clock source is divided by 4
|
||||
* @arg @ref RCC_HSI_DIV8 HSI clock source is divided by 8
|
||||
* @arg @ref RCC_HSI_DIV16 HSI clock source is divided by 16
|
||||
* @arg @ref RCC_HSI_DIV32 HSI clock source is divided by 32
|
||||
* @arg @ref RCC_HSI_DIV64 HSI clock source is divided by 64
|
||||
* @arg @ref RCC_HSI_DIV128 HSI clock source is divided by 128
|
||||
*/
|
||||
#define __HAL_RCC_HSI_CONFIG(__HSIDIV__) \
|
||||
MODIFY_REG(RCC->CR, RCC_CR_HSIDIV, (__HSIDIV__))
|
||||
|
||||
/** @brief Macros to enable or disable the Internal Low Speed oscillator (LSI).
|
||||
* @note After enabling the LSI, the application software should wait on
|
||||
* LSIRDY flag to be set indicating that LSI clock is stable and can
|
||||
* be used to clock the IWDG and/or the RTC.
|
||||
* @note LSI can not be disabled if the IWDG is running.
|
||||
* @note When the LSI is stopped, LSIRDY flag goes low after 6 LSI oscillator
|
||||
* clock cycles.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_RCC_LSI_ENABLE() SET_BIT(RCC->CSR, RCC_CSR_LSION)
|
||||
|
||||
#define __HAL_RCC_LSI_DISABLE() CLEAR_BIT(RCC->CSR, RCC_CSR_LSION)
|
||||
|
||||
/**
|
||||
* @brief Macro to configure the External High Speed oscillator (HSE).
|
||||
* @note Transition HSE Bypass to HSE On and HSE On to HSE Bypass are not
|
||||
* supported by this macro. User should request a transition to HSE Off
|
||||
* first and then HSE On or HSE Bypass.
|
||||
* @note After enabling the HSE (RCC_HSE_ON or RCC_HSE_Bypass), the application
|
||||
* software should wait on HSERDY flag to be set indicating that HSE clock
|
||||
* is stable and can be used to clock the PLL and/or system clock.
|
||||
* @note HSE state can not be changed if it is used directly or through the
|
||||
* PLL as system clock. In this case, you have to select another source
|
||||
* of the system clock then change the HSE state (ex. disable it).
|
||||
* @note The HSE is stopped by hardware when entering STOP and STANDBY modes.
|
||||
* @note This function reset the CSSON bit, so if the clock security system(CSS)
|
||||
* was previously enabled you have to enable it again after calling this
|
||||
* function.
|
||||
* @param __STATE__ specifies the new state of the HSE.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg @ref RCC_HSE_OFF Turn OFF the HSE oscillator, HSERDY flag goes low after
|
||||
* 6 HSE oscillator clock cycles.
|
||||
* @arg @ref RCC_HSE_ON Turn ON the HSE oscillator.
|
||||
* @arg @ref RCC_HSE_BYPASS HSE oscillator bypassed with external clock.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_RCC_HSE_CONFIG(__STATE__) \
|
||||
do { \
|
||||
if((__STATE__) == RCC_HSE_ON) \
|
||||
{ \
|
||||
SET_BIT(RCC->CR, RCC_CR_HSEON); \
|
||||
} \
|
||||
else if((__STATE__) == RCC_HSE_BYPASS) \
|
||||
{ \
|
||||
SET_BIT(RCC->CR, RCC_CR_HSEBYP); \
|
||||
SET_BIT(RCC->CR, RCC_CR_HSEON); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
CLEAR_BIT(RCC->CR, RCC_CR_HSEON); \
|
||||
CLEAR_BIT(RCC->CR, RCC_CR_HSEBYP); \
|
||||
} \
|
||||
} while(0U)
|
||||
|
||||
#if defined(RCC_LSE_SUPPORT)
|
||||
/**
|
||||
* @brief Macro to configure the External Low Speed oscillator (LSE).
|
||||
* @note Transitions LSE Bypass to LSE On and LSE On to LSE Bypass are not
|
||||
* supported by this macro. User should request a transition to LSE Off
|
||||
* first and then LSE On or LSE Bypass.
|
||||
* @note As the LSE is in the Backup domain and write access is denied to
|
||||
* this domain after reset, you have to enable write access using
|
||||
* HAL_PWR_EnableBkUpAccess() function before to configure the LSE
|
||||
* (to be done once after reset).
|
||||
* @note After enabling the LSE (RCC_LSE_ON or RCC_LSE_BYPASS), the application
|
||||
* software should wait on LSERDY flag to be set indicating that LSE clock
|
||||
* is stable and can be used to clock the RTC.
|
||||
* @param __STATE__ specifies the new state of the LSE.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg @ref RCC_LSE_OFF Turn OFF the LSE oscillator, LSERDY flag goes low after
|
||||
* 6 LSE oscillator clock cycles.
|
||||
* @arg @ref RCC_LSE_ON Turn ON the LSE oscillator.
|
||||
* @arg @ref RCC_LSE_BYPASS LSE oscillator bypassed with external clock.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_RCC_LSE_CONFIG(__STATE__) \
|
||||
do { \
|
||||
if((__STATE__) == RCC_LSE_ON) \
|
||||
{ \
|
||||
SET_BIT(RCC->BDCR, RCC_BDCR_LSEON); \
|
||||
} \
|
||||
else if((__STATE__) == RCC_LSE_BYPASS) \
|
||||
{ \
|
||||
SET_BIT(RCC->BDCR, RCC_BDCR_LSEBYP); \
|
||||
SET_BIT(RCC->BDCR, RCC_BDCR_LSEON); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSEON); \
|
||||
CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSEBYP); \
|
||||
} \
|
||||
} while(0U)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif
|
||||
|
||||
#if defined(RTC)
|
||||
/** @addtogroup RCC_RTC_Clock_Configuration
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @brief Macros to configure the RTC clock (RTCCLK).
|
||||
* @note As the RTC clock configuration bits are in the Backup domain and write
|
||||
* access is denied to this domain after reset, you have to enable write
|
||||
* access using the Power Backup Access macro before to configure
|
||||
* the RTC clock source (to be done once after reset).
|
||||
* @note Once the RTC clock is configured it cannot be changed unless the
|
||||
* Backup domain is reset using __HAL_RCC_BACKUPRESET_FORCE() macro, or by
|
||||
* a Power On Reset (POR).
|
||||
*
|
||||
* @param __RTC_CLKSOURCE__ specifies the RTC clock source.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg @ref RCC_RTCCLKSOURCE_NONE No clock selected as RTC clock.
|
||||
* @arg @ref RCC_RTCCLKSOURCE_LSE LSE selected as RTC clock.
|
||||
* @arg @ref RCC_RTCCLKSOURCE_LSI LSI selected as RTC clock.
|
||||
* @arg @ref RCC_RTCCLKSOURCE_HSE_DIV32 HSE clock divided by 32 selected
|
||||
*
|
||||
* @note If the LSE or LSI is used as RTC clock source, the RTC continues to
|
||||
* work in STOP and STANDBY modes, and can be used as wakeup source.
|
||||
* However, when the HSE clock is used as RTC clock source, the RTC
|
||||
* cannot be used in STOP and STANDBY modes.
|
||||
* @note The maximum input clock frequency for RTC is 1MHz (when using HSE as
|
||||
* RTC clock source).
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_RCC_RTC_CONFIG(__RTC_CLKSOURCE__) \
|
||||
MODIFY_REG( RCC->BDCR, RCC_BDCR_RTCSEL, (__RTC_CLKSOURCE__))
|
||||
|
||||
|
||||
/** @brief Macro to get the RTC clock source.
|
||||
* @retval The returned value can be one of the following:
|
||||
* @arg @ref RCC_RTCCLKSOURCE_NONE No clock selected as RTC clock.
|
||||
* @arg @ref RCC_RTCCLKSOURCE_LSE LSE selected as RTC clock.
|
||||
* @arg @ref RCC_RTCCLKSOURCE_LSI LSI selected as RTC clock.
|
||||
* @arg @ref RCC_RTCCLKSOURCE_HSE_DIV32 HSE clock divided by 32 selected
|
||||
*/
|
||||
#define __HAL_RCC_GET_RTC_SOURCE() ((uint32_t)(READ_BIT(RCC->BDCR, RCC_BDCR_RTCSEL)))
|
||||
|
||||
/** @brief Macros to enable or disable the main PLL.
|
||||
* @note After enabling the main PLL, the application software should wait on
|
||||
* PLLRDY flag to be set indicating that PLL clock is stable and can
|
||||
* be used as system clock source.
|
||||
* @note The main PLL can not be disabled if it is used as system clock source
|
||||
* @note The main PLL is disabled by hardware when entering STOP and STANDBY modes.
|
||||
* @retval None
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif
|
||||
|
||||
#if defined(RCC_PLL_SUPPORT)
|
||||
/** @addtogroup RCC_Clock_Configuration
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define __HAL_RCC_PLL_ENABLE() SET_BIT(RCC->CR, RCC_CR_PLLON)
|
||||
|
||||
#define __HAL_RCC_PLL_DISABLE() CLEAR_BIT(RCC->CR, RCC_CR_PLLON)
|
||||
|
||||
/** @brief Macro to configure the PLL clock source.
|
||||
* @note This function must be used only when the main PLL is disabled.
|
||||
* @param __PLLSOURCE__ specifies the PLL entry clock source.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg @ref RCC_PLLSOURCE_NONE No clock selected as PLL clock entry
|
||||
* @arg @ref RCC_PLLSOURCE_HSI HSI oscillator clock selected as PLL clock entry
|
||||
* @arg @ref RCC_PLLSOURCE_HSE HSE oscillator clock selected as PLL clock entry
|
||||
* @retval None
|
||||
*
|
||||
*/
|
||||
#define __HAL_RCC_PLL_PLLSOURCE_CONFIG(__PLLSOURCE__) \
|
||||
MODIFY_REG(RCC->PLLCFGR, RCC_PLLCFGR_PLLSRC, (__PLLSOURCE__))
|
||||
|
||||
/** @brief Macro to get the oscillator used as PLL clock source.
|
||||
* @retval The oscillator used as PLL clock source. The returned value can be one
|
||||
* of the following:
|
||||
* @arg @ref RCC_PLLSOURCE_NONE No oscillator is used as PLL clock source.
|
||||
* @arg @ref RCC_PLLSOURCE_HSI HSI oscillator is used as PLL clock source.
|
||||
* @arg @ref RCC_PLLSOURCE_HSE HSE oscillator is used as PLL clock source.
|
||||
*/
|
||||
#define __HAL_RCC_GET_PLL_OSCSOURCE() ((uint32_t)(RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC))
|
||||
#endif
|
||||
/**
|
||||
* @brief Macro to configure the system clock source.
|
||||
* @param __SYSCLKSOURCE__ specifies the system clock source.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg @ref RCC_SYSCLKSOURCE_HSI HSI oscillator is used as system clock source.
|
||||
* @arg @ref RCC_SYSCLKSOURCE_HSE HSE oscillator is used as system clock source.
|
||||
* @arg @ref RCC_SYSCLKSOURCE_PLLCLK PLL output is used as system clock source.
|
||||
* @arg @ref RCC_SYSCLKSOURCE_LSI LSI oscillator is used as system clock source.
|
||||
* @arg @ref RCC_SYSCLKSOURCE_LSE LSE oscillator is used as system clock source.
|
||||
* @note Depending on devices and packages, some clocks may not be available.
|
||||
* Refer to device datasheet for clocks availability.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_RCC_SYSCLK_CONFIG(__SYSCLKSOURCE__) \
|
||||
MODIFY_REG(RCC->CFGR, RCC_CFGR_SW, (__SYSCLKSOURCE__))
|
||||
|
||||
/** @brief Macro to get the clock source used as system clock.
|
||||
* @retval The clock source used as system clock. The returned value can be one
|
||||
* of the following:
|
||||
* @arg @ref RCC_SYSCLKSOURCE_STATUS_HSI HSI used as system clock.
|
||||
* @arg @ref RCC_SYSCLKSOURCE_STATUS_HSE HSE used as system clock.
|
||||
* @arg @ref RCC_SYSCLKSOURCE_STATUS_PLLCLK PLL used as system clock.
|
||||
* @arg @ref RCC_SYSCLKSOURCE_STATUS_LSI LSI used as system clock source.
|
||||
* @arg @ref RCC_SYSCLKSOURCE_STATUS_LSE LSE used as system clock source.
|
||||
* @note Depending on devices and packages, some clocks may not be available.
|
||||
* Refer to device datasheet for clocks availability.
|
||||
*/
|
||||
#define __HAL_RCC_GET_SYSCLK_SOURCE() (RCC->CFGR & RCC_CFGR_SWS)
|
||||
#if defined(RCC_LSE_SUPPORT)
|
||||
/**
|
||||
* @brief Macro to configure the External Low Speed oscillator (LSE) drive capability.
|
||||
* @note As the LSE is in the Backup domain and write access is denied to
|
||||
* this domain after reset, you have to enable write access using
|
||||
* HAL_PWR_EnableBkUpAccess() function before to configure the LSE
|
||||
* (to be done once after reset).
|
||||
* @param __LSEDRIVE__ specifies the new state of the LSE drive capability.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg @ref RCC_LSEDRIVE_LOW LSE oscillator low drive capability.
|
||||
* @arg @ref RCC_LSEDRIVE_MEDIUM LSE oscillator medium low drive capability.
|
||||
* @arg @ref RCC_LSEDRIVE_HIGH LSE oscillator high drive capability.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_RCC_LSEDRIVE_CONFIG(__LSEDRIVE__) \
|
||||
MODIFY_REG(RCC->ECSCR, RCC_ECSCR_LSE_DRIVER, (uint32_t)(__LSEDRIVE__))
|
||||
#endif
|
||||
/** @brief Macro to configure the MCO clock.
|
||||
* @param __MCOCLKSOURCE__ specifies the MCO clock source.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg @ref RCC_MCO1SOURCE_NOCLOCK MCO output disabled
|
||||
* @arg @ref RCC_MCO1SOURCE_SYSCLK System clock selected as MCO source
|
||||
* @arg @ref RCC_MCO1SOURCE_HSI HSI clock selected as MCO source
|
||||
* @arg @ref RCC_MCO1SOURCE_HSE HSE clock selected as MCO sourcee
|
||||
* @arg @ref RCC_MCO1SOURCE_PLLCLK Main PLL clock selected as MCO source
|
||||
* @arg @ref RCC_MCO1SOURCE_LSI LSI clock selected as MCO source
|
||||
* @arg @ref RCC_MCO1SOURCE_LSE LSE clock selected as MCO source
|
||||
* @note Depending on devices and packages, some clocks may not be available.
|
||||
* Refer to device datasheet for clocks availability.
|
||||
* @param __MCODIV__ specifies the MCO clock prescaler.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg @ref RCC_MCODIV_1 MCO clock source is divided by 1
|
||||
* @arg @ref RCC_MCODIV_2 MCO clock source is divided by 2
|
||||
* @arg @ref RCC_MCODIV_4 MCO clock source is divided by 4
|
||||
* @arg @ref RCC_MCODIV_8 MCO clock source is divided by 8
|
||||
* @arg @ref RCC_MCODIV_16 MCO clock source is divided by 16
|
||||
* @arg @ref RCC_MCODIV_32 MCO clock source is divided by 32
|
||||
* @arg @ref RCC_MCODIV_64 MCO clock source is divided by 64
|
||||
* @arg @ref RCC_MCODIV_128 MCO clock source is divided by 128
|
||||
*/
|
||||
#define __HAL_RCC_MCO1_CONFIG(__MCOCLKSOURCE__, __MCODIV__) \
|
||||
MODIFY_REG(RCC->CFGR, (RCC_CFGR_MCOSEL | RCC_CFGR_MCOPRE), ((__MCOCLKSOURCE__) | (__MCODIV__)))
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup RCC_Flags_Interrupts_Management Flags Interrupts Management
|
||||
* @brief macros to manage the specified RCC Flags and interrupts.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @brief Enable RCC interrupt.
|
||||
* @param __INTERRUPT__ specifies the RCC interrupt sources to be enabled.
|
||||
* This parameter can be any combination of the following values:
|
||||
* @arg @ref RCC_IT_LSIRDY LSI ready interrupt
|
||||
* @arg @ref RCC_IT_LSERDY LSE ready interrupt
|
||||
* @arg @ref RCC_IT_HSIRDY HSI ready interrupt
|
||||
* @arg @ref RCC_IT_HSERDY HSE ready interrupt
|
||||
* @arg @ref RCC_IT_PLLRDY Main PLL ready interrupt
|
||||
* @note Depending on devices and packages, some clocks may not be available.
|
||||
* Refer to device datasheet for clocks availability.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_RCC_ENABLE_IT(__INTERRUPT__) SET_BIT(RCC->CIER, (__INTERRUPT__))
|
||||
|
||||
/** @brief Disable RCC interrupt.
|
||||
* @param __INTERRUPT__ specifies the RCC interrupt sources to be disabled.
|
||||
* This parameter can be any combination of the following values:
|
||||
* @arg @ref RCC_IT_LSIRDY LSI ready interrupt
|
||||
* @arg @ref RCC_IT_LSERDY LSE ready interrupt
|
||||
* @arg @ref RCC_IT_HSIRDY HSI ready interrupt
|
||||
* @arg @ref RCC_IT_HSERDY HSE ready interrupt
|
||||
* @arg @ref RCC_IT_PLLRDY Main PLL ready interrupt
|
||||
* @note Depending on devices and packages, some clocks may not be available.
|
||||
* Refer to device datasheet for clocks availability.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_RCC_DISABLE_IT(__INTERRUPT__) CLEAR_BIT(RCC->CIER, (__INTERRUPT__))
|
||||
|
||||
/** @brief Clear RCC interrupt pending bits.
|
||||
* @param __INTERRUPT__ specifies the interrupt pending bit to clear.
|
||||
* This parameter can be any combination of the following values:
|
||||
* @arg @ref RCC_IT_LSIRDY LSI ready interrupt
|
||||
* @arg @ref RCC_IT_LSERDY LSE ready interrupt
|
||||
* @arg @ref RCC_IT_HSIRDY HSI ready interrupt
|
||||
* @arg @ref RCC_IT_HSERDY HSE ready interrupt
|
||||
* @arg @ref RCC_IT_PLLRDY Main PLL ready interrupt
|
||||
* @arg @ref RCC_IT_CSS HSE Clock security system interrupt
|
||||
* @arg @ref RCC_IT_LSECSS LSE Clock security system interrupt
|
||||
* @note Depending on devices and packages, some clocks may not be available.
|
||||
* Refer to device datasheet for clocks availability.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_RCC_CLEAR_IT(__INTERRUPT__) (RCC->CICR = (__INTERRUPT__))
|
||||
|
||||
/** @brief Check whether the RCC interrupt has occurred or not.
|
||||
* @param __INTERRUPT__ specifies the RCC interrupt source to check.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg @ref RCC_IT_LSIRDY LSI ready interrupt
|
||||
* @arg @ref RCC_IT_LSERDY LSE ready interrupt
|
||||
* @arg @ref RCC_IT_HSIRDY HSI ready interrupt
|
||||
* @arg @ref RCC_IT_HSERDY HSE ready interrupt
|
||||
* @arg @ref RCC_IT_PLLRDY Main PLL ready interrupt
|
||||
* @arg @ref RCC_IT_CSS HSE Clock security system interrupt
|
||||
* @arg @ref RCC_IT_LSECSS LSE Clock security system interrupt
|
||||
* @note Depending on devices and packages, some clocks may not be available.
|
||||
* Refer to device datasheet for clocks availability.
|
||||
* @retval The new state of __INTERRUPT__ (TRUE or FALSE).
|
||||
*/
|
||||
#define __HAL_RCC_GET_IT(__INTERRUPT__) ((RCC->CIFR & (__INTERRUPT__)) == (__INTERRUPT__))
|
||||
|
||||
/** @brief Set RMVF bit to clear the reset flags.
|
||||
* The reset flags are: RCC_FLAG_OBLRST, RCC_FLAG_PINRST, RCC_FLAG_PWRRST,
|
||||
* RCC_FLAG_SFTRST, RCC_FLAG_IWDGRST, RCC_FLAG_WWDGRST.
|
||||
* @note Depending on the device and software package, some flag bits may not be available.
|
||||
* Refer to the device data sheet for flag bit availability.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_RCC_CLEAR_RESET_FLAGS() (RCC->CSR |= RCC_CSR_RMVF)
|
||||
|
||||
/** @brief Check whether the selected RCC flag is set or not.
|
||||
* @param __FLAG__ specifies the flag to check.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg @ref RCC_FLAG_HSIRDY HSI oscillator clock ready
|
||||
* @arg @ref RCC_FLAG_HSERDY HSE oscillator clock ready
|
||||
* @arg @ref RCC_FLAG_PLLRDY Main PLL clock ready
|
||||
* @arg @ref RCC_FLAG_LSERDY LSE oscillator clock ready
|
||||
* @arg @ref RCC_FLAG_LSIRDY LSI oscillator clock ready
|
||||
* @arg @ref RCC_FLAG_PWRRST BOR or POR/PDR reset
|
||||
* @arg @ref RCC_FLAG_OBLRST OBLRST reset
|
||||
* @arg @ref RCC_FLAG_PINRST Pin reset
|
||||
* @arg @ref RCC_FLAG_SFTRST Software reset
|
||||
* @arg @ref RCC_FLAG_IWDGRST Independent Watchdog reset
|
||||
* @arg @ref RCC_FLAG_WWDGRST Window Watchdog reset
|
||||
* @note Depending on the device and software package, some flag bits may not be available.
|
||||
* Refer to the device data sheet for flag bit availability.
|
||||
* @retval The new state of __FLAG__ (TRUE or FALSE).
|
||||
*/
|
||||
#define __HAL_RCC_GET_FLAG(__FLAG__) (((((((__FLAG__) >> 5U) == CR_REG_INDEX) ? RCC->CR : \
|
||||
((((__FLAG__) >> 5U) == BDCR_REG_INDEX) ? RCC->BDCR : \
|
||||
((((__FLAG__) >> 5U) == CSR_REG_INDEX) ? RCC->CSR : RCC->CIFR))) & \
|
||||
(1U << ((__FLAG__) & RCC_FLAG_MASK))) != RESET) \
|
||||
? 1U : 0U)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Include RCC HAL Extended module */
|
||||
#include "py32f0xx_hal_rcc_ex.h"
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/** @addtogroup RCC_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @addtogroup RCC_Exported_Functions_Group1
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Initialization and de-initialization functions ******************************/
|
||||
HAL_StatusTypeDef HAL_RCC_DeInit(void);
|
||||
HAL_StatusTypeDef HAL_RCC_OscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct);
|
||||
HAL_StatusTypeDef HAL_RCC_ClockConfig(RCC_ClkInitTypeDef *RCC_ClkInitStruct, uint32_t FLatency);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup RCC_Exported_Functions_Group2
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Peripheral Control functions ************************************************/
|
||||
void HAL_RCC_MCOConfig(uint32_t RCC_MCOx, uint32_t RCC_MCOSource, uint32_t RCC_MCODiv);
|
||||
void HAL_RCC_EnableCSS(void);
|
||||
#if defined(RCC_LSE_SUPPORT)
|
||||
void HAL_RCC_EnableLSECSS(void);
|
||||
void HAL_RCC_DisableLSECSS(void);
|
||||
void HAL_RCC_LSECSSCallback(void);
|
||||
#endif
|
||||
uint32_t HAL_RCC_GetSysClockFreq(void);
|
||||
uint32_t HAL_RCC_GetHCLKFreq(void);
|
||||
uint32_t HAL_RCC_GetPCLK1Freq(void);
|
||||
void HAL_RCC_GetOscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct);
|
||||
void HAL_RCC_GetClockConfig(RCC_ClkInitTypeDef *RCC_ClkInitStruct, uint32_t *pFLatency);
|
||||
/* LSE & HSE CSS NMI IRQ handler */
|
||||
void HAL_RCC_NMI_IRQHandler(void);
|
||||
/* User Callbacks in non blocking mode (IT mode) */
|
||||
void HAL_RCC_CSSCallback(void);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __PY32F0xx_HAL_RCC_H */
|
||||
|
||||
/************************ (C) COPYRIGHT Puya *****END OF FILE****/
|
||||
468
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_rcc_ex.h
Normal file
468
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_rcc_ex.h
Normal file
@@ -0,0 +1,468 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file py32f0xx_hal_rcc_ex.h
|
||||
* @author MCU Application Team
|
||||
* @brief Header file of RCC HAL Extended module.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) Puya Semiconductor Co.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __PY32F0xx_HAL_RCC_EX_H
|
||||
#define __PY32F0xx_HAL_RCC_EX_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "py32f0xx_hal_def.h"
|
||||
|
||||
/** @addtogroup PY32F0xx_HAL_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup RCCEx
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
|
||||
/** @defgroup RCCEx_Exported_Types RCCEx Exported Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief RCC extended clocks structure definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t PeriphClockSelection; /*!< The Extended Clock to be configured.
|
||||
This parameter can be a value of @ref RCCEx_Periph_Clock_Selection */
|
||||
|
||||
#if defined(RCC_CCIPR_PVDSEL)
|
||||
uint32_t PvdClockSelection; /*!< Specifies PVD clock source.
|
||||
This parameter can be a value of @ref RCCEx_PVD_Clock_Source */
|
||||
#endif
|
||||
|
||||
#if defined(RCC_CCIPR_COMP1SEL)
|
||||
uint32_t Comp1ClockSelection; /*!< Specifies COMP1 clock source.
|
||||
This parameter can be a value of @ref RCCEx_COMP1_Clock_Source */
|
||||
#endif
|
||||
|
||||
#if defined(RCC_CCIPR_COMP2SEL)
|
||||
uint32_t Comp2ClockSelection; /*!< Specifies COMP2 clock source.
|
||||
This parameter can be a value of @ref RCCEx_COMP2_Clock_Source */
|
||||
#endif
|
||||
|
||||
#if defined(RCC_CCIPR_LPTIMSEL)
|
||||
uint32_t LptimClockSelection; /*!< Specifies LPTIM1 clock source
|
||||
This parameter can be a value of @ref RCCEx_LPTIM1_Clock_Source */
|
||||
#endif
|
||||
|
||||
#if defined(RCC_BDCR_RTCSEL)
|
||||
uint32_t RTCClockSelection; /*!< Specifies RTC clock source.
|
||||
This parameter can be a value of @ref RCC_RTC_Clock_Source */
|
||||
#endif
|
||||
} RCC_PeriphCLKInitTypeDef;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/** @defgroup RCCEx_Exported_Constants RCCEx Exported Constants
|
||||
* @{
|
||||
*/
|
||||
#if defined(RCC_BDCR_LSCOSEL)
|
||||
/** @defgroup RCCEx_LSCO_Clock_Source Low Speed Clock Source
|
||||
* @{
|
||||
*/
|
||||
#define RCC_LSCOSOURCE_LSI 0x00000000U /*!< LSI selection for low speed clock output */
|
||||
#if defined(RCC_LSE_SUPPORT)
|
||||
#define RCC_LSCOSOURCE_LSE RCC_BDCR_LSCOSEL /*!< LSE selection for low speed clock output */
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif
|
||||
/** @defgroup RCCEx_Periph_Clock_Selection Periph Clock Selection
|
||||
* @{
|
||||
*/
|
||||
#if defined(RCC_CCIPR_PVDSEL)
|
||||
#define RCC_PERIPHCLK_PVD 0x00000001U
|
||||
#endif /* RCC_CCIPR_PVDSEL */
|
||||
|
||||
#if defined(RCC_CCIPR_COMP1SEL)
|
||||
#define RCC_PERIPHCLK_COMP1 0x00000002U
|
||||
#endif /* RCC_CCIPR_COMP1SEL */
|
||||
|
||||
#if defined(RCC_CCIPR_COMP2SEL)
|
||||
#define RCC_PERIPHCLK_COMP2 0x00000020U
|
||||
#endif /* RCC_CCIPR_COMP2SEL */
|
||||
|
||||
#if defined(RCC_CCIPR_LPTIMSEL)
|
||||
#define RCC_PERIPHCLK_LPTIM 0x00000200U
|
||||
#endif /* RCC_CCIPR_LPTIM1SEL */
|
||||
|
||||
#if defined(RCC_CCIPR_ADCSEL)
|
||||
#define RCC_PERIPHCLK_ADC 0x00004000U
|
||||
#endif /* RCC_CCIPR_ADCSEL */
|
||||
|
||||
#if defined(RCC_BDCR_RTCSEL)
|
||||
#define RCC_PERIPHCLK_RTC 0x00020000U
|
||||
#endif /* RCC_BDCR_RTCSEL */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#if defined(RCC_CCIPR_PVDSEL)
|
||||
/** @defgroup RCCEx_PVD_Clock_Source RCC PVD Clock Source
|
||||
* @{
|
||||
*/
|
||||
#define RCC_PVDCLKSOURCE_PCLK 0x00000000U /*!< APB clock selected as PVD clock */
|
||||
#define RCC_PVDCLKSOURCE_LSC RCC_CCIPR_PVDSEL /*!< LSC clock selected as PVD clock */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif
|
||||
|
||||
#if defined(RCC_CCIPR_COMP1SEL)
|
||||
/** @defgroup RCCEx_COMP1_Clock_Source RCC COMP1 Clock Source
|
||||
* @{
|
||||
*/
|
||||
#define RCC_COMP1CLKSOURCE_PCLK 0x00000000U /*!< APB clock selected as COMP1 clock */
|
||||
#define RCC_COMP1CLKSOURCE_LSC RCC_CCIPR_COMP1SEL /*!< LSC clock selected as COMP1 clock */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif /* RCC_CCIPR_COMP1SEL */
|
||||
|
||||
#if defined(RCC_CCIPR_COMP2SEL)
|
||||
/** @defgroup RCCEx_COMP2_Clock_Source RCC COMP2 Clock Source
|
||||
* @{
|
||||
*/
|
||||
#define RCC_COMP2CLKSOURCE_PCLK 0x00000000U /*!< APB clock selected as COMP2 clock */
|
||||
#define RCC_COMP2CLKSOURCE_LSC RCC_CCIPR_COMP2SEL /*!< LSC clock selected as COMP2 clock */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif /* RCC_CCIPR_COMP1SEL */
|
||||
|
||||
#if defined(RCC_CCIPR_LPTIMSEL)
|
||||
/** @defgroup RCCEx_LPTIM1_Clock_Source RCC LPTIM1 Clock Source
|
||||
* @{
|
||||
*/
|
||||
#define RCC_LPTIMCLKSOURCE_PCLK 0x00000000U /*!< APB clock selected as LPTimer 1 clock */
|
||||
#define RCC_LPTIMCLKSOURCE_LSI RCC_CCIPR_LPTIMSEL_0 /*!< LSI clock selected as LPTimer 1 clock */
|
||||
#if defined(RCC_LSE_SUPPORT)
|
||||
#define RCC_LPTIMCLKSOURCE_LSE RCC_CCIPR_LPTIMSEL /*!< LSE clock selected as LPTimer 1 clock */
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif /* RCC_CCIPR_LPTIM1SEL */
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported macros -----------------------------------------------------------*/
|
||||
/** @defgroup RCCEx_Exported_Macros RCCEx Exported Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if defined(RCC_CCIPR_PVDSEL)
|
||||
/** @brief Macro to configure the PVD clock (PVDCLK).
|
||||
*
|
||||
* @param __PVD_CLKSOURCE__ specifies the PVD clock source.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg @ref RCC_PVDCLKSOURCE_PCLK PCLK selected as PVD clock
|
||||
* @arg @ref RCC_PVDCLKSOURCE_LSC LSC selected as PVD clock
|
||||
*/
|
||||
#define __HAL_RCC_PVD_CONFIG(__PVD_CLKSOURCE__) \
|
||||
MODIFY_REG(RCC->CCIPR, RCC_CCIPR_PVDSEL, (uint32_t)(__PVD_CLKSOURCE__))
|
||||
|
||||
/** @brief Macro to get the PVD clock source.
|
||||
* @retval The clock source can be one of the following values:
|
||||
* @arg @ref RCC_PVDCLKSOURCE_PCLK PCLK selected as PVD clock
|
||||
* @arg @ref RCC_PVDCLKSOURCE_LSC LSC selected as PVD clock
|
||||
*/
|
||||
#define __HAL_RCC_GET_PVD_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR, RCC_CCIPR_PVDSEL)))
|
||||
#endif /* RCC_CCIPR_PVDSEL */
|
||||
|
||||
#if defined(RCC_CCIPR_COMP1SEL)
|
||||
/** @brief Macro to configure the COMP1 clock (COMP1CLK).
|
||||
*
|
||||
* @param __COMP1_CLKSOURCE__ specifies the COMP1 clock source.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg @ref RCC_COMP1CLKSOURCE_PCLK PCLK selected as COMP1 clock
|
||||
* @arg @ref RCC_COMP1CLKSOURCE_HSI LSC selected as COMP1 clock
|
||||
*/
|
||||
#define __HAL_RCC_COMP1_CONFIG(__COMP1_CLKSOURCE__) \
|
||||
MODIFY_REG(RCC->CCIPR, RCC_CCIPR_COMP1SEL, (uint32_t)(__COMP1_CLKSOURCE__))
|
||||
|
||||
/** @brief Macro to get the COMP1 clock source.
|
||||
* @retval The clock source can be one of the following values:
|
||||
* @arg @ref RCC_COMP1CLKSOURCE_PCLK1 PCLK selected as COMP1 clock
|
||||
* @arg @ref RCC_COMP1CLKSOURCE_HSI LSC selected as COMP1 clock
|
||||
*/
|
||||
#define __HAL_RCC_GET_COMP1_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR, RCC_CCIPR_COMP1SEL)))
|
||||
#endif /* RCC_CCIPR_COMP1SEL */
|
||||
|
||||
#if defined(RCC_CCIPR_COMP2SEL)
|
||||
/** @brief Macro to configure the COMP2 clock (COMP2CLK).
|
||||
*
|
||||
* @param __COMP2_CLKSOURCE__ specifies the COMP2 clock source.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg @ref RCC_COMP2CLKSOURCE_PCLK PCLK selected as COMP2 clock
|
||||
* @arg @ref RCC_COMP2CLKSOURCE_HSI LSC selected as COMP2 clock
|
||||
*/
|
||||
#define __HAL_RCC_COMP2_CONFIG(__COMP2_CLKSOURCE__) \
|
||||
MODIFY_REG(RCC->CCIPR, RCC_CCIPR_COMP2SEL, (uint32_t)(__COMP2_CLKSOURCE__))
|
||||
|
||||
/** @brief Macro to get the COMP2 clock source.
|
||||
* @retval The clock source can be one of the following values:
|
||||
* @arg @ref RCC_COMP2CLKSOURCE_PCLK1 PCLK selected as COMP2 clock
|
||||
* @arg @ref RCC_COMP2CLKSOURCE_HSI LSC selected as COMP2 clock
|
||||
*/
|
||||
#define __HAL_RCC_GET_COMP2_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR, RCC_CCIPR_COMP2SEL)))
|
||||
#endif /* RCC_CCIPR_COMP2SEL */
|
||||
|
||||
#if defined(RCC_CCIPR_LPUART1SEL)
|
||||
/** @brief Macro to configure the LPUART1 clock (LPUART1CLK).
|
||||
*
|
||||
* @param __LPUART1_CLKSOURCE__ specifies the LPUART1 clock source.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg @ref RCC_LPUART1CLKSOURCE_PCLK1 PCLK1 selected as LPUART1 clock
|
||||
* @arg @ref RCC_LPUART1CLKSOURCE_HSI HSI selected as LPUART1 clock
|
||||
* @arg @ref RCC_LPUART1CLKSOURCE_SYSCLK System Clock selected as LPUART1 clock
|
||||
* @arg @ref RCC_LPUART1CLKSOURCE_LSE LSE selected as LPUART1 clock
|
||||
*/
|
||||
#define __HAL_RCC_LPUART1_CONFIG(__LPUART1_CLKSOURCE__) \
|
||||
MODIFY_REG(RCC->CCIPR, RCC_CCIPR_LPUART1SEL, (uint32_t)(__LPUART1_CLKSOURCE__))
|
||||
|
||||
/** @brief Macro to get the LPUART1 clock source.
|
||||
* @retval The clock source can be one of the following values:
|
||||
* @arg @ref RCC_LPUART1CLKSOURCE_PCLK1 PCLK1 selected as LPUART1 clock
|
||||
* @arg @ref RCC_LPUART1CLKSOURCE_HSI HSI selected as LPUART1 clock
|
||||
* @arg @ref RCC_LPUART1CLKSOURCE_SYSCLK System Clock selected as LPUART1 clock
|
||||
* @arg @ref RCC_LPUART1CLKSOURCE_LSE LSE selected as LPUART1 clock
|
||||
*/
|
||||
#define __HAL_RCC_GET_LPUART1_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR, RCC_CCIPR_LPUART1SEL)))
|
||||
#endif /* RCC_CCIPR_LPUART1SEL */
|
||||
|
||||
#if defined(RCC_CCIPR_LPTIMSEL)
|
||||
/** @brief Macro to configure the LPTIM1 clock (LPTIM1CLK).
|
||||
*
|
||||
* @param __LPTIM1_CLKSOURCE__ specifies the LPTIM1 clock source.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg @ref RCC_LPTIM1CLKSOURCE_PCLK1 PCLK1 selected as LPTIM1 clock
|
||||
* @arg @ref RCC_LPTIM1CLKSOURCE_LSI HSI selected as LPTIM1 clock
|
||||
* @arg @ref RCC_LPTIM1CLKSOURCE_HSI LSI selected as LPTIM1 clock
|
||||
* @arg @ref RCC_LPTIM1CLKSOURCE_LSE LSE selected as LPTIM1 clock
|
||||
* @note Depending on devices and packages, some clocks may not be available.
|
||||
* Refer to device datasheet for clocks availability.
|
||||
*/
|
||||
#define __HAL_RCC_LPTIM_CONFIG(__LPTIM1_CLKSOURCE__) \
|
||||
MODIFY_REG(RCC->CCIPR, RCC_CCIPR_LPTIMSEL, (uint32_t)(__LPTIM1_CLKSOURCE__))
|
||||
|
||||
/** @brief Macro to get the LPTIM clock source.
|
||||
* @retval The clock source can be one of the following values:
|
||||
* @arg @ref RCC_LPTIMCLKSOURCE_PCLK1 PCLK1 selected as LPUART1 clock
|
||||
* @arg @ref RCC_LPTIMCLKSOURCE_LSI HSI selected as LPUART1 clock
|
||||
* @arg @ref RCC_LPTIMCLKSOURCE_LSE LSE selected as LPUART1 clock
|
||||
* @note Depending on devices and packages, some clocks may not be available.
|
||||
* Refer to device datasheet for clocks availability.
|
||||
*/
|
||||
#define __HAL_RCC_GET_LPTIM_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR, RCC_CCIPR_LPTIMSEL)))
|
||||
#endif /* RCC_CCIPR_LPTIM1SEL */
|
||||
|
||||
#if defined(RCC_CCIPR_TIM1SEL)
|
||||
/** @brief Macro to configure the TIM1 interface clock
|
||||
* @param __TIM1_CLKSOURCE__ specifies the TIM1 digital interface clock source.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg @ref RCC_TIM1CLKSOURCE_PLL PLLQ Output Clock selected as TIM1 clock
|
||||
* @arg @ref RCC_TIM1CLKSOURCE_PCLK1 System Clock selected as TIM1 clock
|
||||
*/
|
||||
#define __HAL_RCC_TIM1_CONFIG(__TIM1_CLKSOURCE__) \
|
||||
MODIFY_REG(RCC->CCIPR, RCC_CCIPR_TIM1SEL, (uint32_t)(__TIM1_CLKSOURCE__))
|
||||
|
||||
/** @brief Macro to get the TIM1 clock source.
|
||||
* @retval The clock source can be one of the following values:
|
||||
* @arg @ref RCC_TIM1CLKSOURCE_PLL PLLQ Output Clock selected as TIM1 clock
|
||||
* @arg @ref RCC_TIM1CLKSOURCE_PCLK1 System Clock selected as TIM1 clock
|
||||
*/
|
||||
#define __HAL_RCC_GET_TIM1_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR, RCC_CCIPR_TIM1SEL)))
|
||||
#endif /* RCC_CCIPR_TIM1SEL */
|
||||
|
||||
#if defined(RCC_CCIPR_TIM15SEL)
|
||||
/** @brief Macro to configure the TIM15 interface clock
|
||||
* @param __TIM15_CLKSOURCE__ specifies the TIM15 digital interface clock source.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg RCC_TIM15CLKSOURCE_PLL PLLQ Output Clock selected as TIM15 clock
|
||||
* @arg RCC_TIM15CLKSOURCE_PCLK1 System Clock selected as TIM15 clock
|
||||
*/
|
||||
#define __HAL_RCC_TIM15_CONFIG(__TIM15_CLKSOURCE__) \
|
||||
MODIFY_REG(RCC->CCIPR, RCC_CCIPR_TIM15SEL, (uint32_t)(__TIM15_CLKSOURCE__))
|
||||
|
||||
/** @brief Macro to get the TIM15 clock source.
|
||||
* @retval The clock source can be one of the following values:
|
||||
* @arg @ref RCC_TIM15CLKSOURCE_PLL PLLQ Output Clock selected as TIM15 clock
|
||||
* @arg @ref RCC_TIM15CLKSOURCE_PCLK1 System Clock selected as TIM15 clock
|
||||
*/
|
||||
#define __HAL_RCC_GET_TIM15_SOURCE() ((uint32_t)(READ_BIT(RCC->CCIPR, RCC_CCIPR_TIM15SEL)))
|
||||
#endif /* RCC_CCIPR_TIM15SEL */
|
||||
|
||||
/** @defgroup RCCEx_Flags_Interrupts_Management Flags Interrupts Management
|
||||
* @brief macros to manage the specified RCC Flags and interrupts.
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/** @addtogroup RCCEx_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup RCCEx_Exported_Functions_Group1
|
||||
* @{
|
||||
*/
|
||||
|
||||
HAL_StatusTypeDef HAL_RCCEx_PeriphCLKConfig(RCC_PeriphCLKInitTypeDef *PeriphClkInit);
|
||||
void HAL_RCCEx_GetPeriphCLKConfig(RCC_PeriphCLKInitTypeDef *PeriphClkInit);
|
||||
uint32_t HAL_RCCEx_GetPeriphCLKFreq(uint32_t PeriphClk);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup RCCEx_Exported_Functions_Group2
|
||||
* @{
|
||||
*/
|
||||
#if defined(RCC_BDCR_LSCOEN)
|
||||
void HAL_RCCEx_EnableLSCO(uint32_t LSCOSource);
|
||||
void HAL_RCCEx_DisableLSCO(void);
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Private macros ------------------------------------------------------------*/
|
||||
/** @defgroup RCCEx_Private_Macros RCCEx Private Macros
|
||||
* @{
|
||||
*/
|
||||
#if defined(RCC_BDCR_LSCOSEL)
|
||||
#if defined(RCC_LSE_SUPPORT)
|
||||
#define IS_RCC_LSCOSOURCE(__SOURCE__) (((__SOURCE__) == RCC_LSCOSOURCE_LSI) || \
|
||||
((__SOURCE__) == RCC_LSCOSOURCE_LSE))
|
||||
#else
|
||||
#define IS_RCC_LSCOSOURCE(__SOURCE__) (((__SOURCE__) == RCC_LSCOSOURCE_LSI))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(RCC_LSE_SUPPORT)
|
||||
#define IS_RCC_USART1CLKSOURCE(__SOURCE__) \
|
||||
(((__SOURCE__) == RCC_USART1CLKSOURCE_PCLK1) || \
|
||||
((__SOURCE__) == RCC_USART1CLKSOURCE_SYSCLK) || \
|
||||
((__SOURCE__) == RCC_USART1CLKSOURCE_LSE) || \
|
||||
((__SOURCE__) == RCC_USART1CLKSOURCE_HSI))
|
||||
#else
|
||||
#define IS_RCC_USART1CLKSOURCE(__SOURCE__) \
|
||||
(((__SOURCE__) == RCC_USART1CLKSOURCE_PCLK1) || \
|
||||
((__SOURCE__) == RCC_USART1CLKSOURCE_SYSCLK) || \
|
||||
((__SOURCE__) == RCC_USART1CLKSOURCE_HSI))
|
||||
#endif
|
||||
|
||||
#if defined(RCC_CCIPR_PVDSEL)
|
||||
#define IS_RCC_PVDCLKSOURCE(__SOURCE__) \
|
||||
(((__SOURCE__) == RCC_PVDCLKSOURCE_PCLK) || \
|
||||
((__SOURCE__) == RCC_PVDCLKSOURCE_LSC))
|
||||
#endif /* RCC_CCIPR_PVDSEL */
|
||||
|
||||
#if defined(RCC_CCIPR_COMP1SEL)
|
||||
#define IS_RCC_COMP1CLKSOURCE(__SOURCE__) \
|
||||
(((__SOURCE__) == RCC_COMP1CLKSOURCE_PCLK) || \
|
||||
((__SOURCE__) == RCC_COMP1CLKSOURCE_LSC))
|
||||
#endif /* RCC_CCIPR_COMP1SEL */
|
||||
|
||||
#if defined(RCC_CCIPR_COMP2SEL)
|
||||
#define IS_RCC_COMP2CLKSOURCE(__SOURCE__) \
|
||||
(((__SOURCE__) == RCC_COMP2CLKSOURCE_PCLK) || \
|
||||
((__SOURCE__) == RCC_COMP2CLKSOURCE_LSC))
|
||||
#endif /* RCC_CCIPR_COMP2SEL */
|
||||
|
||||
#if defined(RCC_CCIPR_LPTIMSEL)
|
||||
#if defined(RCC_LSE_SUPPORT)
|
||||
#define IS_RCC_LPTIM1CLKSOURCE(__SOURCE__) \
|
||||
(((__SOURCE__) == RCC_LPTIMCLKSOURCE_PCLK)|| \
|
||||
((__SOURCE__) == RCC_LPTIMCLKSOURCE_LSI) || \
|
||||
((__SOURCE__) == RCC_LPTIMCLKSOURCE_LSE))
|
||||
#else
|
||||
#define IS_RCC_LPTIM1CLKSOURCE(__SOURCE__) \
|
||||
(((__SOURCE__) == RCC_LPTIMCLKSOURCE_PCLK)|| \
|
||||
((__SOURCE__) == RCC_LPTIMCLKSOURCE_LSI))
|
||||
#endif
|
||||
#endif /* RCC_CCIPR_LPTIM1SEL */
|
||||
|
||||
#if defined(PY32F002APRE)
|
||||
#define IS_RCC_PERIPHCLOCK(__SELECTION__) \
|
||||
((((__SELECTION__) & RCC_PERIPHCLK_LPTIM) == RCC_PERIPHCLK_LPTIM))
|
||||
#else
|
||||
#define IS_RCC_PERIPHCLOCK(__SELECTION__) \
|
||||
((((__SELECTION__) & RCC_PERIPHCLK_COMP1) == RCC_PERIPHCLK_COMP1) || \
|
||||
(((__SELECTION__) & RCC_PERIPHCLK_COMP2) == RCC_PERIPHCLK_COMP2) || \
|
||||
(((__SELECTION__) & RCC_PERIPHCLK_PVD) == RCC_PERIPHCLK_PVD) || \
|
||||
(((__SELECTION__) & RCC_PERIPHCLK_LPTIM) == RCC_PERIPHCLK_LPTIM) || \
|
||||
(((__SELECTION__) & RCC_PERIPHCLK_RTC) == RCC_PERIPHCLK_RTC))
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __PY32F0xx_HAL_RCC_EX_H */
|
||||
|
||||
/************************ (C) COPYRIGHT Puya *****END OF FILE****/
|
||||
604
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_rtc.h
Normal file
604
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_rtc.h
Normal file
@@ -0,0 +1,604 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file py32f0xx_hal_rtc.h
|
||||
* @author MCU Application Team
|
||||
* @brief Header file of RTC HAL module.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) Puya Semiconductor Co.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __PY32F0xx_HAL_RTC_H
|
||||
#define __PY32F0xx_HAL_RTC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "py32f0xx_hal_def.h"
|
||||
|
||||
/** @addtogroup PY32F0xx_HAL_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup RTC
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup RTC_Private_Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define IS_RTC_ASYNCH_PREDIV(PREDIV) (((PREDIV) <= 0xFFFFFU) || ((PREDIV) == RTC_AUTO_1_SECOND))
|
||||
#define IS_RTC_HOUR24(HOUR) ((HOUR) <= 23U)
|
||||
#define IS_RTC_MINUTES(MINUTES) ((MINUTES) <= 59U)
|
||||
#define IS_RTC_SECONDS(SECONDS) ((SECONDS) <= 59U)
|
||||
#define IS_RTC_FORMAT(FORMAT) (((FORMAT) == RTC_FORMAT_BIN) || ((FORMAT) == RTC_FORMAT_BCD))
|
||||
#define IS_RTC_YEAR(YEAR) ((YEAR) <= 99U)
|
||||
#define IS_RTC_MONTH(MONTH) (((MONTH) >= 1U) && ((MONTH) <= 12U))
|
||||
#define IS_RTC_DATE(DATE) (((DATE) >= 1U) && ((DATE) <= 31U))
|
||||
#define IS_RTC_CALIB_OUTPUT(__OUTPUT__) (((__OUTPUT__) == RTC_OUTPUTSOURCE_NONE) || \
|
||||
((__OUTPUT__) == RTC_OUTPUTSOURCE_CALIBCLOCK) || \
|
||||
((__OUTPUT__) == RTC_OUTPUTSOURCE_ALARM) || \
|
||||
((__OUTPUT__) == RTC_OUTPUTSOURCE_SECOND))
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup RTC_Private_Constants
|
||||
* @{
|
||||
*/
|
||||
/** @defgroup RTC_Timeout_Value Default Timeout Value
|
||||
* @{
|
||||
*/
|
||||
#define RTC_TIMEOUT_VALUE 2000U
|
||||
#define RTC_RTOFF_RESET_TIMEOUT_VALUE 4U
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup RTC_EXTI_Line_Event RTC EXTI Line event
|
||||
* @{
|
||||
*/
|
||||
#define RTC_EXTI_LINE_ALARM_EVENT ((uint32_t)EXTI_IMR_IM19) /*!< External interrupt line 19 Connected to the RTC Alarm event */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/** @defgroup RTC_Exported_Types RTC Exported Types
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief RTC Time structure definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t Hours; /*!< Specifies the RTC Time Hour.
|
||||
This parameter must be a number between Min_Data = 0 and Max_Data = 23 */
|
||||
|
||||
uint8_t Minutes; /*!< Specifies the RTC Time Minutes.
|
||||
This parameter must be a number between Min_Data = 0 and Max_Data = 59 */
|
||||
|
||||
uint8_t Seconds; /*!< Specifies the RTC Time Seconds.
|
||||
This parameter must be a number between Min_Data = 0 and Max_Data = 59 */
|
||||
|
||||
} RTC_TimeTypeDef;
|
||||
|
||||
/**
|
||||
* @brief RTC Alarm structure definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
RTC_TimeTypeDef AlarmTime; /*!< Specifies the RTC Alarm Time members */
|
||||
|
||||
} RTC_AlarmTypeDef;
|
||||
|
||||
/**
|
||||
* @brief HAL State structures definition
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
HAL_RTC_STATE_RESET = 0x00U, /*!< RTC not yet initialized or disabled */
|
||||
HAL_RTC_STATE_READY = 0x01U, /*!< RTC initialized and ready for use */
|
||||
HAL_RTC_STATE_BUSY = 0x02U, /*!< RTC process is ongoing */
|
||||
HAL_RTC_STATE_TIMEOUT = 0x03U, /*!< RTC timeout state */
|
||||
HAL_RTC_STATE_ERROR = 0x04U /*!< RTC error state */
|
||||
|
||||
} HAL_RTCStateTypeDef;
|
||||
|
||||
/**
|
||||
* @brief RTC Configuration Structure definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t AsynchPrediv; /*!< Specifies the RTC Asynchronous Predivider value.
|
||||
This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFFFFF or RTC_AUTO_1_SECOND
|
||||
If RTC_AUTO_1_SECOND is selected, AsynchPrediv will be set automatically to get 1sec timebase */
|
||||
|
||||
uint32_t OutPut; /*!< Specifies which signal will be routed to the RTC Tamper pin.
|
||||
This parameter can be a value of @ref RTC_output_source_to_output_pin */
|
||||
|
||||
} RTC_InitTypeDef;
|
||||
|
||||
/**
|
||||
* @brief RTC Date structure definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t WeekDay; /*!< Specifies the RTC Date WeekDay (not necessary for HAL_RTC_SetDate).
|
||||
This parameter can be a value of @ref RTC_WeekDay_Definitions */
|
||||
|
||||
uint8_t Month; /*!< Specifies the RTC Date Month (in BCD format).
|
||||
This parameter can be a value of @ref RTC_Month_Date_Definitions */
|
||||
|
||||
uint8_t Date; /*!< Specifies the RTC Date.
|
||||
This parameter must be a number between Min_Data = 1 and Max_Data = 31 */
|
||||
|
||||
uint8_t Year; /*!< Specifies the RTC Date Year.
|
||||
This parameter must be a number between Min_Data = 0 and Max_Data = 99 */
|
||||
|
||||
} RTC_DateTypeDef;
|
||||
|
||||
/**
|
||||
* @brief Time Handle Structure definition
|
||||
*/
|
||||
#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
|
||||
typedef struct __RTC_HandleTypeDef
|
||||
#else
|
||||
typedef struct
|
||||
#endif /* (USE_HAL_RTC_REGISTER_CALLBACKS) */
|
||||
{
|
||||
RTC_TypeDef *Instance; /*!< Register base address */
|
||||
|
||||
RTC_InitTypeDef Init; /*!< RTC required parameters */
|
||||
|
||||
RTC_DateTypeDef DateToUpdate; /*!< Current date set by user and updated automatically */
|
||||
|
||||
HAL_LockTypeDef Lock; /*!< RTC locking object */
|
||||
|
||||
__IO HAL_RTCStateTypeDef State; /*!< Time communication state */
|
||||
|
||||
#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
|
||||
void (* AlarmAEventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Alarm A Event callback */
|
||||
|
||||
void (* MspInitCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Msp Init callback */
|
||||
|
||||
void (* MspDeInitCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Msp DeInit callback */
|
||||
|
||||
#endif /* (USE_HAL_RTC_REGISTER_CALLBACKS) */
|
||||
|
||||
} RTC_HandleTypeDef;
|
||||
|
||||
#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
|
||||
/**
|
||||
* @brief HAL RTC Callback ID enumeration definition
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
HAL_RTC_ALARM_A_EVENT_CB_ID = 0x00u, /*!< RTC Alarm A Event Callback ID */
|
||||
HAL_RTC_TAMPER1_EVENT_CB_ID = 0x04u, /*!< RTC Tamper 1 Callback ID */
|
||||
HAL_RTC_MSPINIT_CB_ID = 0x0Eu, /*!< RTC Msp Init callback ID */
|
||||
HAL_RTC_MSPDEINIT_CB_ID = 0x0Fu /*!< RTC Msp DeInit callback ID */
|
||||
} HAL_RTC_CallbackIDTypeDef;
|
||||
|
||||
/**
|
||||
* @brief HAL RTC Callback pointer definition
|
||||
*/
|
||||
typedef void (*pRTC_CallbackTypeDef)(RTC_HandleTypeDef *hrtc); /*!< pointer to an RTC callback function */
|
||||
#endif /* USE_HAL_RTC_REGISTER_CALLBACKS */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/** @defgroup RTC_Exported_Constants RTC Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup RTC_Automatic_Prediv_1_Second Automatic calculation of prediv for 1sec timebase
|
||||
* @{
|
||||
*/
|
||||
#define RTC_AUTO_1_SECOND 0xFFFFFFFFU
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup RTC_Input_parameter_format_definitions Input Parameter Format
|
||||
* @{
|
||||
*/
|
||||
#define RTC_FORMAT_BIN 0x000000000U
|
||||
#define RTC_FORMAT_BCD 0x000000001U
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup RTC_Month_Date_Definitions Month Definitions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Coded in BCD format */
|
||||
#define RTC_MONTH_JANUARY ((uint8_t)0x01)
|
||||
#define RTC_MONTH_FEBRUARY ((uint8_t)0x02)
|
||||
#define RTC_MONTH_MARCH ((uint8_t)0x03)
|
||||
#define RTC_MONTH_APRIL ((uint8_t)0x04)
|
||||
#define RTC_MONTH_MAY ((uint8_t)0x05)
|
||||
#define RTC_MONTH_JUNE ((uint8_t)0x06)
|
||||
#define RTC_MONTH_JULY ((uint8_t)0x07)
|
||||
#define RTC_MONTH_AUGUST ((uint8_t)0x08)
|
||||
#define RTC_MONTH_SEPTEMBER ((uint8_t)0x09)
|
||||
#define RTC_MONTH_OCTOBER ((uint8_t)0x10)
|
||||
#define RTC_MONTH_NOVEMBER ((uint8_t)0x11)
|
||||
#define RTC_MONTH_DECEMBER ((uint8_t)0x12)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup RTC_WeekDay_Definitions WeekDay Definitions
|
||||
* @{
|
||||
*/
|
||||
#define RTC_WEEKDAY_MONDAY ((uint8_t)0x01)
|
||||
#define RTC_WEEKDAY_TUESDAY ((uint8_t)0x02)
|
||||
#define RTC_WEEKDAY_WEDNESDAY ((uint8_t)0x03)
|
||||
#define RTC_WEEKDAY_THURSDAY ((uint8_t)0x04)
|
||||
#define RTC_WEEKDAY_FRIDAY ((uint8_t)0x05)
|
||||
#define RTC_WEEKDAY_SATURDAY ((uint8_t)0x06)
|
||||
#define RTC_WEEKDAY_SUNDAY ((uint8_t)0x00)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup RTC_Alarms_Definitions Alarms Definitions
|
||||
* @{
|
||||
*/
|
||||
#define RTC_ALARM_A 0U /*!< Specify alarm ID (mainly for legacy purposes) */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup RTC_output_source_to_output_pin Output source to output pin
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define RTC_OUTPUTSOURCE_NONE 0x00000000U /*!< No output on the TAMPER pin */
|
||||
#define RTC_OUTPUTSOURCE_CALIBCLOCK BKP_RTCCR_CCO /*!< RTC clock with a frequency divided by 64 on the TAMPER pin */
|
||||
#define RTC_OUTPUTSOURCE_ALARM BKP_RTCCR_ASOE /*!< Alarm pulse signal on the TAMPER pin */
|
||||
#define RTC_OUTPUTSOURCE_SECOND (BKP_RTCCR_ASOS | BKP_RTCCR_ASOE) /*!< Second pulse signal on the TAMPER pin */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup RTC_Interrupts_Definitions Interrupts Definitions
|
||||
* @{
|
||||
*/
|
||||
#define RTC_IT_OW RTC_CRH_OWIE /*!< Overflow interrupt */
|
||||
#define RTC_IT_ALRA RTC_CRH_ALRIE /*!< Alarm interrupt */
|
||||
#define RTC_IT_SEC RTC_CRH_SECIE /*!< Second interrupt */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup RTC_Flags_Definitions Flags Definitions
|
||||
* @{
|
||||
*/
|
||||
#define RTC_FLAG_RTOFF RTC_CRL_RTOFF /*!< RTC Operation OFF flag */
|
||||
#define RTC_FLAG_RSF RTC_CRL_RSF /*!< Registers Synchronized flag */
|
||||
#define RTC_FLAG_OW RTC_CRL_OWF /*!< Overflow flag */
|
||||
#define RTC_FLAG_ALRAF RTC_CRL_ALRF /*!< Alarm flag */
|
||||
#define RTC_FLAG_SEC RTC_CRL_SECF /*!< Second flag */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/** @defgroup RTC_Exported_macros RTC Exported Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @brief Reset RTC handle state
|
||||
* @param __HANDLE__: RTC handle.
|
||||
* @retval None
|
||||
*/
|
||||
#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
|
||||
#define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) do{\
|
||||
(__HANDLE__)->State = HAL_RTC_STATE_RESET;\
|
||||
(__HANDLE__)->MspInitCallback = NULL;\
|
||||
(__HANDLE__)->MspDeInitCallback = NULL;\
|
||||
}while(0u)
|
||||
#else
|
||||
#define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_RTC_STATE_RESET)
|
||||
#endif /* USE_HAL_RTC_REGISTER_CALLBACKS */
|
||||
|
||||
/**
|
||||
* @brief Disable the write protection for RTC registers.
|
||||
* @param __HANDLE__: specifies the RTC handle.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CRL, RTC_CRL_CNF)
|
||||
|
||||
/**
|
||||
* @brief Enable the write protection for RTC registers.
|
||||
* @param __HANDLE__: specifies the RTC handle.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->CRL, RTC_CRL_CNF)
|
||||
|
||||
/**
|
||||
* @brief Enable the RTC Alarm interrupt.
|
||||
* @param __HANDLE__: specifies the RTC handle.
|
||||
* @param __INTERRUPT__: specifies the RTC Alarm interrupt sources to be enabled or disabled.
|
||||
* This parameter can be any combination of the following values:
|
||||
* @arg RTC_IT_ALRA: Alarm A interrupt
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_RTC_ALARM_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BIT((__HANDLE__)->Instance->CRH, (__INTERRUPT__))
|
||||
|
||||
/**
|
||||
* @brief Disable the RTC Alarm interrupt.
|
||||
* @param __HANDLE__: specifies the RTC handle.
|
||||
* @param __INTERRUPT__: specifies the RTC Alarm interrupt sources to be enabled or disabled.
|
||||
* This parameter can be any combination of the following values:
|
||||
* @arg RTC_IT_ALRA: Alarm A interrupt
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_RTC_ALARM_DISABLE_IT(__HANDLE__, __INTERRUPT__) CLEAR_BIT((__HANDLE__)->Instance->CRH, (__INTERRUPT__))
|
||||
|
||||
/**
|
||||
* @brief Check whether the specified RTC Alarm interrupt has been enabled or not.
|
||||
* @param __HANDLE__: specifies the RTC handle.
|
||||
* @param __INTERRUPT__: specifies the RTC Alarm interrupt sources to be checked
|
||||
* This parameter can be:
|
||||
* @arg RTC_IT_ALRA: Alarm A interrupt
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_RTC_ALARM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((((__HANDLE__)->Instance->CRH)& ((__INTERRUPT__)))) != RESET)? SET : RESET)
|
||||
|
||||
/**
|
||||
* @brief Get the selected RTC Alarm's flag status.
|
||||
* @param __HANDLE__: specifies the RTC handle.
|
||||
* @param __FLAG__: specifies the RTC Alarm Flag sources to be enabled or disabled.
|
||||
* This parameter can be:
|
||||
* @arg RTC_FLAG_ALRAF
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_RTC_ALARM_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->CRL) & (__FLAG__)) != RESET)? SET : RESET)
|
||||
|
||||
/**
|
||||
* @brief Check whether the specified RTC Alarm interrupt has occurred or not.
|
||||
* @param __HANDLE__: specifies the RTC handle.
|
||||
* @param __INTERRUPT__: specifies the RTC Alarm interrupt sources to check.
|
||||
* This parameter can be:
|
||||
* @arg RTC_IT_ALRA: Alarm A interrupt
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_RTC_ALARM_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->CRL) & (__INTERRUPT__)) != RESET)? SET : RESET)
|
||||
|
||||
/**
|
||||
* @brief Clear the RTC Alarm's pending flags.
|
||||
* @param __HANDLE__: specifies the RTC handle.
|
||||
* @param __FLAG__: specifies the RTC Alarm Flag sources to be enabled or disabled.
|
||||
* This parameter can be:
|
||||
* @arg RTC_FLAG_ALRAF
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_RTC_ALARM_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->CRL) = ~(__FLAG__)
|
||||
|
||||
/**
|
||||
* @brief Enable interrupt on ALARM Exti Line 17.
|
||||
* @retval None.
|
||||
*/
|
||||
#define __HAL_RTC_ALARM_EXTI_ENABLE_IT() SET_BIT(EXTI->IMR, RTC_EXTI_LINE_ALARM_EVENT)
|
||||
|
||||
/**
|
||||
* @brief Disable interrupt on ALARM Exti Line 17.
|
||||
* @retval None.
|
||||
*/
|
||||
#define __HAL_RTC_ALARM_EXTI_DISABLE_IT() CLEAR_BIT(EXTI->IMR, RTC_EXTI_LINE_ALARM_EVENT)
|
||||
|
||||
/**
|
||||
* @brief Enable event on ALARM Exti Line 17.
|
||||
* @retval None.
|
||||
*/
|
||||
#define __HAL_RTC_ALARM_EXTI_ENABLE_EVENT() SET_BIT(EXTI->EMR, RTC_EXTI_LINE_ALARM_EVENT)
|
||||
|
||||
/**
|
||||
* @brief Disable event on ALARM Exti Line 17.
|
||||
* @retval None.
|
||||
*/
|
||||
#define __HAL_RTC_ALARM_EXTI_DISABLE_EVENT() CLEAR_BIT(EXTI->EMR, RTC_EXTI_LINE_ALARM_EVENT)
|
||||
|
||||
|
||||
/**
|
||||
* @brief ALARM EXTI line configuration: set falling edge trigger.
|
||||
* @retval None.
|
||||
*/
|
||||
#define __HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE() SET_BIT(EXTI->FTSR, RTC_EXTI_LINE_ALARM_EVENT)
|
||||
|
||||
|
||||
/**
|
||||
* @brief Disable the ALARM Extended Interrupt Falling Trigger.
|
||||
* @retval None.
|
||||
*/
|
||||
#define __HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE() CLEAR_BIT(EXTI->FTSR, RTC_EXTI_LINE_ALARM_EVENT)
|
||||
|
||||
|
||||
/**
|
||||
* @brief ALARM EXTI line configuration: set rising edge trigger.
|
||||
* @retval None.
|
||||
*/
|
||||
#define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE() SET_BIT(EXTI->RTSR, RTC_EXTI_LINE_ALARM_EVENT)
|
||||
|
||||
/**
|
||||
* @brief Disable the ALARM Extended Interrupt Rising Trigger.
|
||||
* This parameter can be:
|
||||
* @retval None.
|
||||
*/
|
||||
#define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE() CLEAR_BIT(EXTI->RTSR, RTC_EXTI_LINE_ALARM_EVENT)
|
||||
|
||||
/**
|
||||
* @brief ALARM EXTI line configuration: set rising & falling edge trigger.
|
||||
* @retval None.
|
||||
*/
|
||||
#define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_FALLING_EDGE() \
|
||||
do{ \
|
||||
__HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE(); \
|
||||
__HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE(); \
|
||||
} while(0U)
|
||||
|
||||
/**
|
||||
* @brief Disable the ALARM Extended Interrupt Rising & Falling Trigger.
|
||||
* This parameter can be:
|
||||
* @retval None.
|
||||
*/
|
||||
#define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_FALLING_EDGE() \
|
||||
do{ \
|
||||
__HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE(); \
|
||||
__HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE(); \
|
||||
} while(0U)
|
||||
|
||||
/**
|
||||
* @brief Check whether the specified ALARM EXTI interrupt flag is set or not.
|
||||
* @retval EXTI ALARM Line Status.
|
||||
*/
|
||||
#define __HAL_RTC_ALARM_EXTI_GET_FLAG() (EXTI->PR & (RTC_EXTI_LINE_ALARM_EVENT))
|
||||
|
||||
/**
|
||||
* @brief Clear the ALARM EXTI flag.
|
||||
* @retval None.
|
||||
*/
|
||||
#define __HAL_RTC_ALARM_EXTI_CLEAR_FLAG() (EXTI->PR = (RTC_EXTI_LINE_ALARM_EVENT))
|
||||
|
||||
/**
|
||||
* @brief Generate a Software interrupt on selected EXTI line.
|
||||
* @retval None.
|
||||
*/
|
||||
#define __HAL_RTC_ALARM_EXTI_GENERATE_SWIT() SET_BIT(EXTI->SWIER, RTC_EXTI_LINE_ALARM_EVENT)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Include RTC HAL Extension module */
|
||||
#include "py32f0xx_hal_rtc_ex.h"
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/** @addtogroup RTC_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/* Initialization and de-initialization functions ****************************/
|
||||
/** @addtogroup RTC_Exported_Functions_Group1
|
||||
* @{
|
||||
*/
|
||||
HAL_StatusTypeDef HAL_RTC_Init(RTC_HandleTypeDef *hrtc);
|
||||
HAL_StatusTypeDef HAL_RTC_DeInit(RTC_HandleTypeDef *hrtc);
|
||||
void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc);
|
||||
void HAL_RTC_MspDeInit(RTC_HandleTypeDef *hrtc);
|
||||
|
||||
/* Callbacks Register/UnRegister functions ***********************************/
|
||||
#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
|
||||
HAL_StatusTypeDef HAL_RTC_RegisterCallback(RTC_HandleTypeDef *hrtc, HAL_RTC_CallbackIDTypeDef CallbackID, pRTC_CallbackTypeDef pCallback);
|
||||
HAL_StatusTypeDef HAL_RTC_UnRegisterCallback(RTC_HandleTypeDef *hrtc, HAL_RTC_CallbackIDTypeDef CallbackID);
|
||||
#endif /* USE_HAL_RTC_REGISTER_CALLBACKS */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* RTC Time and Date functions ************************************************/
|
||||
/** @addtogroup RTC_Exported_Functions_Group2
|
||||
* @{
|
||||
*/
|
||||
HAL_StatusTypeDef HAL_RTC_SetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format);
|
||||
HAL_StatusTypeDef HAL_RTC_GetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format);
|
||||
HAL_StatusTypeDef HAL_RTC_SetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format);
|
||||
HAL_StatusTypeDef HAL_RTC_GetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* RTC Alarm functions ********************************************************/
|
||||
/** @addtogroup RTC_Exported_Functions_Group3
|
||||
* @{
|
||||
*/
|
||||
HAL_StatusTypeDef HAL_RTC_SetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format);
|
||||
HAL_StatusTypeDef HAL_RTC_SetAlarm_IT(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format);
|
||||
HAL_StatusTypeDef HAL_RTC_DeactivateAlarm(RTC_HandleTypeDef *hrtc);
|
||||
HAL_StatusTypeDef HAL_RTC_GetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format);
|
||||
void HAL_RTC_AlarmIRQHandler(RTC_HandleTypeDef *hrtc);
|
||||
HAL_StatusTypeDef HAL_RTC_PollForAlarmAEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
|
||||
void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Peripheral State functions *************************************************/
|
||||
/** @addtogroup RTC_Exported_Functions_Group4
|
||||
* @{
|
||||
*/
|
||||
HAL_RTCStateTypeDef HAL_RTC_GetState(RTC_HandleTypeDef *hrtc);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Peripheral Control functions ***********************************************/
|
||||
/** @addtogroup RTC_Exported_Functions_Group5
|
||||
* @{
|
||||
*/
|
||||
HAL_StatusTypeDef HAL_RTC_WaitForSynchro(RTC_HandleTypeDef *hrtc);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __PY32F0xx_HAL_RTC_H */
|
||||
|
||||
/************************ (C) COPYRIGHT Puya *****END OF FILE****/
|
||||
216
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_rtc_ex.h
Normal file
216
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_rtc_ex.h
Normal file
@@ -0,0 +1,216 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file py32f0xx_hal_rtc_ex.h
|
||||
* @author MCU Application Team
|
||||
* @brief Header file of RTC HAL Extension module.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) Puya Semiconductor Co.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __PY32F0xxHAL_RTC_EX_H
|
||||
#define __PY32F0xxHAL_RTC_EX_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "py32f0xx_hal_def.h"
|
||||
|
||||
/** @addtogroup PY32F0xxHAL_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup RTCEx
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup RTCEx_Private_Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup RTCEx_IS_RTC_Definitions Private macros to check input parameters
|
||||
* @{
|
||||
*/
|
||||
#define IS_RTC_SMOOTH_CALIB_MINUS(__VALUE__) ((__VALUE__) <= 0x0000007FU)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/** @defgroup RTCEx_Exported_Macros RTCEx Exported Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Enable the RTC Second interrupt.
|
||||
* @param __HANDLE__: specifies the RTC handle.
|
||||
* @param __INTERRUPT__: specifies the RTC Second interrupt sources to be enabled
|
||||
* This parameter can be any combination of the following values:
|
||||
* @arg RTC_IT_SEC: Second A interrupt
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_RTC_SECOND_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BIT((__HANDLE__)->Instance->CRH, (__INTERRUPT__))
|
||||
|
||||
/**
|
||||
* @brief Disable the RTC Second interrupt.
|
||||
* @param __HANDLE__: specifies the RTC handle.
|
||||
* @param __INTERRUPT__: specifies the RTC Second interrupt sources to be disabled.
|
||||
* This parameter can be any combination of the following values:
|
||||
* @arg RTC_IT_SEC: Second A interrupt
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_RTC_SECOND_DISABLE_IT(__HANDLE__, __INTERRUPT__) CLEAR_BIT((__HANDLE__)->Instance->CRH, (__INTERRUPT__))
|
||||
|
||||
/**
|
||||
* @brief Check whether the specified RTC Second interrupt has occurred or not.
|
||||
* @param __HANDLE__: specifies the RTC handle.
|
||||
* @param __INTERRUPT__: specifies the RTC Second interrupt sources to be enabled or disabled.
|
||||
* This parameter can be:
|
||||
* @arg RTC_IT_SEC: Second A interrupt
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_RTC_SECOND_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((((__HANDLE__)->Instance->CRH)& ((__INTERRUPT__)))) != RESET)? SET : RESET)
|
||||
|
||||
/**
|
||||
* @brief Get the selected RTC Second's flag status.
|
||||
* @param __HANDLE__: specifies the RTC handle.
|
||||
* @param __FLAG__: specifies the RTC Second Flag sources to be enabled or disabled.
|
||||
* This parameter can be:
|
||||
* @arg RTC_FLAG_SEC
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_RTC_SECOND_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->CRL) & (__FLAG__)) != RESET)? SET : RESET)
|
||||
|
||||
/**
|
||||
* @brief Clear the RTC Second's pending flags.
|
||||
* @param __HANDLE__: specifies the RTC handle.
|
||||
* @param __FLAG__: specifies the RTC Second Flag sources to be enabled or disabled.
|
||||
* This parameter can be:
|
||||
* @arg RTC_FLAG_SEC
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_RTC_SECOND_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->CRL) = ~(__FLAG__)
|
||||
|
||||
/**
|
||||
* @brief Enable the RTC Overflow interrupt.
|
||||
* @param __HANDLE__: specifies the RTC handle.
|
||||
* @param __INTERRUPT__: specifies the RTC Overflow interrupt sources to be enabled
|
||||
* This parameter can be any combination of the following values:
|
||||
* @arg RTC_IT_OW: Overflow A interrupt
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_RTC_OVERFLOW_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BIT((__HANDLE__)->Instance->CRH, (__INTERRUPT__))
|
||||
|
||||
/**
|
||||
* @brief Disable the RTC Overflow interrupt.
|
||||
* @param __HANDLE__: specifies the RTC handle.
|
||||
* @param __INTERRUPT__: specifies the RTC Overflow interrupt sources to be disabled.
|
||||
* This parameter can be any combination of the following values:
|
||||
* @arg RTC_IT_OW: Overflow A interrupt
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_RTC_OVERFLOW_DISABLE_IT(__HANDLE__, __INTERRUPT__) CLEAR_BIT((__HANDLE__)->Instance->CRH, (__INTERRUPT__))
|
||||
|
||||
/**
|
||||
* @brief Check whether the specified RTC Overflow interrupt has occurred or not.
|
||||
* @param __HANDLE__: specifies the RTC handle.
|
||||
* @param __INTERRUPT__: specifies the RTC Overflow interrupt sources to be enabled or disabled.
|
||||
* This parameter can be:
|
||||
* @arg RTC_IT_OW: Overflow A interrupt
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_RTC_OVERFLOW_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((((__HANDLE__)->Instance->CRH)& ((__INTERRUPT__))) ) != RESET)? SET : RESET)
|
||||
|
||||
/**
|
||||
* @brief Get the selected RTC Overflow's flag status.
|
||||
* @param __HANDLE__: specifies the RTC handle.
|
||||
* @param __FLAG__: specifies the RTC Overflow Flag sources to be enabled or disabled.
|
||||
* This parameter can be:
|
||||
* @arg RTC_FLAG_OW
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_RTC_OVERFLOW_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->CRL) & (__FLAG__)) != RESET)? SET : RESET)
|
||||
|
||||
/**
|
||||
* @brief Clear the RTC Overflow's pending flags.
|
||||
* @param __HANDLE__: specifies the RTC handle.
|
||||
* @param __FLAG__: specifies the RTC Overflow Flag sources to be enabled or disabled.
|
||||
* This parameter can be:
|
||||
* @arg RTC_FLAG_OW
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_RTC_OVERFLOW_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->CRL) = ~(__FLAG__)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/** @addtogroup RTCEx_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* RTC Second functions *****************************************/
|
||||
/** @addtogroup RTCEx_Exported_Functions_Group2
|
||||
* @{
|
||||
*/
|
||||
HAL_StatusTypeDef HAL_RTCEx_SetSecond_IT(RTC_HandleTypeDef *hrtc);
|
||||
HAL_StatusTypeDef HAL_RTCEx_DeactivateSecond(RTC_HandleTypeDef *hrtc);
|
||||
void HAL_RTCEx_RTCIRQHandler(RTC_HandleTypeDef *hrtc);
|
||||
void HAL_RTCEx_RTCEventCallback(RTC_HandleTypeDef *hrtc);
|
||||
void HAL_RTCEx_RTCEventErrorCallback(RTC_HandleTypeDef *hrtc);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Extension Control functions ************************************************/
|
||||
/** @addtogroup RTCEx_Exported_Functions_Group3
|
||||
* @{
|
||||
*/
|
||||
HAL_StatusTypeDef HAL_RTCEx_SetSmoothCalib(RTC_HandleTypeDef *hrtc, uint32_t SmoothCalibPeriod, uint32_t SmoothCalibPlusPulses, uint32_t SmouthCalibMinusPulsesValue);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __PY32F0xxHAL_RTC_EX_H */
|
||||
|
||||
/************************ (C) COPYRIGHT Puya *****END OF FILE****/
|
||||
740
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_spi.h
Normal file
740
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_spi.h
Normal file
@@ -0,0 +1,740 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file py32f0xx_hal_spi.h
|
||||
* @author MCU Application Team
|
||||
* @brief Header file of SPI HAL module.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) Puya Semiconductor Co.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __PY32F0xx_HAL_SPI_H
|
||||
#define __PY32F0xx_HAL_SPI_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "py32f0xx_hal_def.h"
|
||||
|
||||
/** @addtogroup PY32F0xx_HAL_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup SPI
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/** @defgroup SPI_Exported_Types SPI Exported Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief SPI Configuration Structure definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t Mode; /*!< Specifies the SPI operating mode.
|
||||
This parameter can be a value of @ref SPI_Mode */
|
||||
|
||||
uint32_t Direction; /*!< Specifies the SPI bidirectional mode state.
|
||||
This parameter can be a value of @ref SPI_Direction */
|
||||
|
||||
uint32_t DataSize; /*!< Specifies the SPI data size.
|
||||
This parameter can be a value of @ref SPI_Data_Size */
|
||||
|
||||
uint32_t CLKPolarity; /*!< Specifies the serial clock steady state.
|
||||
This parameter can be a value of @ref SPI_Clock_Polarity */
|
||||
|
||||
uint32_t CLKPhase; /*!< Specifies the clock active edge for the bit capture.
|
||||
This parameter can be a value of @ref SPI_Clock_Phase */
|
||||
|
||||
uint32_t NSS; /*!< Specifies whether the NSS signal is managed by
|
||||
hardware (NSS pin) or by software using the SSI bit.
|
||||
This parameter can be a value of @ref SPI_Slave_Select_management */
|
||||
|
||||
uint32_t BaudRatePrescaler; /*!< Specifies the Baud Rate prescaler value which will be
|
||||
used to configure the transmit and receive SCK clock.
|
||||
This parameter can be a value of @ref SPI_BaudRate_Prescaler
|
||||
@note The communication clock is derived from the master
|
||||
clock. The slave clock does not need to be set. */
|
||||
|
||||
uint32_t FirstBit; /*!< Specifies whether data transfers start from MSB or LSB bit.
|
||||
This parameter can be a value of @ref SPI_MSB_LSB_transmission */
|
||||
|
||||
uint32_t SlaveFastMode; /*!< Specifies the Slave fast mode is enabled or not.
|
||||
This parameter can be a value of @ref SPI_Slave_Fast_mode */
|
||||
} SPI_InitTypeDef;
|
||||
|
||||
/**
|
||||
* @brief HAL SPI State structure definition
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
HAL_SPI_STATE_RESET = 0x00U, /*!< Peripheral not Initialized */
|
||||
HAL_SPI_STATE_READY = 0x01U, /*!< Peripheral Initialized and ready for use */
|
||||
HAL_SPI_STATE_BUSY = 0x02U, /*!< an internal process is ongoing */
|
||||
HAL_SPI_STATE_BUSY_TX = 0x03U, /*!< Data Transmission process is ongoing */
|
||||
HAL_SPI_STATE_BUSY_RX = 0x04U, /*!< Data Reception process is ongoing */
|
||||
HAL_SPI_STATE_BUSY_TX_RX = 0x05U, /*!< Data Transmission and Reception process is ongoing */
|
||||
HAL_SPI_STATE_ERROR = 0x06U, /*!< SPI error state */
|
||||
HAL_SPI_STATE_ABORT = 0x07U /*!< SPI abort is ongoing */
|
||||
} HAL_SPI_StateTypeDef;
|
||||
|
||||
/**
|
||||
* @brief SPI handle Structure definition
|
||||
*/
|
||||
typedef struct __SPI_HandleTypeDef
|
||||
{
|
||||
SPI_TypeDef *Instance; /*!< SPI registers base address */
|
||||
|
||||
SPI_InitTypeDef Init; /*!< SPI communication parameters */
|
||||
|
||||
uint8_t *pTxBuffPtr; /*!< Pointer to SPI Tx transfer Buffer */
|
||||
|
||||
uint16_t TxXferSize; /*!< SPI Tx Transfer size */
|
||||
|
||||
__IO uint16_t TxXferCount; /*!< SPI Tx Transfer Counter */
|
||||
|
||||
uint8_t *pRxBuffPtr; /*!< Pointer to SPI Rx transfer Buffer */
|
||||
|
||||
uint16_t RxXferSize; /*!< SPI Rx Transfer size */
|
||||
|
||||
__IO uint16_t RxXferCount; /*!< SPI Rx Transfer Counter */
|
||||
|
||||
void (*RxISR)(struct __SPI_HandleTypeDef *hspi); /*!< function pointer on Rx ISR */
|
||||
|
||||
void (*TxISR)(struct __SPI_HandleTypeDef *hspi); /*!< function pointer on Tx ISR */
|
||||
|
||||
#if (defined(DMA1) || defined(DMA))
|
||||
DMA_HandleTypeDef *hdmatx; /*!< SPI Tx DMA Handle parameters */
|
||||
|
||||
DMA_HandleTypeDef *hdmarx; /*!< SPI Rx DMA Handle parameters */
|
||||
#endif /* DMA1 or DMA */
|
||||
|
||||
HAL_LockTypeDef Lock; /*!< Locking object */
|
||||
|
||||
__IO HAL_SPI_StateTypeDef State; /*!< SPI communication state */
|
||||
|
||||
__IO uint32_t ErrorCode; /*!< SPI Error code */
|
||||
|
||||
#if (USE_HAL_SPI_REGISTER_CALLBACKS == 1U)
|
||||
void (* TxCpltCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Tx Completed callback */
|
||||
void (* RxCpltCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Rx Completed callback */
|
||||
void (* TxRxCpltCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI TxRx Completed callback */
|
||||
void (* TxHalfCpltCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Tx Half Completed callback */
|
||||
void (* RxHalfCpltCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Rx Half Completed callback */
|
||||
void (* TxRxHalfCpltCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI TxRx Half Completed callback */
|
||||
void (* ErrorCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Error callback */
|
||||
void (* AbortCpltCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Abort callback */
|
||||
void (* MspInitCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Msp Init callback */
|
||||
void (* MspDeInitCallback)(struct __SPI_HandleTypeDef *hspi); /*!< SPI Msp DeInit callback */
|
||||
|
||||
#endif /* USE_HAL_SPI_REGISTER_CALLBACKS */
|
||||
} SPI_HandleTypeDef;
|
||||
|
||||
#if (USE_HAL_SPI_REGISTER_CALLBACKS == 1U)
|
||||
/**
|
||||
* @brief HAL SPI Callback ID enumeration definition
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
HAL_SPI_TX_COMPLETE_CB_ID = 0x00U, /*!< SPI Tx Completed callback ID */
|
||||
HAL_SPI_RX_COMPLETE_CB_ID = 0x01U, /*!< SPI Rx Completed callback ID */
|
||||
HAL_SPI_TX_RX_COMPLETE_CB_ID = 0x02U, /*!< SPI TxRx Completed callback ID */
|
||||
HAL_SPI_TX_HALF_COMPLETE_CB_ID = 0x03U, /*!< SPI Tx Half Completed callback ID */
|
||||
HAL_SPI_RX_HALF_COMPLETE_CB_ID = 0x04U, /*!< SPI Rx Half Completed callback ID */
|
||||
HAL_SPI_TX_RX_HALF_COMPLETE_CB_ID = 0x05U, /*!< SPI TxRx Half Completed callback ID */
|
||||
HAL_SPI_ERROR_CB_ID = 0x06U, /*!< SPI Error callback ID */
|
||||
HAL_SPI_ABORT_CB_ID = 0x07U, /*!< SPI Abort callback ID */
|
||||
HAL_SPI_MSPINIT_CB_ID = 0x08U, /*!< SPI Msp Init callback ID */
|
||||
HAL_SPI_MSPDEINIT_CB_ID = 0x09U /*!< SPI Msp DeInit callback ID */
|
||||
|
||||
} HAL_SPI_CallbackIDTypeDef;
|
||||
|
||||
/**
|
||||
* @brief HAL SPI Callback pointer definition
|
||||
*/
|
||||
typedef void (*pSPI_CallbackTypeDef)(SPI_HandleTypeDef *hspi); /*!< pointer to an SPI callback function */
|
||||
|
||||
#endif /* USE_HAL_SPI_REGISTER_CALLBACKS */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/** @defgroup SPI_Exported_Constants SPI Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup SPI_Error_Code SPI Error Code
|
||||
* @{
|
||||
*/
|
||||
#define HAL_SPI_ERROR_NONE (0x00000000U) /*!< No error */
|
||||
#define HAL_SPI_ERROR_MODF (0x00000001U) /*!< MODF error */
|
||||
#define HAL_SPI_ERROR_OVR (0x00000004U) /*!< OVR error */
|
||||
#define HAL_SPI_ERROR_FRE (0x00000008U) /*!< FRE error */
|
||||
#if (defined(DMA1) || defined(DMA))
|
||||
#define HAL_SPI_ERROR_DMA (0x00000010U) /*!< DMA transfer error */
|
||||
#endif /* DMA1 or DMA */
|
||||
#define HAL_SPI_ERROR_FLAG (0x00000020U) /*!< Error on RXNE/TXE/BSY/FTLVL/FRLVL Flag */
|
||||
#define HAL_SPI_ERROR_ABORT (0x00000040U) /*!< Error during SPI Abort procedure */
|
||||
#if (USE_HAL_SPI_REGISTER_CALLBACKS == 1U)
|
||||
#define HAL_SPI_ERROR_INVALID_CALLBACK (0x00000080U) /*!< Invalid Callback error */
|
||||
#endif /* USE_HAL_SPI_REGISTER_CALLBACKS */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup SPI_Mode SPI Mode
|
||||
* @{
|
||||
*/
|
||||
#define SPI_MODE_SLAVE (0x00000000U)
|
||||
#define SPI_MODE_MASTER (SPI_CR1_MSTR | SPI_CR1_SSI)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup SPI_Direction SPI Direction Mode
|
||||
* @{
|
||||
*/
|
||||
#define SPI_DIRECTION_2LINES (0x00000000U)
|
||||
#define SPI_DIRECTION_2LINES_RXONLY SPI_CR1_RXONLY
|
||||
#define SPI_DIRECTION_1LINE SPI_CR1_BIDIMODE
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup SPI_Data_Size SPI Data Size
|
||||
* @{
|
||||
*/
|
||||
#define SPI_DATASIZE_8BIT (0x00000700U)
|
||||
#define SPI_DATASIZE_16BIT (0x00000F00U)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup SPI_Clock_Polarity SPI Clock Polarity
|
||||
* @{
|
||||
*/
|
||||
#define SPI_POLARITY_LOW (0x00000000U)
|
||||
#define SPI_POLARITY_HIGH SPI_CR1_CPOL
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup SPI_Clock_Phase SPI Clock Phase
|
||||
* @{
|
||||
*/
|
||||
#define SPI_PHASE_1EDGE (0x00000000U)
|
||||
#define SPI_PHASE_2EDGE SPI_CR1_CPHA
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup SPI_Slave_Select_management SPI Slave Select Management
|
||||
* @{
|
||||
*/
|
||||
#define SPI_NSS_SOFT SPI_CR1_SSM
|
||||
#define SPI_NSS_HARD_INPUT (0x00000000U)
|
||||
#define SPI_NSS_HARD_OUTPUT (SPI_CR2_SSOE << 16U)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup SPI_BaudRate_Prescaler SPI BaudRate Prescaler
|
||||
* @{
|
||||
*/
|
||||
#define SPI_BAUDRATEPRESCALER_2 (0x00000000U)
|
||||
#define SPI_BAUDRATEPRESCALER_4 (SPI_CR1_BR_0)
|
||||
#define SPI_BAUDRATEPRESCALER_8 (SPI_CR1_BR_1)
|
||||
#define SPI_BAUDRATEPRESCALER_16 (SPI_CR1_BR_1 | SPI_CR1_BR_0)
|
||||
#define SPI_BAUDRATEPRESCALER_32 (SPI_CR1_BR_2)
|
||||
#define SPI_BAUDRATEPRESCALER_64 (SPI_CR1_BR_2 | SPI_CR1_BR_0)
|
||||
#define SPI_BAUDRATEPRESCALER_128 (SPI_CR1_BR_2 | SPI_CR1_BR_1)
|
||||
#define SPI_BAUDRATEPRESCALER_256 (SPI_CR1_BR_2 | SPI_CR1_BR_1 | SPI_CR1_BR_0)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup SPI_MSB_LSB_transmission SPI MSB LSB Transmission
|
||||
* @{
|
||||
*/
|
||||
#define SPI_FIRSTBIT_MSB (0x00000000U)
|
||||
#define SPI_FIRSTBIT_LSB SPI_CR1_LSBFIRST
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup SPI_Slave_Fast_mode SPI Slave Fast Mode
|
||||
* @{
|
||||
*/
|
||||
#define SPI_SLAVE_FAST_MODE_DISABLE (0x00000000U)
|
||||
#define SPI_SLAVE_FAST_MODE_ENABLE SPI_CR2_SLVFM
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup SPI_FIFO_reception_threshold SPI FIFO Reception Threshold
|
||||
* @{
|
||||
* This parameter can be one of the following values:
|
||||
* SPI_RXFIFO_THRESHOLD or SPI_RXFIFO_THRESHOLD_QF :
|
||||
* RXNE event is generated if the FIFO
|
||||
* level is greater or equal to 1/4(8-bits).
|
||||
* SPI_RXFIFO_THRESHOLD_HF: RXNE event is generated if the FIFO
|
||||
* level is greater or equal to 1/2(16 bits). */
|
||||
#define SPI_RXFIFO_THRESHOLD SPI_CR2_FRXTH
|
||||
#define SPI_RXFIFO_THRESHOLD_QF SPI_CR2_FRXTH
|
||||
#define SPI_RXFIFO_THRESHOLD_HF (0x00000000U)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup SPI_Interrupt_definition SPI Interrupt Definition
|
||||
* @{
|
||||
*/
|
||||
#define SPI_IT_TXE SPI_CR2_TXEIE
|
||||
#define SPI_IT_RXNE SPI_CR2_RXNEIE
|
||||
#define SPI_IT_ERR SPI_CR2_ERRIE
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup SPI_Flags_definition SPI Flags Definition
|
||||
* @{
|
||||
*/
|
||||
#define SPI_FLAG_RXNE SPI_SR_RXNE /* SPI status flag: Rx buffer not empty flag */
|
||||
#define SPI_FLAG_TXE SPI_SR_TXE /* SPI status flag: Tx buffer empty flag */
|
||||
#define SPI_FLAG_BSY SPI_SR_BSY /* SPI status flag: Busy flag */
|
||||
#define SPI_FLAG_MODF SPI_SR_MODF /* SPI Error flag: Mode fault flag */
|
||||
#define SPI_FLAG_OVR SPI_SR_OVR /* SPI Error flag: Overrun flag */
|
||||
#define SPI_FLAG_FTLVL SPI_SR_FTLVL /* SPI fifo transmission level */
|
||||
#define SPI_FLAG_FRLVL SPI_SR_FRLVL /* SPI fifo reception level */
|
||||
#define SPI_FLAG_MASK (SPI_SR_RXNE | SPI_SR_TXE \
|
||||
| SPI_SR_MODF | SPI_SR_OVR | SPI_SR_BSY \
|
||||
| SPI_SR_FRLVL | SPI_SR_FTLVL)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup SPI_transmission_fifo_status_level SPI Transmission FIFO Status Level
|
||||
* @{
|
||||
*/
|
||||
#define SPI_FTLVL_EMPTY (0x00000000U)
|
||||
#define SPI_FTLVL_QUARTER_FULL (0x00000800U)
|
||||
#define SPI_FTLVL_HALF_FULL (0x00001000U)
|
||||
#define SPI_FTLVL_FULL (0x00001800U)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup SPI_reception_fifo_status_level SPI Reception FIFO Status Level
|
||||
* @{
|
||||
*/
|
||||
#define SPI_FRLVL_EMPTY (0x00000000U)
|
||||
#define SPI_FRLVL_QUARTER_FULL (0x00000200U)
|
||||
#define SPI_FRLVL_HALF_FULL (0x00000400U)
|
||||
#define SPI_FRLVL_FULL (0x00000600U)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported macros -----------------------------------------------------------*/
|
||||
/** @defgroup SPI_Exported_Macros SPI Exported Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @brief Reset SPI handle state.
|
||||
* @param __HANDLE__ specifies the SPI Handle.
|
||||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
||||
* @retval None
|
||||
*/
|
||||
#if (USE_HAL_SPI_REGISTER_CALLBACKS == 1U)
|
||||
#define __HAL_SPI_RESET_HANDLE_STATE(__HANDLE__) do{ \
|
||||
(__HANDLE__)->State = HAL_SPI_STATE_RESET; \
|
||||
(__HANDLE__)->MspInitCallback = NULL; \
|
||||
(__HANDLE__)->MspDeInitCallback = NULL; \
|
||||
} while(0)
|
||||
#else
|
||||
#define __HAL_SPI_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SPI_STATE_RESET)
|
||||
#endif /* USE_HAL_SPI_REGISTER_CALLBACKS */
|
||||
|
||||
/** @brief Enable the specified SPI interrupts.
|
||||
* @param __HANDLE__ specifies the SPI Handle.
|
||||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
||||
* @param __INTERRUPT__ specifies the interrupt source to enable.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg SPI_IT_TXE: Tx buffer empty interrupt enable
|
||||
* @arg SPI_IT_RXNE: RX buffer not empty interrupt enable
|
||||
* @arg SPI_IT_ERR: Error interrupt enable
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_SPI_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BIT((__HANDLE__)->Instance->CR2, (__INTERRUPT__))
|
||||
|
||||
/** @brief Disable the specified SPI interrupts.
|
||||
* @param __HANDLE__ specifies the SPI handle.
|
||||
* This parameter can be SPIx where x: 1, 2, or 3 to select the SPI peripheral.
|
||||
* @param __INTERRUPT__ specifies the interrupt source to disable.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg SPI_IT_TXE: Tx buffer empty interrupt enable
|
||||
* @arg SPI_IT_RXNE: RX buffer not empty interrupt enable
|
||||
* @arg SPI_IT_ERR: Error interrupt enable
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_SPI_DISABLE_IT(__HANDLE__, __INTERRUPT__) CLEAR_BIT((__HANDLE__)->Instance->CR2, (__INTERRUPT__))
|
||||
|
||||
/** @brief Check whether the specified SPI interrupt source is enabled or not.
|
||||
* @param __HANDLE__ specifies the SPI Handle.
|
||||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
||||
* @param __INTERRUPT__ specifies the SPI interrupt source to check.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg SPI_IT_TXE: Tx buffer empty interrupt enable
|
||||
* @arg SPI_IT_RXNE: RX buffer not empty interrupt enable
|
||||
* @arg SPI_IT_ERR: Error interrupt enable
|
||||
* @retval The new state of __IT__ (TRUE or FALSE).
|
||||
*/
|
||||
#define __HAL_SPI_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->CR2\
|
||||
& (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
|
||||
|
||||
/** @brief Check whether the specified SPI flag is set or not.
|
||||
* @param __HANDLE__ specifies the SPI Handle.
|
||||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
||||
* @param __FLAG__ specifies the flag to check.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg SPI_FLAG_RXNE: Receive buffer not empty flag
|
||||
* @arg SPI_FLAG_TXE: Transmit buffer empty flag
|
||||
* @arg SPI_FLAG_MODF: Mode fault flag
|
||||
* @arg SPI_FLAG_OVR: Overrun flag
|
||||
* @arg SPI_FLAG_BSY: Busy flag
|
||||
* @arg SPI_FLAG_FRE: Frame format error flag
|
||||
* @arg SPI_FLAG_FTLVL: SPI fifo transmission level
|
||||
* @arg SPI_FLAG_FRLVL: SPI fifo reception level
|
||||
* @retval The new state of __FLAG__ (TRUE or FALSE).
|
||||
*/
|
||||
#define __HAL_SPI_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__))
|
||||
|
||||
/** @brief Clear the SPI MODF pending flag.
|
||||
* @param __HANDLE__ specifies the SPI Handle.
|
||||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_SPI_CLEAR_MODFFLAG(__HANDLE__) \
|
||||
do{ \
|
||||
__IO uint32_t tmpreg_modf = 0x00U; \
|
||||
tmpreg_modf = (__HANDLE__)->Instance->SR; \
|
||||
CLEAR_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_SPE); \
|
||||
UNUSED(tmpreg_modf); \
|
||||
} while(0U)
|
||||
|
||||
/** @brief Clear the SPI OVR pending flag.
|
||||
* @param __HANDLE__ specifies the SPI Handle.
|
||||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_SPI_CLEAR_OVRFLAG(__HANDLE__) \
|
||||
do{ \
|
||||
__IO uint32_t tmpreg_ovr = 0x00U; \
|
||||
tmpreg_ovr = (__HANDLE__)->Instance->DR; \
|
||||
tmpreg_ovr = (__HANDLE__)->Instance->SR; \
|
||||
UNUSED(tmpreg_ovr); \
|
||||
} while(0U)
|
||||
|
||||
/** @brief Clear the SPI FRE pending flag.
|
||||
* @param __HANDLE__ specifies the SPI Handle.
|
||||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_SPI_CLEAR_FREFLAG(__HANDLE__) \
|
||||
do{ \
|
||||
__IO uint32_t tmpreg_fre = 0x00U; \
|
||||
tmpreg_fre = (__HANDLE__)->Instance->SR; \
|
||||
UNUSED(tmpreg_fre); \
|
||||
}while(0U)
|
||||
|
||||
/** @brief Enable the SPI peripheral.
|
||||
* @param __HANDLE__ specifies the SPI Handle.
|
||||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_SPI_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_SPE)
|
||||
|
||||
/** @brief Disable the SPI peripheral.
|
||||
* @param __HANDLE__ specifies the SPI Handle.
|
||||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_SPI_DISABLE(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_SPE)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Private macros ------------------------------------------------------------*/
|
||||
/** @defgroup SPI_Private_Macros SPI Private Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @brief Set the SPI transmit-only mode.
|
||||
* @param __HANDLE__ specifies the SPI Handle.
|
||||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
||||
* @retval None
|
||||
*/
|
||||
#define SPI_1LINE_TX(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_BIDIOE)
|
||||
|
||||
/** @brief Set the SPI receive-only mode.
|
||||
* @param __HANDLE__ specifies the SPI Handle.
|
||||
* This parameter can be SPI where x: 1, 2, or 3 to select the SPI peripheral.
|
||||
* @retval None
|
||||
*/
|
||||
#define SPI_1LINE_RX(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_BIDIOE)
|
||||
|
||||
/** @brief Check whether the specified SPI flag is set or not.
|
||||
* @param __SR__ copy of SPI SR regsiter.
|
||||
* @param __FLAG__ specifies the flag to check.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg SPI_FLAG_RXNE: Receive buffer not empty flag
|
||||
* @arg SPI_FLAG_TXE: Transmit buffer empty flag
|
||||
* @arg SPI_FLAG_MODF: Mode fault flag
|
||||
* @arg SPI_FLAG_OVR: Overrun flag
|
||||
* @arg SPI_FLAG_BSY: Busy flag
|
||||
* @arg SPI_FLAG_FRE: Frame format error flag
|
||||
* @arg SPI_FLAG_FTLVL: SPI fifo transmission level
|
||||
* @arg SPI_FLAG_FRLVL: SPI fifo reception level
|
||||
* @retval SET or RESET.
|
||||
*/
|
||||
#define SPI_CHECK_FLAG(__SR__, __FLAG__) ((((__SR__) & ((__FLAG__) & SPI_FLAG_MASK)) == ((__FLAG__) & SPI_FLAG_MASK)) ? SET : RESET)
|
||||
|
||||
/** @brief Check whether the specified SPI Interrupt is set or not.
|
||||
* @param __CR2__ copy of SPI CR2 regsiter.
|
||||
* @param __INTERRUPT__ specifies the SPI interrupt source to check.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg SPI_IT_TXE: Tx buffer empty interrupt enable
|
||||
* @arg SPI_IT_RXNE: RX buffer not empty interrupt enable
|
||||
* @arg SPI_IT_ERR: Error interrupt enable
|
||||
* @retval SET or RESET.
|
||||
*/
|
||||
#define SPI_CHECK_IT_SOURCE(__CR2__, __INTERRUPT__) ((((__CR2__) & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
|
||||
|
||||
/** @brief Checks if SPI Mode parameter is in allowed range.
|
||||
* @param __MODE__ specifies the SPI Mode.
|
||||
* This parameter can be a value of @ref SPI_Mode
|
||||
* @retval None
|
||||
*/
|
||||
#define IS_SPI_MODE(__MODE__) (((__MODE__) == SPI_MODE_SLAVE) || \
|
||||
((__MODE__) == SPI_MODE_MASTER))
|
||||
|
||||
/** @brief Checks if SPI Direction Mode parameter is in allowed range.
|
||||
* @param __MODE__ specifies the SPI Direction Mode.
|
||||
* This parameter can be a value of @ref SPI_Direction
|
||||
* @retval None
|
||||
*/
|
||||
#define IS_SPI_DIRECTION(__MODE__) (((__MODE__) == SPI_DIRECTION_2LINES) || \
|
||||
((__MODE__) == SPI_DIRECTION_2LINES_RXONLY) || \
|
||||
((__MODE__) == SPI_DIRECTION_1LINE))
|
||||
|
||||
/** @brief Checks if SPI Direction Mode parameter is 2 lines.
|
||||
* @param __MODE__ specifies the SPI Direction Mode.
|
||||
* @retval None
|
||||
*/
|
||||
#define IS_SPI_DIRECTION_2LINES(__MODE__) ((__MODE__) == SPI_DIRECTION_2LINES)
|
||||
|
||||
/** @brief Checks if SPI Direction Mode parameter is 1 or 2 lines.
|
||||
* @param __MODE__ specifies the SPI Direction Mode.
|
||||
* @retval None
|
||||
*/
|
||||
#define IS_SPI_DIRECTION_2LINES_OR_1LINE(__MODE__) (((__MODE__) == SPI_DIRECTION_2LINES) || \
|
||||
((__MODE__) == SPI_DIRECTION_1LINE))
|
||||
|
||||
/** @brief Checks if SPI Data Size parameter is in allowed range.
|
||||
* @param __DATASIZE__ specifies the SPI Data Size.
|
||||
* This parameter can be a value of @ref SPI_Data_Size
|
||||
* @retval None
|
||||
*/
|
||||
#define IS_SPI_DATASIZE(__DATASIZE__) (((__DATASIZE__) == SPI_DATASIZE_16BIT) || \
|
||||
((__DATASIZE__) == SPI_DATASIZE_8BIT))
|
||||
|
||||
/** @brief Checks if SPI Serial clock steady state parameter is in allowed range.
|
||||
* @param __CPOL__ specifies the SPI serial clock steady state.
|
||||
* This parameter can be a value of @ref SPI_Clock_Polarity
|
||||
* @retval None
|
||||
*/
|
||||
#define IS_SPI_CPOL(__CPOL__) (((__CPOL__) == SPI_POLARITY_LOW) || \
|
||||
((__CPOL__) == SPI_POLARITY_HIGH))
|
||||
|
||||
/** @brief Checks if SPI Clock Phase parameter is in allowed range.
|
||||
* @param __CPHA__ specifies the SPI Clock Phase.
|
||||
* This parameter can be a value of @ref SPI_Clock_Phase
|
||||
* @retval None
|
||||
*/
|
||||
#define IS_SPI_CPHA(__CPHA__) (((__CPHA__) == SPI_PHASE_1EDGE) || \
|
||||
((__CPHA__) == SPI_PHASE_2EDGE))
|
||||
|
||||
/** @brief Checks if SPI Slave Select parameter is in allowed range.
|
||||
* @param __NSS__ specifies the SPI Slave Select management parameter.
|
||||
* This parameter can be a value of @ref SPI_Slave_Select_management
|
||||
* @retval None
|
||||
*/
|
||||
#define IS_SPI_NSS(__NSS__) (((__NSS__) == SPI_NSS_SOFT) || \
|
||||
((__NSS__) == SPI_NSS_HARD_INPUT) || \
|
||||
((__NSS__) == SPI_NSS_HARD_OUTPUT))
|
||||
|
||||
/** @brief Checks if SPI NSS Pulse parameter is in allowed range.
|
||||
* @param __NSSP__ specifies the SPI NSS Pulse Mode parameter.
|
||||
* This parameter can be a value of @ref SPI_NSSP_Mode
|
||||
* @retval None
|
||||
*/
|
||||
#define IS_SPI_NSSP(__NSSP__) (((__NSSP__) == SPI_NSS_PULSE_ENABLE) || \
|
||||
((__NSSP__) == SPI_NSS_PULSE_DISABLE))
|
||||
|
||||
/** @brief Checks if SPI Baudrate prescaler parameter is in allowed range.
|
||||
* @param __PRESCALER__ specifies the SPI Baudrate prescaler.
|
||||
* This parameter can be a value of @ref SPI_BaudRate_Prescaler
|
||||
* @retval None
|
||||
*/
|
||||
#define IS_SPI_BAUDRATE_PRESCALER(__PRESCALER__) (((__PRESCALER__) == SPI_BAUDRATEPRESCALER_2) || \
|
||||
((__PRESCALER__) == SPI_BAUDRATEPRESCALER_4) || \
|
||||
((__PRESCALER__) == SPI_BAUDRATEPRESCALER_8) || \
|
||||
((__PRESCALER__) == SPI_BAUDRATEPRESCALER_16) || \
|
||||
((__PRESCALER__) == SPI_BAUDRATEPRESCALER_32) || \
|
||||
((__PRESCALER__) == SPI_BAUDRATEPRESCALER_64) || \
|
||||
((__PRESCALER__) == SPI_BAUDRATEPRESCALER_128) || \
|
||||
((__PRESCALER__) == SPI_BAUDRATEPRESCALER_256))
|
||||
|
||||
/** @brief Checks if SPI MSB LSB transmission parameter is in allowed range.
|
||||
* @param __BIT__ specifies the SPI MSB LSB transmission (whether data transfer starts from MSB or LSB bit).
|
||||
* This parameter can be a value of @ref SPI_MSB_LSB_transmission
|
||||
* @retval None
|
||||
*/
|
||||
#define IS_SPI_FIRST_BIT(__BIT__) (((__BIT__) == SPI_FIRSTBIT_MSB) || \
|
||||
((__BIT__) == SPI_FIRSTBIT_LSB))
|
||||
|
||||
#if (defined(DMA1) || defined(DMA))
|
||||
/** @brief Checks if DMA handle is valid.
|
||||
* @param __HANDLE__ specifies a DMA Handle.
|
||||
* @retval None
|
||||
*/
|
||||
#define IS_SPI_DMA_HANDLE(__HANDLE__) ((__HANDLE__) != NULL)
|
||||
#endif /* DMA1 or DMA */
|
||||
|
||||
/** @brief Checks if a data address is 16bit aligned.
|
||||
* @param __DATA__ specifies a data address.
|
||||
* @retval None
|
||||
*/
|
||||
#define IS_SPI_16BIT_ALIGNED_ADDRESS(__DATA__) (((uint32_t)(__DATA__) % 2U) == 0U)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/** @addtogroup SPI_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup SPI_Exported_Functions_Group1
|
||||
* @{
|
||||
*/
|
||||
/* Initialization/de-initialization functions ********************************/
|
||||
HAL_StatusTypeDef HAL_SPI_Init(SPI_HandleTypeDef *hspi);
|
||||
HAL_StatusTypeDef HAL_SPI_DeInit(SPI_HandleTypeDef *hspi);
|
||||
void HAL_SPI_MspInit(SPI_HandleTypeDef *hspi);
|
||||
void HAL_SPI_MspDeInit(SPI_HandleTypeDef *hspi);
|
||||
|
||||
/* Callbacks Register/UnRegister functions ***********************************/
|
||||
#if (USE_HAL_SPI_REGISTER_CALLBACKS == 1U)
|
||||
HAL_StatusTypeDef HAL_SPI_RegisterCallback(SPI_HandleTypeDef *hspi, HAL_SPI_CallbackIDTypeDef CallbackID, pSPI_CallbackTypeDef pCallback);
|
||||
HAL_StatusTypeDef HAL_SPI_UnRegisterCallback(SPI_HandleTypeDef *hspi, HAL_SPI_CallbackIDTypeDef CallbackID);
|
||||
#endif /* USE_HAL_SPI_REGISTER_CALLBACKS */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup SPI_Exported_Functions_Group2
|
||||
* @{
|
||||
*/
|
||||
/* I/O operation functions ***************************************************/
|
||||
HAL_StatusTypeDef HAL_SPI_Transmit(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout);
|
||||
HAL_StatusTypeDef HAL_SPI_Receive(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout);
|
||||
HAL_StatusTypeDef HAL_SPI_TransmitReceive(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size,
|
||||
uint32_t Timeout);
|
||||
HAL_StatusTypeDef HAL_SPI_Transmit_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size);
|
||||
HAL_StatusTypeDef HAL_SPI_Receive_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size);
|
||||
HAL_StatusTypeDef HAL_SPI_TransmitReceive_IT(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData,
|
||||
uint16_t Size);
|
||||
#if (defined(DMA1) || defined(DMA))
|
||||
HAL_StatusTypeDef HAL_SPI_Transmit_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size);
|
||||
HAL_StatusTypeDef HAL_SPI_Receive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size);
|
||||
HAL_StatusTypeDef HAL_SPI_TransmitReceive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData,
|
||||
uint16_t Size);
|
||||
HAL_StatusTypeDef HAL_SPI_DMAPause(SPI_HandleTypeDef *hspi);
|
||||
HAL_StatusTypeDef HAL_SPI_DMAResume(SPI_HandleTypeDef *hspi);
|
||||
HAL_StatusTypeDef HAL_SPI_DMAStop(SPI_HandleTypeDef *hspi);
|
||||
#endif /* DMA1 or DMA */
|
||||
/* Transfer Abort functions */
|
||||
HAL_StatusTypeDef HAL_SPI_Abort(SPI_HandleTypeDef *hspi);
|
||||
HAL_StatusTypeDef HAL_SPI_Abort_IT(SPI_HandleTypeDef *hspi);
|
||||
|
||||
void HAL_SPI_IRQHandler(SPI_HandleTypeDef *hspi);
|
||||
void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef *hspi);
|
||||
void HAL_SPI_RxCpltCallback(SPI_HandleTypeDef *hspi);
|
||||
void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef *hspi);
|
||||
void HAL_SPI_TxHalfCpltCallback(SPI_HandleTypeDef *hspi);
|
||||
void HAL_SPI_RxHalfCpltCallback(SPI_HandleTypeDef *hspi);
|
||||
void HAL_SPI_TxRxHalfCpltCallback(SPI_HandleTypeDef *hspi);
|
||||
void HAL_SPI_ErrorCallback(SPI_HandleTypeDef *hspi);
|
||||
void HAL_SPI_AbortCpltCallback(SPI_HandleTypeDef *hspi);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup SPI_Exported_Functions_Group3
|
||||
* @{
|
||||
*/
|
||||
/* Peripheral State and Error functions ***************************************/
|
||||
HAL_SPI_StateTypeDef HAL_SPI_GetState(SPI_HandleTypeDef *hspi);
|
||||
uint32_t HAL_SPI_GetError(SPI_HandleTypeDef *hspi);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __PY32F0xx_HAL_SPI_H */
|
||||
|
||||
/************************ (C) COPYRIGHT Puya *****END OF FILE****/
|
||||
2072
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_tim.h
Normal file
2072
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_tim.h
Normal file
@@ -0,0 +1,2072 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file py32f0xx_hal_tim.h
|
||||
* @author MCU Application Team
|
||||
* @brief Header file of TIM HAL module.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) Puya Semiconductor Co.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef py32f0xx_HAL_TIM_H
|
||||
#define py32f0xx_HAL_TIM_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "py32f0xx_hal_def.h"
|
||||
|
||||
/** @addtogroup py32f0xx_HAL_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup TIM
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/** @defgroup TIM_Exported_Types TIM Exported Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief TIM Time base Configuration Structure definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t Prescaler; /*!< Specifies the prescaler value used to divide the TIM clock.
|
||||
This parameter can be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF */
|
||||
|
||||
uint32_t CounterMode; /*!< Specifies the counter mode.
|
||||
This parameter can be a value of @ref TIM_Counter_Mode */
|
||||
|
||||
uint32_t Period; /*!< Specifies the period value to be loaded into the active
|
||||
Auto-Reload Register at the next update event.
|
||||
This parameter can be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF. */
|
||||
|
||||
uint32_t ClockDivision; /*!< Specifies the clock division.
|
||||
This parameter can be a value of @ref TIM_ClockDivision */
|
||||
|
||||
uint32_t RepetitionCounter; /*!< Specifies the repetition counter value. Each time the RCR downcounter
|
||||
reaches zero, an update event is generated and counting restarts
|
||||
from the RCR value (N).
|
||||
This means in PWM mode that (N+1) corresponds to:
|
||||
- the number of PWM periods in edge-aligned mode
|
||||
- the number of half PWM period in center-aligned mode
|
||||
GP timers: this parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF.
|
||||
Advanced timers: this parameter must be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF. */
|
||||
|
||||
uint32_t AutoReloadPreload; /*!< Specifies the auto-reload preload.
|
||||
This parameter can be a value of @ref TIM_AutoReloadPreload */
|
||||
} TIM_Base_InitTypeDef;
|
||||
|
||||
/**
|
||||
* @brief TIM Output Compare Configuration Structure definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t OCMode; /*!< Specifies the TIM mode.
|
||||
This parameter can be a value of @ref TIM_Output_Compare_and_PWM_modes */
|
||||
|
||||
uint32_t Pulse; /*!< Specifies the pulse value to be loaded into the Capture Compare Register.
|
||||
This parameter can be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF */
|
||||
|
||||
uint32_t OCPolarity; /*!< Specifies the output polarity.
|
||||
This parameter can be a value of @ref TIM_Output_Compare_Polarity */
|
||||
|
||||
uint32_t OCNPolarity; /*!< Specifies the complementary output polarity.
|
||||
This parameter can be a value of @ref TIM_Output_Compare_N_Polarity
|
||||
@note This parameter is valid only for timer instances supporting break feature. */
|
||||
|
||||
uint32_t OCFastMode; /*!< Specifies the Fast mode state.
|
||||
This parameter can be a value of @ref TIM_Output_Fast_State
|
||||
@note This parameter is valid only in PWM1 and PWM2 mode. */
|
||||
|
||||
uint32_t OCIdleState; /*!< Specifies the TIM Output Compare pin state during Idle state.
|
||||
This parameter can be a value of @ref TIM_Output_Compare_Idle_State
|
||||
@note This parameter is valid only for timer instances supporting break feature. */
|
||||
|
||||
uint32_t OCNIdleState; /*!< Specifies the TIM Output Compare pin state during Idle state.
|
||||
This parameter can be a value of @ref TIM_Output_Compare_N_Idle_State
|
||||
@note This parameter is valid only for timer instances supporting break feature. */
|
||||
} TIM_OC_InitTypeDef;
|
||||
|
||||
/**
|
||||
* @brief TIM One Pulse Mode Configuration Structure definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t OCMode; /*!< Specifies the TIM mode.
|
||||
This parameter can be a value of @ref TIM_Output_Compare_and_PWM_modes */
|
||||
|
||||
uint32_t Pulse; /*!< Specifies the pulse value to be loaded into the Capture Compare Register.
|
||||
This parameter can be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF */
|
||||
|
||||
uint32_t OCPolarity; /*!< Specifies the output polarity.
|
||||
This parameter can be a value of @ref TIM_Output_Compare_Polarity */
|
||||
|
||||
uint32_t OCNPolarity; /*!< Specifies the complementary output polarity.
|
||||
This parameter can be a value of @ref TIM_Output_Compare_N_Polarity
|
||||
@note This parameter is valid only for timer instances supporting break feature. */
|
||||
|
||||
uint32_t OCIdleState; /*!< Specifies the TIM Output Compare pin state during Idle state.
|
||||
This parameter can be a value of @ref TIM_Output_Compare_Idle_State
|
||||
@note This parameter is valid only for timer instances supporting break feature. */
|
||||
|
||||
uint32_t OCNIdleState; /*!< Specifies the TIM Output Compare pin state during Idle state.
|
||||
This parameter can be a value of @ref TIM_Output_Compare_N_Idle_State
|
||||
@note This parameter is valid only for timer instances supporting break feature. */
|
||||
|
||||
uint32_t ICPolarity; /*!< Specifies the active edge of the input signal.
|
||||
This parameter can be a value of @ref TIM_Input_Capture_Polarity */
|
||||
|
||||
uint32_t ICSelection; /*!< Specifies the input.
|
||||
This parameter can be a value of @ref TIM_Input_Capture_Selection */
|
||||
|
||||
uint32_t ICFilter; /*!< Specifies the input capture filter.
|
||||
This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */
|
||||
} TIM_OnePulse_InitTypeDef;
|
||||
|
||||
/**
|
||||
* @brief TIM Input Capture Configuration Structure definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t ICPolarity; /*!< Specifies the active edge of the input signal.
|
||||
This parameter can be a value of @ref TIM_Input_Capture_Polarity */
|
||||
|
||||
uint32_t ICSelection; /*!< Specifies the input.
|
||||
This parameter can be a value of @ref TIM_Input_Capture_Selection */
|
||||
|
||||
uint32_t ICPrescaler; /*!< Specifies the Input Capture Prescaler.
|
||||
This parameter can be a value of @ref TIM_Input_Capture_Prescaler */
|
||||
|
||||
uint32_t ICFilter; /*!< Specifies the input capture filter.
|
||||
This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */
|
||||
} TIM_IC_InitTypeDef;
|
||||
|
||||
/**
|
||||
* @brief TIM Encoder Configuration Structure definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t EncoderMode; /*!< Specifies the active edge of the input signal.
|
||||
This parameter can be a value of @ref TIM_Encoder_Mode */
|
||||
|
||||
uint32_t IC1Polarity; /*!< Specifies the active edge of the input signal.
|
||||
This parameter can be a value of @ref TIM_Encoder_Input_Polarity */
|
||||
|
||||
uint32_t IC1Selection; /*!< Specifies the input.
|
||||
This parameter can be a value of @ref TIM_Input_Capture_Selection */
|
||||
|
||||
uint32_t IC1Prescaler; /*!< Specifies the Input Capture Prescaler.
|
||||
This parameter can be a value of @ref TIM_Input_Capture_Prescaler */
|
||||
|
||||
uint32_t IC1Filter; /*!< Specifies the input capture filter.
|
||||
This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */
|
||||
|
||||
uint32_t IC2Polarity; /*!< Specifies the active edge of the input signal.
|
||||
This parameter can be a value of @ref TIM_Encoder_Input_Polarity */
|
||||
|
||||
uint32_t IC2Selection; /*!< Specifies the input.
|
||||
This parameter can be a value of @ref TIM_Input_Capture_Selection */
|
||||
|
||||
uint32_t IC2Prescaler; /*!< Specifies the Input Capture Prescaler.
|
||||
This parameter can be a value of @ref TIM_Input_Capture_Prescaler */
|
||||
|
||||
uint32_t IC2Filter; /*!< Specifies the input capture filter.
|
||||
This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */
|
||||
} TIM_Encoder_InitTypeDef;
|
||||
|
||||
/**
|
||||
* @brief Clock Configuration Handle Structure definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t ClockSource; /*!< TIM clock sources
|
||||
This parameter can be a value of @ref TIM_Clock_Source */
|
||||
uint32_t ClockPolarity; /*!< TIM clock polarity
|
||||
This parameter can be a value of @ref TIM_Clock_Polarity */
|
||||
uint32_t ClockPrescaler; /*!< TIM clock prescaler
|
||||
This parameter can be a value of @ref TIM_Clock_Prescaler */
|
||||
uint32_t ClockFilter; /*!< TIM clock filter
|
||||
This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */
|
||||
} TIM_ClockConfigTypeDef;
|
||||
|
||||
/**
|
||||
* @brief TIM Clear Input Configuration Handle Structure definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t ClearInputState; /*!< TIM clear Input state
|
||||
This parameter can be ENABLE or DISABLE */
|
||||
uint32_t ClearInputSource; /*!< TIM clear Input sources
|
||||
This parameter can be a value of @ref TIM_ClearInput_Source */
|
||||
uint32_t ClearInputPolarity; /*!< TIM Clear Input polarity
|
||||
This parameter can be a value of @ref TIM_ClearInput_Polarity */
|
||||
uint32_t ClearInputPrescaler; /*!< TIM Clear Input prescaler
|
||||
This parameter must be 0: When OCRef clear feature is used with ETR source, ETR prescaler must be off */
|
||||
uint32_t ClearInputFilter; /*!< TIM Clear Input filter
|
||||
This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */
|
||||
} TIM_ClearInputConfigTypeDef;
|
||||
|
||||
/**
|
||||
* @brief TIM Master configuration Structure definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t MasterOutputTrigger; /*!< Trigger output (TRGO) selection
|
||||
This parameter can be a value of @ref TIM_Master_Mode_Selection */
|
||||
uint32_t MasterSlaveMode; /*!< Master/slave mode selection
|
||||
This parameter can be a value of @ref TIM_Master_Slave_Mode
|
||||
@note When the Master/slave mode is enabled, the effect of
|
||||
an event on the trigger input (TRGI) is delayed to allow a
|
||||
perfect synchronization between the current timer and its
|
||||
slaves (through TRGO). It is not mandatory in case of timer
|
||||
synchronization mode. */
|
||||
} TIM_MasterConfigTypeDef;
|
||||
|
||||
/**
|
||||
* @brief TIM Slave configuration Structure definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t SlaveMode; /*!< Slave mode selection
|
||||
This parameter can be a value of @ref TIM_Slave_Mode */
|
||||
uint32_t InputTrigger; /*!< Input Trigger source
|
||||
This parameter can be a value of @ref TIM_Trigger_Selection */
|
||||
uint32_t TriggerPolarity; /*!< Input Trigger polarity
|
||||
This parameter can be a value of @ref TIM_Trigger_Polarity */
|
||||
uint32_t TriggerPrescaler; /*!< Input trigger prescaler
|
||||
This parameter can be a value of @ref TIM_Trigger_Prescaler */
|
||||
uint32_t TriggerFilter; /*!< Input trigger filter
|
||||
This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */
|
||||
|
||||
} TIM_SlaveConfigTypeDef;
|
||||
|
||||
/**
|
||||
* @brief TIM Break input(s) and Dead time configuration Structure definition
|
||||
* @note 2 break inputs can be configured (BKIN and BKIN2) with configurable
|
||||
* filter and polarity.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t OffStateRunMode; /*!< TIM off state in run mode
|
||||
This parameter can be a value of @ref TIM_OSSR_Off_State_Selection_for_Run_mode_state */
|
||||
uint32_t OffStateIDLEMode; /*!< TIM off state in IDLE mode
|
||||
This parameter can be a value of @ref TIM_OSSI_Off_State_Selection_for_Idle_mode_state */
|
||||
uint32_t LockLevel; /*!< TIM Lock level
|
||||
This parameter can be a value of @ref TIM_Lock_level */
|
||||
uint32_t DeadTime; /*!< TIM dead Time
|
||||
This parameter can be a number between Min_Data = 0x00 and Max_Data = 0xFF */
|
||||
uint32_t BreakState; /*!< TIM Break State
|
||||
This parameter can be a value of @ref TIM_Break_Input_enable_disable */
|
||||
uint32_t BreakPolarity; /*!< TIM Break input polarity
|
||||
This parameter can be a value of @ref TIM_Break_Polarity */
|
||||
uint32_t BreakFilter; /*!< Specifies the break input filter.
|
||||
This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */
|
||||
uint32_t AutomaticOutput; /*!< TIM Automatic Output Enable state
|
||||
This parameter can be a value of @ref TIM_AOE_Bit_Set_Reset */
|
||||
} TIM_BreakDeadTimeConfigTypeDef;
|
||||
|
||||
/**
|
||||
* @brief HAL State structures definition
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
HAL_TIM_STATE_RESET = 0x00U, /*!< Peripheral not yet initialized or disabled */
|
||||
HAL_TIM_STATE_READY = 0x01U, /*!< Peripheral Initialized and ready for use */
|
||||
HAL_TIM_STATE_BUSY = 0x02U, /*!< An internal process is ongoing */
|
||||
HAL_TIM_STATE_TIMEOUT = 0x03U, /*!< Timeout state */
|
||||
HAL_TIM_STATE_ERROR = 0x04U /*!< Reception process is ongoing */
|
||||
} HAL_TIM_StateTypeDef;
|
||||
|
||||
/**
|
||||
* @brief HAL Active channel structures definition
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
HAL_TIM_ACTIVE_CHANNEL_1 = 0x01U, /*!< The active channel is 1 */
|
||||
HAL_TIM_ACTIVE_CHANNEL_2 = 0x02U, /*!< The active channel is 2 */
|
||||
HAL_TIM_ACTIVE_CHANNEL_3 = 0x04U, /*!< The active channel is 3 */
|
||||
HAL_TIM_ACTIVE_CHANNEL_4 = 0x08U, /*!< The active channel is 4 */
|
||||
HAL_TIM_ACTIVE_CHANNEL_CLEARED = 0x00U /*!< All active channels cleared */
|
||||
} HAL_TIM_ActiveChannel;
|
||||
|
||||
/**
|
||||
* @brief TIM Time Base Handle Structure definition
|
||||
*/
|
||||
#if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
|
||||
typedef struct __TIM_HandleTypeDef
|
||||
#else
|
||||
typedef struct
|
||||
#endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
|
||||
{
|
||||
TIM_TypeDef *Instance; /*!< Register base address */
|
||||
TIM_Base_InitTypeDef Init; /*!< TIM Time Base required parameters */
|
||||
HAL_TIM_ActiveChannel Channel; /*!< Active channel */
|
||||
#if (defined(DMA) || defined(DMA1))
|
||||
DMA_HandleTypeDef *hdma[7]; /*!< DMA Handlers array
|
||||
This array is accessed by a @ref DMA_Handle_index */
|
||||
#endif
|
||||
HAL_LockTypeDef Lock; /*!< Locking object */
|
||||
__IO HAL_TIM_StateTypeDef State; /*!< TIM operation state */
|
||||
|
||||
#if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
|
||||
void (* Base_MspInitCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM Base Msp Init Callback */
|
||||
void (* Base_MspDeInitCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM Base Msp DeInit Callback */
|
||||
void (* IC_MspInitCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM IC Msp Init Callback */
|
||||
void (* IC_MspDeInitCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM IC Msp DeInit Callback */
|
||||
void (* OC_MspInitCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM OC Msp Init Callback */
|
||||
void (* OC_MspDeInitCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM OC Msp DeInit Callback */
|
||||
void (* PWM_MspInitCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM PWM Msp Init Callback */
|
||||
void (* PWM_MspDeInitCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM PWM Msp DeInit Callback */
|
||||
void (* OnePulse_MspInitCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM One Pulse Msp Init Callback */
|
||||
void (* OnePulse_MspDeInitCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM One Pulse Msp DeInit Callback */
|
||||
void (* Encoder_MspInitCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM Encoder Msp Init Callback */
|
||||
void (* Encoder_MspDeInitCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM Encoder Msp DeInit Callback */
|
||||
void (* HallSensor_MspInitCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM Hall Sensor Msp Init Callback */
|
||||
void (* HallSensor_MspDeInitCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM Hall Sensor Msp DeInit Callback */
|
||||
void (* PeriodElapsedCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM Period Elapsed Callback */
|
||||
void (* PeriodElapsedHalfCpltCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM Period Elapsed half complete Callback */
|
||||
void (* TriggerCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM Trigger Callback */
|
||||
void (* TriggerHalfCpltCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM Trigger half complete Callback */
|
||||
void (* IC_CaptureCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM Input Capture Callback */
|
||||
void (* IC_CaptureHalfCpltCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM Input Capture half complete Callback */
|
||||
void (* OC_DelayElapsedCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM Output Compare Delay Elapsed Callback */
|
||||
void (* PWM_PulseFinishedCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM PWM Pulse Finished Callback */
|
||||
void (* PWM_PulseFinishedHalfCpltCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM PWM Pulse Finished half complete Callback */
|
||||
void (* ErrorCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM Error Callback */
|
||||
void (* CommutationCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM Commutation Callback */
|
||||
void (* CommutationHalfCpltCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM Commutation half complete Callback */
|
||||
void (* BreakCallback)(struct __TIM_HandleTypeDef *htim); /*!< TIM Break Callback */
|
||||
#endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
|
||||
} TIM_HandleTypeDef;
|
||||
|
||||
#if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
|
||||
/**
|
||||
* @brief HAL TIM Callback ID enumeration definition
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
HAL_TIM_BASE_MSPINIT_CB_ID = 0x00U /*!< TIM Base MspInit Callback ID */
|
||||
,HAL_TIM_BASE_MSPDEINIT_CB_ID = 0x01U /*!< TIM Base MspDeInit Callback ID */
|
||||
,HAL_TIM_IC_MSPINIT_CB_ID = 0x02U /*!< TIM IC MspInit Callback ID */
|
||||
,HAL_TIM_IC_MSPDEINIT_CB_ID = 0x03U /*!< TIM IC MspDeInit Callback ID */
|
||||
,HAL_TIM_OC_MSPINIT_CB_ID = 0x04U /*!< TIM OC MspInit Callback ID */
|
||||
,HAL_TIM_OC_MSPDEINIT_CB_ID = 0x05U /*!< TIM OC MspDeInit Callback ID */
|
||||
,HAL_TIM_PWM_MSPINIT_CB_ID = 0x06U /*!< TIM PWM MspInit Callback ID */
|
||||
,HAL_TIM_PWM_MSPDEINIT_CB_ID = 0x07U /*!< TIM PWM MspDeInit Callback ID */
|
||||
,HAL_TIM_ONE_PULSE_MSPINIT_CB_ID = 0x08U /*!< TIM One Pulse MspInit Callback ID */
|
||||
,HAL_TIM_ONE_PULSE_MSPDEINIT_CB_ID = 0x09U /*!< TIM One Pulse MspDeInit Callback ID */
|
||||
,HAL_TIM_ENCODER_MSPINIT_CB_ID = 0x0AU /*!< TIM Encoder MspInit Callback ID */
|
||||
,HAL_TIM_ENCODER_MSPDEINIT_CB_ID = 0x0BU /*!< TIM Encoder MspDeInit Callback ID */
|
||||
,HAL_TIM_HALL_SENSOR_MSPINIT_CB_ID = 0x0CU /*!< TIM Hall Sensor MspDeInit Callback ID */
|
||||
,HAL_TIM_HALL_SENSOR_MSPDEINIT_CB_ID = 0x0DU /*!< TIM Hall Sensor MspDeInit Callback ID */
|
||||
,HAL_TIM_PERIOD_ELAPSED_CB_ID = 0x0EU /*!< TIM Period Elapsed Callback ID */
|
||||
,HAL_TIM_PERIOD_ELAPSED_HALF_CB_ID = 0x0FU /*!< TIM Period Elapsed half complete Callback ID */
|
||||
,HAL_TIM_TRIGGER_CB_ID = 0x10U /*!< TIM Trigger Callback ID */
|
||||
,HAL_TIM_TRIGGER_HALF_CB_ID = 0x11U /*!< TIM Trigger half complete Callback ID */
|
||||
|
||||
,HAL_TIM_IC_CAPTURE_CB_ID = 0x12U /*!< TIM Input Capture Callback ID */
|
||||
,HAL_TIM_IC_CAPTURE_HALF_CB_ID = 0x13U /*!< TIM Input Capture half complete Callback ID */
|
||||
,HAL_TIM_OC_DELAY_ELAPSED_CB_ID = 0x14U /*!< TIM Output Compare Delay Elapsed Callback ID */
|
||||
,HAL_TIM_PWM_PULSE_FINISHED_CB_ID = 0x15U /*!< TIM PWM Pulse Finished Callback ID */
|
||||
,HAL_TIM_PWM_PULSE_FINISHED_HALF_CB_ID = 0x16U /*!< TIM PWM Pulse Finished half complete Callback ID */
|
||||
,HAL_TIM_ERROR_CB_ID = 0x17U /*!< TIM Error Callback ID */
|
||||
,HAL_TIM_COMMUTATION_CB_ID = 0x18U /*!< TIM Commutation Callback ID */
|
||||
,HAL_TIM_COMMUTATION_HALF_CB_ID = 0x19U /*!< TIM Commutation half complete Callback ID */
|
||||
,HAL_TIM_BREAK_CB_ID = 0x1AU /*!< TIM Break Callback ID */
|
||||
} HAL_TIM_CallbackIDTypeDef;
|
||||
|
||||
/**
|
||||
* @brief HAL TIM Callback pointer definition
|
||||
*/
|
||||
typedef void (*pTIM_CallbackTypeDef)(TIM_HandleTypeDef *htim); /*!< pointer to the TIM callback function */
|
||||
|
||||
#endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/* End of exported types -----------------------------------------------------*/
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/** @defgroup TIM_Exported_Constants TIM Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup TIM_ClearInput_Source TIM Clear Input Source
|
||||
* @{
|
||||
*/
|
||||
#define TIM_CLEARINPUTSOURCE_NONE 0x00000000U /*!< OCREF_CLR is disabled */
|
||||
#define TIM_CLEARINPUTSOURCE_ETR 0x00000001U /*!< OCREF_CLR is connected to ETRF input */
|
||||
#define TIM_CLEARINPUTSOURCE_OCREFCLR 0x00000002U /*!< OCREF_CLR is connected to OCREF_CLR_INT */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#if (defined(DMA) || defined(DMA1))
|
||||
/** @defgroup TIM_DMA_Base_address TIM DMA Base Address
|
||||
* @{
|
||||
*/
|
||||
#define TIM_DMABASE_CR1 0x00000000U
|
||||
#define TIM_DMABASE_CR2 0x00000001U
|
||||
#define TIM_DMABASE_SMCR 0x00000002U
|
||||
#define TIM_DMABASE_DIER 0x00000003U
|
||||
#define TIM_DMABASE_SR 0x00000004U
|
||||
#define TIM_DMABASE_EGR 0x00000005U
|
||||
#define TIM_DMABASE_CCMR1 0x00000006U
|
||||
#define TIM_DMABASE_CCMR2 0x00000007U
|
||||
#define TIM_DMABASE_CCER 0x00000008U
|
||||
#define TIM_DMABASE_CNT 0x00000009U
|
||||
#define TIM_DMABASE_PSC 0x0000000AU
|
||||
#define TIM_DMABASE_ARR 0x0000000BU
|
||||
#define TIM_DMABASE_RCR 0x0000000CU
|
||||
#define TIM_DMABASE_CCR1 0x0000000DU
|
||||
#define TIM_DMABASE_CCR2 0x0000000EU
|
||||
#define TIM_DMABASE_CCR3 0x0000000FU
|
||||
#define TIM_DMABASE_CCR4 0x00000010U
|
||||
#define TIM_DMABASE_BDTR 0x00000011U
|
||||
#define TIM_DMABASE_DCR 0x00000012U
|
||||
#define TIM_DMABASE_DMAR 0x00000013U
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif
|
||||
|
||||
/** @defgroup TIM_Event_Source TIM Event Source
|
||||
* @{
|
||||
*/
|
||||
#define TIM_EVENTSOURCE_UPDATE TIM_EGR_UG /*!< Reinitialize the counter and generates an update of the registers */
|
||||
#define TIM_EVENTSOURCE_CC1 TIM_EGR_CC1G /*!< A capture/compare event is generated on channel 1 */
|
||||
#define TIM_EVENTSOURCE_CC2 TIM_EGR_CC2G /*!< A capture/compare event is generated on channel 2 */
|
||||
#define TIM_EVENTSOURCE_CC3 TIM_EGR_CC3G /*!< A capture/compare event is generated on channel 3 */
|
||||
#define TIM_EVENTSOURCE_CC4 TIM_EGR_CC4G /*!< A capture/compare event is generated on channel 4 */
|
||||
#define TIM_EVENTSOURCE_COM TIM_EGR_COMG /*!< A commutation event is generated */
|
||||
#define TIM_EVENTSOURCE_TRIGGER TIM_EGR_TG /*!< A trigger event is generated */
|
||||
#define TIM_EVENTSOURCE_BREAK TIM_EGR_BG /*!< A break event is generated */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup TIM_Input_Channel_Polarity TIM Input Channel polarity
|
||||
* @{
|
||||
*/
|
||||
#define TIM_INPUTCHANNELPOLARITY_RISING 0x00000000U /*!< Polarity for TIx source */
|
||||
#define TIM_INPUTCHANNELPOLARITY_FALLING TIM_CCER_CC1P /*!< Polarity for TIx source */
|
||||
#define TIM_INPUTCHANNELPOLARITY_BOTHEDGE (TIM_CCER_CC1P | TIM_CCER_CC1NP) /*!< Polarity for TIx source */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup TIM_ETR_Polarity TIM ETR Polarity
|
||||
* @{
|
||||
*/
|
||||
#define TIM_ETRPOLARITY_INVERTED TIM_SMCR_ETP /*!< Polarity for ETR source */
|
||||
#define TIM_ETRPOLARITY_NONINVERTED 0x00000000U /*!< Polarity for ETR source */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup TIM_ETR_Prescaler TIM ETR Prescaler
|
||||
* @{
|
||||
*/
|
||||
#define TIM_ETRPRESCALER_DIV1 0x00000000U /*!< No prescaler is used */
|
||||
#define TIM_ETRPRESCALER_DIV2 TIM_SMCR_ETPS_0 /*!< ETR input source is divided by 2 */
|
||||
#define TIM_ETRPRESCALER_DIV4 TIM_SMCR_ETPS_1 /*!< ETR input source is divided by 4 */
|
||||
#define TIM_ETRPRESCALER_DIV8 TIM_SMCR_ETPS /*!< ETR input source is divided by 8 */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup TIM_Counter_Mode TIM Counter Mode
|
||||
* @{
|
||||
*/
|
||||
#define TIM_COUNTERMODE_UP 0x00000000U /*!< Counter used as up-counter */
|
||||
#define TIM_COUNTERMODE_DOWN TIM_CR1_DIR /*!< Counter used as down-counter */
|
||||
#define TIM_COUNTERMODE_CENTERALIGNED1 TIM_CR1_CMS_0 /*!< Center-aligned mode 1 */
|
||||
#define TIM_COUNTERMODE_CENTERALIGNED2 TIM_CR1_CMS_1 /*!< Center-aligned mode 2 */
|
||||
#define TIM_COUNTERMODE_CENTERALIGNED3 TIM_CR1_CMS /*!< Center-aligned mode 3 */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup TIM_ClockDivision TIM Clock Division
|
||||
* @{
|
||||
*/
|
||||
#define TIM_CLOCKDIVISION_DIV1 0x00000000U /*!< Clock division: tDTS=tCK_INT */
|
||||
#define TIM_CLOCKDIVISION_DIV2 TIM_CR1_CKD_0 /*!< Clock division: tDTS=2*tCK_INT */
|
||||
#define TIM_CLOCKDIVISION_DIV4 TIM_CR1_CKD_1 /*!< Clock division: tDTS=4*tCK_INT */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup TIM_Output_Compare_State TIM Output Compare State
|
||||
* @{
|
||||
*/
|
||||
#define TIM_OUTPUTSTATE_DISABLE 0x00000000U /*!< Capture/Compare 1 output disabled */
|
||||
#define TIM_OUTPUTSTATE_ENABLE TIM_CCER_CC1E /*!< Capture/Compare 1 output enabled */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup TIM_AutoReloadPreload TIM Auto-Reload Preload
|
||||
* @{
|
||||
*/
|
||||
#define TIM_AUTORELOAD_PRELOAD_DISABLE 0x00000000U /*!< TIMx_ARR register is not buffered */
|
||||
#define TIM_AUTORELOAD_PRELOAD_ENABLE TIM_CR1_ARPE /*!< TIMx_ARR register is buffered */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup TIM_Output_Fast_State TIM Output Fast State
|
||||
* @{
|
||||
*/
|
||||
#define TIM_OCFAST_DISABLE 0x00000000U /*!< Output Compare fast disable */
|
||||
#define TIM_OCFAST_ENABLE TIM_CCMR1_OC1FE /*!< Output Compare fast enable */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup TIM_Output_Compare_N_State TIM Complementary Output Compare State
|
||||
* @{
|
||||
*/
|
||||
#define TIM_OUTPUTNSTATE_DISABLE 0x00000000U /*!< OCxN is disabled */
|
||||
#define TIM_OUTPUTNSTATE_ENABLE TIM_CCER_CC1NE /*!< OCxN is enabled */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup TIM_Output_Compare_Polarity TIM Output Compare Polarity
|
||||
* @{
|
||||
*/
|
||||
#define TIM_OCPOLARITY_HIGH 0x00000000U /*!< Capture/Compare output polarity */
|
||||
#define TIM_OCPOLARITY_LOW TIM_CCER_CC1P /*!< Capture/Compare output polarity */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup TIM_Output_Compare_N_Polarity TIM Complementary Output Compare Polarity
|
||||
* @{
|
||||
*/
|
||||
#define TIM_OCNPOLARITY_HIGH 0x00000000U /*!< Capture/Compare complementary output polarity */
|
||||
#define TIM_OCNPOLARITY_LOW TIM_CCER_CC1NP /*!< Capture/Compare complementary output polarity */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup TIM_Output_Compare_Idle_State TIM Output Compare Idle State
|
||||
* @{
|
||||
*/
|
||||
#define TIM_OCIDLESTATE_SET TIM_CR2_OIS1 /*!< Output Idle state: OCx=1 when MOE=0 */
|
||||
#define TIM_OCIDLESTATE_RESET 0x00000000U /*!< Output Idle state: OCx=0 when MOE=0 */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup TIM_Output_Compare_N_Idle_State TIM Complementary Output Compare Idle State
|
||||
* @{
|
||||
*/
|
||||
#define TIM_OCNIDLESTATE_SET TIM_CR2_OIS1N /*!< Complementary output Idle state: OCxN=1 when MOE=0 */
|
||||
#define TIM_OCNIDLESTATE_RESET 0x00000000U /*!< Complementary output Idle state: OCxN=0 when MOE=0 */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup TIM_Input_Capture_Polarity TIM Input Capture Polarity
|
||||
* @{
|
||||
*/
|
||||
#define TIM_ICPOLARITY_RISING TIM_INPUTCHANNELPOLARITY_RISING /*!< Capture triggered by rising edge on timer input */
|
||||
#define TIM_ICPOLARITY_FALLING TIM_INPUTCHANNELPOLARITY_FALLING /*!< Capture triggered by falling edge on timer input */
|
||||
#define TIM_ICPOLARITY_BOTHEDGE TIM_INPUTCHANNELPOLARITY_BOTHEDGE /*!< Capture triggered by both rising and falling edges on timer input*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup TIM_Encoder_Input_Polarity TIM Encoder Input Polarity
|
||||
* @{
|
||||
*/
|
||||
#define TIM_ENCODERINPUTPOLARITY_RISING TIM_INPUTCHANNELPOLARITY_RISING /*!< Encoder input with rising edge polarity */
|
||||
#define TIM_ENCODERINPUTPOLARITY_FALLING TIM_INPUTCHANNELPOLARITY_FALLING /*!< Encoder input with falling edge polarity */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup TIM_Input_Capture_Selection TIM Input Capture Selection
|
||||
* @{
|
||||
*/
|
||||
#define TIM_ICSELECTION_DIRECTTI TIM_CCMR1_CC1S_0 /*!< TIM Input 1, 2, 3 or 4 is selected to be
|
||||
connected to IC1, IC2, IC3 or IC4, respectively */
|
||||
#define TIM_ICSELECTION_INDIRECTTI TIM_CCMR1_CC1S_1 /*!< TIM Input 1, 2, 3 or 4 is selected to be
|
||||
connected to IC2, IC1, IC4 or IC3, respectively */
|
||||
#define TIM_ICSELECTION_TRC TIM_CCMR1_CC1S /*!< TIM Input 1, 2, 3 or 4 is selected to be connected to TRC */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup TIM_Input_Capture_Prescaler TIM Input Capture Prescaler
|
||||
* @{
|
||||
*/
|
||||
#define TIM_ICPSC_DIV1 0x00000000U /*!< Capture performed each time an edge is detected on the capture input */
|
||||
#define TIM_ICPSC_DIV2 TIM_CCMR1_IC1PSC_0 /*!< Capture performed once every 2 events */
|
||||
#define TIM_ICPSC_DIV4 TIM_CCMR1_IC1PSC_1 /*!< Capture performed once every 4 events */
|
||||
#define TIM_ICPSC_DIV8 TIM_CCMR1_IC1PSC /*!< Capture performed once every 8 events */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup TIM_One_Pulse_Mode TIM One Pulse Mode
|
||||
* @{
|
||||
*/
|
||||
#define TIM_OPMODE_SINGLE TIM_CR1_OPM /*!< Counter stops counting at the next update event */
|
||||
#define TIM_OPMODE_REPETITIVE 0x00000000U /*!< Counter is not stopped at update event */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup TIM_Encoder_Mode TIM Encoder Mode
|
||||
* @{
|
||||
*/
|
||||
#define TIM_ENCODERMODE_TI1 TIM_SMCR_SMS_0 /*!< Quadrature encoder mode 1, x2 mode, counts up/down on TI1FP1 edge depending on TI2FP2 level */
|
||||
#define TIM_ENCODERMODE_TI2 TIM_SMCR_SMS_1 /*!< Quadrature encoder mode 2, x2 mode, counts up/down on TI2FP2 edge depending on TI1FP1 level. */
|
||||
#define TIM_ENCODERMODE_TI12 (TIM_SMCR_SMS_1 | TIM_SMCR_SMS_0) /*!< Quadrature encoder mode 3, x4 mode, counts up/down on both TI1FP1 and TI2FP2 edges depending on the level of the other input. */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup TIM_Interrupt_definition TIM interrupt Definition
|
||||
* @{
|
||||
*/
|
||||
#define TIM_IT_UPDATE TIM_DIER_UIE /*!< Update interrupt */
|
||||
#define TIM_IT_CC1 TIM_DIER_CC1IE /*!< Capture/Compare 1 interrupt */
|
||||
#define TIM_IT_CC2 TIM_DIER_CC2IE /*!< Capture/Compare 2 interrupt */
|
||||
#define TIM_IT_CC3 TIM_DIER_CC3IE /*!< Capture/Compare 3 interrupt */
|
||||
#define TIM_IT_CC4 TIM_DIER_CC4IE /*!< Capture/Compare 4 interrupt */
|
||||
#define TIM_IT_COM TIM_DIER_COMIE /*!< Commutation interrupt */
|
||||
#define TIM_IT_TRIGGER TIM_DIER_TIE /*!< Trigger interrupt */
|
||||
#define TIM_IT_BREAK TIM_DIER_BIE /*!< Break interrupt */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup TIM_Commutation_Source TIM Commutation Source
|
||||
* @{
|
||||
*/
|
||||
#define TIM_COMMUTATION_TRGI TIM_CR2_CCUS /*!< When Capture/compare control bits are preloaded, they are updated by setting the COMG bit or when an rising edge occurs on trigger input */
|
||||
#define TIM_COMMUTATION_SOFTWARE 0x00000000U /*!< When Capture/compare control bits are preloaded, they are updated by setting the COMG bit */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#if (defined(DMA) || defined(DMA1))
|
||||
/** @defgroup TIM_DMA_sources TIM DMA Sources
|
||||
* @{
|
||||
*/
|
||||
#define TIM_DMA_UPDATE TIM_DIER_UDE /*!< DMA request is triggered by the update event */
|
||||
#define TIM_DMA_CC1 TIM_DIER_CC1DE /*!< DMA request is triggered by the capture/compare macth 1 event */
|
||||
#define TIM_DMA_CC2 TIM_DIER_CC2DE /*!< DMA request is triggered by the capture/compare macth 2 event */
|
||||
#define TIM_DMA_CC3 TIM_DIER_CC3DE /*!< DMA request is triggered by the capture/compare macth 3 event */
|
||||
#define TIM_DMA_CC4 TIM_DIER_CC4DE /*!< DMA request is triggered by the capture/compare macth 4 event */
|
||||
#define TIM_DMA_COM TIM_DIER_COMDE /*!< DMA request is triggered by the commutation event */
|
||||
#define TIM_DMA_TRIGGER TIM_DIER_TDE /*!< DMA request is triggered by the trigger event */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif
|
||||
|
||||
/** @defgroup TIM_Flag_definition TIM Flag Definition
|
||||
* @{
|
||||
*/
|
||||
#define TIM_FLAG_UPDATE TIM_SR_UIF /*!< Update interrupt flag */
|
||||
#define TIM_FLAG_CC1 TIM_SR_CC1IF /*!< Capture/Compare 1 interrupt flag */
|
||||
#define TIM_FLAG_CC2 TIM_SR_CC2IF /*!< Capture/Compare 2 interrupt flag */
|
||||
#define TIM_FLAG_CC3 TIM_SR_CC3IF /*!< Capture/Compare 3 interrupt flag */
|
||||
#define TIM_FLAG_CC4 TIM_SR_CC4IF /*!< Capture/Compare 4 interrupt flag */
|
||||
#define TIM_FLAG_COM TIM_SR_COMIF /*!< Commutation interrupt flag */
|
||||
#define TIM_FLAG_TRIGGER TIM_SR_TIF /*!< Trigger interrupt flag */
|
||||
#define TIM_FLAG_BREAK TIM_SR_BIF /*!< Break interrupt flag */
|
||||
#define TIM_FLAG_CC1OF TIM_SR_CC1OF /*!< Capture 1 overcapture flag */
|
||||
#define TIM_FLAG_CC2OF TIM_SR_CC2OF /*!< Capture 2 overcapture flag */
|
||||
#define TIM_FLAG_CC3OF TIM_SR_CC3OF /*!< Capture 3 overcapture flag */
|
||||
#define TIM_FLAG_CC4OF TIM_SR_CC4OF /*!< Capture 4 overcapture flag */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup TIM_Channel TIM Channel
|
||||
* @{
|
||||
*/
|
||||
#define TIM_CHANNEL_1 0x00000000U /*!< Capture/compare channel 1 identifier */
|
||||
#define TIM_CHANNEL_2 0x00000004U /*!< Capture/compare channel 2 identifier */
|
||||
#define TIM_CHANNEL_3 0x00000008U /*!< Capture/compare channel 3 identifier */
|
||||
#define TIM_CHANNEL_4 0x0000000CU /*!< Capture/compare channel 4 identifier */
|
||||
#define TIM_CHANNEL_ALL 0x0000003CU /*!< Global Capture/compare channel identifier */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup TIM_Clock_Source TIM Clock Source
|
||||
* @{
|
||||
*/
|
||||
#define TIM_CLOCKSOURCE_ETRMODE2 TIM_SMCR_ETPS_1 /*!< External clock source mode 2 */
|
||||
#define TIM_CLOCKSOURCE_INTERNAL TIM_SMCR_ETPS_0 /*!< Internal clock source */
|
||||
#define TIM_CLOCKSOURCE_ITR0 TIM_TS_ITR0 /*!< External clock source mode 1 (ITR0) */
|
||||
#define TIM_CLOCKSOURCE_ITR1 TIM_TS_ITR1 /*!< External clock source mode 1 (ITR1) */
|
||||
#define TIM_CLOCKSOURCE_ITR2 TIM_TS_ITR2 /*!< External clock source mode 1 (ITR2) */
|
||||
#define TIM_CLOCKSOURCE_ITR3 TIM_TS_ITR3 /*!< External clock source mode 1 (ITR3) */
|
||||
#define TIM_CLOCKSOURCE_TI1ED TIM_TS_TI1F_ED /*!< External clock source mode 1 (TTI1FP1 + edge detect.) */
|
||||
#define TIM_CLOCKSOURCE_TI1 TIM_TS_TI1FP1 /*!< External clock source mode 1 (TTI1FP1) */
|
||||
#define TIM_CLOCKSOURCE_TI2 TIM_TS_TI2FP2 /*!< External clock source mode 1 (TTI2FP2) */
|
||||
#define TIM_CLOCKSOURCE_ETRMODE1 TIM_TS_ETRF /*!< External clock source mode 1 (ETRF) */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup TIM_Clock_Polarity TIM Clock Polarity
|
||||
* @{
|
||||
*/
|
||||
#define TIM_CLOCKPOLARITY_INVERTED TIM_ETRPOLARITY_INVERTED /*!< Polarity for ETRx clock sources */
|
||||
#define TIM_CLOCKPOLARITY_NONINVERTED TIM_ETRPOLARITY_NONINVERTED /*!< Polarity for ETRx clock sources */
|
||||
#define TIM_CLOCKPOLARITY_RISING TIM_INPUTCHANNELPOLARITY_RISING /*!< Polarity for TIx clock sources */
|
||||
#define TIM_CLOCKPOLARITY_FALLING TIM_INPUTCHANNELPOLARITY_FALLING /*!< Polarity for TIx clock sources */
|
||||
#define TIM_CLOCKPOLARITY_BOTHEDGE TIM_INPUTCHANNELPOLARITY_BOTHEDGE /*!< Polarity for TIx clock sources */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup TIM_Clock_Prescaler TIM Clock Prescaler
|
||||
* @{
|
||||
*/
|
||||
#define TIM_CLOCKPRESCALER_DIV1 TIM_ETRPRESCALER_DIV1 /*!< No prescaler is used */
|
||||
#define TIM_CLOCKPRESCALER_DIV2 TIM_ETRPRESCALER_DIV2 /*!< Prescaler for External ETR Clock: Capture performed once every 2 events. */
|
||||
#define TIM_CLOCKPRESCALER_DIV4 TIM_ETRPRESCALER_DIV4 /*!< Prescaler for External ETR Clock: Capture performed once every 4 events. */
|
||||
#define TIM_CLOCKPRESCALER_DIV8 TIM_ETRPRESCALER_DIV8 /*!< Prescaler for External ETR Clock: Capture performed once every 8 events. */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup TIM_ClearInput_Polarity TIM Clear Input Polarity
|
||||
* @{
|
||||
*/
|
||||
#define TIM_CLEARINPUTPOLARITY_INVERTED TIM_ETRPOLARITY_INVERTED /*!< Polarity for ETRx pin */
|
||||
#define TIM_CLEARINPUTPOLARITY_NONINVERTED TIM_ETRPOLARITY_NONINVERTED /*!< Polarity for ETRx pin */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup TIM_ClearInput_Prescaler TIM Clear Input Prescaler
|
||||
* @{
|
||||
*/
|
||||
#define TIM_CLEARINPUTPRESCALER_DIV1 TIM_ETRPRESCALER_DIV1 /*!< No prescaler is used */
|
||||
#define TIM_CLEARINPUTPRESCALER_DIV2 TIM_ETRPRESCALER_DIV2 /*!< Prescaler for External ETR pin: Capture performed once every 2 events. */
|
||||
#define TIM_CLEARINPUTPRESCALER_DIV4 TIM_ETRPRESCALER_DIV4 /*!< Prescaler for External ETR pin: Capture performed once every 4 events. */
|
||||
#define TIM_CLEARINPUTPRESCALER_DIV8 TIM_ETRPRESCALER_DIV8 /*!< Prescaler for External ETR pin: Capture performed once every 8 events. */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup TIM_OSSR_Off_State_Selection_for_Run_mode_state TIM OSSR OffState Selection for Run mode state
|
||||
* @{
|
||||
*/
|
||||
#define TIM_OSSR_ENABLE TIM_BDTR_OSSR /*!< When inactive, OC/OCN outputs are enabled (still controlled by the timer) */
|
||||
#define TIM_OSSR_DISABLE 0x00000000U /*!< When inactive, OC/OCN outputs are disabled (not controlled any longer by the timer) */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup TIM_OSSI_Off_State_Selection_for_Idle_mode_state TIM OSSI OffState Selection for Idle mode state
|
||||
* @{
|
||||
*/
|
||||
#define TIM_OSSI_ENABLE TIM_BDTR_OSSI /*!< When inactive, OC/OCN outputs are enabled (still controlled by the timer) */
|
||||
#define TIM_OSSI_DISABLE 0x00000000U /*!< When inactive, OC/OCN outputs are disabled (not controlled any longer by the timer) */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/** @defgroup TIM_Lock_level TIM Lock level
|
||||
* @{
|
||||
*/
|
||||
#define TIM_LOCKLEVEL_OFF 0x00000000U /*!< LOCK OFF */
|
||||
#define TIM_LOCKLEVEL_1 TIM_BDTR_LOCK_0 /*!< LOCK Level 1 */
|
||||
#define TIM_LOCKLEVEL_2 TIM_BDTR_LOCK_1 /*!< LOCK Level 2 */
|
||||
#define TIM_LOCKLEVEL_3 TIM_BDTR_LOCK /*!< LOCK Level 3 */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup TIM_Break_Input_enable_disable TIM Break Input Enable
|
||||
* @{
|
||||
*/
|
||||
#define TIM_BREAK_ENABLE TIM_BDTR_BKE /*!< Break input BRK is enabled */
|
||||
#define TIM_BREAK_DISABLE 0x00000000U /*!< Break input BRK is disabled */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup TIM_Break_Polarity TIM Break Input Polarity
|
||||
* @{
|
||||
*/
|
||||
#define TIM_BREAKPOLARITY_LOW 0x00000000U /*!< Break input BRK is active low */
|
||||
#define TIM_BREAKPOLARITY_HIGH TIM_BDTR_BKP /*!< Break input BRK is active high */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup TIM_AOE_Bit_Set_Reset TIM Automatic Output Enable
|
||||
* @{
|
||||
*/
|
||||
#define TIM_AUTOMATICOUTPUT_DISABLE 0x00000000U /*!< MOE can be set only by software */
|
||||
#define TIM_AUTOMATICOUTPUT_ENABLE TIM_BDTR_AOE /*!< MOE can be set by software or automatically at the next update event
|
||||
(if none of the break inputs BRK and BRK2 is active) */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup TIM_Master_Mode_Selection TIM Master Mode Selection
|
||||
* @{
|
||||
*/
|
||||
#define TIM_TRGO_RESET 0x00000000U /*!< TIMx_EGR.UG bit is used as trigger output (TRGO) */
|
||||
#define TIM_TRGO_ENABLE TIM_CR2_MMS_0 /*!< TIMx_CR1.CEN bit is used as trigger output (TRGO) */
|
||||
#define TIM_TRGO_UPDATE TIM_CR2_MMS_1 /*!< Update event is used as trigger output (TRGO) */
|
||||
#define TIM_TRGO_OC1 (TIM_CR2_MMS_1 | TIM_CR2_MMS_0) /*!< Capture or compare match 1 is used as trigger output (TRGO) */
|
||||
#define TIM_TRGO_OC1REF TIM_CR2_MMS_2 /*!< OC1REF signal is used as trigger output(TRGO) */
|
||||
#define TIM_TRGO_OC2REF (TIM_CR2_MMS_2 | TIM_CR2_MMS_0) /*!< OC2REF signal is used as trigger output(TRGO) */
|
||||
#define TIM_TRGO_OC3REF (TIM_CR2_MMS_2 | TIM_CR2_MMS_1) /*!< OC3REF signal is used as trigger output(TRGO) */
|
||||
#define TIM_TRGO_OC4REF (TIM_CR2_MMS_2 | TIM_CR2_MMS_1 | TIM_CR2_MMS_0) /*!< OC4REF signal is used as trigger output(TRGO) */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup TIM_Master_Slave_Mode TIM Master/Slave Mode
|
||||
* @{
|
||||
*/
|
||||
#define TIM_MASTERSLAVEMODE_ENABLE TIM_SMCR_MSM /*!< Master/slave mode is selected */
|
||||
#define TIM_MASTERSLAVEMODE_DISABLE 0x00000000U /*!< No action */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup TIM_Slave_Mode TIM Slave mode
|
||||
* @{
|
||||
*/
|
||||
#define TIM_SLAVEMODE_DISABLE 0x00000000U /*!< Slave mode disabled */
|
||||
#define TIM_SLAVEMODE_RESET TIM_SMCR_SMS_2 /*!< Reset Mode */
|
||||
#define TIM_SLAVEMODE_GATED (TIM_SMCR_SMS_2 | TIM_SMCR_SMS_0) /*!< Gated Mode */
|
||||
#define TIM_SLAVEMODE_TRIGGER (TIM_SMCR_SMS_2 | TIM_SMCR_SMS_1) /*!< Trigger Mode */
|
||||
#define TIM_SLAVEMODE_EXTERNAL1 (TIM_SMCR_SMS_2 | TIM_SMCR_SMS_1 | TIM_SMCR_SMS_0) /*!< External Clock Mode 1 */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup TIM_Output_Compare_and_PWM_modes TIM Output Compare and PWM Modes
|
||||
* @{
|
||||
*/
|
||||
#define TIM_OCMODE_TIMING 0x00000000U /*!< Frozen */
|
||||
#define TIM_OCMODE_ACTIVE TIM_CCMR1_OC1M_0 /*!< Set channel to active level on match */
|
||||
#define TIM_OCMODE_INACTIVE TIM_CCMR1_OC1M_1 /*!< Set channel to inactive level on match */
|
||||
#define TIM_OCMODE_TOGGLE (TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_0) /*!< Toggle */
|
||||
#define TIM_OCMODE_PWM1 (TIM_CCMR1_OC1M_2 | TIM_CCMR1_OC1M_1) /*!< PWM mode 1 */
|
||||
#define TIM_OCMODE_PWM2 (TIM_CCMR1_OC1M_2 | TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_0) /*!< PWM mode 2 */
|
||||
#define TIM_OCMODE_FORCED_ACTIVE (TIM_CCMR1_OC1M_2 | TIM_CCMR1_OC1M_0) /*!< Force active level */
|
||||
#define TIM_OCMODE_FORCED_INACTIVE TIM_CCMR1_OC1M_2 /*!< Force inactive level */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup TIM_Trigger_Selection TIM Trigger Selection
|
||||
* @{
|
||||
*/
|
||||
#define TIM_TS_ITR0 0x00000000U /*!< Internal Trigger 0 (ITR0) */
|
||||
#define TIM_TS_ITR1 TIM_SMCR_TS_0 /*!< Internal Trigger 1 (ITR1) */
|
||||
#define TIM_TS_ITR2 TIM_SMCR_TS_1 /*!< Internal Trigger 2 (ITR2) */
|
||||
#define TIM_TS_ITR3 (TIM_SMCR_TS_0 | TIM_SMCR_TS_1) /*!< Internal Trigger 3 (ITR3) */
|
||||
#define TIM_TS_TI1F_ED TIM_SMCR_TS_2 /*!< TI1 Edge Detector (TI1F_ED) */
|
||||
#define TIM_TS_TI1FP1 (TIM_SMCR_TS_0 | TIM_SMCR_TS_2) /*!< Filtered Timer Input 1 (TI1FP1) */
|
||||
#define TIM_TS_TI2FP2 (TIM_SMCR_TS_1 | TIM_SMCR_TS_2) /*!< Filtered Timer Input 2 (TI2FP2) */
|
||||
#define TIM_TS_ETRF (TIM_SMCR_TS_0 | TIM_SMCR_TS_1 | TIM_SMCR_TS_2) /*!< Filtered External Trigger input (ETRF) */
|
||||
#define TIM_TS_NONE 0x0000FFFFU /*!< No trigger selected */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup TIM_Trigger_Polarity TIM Trigger Polarity
|
||||
* @{
|
||||
*/
|
||||
#define TIM_TRIGGERPOLARITY_INVERTED TIM_ETRPOLARITY_INVERTED /*!< Polarity for ETRx trigger sources */
|
||||
#define TIM_TRIGGERPOLARITY_NONINVERTED TIM_ETRPOLARITY_NONINVERTED /*!< Polarity for ETRx trigger sources */
|
||||
#define TIM_TRIGGERPOLARITY_RISING TIM_INPUTCHANNELPOLARITY_RISING /*!< Polarity for TIxFPx or TI1_ED trigger sources */
|
||||
#define TIM_TRIGGERPOLARITY_FALLING TIM_INPUTCHANNELPOLARITY_FALLING /*!< Polarity for TIxFPx or TI1_ED trigger sources */
|
||||
#define TIM_TRIGGERPOLARITY_BOTHEDGE TIM_INPUTCHANNELPOLARITY_BOTHEDGE /*!< Polarity for TIxFPx or TI1_ED trigger sources */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup TIM_Trigger_Prescaler TIM Trigger Prescaler
|
||||
* @{
|
||||
*/
|
||||
#define TIM_TRIGGERPRESCALER_DIV1 TIM_ETRPRESCALER_DIV1 /*!< No prescaler is used */
|
||||
#define TIM_TRIGGERPRESCALER_DIV2 TIM_ETRPRESCALER_DIV2 /*!< Prescaler for External ETR Trigger: Capture performed once every 2 events. */
|
||||
#define TIM_TRIGGERPRESCALER_DIV4 TIM_ETRPRESCALER_DIV4 /*!< Prescaler for External ETR Trigger: Capture performed once every 4 events. */
|
||||
#define TIM_TRIGGERPRESCALER_DIV8 TIM_ETRPRESCALER_DIV8 /*!< Prescaler for External ETR Trigger: Capture performed once every 8 events. */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup TIM_TI1_Selection TIM TI1 Input Selection
|
||||
* @{
|
||||
*/
|
||||
#define TIM_TI1SELECTION_CH1 0x00000000U /*!< The TIMx_CH1 pin is connected to TI1 input */
|
||||
#define TIM_TI1SELECTION_XORCOMBINATION TIM_CR2_TI1S /*!< The TIMx_CH1, CH2 and CH3 pins are connected to the TI1 input (XOR combination) */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#if (defined(DMA) || defined(DMA1))
|
||||
/** @defgroup TIM_DMA_Burst_Length TIM DMA Burst Length
|
||||
* @{
|
||||
*/
|
||||
#define TIM_DMABURSTLENGTH_1TRANSFER 0x00000000U /*!< The transfer is done to 1 register starting from TIMx_CR1 + TIMx_DCR.DBA */
|
||||
#define TIM_DMABURSTLENGTH_2TRANSFERS 0x00000100U /*!< The transfer is done to 2 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
|
||||
#define TIM_DMABURSTLENGTH_3TRANSFERS 0x00000200U /*!< The transfer is done to 3 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
|
||||
#define TIM_DMABURSTLENGTH_4TRANSFERS 0x00000300U /*!< The transfer is done to 4 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
|
||||
#define TIM_DMABURSTLENGTH_5TRANSFERS 0x00000400U /*!< The transfer is done to 5 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
|
||||
#define TIM_DMABURSTLENGTH_6TRANSFERS 0x00000500U /*!< The transfer is done to 6 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
|
||||
#define TIM_DMABURSTLENGTH_7TRANSFERS 0x00000600U /*!< The transfer is done to 7 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
|
||||
#define TIM_DMABURSTLENGTH_8TRANSFERS 0x00000700U /*!< The transfer is done to 8 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
|
||||
#define TIM_DMABURSTLENGTH_9TRANSFERS 0x00000800U /*!< The transfer is done to 9 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
|
||||
#define TIM_DMABURSTLENGTH_10TRANSFERS 0x00000900U /*!< The transfer is done to 10 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
|
||||
#define TIM_DMABURSTLENGTH_11TRANSFERS 0x00000A00U /*!< The transfer is done to 11 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
|
||||
#define TIM_DMABURSTLENGTH_12TRANSFERS 0x00000B00U /*!< The transfer is done to 12 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
|
||||
#define TIM_DMABURSTLENGTH_13TRANSFERS 0x00000C00U /*!< The transfer is done to 13 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
|
||||
#define TIM_DMABURSTLENGTH_14TRANSFERS 0x00000D00U /*!< The transfer is done to 14 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
|
||||
#define TIM_DMABURSTLENGTH_15TRANSFERS 0x00000E00U /*!< The transfer is done to 15 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
|
||||
#define TIM_DMABURSTLENGTH_16TRANSFERS 0x00000F00U /*!< The transfer is done to 16 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
|
||||
#define TIM_DMABURSTLENGTH_17TRANSFERS 0x00001000U /*!< The transfer is done to 17 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
|
||||
#define TIM_DMABURSTLENGTH_18TRANSFERS 0x00001100U /*!< The transfer is done to 18 registers starting from TIMx_CR1 + TIMx_DCR.DBA */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup DMA_Handle_index TIM DMA Handle Index
|
||||
* @{
|
||||
*/
|
||||
#define TIM_DMA_ID_UPDATE ((uint16_t) 0x0000) /*!< Index of the DMA handle used for Update DMA requests */
|
||||
#define TIM_DMA_ID_CC1 ((uint16_t) 0x0001) /*!< Index of the DMA handle used for Capture/Compare 1 DMA requests */
|
||||
#define TIM_DMA_ID_CC2 ((uint16_t) 0x0002) /*!< Index of the DMA handle used for Capture/Compare 2 DMA requests */
|
||||
#define TIM_DMA_ID_CC3 ((uint16_t) 0x0003) /*!< Index of the DMA handle used for Capture/Compare 3 DMA requests */
|
||||
#define TIM_DMA_ID_CC4 ((uint16_t) 0x0004) /*!< Index of the DMA handle used for Capture/Compare 4 DMA requests */
|
||||
#define TIM_DMA_ID_COMMUTATION ((uint16_t) 0x0005) /*!< Index of the DMA handle used for Commutation DMA requests */
|
||||
#define TIM_DMA_ID_TRIGGER ((uint16_t) 0x0006) /*!< Index of the DMA handle used for Trigger DMA requests */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif
|
||||
|
||||
/** @defgroup Channel_CC_State TIM Capture/Compare Channel State
|
||||
* @{
|
||||
*/
|
||||
#define TIM_CCx_ENABLE 0x00000001U /*!< Input or output channel is enabled */
|
||||
#define TIM_CCx_DISABLE 0x00000000U /*!< Input or output channel is disabled */
|
||||
#define TIM_CCxN_ENABLE 0x00000004U /*!< Complementary output channel is enabled */
|
||||
#define TIM_CCxN_DISABLE 0x00000000U /*!< Complementary output channel is disabled */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/* End of exported constants -------------------------------------------------*/
|
||||
|
||||
/* Exported macros -----------------------------------------------------------*/
|
||||
/** @defgroup TIM_Exported_Macros TIM Exported Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @brief Reset TIM handle state.
|
||||
* @param __HANDLE__ TIM handle.
|
||||
* @retval None
|
||||
*/
|
||||
#if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
|
||||
#define __HAL_TIM_RESET_HANDLE_STATE(__HANDLE__) do { \
|
||||
(__HANDLE__)->State = HAL_TIM_STATE_RESET; \
|
||||
(__HANDLE__)->Base_MspInitCallback = NULL; \
|
||||
(__HANDLE__)->Base_MspDeInitCallback = NULL; \
|
||||
(__HANDLE__)->IC_MspInitCallback = NULL; \
|
||||
(__HANDLE__)->IC_MspDeInitCallback = NULL; \
|
||||
(__HANDLE__)->OC_MspInitCallback = NULL; \
|
||||
(__HANDLE__)->OC_MspDeInitCallback = NULL; \
|
||||
(__HANDLE__)->PWM_MspInitCallback = NULL; \
|
||||
(__HANDLE__)->PWM_MspDeInitCallback = NULL; \
|
||||
(__HANDLE__)->OnePulse_MspInitCallback = NULL; \
|
||||
(__HANDLE__)->OnePulse_MspDeInitCallback = NULL; \
|
||||
(__HANDLE__)->Encoder_MspInitCallback = NULL; \
|
||||
(__HANDLE__)->Encoder_MspDeInitCallback = NULL; \
|
||||
(__HANDLE__)->HallSensor_MspInitCallback = NULL; \
|
||||
(__HANDLE__)->HallSensor_MspDeInitCallback = NULL; \
|
||||
} while(0)
|
||||
#else
|
||||
#define __HAL_TIM_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_TIM_STATE_RESET)
|
||||
#endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
|
||||
|
||||
/**
|
||||
* @brief Enable the TIM peripheral.
|
||||
* @param __HANDLE__ TIM handle
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_TIM_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1|=(TIM_CR1_CEN))
|
||||
|
||||
/**
|
||||
* @brief Enable the TIM main Output.
|
||||
* @param __HANDLE__ TIM handle
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_TIM_MOE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->BDTR|=(TIM_BDTR_MOE))
|
||||
|
||||
/**
|
||||
* @brief Disable the TIM peripheral.
|
||||
* @param __HANDLE__ TIM handle
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_TIM_DISABLE(__HANDLE__) \
|
||||
do { \
|
||||
if (((__HANDLE__)->Instance->CCER & TIM_CCER_CCxE_MASK) == 0UL) \
|
||||
{ \
|
||||
if(((__HANDLE__)->Instance->CCER & TIM_CCER_CCxNE_MASK) == 0UL) \
|
||||
{ \
|
||||
(__HANDLE__)->Instance->CR1 &= ~(TIM_CR1_CEN); \
|
||||
} \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
/**
|
||||
* @brief Disable the TIM main Output.
|
||||
* @param __HANDLE__ TIM handle
|
||||
* @retval None
|
||||
* @note The Main Output Enable of a timer instance is disabled only if all the CCx and CCxN channels have been disabled
|
||||
*/
|
||||
#define __HAL_TIM_MOE_DISABLE(__HANDLE__) \
|
||||
do { \
|
||||
if (((__HANDLE__)->Instance->CCER & TIM_CCER_CCxE_MASK) == 0UL) \
|
||||
{ \
|
||||
if(((__HANDLE__)->Instance->CCER & TIM_CCER_CCxNE_MASK) == 0UL) \
|
||||
{ \
|
||||
(__HANDLE__)->Instance->BDTR &= ~(TIM_BDTR_MOE); \
|
||||
} \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
/**
|
||||
* @brief Disable the TIM main Output.
|
||||
* @param __HANDLE__ TIM handle
|
||||
* @retval None
|
||||
* @note The Main Output Enable of a timer instance is disabled unconditionally
|
||||
*/
|
||||
#define __HAL_TIM_MOE_DISABLE_UNCONDITIONALLY(__HANDLE__) (__HANDLE__)->Instance->BDTR &= ~(TIM_BDTR_MOE)
|
||||
|
||||
/** @brief Enable the specified TIM interrupt.
|
||||
* @param __HANDLE__ specifies the TIM Handle.
|
||||
* @param __INTERRUPT__ specifies the TIM interrupt source to enable.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg TIM_IT_UPDATE: Update interrupt
|
||||
* @arg TIM_IT_CC1: Capture/Compare 1 interrupt
|
||||
* @arg TIM_IT_CC2: Capture/Compare 2 interrupt
|
||||
* @arg TIM_IT_CC3: Capture/Compare 3 interrupt
|
||||
* @arg TIM_IT_CC4: Capture/Compare 4 interrupt
|
||||
* @arg TIM_IT_COM: Commutation interrupt
|
||||
* @arg TIM_IT_TRIGGER: Trigger interrupt
|
||||
* @arg TIM_IT_BREAK: Break interrupt
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_TIM_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->DIER |= (__INTERRUPT__))
|
||||
|
||||
/** @brief Disable the specified TIM interrupt.
|
||||
* @param __HANDLE__ specifies the TIM Handle.
|
||||
* @param __INTERRUPT__ specifies the TIM interrupt source to disable.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg TIM_IT_UPDATE: Update interrupt
|
||||
* @arg TIM_IT_CC1: Capture/Compare 1 interrupt
|
||||
* @arg TIM_IT_CC2: Capture/Compare 2 interrupt
|
||||
* @arg TIM_IT_CC3: Capture/Compare 3 interrupt
|
||||
* @arg TIM_IT_CC4: Capture/Compare 4 interrupt
|
||||
* @arg TIM_IT_COM: Commutation interrupt
|
||||
* @arg TIM_IT_TRIGGER: Trigger interrupt
|
||||
* @arg TIM_IT_BREAK: Break interrupt
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_TIM_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->DIER &= ~(__INTERRUPT__))
|
||||
|
||||
#if (defined(DMA) || defined(DMA1))
|
||||
/** @brief Enable the specified DMA request.
|
||||
* @param __HANDLE__ specifies the TIM Handle.
|
||||
* @param __DMA__ specifies the TIM DMA request to enable.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg TIM_DMA_UPDATE: Update DMA request
|
||||
* @arg TIM_DMA_CC1: Capture/Compare 1 DMA request
|
||||
* @arg TIM_DMA_CC2: Capture/Compare 2 DMA request
|
||||
* @arg TIM_DMA_CC3: Capture/Compare 3 DMA request
|
||||
* @arg TIM_DMA_CC4: Capture/Compare 4 DMA request
|
||||
* @arg TIM_DMA_COM: Commutation DMA request
|
||||
* @arg TIM_DMA_TRIGGER: Trigger DMA request
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_TIM_ENABLE_DMA(__HANDLE__, __DMA__) ((__HANDLE__)->Instance->DIER |= (__DMA__))
|
||||
|
||||
/** @brief Disable the specified DMA request.
|
||||
* @param __HANDLE__ specifies the TIM Handle.
|
||||
* @param __DMA__ specifies the TIM DMA request to disable.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg TIM_DMA_UPDATE: Update DMA request
|
||||
* @arg TIM_DMA_CC1: Capture/Compare 1 DMA request
|
||||
* @arg TIM_DMA_CC2: Capture/Compare 2 DMA request
|
||||
* @arg TIM_DMA_CC3: Capture/Compare 3 DMA request
|
||||
* @arg TIM_DMA_CC4: Capture/Compare 4 DMA request
|
||||
* @arg TIM_DMA_COM: Commutation DMA request
|
||||
* @arg TIM_DMA_TRIGGER: Trigger DMA request
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_TIM_DISABLE_DMA(__HANDLE__, __DMA__) ((__HANDLE__)->Instance->DIER &= ~(__DMA__))
|
||||
#endif
|
||||
|
||||
/** @brief Check whether the specified TIM interrupt flag is set or not.
|
||||
* @param __HANDLE__ specifies the TIM Handle.
|
||||
* @param __FLAG__ specifies the TIM interrupt flag to check.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg TIM_FLAG_UPDATE: Update interrupt flag
|
||||
* @arg TIM_FLAG_CC1: Capture/Compare 1 interrupt flag
|
||||
* @arg TIM_FLAG_CC2: Capture/Compare 2 interrupt flag
|
||||
* @arg TIM_FLAG_CC3: Capture/Compare 3 interrupt flag
|
||||
* @arg TIM_FLAG_CC4: Capture/Compare 4 interrupt flag
|
||||
* @arg TIM_FLAG_COM: Commutation interrupt flag
|
||||
* @arg TIM_FLAG_TRIGGER: Trigger interrupt flag
|
||||
* @arg TIM_FLAG_BREAK: Break interrupt flag
|
||||
* @arg TIM_FLAG_CC1OF: Capture/Compare 1 overcapture flag
|
||||
* @arg TIM_FLAG_CC2OF: Capture/Compare 2 overcapture flag
|
||||
* @arg TIM_FLAG_CC3OF: Capture/Compare 3 overcapture flag
|
||||
* @arg TIM_FLAG_CC4OF: Capture/Compare 4 overcapture flag
|
||||
* @retval The new state of __FLAG__ (TRUE or FALSE).
|
||||
*/
|
||||
#define __HAL_TIM_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR &(__FLAG__)) == (__FLAG__))
|
||||
|
||||
/** @brief Clear the specified TIM interrupt flag.
|
||||
* @param __HANDLE__ specifies the TIM Handle.
|
||||
* @param __FLAG__ specifies the TIM interrupt flag to clear.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg TIM_FLAG_UPDATE: Update interrupt flag
|
||||
* @arg TIM_FLAG_CC1: Capture/Compare 1 interrupt flag
|
||||
* @arg TIM_FLAG_CC2: Capture/Compare 2 interrupt flag
|
||||
* @arg TIM_FLAG_CC3: Capture/Compare 3 interrupt flag
|
||||
* @arg TIM_FLAG_CC4: Capture/Compare 4 interrupt flag
|
||||
* @arg TIM_FLAG_COM: Commutation interrupt flag
|
||||
* @arg TIM_FLAG_TRIGGER: Trigger interrupt flag
|
||||
* @arg TIM_FLAG_BREAK: Break interrupt flag
|
||||
* @arg TIM_FLAG_CC1OF: Capture/Compare 1 overcapture flag
|
||||
* @arg TIM_FLAG_CC2OF: Capture/Compare 2 overcapture flag
|
||||
* @arg TIM_FLAG_CC3OF: Capture/Compare 3 overcapture flag
|
||||
* @arg TIM_FLAG_CC4OF: Capture/Compare 4 overcapture flag
|
||||
* @retval The new state of __FLAG__ (TRUE or FALSE).
|
||||
*/
|
||||
#define __HAL_TIM_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR = ~(__FLAG__))
|
||||
|
||||
/**
|
||||
* @brief Check whether the specified TIM interrupt source is enabled or not.
|
||||
* @param __HANDLE__ TIM handle
|
||||
* @param __INTERRUPT__ specifies the TIM interrupt source to check.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg TIM_IT_UPDATE: Update interrupt
|
||||
* @arg TIM_IT_CC1: Capture/Compare 1 interrupt
|
||||
* @arg TIM_IT_CC2: Capture/Compare 2 interrupt
|
||||
* @arg TIM_IT_CC3: Capture/Compare 3 interrupt
|
||||
* @arg TIM_IT_CC4: Capture/Compare 4 interrupt
|
||||
* @arg TIM_IT_COM: Commutation interrupt
|
||||
* @arg TIM_IT_TRIGGER: Trigger interrupt
|
||||
* @arg TIM_IT_BREAK: Break interrupt
|
||||
* @retval The state of TIM_IT (SET or RESET).
|
||||
*/
|
||||
#define __HAL_TIM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->DIER & (__INTERRUPT__)) \
|
||||
== (__INTERRUPT__)) ? SET : RESET)
|
||||
|
||||
/** @brief Clear the TIM interrupt pending bits.
|
||||
* @param __HANDLE__ TIM handle
|
||||
* @param __INTERRUPT__ specifies the interrupt pending bit to clear.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg TIM_IT_UPDATE: Update interrupt
|
||||
* @arg TIM_IT_CC1: Capture/Compare 1 interrupt
|
||||
* @arg TIM_IT_CC2: Capture/Compare 2 interrupt
|
||||
* @arg TIM_IT_CC3: Capture/Compare 3 interrupt
|
||||
* @arg TIM_IT_CC4: Capture/Compare 4 interrupt
|
||||
* @arg TIM_IT_COM: Commutation interrupt
|
||||
* @arg TIM_IT_TRIGGER: Trigger interrupt
|
||||
* @arg TIM_IT_BREAK: Break interrupt
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_TIM_CLEAR_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->SR = ~(__INTERRUPT__))
|
||||
|
||||
/**
|
||||
* @brief Indicates whether or not the TIM Counter is used as downcounter.
|
||||
* @param __HANDLE__ TIM handle.
|
||||
* @retval False (Counter used as upcounter) or True (Counter used as downcounter)
|
||||
* @note This macro is particularly useful to get the counting mode when the timer operates in Center-aligned mode or Encoder
|
||||
mode.
|
||||
*/
|
||||
#define __HAL_TIM_IS_TIM_COUNTING_DOWN(__HANDLE__) (((__HANDLE__)->Instance->CR1 &(TIM_CR1_DIR)) == (TIM_CR1_DIR))
|
||||
|
||||
/**
|
||||
* @brief Set the TIM Prescaler on runtime.
|
||||
* @param __HANDLE__ TIM handle.
|
||||
* @param __PRESC__ specifies the Prescaler new value.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_TIM_SET_PRESCALER(__HANDLE__, __PRESC__) ((__HANDLE__)->Instance->PSC = (__PRESC__))
|
||||
|
||||
/**
|
||||
* @brief Set the TIM Counter Register value on runtime.
|
||||
* @param __HANDLE__ TIM handle.
|
||||
* @param __COUNTER__ specifies the Counter register new value.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_TIM_SET_COUNTER(__HANDLE__, __COUNTER__) ((__HANDLE__)->Instance->CNT = (__COUNTER__))
|
||||
|
||||
/**
|
||||
* @brief Get the TIM Counter Register value on runtime.
|
||||
* @param __HANDLE__ TIM handle.
|
||||
* @retval 16-bit or 32-bit value of the timer counter register (TIMx_CNT)
|
||||
*/
|
||||
#define __HAL_TIM_GET_COUNTER(__HANDLE__) ((__HANDLE__)->Instance->CNT)
|
||||
|
||||
/**
|
||||
* @brief Set the TIM Autoreload Register value on runtime without calling another time any Init function.
|
||||
* @param __HANDLE__ TIM handle.
|
||||
* @param __AUTORELOAD__ specifies the Counter register new value.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_TIM_SET_AUTORELOAD(__HANDLE__, __AUTORELOAD__) \
|
||||
do{ \
|
||||
(__HANDLE__)->Instance->ARR = (__AUTORELOAD__); \
|
||||
(__HANDLE__)->Init.Period = (__AUTORELOAD__); \
|
||||
} while(0)
|
||||
|
||||
/**
|
||||
* @brief Get the TIM Autoreload Register value on runtime.
|
||||
* @param __HANDLE__ TIM handle.
|
||||
* @retval 16-bit or 32-bit value of the timer auto-reload register(TIMx_ARR)
|
||||
*/
|
||||
#define __HAL_TIM_GET_AUTORELOAD(__HANDLE__) ((__HANDLE__)->Instance->ARR)
|
||||
|
||||
/**
|
||||
* @brief Set the TIM Clock Division value on runtime without calling another time any Init function.
|
||||
* @param __HANDLE__ TIM handle.
|
||||
* @param __CKD__ specifies the clock division value.
|
||||
* This parameter can be one of the following value:
|
||||
* @arg TIM_CLOCKDIVISION_DIV1: tDTS=tCK_INT
|
||||
* @arg TIM_CLOCKDIVISION_DIV2: tDTS=2*tCK_INT
|
||||
* @arg TIM_CLOCKDIVISION_DIV4: tDTS=4*tCK_INT
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_TIM_SET_CLOCKDIVISION(__HANDLE__, __CKD__) \
|
||||
do{ \
|
||||
(__HANDLE__)->Instance->CR1 &= (~TIM_CR1_CKD); \
|
||||
(__HANDLE__)->Instance->CR1 |= (__CKD__); \
|
||||
(__HANDLE__)->Init.ClockDivision = (__CKD__); \
|
||||
} while(0)
|
||||
|
||||
/**
|
||||
* @brief Get the TIM Clock Division value on runtime.
|
||||
* @param __HANDLE__ TIM handle.
|
||||
* @retval The clock division can be one of the following values:
|
||||
* @arg TIM_CLOCKDIVISION_DIV1: tDTS=tCK_INT
|
||||
* @arg TIM_CLOCKDIVISION_DIV2: tDTS=2*tCK_INT
|
||||
* @arg TIM_CLOCKDIVISION_DIV4: tDTS=4*tCK_INT
|
||||
*/
|
||||
#define __HAL_TIM_GET_CLOCKDIVISION(__HANDLE__) ((__HANDLE__)->Instance->CR1 & TIM_CR1_CKD)
|
||||
|
||||
/**
|
||||
* @brief Set the TIM Input Capture prescaler on runtime without calling another time HAL_TIM_IC_ConfigChannel() function.
|
||||
* @param __HANDLE__ TIM handle.
|
||||
* @param __CHANNEL__ TIM Channels to be configured.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg TIM_CHANNEL_1: TIM Channel 1 selected
|
||||
* @arg TIM_CHANNEL_2: TIM Channel 2 selected
|
||||
* @arg TIM_CHANNEL_3: TIM Channel 3 selected
|
||||
* @arg TIM_CHANNEL_4: TIM Channel 4 selected
|
||||
* @param __ICPSC__ specifies the Input Capture4 prescaler new value.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg TIM_ICPSC_DIV1: no prescaler
|
||||
* @arg TIM_ICPSC_DIV2: capture is done once every 2 events
|
||||
* @arg TIM_ICPSC_DIV4: capture is done once every 4 events
|
||||
* @arg TIM_ICPSC_DIV8: capture is done once every 8 events
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_TIM_SET_ICPRESCALER(__HANDLE__, __CHANNEL__, __ICPSC__) \
|
||||
do{ \
|
||||
TIM_RESET_ICPRESCALERVALUE((__HANDLE__), (__CHANNEL__)); \
|
||||
TIM_SET_ICPRESCALERVALUE((__HANDLE__), (__CHANNEL__), (__ICPSC__)); \
|
||||
} while(0)
|
||||
|
||||
/**
|
||||
* @brief Get the TIM Input Capture prescaler on runtime.
|
||||
* @param __HANDLE__ TIM handle.
|
||||
* @param __CHANNEL__ TIM Channels to be configured.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg TIM_CHANNEL_1: get input capture 1 prescaler value
|
||||
* @arg TIM_CHANNEL_2: get input capture 2 prescaler value
|
||||
* @arg TIM_CHANNEL_3: get input capture 3 prescaler value
|
||||
* @arg TIM_CHANNEL_4: get input capture 4 prescaler value
|
||||
* @retval The input capture prescaler can be one of the following values:
|
||||
* @arg TIM_ICPSC_DIV1: no prescaler
|
||||
* @arg TIM_ICPSC_DIV2: capture is done once every 2 events
|
||||
* @arg TIM_ICPSC_DIV4: capture is done once every 4 events
|
||||
* @arg TIM_ICPSC_DIV8: capture is done once every 8 events
|
||||
*/
|
||||
#define __HAL_TIM_GET_ICPRESCALER(__HANDLE__, __CHANNEL__) \
|
||||
(((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCMR1 & TIM_CCMR1_IC1PSC) :\
|
||||
((__CHANNEL__) == TIM_CHANNEL_2) ? (((__HANDLE__)->Instance->CCMR1 & TIM_CCMR1_IC2PSC) >> 8U) :\
|
||||
((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCMR2 & TIM_CCMR2_IC3PSC) :\
|
||||
(((__HANDLE__)->Instance->CCMR2 & TIM_CCMR2_IC4PSC)) >> 8U)
|
||||
|
||||
/**
|
||||
* @brief Set the TIM Capture Compare Register value on runtime without calling another time ConfigChannel function.
|
||||
* @param __HANDLE__ TIM handle.
|
||||
* @param __CHANNEL__ TIM Channels to be configured.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg TIM_CHANNEL_1: TIM Channel 1 selected
|
||||
* @arg TIM_CHANNEL_2: TIM Channel 2 selected
|
||||
* @arg TIM_CHANNEL_3: TIM Channel 3 selected
|
||||
* @arg TIM_CHANNEL_4: TIM Channel 4 selected
|
||||
* @param __COMPARE__ specifies the Capture Compare register new value.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_TIM_SET_COMPARE(__HANDLE__, __CHANNEL__, __COMPARE__) \
|
||||
(((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCR1 = (__COMPARE__)) :\
|
||||
((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCR2 = (__COMPARE__)) :\
|
||||
((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCR3 = (__COMPARE__)) :\
|
||||
((__HANDLE__)->Instance->CCR4 = (__COMPARE__)))
|
||||
|
||||
/**
|
||||
* @brief Get the TIM Capture Compare Register value on runtime.
|
||||
* @param __HANDLE__ TIM handle.
|
||||
* @param __CHANNEL__ TIM Channel associated with the capture compare register
|
||||
* This parameter can be one of the following values:
|
||||
* @arg TIM_CHANNEL_1: get capture/compare 1 register value
|
||||
* @arg TIM_CHANNEL_2: get capture/compare 2 register value
|
||||
* @arg TIM_CHANNEL_3: get capture/compare 3 register value
|
||||
* @arg TIM_CHANNEL_4: get capture/compare 4 register value
|
||||
* @retval 16-bit or 32-bit value of the capture/compare register (TIMx_CCRy)
|
||||
*/
|
||||
#define __HAL_TIM_GET_COMPARE(__HANDLE__, __CHANNEL__) \
|
||||
(((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCR1) :\
|
||||
((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCR2) :\
|
||||
((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCR3) :\
|
||||
((__HANDLE__)->Instance->CCR4))
|
||||
|
||||
/**
|
||||
* @brief Set the TIM Output compare preload.
|
||||
* @param __HANDLE__ TIM handle.
|
||||
* @param __CHANNEL__ TIM Channels to be configured.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg TIM_CHANNEL_1: TIM Channel 1 selected
|
||||
* @arg TIM_CHANNEL_2: TIM Channel 2 selected
|
||||
* @arg TIM_CHANNEL_3: TIM Channel 3 selected
|
||||
* @arg TIM_CHANNEL_4: TIM Channel 4 selected
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_TIM_ENABLE_OCxPRELOAD(__HANDLE__, __CHANNEL__) \
|
||||
(((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCMR1 |= TIM_CCMR1_OC1PE) :\
|
||||
((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCMR1 |= TIM_CCMR1_OC2PE) :\
|
||||
((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCMR2 |= TIM_CCMR2_OC3PE) :\
|
||||
((__HANDLE__)->Instance->CCMR2 |= TIM_CCMR2_OC4PE))
|
||||
|
||||
/**
|
||||
* @brief Reset the TIM Output compare preload.
|
||||
* @param __HANDLE__ TIM handle.
|
||||
* @param __CHANNEL__ TIM Channels to be configured.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg TIM_CHANNEL_1: TIM Channel 1 selected
|
||||
* @arg TIM_CHANNEL_2: TIM Channel 2 selected
|
||||
* @arg TIM_CHANNEL_3: TIM Channel 3 selected
|
||||
* @arg TIM_CHANNEL_4: TIM Channel 4 selected
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_TIM_DISABLE_OCxPRELOAD(__HANDLE__, __CHANNEL__) \
|
||||
(((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCMR1 &= ~TIM_CCMR1_OC1PE) :\
|
||||
((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCMR1 &= ~TIM_CCMR1_OC2PE) :\
|
||||
((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCMR2 &= ~TIM_CCMR2_OC3PE) :\
|
||||
((__HANDLE__)->Instance->CCMR2 &= ~TIM_CCMR2_OC4PE))
|
||||
|
||||
/**
|
||||
* @brief Enable fast mode for a given channel.
|
||||
* @param __HANDLE__ TIM handle.
|
||||
* @param __CHANNEL__ TIM Channels to be configured.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg TIM_CHANNEL_1: TIM Channel 1 selected
|
||||
* @arg TIM_CHANNEL_2: TIM Channel 2 selected
|
||||
* @arg TIM_CHANNEL_3: TIM Channel 3 selected
|
||||
* @arg TIM_CHANNEL_4: TIM Channel 4 selected
|
||||
* @note When fast mode is enabled an active edge on the trigger input acts
|
||||
* like a compare match on CCx output. Delay to sample the trigger
|
||||
* input and to activate CCx output is reduced to 3 clock cycles.
|
||||
* @note Fast mode acts only if the channel is configured in PWM1 or PWM2 mode.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_TIM_ENABLE_OCxFAST(__HANDLE__, __CHANNEL__) \
|
||||
(((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCMR1 |= TIM_CCMR1_OC1FE) :\
|
||||
((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCMR1 |= TIM_CCMR1_OC2FE) :\
|
||||
((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCMR2 |= TIM_CCMR2_OC3FE) :\
|
||||
((__HANDLE__)->Instance->CCMR2 |= TIM_CCMR2_OC4FE))
|
||||
|
||||
/**
|
||||
* @brief Disable fast mode for a given channel.
|
||||
* @param __HANDLE__ TIM handle.
|
||||
* @param __CHANNEL__ TIM Channels to be configured.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg TIM_CHANNEL_1: TIM Channel 1 selected
|
||||
* @arg TIM_CHANNEL_2: TIM Channel 2 selected
|
||||
* @arg TIM_CHANNEL_3: TIM Channel 3 selected
|
||||
* @arg TIM_CHANNEL_4: TIM Channel 4 selected
|
||||
* @note When fast mode is disabled CCx output behaves normally depending
|
||||
* on counter and CCRx values even when the trigger is ON. The minimum
|
||||
* delay to activate CCx output when an active edge occurs on the
|
||||
* trigger input is 5 clock cycles.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_TIM_DISABLE_OCxFAST(__HANDLE__, __CHANNEL__) \
|
||||
(((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCMR1 &= ~TIM_CCMR1_OC1FE) :\
|
||||
((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCMR1 &= ~TIM_CCMR1_OC2FE) :\
|
||||
((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCMR2 &= ~TIM_CCMR2_OC3FE) :\
|
||||
((__HANDLE__)->Instance->CCMR2 &= ~TIM_CCMR2_OC4FE))
|
||||
|
||||
/**
|
||||
* @brief Set the Update Request Source (URS) bit of the TIMx_CR1 register.
|
||||
* @param __HANDLE__ TIM handle.
|
||||
* @note When the URS bit of the TIMx_CR1 register is set, only counter
|
||||
* overflow/underflow generates an update interrupt or DMA request (if
|
||||
* enabled)
|
||||
* @note Depending on devices and packages, DMA may not be available.
|
||||
* Refer to device datasheet for DMA availability.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_TIM_URS_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1|= TIM_CR1_URS)
|
||||
|
||||
/**
|
||||
* @brief Reset the Update Request Source (URS) bit of the TIMx_CR1 register.
|
||||
* @param __HANDLE__ TIM handle.
|
||||
* @note When the URS bit of the TIMx_CR1 register is reset, any of the
|
||||
* following events generate an update interrupt or DMA request (if
|
||||
* enabled):
|
||||
* _ Counter overflow underflow
|
||||
* _ Setting the UG bit
|
||||
* _ Update generation through the slave mode controller
|
||||
* @note Depending on devices and packages, DMA may not be available.
|
||||
* Refer to device datasheet for DMA availability.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_TIM_URS_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1&=~TIM_CR1_URS)
|
||||
|
||||
/**
|
||||
* @brief Set the TIM Capture x input polarity on runtime.
|
||||
* @param __HANDLE__ TIM handle.
|
||||
* @param __CHANNEL__ TIM Channels to be configured.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg TIM_CHANNEL_1: TIM Channel 1 selected
|
||||
* @arg TIM_CHANNEL_2: TIM Channel 2 selected
|
||||
* @arg TIM_CHANNEL_3: TIM Channel 3 selected
|
||||
* @arg TIM_CHANNEL_4: TIM Channel 4 selected
|
||||
* @param __POLARITY__ Polarity for TIx source
|
||||
* @arg TIM_INPUTCHANNELPOLARITY_RISING: Rising Edge
|
||||
* @arg TIM_INPUTCHANNELPOLARITY_FALLING: Falling Edge
|
||||
* @arg TIM_INPUTCHANNELPOLARITY_BOTHEDGE: Rising and Falling Edge
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_TIM_SET_CAPTUREPOLARITY(__HANDLE__, __CHANNEL__, __POLARITY__) \
|
||||
do{ \
|
||||
TIM_RESET_CAPTUREPOLARITY((__HANDLE__), (__CHANNEL__)); \
|
||||
TIM_SET_CAPTUREPOLARITY((__HANDLE__), (__CHANNEL__), (__POLARITY__)); \
|
||||
}while(0)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/* End of exported macros ----------------------------------------------------*/
|
||||
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
/** @defgroup TIM_Private_Constants TIM Private Constants
|
||||
* @{
|
||||
*/
|
||||
/* The counter of a timer instance is disabled only if all the CCx and CCxN
|
||||
channels have been disabled */
|
||||
#define TIM_CCER_CCxE_MASK ((uint32_t)(TIM_CCER_CC1E | TIM_CCER_CC2E | TIM_CCER_CC3E | TIM_CCER_CC4E))
|
||||
#define TIM_CCER_CCxNE_MASK ((uint32_t)(TIM_CCER_CC1NE | TIM_CCER_CC2NE | TIM_CCER_CC3NE))
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/* End of private constants --------------------------------------------------*/
|
||||
|
||||
/* Private macros ------------------------------------------------------------*/
|
||||
/** @defgroup TIM_Private_Macros TIM Private Macros
|
||||
* @{
|
||||
*/
|
||||
#define IS_TIM_CLEARINPUT_SOURCE(__MODE__) (((__MODE__) == TIM_CLEARINPUTSOURCE_NONE) || \
|
||||
((__MODE__) == TIM_CLEARINPUTSOURCE_ETR) || \
|
||||
((__MODE__) == TIM_CLEARINPUTSOURCE_OCREFCLR))
|
||||
#if (defined(DMA) || defined(DMA1))
|
||||
#define IS_TIM_DMA_BASE(__BASE__) (((__BASE__) == TIM_DMABASE_CR1) || \
|
||||
((__BASE__) == TIM_DMABASE_CR2) || \
|
||||
((__BASE__) == TIM_DMABASE_SMCR) || \
|
||||
((__BASE__) == TIM_DMABASE_DIER) || \
|
||||
((__BASE__) == TIM_DMABASE_SR) || \
|
||||
((__BASE__) == TIM_DMABASE_EGR) || \
|
||||
((__BASE__) == TIM_DMABASE_CCMR1) || \
|
||||
((__BASE__) == TIM_DMABASE_CCMR2) || \
|
||||
((__BASE__) == TIM_DMABASE_CCER) || \
|
||||
((__BASE__) == TIM_DMABASE_CNT) || \
|
||||
((__BASE__) == TIM_DMABASE_PSC) || \
|
||||
((__BASE__) == TIM_DMABASE_ARR) || \
|
||||
((__BASE__) == TIM_DMABASE_RCR) || \
|
||||
((__BASE__) == TIM_DMABASE_CCR1) || \
|
||||
((__BASE__) == TIM_DMABASE_CCR2) || \
|
||||
((__BASE__) == TIM_DMABASE_CCR3) || \
|
||||
((__BASE__) == TIM_DMABASE_CCR4) || \
|
||||
((__BASE__) == TIM_DMABASE_BDTR))
|
||||
#endif
|
||||
|
||||
#define IS_TIM_EVENT_SOURCE(__SOURCE__) ((((__SOURCE__) & 0xFFFFFF00U) == 0x00000000U) && ((__SOURCE__) != 0x00000000U))
|
||||
|
||||
#define IS_TIM_COUNTER_MODE(__MODE__) (((__MODE__) == TIM_COUNTERMODE_UP) || \
|
||||
((__MODE__) == TIM_COUNTERMODE_DOWN) || \
|
||||
((__MODE__) == TIM_COUNTERMODE_CENTERALIGNED1) || \
|
||||
((__MODE__) == TIM_COUNTERMODE_CENTERALIGNED2) || \
|
||||
((__MODE__) == TIM_COUNTERMODE_CENTERALIGNED3))
|
||||
|
||||
#define IS_TIM_CLOCKDIVISION_DIV(__DIV__) (((__DIV__) == TIM_CLOCKDIVISION_DIV1) || \
|
||||
((__DIV__) == TIM_CLOCKDIVISION_DIV2) || \
|
||||
((__DIV__) == TIM_CLOCKDIVISION_DIV4))
|
||||
|
||||
#define IS_TIM_AUTORELOAD_PRELOAD(PRELOAD) (((PRELOAD) == TIM_AUTORELOAD_PRELOAD_DISABLE) || \
|
||||
((PRELOAD) == TIM_AUTORELOAD_PRELOAD_ENABLE))
|
||||
|
||||
#define IS_TIM_FAST_STATE(__STATE__) (((__STATE__) == TIM_OCFAST_DISABLE) || \
|
||||
((__STATE__) == TIM_OCFAST_ENABLE))
|
||||
|
||||
#define IS_TIM_OC_POLARITY(__POLARITY__) (((__POLARITY__) == TIM_OCPOLARITY_HIGH) || \
|
||||
((__POLARITY__) == TIM_OCPOLARITY_LOW))
|
||||
|
||||
#define IS_TIM_OCN_POLARITY(__POLARITY__) (((__POLARITY__) == TIM_OCNPOLARITY_HIGH) || \
|
||||
((__POLARITY__) == TIM_OCNPOLARITY_LOW))
|
||||
|
||||
#define IS_TIM_OCIDLE_STATE(__STATE__) (((__STATE__) == TIM_OCIDLESTATE_SET) || \
|
||||
((__STATE__) == TIM_OCIDLESTATE_RESET))
|
||||
|
||||
#define IS_TIM_OCNIDLE_STATE(__STATE__) (((__STATE__) == TIM_OCNIDLESTATE_SET) || \
|
||||
((__STATE__) == TIM_OCNIDLESTATE_RESET))
|
||||
|
||||
#define IS_TIM_ENCODERINPUT_POLARITY(__POLARITY__) (((__POLARITY__) == TIM_ENCODERINPUTPOLARITY_RISING) || \
|
||||
((__POLARITY__) == TIM_ENCODERINPUTPOLARITY_FALLING))
|
||||
|
||||
#define IS_TIM_IC_POLARITY(__POLARITY__) (((__POLARITY__) == TIM_ICPOLARITY_RISING) || \
|
||||
((__POLARITY__) == TIM_ICPOLARITY_FALLING) || \
|
||||
((__POLARITY__) == TIM_ICPOLARITY_BOTHEDGE))
|
||||
|
||||
#define IS_TIM_IC_SELECTION(__SELECTION__) (((__SELECTION__) == TIM_ICSELECTION_DIRECTTI) || \
|
||||
((__SELECTION__) == TIM_ICSELECTION_INDIRECTTI) || \
|
||||
((__SELECTION__) == TIM_ICSELECTION_TRC))
|
||||
|
||||
#define IS_TIM_IC_PRESCALER(__PRESCALER__) (((__PRESCALER__) == TIM_ICPSC_DIV1) || \
|
||||
((__PRESCALER__) == TIM_ICPSC_DIV2) || \
|
||||
((__PRESCALER__) == TIM_ICPSC_DIV4) || \
|
||||
((__PRESCALER__) == TIM_ICPSC_DIV8))
|
||||
|
||||
#define IS_TIM_OPM_MODE(__MODE__) (((__MODE__) == TIM_OPMODE_SINGLE) || \
|
||||
((__MODE__) == TIM_OPMODE_REPETITIVE))
|
||||
|
||||
#define IS_TIM_ENCODER_MODE(__MODE__) (((__MODE__) == TIM_ENCODERMODE_TI1) || \
|
||||
((__MODE__) == TIM_ENCODERMODE_TI2) || \
|
||||
((__MODE__) == TIM_ENCODERMODE_TI12))
|
||||
|
||||
#define IS_TIM_DMA_SOURCE(__SOURCE__) ((((__SOURCE__) & 0xFFFF80FFU) == 0x00000000U) && ((__SOURCE__) != 0x00000000U))
|
||||
|
||||
#define IS_TIM_CHANNELS(__CHANNEL__) (((__CHANNEL__) == TIM_CHANNEL_1) || \
|
||||
((__CHANNEL__) == TIM_CHANNEL_2) || \
|
||||
((__CHANNEL__) == TIM_CHANNEL_3) || \
|
||||
((__CHANNEL__) == TIM_CHANNEL_4) || \
|
||||
((__CHANNEL__) == TIM_CHANNEL_ALL))
|
||||
|
||||
#define IS_TIM_OPM_CHANNELS(__CHANNEL__) (((__CHANNEL__) == TIM_CHANNEL_1) || \
|
||||
((__CHANNEL__) == TIM_CHANNEL_2))
|
||||
|
||||
#define IS_TIM_COMPLEMENTARY_CHANNELS(__CHANNEL__) (((__CHANNEL__) == TIM_CHANNEL_1) || \
|
||||
((__CHANNEL__) == TIM_CHANNEL_2) || \
|
||||
((__CHANNEL__) == TIM_CHANNEL_3))
|
||||
|
||||
#define IS_TIM_CLOCKSOURCE(__CLOCK__) (((__CLOCK__) == TIM_CLOCKSOURCE_INTERNAL) || \
|
||||
((__CLOCK__) == TIM_CLOCKSOURCE_ETRMODE2) || \
|
||||
((__CLOCK__) == TIM_CLOCKSOURCE_ITR0) || \
|
||||
((__CLOCK__) == TIM_CLOCKSOURCE_ITR1) || \
|
||||
((__CLOCK__) == TIM_CLOCKSOURCE_ITR2) || \
|
||||
((__CLOCK__) == TIM_CLOCKSOURCE_ITR3) || \
|
||||
((__CLOCK__) == TIM_CLOCKSOURCE_TI1ED) || \
|
||||
((__CLOCK__) == TIM_CLOCKSOURCE_TI1) || \
|
||||
((__CLOCK__) == TIM_CLOCKSOURCE_TI2) || \
|
||||
((__CLOCK__) == TIM_CLOCKSOURCE_ETRMODE1))
|
||||
|
||||
#define IS_TIM_CLOCKPOLARITY(__POLARITY__) (((__POLARITY__) == TIM_CLOCKPOLARITY_INVERTED) || \
|
||||
((__POLARITY__) == TIM_CLOCKPOLARITY_NONINVERTED) || \
|
||||
((__POLARITY__) == TIM_CLOCKPOLARITY_RISING) || \
|
||||
((__POLARITY__) == TIM_CLOCKPOLARITY_FALLING) || \
|
||||
((__POLARITY__) == TIM_CLOCKPOLARITY_BOTHEDGE))
|
||||
|
||||
#define IS_TIM_CLOCKPRESCALER(__PRESCALER__) (((__PRESCALER__) == TIM_CLOCKPRESCALER_DIV1) || \
|
||||
((__PRESCALER__) == TIM_CLOCKPRESCALER_DIV2) || \
|
||||
((__PRESCALER__) == TIM_CLOCKPRESCALER_DIV4) || \
|
||||
((__PRESCALER__) == TIM_CLOCKPRESCALER_DIV8))
|
||||
|
||||
#define IS_TIM_CLOCKFILTER(__ICFILTER__) ((__ICFILTER__) <= 0xFU)
|
||||
|
||||
#define IS_TIM_CLEARINPUT_POLARITY(__POLARITY__) (((__POLARITY__) == TIM_CLEARINPUTPOLARITY_INVERTED) || \
|
||||
((__POLARITY__) == TIM_CLEARINPUTPOLARITY_NONINVERTED))
|
||||
|
||||
#define IS_TIM_CLEARINPUT_PRESCALER(__PRESCALER__) (((__PRESCALER__) == TIM_CLEARINPUTPRESCALER_DIV1) || \
|
||||
((__PRESCALER__) == TIM_CLEARINPUTPRESCALER_DIV2) || \
|
||||
((__PRESCALER__) == TIM_CLEARINPUTPRESCALER_DIV4) || \
|
||||
((__PRESCALER__) == TIM_CLEARINPUTPRESCALER_DIV8))
|
||||
|
||||
#define IS_TIM_CLEARINPUT_FILTER(__ICFILTER__) ((__ICFILTER__) <= 0xFU)
|
||||
|
||||
#define IS_TIM_OSSR_STATE(__STATE__) (((__STATE__) == TIM_OSSR_ENABLE) || \
|
||||
((__STATE__) == TIM_OSSR_DISABLE))
|
||||
|
||||
#define IS_TIM_OSSI_STATE(__STATE__) (((__STATE__) == TIM_OSSI_ENABLE) || \
|
||||
((__STATE__) == TIM_OSSI_DISABLE))
|
||||
|
||||
#define IS_TIM_LOCK_LEVEL(__LEVEL__) (((__LEVEL__) == TIM_LOCKLEVEL_OFF) || \
|
||||
((__LEVEL__) == TIM_LOCKLEVEL_1) || \
|
||||
((__LEVEL__) == TIM_LOCKLEVEL_2) || \
|
||||
((__LEVEL__) == TIM_LOCKLEVEL_3))
|
||||
|
||||
#define IS_TIM_BREAK_FILTER(__BRKFILTER__) ((__BRKFILTER__) <= 0xFUL)
|
||||
|
||||
|
||||
#define IS_TIM_BREAK_STATE(__STATE__) (((__STATE__) == TIM_BREAK_ENABLE) || \
|
||||
((__STATE__) == TIM_BREAK_DISABLE))
|
||||
|
||||
#define IS_TIM_BREAK_POLARITY(__POLARITY__) (((__POLARITY__) == TIM_BREAKPOLARITY_LOW) || \
|
||||
((__POLARITY__) == TIM_BREAKPOLARITY_HIGH))
|
||||
|
||||
#define IS_TIM_AUTOMATIC_OUTPUT_STATE(__STATE__) (((__STATE__) == TIM_AUTOMATICOUTPUT_ENABLE) || \
|
||||
((__STATE__) == TIM_AUTOMATICOUTPUT_DISABLE))
|
||||
|
||||
#define IS_TIM_TRGO_SOURCE(__SOURCE__) (((__SOURCE__) == TIM_TRGO_RESET) || \
|
||||
((__SOURCE__) == TIM_TRGO_ENABLE) || \
|
||||
((__SOURCE__) == TIM_TRGO_UPDATE) || \
|
||||
((__SOURCE__) == TIM_TRGO_OC1) || \
|
||||
((__SOURCE__) == TIM_TRGO_OC1REF) || \
|
||||
((__SOURCE__) == TIM_TRGO_OC2REF) || \
|
||||
((__SOURCE__) == TIM_TRGO_OC3REF) || \
|
||||
((__SOURCE__) == TIM_TRGO_OC4REF))
|
||||
|
||||
#define IS_TIM_MSM_STATE(__STATE__) (((__STATE__) == TIM_MASTERSLAVEMODE_ENABLE) || \
|
||||
((__STATE__) == TIM_MASTERSLAVEMODE_DISABLE))
|
||||
|
||||
#define IS_TIM_SLAVE_MODE(__MODE__) (((__MODE__) == TIM_SLAVEMODE_DISABLE) || \
|
||||
((__MODE__) == TIM_SLAVEMODE_RESET) || \
|
||||
((__MODE__) == TIM_SLAVEMODE_GATED) || \
|
||||
((__MODE__) == TIM_SLAVEMODE_TRIGGER) || \
|
||||
((__MODE__) == TIM_SLAVEMODE_EXTERNAL1))
|
||||
|
||||
#define IS_TIM_PWM_MODE(__MODE__) (((__MODE__) == TIM_OCMODE_PWM1) || \
|
||||
((__MODE__) == TIM_OCMODE_PWM2))
|
||||
|
||||
#define IS_TIM_OC_MODE(__MODE__) (((__MODE__) == TIM_OCMODE_TIMING) || \
|
||||
((__MODE__) == TIM_OCMODE_ACTIVE) || \
|
||||
((__MODE__) == TIM_OCMODE_INACTIVE) || \
|
||||
((__MODE__) == TIM_OCMODE_TOGGLE) || \
|
||||
((__MODE__) == TIM_OCMODE_FORCED_ACTIVE) || \
|
||||
((__MODE__) == TIM_OCMODE_FORCED_INACTIVE))
|
||||
|
||||
#define IS_TIM_TRIGGER_SELECTION(__SELECTION__) (((__SELECTION__) == TIM_TS_ITR0) || \
|
||||
((__SELECTION__) == TIM_TS_ITR1) || \
|
||||
((__SELECTION__) == TIM_TS_ITR2) || \
|
||||
((__SELECTION__) == TIM_TS_ITR3) || \
|
||||
((__SELECTION__) == TIM_TS_TI1F_ED) || \
|
||||
((__SELECTION__) == TIM_TS_TI1FP1) || \
|
||||
((__SELECTION__) == TIM_TS_TI2FP2) || \
|
||||
((__SELECTION__) == TIM_TS_ETRF))
|
||||
|
||||
#define IS_TIM_INTERNAL_TRIGGEREVENT_SELECTION(__SELECTION__) (((__SELECTION__) == TIM_TS_ITR0) || \
|
||||
((__SELECTION__) == TIM_TS_ITR1) || \
|
||||
((__SELECTION__) == TIM_TS_ITR2) || \
|
||||
((__SELECTION__) == TIM_TS_ITR3) || \
|
||||
((__SELECTION__) == TIM_TS_NONE))
|
||||
|
||||
#define IS_TIM_TRIGGERPOLARITY(__POLARITY__) (((__POLARITY__) == TIM_TRIGGERPOLARITY_INVERTED ) || \
|
||||
((__POLARITY__) == TIM_TRIGGERPOLARITY_NONINVERTED) || \
|
||||
((__POLARITY__) == TIM_TRIGGERPOLARITY_RISING ) || \
|
||||
((__POLARITY__) == TIM_TRIGGERPOLARITY_FALLING ) || \
|
||||
((__POLARITY__) == TIM_TRIGGERPOLARITY_BOTHEDGE ))
|
||||
|
||||
#define IS_TIM_TRIGGERPRESCALER(__PRESCALER__) (((__PRESCALER__) == TIM_TRIGGERPRESCALER_DIV1) || \
|
||||
((__PRESCALER__) == TIM_TRIGGERPRESCALER_DIV2) || \
|
||||
((__PRESCALER__) == TIM_TRIGGERPRESCALER_DIV4) || \
|
||||
((__PRESCALER__) == TIM_TRIGGERPRESCALER_DIV8))
|
||||
|
||||
#define IS_TIM_TRIGGERFILTER(__ICFILTER__) ((__ICFILTER__) <= 0xFU)
|
||||
|
||||
#define IS_TIM_TI1SELECTION(__TI1SELECTION__) (((__TI1SELECTION__) == TIM_TI1SELECTION_CH1) || \
|
||||
((__TI1SELECTION__) == TIM_TI1SELECTION_XORCOMBINATION))
|
||||
|
||||
#if (defined(DMA) || defined(DMA1))
|
||||
#define IS_TIM_DMA_LENGTH(__LENGTH__) (((__LENGTH__) == TIM_DMABURSTLENGTH_1TRANSFER) || \
|
||||
((__LENGTH__) == TIM_DMABURSTLENGTH_2TRANSFERS) || \
|
||||
((__LENGTH__) == TIM_DMABURSTLENGTH_3TRANSFERS) || \
|
||||
((__LENGTH__) == TIM_DMABURSTLENGTH_4TRANSFERS) || \
|
||||
((__LENGTH__) == TIM_DMABURSTLENGTH_5TRANSFERS) || \
|
||||
((__LENGTH__) == TIM_DMABURSTLENGTH_6TRANSFERS) || \
|
||||
((__LENGTH__) == TIM_DMABURSTLENGTH_7TRANSFERS) || \
|
||||
((__LENGTH__) == TIM_DMABURSTLENGTH_8TRANSFERS) || \
|
||||
((__LENGTH__) == TIM_DMABURSTLENGTH_9TRANSFERS) || \
|
||||
((__LENGTH__) == TIM_DMABURSTLENGTH_10TRANSFERS) || \
|
||||
((__LENGTH__) == TIM_DMABURSTLENGTH_11TRANSFERS) || \
|
||||
((__LENGTH__) == TIM_DMABURSTLENGTH_12TRANSFERS) || \
|
||||
((__LENGTH__) == TIM_DMABURSTLENGTH_13TRANSFERS) || \
|
||||
((__LENGTH__) == TIM_DMABURSTLENGTH_14TRANSFERS) || \
|
||||
((__LENGTH__) == TIM_DMABURSTLENGTH_15TRANSFERS) || \
|
||||
((__LENGTH__) == TIM_DMABURSTLENGTH_16TRANSFERS) || \
|
||||
((__LENGTH__) == TIM_DMABURSTLENGTH_17TRANSFERS) || \
|
||||
((__LENGTH__) == TIM_DMABURSTLENGTH_18TRANSFERS))
|
||||
|
||||
#define IS_TIM_DMA_DATA_LENGTH(LENGTH) (((LENGTH) >= 0x1U) && ((LENGTH) < 0x10000U))
|
||||
#endif
|
||||
|
||||
#define IS_TIM_IC_FILTER(__ICFILTER__) ((__ICFILTER__) <= 0xFU)
|
||||
|
||||
#define IS_TIM_DEADTIME(__DEADTIME__) ((__DEADTIME__) <= 0xFFU)
|
||||
|
||||
#define IS_TIM_SLAVEMODE_TRIGGER_ENABLED(__TRIGGER__) ((__TRIGGER__) == TIM_SLAVEMODE_TRIGGER)
|
||||
|
||||
#define TIM_SET_ICPRESCALERVALUE(__HANDLE__, __CHANNEL__, __ICPSC__) \
|
||||
(((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCMR1 |= (__ICPSC__)) :\
|
||||
((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCMR1 |= ((__ICPSC__) << 8U)) :\
|
||||
((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCMR2 |= (__ICPSC__)) :\
|
||||
((__HANDLE__)->Instance->CCMR2 |= ((__ICPSC__) << 8U)))
|
||||
|
||||
#define TIM_RESET_ICPRESCALERVALUE(__HANDLE__, __CHANNEL__) \
|
||||
(((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCMR1 &= ~TIM_CCMR1_IC1PSC) :\
|
||||
((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCMR1 &= ~TIM_CCMR1_IC2PSC) :\
|
||||
((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCMR2 &= ~TIM_CCMR2_IC3PSC) :\
|
||||
((__HANDLE__)->Instance->CCMR2 &= ~TIM_CCMR2_IC4PSC))
|
||||
|
||||
#define TIM_SET_CAPTUREPOLARITY(__HANDLE__, __CHANNEL__, __POLARITY__) \
|
||||
(((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCER |= (__POLARITY__)) :\
|
||||
((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCER |= ((__POLARITY__) << 4U)) :\
|
||||
((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCER |= ((__POLARITY__) << 8U)) :\
|
||||
((__HANDLE__)->Instance->CCER |= (((__POLARITY__) << 12U))))
|
||||
|
||||
#define TIM_RESET_CAPTUREPOLARITY(__HANDLE__, __CHANNEL__) \
|
||||
(((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCER &= ~(TIM_CCER_CC1P | TIM_CCER_CC1NP)) :\
|
||||
((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCER &= ~(TIM_CCER_CC2P | TIM_CCER_CC2NP)) :\
|
||||
((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCER &= ~(TIM_CCER_CC3P | TIM_CCER_CC3NP)) :\
|
||||
((__HANDLE__)->Instance->CCER &= ~(TIM_CCER_CC4P | TIM_CCER_CC4NP)))
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/* End of private macros -----------------------------------------------------*/
|
||||
|
||||
/* Include TIM HAL Extended module */
|
||||
#include "py32f0xx_hal_tim_ex.h"
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/** @addtogroup TIM_Exported_Functions TIM Exported Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup TIM_Exported_Functions_Group1 TIM Time Base functions
|
||||
* @brief Time Base functions
|
||||
* @{
|
||||
*/
|
||||
/* Time Base functions ********************************************************/
|
||||
HAL_StatusTypeDef HAL_TIM_Base_Init(TIM_HandleTypeDef *htim);
|
||||
HAL_StatusTypeDef HAL_TIM_Base_DeInit(TIM_HandleTypeDef *htim);
|
||||
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim);
|
||||
void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef *htim);
|
||||
/* Blocking mode: Polling */
|
||||
HAL_StatusTypeDef HAL_TIM_Base_Start(TIM_HandleTypeDef *htim);
|
||||
HAL_StatusTypeDef HAL_TIM_Base_Stop(TIM_HandleTypeDef *htim);
|
||||
/* Non-Blocking mode: Interrupt */
|
||||
HAL_StatusTypeDef HAL_TIM_Base_Start_IT(TIM_HandleTypeDef *htim);
|
||||
HAL_StatusTypeDef HAL_TIM_Base_Stop_IT(TIM_HandleTypeDef *htim);
|
||||
#if (defined(DMA) || defined(DMA1))
|
||||
/* Non-Blocking mode: DMA */
|
||||
HAL_StatusTypeDef HAL_TIM_Base_Start_DMA(TIM_HandleTypeDef *htim, uint32_t *pData, uint16_t Length);
|
||||
HAL_StatusTypeDef HAL_TIM_Base_Stop_DMA(TIM_HandleTypeDef *htim);
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup TIM_Exported_Functions_Group2 TIM Output Compare functions
|
||||
* @brief TIM Output Compare functions
|
||||
* @{
|
||||
*/
|
||||
/* Timer Output Compare functions *********************************************/
|
||||
HAL_StatusTypeDef HAL_TIM_OC_Init(TIM_HandleTypeDef *htim);
|
||||
HAL_StatusTypeDef HAL_TIM_OC_DeInit(TIM_HandleTypeDef *htim);
|
||||
void HAL_TIM_OC_MspInit(TIM_HandleTypeDef *htim);
|
||||
void HAL_TIM_OC_MspDeInit(TIM_HandleTypeDef *htim);
|
||||
/* Blocking mode: Polling */
|
||||
HAL_StatusTypeDef HAL_TIM_OC_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||
HAL_StatusTypeDef HAL_TIM_OC_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||
/* Non-Blocking mode: Interrupt */
|
||||
HAL_StatusTypeDef HAL_TIM_OC_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||
HAL_StatusTypeDef HAL_TIM_OC_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||
#if (defined(DMA) || defined(DMA1))
|
||||
/* Non-Blocking mode: DMA */
|
||||
HAL_StatusTypeDef HAL_TIM_OC_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length);
|
||||
HAL_StatusTypeDef HAL_TIM_OC_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup TIM_Exported_Functions_Group3 TIM PWM functions
|
||||
* @brief TIM PWM functions
|
||||
* @{
|
||||
*/
|
||||
/* Timer PWM functions ********************************************************/
|
||||
HAL_StatusTypeDef HAL_TIM_PWM_Init(TIM_HandleTypeDef *htim);
|
||||
HAL_StatusTypeDef HAL_TIM_PWM_DeInit(TIM_HandleTypeDef *htim);
|
||||
void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef *htim);
|
||||
void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef *htim);
|
||||
/* Blocking mode: Polling */
|
||||
HAL_StatusTypeDef HAL_TIM_PWM_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||
HAL_StatusTypeDef HAL_TIM_PWM_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||
/* Non-Blocking mode: Interrupt */
|
||||
HAL_StatusTypeDef HAL_TIM_PWM_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||
HAL_StatusTypeDef HAL_TIM_PWM_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||
#if (defined(DMA) || defined(DMA1))
|
||||
/* Non-Blocking mode: DMA */
|
||||
HAL_StatusTypeDef HAL_TIM_PWM_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length);
|
||||
HAL_StatusTypeDef HAL_TIM_PWM_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup TIM_Exported_Functions_Group4 TIM Input Capture functions
|
||||
* @brief TIM Input Capture functions
|
||||
* @{
|
||||
*/
|
||||
/* Timer Input Capture functions **********************************************/
|
||||
HAL_StatusTypeDef HAL_TIM_IC_Init(TIM_HandleTypeDef *htim);
|
||||
HAL_StatusTypeDef HAL_TIM_IC_DeInit(TIM_HandleTypeDef *htim);
|
||||
void HAL_TIM_IC_MspInit(TIM_HandleTypeDef *htim);
|
||||
void HAL_TIM_IC_MspDeInit(TIM_HandleTypeDef *htim);
|
||||
/* Blocking mode: Polling */
|
||||
HAL_StatusTypeDef HAL_TIM_IC_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||
HAL_StatusTypeDef HAL_TIM_IC_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||
/* Non-Blocking mode: Interrupt */
|
||||
HAL_StatusTypeDef HAL_TIM_IC_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||
HAL_StatusTypeDef HAL_TIM_IC_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||
#if (defined(DMA) || defined(DMA1))
|
||||
/* Non-Blocking mode: DMA */
|
||||
HAL_StatusTypeDef HAL_TIM_IC_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length);
|
||||
HAL_StatusTypeDef HAL_TIM_IC_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup TIM_Exported_Functions_Group5 TIM One Pulse functions
|
||||
* @brief TIM One Pulse functions
|
||||
* @{
|
||||
*/
|
||||
/* Timer One Pulse functions **************************************************/
|
||||
HAL_StatusTypeDef HAL_TIM_OnePulse_Init(TIM_HandleTypeDef *htim, uint32_t OnePulseMode);
|
||||
HAL_StatusTypeDef HAL_TIM_OnePulse_DeInit(TIM_HandleTypeDef *htim);
|
||||
void HAL_TIM_OnePulse_MspInit(TIM_HandleTypeDef *htim);
|
||||
void HAL_TIM_OnePulse_MspDeInit(TIM_HandleTypeDef *htim);
|
||||
/* Blocking mode: Polling */
|
||||
HAL_StatusTypeDef HAL_TIM_OnePulse_Start(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
|
||||
HAL_StatusTypeDef HAL_TIM_OnePulse_Stop(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
|
||||
/* Non-Blocking mode: Interrupt */
|
||||
HAL_StatusTypeDef HAL_TIM_OnePulse_Start_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
|
||||
HAL_StatusTypeDef HAL_TIM_OnePulse_Stop_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup TIM_Exported_Functions_Group6 TIM Encoder functions
|
||||
* @brief TIM Encoder functions
|
||||
* @{
|
||||
*/
|
||||
/* Timer Encoder functions ****************************************************/
|
||||
HAL_StatusTypeDef HAL_TIM_Encoder_Init(TIM_HandleTypeDef *htim, TIM_Encoder_InitTypeDef *sConfig);
|
||||
HAL_StatusTypeDef HAL_TIM_Encoder_DeInit(TIM_HandleTypeDef *htim);
|
||||
void HAL_TIM_Encoder_MspInit(TIM_HandleTypeDef *htim);
|
||||
void HAL_TIM_Encoder_MspDeInit(TIM_HandleTypeDef *htim);
|
||||
/* Blocking mode: Polling */
|
||||
HAL_StatusTypeDef HAL_TIM_Encoder_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||
HAL_StatusTypeDef HAL_TIM_Encoder_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||
/* Non-Blocking mode: Interrupt */
|
||||
HAL_StatusTypeDef HAL_TIM_Encoder_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||
HAL_StatusTypeDef HAL_TIM_Encoder_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||
#if (defined(DMA) || defined(DMA1))
|
||||
/* Non-Blocking mode: DMA */
|
||||
HAL_StatusTypeDef HAL_TIM_Encoder_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData1,
|
||||
uint32_t *pData2, uint16_t Length);
|
||||
HAL_StatusTypeDef HAL_TIM_Encoder_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup TIM_Exported_Functions_Group7 TIM IRQ handler management
|
||||
* @brief IRQ handler management
|
||||
* @{
|
||||
*/
|
||||
/* Interrupt Handler functions ***********************************************/
|
||||
void HAL_TIM_IRQHandler(TIM_HandleTypeDef *htim);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup TIM_Exported_Functions_Group8 TIM Peripheral Control functions
|
||||
* @brief Peripheral Control functions
|
||||
* @{
|
||||
*/
|
||||
/* Control functions *********************************************************/
|
||||
HAL_StatusTypeDef HAL_TIM_OC_ConfigChannel(TIM_HandleTypeDef *htim, TIM_OC_InitTypeDef *sConfig, uint32_t Channel);
|
||||
HAL_StatusTypeDef HAL_TIM_PWM_ConfigChannel(TIM_HandleTypeDef *htim, TIM_OC_InitTypeDef *sConfig, uint32_t Channel);
|
||||
HAL_StatusTypeDef HAL_TIM_IC_ConfigChannel(TIM_HandleTypeDef *htim, TIM_IC_InitTypeDef *sConfig, uint32_t Channel);
|
||||
HAL_StatusTypeDef HAL_TIM_OnePulse_ConfigChannel(TIM_HandleTypeDef *htim, TIM_OnePulse_InitTypeDef *sConfig,
|
||||
uint32_t OutputChannel, uint32_t InputChannel);
|
||||
HAL_StatusTypeDef HAL_TIM_ConfigOCrefClear(TIM_HandleTypeDef *htim, TIM_ClearInputConfigTypeDef *sClearInputConfig,
|
||||
uint32_t Channel);
|
||||
HAL_StatusTypeDef HAL_TIM_ConfigClockSource(TIM_HandleTypeDef *htim, TIM_ClockConfigTypeDef *sClockSourceConfig);
|
||||
HAL_StatusTypeDef HAL_TIM_ConfigTI1Input(TIM_HandleTypeDef *htim, uint32_t TI1_Selection);
|
||||
HAL_StatusTypeDef HAL_TIM_SlaveConfigSynchro(TIM_HandleTypeDef *htim, TIM_SlaveConfigTypeDef *sSlaveConfig);
|
||||
HAL_StatusTypeDef HAL_TIM_SlaveConfigSynchro_IT(TIM_HandleTypeDef *htim, TIM_SlaveConfigTypeDef *sSlaveConfig);
|
||||
#if (defined(DMA) || defined(DMA1))
|
||||
HAL_StatusTypeDef HAL_TIM_DMABurst_WriteStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress,
|
||||
uint32_t BurstRequestSrc, uint32_t *BurstBuffer, uint32_t BurstLength);
|
||||
HAL_StatusTypeDef HAL_TIM_DMABurst_MultiWriteStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress,
|
||||
uint32_t BurstRequestSrc, uint32_t *BurstBuffer, uint32_t BurstLength,
|
||||
uint32_t DataLength);
|
||||
HAL_StatusTypeDef HAL_TIM_DMABurst_WriteStop(TIM_HandleTypeDef *htim, uint32_t BurstRequestSrc);
|
||||
HAL_StatusTypeDef HAL_TIM_DMABurst_ReadStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress,
|
||||
uint32_t BurstRequestSrc, uint32_t *BurstBuffer, uint32_t BurstLength);
|
||||
HAL_StatusTypeDef HAL_TIM_DMABurst_MultiReadStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress,
|
||||
uint32_t BurstRequestSrc, uint32_t *BurstBuffer, uint32_t BurstLength,
|
||||
uint32_t DataLength);
|
||||
HAL_StatusTypeDef HAL_TIM_DMABurst_ReadStop(TIM_HandleTypeDef *htim, uint32_t BurstRequestSrc);
|
||||
#endif
|
||||
HAL_StatusTypeDef HAL_TIM_GenerateEvent(TIM_HandleTypeDef *htim, uint32_t EventSource);
|
||||
uint32_t HAL_TIM_ReadCapturedValue(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup TIM_Exported_Functions_Group9 TIM Callbacks functions
|
||||
* @brief TIM Callbacks functions
|
||||
* @{
|
||||
*/
|
||||
/* Callback in non blocking modes (Interrupt and DMA) *************************/
|
||||
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim);
|
||||
void HAL_TIM_PeriodElapsedHalfCpltCallback(TIM_HandleTypeDef *htim);
|
||||
void HAL_TIM_OC_DelayElapsedCallback(TIM_HandleTypeDef *htim);
|
||||
void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim);
|
||||
void HAL_TIM_IC_CaptureHalfCpltCallback(TIM_HandleTypeDef *htim);
|
||||
void HAL_TIM_PWM_PulseFinishedCallback(TIM_HandleTypeDef *htim);
|
||||
void HAL_TIM_PWM_PulseFinishedHalfCpltCallback(TIM_HandleTypeDef *htim);
|
||||
void HAL_TIM_TriggerCallback(TIM_HandleTypeDef *htim);
|
||||
void HAL_TIM_TriggerHalfCpltCallback(TIM_HandleTypeDef *htim);
|
||||
void HAL_TIM_ErrorCallback(TIM_HandleTypeDef *htim);
|
||||
|
||||
/* Callbacks Register/UnRegister functions ***********************************/
|
||||
#if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
|
||||
HAL_StatusTypeDef HAL_TIM_RegisterCallback(TIM_HandleTypeDef *htim, HAL_TIM_CallbackIDTypeDef CallbackID,
|
||||
pTIM_CallbackTypeDef pCallback);
|
||||
HAL_StatusTypeDef HAL_TIM_UnRegisterCallback(TIM_HandleTypeDef *htim, HAL_TIM_CallbackIDTypeDef CallbackID);
|
||||
#endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup TIM_Exported_Functions_Group10 TIM Peripheral State functions
|
||||
* @brief Peripheral State functions
|
||||
* @{
|
||||
*/
|
||||
/* Peripheral State functions ************************************************/
|
||||
HAL_TIM_StateTypeDef HAL_TIM_Base_GetState(TIM_HandleTypeDef *htim);
|
||||
HAL_TIM_StateTypeDef HAL_TIM_OC_GetState(TIM_HandleTypeDef *htim);
|
||||
HAL_TIM_StateTypeDef HAL_TIM_PWM_GetState(TIM_HandleTypeDef *htim);
|
||||
HAL_TIM_StateTypeDef HAL_TIM_IC_GetState(TIM_HandleTypeDef *htim);
|
||||
HAL_TIM_StateTypeDef HAL_TIM_OnePulse_GetState(TIM_HandleTypeDef *htim);
|
||||
HAL_TIM_StateTypeDef HAL_TIM_Encoder_GetState(TIM_HandleTypeDef *htim);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/* End of exported functions -------------------------------------------------*/
|
||||
|
||||
/* Private functions----------------------------------------------------------*/
|
||||
/** @defgroup TIM_Private_Functions TIM Private Functions
|
||||
* @{
|
||||
*/
|
||||
void TIM_Base_SetConfig(TIM_TypeDef *TIMx, TIM_Base_InitTypeDef *Structure);
|
||||
void TIM_TI1_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection, uint32_t TIM_ICFilter);
|
||||
void TIM_OC2_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config);
|
||||
void TIM_ETR_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ExtTRGPrescaler,
|
||||
uint32_t TIM_ExtTRGPolarity, uint32_t ExtTRGFilter);
|
||||
#if (defined(DMA) || defined(DMA1))
|
||||
void TIM_DMADelayPulseCplt(DMA_HandleTypeDef *hdma);
|
||||
void TIM_DMADelayPulseHalfCplt(DMA_HandleTypeDef *hdma);
|
||||
void TIM_DMAError(DMA_HandleTypeDef *hdma);
|
||||
void TIM_DMACaptureCplt(DMA_HandleTypeDef *hdma);
|
||||
void TIM_DMACaptureHalfCplt(DMA_HandleTypeDef *hdma);
|
||||
#endif
|
||||
void TIM_CCxChannelCmd(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t ChannelState);
|
||||
|
||||
#if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
|
||||
void TIM_ResetCallback(TIM_HandleTypeDef *htim);
|
||||
#endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/* End of private functions --------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* py32f0xx_HAL_TIM_H */
|
||||
|
||||
/************************ (C) COPYRIGHT Puya *****END OF FILE****/
|
||||
272
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_tim_ex.h
Normal file
272
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_tim_ex.h
Normal file
@@ -0,0 +1,272 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file py32f0xx_hal_tim_ex.h
|
||||
* @author MCU Application Team
|
||||
* @brief Header file of TIM HAL Extended module.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) Puya Semiconductor Co.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __PY32F0xx_HAL_TIM_EX_H
|
||||
#define __PY32F0xx_HAL_TIM_EX_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "py32f0xx_hal_def.h"
|
||||
|
||||
/** @addtogroup PY32F0xx_HAL_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup TIMEx
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/** @defgroup TIMEx_Exported_Types TIM Extended Exported Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief TIM Hall sensor Configuration Structure definition
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t IC1Polarity; /*!< Specifies the active edge of the input signal.
|
||||
This parameter can be a value of @ref TIM_Input_Capture_Polarity */
|
||||
|
||||
uint32_t IC1Prescaler; /*!< Specifies the Input Capture Prescaler.
|
||||
This parameter can be a value of @ref TIM_Input_Capture_Prescaler */
|
||||
|
||||
uint32_t IC1Filter; /*!< Specifies the input capture filter.
|
||||
This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */
|
||||
|
||||
uint32_t Commutation_Delay; /*!< Specifies the pulse value to be loaded into the Capture Compare Register.
|
||||
This parameter can be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF */
|
||||
} TIM_HallSensor_InitTypeDef;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/* End of exported types -----------------------------------------------------*/
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/** @defgroup TIMEx_Exported_Constants TIM Extended Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup TIMEx_Remap TIM Extended Remapping
|
||||
* @{
|
||||
*/
|
||||
#define TIM_TIM14_GPIO (0x00000000U) /*!< TIM_MB TI1 is connected to GPIO */
|
||||
#define TIM_TIM14_RTC (0x00000001U) /*!< TIM_MB TI1 is connected to RTC_clock */
|
||||
#define TIM_TIM14_HSE (0x00000002U) /*!< TIM_MB TI1 is connected to HSE/32U */
|
||||
#define TIM_TIM14_MCO (0x00000003U) /*!< TIM_MB TI1 is connected to MCO */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/* End of exported constants -------------------------------------------------*/
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/** @defgroup TIMEx_Exported_Macros TIM Extended Exported Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/* End of exported macro -----------------------------------------------------*/
|
||||
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/** @defgroup TIMEx_Private_Macros TIM Extended Private Macros
|
||||
* @{
|
||||
*/
|
||||
#define IS_TIM_REMAP(__INSTANCE__, __REMAP__) \
|
||||
(((__INSTANCE__) == TIM_MB) && (((__REMAP__) & 0xFFFFFFFCU) == 0x00000000U))
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/* End of private macro ------------------------------------------------------*/
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/** @addtogroup TIMEx_Exported_Functions TIM Extended Exported Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup TIMEx_Exported_Functions_Group1 Extended Timer Hall Sensor functions
|
||||
* @brief Timer Hall Sensor functions
|
||||
* @{
|
||||
*/
|
||||
/* Timer Hall Sensor functions **********************************************/
|
||||
HAL_StatusTypeDef HAL_TIMEx_HallSensor_Init(TIM_HandleTypeDef *htim, TIM_HallSensor_InitTypeDef *sConfig);
|
||||
HAL_StatusTypeDef HAL_TIMEx_HallSensor_DeInit(TIM_HandleTypeDef *htim);
|
||||
|
||||
void HAL_TIMEx_HallSensor_MspInit(TIM_HandleTypeDef *htim);
|
||||
void HAL_TIMEx_HallSensor_MspDeInit(TIM_HandleTypeDef *htim);
|
||||
|
||||
/* Blocking mode: Polling */
|
||||
HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start(TIM_HandleTypeDef *htim);
|
||||
HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop(TIM_HandleTypeDef *htim);
|
||||
/* Non-Blocking mode: Interrupt */
|
||||
HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_IT(TIM_HandleTypeDef *htim);
|
||||
HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_IT(TIM_HandleTypeDef *htim);
|
||||
/* Non-Blocking mode: DMA */
|
||||
HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_DMA(TIM_HandleTypeDef *htim, uint32_t *pData, uint16_t Length);
|
||||
HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_DMA(TIM_HandleTypeDef *htim);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup TIMEx_Exported_Functions_Group2 Extended Timer Complementary Output Compare functions
|
||||
* @brief Timer Complementary Output Compare functions
|
||||
* @{
|
||||
*/
|
||||
/* Timer Complementary Output Compare functions *****************************/
|
||||
/* Blocking mode: Polling */
|
||||
HAL_StatusTypeDef HAL_TIMEx_OCN_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||
HAL_StatusTypeDef HAL_TIMEx_OCN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||
|
||||
/* Non-Blocking mode: Interrupt */
|
||||
HAL_StatusTypeDef HAL_TIMEx_OCN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||
HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||
|
||||
/* Non-Blocking mode: DMA */
|
||||
HAL_StatusTypeDef HAL_TIMEx_OCN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length);
|
||||
HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup TIMEx_Exported_Functions_Group3 Extended Timer Complementary PWM functions
|
||||
* @brief Timer Complementary PWM functions
|
||||
* @{
|
||||
*/
|
||||
/* Timer Complementary PWM functions ****************************************/
|
||||
/* Blocking mode: Polling */
|
||||
HAL_StatusTypeDef HAL_TIMEx_PWMN_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||
HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||
|
||||
/* Non-Blocking mode: Interrupt */
|
||||
HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||
HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||
/* Non-Blocking mode: DMA */
|
||||
HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length);
|
||||
HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup TIMEx_Exported_Functions_Group4 Extended Timer Complementary One Pulse functions
|
||||
* @brief Timer Complementary One Pulse functions
|
||||
* @{
|
||||
*/
|
||||
/* Timer Complementary One Pulse functions **********************************/
|
||||
/* Blocking mode: Polling */
|
||||
HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
|
||||
HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
|
||||
|
||||
/* Non-Blocking mode: Interrupt */
|
||||
HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
|
||||
HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup TIMEx_Exported_Functions_Group5 Extended Peripheral Control functions
|
||||
* @brief Peripheral Control functions
|
||||
* @{
|
||||
*/
|
||||
/* Extended Control functions ************************************************/
|
||||
HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent(TIM_HandleTypeDef *htim, uint32_t InputTrigger,
|
||||
uint32_t CommutationSource);
|
||||
HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent_IT(TIM_HandleTypeDef *htim, uint32_t InputTrigger,
|
||||
uint32_t CommutationSource);
|
||||
HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent_DMA(TIM_HandleTypeDef *htim, uint32_t InputTrigger,
|
||||
uint32_t CommutationSource);
|
||||
HAL_StatusTypeDef HAL_TIMEx_MasterConfigSynchronization(TIM_HandleTypeDef *htim,
|
||||
TIM_MasterConfigTypeDef *sMasterConfig);
|
||||
HAL_StatusTypeDef HAL_TIMEx_ConfigBreakDeadTime(TIM_HandleTypeDef *htim,
|
||||
TIM_BreakDeadTimeConfigTypeDef *sBreakDeadTimeConfig);
|
||||
HAL_StatusTypeDef HAL_TIMEx_RemapConfig(TIM_HandleTypeDef *htim, uint32_t Remap);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup TIMEx_Exported_Functions_Group6 Extended Callbacks functions
|
||||
* @brief Extended Callbacks functions
|
||||
* @{
|
||||
*/
|
||||
/* Extended Callback **********************************************************/
|
||||
void HAL_TIMEx_CommutCallback(TIM_HandleTypeDef *htim);
|
||||
void HAL_TIMEx_CommutHalfCpltCallback(TIM_HandleTypeDef *htim);
|
||||
void HAL_TIMEx_BreakCallback(TIM_HandleTypeDef *htim);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup TIMEx_Exported_Functions_Group7 Extended Peripheral State functions
|
||||
* @brief Extended Peripheral State functions
|
||||
* @{
|
||||
*/
|
||||
/* Extended Peripheral State functions ***************************************/
|
||||
HAL_TIM_StateTypeDef HAL_TIMEx_HallSensor_GetState(TIM_HandleTypeDef *htim);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/* End of exported functions -------------------------------------------------*/
|
||||
|
||||
/* Private functions----------------------------------------------------------*/
|
||||
/** @addtogroup TIMEx_Private_Functions TIMEx Private Functions
|
||||
* @{
|
||||
*/
|
||||
#if (defined(DMA) || defined(DMA1))
|
||||
void TIMEx_DMACommutationCplt(DMA_HandleTypeDef *hdma);
|
||||
void TIMEx_DMACommutationHalfCplt(DMA_HandleTypeDef *hdma);
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/* End of private functions --------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* __PY32F0xx_HAL_TIM_EX_H */
|
||||
|
||||
/************************ (C) COPYRIGHT Puya *****END OF FILE****/
|
||||
899
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_uart.h
Normal file
899
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_uart.h
Normal file
@@ -0,0 +1,899 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file py32f0xx_hal_uart.h
|
||||
* @author MCU Application Team
|
||||
* @brief Header file of UART HAL module.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) Puya Semiconductor Co.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __PY32F0xx_HAL_UART_H
|
||||
#define __PY32F0xx_HAL_UART_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "py32f0xx_hal_def.h"
|
||||
|
||||
/** @addtogroup PY32F0xx_HAL_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup UART
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/** @defgroup UART_Exported_Types UART Exported Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief UART Init Structure definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t BaudRate; /*!< This member configures the UART communication baud rate.
|
||||
The baud rate is computed using the following formula:
|
||||
- IntegerDivider = ((PCLKx) / (16 * (huart->Init.BaudRate)))
|
||||
- FractionalDivider = ((IntegerDivider - ((uint32_t) IntegerDivider)) * 16) + 0.5 */
|
||||
|
||||
uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame.
|
||||
This parameter can be a value of @ref UART_Word_Length */
|
||||
|
||||
uint32_t StopBits; /*!< Specifies the number of stop bits transmitted.
|
||||
This parameter can be a value of @ref UART_Stop_Bits */
|
||||
|
||||
uint32_t Parity; /*!< Specifies the parity mode.
|
||||
This parameter can be a value of @ref UART_Parity
|
||||
@note When parity is enabled, the computed parity is inserted
|
||||
at the MSB position of the transmitted data (9th bit when
|
||||
the word length is set to 9 data bits; 8th bit when the
|
||||
word length is set to 8 data bits). */
|
||||
|
||||
uint32_t Mode; /*!< Specifies whether the Receive or Transmit mode is enabled or disabled.
|
||||
This parameter can be a value of @ref UART_Mode */
|
||||
|
||||
uint32_t HwFlowCtl; /*!< Specifies whether the hardware flow control mode is enabled or disabled.
|
||||
This parameter can be a value of @ref UART_Hardware_Flow_Control */
|
||||
|
||||
uint32_t OverSampling; /*!< Specifies whether the Over sampling 8 or Over sampling 16.
|
||||
This parameter can be a value of @ref UART_Over_Sampling. */
|
||||
} UART_InitTypeDef;
|
||||
|
||||
/**
|
||||
* @brief HAL UART State structures definition
|
||||
* @note HAL UART State value is a combination of 2 different substates: gState and RxState.
|
||||
* - gState contains UART state information related to global Handle management
|
||||
* and also information related to Tx operations.
|
||||
* gState value coding follow below described bitmap :
|
||||
* b7-b6 Error information
|
||||
* 00 : No Error
|
||||
* 01 : (Not Used)
|
||||
* 10 : Timeout
|
||||
* 11 : Error
|
||||
* b5 Peripheral initialization status
|
||||
* 0 : Reset (Peripheral not initialized)
|
||||
* 1 : Init done (Peripheral not initialized. HAL UART Init function already called)
|
||||
* b4-b3 (not used)
|
||||
* xx : Should be set to 00
|
||||
* b2 Intrinsic process state
|
||||
* 0 : Ready
|
||||
* 1 : Busy (Peripheral busy with some configuration or internal operations)
|
||||
* b1 (not used)
|
||||
* x : Should be set to 0
|
||||
* b0 Tx state
|
||||
* 0 : Ready (no Tx operation ongoing)
|
||||
* 1 : Busy (Tx operation ongoing)
|
||||
* - RxState contains information related to Rx operations.
|
||||
* RxState value coding follow below described bitmap :
|
||||
* b7-b6 (not used)
|
||||
* xx : Should be set to 00
|
||||
* b5 Peripheral initialization status
|
||||
* 0 : Reset (Peripheral not initialized)
|
||||
* 1 : Init done (Peripheral not initialized)
|
||||
* b4-b2 (not used)
|
||||
* xxx : Should be set to 000
|
||||
* b1 Rx state
|
||||
* 0 : Ready (no Rx operation ongoing)
|
||||
* 1 : Busy (Rx operation ongoing)
|
||||
* b0 (not used)
|
||||
* x : Should be set to 0.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
HAL_UART_STATE_RESET = 0x00U, /*!< Peripheral is not yet Initialized
|
||||
Value is allowed for gState and RxState */
|
||||
HAL_UART_STATE_READY = 0x20U, /*!< Peripheral Initialized and ready for use
|
||||
Value is allowed for gState and RxState */
|
||||
HAL_UART_STATE_BUSY = 0x24U, /*!< an internal process is ongoing
|
||||
Value is allowed for gState only */
|
||||
HAL_UART_STATE_BUSY_TX = 0x21U, /*!< Data Transmission process is ongoing
|
||||
Value is allowed for gState only */
|
||||
HAL_UART_STATE_BUSY_RX = 0x22U, /*!< Data Reception process is ongoing
|
||||
Value is allowed for RxState only */
|
||||
HAL_UART_STATE_BUSY_TX_RX = 0x23U, /*!< Data Transmission and Reception process is ongoing
|
||||
Not to be used for neither gState nor RxState.
|
||||
Value is result of combination (Or) between gState and RxState values */
|
||||
HAL_UART_STATE_TIMEOUT = 0xA0U, /*!< Timeout state
|
||||
Value is allowed for gState only */
|
||||
HAL_UART_STATE_ERROR = 0xE0U /*!< Error
|
||||
Value is allowed for gState only */
|
||||
} HAL_UART_StateTypeDef;
|
||||
|
||||
/* @brief UART Advanced Features initialization structure definition */
|
||||
typedef struct
|
||||
{
|
||||
uint32_t AdvFeatureInit; /*!< Specifies which advanced UART features is initialized. Several
|
||||
Advanced Features may be initialized at the same time .
|
||||
This parameter can be a value of @ref UART_Advanced_Features_Initialization_Type. */
|
||||
|
||||
uint32_t AutoBaudRateEnable; /*!< Specifies whether auto Baud rate detection is enabled.
|
||||
This parameter can be a value of @ref UART_AutoBaudRate_Enable. */
|
||||
|
||||
uint32_t AutoBaudRateMode; /*!< If auto Baud rate detection is enabled, specifies how the rate
|
||||
detection is carried out.
|
||||
This parameter can be a value of @ref UART_AutoBaud_Rate_Mode. */
|
||||
} UART_AdvFeatureInitTypeDef;
|
||||
/**
|
||||
* @brief UART handle Structure definition
|
||||
*/
|
||||
typedef struct __UART_HandleTypeDef
|
||||
{
|
||||
USART_TypeDef *Instance; /*!< UART registers base address */
|
||||
|
||||
UART_InitTypeDef Init; /*!< UART communication parameters */
|
||||
|
||||
UART_AdvFeatureInitTypeDef AdvancedInit; /*!< UART Advanced Features initialization parameters */
|
||||
|
||||
uint8_t *pTxBuffPtr; /*!< Pointer to UART Tx transfer Buffer */
|
||||
|
||||
uint16_t TxXferSize; /*!< UART Tx Transfer size */
|
||||
|
||||
__IO uint16_t TxXferCount; /*!< UART Tx Transfer Counter */
|
||||
|
||||
uint8_t *pRxBuffPtr; /*!< Pointer to UART Rx transfer Buffer */
|
||||
|
||||
uint16_t RxXferSize; /*!< UART Rx Transfer size */
|
||||
|
||||
__IO uint16_t RxXferCount; /*!< UART Rx Transfer Counter */
|
||||
|
||||
#if (defined(DMA1) || defined(DMA))
|
||||
DMA_HandleTypeDef *hdmatx; /*!< UART Tx DMA Handle parameters */
|
||||
|
||||
DMA_HandleTypeDef *hdmarx; /*!< UART Rx DMA Handle parameters */
|
||||
#endif /* DMA1 or DMA */
|
||||
|
||||
HAL_LockTypeDef Lock; /*!< Locking object */
|
||||
|
||||
__IO HAL_UART_StateTypeDef gState; /*!< UART state information related to global Handle management
|
||||
and also related to Tx operations.
|
||||
This parameter can be a value of @ref HAL_UART_StateTypeDef */
|
||||
|
||||
__IO HAL_UART_StateTypeDef RxState; /*!< UART state information related to Rx operations.
|
||||
This parameter can be a value of @ref HAL_UART_StateTypeDef */
|
||||
|
||||
__IO uint32_t ErrorCode; /*!< UART Error code */
|
||||
|
||||
#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
|
||||
void (* TxHalfCpltCallback)(struct __UART_HandleTypeDef *huart); /*!< UART Tx Half Complete Callback */
|
||||
void (* TxCpltCallback)(struct __UART_HandleTypeDef *huart); /*!< UART Tx Complete Callback */
|
||||
void (* RxHalfCpltCallback)(struct __UART_HandleTypeDef *huart); /*!< UART Rx Half Complete Callback */
|
||||
void (* RxCpltCallback)(struct __UART_HandleTypeDef *huart); /*!< UART Rx Complete Callback */
|
||||
void (* ErrorCallback)(struct __UART_HandleTypeDef *huart); /*!< UART Error Callback */
|
||||
void (* AbortCpltCallback)(struct __UART_HandleTypeDef *huart); /*!< UART Abort Complete Callback */
|
||||
void (* AbortTransmitCpltCallback)(struct __UART_HandleTypeDef *huart); /*!< UART Abort Transmit Complete Callback */
|
||||
void (* AbortReceiveCpltCallback)(struct __UART_HandleTypeDef *huart); /*!< UART Abort Receive Complete Callback */
|
||||
void (* WakeupCallback)(struct __UART_HandleTypeDef *huart); /*!< UART Wakeup Callback */
|
||||
|
||||
void (* MspInitCallback)(struct __UART_HandleTypeDef *huart); /*!< UART Msp Init callback */
|
||||
void (* MspDeInitCallback)(struct __UART_HandleTypeDef *huart); /*!< UART Msp DeInit callback */
|
||||
#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
|
||||
|
||||
} UART_HandleTypeDef;
|
||||
|
||||
#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
|
||||
/**
|
||||
* @brief HAL UART Callback ID enumeration definition
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
HAL_UART_TX_HALFCOMPLETE_CB_ID = 0x00U, /*!< UART Tx Half Complete Callback ID */
|
||||
HAL_UART_TX_COMPLETE_CB_ID = 0x01U, /*!< UART Tx Complete Callback ID */
|
||||
HAL_UART_RX_HALFCOMPLETE_CB_ID = 0x02U, /*!< UART Rx Half Complete Callback ID */
|
||||
HAL_UART_RX_COMPLETE_CB_ID = 0x03U, /*!< UART Rx Complete Callback ID */
|
||||
HAL_UART_ERROR_CB_ID = 0x04U, /*!< UART Error Callback ID */
|
||||
HAL_UART_ABORT_COMPLETE_CB_ID = 0x05U, /*!< UART Abort Complete Callback ID */
|
||||
HAL_UART_ABORT_TRANSMIT_COMPLETE_CB_ID = 0x06U, /*!< UART Abort Transmit Complete Callback ID */
|
||||
HAL_UART_ABORT_RECEIVE_COMPLETE_CB_ID = 0x07U, /*!< UART Abort Receive Complete Callback ID */
|
||||
HAL_UART_WAKEUP_CB_ID = 0x08U, /*!< UART Wakeup Callback ID */
|
||||
|
||||
HAL_UART_MSPINIT_CB_ID = 0x0BU, /*!< UART MspInit callback ID */
|
||||
HAL_UART_MSPDEINIT_CB_ID = 0x0CU /*!< UART MspDeInit callback ID */
|
||||
|
||||
} HAL_UART_CallbackIDTypeDef;
|
||||
|
||||
/**
|
||||
* @brief HAL UART Callback pointer definition
|
||||
*/
|
||||
typedef void (*pUART_CallbackTypeDef)(UART_HandleTypeDef *huart); /*!< pointer to an UART callback function */
|
||||
|
||||
#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/** @defgroup UART_Exported_Constants UART Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup UART_Error_Code UART Error Code
|
||||
* @{
|
||||
*/
|
||||
#define HAL_UART_ERROR_NONE 0x00000000U /*!< No error */
|
||||
#define HAL_UART_ERROR_PE 0x00000001U /*!< Parity error */
|
||||
#define HAL_UART_ERROR_NE 0x00000002U /*!< Noise error */
|
||||
#define HAL_UART_ERROR_FE 0x00000004U /*!< Frame error */
|
||||
#define HAL_UART_ERROR_ORE 0x00000008U /*!< Overrun error */
|
||||
#if (defined(DMA1) || defined(DMA))
|
||||
#define HAL_UART_ERROR_DMA 0x00000010U /*!< DMA transfer error */
|
||||
#endif /* DMA1 or DMA */
|
||||
#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
|
||||
#define HAL_UART_ERROR_INVALID_CALLBACK 0x00000020U /*!< Invalid Callback error */
|
||||
#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup UART_Word_Length UART Word Length
|
||||
* @{
|
||||
*/
|
||||
#define UART_WORDLENGTH_8B 0x00000000U
|
||||
#define UART_WORDLENGTH_9B ((uint32_t)USART_CR1_M)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup UART_Stop_Bits UART Number of Stop Bits
|
||||
* @{
|
||||
*/
|
||||
#define UART_STOPBITS_1 0x00000000U
|
||||
#define UART_STOPBITS_2 ((uint32_t)USART_CR2_STOP)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup UART_Parity UART Parity
|
||||
* @{
|
||||
*/
|
||||
#define UART_PARITY_NONE 0x00000000U
|
||||
#define UART_PARITY_EVEN ((uint32_t)USART_CR1_PCE)
|
||||
#define UART_PARITY_ODD ((uint32_t)(USART_CR1_PCE | USART_CR1_PS))
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup UART_Hardware_Flow_Control UART Hardware Flow Control
|
||||
* @{
|
||||
*/
|
||||
#define UART_HWCONTROL_NONE 0x00000000U
|
||||
#define UART_HWCONTROL_RTS ((uint32_t)USART_CR3_RTSE)
|
||||
#define UART_HWCONTROL_CTS ((uint32_t)USART_CR3_CTSE)
|
||||
#define UART_HWCONTROL_RTS_CTS ((uint32_t)(USART_CR3_RTSE | USART_CR3_CTSE))
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup UART_Mode UART Transfer Mode
|
||||
* @{
|
||||
*/
|
||||
#define UART_MODE_RX ((uint32_t)USART_CR1_RE)
|
||||
#define UART_MODE_TX ((uint32_t)USART_CR1_TE)
|
||||
#define UART_MODE_TX_RX ((uint32_t)(USART_CR1_TE | USART_CR1_RE))
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup UART_State UART State
|
||||
* @{
|
||||
*/
|
||||
#define UART_STATE_DISABLE 0x00000000U
|
||||
#define UART_STATE_ENABLE ((uint32_t)USART_CR1_UE)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup UART_Over_Sampling UART Over Sampling
|
||||
* @{
|
||||
*/
|
||||
#define UART_OVERSAMPLING_16 0x00000000U
|
||||
#if defined(USART_CR3_OVER8)
|
||||
#define UART_OVERSAMPLING_8 ((uint32_t)USART_CR3_OVER8)
|
||||
#endif /* USART_CR3_OVER8 */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup UART_LIN_Break_Detection_Length UART LIN Break Detection Length
|
||||
* @{
|
||||
*/
|
||||
#define UART_LINBREAKDETECTLENGTH_10B 0x00000000U
|
||||
#define UART_LINBREAKDETECTLENGTH_11B ((uint32_t)USART_CR2_LBDL)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup UART_WakeUp_functions UART Wakeup Functions
|
||||
* @{
|
||||
*/
|
||||
#define UART_WAKEUPMETHOD_IDLELINE 0x00000000U
|
||||
#define UART_WAKEUPMETHOD_ADDRESSMARK ((uint32_t)USART_CR1_WAKE)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup UART_Flags UART FLags
|
||||
* Elements values convention: 0xXXXX
|
||||
* - 0xXXXX : Flag mask in the SR register
|
||||
* @{
|
||||
*/
|
||||
#define UART_FLAG_ABRF ((uint32_t)USART_SR_ABRF) /*!< UART auto Baud rate flag */
|
||||
#define UART_FLAG_ABRE ((uint32_t)USART_SR_ABRE) /*!< UART auto Baud rate error */
|
||||
#define UART_FLAG_CTS ((uint32_t)USART_SR_CTS)
|
||||
#define UART_FLAG_TXE ((uint32_t)USART_SR_TXE)
|
||||
#define UART_FLAG_TC ((uint32_t)USART_SR_TC)
|
||||
#define UART_FLAG_RXNE ((uint32_t)USART_SR_RXNE)
|
||||
#define UART_FLAG_IDLE ((uint32_t)USART_SR_IDLE)
|
||||
#define UART_FLAG_ORE ((uint32_t)USART_SR_ORE)
|
||||
#define UART_FLAG_NE ((uint32_t)USART_SR_NE)
|
||||
#define UART_FLAG_FE ((uint32_t)USART_SR_FE)
|
||||
#define UART_FLAG_PE ((uint32_t)USART_SR_PE)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup UART_Interrupt_definition UART Interrupt Definitions
|
||||
* Elements values convention: 0xY000XXXX
|
||||
* - XXXX : Interrupt mask (16 bits) in the Y register
|
||||
* - Y : Interrupt source register (2bits)
|
||||
* - 0001: CR1 register
|
||||
* - 0010: CR2 register
|
||||
* - 0011: CR3 register
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define UART_IT_PE ((uint32_t)(UART_CR1_REG_INDEX << 28U | USART_CR1_PEIE))
|
||||
#define UART_IT_TXE ((uint32_t)(UART_CR1_REG_INDEX << 28U | USART_CR1_TXEIE))
|
||||
#define UART_IT_TC ((uint32_t)(UART_CR1_REG_INDEX << 28U | USART_CR1_TCIE))
|
||||
#define UART_IT_RXNE ((uint32_t)(UART_CR1_REG_INDEX << 28U | USART_CR1_RXNEIE))
|
||||
#define UART_IT_IDLE ((uint32_t)(UART_CR1_REG_INDEX << 28U | USART_CR1_IDLEIE))
|
||||
|
||||
#define UART_IT_CTS ((uint32_t)(UART_CR3_REG_INDEX << 28U | USART_CR3_CTSIE))
|
||||
#define UART_IT_ERR ((uint32_t)(UART_CR3_REG_INDEX << 28U | USART_CR3_EIE))
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup UART_Advanced_Features_Initialization_Type UART Advanced Feature Initialization Type
|
||||
* @{
|
||||
*/
|
||||
#define UART_ADVFEATURE_NO_INIT 0x00000000U /*!< No advanced feature initialization */
|
||||
#define UART_ADVFEATURE_AUTOBAUDRATE_INIT 0x00000040U /*!< Auto Baud rate detection initialization */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup UART_AutoBaudRate_Enable UART Advanced Feature Auto BaudRate Enable
|
||||
* @{
|
||||
*/
|
||||
#define UART_ADVFEATURE_AUTOBAUDRATE_DISABLE 0x00000000U /*!< RX Auto Baud rate detection enable */
|
||||
#define UART_ADVFEATURE_AUTOBAUDRATE_ENABLE USART_CR3_ABREN /*!< RX Auto Baud rate detection disable */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup UART_AutoBaud_Rate_Mode UART Advanced Feature AutoBaud Rate Mode
|
||||
* @{
|
||||
*/
|
||||
#define UART_ADVFEATURE_AUTOBAUDRATE_ONSTARTBIT 0x00000000U /*!< Auto Baud rate detection on start bit */
|
||||
#define UART_ADVFEATURE_AUTOBAUDRATE_ONFALLINGEDGE USART_CR3_ABRMODE_0 /*!< Auto Baud rate detection on falling edge */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/** @defgroup UART_Exported_Macros UART Exported Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @brief Reset UART handle gstate & RxState
|
||||
* @param __HANDLE__ specifies the UART Handle.
|
||||
* UART Handle selects the USARTx or UARTy peripheral
|
||||
* (USART,UART availability and x,y values depending on device).
|
||||
* @retval None
|
||||
*/
|
||||
#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
|
||||
#define __HAL_UART_RESET_HANDLE_STATE(__HANDLE__) do{ \
|
||||
(__HANDLE__)->gState = HAL_UART_STATE_RESET; \
|
||||
(__HANDLE__)->RxState = HAL_UART_STATE_RESET; \
|
||||
(__HANDLE__)->MspInitCallback = NULL; \
|
||||
(__HANDLE__)->MspDeInitCallback = NULL; \
|
||||
} while(0U)
|
||||
#else
|
||||
#define __HAL_UART_RESET_HANDLE_STATE(__HANDLE__) do{ \
|
||||
(__HANDLE__)->gState = HAL_UART_STATE_RESET; \
|
||||
(__HANDLE__)->RxState = HAL_UART_STATE_RESET; \
|
||||
} while(0U)
|
||||
#endif /*USE_HAL_UART_REGISTER_CALLBACKS */
|
||||
|
||||
/** @brief Flushes the UART DR register
|
||||
* @param __HANDLE__ specifies the UART Handle.
|
||||
* UART Handle selects the USARTx or UARTy peripheral
|
||||
* (USART,UART availability and x,y values depending on device).
|
||||
*/
|
||||
#define __HAL_UART_FLUSH_DRREGISTER(__HANDLE__) ((__HANDLE__)->Instance->DR)
|
||||
|
||||
/** @brief Checks whether the specified UART flag is set or not.
|
||||
* @param __HANDLE__ specifies the UART Handle.
|
||||
* UART Handle selects the USARTx or UARTy peripheral
|
||||
* (USART,UART availability and x,y values depending on device).
|
||||
* @param __FLAG__ specifies the flag to check.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg UART_FLAG_CTS: CTS Change flag
|
||||
* @arg UART_FLAG_TXE: Transmit data register empty flag
|
||||
* @arg UART_FLAG_TC: Transmission Complete flag
|
||||
* @arg UART_FLAG_RXNE: Receive data register not empty flag
|
||||
* @arg UART_FLAG_IDLE: Idle Line detection flag
|
||||
* @arg UART_FLAG_ORE: Overrun Error flag
|
||||
* @arg UART_FLAG_NE: Noise Error flag
|
||||
* @arg UART_FLAG_FE: Framing Error flag
|
||||
* @arg UART_FLAG_PE: Parity Error flag
|
||||
* @retval The new state of __FLAG__ (TRUE or FALSE).
|
||||
*/
|
||||
#define __HAL_UART_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__))
|
||||
|
||||
/** @brief Clears the specified UART pending flag.
|
||||
* @param __HANDLE__ specifies the UART Handle.
|
||||
* UART Handle selects the USARTx or UARTy peripheral
|
||||
* (USART,UART availability and x,y values depending on device).
|
||||
* @param __FLAG__ specifies the flag to check.
|
||||
* This parameter can be any combination of the following values:
|
||||
* @arg UART_FLAG_CTS: CTS Change flag.
|
||||
* @arg UART_FLAG_TC: Transmission Complete flag.
|
||||
* @arg UART_FLAG_RXNE: Receive data register not empty flag.
|
||||
*
|
||||
* @note PE (Parity error), FE (Framing error), NE (Noise error), ORE (Overrun
|
||||
* error) and IDLE (Idle line detected) flags are cleared by software
|
||||
* sequence: a read operation to USART_SR register followed by a read
|
||||
* operation to USART_DR register.
|
||||
* @note RXNE flag can be also cleared by a read to the USART_DR register.
|
||||
* @note TC flag can be also cleared by software sequence: a read operation to
|
||||
* USART_SR register followed by a write operation to USART_DR register.
|
||||
* @note TXE flag is cleared only by a write to the USART_DR register.
|
||||
*
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_UART_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR = ~(__FLAG__))
|
||||
|
||||
/** @brief Clears the UART PE pending flag.
|
||||
* @param __HANDLE__ specifies the UART Handle.
|
||||
* UART Handle selects the USARTx or UARTy peripheral
|
||||
* (USART,UART availability and x,y values depending on device).
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_UART_CLEAR_PEFLAG(__HANDLE__) \
|
||||
do{ \
|
||||
__IO uint32_t tmpreg = 0x00U; \
|
||||
tmpreg = (__HANDLE__)->Instance->SR; \
|
||||
tmpreg = (__HANDLE__)->Instance->DR; \
|
||||
UNUSED(tmpreg); \
|
||||
} while(0U)
|
||||
|
||||
/** @brief Clears the UART FE pending flag.
|
||||
* @param __HANDLE__ specifies the UART Handle.
|
||||
* UART Handle selects the USARTx or UARTy peripheral
|
||||
* (USART,UART availability and x,y values depending on device).
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_UART_CLEAR_FEFLAG(__HANDLE__) __HAL_UART_CLEAR_PEFLAG(__HANDLE__)
|
||||
|
||||
/** @brief Clears the UART NE pending flag.
|
||||
* @param __HANDLE__ specifies the UART Handle.
|
||||
* UART Handle selects the USARTx or UARTy peripheral
|
||||
* (USART,UART availability and x,y values depending on device).
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_UART_CLEAR_NEFLAG(__HANDLE__) __HAL_UART_CLEAR_PEFLAG(__HANDLE__)
|
||||
|
||||
/** @brief Clears the UART ORE pending flag.
|
||||
* @param __HANDLE__ specifies the UART Handle.
|
||||
* UART Handle selects the USARTx or UARTy peripheral
|
||||
* (USART,UART availability and x,y values depending on device).
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_UART_CLEAR_OREFLAG(__HANDLE__) __HAL_UART_CLEAR_PEFLAG(__HANDLE__)
|
||||
|
||||
/** @brief Clears the UART IDLE pending flag.
|
||||
* @param __HANDLE__ specifies the UART Handle.
|
||||
* UART Handle selects the USARTx or UARTy peripheral
|
||||
* (USART,UART availability and x,y values depending on device).
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_UART_CLEAR_IDLEFLAG(__HANDLE__) __HAL_UART_CLEAR_PEFLAG(__HANDLE__)
|
||||
|
||||
/** @brief Enable the specified UART interrupt.
|
||||
* @param __HANDLE__ specifies the UART Handle.
|
||||
* UART Handle selects the USARTx or UARTy peripheral
|
||||
* (USART,UART availability and x,y values depending on device).
|
||||
* @param __INTERRUPT__ specifies the UART interrupt source to enable.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg UART_IT_CTS: CTS change interrupt
|
||||
* @arg UART_IT_LBD: LIN Break detection interrupt
|
||||
* @arg UART_IT_TXE: Transmit Data Register empty interrupt
|
||||
* @arg UART_IT_TC: Transmission complete interrupt
|
||||
* @arg UART_IT_RXNE: Receive Data register not empty interrupt
|
||||
* @arg UART_IT_IDLE: Idle line detection interrupt
|
||||
* @arg UART_IT_PE: Parity Error interrupt
|
||||
* @arg UART_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_UART_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28U) == UART_CR1_REG_INDEX)? ((__HANDLE__)->Instance->CR1 |= ((__INTERRUPT__) & UART_IT_MASK)): \
|
||||
(((__INTERRUPT__) >> 28U) == UART_CR2_REG_INDEX)? ((__HANDLE__)->Instance->CR2 |= ((__INTERRUPT__) & UART_IT_MASK)): \
|
||||
((__HANDLE__)->Instance->CR3 |= ((__INTERRUPT__) & UART_IT_MASK)))
|
||||
|
||||
/** @brief Disable the specified UART interrupt.
|
||||
* @param __HANDLE__ specifies the UART Handle.
|
||||
* UART Handle selects the USARTx or UARTy peripheral
|
||||
* (USART,UART availability and x,y values depending on device).
|
||||
* @param __INTERRUPT__ specifies the UART interrupt source to disable.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg UART_IT_CTS: CTS change interrupt
|
||||
* @arg UART_IT_LBD: LIN Break detection interrupt
|
||||
* @arg UART_IT_TXE: Transmit Data Register empty interrupt
|
||||
* @arg UART_IT_TC: Transmission complete interrupt
|
||||
* @arg UART_IT_RXNE: Receive Data register not empty interrupt
|
||||
* @arg UART_IT_IDLE: Idle line detection interrupt
|
||||
* @arg UART_IT_PE: Parity Error interrupt
|
||||
* @arg UART_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_UART_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28U) == UART_CR1_REG_INDEX)? ((__HANDLE__)->Instance->CR1 &= ~((__INTERRUPT__) & UART_IT_MASK)): \
|
||||
(((__INTERRUPT__) >> 28U) == UART_CR2_REG_INDEX)? ((__HANDLE__)->Instance->CR2 &= ~((__INTERRUPT__) & UART_IT_MASK)): \
|
||||
((__HANDLE__)->Instance->CR3 &= ~ ((__INTERRUPT__) & UART_IT_MASK)))
|
||||
|
||||
/** @brief Checks whether the specified UART interrupt has occurred or not.
|
||||
* @param __HANDLE__ specifies the UART Handle.
|
||||
* UART Handle selects the USARTx or UARTy peripheral
|
||||
* (USART,UART availability and x,y values depending on device).
|
||||
* @param __IT__ specifies the UART interrupt source to check.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg UART_IT_CTS: CTS change interrupt
|
||||
* @arg UART_IT_LBD: LIN Break detection interrupt
|
||||
* @arg UART_IT_TXE: Transmit Data Register empty interrupt
|
||||
* @arg UART_IT_TC: Transmission complete interrupt
|
||||
* @arg UART_IT_RXNE: Receive Data register not empty interrupt
|
||||
* @arg UART_IT_IDLE: Idle line detection interrupt
|
||||
* @arg UART_IT_ERR: Error interrupt
|
||||
* @retval The new state of __IT__ (TRUE or FALSE).
|
||||
*/
|
||||
#define __HAL_UART_GET_IT_SOURCE(__HANDLE__, __IT__) (((((__IT__) >> 28U) == UART_CR1_REG_INDEX)? (__HANDLE__)->Instance->CR1:(((((uint32_t)(__IT__)) >> 28U) == UART_CR2_REG_INDEX)? \
|
||||
(__HANDLE__)->Instance->CR2 : (__HANDLE__)->Instance->CR3)) & (((uint32_t)(__IT__)) & UART_IT_MASK))
|
||||
|
||||
/** @brief Enable CTS flow control
|
||||
* @note This macro allows to enable CTS hardware flow control for a given UART instance,
|
||||
* without need to call HAL_UART_Init() function.
|
||||
* As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
|
||||
* @note As macro is expected to be used for modifying CTS Hw flow control feature activation, without need
|
||||
* for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
|
||||
* - UART instance should have already been initialised (through call of HAL_UART_Init() )
|
||||
* - macro could only be called when corresponding UART instance is disabled (i.e __HAL_UART_DISABLE(__HANDLE__))
|
||||
* and should be followed by an Enable macro (i.e __HAL_UART_ENABLE(__HANDLE__)).
|
||||
* @param __HANDLE__ specifies the UART Handle.
|
||||
* The Handle Instance can be any USARTx (supporting the HW Flow control feature).
|
||||
* It is used to select the USART peripheral (USART availability and x value depending on device).
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_UART_HWCONTROL_CTS_ENABLE(__HANDLE__) \
|
||||
do{ \
|
||||
SET_BIT((__HANDLE__)->Instance->CR3, USART_CR3_CTSE); \
|
||||
(__HANDLE__)->Init.HwFlowCtl |= USART_CR3_CTSE; \
|
||||
} while(0U)
|
||||
|
||||
/** @brief Disable CTS flow control
|
||||
* @note This macro allows to disable CTS hardware flow control for a given UART instance,
|
||||
* without need to call HAL_UART_Init() function.
|
||||
* As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
|
||||
* @note As macro is expected to be used for modifying CTS Hw flow control feature activation, without need
|
||||
* for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
|
||||
* - UART instance should have already been initialised (through call of HAL_UART_Init() )
|
||||
* - macro could only be called when corresponding UART instance is disabled (i.e __HAL_UART_DISABLE(__HANDLE__))
|
||||
* and should be followed by an Enable macro (i.e __HAL_UART_ENABLE(__HANDLE__)).
|
||||
* @param __HANDLE__ specifies the UART Handle.
|
||||
* The Handle Instance can be any USARTx (supporting the HW Flow control feature).
|
||||
* It is used to select the USART peripheral (USART availability and x value depending on device).
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_UART_HWCONTROL_CTS_DISABLE(__HANDLE__) \
|
||||
do{ \
|
||||
CLEAR_BIT((__HANDLE__)->Instance->CR3, USART_CR3_CTSE); \
|
||||
(__HANDLE__)->Init.HwFlowCtl &= ~(USART_CR3_CTSE); \
|
||||
} while(0U)
|
||||
|
||||
/** @brief Enable RTS flow control
|
||||
* This macro allows to enable RTS hardware flow control for a given UART instance,
|
||||
* without need to call HAL_UART_Init() function.
|
||||
* As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
|
||||
* @note As macro is expected to be used for modifying RTS Hw flow control feature activation, without need
|
||||
* for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
|
||||
* - UART instance should have already been initialised (through call of HAL_UART_Init() )
|
||||
* - macro could only be called when corresponding UART instance is disabled (i.e __HAL_UART_DISABLE(__HANDLE__))
|
||||
* and should be followed by an Enable macro (i.e __HAL_UART_ENABLE(__HANDLE__)).
|
||||
* @param __HANDLE__ specifies the UART Handle.
|
||||
* The Handle Instance can be any USARTx (supporting the HW Flow control feature).
|
||||
* It is used to select the USART peripheral (USART availability and x value depending on device).
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_UART_HWCONTROL_RTS_ENABLE(__HANDLE__) \
|
||||
do{ \
|
||||
SET_BIT((__HANDLE__)->Instance->CR3, USART_CR3_RTSE); \
|
||||
(__HANDLE__)->Init.HwFlowCtl |= USART_CR3_RTSE; \
|
||||
} while(0U)
|
||||
|
||||
/** @brief Disable RTS flow control
|
||||
* This macro allows to disable RTS hardware flow control for a given UART instance,
|
||||
* without need to call HAL_UART_Init() function.
|
||||
* As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
|
||||
* @note As macro is expected to be used for modifying RTS Hw flow control feature activation, without need
|
||||
* for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
|
||||
* - UART instance should have already been initialised (through call of HAL_UART_Init() )
|
||||
* - macro could only be called when corresponding UART instance is disabled (i.e __HAL_UART_DISABLE(__HANDLE__))
|
||||
* and should be followed by an Enable macro (i.e __HAL_UART_ENABLE(__HANDLE__)).
|
||||
* @param __HANDLE__ specifies the UART Handle.
|
||||
* The Handle Instance can be any USARTx (supporting the HW Flow control feature).
|
||||
* It is used to select the USART peripheral (USART availability and x value depending on device).
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_UART_HWCONTROL_RTS_DISABLE(__HANDLE__) \
|
||||
do{ \
|
||||
CLEAR_BIT((__HANDLE__)->Instance->CR3, USART_CR3_RTSE);\
|
||||
(__HANDLE__)->Init.HwFlowCtl &= ~(USART_CR3_RTSE); \
|
||||
} while(0U)
|
||||
#if defined(USART_CR3_ONEBIT)
|
||||
|
||||
/** @brief Macro to enable the UART's one bit sample method
|
||||
* @param __HANDLE__ specifies the UART Handle.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_UART_ONE_BIT_SAMPLE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3|= USART_CR3_ONEBIT)
|
||||
|
||||
/** @brief Macro to disable the UART's one bit sample method
|
||||
* @param __HANDLE__ specifies the UART Handle.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_UART_ONE_BIT_SAMPLE_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3 &= (uint16_t)~((uint16_t)USART_CR3_ONEBIT))
|
||||
#endif /* UART_ONE_BIT_SAMPLE_Feature */
|
||||
|
||||
/** @brief Enable UART
|
||||
* @param __HANDLE__ specifies the UART Handle.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_UART_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE)
|
||||
|
||||
/** @brief Disable UART
|
||||
* @param __HANDLE__ specifies the UART Handle.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_UART_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE)
|
||||
|
||||
/** @brief Send Auto-Baud Rate Request.
|
||||
* @param __HANDLE__ specifies the UART Handle.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_UART_SEND_AUTOBAUD_REQ(__HANDLE__) ((__HANDLE__)->Instance->SR |= (uint16_t)(USART_SR_ABRRQ))
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/** @addtogroup UART_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup UART_Exported_Functions_Group1 Initialization and de-initialization functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Initialization/de-initialization functions **********************************/
|
||||
HAL_StatusTypeDef HAL_UART_Init(UART_HandleTypeDef *huart);
|
||||
HAL_StatusTypeDef HAL_HalfDuplex_Init(UART_HandleTypeDef *huart);
|
||||
HAL_StatusTypeDef HAL_MultiProcessor_Init(UART_HandleTypeDef *huart, uint8_t Address, uint32_t WakeUpMethod);
|
||||
HAL_StatusTypeDef HAL_UART_DeInit(UART_HandleTypeDef *huart);
|
||||
void HAL_UART_MspInit(UART_HandleTypeDef *huart);
|
||||
void HAL_UART_MspDeInit(UART_HandleTypeDef *huart);
|
||||
|
||||
/* Callbacks Register/UnRegister functions ***********************************/
|
||||
#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
|
||||
HAL_StatusTypeDef HAL_UART_RegisterCallback(UART_HandleTypeDef *huart, HAL_UART_CallbackIDTypeDef CallbackID, pUART_CallbackTypeDef pCallback);
|
||||
HAL_StatusTypeDef HAL_UART_UnRegisterCallback(UART_HandleTypeDef *huart, HAL_UART_CallbackIDTypeDef CallbackID);
|
||||
#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup UART_Exported_Functions_Group IO operation functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* IO operation functions *******************************************************/
|
||||
HAL_StatusTypeDef HAL_UART_Transmit(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout);
|
||||
HAL_StatusTypeDef HAL_UART_Receive(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout);
|
||||
HAL_StatusTypeDef HAL_UART_Transmit_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
|
||||
HAL_StatusTypeDef HAL_UART_Receive_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
|
||||
#if (defined(DMA1) || defined(DMA))
|
||||
HAL_StatusTypeDef HAL_UART_Transmit_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
|
||||
HAL_StatusTypeDef HAL_UART_Receive_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
|
||||
HAL_StatusTypeDef HAL_UART_DMAPause(UART_HandleTypeDef *huart);
|
||||
HAL_StatusTypeDef HAL_UART_DMAResume(UART_HandleTypeDef *huart);
|
||||
HAL_StatusTypeDef HAL_UART_DMAStop(UART_HandleTypeDef *huart);
|
||||
#endif /* DMA1 or DMA */
|
||||
/* Transfer Abort functions */
|
||||
HAL_StatusTypeDef HAL_UART_Abort(UART_HandleTypeDef *huart);
|
||||
HAL_StatusTypeDef HAL_UART_AbortTransmit(UART_HandleTypeDef *huart);
|
||||
HAL_StatusTypeDef HAL_UART_AbortReceive(UART_HandleTypeDef *huart);
|
||||
HAL_StatusTypeDef HAL_UART_Abort_IT(UART_HandleTypeDef *huart);
|
||||
HAL_StatusTypeDef HAL_UART_AbortTransmit_IT(UART_HandleTypeDef *huart);
|
||||
HAL_StatusTypeDef HAL_UART_AbortReceive_IT(UART_HandleTypeDef *huart);
|
||||
|
||||
void HAL_UART_IRQHandler(UART_HandleTypeDef *huart);
|
||||
void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart);
|
||||
void HAL_UART_TxHalfCpltCallback(UART_HandleTypeDef *huart);
|
||||
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart);
|
||||
void HAL_UART_RxHalfCpltCallback(UART_HandleTypeDef *huart);
|
||||
void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart);
|
||||
void HAL_UART_AbortCpltCallback(UART_HandleTypeDef *huart);
|
||||
void HAL_UART_AbortTransmitCpltCallback(UART_HandleTypeDef *huart);
|
||||
void HAL_UART_AbortReceiveCpltCallback(UART_HandleTypeDef *huart);
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup UART_Exported_Functions_Group3
|
||||
* @{
|
||||
*/
|
||||
/* Peripheral Control functions ************************************************/
|
||||
HAL_StatusTypeDef HAL_UART_SendBreak(UART_HandleTypeDef *huart);
|
||||
HAL_StatusTypeDef HAL_MultiProcessor_EnterMuteMode(UART_HandleTypeDef *huart);
|
||||
HAL_StatusTypeDef HAL_MultiProcessor_ExitMuteMode(UART_HandleTypeDef *huart);
|
||||
HAL_StatusTypeDef HAL_HalfDuplex_EnableTransmitter(UART_HandleTypeDef *huart);
|
||||
HAL_StatusTypeDef HAL_HalfDuplex_EnableReceiver(UART_HandleTypeDef *huart);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup UART_Exported_Functions_Group4
|
||||
* @{
|
||||
*/
|
||||
/* Peripheral State functions **************************************************/
|
||||
HAL_UART_StateTypeDef HAL_UART_GetState(UART_HandleTypeDef *huart);
|
||||
uint32_t HAL_UART_GetError(UART_HandleTypeDef *huart);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/* Private types -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
/** @defgroup UART_Private_Constants UART Private Constants
|
||||
* @{
|
||||
*/
|
||||
/** @brief UART interruptions flag mask
|
||||
*
|
||||
*/
|
||||
#define UART_IT_MASK 0x0000FFFFU
|
||||
|
||||
#define UART_CR1_REG_INDEX 1U
|
||||
#define UART_CR2_REG_INDEX 2U
|
||||
#define UART_CR3_REG_INDEX 3U
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Private macros ------------------------------------------------------------*/
|
||||
/** @defgroup UART_Private_Macros UART Private Macros
|
||||
* @{
|
||||
*/
|
||||
#define IS_UART_WORD_LENGTH(LENGTH) (((LENGTH) == UART_WORDLENGTH_8B) || \
|
||||
((LENGTH) == UART_WORDLENGTH_9B))
|
||||
#define IS_UART_LIN_WORD_LENGTH(LENGTH) (((LENGTH) == UART_WORDLENGTH_8B))
|
||||
#define IS_UART_STOPBITS(STOPBITS) (((STOPBITS) == UART_STOPBITS_1) || \
|
||||
((STOPBITS) == UART_STOPBITS_2))
|
||||
#define IS_UART_PARITY(PARITY) (((PARITY) == UART_PARITY_NONE) || \
|
||||
((PARITY) == UART_PARITY_EVEN) || \
|
||||
((PARITY) == UART_PARITY_ODD))
|
||||
#define IS_UART_HARDWARE_FLOW_CONTROL(CONTROL)\
|
||||
(((CONTROL) == UART_HWCONTROL_NONE) || \
|
||||
((CONTROL) == UART_HWCONTROL_RTS) || \
|
||||
((CONTROL) == UART_HWCONTROL_CTS) || \
|
||||
((CONTROL) == UART_HWCONTROL_RTS_CTS))
|
||||
#define IS_UART_MODE(MODE) ((((MODE) & (~((uint32_t)UART_MODE_TX_RX))) == 0x00U) && ((MODE) != 0x00U))
|
||||
#define IS_UART_STATE(STATE) (((STATE) == UART_STATE_DISABLE) || \
|
||||
((STATE) == UART_STATE_ENABLE))
|
||||
#if defined(USART_CR3_OVER8)
|
||||
#define IS_UART_OVERSAMPLING(SAMPLING) (((SAMPLING) == UART_OVERSAMPLING_16) || \
|
||||
((SAMPLING) == UART_OVERSAMPLING_8))
|
||||
#endif /* USART_CR3_OVER8 */
|
||||
#define IS_UART_LIN_OVERSAMPLING(SAMPLING) (((SAMPLING) == UART_OVERSAMPLING_16))
|
||||
#define IS_UART_LIN_BREAK_DETECT_LENGTH(LENGTH) (((LENGTH) == UART_LINBREAKDETECTLENGTH_10B) || \
|
||||
((LENGTH) == UART_LINBREAKDETECTLENGTH_11B))
|
||||
#define IS_UART_WAKEUPMETHOD(WAKEUP) (((WAKEUP) == UART_WAKEUPMETHOD_IDLELINE) || \
|
||||
((WAKEUP) == UART_WAKEUPMETHOD_ADDRESSMARK))
|
||||
#define IS_UART_BAUDRATE(BAUDRATE) ((BAUDRATE) <= 4500000U)
|
||||
#define IS_UART_ADDRESS(ADDRESS) ((ADDRESS) <= 0x0FU)
|
||||
#define IS_UART_ADVFEATURE_INIT(__PARAM__) (((__PARAM__) == UART_ADVFEATURE_NO_INIT) || \
|
||||
((__PARAM__) == UART_ADVFEATURE_AUTOBAUDRATE_INIT))
|
||||
#define IS_UART_ADVFEATURE_AUTOBAUDRATE(__PARAM__) (((__PARAM__) == UART_ADVFEATURE_AUTOBAUDRATE_DISABLE) || \
|
||||
((__PARAM__) == UART_ADVFEATURE_AUTOBAUDRATE_ENABLE))
|
||||
#define IS_UART_ADVFEATURE_AUTOBAUDRATEMODE(__PARAM__) (((__PARAM__) == UART_ADVFEATURE_AUTOBAUDRATE_ONSTARTBIT) || \
|
||||
((__PARAM__) == UART_ADVFEATURE_AUTOBAUDRATE_ONFALLINGEDGE))
|
||||
|
||||
#define UART_DIV_SAMPLING16(_PCLK_, _BAUD_) (((_PCLK_)*25U)/(4U*(_BAUD_)))
|
||||
#define UART_DIVMANT_SAMPLING16(_PCLK_, _BAUD_) (UART_DIV_SAMPLING16((_PCLK_), (_BAUD_))/100U)
|
||||
#define UART_DIVFRAQ_SAMPLING16(_PCLK_, _BAUD_) (((UART_DIV_SAMPLING16((_PCLK_), (_BAUD_)) - (UART_DIVMANT_SAMPLING16((_PCLK_), (_BAUD_)) * 100U)) * 16U + 50U) / 100U)
|
||||
/* UART BRR = mantissa + overflow + fraction
|
||||
= (UART DIVMANT << 4) + (UART DIVFRAQ & 0xF0) + (UART DIVFRAQ & 0x0FU) */
|
||||
#define UART_BRR_SAMPLING16(_PCLK_, _BAUD_) (((UART_DIVMANT_SAMPLING16((_PCLK_), (_BAUD_)) << 4U) + \
|
||||
(UART_DIVFRAQ_SAMPLING16((_PCLK_), (_BAUD_)) & 0xF0U)) + \
|
||||
(UART_DIVFRAQ_SAMPLING16((_PCLK_), (_BAUD_)) & 0x0FU))
|
||||
|
||||
#define UART_DIV_SAMPLING8(_PCLK_, _BAUD_) (((_PCLK_)*25U)/(2U*(_BAUD_)))
|
||||
#define UART_DIVMANT_SAMPLING8(_PCLK_, _BAUD_) (UART_DIV_SAMPLING8((_PCLK_), (_BAUD_))/100U)
|
||||
#define UART_DIVFRAQ_SAMPLING8(_PCLK_, _BAUD_) (((UART_DIV_SAMPLING8((_PCLK_), (_BAUD_)) - (UART_DIVMANT_SAMPLING8((_PCLK_), (_BAUD_)) * 100U)) * 8U + 50U) / 100U)
|
||||
/* UART BRR = mantissa + overflow + fraction
|
||||
= (UART DIVMANT << 4) + ((UART DIVFRAQ & 0xF8) << 1) + (UART DIVFRAQ & 0x07U) */
|
||||
#define UART_BRR_SAMPLING8(_PCLK_, _BAUD_) (((UART_DIVMANT_SAMPLING8((_PCLK_), (_BAUD_)) << 4U) + \
|
||||
((UART_DIVFRAQ_SAMPLING8((_PCLK_), (_BAUD_)) & 0xF8U) << 1U)) + \
|
||||
(UART_DIVFRAQ_SAMPLING8((_PCLK_), (_BAUD_)) & 0x07U))
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __PY32F0xx_HAL_UART_H */
|
||||
|
||||
/************************ (C) COPYRIGHT Puya *****END OF FILE****/
|
||||
623
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_usart.h
Normal file
623
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_usart.h
Normal file
@@ -0,0 +1,623 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file py32f0xx_hal_usart.h
|
||||
* @author MCU Application Team
|
||||
* @brief Header file of USART HAL module.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) Puya Semiconductor Co.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __PY32F0xx_HAL_USART_H
|
||||
#define __PY32F0xx_HAL_USART_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "py32f0xx_hal_def.h"
|
||||
|
||||
/** @addtogroup PY32F0xx_HAL_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup USART
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/** @defgroup USART_Exported_Types USART Exported Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief USART Init Structure definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t BaudRate; /*!< This member configures the Usart communication baud rate.
|
||||
The baud rate is computed using the following formula:
|
||||
- IntegerDivider = ((PCLKx) / (16 * (husart->Init.BaudRate)))
|
||||
- FractionalDivider = ((IntegerDivider - ((uint32_t) IntegerDivider)) * 16) + 0.5 */
|
||||
|
||||
uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame.
|
||||
This parameter can be a value of @ref USART_Word_Length */
|
||||
|
||||
uint32_t StopBits; /*!< Specifies the number of stop bits transmitted.
|
||||
This parameter can be a value of @ref USART_Stop_Bits */
|
||||
|
||||
uint32_t Parity; /*!< Specifies the parity mode.
|
||||
This parameter can be a value of @ref USART_Parity
|
||||
@note When parity is enabled, the computed parity is inserted
|
||||
at the MSB position of the transmitted data (9th bit when
|
||||
the word length is set to 9 data bits; 8th bit when the
|
||||
word length is set to 8 data bits). */
|
||||
|
||||
uint32_t Mode; /*!< Specifies whether the Receive or Transmit mode is enabled or disabled.
|
||||
This parameter can be a value of @ref USART_Mode */
|
||||
|
||||
uint32_t CLKPolarity; /*!< Specifies the steady state of the serial clock.
|
||||
This parameter can be a value of @ref USART_Clock_Polarity */
|
||||
|
||||
uint32_t CLKPhase; /*!< Specifies the clock transition on which the bit capture is made.
|
||||
This parameter can be a value of @ref USART_Clock_Phase */
|
||||
|
||||
uint32_t CLKLastBit; /*!< Specifies whether the clock pulse corresponding to the last transmitted
|
||||
data bit (MSB) has to be output on the SCLK pin in synchronous mode.
|
||||
This parameter can be a value of @ref USART_Last_Bit */
|
||||
} USART_InitTypeDef;
|
||||
|
||||
/**
|
||||
* @brief HAL State structures definition
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
HAL_USART_STATE_RESET = 0x00U, /*!< Peripheral is not yet Initialized */
|
||||
HAL_USART_STATE_READY = 0x01U, /*!< Peripheral Initialized and ready for use */
|
||||
HAL_USART_STATE_BUSY = 0x02U, /*!< an internal process is ongoing */
|
||||
HAL_USART_STATE_BUSY_TX = 0x12U, /*!< Data Transmission process is ongoing */
|
||||
HAL_USART_STATE_BUSY_RX = 0x22U, /*!< Data Reception process is ongoing */
|
||||
HAL_USART_STATE_BUSY_TX_RX = 0x32U, /*!< Data Transmission Reception process is ongoing */
|
||||
HAL_USART_STATE_TIMEOUT = 0x03U, /*!< Timeout state */
|
||||
HAL_USART_STATE_ERROR = 0x04U /*!< Error */
|
||||
} HAL_USART_StateTypeDef;
|
||||
|
||||
/**
|
||||
* @brief USART handle Structure definition
|
||||
*/
|
||||
typedef struct __USART_HandleTypeDef
|
||||
{
|
||||
USART_TypeDef *Instance; /*!< USART registers base address */
|
||||
|
||||
USART_InitTypeDef Init; /*!< Usart communication parameters */
|
||||
|
||||
uint8_t *pTxBuffPtr; /*!< Pointer to Usart Tx transfer Buffer */
|
||||
|
||||
uint16_t TxXferSize; /*!< Usart Tx Transfer size */
|
||||
|
||||
__IO uint16_t TxXferCount; /*!< Usart Tx Transfer Counter */
|
||||
|
||||
uint8_t *pRxBuffPtr; /*!< Pointer to Usart Rx transfer Buffer */
|
||||
|
||||
uint16_t RxXferSize; /*!< Usart Rx Transfer size */
|
||||
|
||||
__IO uint16_t RxXferCount; /*!< Usart Rx Transfer Counter */
|
||||
|
||||
#if (defined(DMA1) || defined(DMA))
|
||||
DMA_HandleTypeDef *hdmatx; /*!< Usart Tx DMA Handle parameters */
|
||||
|
||||
DMA_HandleTypeDef *hdmarx; /*!< Usart Rx DMA Handle parameters */
|
||||
#endif /* DMA1 or DMA */
|
||||
|
||||
HAL_LockTypeDef Lock; /*!< Locking object */
|
||||
|
||||
__IO HAL_USART_StateTypeDef State; /*!< Usart communication state */
|
||||
|
||||
__IO uint32_t ErrorCode; /*!< USART Error code */
|
||||
|
||||
#if (USE_HAL_USART_REGISTER_CALLBACKS == 1)
|
||||
void (* TxHalfCpltCallback)(struct __USART_HandleTypeDef *husart); /*!< USART Tx Half Complete Callback */
|
||||
void (* TxCpltCallback)(struct __USART_HandleTypeDef *husart); /*!< USART Tx Complete Callback */
|
||||
void (* RxHalfCpltCallback)(struct __USART_HandleTypeDef *husart); /*!< USART Rx Half Complete Callback */
|
||||
void (* RxCpltCallback)(struct __USART_HandleTypeDef *husart); /*!< USART Rx Complete Callback */
|
||||
void (* TxRxCpltCallback)(struct __USART_HandleTypeDef *husart); /*!< USART Tx Rx Complete Callback */
|
||||
void (* ErrorCallback)(struct __USART_HandleTypeDef *husart); /*!< USART Error Callback */
|
||||
void (* AbortCpltCallback)(struct __USART_HandleTypeDef *husart); /*!< USART Abort Complete Callback */
|
||||
|
||||
void (* MspInitCallback)(struct __USART_HandleTypeDef *husart); /*!< USART Msp Init callback */
|
||||
void (* MspDeInitCallback)(struct __USART_HandleTypeDef *husart); /*!< USART Msp DeInit callback */
|
||||
#endif /* USE_HAL_USART_REGISTER_CALLBACKS */
|
||||
|
||||
} USART_HandleTypeDef;
|
||||
|
||||
#if (USE_HAL_USART_REGISTER_CALLBACKS == 1)
|
||||
/**
|
||||
* @brief HAL USART Callback ID enumeration definition
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
HAL_USART_TX_HALFCOMPLETE_CB_ID = 0x00U, /*!< USART Tx Half Complete Callback ID */
|
||||
HAL_USART_TX_COMPLETE_CB_ID = 0x01U, /*!< USART Tx Complete Callback ID */
|
||||
HAL_USART_RX_HALFCOMPLETE_CB_ID = 0x02U, /*!< USART Rx Half Complete Callback ID */
|
||||
HAL_USART_RX_COMPLETE_CB_ID = 0x03U, /*!< USART Rx Complete Callback ID */
|
||||
HAL_USART_TX_RX_COMPLETE_CB_ID = 0x04U, /*!< USART Tx Rx Complete Callback ID */
|
||||
HAL_USART_ERROR_CB_ID = 0x05U, /*!< USART Error Callback ID */
|
||||
HAL_USART_ABORT_COMPLETE_CB_ID = 0x06U, /*!< USART Abort Complete Callback ID */
|
||||
|
||||
HAL_USART_MSPINIT_CB_ID = 0x07U, /*!< USART MspInit callback ID */
|
||||
HAL_USART_MSPDEINIT_CB_ID = 0x08U /*!< USART MspDeInit callback ID */
|
||||
|
||||
} HAL_USART_CallbackIDTypeDef;
|
||||
|
||||
/**
|
||||
* @brief HAL USART Callback pointer definition
|
||||
*/
|
||||
typedef void (*pUSART_CallbackTypeDef)(USART_HandleTypeDef *husart); /*!< pointer to an USART callback function */
|
||||
|
||||
#endif /* USE_HAL_USART_REGISTER_CALLBACKS */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/** @defgroup USART_Exported_Constants USART Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup USART_Error_Code USART Error Code
|
||||
* @brief USART Error Code
|
||||
* @{
|
||||
*/
|
||||
#define HAL_USART_ERROR_NONE 0x00000000U /*!< No error */
|
||||
#define HAL_USART_ERROR_PE 0x00000001U /*!< Parity error */
|
||||
#define HAL_USART_ERROR_NE 0x00000002U /*!< Noise error */
|
||||
#define HAL_USART_ERROR_FE 0x00000004U /*!< Frame error */
|
||||
#define HAL_USART_ERROR_ORE 0x00000008U /*!< Overrun error */
|
||||
#if (defined(DMA1) || defined(DMA))
|
||||
#define HAL_USART_ERROR_DMA 0x00000010U /*!< DMA transfer error */
|
||||
#endif /* DMA1 or DMA */
|
||||
#if (USE_HAL_USART_REGISTER_CALLBACKS == 1)
|
||||
#define HAL_USART_ERROR_INVALID_CALLBACK 0x00000020U /*!< Invalid Callback error */
|
||||
#endif /* USE_HAL_USART_REGISTER_CALLBACKS */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USART_Word_Length USART Word Length
|
||||
* @{
|
||||
*/
|
||||
#define USART_WORDLENGTH_8B 0x00000000U
|
||||
#define USART_WORDLENGTH_9B ((uint32_t)USART_CR1_M)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USART_Stop_Bits USART Number of Stop Bits
|
||||
* @{
|
||||
*/
|
||||
#define USART_STOPBITS_1 0x00000000U
|
||||
#define USART_STOPBITS_2 ((uint32_t)USART_CR2_STOP)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USART_Parity USART Parity
|
||||
* @{
|
||||
*/
|
||||
#define USART_PARITY_NONE 0x00000000U
|
||||
#define USART_PARITY_EVEN ((uint32_t)USART_CR1_PCE)
|
||||
#define USART_PARITY_ODD ((uint32_t)(USART_CR1_PCE | USART_CR1_PS))
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USART_Mode USART Mode
|
||||
* @{
|
||||
*/
|
||||
#define USART_MODE_RX ((uint32_t)USART_CR1_RE)
|
||||
#define USART_MODE_TX ((uint32_t)USART_CR1_TE)
|
||||
#define USART_MODE_TX_RX ((uint32_t)(USART_CR1_TE | USART_CR1_RE))
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USART_Clock USART Clock
|
||||
* @{
|
||||
*/
|
||||
#define USART_CLOCK_DISABLE 0x00000000U
|
||||
#define USART_CLOCK_ENABLE ((uint32_t)USART_CR2_CLKEN)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USART_Clock_Polarity USART Clock Polarity
|
||||
* @{
|
||||
*/
|
||||
#define USART_POLARITY_LOW 0x00000000U
|
||||
#define USART_POLARITY_HIGH ((uint32_t)USART_CR2_CPOL)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USART_Clock_Phase USART Clock Phase
|
||||
* @{
|
||||
*/
|
||||
#define USART_PHASE_1EDGE 0x00000000U
|
||||
#define USART_PHASE_2EDGE ((uint32_t)USART_CR2_CPHA)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USART_Last_Bit USART Last Bit
|
||||
* @{
|
||||
*/
|
||||
#define USART_LASTBIT_DISABLE 0x00000000U
|
||||
#define USART_LASTBIT_ENABLE ((uint32_t)USART_CR2_LBCL)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USART_Flags USART Flags
|
||||
* Elements values convention: 0xXXXX
|
||||
* - 0xXXXX : Flag mask in the SR register
|
||||
* @{
|
||||
*/
|
||||
#define USART_FLAG_TXE ((uint32_t)USART_SR_TXE)
|
||||
#define USART_FLAG_TC ((uint32_t)USART_SR_TC)
|
||||
#define USART_FLAG_RXNE ((uint32_t)USART_SR_RXNE)
|
||||
#define USART_FLAG_IDLE ((uint32_t)USART_SR_IDLE)
|
||||
#define USART_FLAG_ORE ((uint32_t)USART_SR_ORE)
|
||||
#define USART_FLAG_NE ((uint32_t)USART_SR_NE)
|
||||
#define USART_FLAG_FE ((uint32_t)USART_SR_FE)
|
||||
#define USART_FLAG_PE ((uint32_t)USART_SR_PE)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USART_Interrupt_definition USART Interrupts Definition
|
||||
* Elements values convention: 0xY000XXXX
|
||||
* - XXXX : Interrupt mask in the XX register
|
||||
* - Y : Interrupt source register (2bits)
|
||||
* - 01: CR1 register
|
||||
* - 10: CR2 register
|
||||
* - 11: CR3 register
|
||||
* @{
|
||||
*/
|
||||
#define USART_IT_PE ((uint32_t)(USART_CR1_REG_INDEX << 28U | USART_CR1_PEIE))
|
||||
#define USART_IT_TXE ((uint32_t)(USART_CR1_REG_INDEX << 28U | USART_CR1_TXEIE))
|
||||
#define USART_IT_TC ((uint32_t)(USART_CR1_REG_INDEX << 28U | USART_CR1_TCIE))
|
||||
#define USART_IT_RXNE ((uint32_t)(USART_CR1_REG_INDEX << 28U | USART_CR1_RXNEIE))
|
||||
#define USART_IT_IDLE ((uint32_t)(USART_CR1_REG_INDEX << 28U | USART_CR1_IDLEIE))
|
||||
#define USART_IT_ERR ((uint32_t)(USART_CR3_REG_INDEX << 28U | USART_CR3_EIE))
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/** @defgroup USART_Exported_Macros USART Exported Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @brief Reset USART handle state
|
||||
* @param __HANDLE__ specifies the USART Handle.
|
||||
* USART Handle selects the USARTx peripheral (USART availability and x value depending on device).
|
||||
* @retval None
|
||||
*/
|
||||
#if (USE_HAL_USART_REGISTER_CALLBACKS == 1)
|
||||
#define __HAL_USART_RESET_HANDLE_STATE(__HANDLE__) do{ \
|
||||
(__HANDLE__)->State = HAL_USART_STATE_RESET; \
|
||||
(__HANDLE__)->MspInitCallback = NULL; \
|
||||
(__HANDLE__)->MspDeInitCallback = NULL; \
|
||||
} while(0U)
|
||||
#else
|
||||
#define __HAL_USART_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_USART_STATE_RESET)
|
||||
#endif /* USE_HAL_USART_REGISTER_CALLBACKS */
|
||||
|
||||
/** @brief Check whether the specified USART flag is set or not.
|
||||
* @param __HANDLE__ specifies the USART Handle.
|
||||
* USART Handle selects the USARTx peripheral (USART availability and x value depending on device).
|
||||
* @param __FLAG__ specifies the flag to check.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg USART_FLAG_TXE: Transmit data register empty flag
|
||||
* @arg USART_FLAG_TC: Transmission Complete flag
|
||||
* @arg USART_FLAG_RXNE: Receive data register not empty flag
|
||||
* @arg USART_FLAG_IDLE: Idle Line detection flag
|
||||
* @arg USART_FLAG_ORE: Overrun Error flag
|
||||
* @arg USART_FLAG_NE: Noise Error flag
|
||||
* @arg USART_FLAG_FE: Framing Error flag
|
||||
* @arg USART_FLAG_PE: Parity Error flag
|
||||
* @retval The new state of __FLAG__ (TRUE or FALSE).
|
||||
*/
|
||||
#define __HAL_USART_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__))
|
||||
|
||||
/** @brief Clear the specified USART pending flags.
|
||||
* @param __HANDLE__ specifies the USART Handle.
|
||||
* USART Handle selects the USARTx peripheral (USART availability and x value depending on device).
|
||||
* @param __FLAG__ specifies the flag to check.
|
||||
* This parameter can be any combination of the following values:
|
||||
* @arg USART_FLAG_TC: Transmission Complete flag.
|
||||
* @arg USART_FLAG_RXNE: Receive data register not empty flag.
|
||||
*
|
||||
* @note PE (Parity error), FE (Framing error), NE (Noise error), ORE (Overrun
|
||||
* error) and IDLE (Idle line detected) flags are cleared by software
|
||||
* sequence: a read operation to USART_SR register followed by a read
|
||||
* operation to USART_DR register.
|
||||
* @note RXNE flag can be also cleared by a read to the USART_DR register.
|
||||
* @note TC flag can be also cleared by software sequence: a read operation to
|
||||
* USART_SR register followed by a write operation to USART_DR register.
|
||||
* @note TXE flag is cleared only by a write to the USART_DR register.
|
||||
*
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_USART_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR = ~(__FLAG__))
|
||||
|
||||
/** @brief Clear the USART PE pending flag.
|
||||
* @param __HANDLE__ specifies the USART Handle.
|
||||
* USART Handle selects the USARTx peripheral (USART availability and x value depending on device).
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_USART_CLEAR_PEFLAG(__HANDLE__) \
|
||||
do{ \
|
||||
__IO uint32_t tmpreg = 0x00U; \
|
||||
tmpreg = (__HANDLE__)->Instance->SR; \
|
||||
tmpreg = (__HANDLE__)->Instance->DR; \
|
||||
UNUSED(tmpreg); \
|
||||
} while(0U)
|
||||
|
||||
/** @brief Clear the USART FE pending flag.
|
||||
* @param __HANDLE__ specifies the USART Handle.
|
||||
* USART Handle selects the USARTx peripheral (USART availability and x value depending on device).
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_USART_CLEAR_FEFLAG(__HANDLE__) __HAL_USART_CLEAR_PEFLAG(__HANDLE__)
|
||||
|
||||
/** @brief Clear the USART NE pending flag.
|
||||
* @param __HANDLE__ specifies the USART Handle.
|
||||
* USART Handle selects the USARTx peripheral (USART availability and x value depending on device).
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_USART_CLEAR_NEFLAG(__HANDLE__) __HAL_USART_CLEAR_PEFLAG(__HANDLE__)
|
||||
|
||||
/** @brief Clear the USART ORE pending flag.
|
||||
* @param __HANDLE__ specifies the USART Handle.
|
||||
* USART Handle selects the USARTx peripheral (USART availability and x value depending on device).
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_USART_CLEAR_OREFLAG(__HANDLE__) __HAL_USART_CLEAR_PEFLAG(__HANDLE__)
|
||||
|
||||
/** @brief Clear the USART IDLE pending flag.
|
||||
* @param __HANDLE__ specifies the USART Handle.
|
||||
* USART Handle selects the USARTx peripheral (USART availability and x value depending on device).
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_USART_CLEAR_IDLEFLAG(__HANDLE__) __HAL_USART_CLEAR_PEFLAG(__HANDLE__)
|
||||
|
||||
/** @brief Enables or disables the specified USART interrupts.
|
||||
* @param __HANDLE__ specifies the USART Handle.
|
||||
* USART Handle selects the USARTx peripheral (USART availability and x value depending on device).
|
||||
* @param __INTERRUPT__ specifies the USART interrupt source to check.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg USART_IT_TXE: Transmit Data Register empty interrupt
|
||||
* @arg USART_IT_TC: Transmission complete interrupt
|
||||
* @arg USART_IT_RXNE: Receive Data register not empty interrupt
|
||||
* @arg USART_IT_IDLE: Idle line detection interrupt
|
||||
* @arg USART_IT_PE: Parity Error interrupt
|
||||
* @arg USART_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_USART_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28U) == USART_CR1_REG_INDEX)? ((__HANDLE__)->Instance->CR1 |= ((__INTERRUPT__) & USART_IT_MASK)): \
|
||||
(((__INTERRUPT__) >> 28U) == USART_CR2_REG_INDEX)? ((__HANDLE__)->Instance->CR2 |= ((__INTERRUPT__) & USART_IT_MASK)): \
|
||||
((__HANDLE__)->Instance->CR3 |= ((__INTERRUPT__) & USART_IT_MASK)))
|
||||
#define __HAL_USART_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28U) == USART_CR1_REG_INDEX)? ((__HANDLE__)->Instance->CR1 &= ~((__INTERRUPT__) & USART_IT_MASK)): \
|
||||
(((__INTERRUPT__) >> 28U) == USART_CR2_REG_INDEX)? ((__HANDLE__)->Instance->CR2 &= ~((__INTERRUPT__) & USART_IT_MASK)): \
|
||||
((__HANDLE__)->Instance->CR3 &= ~ ((__INTERRUPT__) & USART_IT_MASK)))
|
||||
|
||||
/** @brief Checks whether the specified USART interrupt has occurred or not.
|
||||
* @param __HANDLE__ specifies the USART Handle.
|
||||
* USART Handle selects the USARTx peripheral (USART availability and x value depending on device).
|
||||
* @param __IT__ specifies the USART interrupt source to check.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg USART_IT_TXE: Transmit Data Register empty interrupt
|
||||
* @arg USART_IT_TC: Transmission complete interrupt
|
||||
* @arg USART_IT_RXNE: Receive Data register not empty interrupt
|
||||
* @arg USART_IT_IDLE: Idle line detection interrupt
|
||||
* @arg USART_IT_ERR: Error interrupt
|
||||
* @arg USART_IT_PE: Parity Error interrupt
|
||||
* @retval The new state of __IT__ (TRUE or FALSE).
|
||||
*/
|
||||
#define __HAL_USART_GET_IT_SOURCE(__HANDLE__, __IT__) (((((__IT__) >> 28U) == USART_CR1_REG_INDEX)? (__HANDLE__)->Instance->CR1:(((((uint32_t)(__IT__)) >> 28U) == USART_CR2_REG_INDEX)? \
|
||||
(__HANDLE__)->Instance->CR2 : (__HANDLE__)->Instance->CR3)) & (((uint32_t)(__IT__)) & USART_IT_MASK))
|
||||
|
||||
/** @brief Enable USART
|
||||
* @param __HANDLE__ specifies the USART Handle.
|
||||
* USART Handle selects the USARTx peripheral (USART availability and x value depending on device).
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_USART_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE)
|
||||
|
||||
/** @brief Disable USART
|
||||
* @param __HANDLE__ specifies the USART Handle.
|
||||
* USART Handle selects the USARTx peripheral (USART availability and x value depending on device).
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_USART_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/** @addtogroup USART_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup USART_Exported_Functions_Group1
|
||||
* @{
|
||||
*/
|
||||
/* Initialization/de-initialization functions **********************************/
|
||||
HAL_StatusTypeDef HAL_USART_Init(USART_HandleTypeDef *husart);
|
||||
HAL_StatusTypeDef HAL_USART_DeInit(USART_HandleTypeDef *husart);
|
||||
void HAL_USART_MspInit(USART_HandleTypeDef *husart);
|
||||
void HAL_USART_MspDeInit(USART_HandleTypeDef *husart);
|
||||
|
||||
/* Callbacks Register/UnRegister functions ***********************************/
|
||||
#if (USE_HAL_USART_REGISTER_CALLBACKS == 1)
|
||||
HAL_StatusTypeDef HAL_USART_RegisterCallback(USART_HandleTypeDef *husart, HAL_USART_CallbackIDTypeDef CallbackID, pUSART_CallbackTypeDef pCallback);
|
||||
HAL_StatusTypeDef HAL_USART_UnRegisterCallback(USART_HandleTypeDef *husart, HAL_USART_CallbackIDTypeDef CallbackID);
|
||||
#endif /* USE_HAL_USART_REGISTER_CALLBACKS */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup USART_Exported_Functions_Group2
|
||||
* @{
|
||||
*/
|
||||
/* IO operation functions *******************************************************/
|
||||
HAL_StatusTypeDef HAL_USART_Transmit(USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size, uint32_t Timeout);
|
||||
HAL_StatusTypeDef HAL_USART_Receive(USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size, uint32_t Timeout);
|
||||
HAL_StatusTypeDef HAL_USART_TransmitReceive(USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size, uint32_t Timeout);
|
||||
HAL_StatusTypeDef HAL_USART_Transmit_IT(USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size);
|
||||
HAL_StatusTypeDef HAL_USART_Receive_IT(USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size);
|
||||
HAL_StatusTypeDef HAL_USART_TransmitReceive_IT(USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size);
|
||||
#if (defined(DMA1) || defined(DMA))
|
||||
HAL_StatusTypeDef HAL_USART_Transmit_DMA(USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size);
|
||||
HAL_StatusTypeDef HAL_USART_Receive_DMA(USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size);
|
||||
HAL_StatusTypeDef HAL_USART_TransmitReceive_DMA(USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size);
|
||||
HAL_StatusTypeDef HAL_USART_DMAPause(USART_HandleTypeDef *husart);
|
||||
HAL_StatusTypeDef HAL_USART_DMAResume(USART_HandleTypeDef *husart);
|
||||
HAL_StatusTypeDef HAL_USART_DMAStop(USART_HandleTypeDef *husart);
|
||||
#endif /* DMA1 or DMA */
|
||||
/* Transfer Abort functions */
|
||||
HAL_StatusTypeDef HAL_USART_Abort(USART_HandleTypeDef *husart);
|
||||
HAL_StatusTypeDef HAL_USART_Abort_IT(USART_HandleTypeDef *husart);
|
||||
|
||||
void HAL_USART_IRQHandler(USART_HandleTypeDef *husart);
|
||||
void HAL_USART_TxCpltCallback(USART_HandleTypeDef *husart);
|
||||
void HAL_USART_TxHalfCpltCallback(USART_HandleTypeDef *husart);
|
||||
void HAL_USART_RxCpltCallback(USART_HandleTypeDef *husart);
|
||||
void HAL_USART_RxHalfCpltCallback(USART_HandleTypeDef *husart);
|
||||
void HAL_USART_TxRxCpltCallback(USART_HandleTypeDef *husart);
|
||||
void HAL_USART_ErrorCallback(USART_HandleTypeDef *husart);
|
||||
void HAL_USART_AbortCpltCallback(USART_HandleTypeDef *husart);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup USART_Exported_Functions_Group3
|
||||
* @{
|
||||
*/
|
||||
/* Peripheral State functions ************************************************/
|
||||
HAL_USART_StateTypeDef HAL_USART_GetState(USART_HandleTypeDef *husart);
|
||||
uint32_t HAL_USART_GetError(USART_HandleTypeDef *husart);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/* Private types -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
/** @defgroup USART_Private_Constants USART Private Constants
|
||||
* @{
|
||||
*/
|
||||
/** @brief USART interruptions flag mask
|
||||
*
|
||||
*/
|
||||
#define USART_IT_MASK ((uint32_t) USART_CR1_PEIE | USART_CR1_TXEIE | USART_CR1_TCIE | USART_CR1_RXNEIE | \
|
||||
USART_CR1_IDLEIE | USART_CR3_CTSIE | USART_CR3_EIE )
|
||||
|
||||
#define USART_CR1_REG_INDEX 1U
|
||||
#define USART_CR2_REG_INDEX 2U
|
||||
#define USART_CR3_REG_INDEX 3U
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Private macros ------------------------------------------------------------*/
|
||||
/** @defgroup USART_Private_Macros USART Private Macros
|
||||
* @{
|
||||
*/
|
||||
#define IS_USART_LASTBIT(LASTBIT) (((LASTBIT) == USART_LASTBIT_DISABLE) || \
|
||||
((LASTBIT) == USART_LASTBIT_ENABLE))
|
||||
|
||||
#define IS_USART_PHASE(CPHA) (((CPHA) == USART_PHASE_1EDGE) || \
|
||||
((CPHA) == USART_PHASE_2EDGE))
|
||||
|
||||
#define IS_USART_POLARITY(CPOL) (((CPOL) == USART_POLARITY_LOW) || \
|
||||
((CPOL) == USART_POLARITY_HIGH))
|
||||
|
||||
#define IS_USART_CLOCK(CLOCK) (((CLOCK) == USART_CLOCK_DISABLE) || \
|
||||
((CLOCK) == USART_CLOCK_ENABLE))
|
||||
|
||||
#define IS_USART_WORD_LENGTH(LENGTH) (((LENGTH) == USART_WORDLENGTH_8B) || \
|
||||
((LENGTH) == USART_WORDLENGTH_9B))
|
||||
|
||||
#define IS_USART_STOPBITS(STOPBITS) (((STOPBITS) == USART_STOPBITS_1) || \
|
||||
((STOPBITS) == USART_STOPBITS_2))
|
||||
|
||||
#define IS_USART_PARITY(PARITY) (((PARITY) == USART_PARITY_NONE) || \
|
||||
((PARITY) == USART_PARITY_EVEN) || \
|
||||
((PARITY) == USART_PARITY_ODD))
|
||||
|
||||
#define IS_USART_MODE(MODE) ((((MODE) & (~((uint32_t)USART_MODE_TX_RX))) == 0x00U) && ((MODE) != 0x00U))
|
||||
|
||||
#define IS_USART_BAUDRATE(BAUDRATE) ((BAUDRATE) <= 4500000U)
|
||||
|
||||
#define USART_DIV(_PCLK_, _BAUD_) (((_PCLK_)*25U)/(4U*(_BAUD_)))
|
||||
|
||||
#define USART_DIVMANT(_PCLK_, _BAUD_) (USART_DIV((_PCLK_), (_BAUD_))/100U)
|
||||
|
||||
#define USART_DIVFRAQ(_PCLK_, _BAUD_) (((USART_DIV((_PCLK_), (_BAUD_)) - (USART_DIVMANT((_PCLK_), (_BAUD_)) * 100U)) * 16U + 50U) / 100U)
|
||||
|
||||
#define USART_BRR(_PCLK_, _BAUD_) (((USART_DIVMANT((_PCLK_), (_BAUD_)) << 4U) + \
|
||||
((USART_DIVFRAQ((_PCLK_), (_BAUD_)) & 0xF0U) << 1U)) + \
|
||||
(USART_DIVFRAQ((_PCLK_), (_BAUD_)) & 0x0FU))
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
/** @defgroup USART_Private_Functions USART Private Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __PY32F0xx_HAL_USART_H */
|
||||
|
||||
/************************ (C) COPYRIGHT Puya *****END OF FILE****/
|
||||
301
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_wwdg.h
Normal file
301
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_hal_wwdg.h
Normal file
@@ -0,0 +1,301 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file py32f0xx_hal_wwdg.h
|
||||
* @author MCU Application Team
|
||||
* @brief Header file of WWDG HAL module.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) Puya Semiconductor Co.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __PY32F0xx_HAL_WWDG_H
|
||||
#define __PY32F0xx_HAL_WWDG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "py32f0xx_hal_def.h"
|
||||
|
||||
/** @addtogroup PY32F0xx_HAL_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup WWDG
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/** @defgroup WWDG_Exported_Types WWDG Exported Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief WWDG Init structure definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t Prescaler; /*!< Specifies the prescaler value of the WWDG.
|
||||
This parameter can be a value of @ref WWDG_Prescaler */
|
||||
|
||||
uint32_t Window; /*!< Specifies the WWDG window value to be compared to the downcounter.
|
||||
This parameter must be a number Min_Data = 0x40 and Max_Data = 0x7F */
|
||||
|
||||
uint32_t Counter; /*!< Specifies the WWDG free-running downcounter value.
|
||||
This parameter must be a number between Min_Data = 0x40 and Max_Data = 0x7F */
|
||||
|
||||
uint32_t EWIMode ; /*!< Specifies if WWDG Early Wakeup Interupt is enable or not.
|
||||
This parameter can be a value of @ref WWDG_EWI_Mode */
|
||||
|
||||
} WWDG_InitTypeDef;
|
||||
|
||||
/**
|
||||
* @brief WWDG handle Structure definition
|
||||
*/
|
||||
#if (USE_HAL_WWDG_REGISTER_CALLBACKS == 1)
|
||||
typedef struct __WWDG_HandleTypeDef
|
||||
#else
|
||||
typedef struct
|
||||
#endif
|
||||
{
|
||||
WWDG_TypeDef *Instance; /*!< Register base address */
|
||||
|
||||
WWDG_InitTypeDef Init; /*!< WWDG required parameters */
|
||||
#if (USE_HAL_WWDG_REGISTER_CALLBACKS == 1)
|
||||
void (* EwiCallback)(struct __WWDG_HandleTypeDef *hwwdg); /*!< WWDG Early WakeUp Interrupt callback */
|
||||
|
||||
void (* MspInitCallback)(struct __WWDG_HandleTypeDef *hwwdg); /*!< WWDG Msp Init callback */
|
||||
#endif
|
||||
} WWDG_HandleTypeDef;
|
||||
|
||||
#if (USE_HAL_WWDG_REGISTER_CALLBACKS == 1)
|
||||
/**
|
||||
* @brief HAL WWDG common Callback ID enumeration definition
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
HAL_WWDG_EWI_CB_ID = 0x00u, /*!< WWDG EWI callback ID */
|
||||
HAL_WWDG_MSPINIT_CB_ID = 0x01u, /*!< WWDG MspInit callback ID */
|
||||
} HAL_WWDG_CallbackIDTypeDef;
|
||||
|
||||
/**
|
||||
* @brief HAL WWDG Callback pointer definition
|
||||
*/
|
||||
typedef void (*pWWDG_CallbackTypeDef)(WWDG_HandleTypeDef * hppp); /*!< pointer to a WWDG common callback functions */
|
||||
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
||||
/** @defgroup WWDG_Exported_Constants WWDG Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup WWDG_Interrupt_definition WWDG Interrupt definition
|
||||
* @{
|
||||
*/
|
||||
#define WWDG_IT_EWI WWDG_CFR_EWI /*!< Early wakeup interrupt */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup WWDG_Flag_definition WWDG Flag definition
|
||||
* @brief WWDG Flag definition
|
||||
* @{
|
||||
*/
|
||||
#define WWDG_FLAG_EWIF WWDG_SR_EWIF /*!< Early wakeup interrupt flag */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup WWDG_Prescaler WWDG Prescaler
|
||||
* @{
|
||||
*/
|
||||
#define WWDG_PRESCALER_1 0x00000000U /*!< WWDG counter clock = (PCLK1/4096)/1 */
|
||||
#define WWDG_PRESCALER_2 WWDG_CFR_WDGTB_0 /*!< WWDG counter clock = (PCLK1/4096)/2 */
|
||||
#define WWDG_PRESCALER_4 WWDG_CFR_WDGTB_1 /*!< WWDG counter clock = (PCLK1/4096)/4 */
|
||||
#define WWDG_PRESCALER_8 WWDG_CFR_WDGTB /*!< WWDG counter clock = (PCLK1/4096)/8 */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup WWDG_EWI_Mode WWDG Early Wakeup Interrupt Mode
|
||||
* @{
|
||||
*/
|
||||
#define WWDG_EWI_DISABLE 0x00000000U /*!< EWI Disable */
|
||||
#define WWDG_EWI_ENABLE WWDG_CFR_EWI /*!< EWI Enable */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Private macros ------------------------------------------------------------*/
|
||||
|
||||
/** @defgroup WWDG_Private_Macros WWDG Private Macros
|
||||
* @{
|
||||
*/
|
||||
#define IS_WWDG_PRESCALER(__PRESCALER__) (((__PRESCALER__) == WWDG_PRESCALER_1) || \
|
||||
((__PRESCALER__) == WWDG_PRESCALER_2) || \
|
||||
((__PRESCALER__) == WWDG_PRESCALER_4) || \
|
||||
((__PRESCALER__) == WWDG_PRESCALER_8))
|
||||
|
||||
#define IS_WWDG_WINDOW(__WINDOW__) (((__WINDOW__) >= WWDG_CFR_W_6) && ((__WINDOW__) <= WWDG_CFR_W))
|
||||
|
||||
#define IS_WWDG_COUNTER(__COUNTER__) (((__COUNTER__) >= WWDG_CR_T_6) && ((__COUNTER__) <= WWDG_CR_T))
|
||||
|
||||
#define IS_WWDG_EWI_MODE(__MODE__) (((__MODE__) == WWDG_EWI_ENABLE) || \
|
||||
((__MODE__) == WWDG_EWI_DISABLE))
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/* Exported macros ------------------------------------------------------------*/
|
||||
|
||||
/** @defgroup WWDG_Exported_Macros WWDG Exported Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Enables the WWDG peripheral.
|
||||
* @param __HANDLE__: WWDG handle
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_WWDG_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CR, WWDG_CR_WDGA)
|
||||
|
||||
/**
|
||||
* @brief Enables the WWDG early wakeup interrupt.
|
||||
* @param __HANDLE__: WWDG handle
|
||||
* @param __INTERRUPT__ specifies the interrupt to enable.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg WWDG_IT_EWI: Early wakeup interrupt
|
||||
* @note Once enabled this interrupt cannot be disabled except by a system reset.
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_WWDG_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BIT((__HANDLE__)->Instance->CFR, (__INTERRUPT__))
|
||||
|
||||
/**
|
||||
* @brief Checks whether the selected WWDG interrupt has occurred or not.
|
||||
* @param __HANDLE__ WWDG handle
|
||||
* @param __INTERRUPT__ specifies the it to check.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg WWDG_FLAG_EWIF: Early wakeup interrupt IT
|
||||
* @retval The new state of WWDG_FLAG (SET or RESET).
|
||||
*/
|
||||
#define __HAL_WWDG_GET_IT(__HANDLE__, __INTERRUPT__) __HAL_WWDG_GET_FLAG((__HANDLE__),(__INTERRUPT__))
|
||||
|
||||
/** @brief Clear the WWDG's interrupt pending bits
|
||||
* bits to clear the selected interrupt pending bits.
|
||||
* @param __HANDLE__: WWDG handle
|
||||
* @param __INTERRUPT__: specifies the interrupt pending bit to clear.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg WWDG_FLAG_EWIF: Early wakeup interrupt flag
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_WWDG_CLEAR_IT(__HANDLE__, __INTERRUPT__) __HAL_WWDG_CLEAR_FLAG((__HANDLE__), (__INTERRUPT__))
|
||||
|
||||
/**
|
||||
* @brief Check whether the specified WWDG flag is set or not.
|
||||
* @param __HANDLE__ WWDG handle
|
||||
* @param __FLAG__ specifies the flag to check.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg WWDG_FLAG_EWIF: Early wakeup interrupt flag
|
||||
* @retval The new state of WWDG_FLAG (SET or RESET).
|
||||
*/
|
||||
#define __HAL_WWDG_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__))
|
||||
|
||||
/**
|
||||
* @brief Clears the WWDG's pending flags.
|
||||
* @param __HANDLE__: WWDG handle
|
||||
* @param __FLAG__: specifies the flag to clear.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg WWDG_FLAG_EWIF: Early wakeup interrupt flag
|
||||
* @retval None
|
||||
*/
|
||||
#define __HAL_WWDG_CLEAR_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR) = ~(__FLAG__))
|
||||
|
||||
/** @brief Checks if the specified WWDG interrupt source is enabled or disabled.
|
||||
* @param __HANDLE__: WWDG Handle.
|
||||
* @param __INTERRUPT__: specifies the WWDG interrupt source to check.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg WWDG_IT_EWI: Early Wakeup Interrupt
|
||||
* @retval state of __INTERRUPT__ (TRUE or FALSE).
|
||||
*/
|
||||
#define __HAL_WWDG_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CFR & (__INTERRUPT__)) == (__INTERRUPT__))
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/** @addtogroup WWDG_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup WWDG_Exported_Functions_Group1
|
||||
* @{
|
||||
*/
|
||||
/* Initialization/de-initialization functions **********************************/
|
||||
HAL_StatusTypeDef HAL_WWDG_Init(WWDG_HandleTypeDef *hwwdg);
|
||||
void HAL_WWDG_MspInit(WWDG_HandleTypeDef *hwwdg);
|
||||
|
||||
/* Callbacks Register/UnRegister functions ***********************************/
|
||||
#if (USE_HAL_WWDG_REGISTER_CALLBACKS == 1)
|
||||
HAL_StatusTypeDef HAL_WWDG_RegisterCallback(WWDG_HandleTypeDef *hwwdg, HAL_WWDG_CallbackIDTypeDef CallbackID, pWWDG_CallbackTypeDef pCallback);
|
||||
HAL_StatusTypeDef HAL_WWDG_UnRegisterCallback(WWDG_HandleTypeDef *hwwdg, HAL_WWDG_CallbackIDTypeDef CallbackID);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup WWDG_Exported_Functions_Group2
|
||||
* @{
|
||||
*/
|
||||
/* I/O operation functions ******************************************************/
|
||||
HAL_StatusTypeDef HAL_WWDG_Refresh(WWDG_HandleTypeDef *hwwdg);
|
||||
void HAL_WWDG_IRQHandler(WWDG_HandleTypeDef *hwwdg);
|
||||
void HAL_WWDG_EarlyWakeupCallback(WWDG_HandleTypeDef *hwwdg);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __PY32F0xx_HAL_WWDG_H */
|
||||
|
||||
/************************ (C) COPYRIGHT Puya *****END OF FILE****/
|
||||
3282
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_ll_adc.h
Normal file
3282
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_ll_adc.h
Normal file
@@ -0,0 +1,3282 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file py32f0xx_ll_adc.h
|
||||
* @author MCU Application Team
|
||||
* @brief Header file of ADC LL module.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) Puya Semiconductor Co.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __PY32F0XX_LL_ADC_H
|
||||
#define __PY32F0XX_LL_ADC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "py32f0xx.h"
|
||||
#include "py32f0xx_ll_bus.h"
|
||||
/** @addtogroup PY320xx_LL_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if defined (ADC1)
|
||||
|
||||
/** @defgroup ADC_LL ADC
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Private types -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
/** @defgroup ADC_LL_Private_Constants ADC Private Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Internal mask for ADC group regular trigger: */
|
||||
/* To select into literal LL_ADC_REG_TRIG_x the relevant bits for: */
|
||||
/* - regular trigger source */
|
||||
/* - regular trigger edge */
|
||||
#define ADC_REG_TRIG_EXT_EDGE_DEFAULT (ADC_CFGR1_EXTEN_0) /* Trigger edge set to rising edge (default setting for compatibility with some ADC on other PY32 families having this setting set by HW default value) */
|
||||
|
||||
/* Mask containing trigger source masks for each of possible */
|
||||
/* trigger edge selection duplicated with shifts [0; 4; 8; 12] */
|
||||
/* corresponding to {SW start; ext trigger; ext trigger; ext trigger}. */
|
||||
#define ADC_REG_TRIG_SOURCE_MASK (((LL_ADC_REG_TRIG_SOFTWARE & ADC_CFGR1_EXTSEL) << (4U * 0U)) | \
|
||||
(( ADC_CFGR1_EXTSEL) << (4U * 1U)) | \
|
||||
(( ADC_CFGR1_EXTSEL) << (4U * 2U)) | \
|
||||
(( ADC_CFGR1_EXTSEL) << (4U * 3U)) )
|
||||
|
||||
/* Mask containing trigger edge masks for each of possible */
|
||||
/* trigger edge selection duplicated with shifts [0; 4; 8; 12] */
|
||||
/* corresponding to {SW start; ext trigger; ext trigger; ext trigger}. */
|
||||
#define ADC_REG_TRIG_EDGE_MASK (((LL_ADC_REG_TRIG_SOFTWARE & ADC_CFGR1_EXTEN) << (4U * 0U)) | \
|
||||
((ADC_REG_TRIG_EXT_EDGE_DEFAULT) << (4U * 1U)) | \
|
||||
((ADC_REG_TRIG_EXT_EDGE_DEFAULT) << (4U * 2U)) | \
|
||||
((ADC_REG_TRIG_EXT_EDGE_DEFAULT) << (4U * 3U)) )
|
||||
|
||||
/* Definition of ADC group regular trigger bits information. */
|
||||
#define ADC_REG_TRIG_EXTSEL_BITOFFSET_POS ( 6U) /* Value equivalent to POSITION_VAL(ADC_CFGR1_EXTSEL) */
|
||||
#define ADC_REG_TRIG_EXTEN_BITOFFSET_POS (10U) /* Value equivalent to POSITION_VAL(ADC_CFGR1_EXTEN) */
|
||||
|
||||
|
||||
|
||||
/* Internal mask for ADC channel: */
|
||||
/* To select into literal LL_ADC_CHANNEL_x the relevant bits for: */
|
||||
/* - channel identifier defined by number */
|
||||
/* - channel identifier defined by bitfield */
|
||||
/* - channel differentiation between external channels (connected to */
|
||||
/* GPIO pins) and internal channels (connected to internal paths) */
|
||||
#define ADC_CHANNEL_ID_NUMBER_MASK (ADC_CFGR1_AWDCH)
|
||||
#define ADC_CHANNEL_ID_BITFIELD_MASK (ADC_CHSELR_CHSEL)
|
||||
#define ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS (26U)/* Value equivalent to POSITION_VAL(ADC_CHANNEL_ID_NUMBER_MASK) */
|
||||
#define ADC_CHANNEL_ID_MASK (ADC_CHANNEL_ID_NUMBER_MASK | ADC_CHANNEL_ID_BITFIELD_MASK | ADC_CHANNEL_ID_INTERNAL_CH_MASK)
|
||||
/* Equivalent mask of ADC_CHANNEL_NUMBER_MASK aligned on register LSB (bit 0) */
|
||||
#define ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0 (0x0000001FU) /* Equivalent to shift: (ADC_CHANNEL_NUMBER_MASK >> POSITION_VAL(ADC_CHANNEL_NUMBER_MASK)) */
|
||||
|
||||
/* Channel differentiation between external and internal channels */
|
||||
#define ADC_CHANNEL_ID_INTERNAL_CH (0x80000000U) /* Marker of internal channel */
|
||||
#define ADC_CHANNEL_ID_INTERNAL_CH_MASK (ADC_CHANNEL_ID_INTERNAL_CH)
|
||||
|
||||
/* Definition of channels ID number information to be inserted into */
|
||||
/* channels literals definition. */
|
||||
#define ADC_CHANNEL_0_NUMBER (0x00000000U)
|
||||
#define ADC_CHANNEL_1_NUMBER ( ADC_CFGR1_AWDCH_0)
|
||||
#define ADC_CHANNEL_2_NUMBER ( ADC_CFGR1_AWDCH_1 )
|
||||
#define ADC_CHANNEL_3_NUMBER ( ADC_CFGR1_AWDCH_1 | ADC_CFGR1_AWDCH_0)
|
||||
#define ADC_CHANNEL_4_NUMBER ( ADC_CFGR1_AWDCH_2 )
|
||||
#define ADC_CHANNEL_5_NUMBER ( ADC_CFGR1_AWDCH_2 | ADC_CFGR1_AWDCH_0)
|
||||
#define ADC_CHANNEL_6_NUMBER ( ADC_CFGR1_AWDCH_2 | ADC_CFGR1_AWDCH_1 )
|
||||
#define ADC_CHANNEL_7_NUMBER ( ADC_CFGR1_AWDCH_2 | ADC_CFGR1_AWDCH_1 | ADC_CFGR1_AWDCH_0)
|
||||
#define ADC_CHANNEL_8_NUMBER (ADC_CFGR1_AWDCH_3 )
|
||||
#define ADC_CHANNEL_9_NUMBER (ADC_CFGR1_AWDCH_3 | ADC_CFGR1_AWDCH_0)
|
||||
#define ADC_CHANNEL_11_NUMBER (ADC_CFGR1_AWDCH_3 | ADC_CFGR1_AWDCH_1 | ADC_CFGR1_AWDCH_0)
|
||||
#define ADC_CHANNEL_12_NUMBER (ADC_CFGR1_AWDCH_3 | ADC_CFGR1_AWDCH_2 )
|
||||
|
||||
/* Definition of channels ID bitfield information to be inserted into */
|
||||
/* channels literals definition. */
|
||||
#define ADC_CHANNEL_0_BITFIELD (ADC_CHSELR_CHSEL0)
|
||||
#define ADC_CHANNEL_1_BITFIELD (ADC_CHSELR_CHSEL1)
|
||||
#define ADC_CHANNEL_2_BITFIELD (ADC_CHSELR_CHSEL2)
|
||||
#define ADC_CHANNEL_3_BITFIELD (ADC_CHSELR_CHSEL3)
|
||||
#define ADC_CHANNEL_4_BITFIELD (ADC_CHSELR_CHSEL4)
|
||||
#define ADC_CHANNEL_5_BITFIELD (ADC_CHSELR_CHSEL5)
|
||||
#define ADC_CHANNEL_6_BITFIELD (ADC_CHSELR_CHSEL6)
|
||||
#define ADC_CHANNEL_7_BITFIELD (ADC_CHSELR_CHSEL7)
|
||||
#define ADC_CHANNEL_8_BITFIELD (ADC_CHSELR_CHSEL8)
|
||||
#define ADC_CHANNEL_9_BITFIELD (ADC_CHSELR_CHSEL9)
|
||||
#define ADC_CHANNEL_11_BITFIELD (ADC_CHSELR_CHSEL11)
|
||||
#define ADC_CHANNEL_12_BITFIELD (ADC_CHSELR_CHSEL12)
|
||||
|
||||
|
||||
/* Internal mask for ADC analog watchdog: */
|
||||
/* To select into literals LL_ADC_AWD_CHANNELx_xxx the relevant bits for: */
|
||||
/* - analog watchdog 1: monitored channel defined by number, */
|
||||
/* selection of ADC group (ADC group regular). */
|
||||
|
||||
/* Internal register offset for ADC analog watchdog channel configuration */
|
||||
#define ADC_AWD_CR1_REGOFFSET (0x00000000U)
|
||||
|
||||
#define ADC_AWD_CRX_REGOFFSET_MASK (ADC_AWD_CR1_REGOFFSET)
|
||||
|
||||
#define ADC_AWD_CR1_CHANNEL_MASK (ADC_CFGR1_AWDCH | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL)
|
||||
#define ADC_AWD_CR_ALL_CHANNEL_MASK (ADC_AWD_CR1_CHANNEL_MASK)
|
||||
|
||||
/* Internal register offset for ADC analog watchdog threshold configuration */
|
||||
#define ADC_AWD_TR1_REGOFFSET (ADC_AWD_CR1_REGOFFSET)
|
||||
#define ADC_AWD_TRX_REGOFFSET_MASK (ADC_AWD_TR1_REGOFFSET)
|
||||
|
||||
|
||||
/* ADC registers bits positions */
|
||||
#define ADC_CFGR1_RES_BITOFFSET_POS ( 3U) /* Value equivalent to POSITION_VAL(ADC_CFGR1_RESSEL) */
|
||||
#define ADC_CFGR1_AWDSGL_BITOFFSET_POS (22U) /* Value equivalent to POSITION_VAL(ADC_CFGR1_AWDSGL) */
|
||||
#define ADC_TR_HT_BITOFFSET_POS (16U) /* Value equivalent to POSITION_VAL(ADC_TR_HT) */
|
||||
#define ADC_CHSELR_CHSEL0_BITOFFSET_POS ( 0U) /* Value equivalent to POSITION_VAL(ADC_CHSELR_CHSEL0) */
|
||||
#define ADC_CHSELR_CHSEL1_BITOFFSET_POS ( 1U) /* Value equivalent to POSITION_VAL(ADC_CHSELR_CHSEL1) */
|
||||
#define ADC_CHSELR_CHSEL2_BITOFFSET_POS ( 2U) /* Value equivalent to POSITION_VAL(ADC_CHSELR_CHSEL2) */
|
||||
#define ADC_CHSELR_CHSEL3_BITOFFSET_POS ( 3U) /* Value equivalent to POSITION_VAL(ADC_CHSELR_CHSEL3) */
|
||||
#define ADC_CHSELR_CHSEL4_BITOFFSET_POS ( 4U) /* Value equivalent to POSITION_VAL(ADC_CHSELR_CHSEL4) */
|
||||
#define ADC_CHSELR_CHSEL5_BITOFFSET_POS ( 5U) /* Value equivalent to POSITION_VAL(ADC_CHSELR_CHSEL5) */
|
||||
#define ADC_CHSELR_CHSEL6_BITOFFSET_POS ( 6U) /* Value equivalent to POSITION_VAL(ADC_CHSELR_CHSEL6) */
|
||||
#define ADC_CHSELR_CHSEL7_BITOFFSET_POS ( 7U) /* Value equivalent to POSITION_VAL(ADC_CHSELR_CHSEL7) */
|
||||
#define ADC_CHSELR_CHSEL8_BITOFFSET_POS ( 8U) /* Value equivalent to POSITION_VAL(ADC_CHSELR_CHSEL8) */
|
||||
#define ADC_CHSELR_CHSEL9_BITOFFSET_POS ( 9U) /* Value equivalent to POSITION_VAL(ADC_CHSELR_CHSEL9) */
|
||||
#define ADC_CHSELR_CHSEL11_BITOFFSET_POS (11U) /* Value equivalent to POSITION_VAL(ADC_CHSELR_CHSEL11) */
|
||||
#define ADC_CHSELR_CHSEL12_BITOFFSET_POS (12U) /* Value equivalent to POSITION_VAL(ADC_CHSELR_CHSEL12) */
|
||||
|
||||
|
||||
|
||||
/* ADC registers bits groups */
|
||||
#define ADC_CR_BITS_PROPERTY_RS (ADC_CR_ADCAL | ADC_CR_ADSTP | ADC_CR_ADSTART | ADC_CR_ADEN) /* ADC register CR bits with HW property "rs": Software can read as well as set this bit. Writing '0' has no effect on the bit value. */
|
||||
|
||||
|
||||
/* ADC internal channels related definitions */
|
||||
/* Internal voltage reference VrefInt */
|
||||
#define VREFINT_CAL_VREF ( 1200U) /* Analog voltage reference (Vref+) value (tolerance: +-10 mV) (unit: mV). */
|
||||
/* Temperature sensor */
|
||||
#define TEMPSENSOR_CAL1_ADDR ((uint16_t*) (0x1fff0f14)) /* Internal temperature sensor, address of parameter TS_CAL1: On PY32F0, temperature sensor ADC raw data acquired at temperature 30 DegC (tolerance: +-5 DegC), Vref+ = 3.3 V (tolerance: +-10 mV). */
|
||||
#define TEMPSENSOR_CAL2_ADDR ((uint16_t*) (0x1fff0f18)) /* Internal temperature sensor, address of parameter TS_CAL2: On PY32F0, temperature sensor ADC raw data acquired at temperature 85 DegC (tolerance: +-5 DegC), Vref+ = 3.3 V (tolerance: +-10 mV). */
|
||||
#define TEMPSENSOR_CAL1_TEMP (( int32_t) 30) /* Internal temperature sensor, temperature at which temperature sensor has been calibrated in production for data into TEMPSENSOR_CAL1_ADDR (tolerance: +-5 DegC) (unit: DegC). */
|
||||
#define TEMPSENSOR_CAL2_TEMP (( int32_t) 85) /* Internal temperature sensor, temperature at which temperature sensor has been calibrated in production for data into TEMPSENSOR_CAL2_ADDR (tolerance: +-5 DegC) (unit: DegC). */
|
||||
#define TEMPSENSOR_CAL_VREFANALOG ( 3300U) /* Analog voltage reference (Vref+) voltage with which temperature sensor has been calibrated in production (+-10 mV) (unit: mV). */
|
||||
|
||||
/* Definitions of ADC hardware constraints delays */
|
||||
/* Note: Only ADC IP HW delays are defined in ADC LL driver driver, */
|
||||
/* not timeout values: */
|
||||
/* Timeout values for ADC operations are dependent to device clock */
|
||||
/* configuration (system clock versus ADC clock), */
|
||||
/* and therefore must be defined in user application. */
|
||||
/* Refer to @ref ADC_LL_EC_HW_DELAYS for description of ADC timeout */
|
||||
/* values definition. */
|
||||
/* Unit: CPU cycles. */
|
||||
#define LL_ADC_CLOCK_RATIO_VS_CPU_HIGHEST ((uint32_t) 512U * 16U * 4U)
|
||||
#define LL_ADC_TIMEOUT_DISABLE_CPU_CYCLES (LL_ADC_CLOCK_RATIO_VS_CPU_HIGHEST * 1U)
|
||||
#define LL_ADC_TIMEOUT_STOP_CONVERSION_CPU_CYCLES (LL_ADC_CLOCK_RATIO_VS_CPU_HIGHEST * 1U)
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
#if defined(USE_FULL_LL_DRIVER)
|
||||
/** @defgroup ADC_LL_ES_INIT ADC Exported Init structure
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Structure definition of some features of ADC instance.
|
||||
* @note These parameters have an impact on ADC scope: ADC instance.
|
||||
* Refer to corresponding unitary functions into
|
||||
* @ref ADC_LL_EF_Configuration_ADC_Instance .
|
||||
* @note The setting of these parameters by function @ref LL_ADC_Init()
|
||||
* is conditioned to ADC state:
|
||||
* ADC instance must be disabled.
|
||||
* This condition is applied to all ADC features, for efficiency
|
||||
* and compatibility over all PY32 families. However, the different
|
||||
* features can be set under different ADC state conditions
|
||||
* (setting possible with ADC enabled without conversion on going,
|
||||
* ADC enabled with conversion on going, ...)
|
||||
* Each feature can be updated afterwards with a unitary function
|
||||
* and potentially with ADC in a different state than disabled,
|
||||
* refer to description of each function for setting
|
||||
* conditioned to ADC state.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t Clock; /*!< Set ADC instance clock source and prescaler.
|
||||
This parameter can be a value of @ref ADC_LL_EC_CLOCK_SOURCE
|
||||
@note On this PY32 serie, this parameter has some clock ratio constraints:
|
||||
Note: In case of usage of the ADC dedicated HSI RC oscillator, it must be preliminarily enabled at RCC top level.
|
||||
Note: This parameter can be modified only if the ADC is disabled
|
||||
|
||||
This feature can be modified afterwards using unitary function @ref LL_ADC_SetClock().
|
||||
For more details, refer to description of this function. */
|
||||
|
||||
uint32_t Resolution; /*!< Set ADC resolution.
|
||||
This parameter can be a value of @ref ADC_LL_EC_RESOLUTION
|
||||
|
||||
This feature can be modified afterwards using unitary function @ref LL_ADC_SetResolution(). */
|
||||
|
||||
uint32_t DataAlignment; /*!< Set ADC conversion data alignment.
|
||||
This parameter can be a value of @ref ADC_LL_EC_DATA_ALIGN
|
||||
|
||||
This feature can be modified afterwards using unitary function @ref LL_ADC_SetDataAlignment(). */
|
||||
|
||||
uint32_t LowPowerMode; /*!< Set ADC low power mode.
|
||||
This parameter can be a value of @ref ADC_LL_EC_LP_MODE
|
||||
|
||||
This feature can be modified afterwards using unitary function @ref LL_ADC_SetLowPowerMode(). */
|
||||
|
||||
} LL_ADC_InitTypeDef;
|
||||
|
||||
/**
|
||||
* @brief Structure definition of some features of ADC group regular.
|
||||
* @note These parameters have an impact on ADC scope: ADC group regular.
|
||||
* Refer to corresponding unitary functions into
|
||||
* @ref ADC_LL_EF_Configuration_ADC_Group_Regular
|
||||
* (functions with prefix "REG").
|
||||
* @note The setting of these parameters by function @ref LL_ADC_REG_Init()
|
||||
* is conditioned to ADC state:
|
||||
* ADC instance must be disabled.
|
||||
* This condition is applied to all ADC features, for efficiency
|
||||
* and compatibility over all PY32 families. However, the different
|
||||
* features can be set under different ADC state conditions
|
||||
* (setting possible with ADC enabled without conversion on going,
|
||||
* ADC enabled with conversion on going, ...)
|
||||
* Each feature can be updated afterwards with a unitary function
|
||||
* and potentially with ADC in a different state than disabled,
|
||||
* refer to description of each function for setting
|
||||
* conditioned to ADC state.
|
||||
* @note Depending on devices and packages, DMA may not be available.
|
||||
* Refer to device datasheet for DMA availability.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t TriggerSource; /*!< Set ADC group regular conversion trigger source: internal (SW start) or from external IP (timer event).
|
||||
This parameter can be a value of @ref ADC_LL_EC_REG_TRIGGER_SOURCE
|
||||
@note On this PY32 serie, setting trigger source to external trigger also set trigger polarity to rising edge
|
||||
(default setting for compatibility with some ADC on other PY32 families having this setting set by HW default value).
|
||||
In case of need to modify trigger edge, use function @ref LL_ADC_REG_SetTriggerEdge().
|
||||
|
||||
This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetTriggerSource(). */
|
||||
|
||||
uint32_t SequencerDiscont; /*!< Set ADC group regular sequencer discontinuous mode: sequence subdivided and scan conversions interrupted every selected number of ranks.
|
||||
This parameter can be a value of @ref ADC_LL_EC_REG_SEQ_DISCONT_MODE
|
||||
@note This parameter has an effect only if group regular sequencer is enabled
|
||||
(several ADC channels enabled in group regular sequencer).
|
||||
|
||||
This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetSequencerDiscont(). */
|
||||
|
||||
uint32_t ContinuousMode; /*!< Set ADC continuous conversion mode on ADC group regular, whether ADC conversions are performed in single mode (one conversion per trigger) or in continuous mode (after the first trigger, following conversions launched successively automatically).
|
||||
This parameter can be a value of @ref ADC_LL_EC_REG_CONTINUOUS_MODE
|
||||
Note: It is not possible to enable both ADC group regular continuous mode and discontinuous mode.
|
||||
|
||||
This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetContinuousMode(). */
|
||||
#if (defined(DMA) || defined(DMA1))
|
||||
uint32_t DMATransfer; /*!< Set ADC group regular conversion data transfer: no transfer or transfer by DMA, and DMA requests mode.
|
||||
This parameter can be a value of @ref ADC_LL_EC_REG_DMA_TRANSFER
|
||||
|
||||
This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetDMATransfer(). */
|
||||
#endif
|
||||
|
||||
uint32_t Overrun; /*!< Set ADC group regular behavior in case of overrun:
|
||||
data preserved or overwritten.
|
||||
This parameter can be a value of @ref ADC_LL_EC_REG_OVR_DATA_BEHAVIOR
|
||||
|
||||
This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetOverrun(). */
|
||||
|
||||
} LL_ADC_REG_InitTypeDef;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif /* USE_FULL_LL_DRIVER */
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/** @defgroup ADC_LL_Exported_Constants ADC Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_LL_EC_FLAG ADC flags
|
||||
* @brief Flags defines which can be used with LL_ADC_ReadReg function
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define LL_ADC_FLAG_EOC ADC_ISR_EOC /*!< ADC flag ADC group regular end of unitary conversion */
|
||||
#define LL_ADC_FLAG_EOS ADC_ISR_EOSEQ /*!< ADC flag ADC group regular end of sequence conversions */
|
||||
#define LL_ADC_FLAG_OVR ADC_ISR_OVR /*!< ADC flag ADC group regular overrun */
|
||||
#define LL_ADC_FLAG_EOSMP ADC_ISR_EOSMP /*!< ADC flag ADC group regular end of sampling phase */
|
||||
#define LL_ADC_FLAG_AWD ADC_ISR_AWD /*!< ADC flag ADC analog watchdog 1 */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_LL_EC_IT ADC interruptions for configuration (interruption enable or disable)
|
||||
* @brief IT defines which can be used with LL_ADC_ReadReg and LL_ADC_WriteReg functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define LL_ADC_IT_EOC ADC_IER_EOCIE /*!< ADC interruption ADC group regular end of unitary conversion */
|
||||
#define LL_ADC_IT_EOS ADC_IER_EOSEQIE /*!< ADC interruption ADC group regular end of sequence conversions */
|
||||
#define LL_ADC_IT_OVR ADC_IER_OVRIE /*!< ADC interruption ADC group regular overrun */
|
||||
#define LL_ADC_IT_EOSMP ADC_IER_EOSMPIE /*!< ADC interruption ADC group regular end of sampling phase */
|
||||
#define LL_ADC_IT_AWD ADC_IER_AWDIE /*!< ADC interruption ADC analog watchdog 1 */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_LL_EC_REGISTERS ADC registers compliant with specific purpose
|
||||
* @{
|
||||
*/
|
||||
/* List of ADC registers intended to be used (most commonly) with */
|
||||
/* DMA transfer. */
|
||||
/* Refer to function @ref LL_ADC_DMA_GetRegAddr(). */
|
||||
#define LL_ADC_DMA_REG_REGULAR_DATA (0x00000000U) /* ADC group regular conversion data register (corresponding to register DR) to be used with ADC configured in independent mode. Without DMA transfer, register accessed by LL function @ref LL_ADC_REG_ReadConversionData32() and other functions @ref LL_ADC_REG_ReadConversionDatax() */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_LL_EC_COMMON_PATH_INTERNAL ADC common - Measurement path to internal channels
|
||||
* @{
|
||||
*/
|
||||
/* Note: Other measurement paths to internal channels may be available */
|
||||
/* (connections to other peripherals). */
|
||||
/* If they are not listed below, they do not require any specific */
|
||||
/* path enable. In this case, Access to measurement path is done */
|
||||
/* only by selecting the corresponding ADC internal channel. */
|
||||
#define LL_ADC_PATH_INTERNAL_NONE (0x00000000U) /*!< ADC measurement pathes all disabled */
|
||||
#define LL_ADC_PATH_INTERNAL_VREFINT (ADC_CCR_VREFEN) /*!< ADC measurement path to internal channel VrefInt */
|
||||
#define LL_ADC_PATH_INTERNAL_TEMPSENSOR (ADC_CCR_TSEN) /*!< ADC measurement path to internal channel temperature sensor */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_LL_EC_CLOCK_SOURCE ADC instance - Clock source
|
||||
* @{
|
||||
*/
|
||||
#define LL_ADC_CLOCK_SYNC_PCLK_DIV1 (0x00000000U) /*!< ADC synchronous clock derived from APB clock divided by a prescaler of 1 */
|
||||
#define LL_ADC_CLOCK_SYNC_PCLK_DIV2 (ADC_CFGR2_CKMODE_0 ) /*!< ADC synchronous clock derived from APB clock divided by a prescaler of 2 */
|
||||
#define LL_ADC_CLOCK_SYNC_PCLK_DIV4 ( ADC_CFGR2_CKMODE_1 ) /*!< ADC synchronous clock derived from APB clock divided by a prescaler of 4 */
|
||||
#define LL_ADC_CLOCK_SYNC_PCLK_DIV8 (ADC_CFGR2_CKMODE_0 | ADC_CFGR2_CKMODE_1 ) /*!< ADC synchronous clock derived from APB clock divided by a prescaler of 8 */
|
||||
#define LL_ADC_CLOCK_SYNC_PCLK_DIV16 ( ADC_CFGR2_CKMODE_2 ) /*!< ADC synchronous clock derived from APB clock divided by a prescaler of 16 */
|
||||
#define LL_ADC_CLOCK_SYNC_PCLK_DIV32 (ADC_CFGR2_CKMODE_0 | ADC_CFGR2_CKMODE_2 ) /*!< ADC synchronous clock derived from APB clock divided by a prescaler of 32 */
|
||||
#define LL_ADC_CLOCK_SYNC_PCLK_DIV64 ( ADC_CFGR2_CKMODE_1 | ADC_CFGR2_CKMODE_2 ) /*!< ADC synchronous clock derived from APB clock divided by a prescaler of 64 */
|
||||
#define LL_ADC_CLOCK_ASYNC_HSI_DIV1 ( ADC_CFGR2_CKMODE_3) /*!< ADC asynchronous clock derived from HSI clock divided by a prescaler of 1 */
|
||||
#define LL_ADC_CLOCK_ASYNC_HSI_DIV2 (ADC_CFGR2_CKMODE_0 | ADC_CFGR2_CKMODE_3) /*!< ADC asynchronous clock derived from HSI clock divided by a prescaler of 2 */
|
||||
#define LL_ADC_CLOCK_ASYNC_HSI_DIV4 ( ADC_CFGR2_CKMODE_1 | ADC_CFGR2_CKMODE_3) /*!< ADC asynchronous clock derived from HSI clock divided by a prescaler of 4 */
|
||||
#define LL_ADC_CLOCK_ASYNC_HSI_DIV8 (ADC_CFGR2_CKMODE_0 | ADC_CFGR2_CKMODE_1 | ADC_CFGR2_CKMODE_3) /*!< ADC asynchronous clock derived from HSI clock divided by a prescaler of 8 */
|
||||
#define LL_ADC_CLOCK_ASYNC_HSI_DIV16 ( ADC_CFGR2_CKMODE_2 | ADC_CFGR2_CKMODE_3) /*!< ADC asynchronous clock derived from HSI clock divided by a prescaler of 16 */
|
||||
#define LL_ADC_CLOCK_ASYNC_HSI_DIV32 (ADC_CFGR2_CKMODE_0 | ADC_CFGR2_CKMODE_2 | ADC_CFGR2_CKMODE_3) /*!< ADC asynchronous clock derived from HSI clock divided by a prescaler of 32 */
|
||||
#define LL_ADC_CLOCK_ASYNC_HSI_DIV64 ( ADC_CFGR2_CKMODE_1 | ADC_CFGR2_CKMODE_2 | ADC_CFGR2_CKMODE_3) /*!< ADC asynchronous clock derived from HSI clock divided by a prescaler of 64 */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_LL_EC_RESOLUTION ADC instance - Resolution
|
||||
* @{
|
||||
*/
|
||||
#define LL_ADC_RESOLUTION_12B (0x00000000U) /*!< ADC resolution 12 bits */
|
||||
#define LL_ADC_RESOLUTION_10B (ADC_CFGR1_RESSEL_0) /*!< ADC resolution 10 bits */
|
||||
#define LL_ADC_RESOLUTION_8B (ADC_CFGR1_RESSEL_1) /*!< ADC resolution 8 bits */
|
||||
#define LL_ADC_RESOLUTION_6B (ADC_CFGR1_RESSEL_1 | ADC_CFGR1_RESSEL_0) /*!< ADC resolution 6 bits */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_LL_EC_DATA_ALIGN ADC instance - Data alignment
|
||||
* @{
|
||||
*/
|
||||
#define LL_ADC_DATA_ALIGN_RIGHT (0x00000000U) /*!< ADC conversion data alignment: right aligned (alignment on data register LSB bit 0)*/
|
||||
#define LL_ADC_DATA_ALIGN_LEFT (ADC_CFGR1_ALIGN) /*!< ADC conversion data alignment: left aligned (aligment on data register MSB bit 15)*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_LL_EC_LP_MODE ADC instance - Low power mode
|
||||
* @{
|
||||
*/
|
||||
#define LL_ADC_LP_MODE_NONE (0x00000000U) /*!< No ADC low power mode activated */
|
||||
#define LL_ADC_LP_AUTOWAIT (ADC_CFGR1_WAIT) /*!< ADC low power mode auto delay: Dynamic low power mode, ADC conversions are performed only when necessary (when previous ADC conversion data is read). See description with function @ref LL_ADC_SetLowPowerMode(). */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_LL_EC_GROUPS ADC instance - Groups
|
||||
* @{
|
||||
*/
|
||||
#define LL_ADC_GROUP_REGULAR (0x00000001U) /*!< ADC group regular (available on all PY32 devices) */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_LL_EC_CHANNEL ADC instance - Channel number
|
||||
* @{
|
||||
*/
|
||||
#define LL_ADC_CHANNEL_0 (ADC_CHANNEL_0_NUMBER | ADC_CHANNEL_0_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN0 */
|
||||
#define LL_ADC_CHANNEL_1 (ADC_CHANNEL_1_NUMBER | ADC_CHANNEL_1_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN1 */
|
||||
#define LL_ADC_CHANNEL_2 (ADC_CHANNEL_2_NUMBER | ADC_CHANNEL_2_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN2 */
|
||||
#define LL_ADC_CHANNEL_3 (ADC_CHANNEL_3_NUMBER | ADC_CHANNEL_3_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN3 */
|
||||
#define LL_ADC_CHANNEL_4 (ADC_CHANNEL_4_NUMBER | ADC_CHANNEL_4_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN4 */
|
||||
#define LL_ADC_CHANNEL_5 (ADC_CHANNEL_5_NUMBER | ADC_CHANNEL_5_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN5 */
|
||||
#define LL_ADC_CHANNEL_6 (ADC_CHANNEL_6_NUMBER | ADC_CHANNEL_6_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN6 */
|
||||
#define LL_ADC_CHANNEL_7 (ADC_CHANNEL_7_NUMBER | ADC_CHANNEL_7_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN7 */
|
||||
#define LL_ADC_CHANNEL_8 (ADC_CHANNEL_8_NUMBER | ADC_CHANNEL_8_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN8 */
|
||||
#define LL_ADC_CHANNEL_9 (ADC_CHANNEL_9_NUMBER | ADC_CHANNEL_9_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN9 */
|
||||
#define LL_ADC_CHANNEL_11 (ADC_CHANNEL_11_NUMBER | ADC_CHANNEL_11_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN11 */
|
||||
#define LL_ADC_CHANNEL_12 (ADC_CHANNEL_12_NUMBER | ADC_CHANNEL_12_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN12 */
|
||||
#define LL_ADC_CHANNEL_VREFINT (LL_ADC_CHANNEL_12 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to VrefInt: Internal voltage reference. */
|
||||
#define LL_ADC_CHANNEL_TEMPSENSOR (LL_ADC_CHANNEL_11 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to Temperature sensor. */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_LL_EC_REG_TRIGGER_SOURCE ADC group regular - Trigger source
|
||||
* @{
|
||||
*/
|
||||
#define LL_ADC_REG_TRIG_SOFTWARE (0x00000000U) /*!< ADC group regular conversion trigger internal: SW start. */
|
||||
#define LL_ADC_REG_TRIG_EXT_TIM1_TRGO ( ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM1 TRGO. Trigger edge set to rising edge (default setting). */
|
||||
#define LL_ADC_REG_TRIG_EXT_TIM1_CH4 ( ADC_CFGR1_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM1 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
|
||||
#define LL_ADC_REG_TRIG_EXT_TIM3_TRGO (ADC_CFGR1_EXTSEL_1 | ADC_CFGR1_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM3 TRGO. Trigger edge set to rising edge (default setting). */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_LL_EC_REG_TRIGGER_EDGE ADC group regular - Trigger edge
|
||||
* @{
|
||||
*/
|
||||
#define LL_ADC_REG_TRIG_EXT_RISING ( ADC_CFGR1_EXTEN_0) /*!< ADC group regular conversion trigger polarity set to rising edge */
|
||||
#define LL_ADC_REG_TRIG_EXT_FALLING (ADC_CFGR1_EXTEN_1 ) /*!< ADC group regular conversion trigger polarity set to falling edge */
|
||||
#define LL_ADC_REG_TRIG_EXT_RISINGFALLING (ADC_CFGR1_EXTEN_1 | ADC_CFGR1_EXTEN_0) /*!< ADC group regular conversion trigger polarity set to both rising and falling edges */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_LL_EC_REG_CONTINUOUS_MODE ADC group regular - Continuous mode
|
||||
* @{
|
||||
*/
|
||||
#define LL_ADC_REG_CONV_SINGLE (0x00000000U) /*!< ADC conversions are performed in single mode: one conversion per trigger */
|
||||
#define LL_ADC_REG_CONV_CONTINUOUS (ADC_CFGR1_CONT) /*!< ADC conversions are performed in continuous mode: after the first trigger, following conversions launched successively automatically */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#if (defined(DMA) || defined(DMA1))
|
||||
/** @defgroup ADC_LL_EC_REG_DMA_TRANSFER ADC group regular - DMA transfer of ADC conversion data
|
||||
* @{
|
||||
*/
|
||||
#define LL_ADC_REG_DMA_TRANSFER_NONE (0x00000000U) /*!< ADC conversions are not transferred by DMA */
|
||||
#define LL_ADC_REG_DMA_TRANSFER_LIMITED ( ADC_CFGR1_DMAEN) /*!< ADC conversion data are transferred by DMA, in limited mode (one shot mode): DMA transfer requests are stopped when number of DMA data transfers (number of ADC conversions) is reached. This ADC mode is intended to be used with DMA mode non-circular. */
|
||||
#define LL_ADC_REG_DMA_TRANSFER_UNLIMITED (ADC_CFGR1_DMACFG | ADC_CFGR1_DMAEN) /*!< ADC conversion data are transferred by DMA, in unlimited mode: DMA transfer requests are unlimited, whatever number of DMA data transferred (number of ADC conversions). This ADC mode is intended to be used with DMA mode circular. */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif
|
||||
|
||||
/** @defgroup ADC_LL_EC_REG_OVR_DATA_BEHAVIOR ADC group regular - Overrun behavior on conversion data
|
||||
* @{
|
||||
*/
|
||||
#define LL_ADC_REG_OVR_DATA_PRESERVED (0x00000000U) /*!< ADC group regular behavior in case of overrun: data preserved */
|
||||
#define LL_ADC_REG_OVR_DATA_OVERWRITTEN (ADC_CFGR1_OVRMOD) /*!< ADC group regular behavior in case of overrun: data overwritten */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_LL_EC_REG_SEQ_SCAN_DIRECTION ADC group regular - Sequencer scan direction
|
||||
* @{
|
||||
*/
|
||||
#define LL_ADC_REG_SEQ_SCAN_DIR_FORWARD (0x00000000U) /*!< ADC group regular sequencer scan direction forward: from lowest channel number to highest channel number (scan of all ranks, ADC conversion of ranks with channels enabled in sequencer). On some other PY32 families, this setting is not available and the default scan direction is forward. */
|
||||
#define LL_ADC_REG_SEQ_SCAN_DIR_BACKWARD (ADC_CFGR1_SCANDIR) /*!< ADC group regular sequencer scan direction backward: from highest channel number to lowest channel number (scan of all ranks, ADC conversion of ranks with channels enabled in sequencer) */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_LL_EC_REG_SEQ_DISCONT_MODE ADC group regular - Sequencer discontinuous mode
|
||||
* @{
|
||||
*/
|
||||
#define LL_ADC_REG_SEQ_DISCONT_DISABLE (0x00000000U) /*!< ADC group regular sequencer discontinuous mode disable */
|
||||
#define LL_ADC_REG_SEQ_DISCONT_1RANK (ADC_CFGR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every rank */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_LL_EC_CHANNEL_SAMPLINGTIME Channel - Sampling time
|
||||
* @{
|
||||
*/
|
||||
#define LL_ADC_SAMPLINGTIME_3CYCLES_5 (0x00000000U) /*!< Sampling time 3.5 ADC clock cycles */
|
||||
#define LL_ADC_SAMPLINGTIME_5CYCLES_5 ( ADC_SMPR_SMP_0) /*!< Sampling time 5.5 ADC clock cycles */
|
||||
#define LL_ADC_SAMPLINGTIME_7CYCLES_5 ( ADC_SMPR_SMP_1 ) /*!< Sampling time 7.5 ADC clock cycles */
|
||||
#define LL_ADC_SAMPLINGTIME_13CYCLES_5 ( ADC_SMPR_SMP_1 | ADC_SMPR_SMP_0) /*!< Sampling time 13.5 ADC clock cycles */
|
||||
#define LL_ADC_SAMPLINGTIME_28CYCLES_5 (ADC_SMPR_SMP_2 ) /*!< Sampling time 28.5 ADC clock cycles */
|
||||
#define LL_ADC_SAMPLINGTIME_41CYCLES_5 (ADC_SMPR_SMP_2 | ADC_SMPR_SMP_0) /*!< Sampling time 41.5 ADC clock cycles */
|
||||
#define LL_ADC_SAMPLINGTIME_71CYCLES_5 (ADC_SMPR_SMP_2 | ADC_SMPR_SMP_1 ) /*!< Sampling time 71.5 ADC clock cycles */
|
||||
#define LL_ADC_SAMPLINGTIME_239CYCLES_5 (ADC_SMPR_SMP_2 | ADC_SMPR_SMP_1 | ADC_SMPR_SMP_0) /*!< Sampling time 239.5 ADC clock cycles */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_LL_EC_AWD_NUMBER Analog watchdog - Analog watchdog number
|
||||
* @{
|
||||
*/
|
||||
#define LL_ADC_AWD (ADC_AWD_CR1_CHANNEL_MASK | ADC_AWD_CR1_REGOFFSET) /*!< ADC analog watchdog number 1 */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_LL_EC_AWD_CHANNELS Analog watchdog - Monitored channels
|
||||
* @{
|
||||
*/
|
||||
#define LL_ADC_AWD_DISABLE (0x00000000U) /*!< ADC analog watchdog monitoring disabled */
|
||||
#define LL_ADC_AWD_ALL_CHANNELS_REG ( ADC_CFGR1_AWDEN ) /*!< ADC analog watchdog monitoring of all channels, converted by group regular only */
|
||||
#define LL_ADC_AWD_CHANNEL_0_REG ((LL_ADC_CHANNEL_0 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN0, converted by group regular only */
|
||||
#define LL_ADC_AWD_CHANNEL_1_REG ((LL_ADC_CHANNEL_1 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN1, converted by group regular only */
|
||||
#define LL_ADC_AWD_CHANNEL_2_REG ((LL_ADC_CHANNEL_2 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN2, converted by group regular only */
|
||||
#define LL_ADC_AWD_CHANNEL_3_REG ((LL_ADC_CHANNEL_3 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN3, converted by group regular only */
|
||||
#define LL_ADC_AWD_CHANNEL_4_REG ((LL_ADC_CHANNEL_4 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN4, converted by group regular only */
|
||||
#define LL_ADC_AWD_CHANNEL_5_REG ((LL_ADC_CHANNEL_5 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN5, converted by group regular only */
|
||||
#define LL_ADC_AWD_CHANNEL_6_REG ((LL_ADC_CHANNEL_6 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN6, converted by group regular only */
|
||||
#define LL_ADC_AWD_CHANNEL_7_REG ((LL_ADC_CHANNEL_7 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN7, converted by group regular only */
|
||||
#define LL_ADC_AWD_CHANNEL_8_REG ((LL_ADC_CHANNEL_8 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN8, converted by group regular only */
|
||||
#define LL_ADC_AWD_CHANNEL_9_REG ((LL_ADC_CHANNEL_9 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN9, converted by group regular only */
|
||||
#define LL_ADC_AWD_CHANNEL_11_REG ((LL_ADC_CHANNEL_11 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN11, converted by group regular only */
|
||||
#define LL_ADC_AWD_CHANNEL_12_REG ((LL_ADC_CHANNEL_12 & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN12, converted by group regular only */
|
||||
#define LL_ADC_AWD_CH_VREFINT_REG ((LL_ADC_CHANNEL_VREFINT & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to VrefInt: Internal voltage reference, converted by group regular only */
|
||||
#define LL_ADC_AWD_CH_TEMPSENSOR_REG ((LL_ADC_CHANNEL_TEMPSENSOR & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to Temperature sensor, converted by group regular only */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_LL_EC_AWD_THRESHOLDS Analog watchdog - Thresholds
|
||||
* @{
|
||||
*/
|
||||
#define LL_ADC_AWD_THRESHOLD_HIGH (ADC_TR_HT ) /*!< ADC analog watchdog threshold high */
|
||||
#define LL_ADC_AWD_THRESHOLD_LOW ( ADC_TR_LT) /*!< ADC analog watchdog threshold low */
|
||||
#define LL_ADC_AWD_THRESHOLDS_HIGH_LOW (ADC_TR_HT | ADC_TR_LT) /*!< ADC analog watchdog both thresholds high and low concatenated into the same data */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_LL_EC_CAL_SAMPLINGTIME Calibration - Sampling time
|
||||
* @{
|
||||
*/
|
||||
#define LL_ADC_CAL_SAMPLINGTIME_2CYCLES (0x00000000U) /*!< CAL Sampling time 2 ADC clock cycles */
|
||||
#define LL_ADC_CAL_SAMPLINGTIME_4CYCLES ( ADC_CCSR_CALSMP_0) /*!< CAL Sampling time 4 ADC clock cycles */
|
||||
#define LL_ADC_CAL_SAMPLINGTIME_8CYCLES (ADC_CCSR_CALSMP_1 ) /*!< CAL Sampling time 8 ADC clock cycles */
|
||||
#define LL_ADC_CAL_SAMPLINGTIME_1CYCLE (ADC_CCSR_CALSMP_1 | ADC_CCSR_CALSMP_0) /*!< CAL Sampling time 1 ADC clock cycle */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_LL_EC_CAL_MODE Calibration - Mode
|
||||
* @{
|
||||
*/
|
||||
#define LL_ADC_CAL_MODE_OFFSET (0x00000000U) /*!< ADC calibration mode selection only OFFSET */
|
||||
#define LL_ADC_CAL_MODE_OFFSETANDLINEARITY ADC_CCSR_CALSEL /*!< ADC calibration mode selection OFFSET AND LINERARITY */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_LL_EC_CAL_STATUS Calibration - Status
|
||||
* @{
|
||||
*/
|
||||
#define LL_ADC_CAL_STATUS_SUCCESS (0x00000000U) /*!< ADC calibration status SUCCESS */
|
||||
#define LL_ADC_CAL_STATUS_FAIL ( ADC_CCSR_CALFAIL) /*!< ADC calibration status FAIL */
|
||||
#define LL_ADC_CAL_STATUS_ONGOING (ADC_CCSR_CALON ) /*!< ADC calibration status ONGOING */
|
||||
#define LL_ADC_CAL_STATUS_INVALID (ADC_CCSR_CALON | ADC_CCSR_CALFAIL) /*!< ADC calibration status INVALID */
|
||||
|
||||
|
||||
/** @defgroup ADC_LL_EC_HW_DELAYS Definitions of ADC hardware constraints delays
|
||||
* @note Only ADC IP HW delays are defined in ADC LL driver driver,
|
||||
* not timeout values.
|
||||
* For details on delays values, refer to descriptions in source code
|
||||
* above each literal definition.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Note: Only ADC IP HW delays are defined in ADC LL driver driver, */
|
||||
/* not timeout values. */
|
||||
/* Timeout values for ADC operations are dependent to device clock */
|
||||
/* configuration (system clock versus ADC clock), */
|
||||
/* and therefore must be defined in user application. */
|
||||
/* Indications for estimation of ADC timeout delays, for this */
|
||||
/* PY32 serie: */
|
||||
/* - ADC calibration time: maximum delay is 64/fADC. */
|
||||
/* - ADC enable time: maximum delay is 8 ADC Clock Cycles. */
|
||||
/* - ADC disable time: maximum delay should be a few ADC clock cycles */
|
||||
/* - ADC stop conversion time: maximum delay should be a few ADC clock */
|
||||
/* cycles */
|
||||
/* - ADC conversion time: duration depending on ADC clock and ADC */
|
||||
/* configuration. */
|
||||
/* (refer to device reference manual, section "Timing") */
|
||||
|
||||
|
||||
/* Delay for internal voltage reference stabilization time. */
|
||||
/* Delay set to maximum value (refer to device datasheet, */
|
||||
/* parameter "tSTART"). */
|
||||
/* Unit: us */
|
||||
#define LL_ADC_DELAY_VREFINT_STAB_US ( 10U) /*!< Delay for internal voltage reference stabilization time */
|
||||
|
||||
/* Delay for temperature sensor stabilization time. */
|
||||
/* Literal set to maximum value (refer to device datasheet, */
|
||||
/* parameter "tSTART"). */
|
||||
/* Unit: us */
|
||||
#define LL_ADC_DELAY_TEMPSENSOR_STAB_US ( 10U) /*!< Delay for temperature sensor stabilization time */
|
||||
|
||||
/* Delay required between ADC end of calibration and ADC enable. */
|
||||
/* Note: On this PY32 serie, a minimum number of ADC clock cycles */
|
||||
/* are required between ADC end of calibration and ADC enable. */
|
||||
/* Wait time can be computed in user application by waiting for the */
|
||||
/* equivalent number of CPU cycles, by taking into account */
|
||||
/* ratio of CPU clock versus ADC clock prescalers. */
|
||||
/* Unit: ADC clock cycles. */
|
||||
#define LL_ADC_DELAY_CALIB_ENABLE_ADC_CYCLES ( 4U) /*!< Delay required between ADC end of calibration and ADC enable */
|
||||
|
||||
/* Delay between ADC end of calibration and ADC enable. */
|
||||
/* Delay estimation in CPU cycles: Case of ADC enable done */
|
||||
/* immediately after ADC calibration, ADC clock setting slow */
|
||||
/* (CPU clock / ADC clock) is above 64. */
|
||||
#define LL_ADC_DELAY_CALIB_ENABLE_CPU_CYCLES (LL_ADC_DELAY_CALIB_ENABLE_ADC_CYCLES * 64)
|
||||
|
||||
/* Timeout values for ADC Calibration. */
|
||||
#define LL_ADC_CALIBRATION_TIMEOUT_CPU_CYCLES ( 1000U)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/** @defgroup ADC_LL_Exported_Macros ADC Exported Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_LL_EM_WRITE_READ Common write and read registers Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Write a value in ADC register
|
||||
* @param __INSTANCE__ ADC Instance
|
||||
* @param __REG__ Register to be written
|
||||
* @param __VALUE__ Value to be written in the register
|
||||
* @retval None
|
||||
*/
|
||||
#define LL_ADC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
|
||||
|
||||
/**
|
||||
* @brief Read a value in ADC register
|
||||
* @param __INSTANCE__ ADC Instance
|
||||
* @param __REG__ Register to be read
|
||||
* @retval Register value
|
||||
*/
|
||||
#define LL_ADC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_LL_EM_HELPER_MACRO ADC helper macro
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Helper macro to get ADC channel number in decimal format
|
||||
* from literals LL_ADC_CHANNEL_x.
|
||||
* @note Example:
|
||||
* __LL_ADC_CHANNEL_TO_DECIMAL_NB(LL_ADC_CHANNEL_4)
|
||||
* will return decimal number "4".
|
||||
* @note The input can be a value from functions where a channel
|
||||
* number is returned, either defined with number
|
||||
* or with bitfield (only one bit must be set).
|
||||
* @note Depending on devices and packages, some channels may not be available.
|
||||
* Refer to device datasheet for channels availability.
|
||||
* @param __CHANNEL__ This parameter can be one of the following values:
|
||||
* @arg @ref LL_ADC_CHANNEL_0
|
||||
* @arg @ref LL_ADC_CHANNEL_1
|
||||
* @arg @ref LL_ADC_CHANNEL_2
|
||||
* @arg @ref LL_ADC_CHANNEL_3
|
||||
* @arg @ref LL_ADC_CHANNEL_4
|
||||
* @arg @ref LL_ADC_CHANNEL_5
|
||||
* @arg @ref LL_ADC_CHANNEL_6
|
||||
* @arg @ref LL_ADC_CHANNEL_7
|
||||
* @arg @ref LL_ADC_CHANNEL_8
|
||||
* @arg @ref LL_ADC_CHANNEL_9
|
||||
* @arg @ref LL_ADC_CHANNEL_11
|
||||
* @arg @ref LL_ADC_CHANNEL_12
|
||||
* @arg @ref LL_ADC_CHANNEL_VREFINT
|
||||
* @arg @ref LL_ADC_CHANNEL_TEMPSENSOR
|
||||
* @retval Value between Min_Data=0 and Max_Data=12
|
||||
*/
|
||||
#define __LL_ADC_CHANNEL_TO_DECIMAL_NB(__CHANNEL__) \
|
||||
((((__CHANNEL__) & ADC_CHANNEL_ID_BITFIELD_MASK) == 0U) \
|
||||
? ( \
|
||||
((__CHANNEL__) & ADC_CHANNEL_ID_NUMBER_MASK) >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS \
|
||||
) \
|
||||
: \
|
||||
( \
|
||||
(((__CHANNEL__) & ADC_CHSELR_CHSEL0) == ADC_CHSELR_CHSEL0) ? (0U) : \
|
||||
( \
|
||||
(((__CHANNEL__) & ADC_CHSELR_CHSEL1) == ADC_CHSELR_CHSEL1) ? (1U) : \
|
||||
( \
|
||||
(((__CHANNEL__) & ADC_CHSELR_CHSEL2) == ADC_CHSELR_CHSEL2) ? (2U) : \
|
||||
( \
|
||||
(((__CHANNEL__) & ADC_CHSELR_CHSEL3) == ADC_CHSELR_CHSEL3) ? (3U) : \
|
||||
( \
|
||||
(((__CHANNEL__) & ADC_CHSELR_CHSEL4) == ADC_CHSELR_CHSEL4) ? (4U) : \
|
||||
( \
|
||||
(((__CHANNEL__) & ADC_CHSELR_CHSEL5) == ADC_CHSELR_CHSEL5) ? (5U) : \
|
||||
( \
|
||||
(((__CHANNEL__) & ADC_CHSELR_CHSEL6) == ADC_CHSELR_CHSEL6) ? (6U) : \
|
||||
( \
|
||||
(((__CHANNEL__) & ADC_CHSELR_CHSEL7) == ADC_CHSELR_CHSEL7) ? (7U) : \
|
||||
( \
|
||||
(((__CHANNEL__) & ADC_CHSELR_CHSEL8) == ADC_CHSELR_CHSEL8) ? (8U) : \
|
||||
( \
|
||||
(((__CHANNEL__) & ADC_CHSELR_CHSEL9) == ADC_CHSELR_CHSEL9) ? (9U) : \
|
||||
( \
|
||||
(((__CHANNEL__) & ADC_CHSELR_CHSEL11) == ADC_CHSELR_CHSEL11) ? (11U) : \
|
||||
( \
|
||||
(((__CHANNEL__) & ADC_CHSELR_CHSEL12) == ADC_CHSELR_CHSEL12) ? (12U) : \
|
||||
(0U) \
|
||||
) \
|
||||
) \
|
||||
) \
|
||||
) \
|
||||
) \
|
||||
) \
|
||||
) \
|
||||
) \
|
||||
) \
|
||||
) \
|
||||
) \
|
||||
) \
|
||||
)
|
||||
|
||||
/**
|
||||
* @brief Helper macro to get ADC channel in literal format LL_ADC_CHANNEL_x
|
||||
* from number in decimal format.
|
||||
* @note Example:
|
||||
* __LL_ADC_DECIMAL_NB_TO_CHANNEL(4)
|
||||
* will return a data equivalent to "LL_ADC_CHANNEL_4".
|
||||
* @note Depending on devices and packages, some channels may not be available.
|
||||
* Refer to device datasheet for channels availability.
|
||||
* @param __DECIMAL_NB__ Value between Min_Data=0 and Max_Data=12
|
||||
* @retval Returned value can be one of the following values:
|
||||
* @arg @ref LL_ADC_CHANNEL_0
|
||||
* @arg @ref LL_ADC_CHANNEL_1
|
||||
* @arg @ref LL_ADC_CHANNEL_2
|
||||
* @arg @ref LL_ADC_CHANNEL_3
|
||||
* @arg @ref LL_ADC_CHANNEL_4
|
||||
* @arg @ref LL_ADC_CHANNEL_5
|
||||
* @arg @ref LL_ADC_CHANNEL_6
|
||||
* @arg @ref LL_ADC_CHANNEL_7
|
||||
* @arg @ref LL_ADC_CHANNEL_8
|
||||
* @arg @ref LL_ADC_CHANNEL_9
|
||||
* @arg @ref LL_ADC_CHANNEL_11
|
||||
* @arg @ref LL_ADC_CHANNEL_12
|
||||
* @arg @ref LL_ADC_CHANNEL_VREFINT (1)
|
||||
* @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
|
||||
* (1) For ADC channel read back from ADC register,
|
||||
* comparison with internal channel parameter to be done
|
||||
* using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
|
||||
*/
|
||||
#define __LL_ADC_DECIMAL_NB_TO_CHANNEL(__DECIMAL_NB__) \
|
||||
( \
|
||||
((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) | \
|
||||
(ADC_CHSELR_CHSEL0 << (__DECIMAL_NB__)) \
|
||||
)
|
||||
|
||||
/**
|
||||
* @brief Helper macro to determine whether the selected channel
|
||||
* corresponds to literal definitions of driver.
|
||||
* @note The different literal definitions of ADC channels are:
|
||||
* - ADC internal channel:
|
||||
* LL_ADC_CHANNEL_VREFINT, LL_ADC_CHANNEL_TEMPSENSOR, ...
|
||||
* - ADC external channel (channel connected to a GPIO pin):
|
||||
* LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...
|
||||
* @note The channel parameter must be a value defined from literal
|
||||
* definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT,
|
||||
* LL_ADC_CHANNEL_TEMPSENSOR, ...),
|
||||
* ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...),
|
||||
* must not be a value from functions where a channel number is
|
||||
* returned from ADC registers,
|
||||
* because internal and external channels share the same channel
|
||||
* number in ADC registers. The differentiation is made only with
|
||||
* parameters definitions of driver.
|
||||
* @note Depending on devices and packages, some channels may not be available.
|
||||
* Refer to device datasheet for channels availability.
|
||||
* @param __CHANNEL__ This parameter can be one of the following values:
|
||||
* @arg @ref LL_ADC_CHANNEL_0
|
||||
* @arg @ref LL_ADC_CHANNEL_1
|
||||
* @arg @ref LL_ADC_CHANNEL_2
|
||||
* @arg @ref LL_ADC_CHANNEL_3
|
||||
* @arg @ref LL_ADC_CHANNEL_4
|
||||
* @arg @ref LL_ADC_CHANNEL_5
|
||||
* @arg @ref LL_ADC_CHANNEL_6
|
||||
* @arg @ref LL_ADC_CHANNEL_7
|
||||
* @arg @ref LL_ADC_CHANNEL_8
|
||||
* @arg @ref LL_ADC_CHANNEL_9
|
||||
* @arg @ref LL_ADC_CHANNEL_11
|
||||
* @arg @ref LL_ADC_CHANNEL_12
|
||||
* @arg @ref LL_ADC_CHANNEL_VREFINT
|
||||
* @arg @ref LL_ADC_CHANNEL_TEMPSENSOR
|
||||
* @retval Value "0" if the channel corresponds to a parameter definition of a ADC external channel (channel connected to a GPIO pin).
|
||||
* Value "1" if the channel corresponds to a parameter definition of a ADC internal channel.
|
||||
*/
|
||||
#define __LL_ADC_IS_CHANNEL_INTERNAL(__CHANNEL__) \
|
||||
(((__CHANNEL__) & ADC_CHANNEL_ID_INTERNAL_CH_MASK) != 0U)
|
||||
|
||||
/**
|
||||
* @brief Helper macro to convert a channel defined from parameter
|
||||
* definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT,
|
||||
* LL_ADC_CHANNEL_TEMPSENSOR, ...),
|
||||
* to its equivalent parameter definition of a ADC external channel
|
||||
* (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...).
|
||||
* @note The channel parameter can be, additionally to a value
|
||||
* defined from parameter definition of a ADC internal channel
|
||||
* (LL_ADC_CHANNEL_VREFINT, LL_ADC_CHANNEL_TEMPSENSOR, ...),
|
||||
* a value defined from parameter definition of
|
||||
* ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...)
|
||||
* or a value from functions where a channel number is returned
|
||||
* from ADC registers.
|
||||
* @note Depending on devices and packages, some channels may not be available.
|
||||
* Refer to device datasheet for channels availability.
|
||||
* @param __CHANNEL__ This parameter can be one of the following values:
|
||||
* @arg @ref LL_ADC_CHANNEL_0
|
||||
* @arg @ref LL_ADC_CHANNEL_1
|
||||
* @arg @ref LL_ADC_CHANNEL_2
|
||||
* @arg @ref LL_ADC_CHANNEL_3
|
||||
* @arg @ref LL_ADC_CHANNEL_4
|
||||
* @arg @ref LL_ADC_CHANNEL_5
|
||||
* @arg @ref LL_ADC_CHANNEL_6
|
||||
* @arg @ref LL_ADC_CHANNEL_7
|
||||
* @arg @ref LL_ADC_CHANNEL_8
|
||||
* @arg @ref LL_ADC_CHANNEL_9
|
||||
* @arg @ref LL_ADC_CHANNEL_11
|
||||
* @arg @ref LL_ADC_CHANNEL_12
|
||||
* @arg @ref LL_ADC_CHANNEL_VREFINT
|
||||
* @arg @ref LL_ADC_CHANNEL_TEMPSENSOR
|
||||
* @retval Returned value can be one of the following values:
|
||||
* @arg @ref LL_ADC_CHANNEL_0
|
||||
* @arg @ref LL_ADC_CHANNEL_1
|
||||
* @arg @ref LL_ADC_CHANNEL_2
|
||||
* @arg @ref LL_ADC_CHANNEL_3
|
||||
* @arg @ref LL_ADC_CHANNEL_4
|
||||
* @arg @ref LL_ADC_CHANNEL_5
|
||||
* @arg @ref LL_ADC_CHANNEL_6
|
||||
* @arg @ref LL_ADC_CHANNEL_7
|
||||
* @arg @ref LL_ADC_CHANNEL_8
|
||||
* @arg @ref LL_ADC_CHANNEL_9
|
||||
* @arg @ref LL_ADC_CHANNEL_11
|
||||
* @arg @ref LL_ADC_CHANNEL_12
|
||||
*/
|
||||
#define __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL(__CHANNEL__) \
|
||||
((__CHANNEL__) & ~ADC_CHANNEL_ID_INTERNAL_CH_MASK)
|
||||
|
||||
/**
|
||||
* @brief Helper macro to determine whether the internal channel
|
||||
* selected is available on the ADC instance selected.
|
||||
* @note The channel parameter must be a value defined from parameter
|
||||
* definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT,
|
||||
* LL_ADC_CHANNEL_TEMPSENSOR, ...),
|
||||
* must not be a value defined from parameter definition of
|
||||
* ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...)
|
||||
* or a value from functions where a channel number is
|
||||
* returned from ADC registers,
|
||||
* because internal and external channels share the same channel
|
||||
* number in ADC registers. The differentiation is made only with
|
||||
* parameters definitions of driver.
|
||||
* @param __ADC_INSTANCE__ ADC instance
|
||||
* @param __CHANNEL__ This parameter can be one of the following values:
|
||||
* @arg @ref LL_ADC_CHANNEL_VREFINT
|
||||
* @arg @ref LL_ADC_CHANNEL_TEMPSENSOR
|
||||
* @retval Value "0" if the internal channel selected is not available on the ADC instance selected.
|
||||
* Value "1" if the internal channel selected is available on the ADC instance selected.
|
||||
*/
|
||||
|
||||
#define __LL_ADC_IS_CHANNEL_INTERNAL_AVAILABLE(__ADC_INSTANCE__, __CHANNEL__) \
|
||||
( \
|
||||
((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) || \
|
||||
((__CHANNEL__) == LL_ADC_CHANNEL_TEMPSENSOR) \
|
||||
)
|
||||
|
||||
/**
|
||||
* @brief Helper macro to define ADC analog watchdog parameter:
|
||||
* define a single channel to monitor with analog watchdog
|
||||
* from sequencer channel and groups definition.
|
||||
* @note To be used with function @ref LL_ADC_SetAnalogWDMonitChannels().
|
||||
* Example:
|
||||
* LL_ADC_SetAnalogWDMonitChannels(
|
||||
* ADC1, LL_ADC_AWD,
|
||||
* __LL_ADC_ANALOGWD_CHANNEL_GROUP(LL_ADC_CHANNEL4, LL_ADC_GROUP_REGULAR))
|
||||
* @note Depending on devices and packages, some channels may not be available.
|
||||
* Refer to device datasheet for channels availability.
|
||||
* @param __CHANNEL__ This parameter can be one of the following values:
|
||||
* @arg @ref LL_ADC_CHANNEL_0
|
||||
* @arg @ref LL_ADC_CHANNEL_1
|
||||
* @arg @ref LL_ADC_CHANNEL_2
|
||||
* @arg @ref LL_ADC_CHANNEL_3
|
||||
* @arg @ref LL_ADC_CHANNEL_4
|
||||
* @arg @ref LL_ADC_CHANNEL_5
|
||||
* @arg @ref LL_ADC_CHANNEL_6
|
||||
* @arg @ref LL_ADC_CHANNEL_7
|
||||
* @arg @ref LL_ADC_CHANNEL_8
|
||||
* @arg @ref LL_ADC_CHANNEL_9
|
||||
* @arg @ref LL_ADC_CHANNEL_11
|
||||
* @arg @ref LL_ADC_CHANNEL_12
|
||||
* @arg @ref LL_ADC_CHANNEL_VREFINT (1)
|
||||
* @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1)
|
||||
* (1) For ADC channel read back from ADC register,
|
||||
* comparison with internal channel parameter to be done
|
||||
* using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
|
||||
* @param __GROUP__ This parameter can be one of the following values:
|
||||
* @arg @ref LL_ADC_GROUP_REGULAR
|
||||
* @retval Returned value can be one of the following values:
|
||||
* @arg @ref LL_ADC_AWD_DISABLE
|
||||
* @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG
|
||||
* @arg @ref LL_ADC_AWD_CHANNEL_0_REG
|
||||
* @arg @ref LL_ADC_AWD_CHANNEL_1_REG
|
||||
* @arg @ref LL_ADC_AWD_CHANNEL_2_REG
|
||||
* @arg @ref LL_ADC_AWD_CHANNEL_3_REG
|
||||
* @arg @ref LL_ADC_AWD_CHANNEL_4_REG
|
||||
* @arg @ref LL_ADC_AWD_CHANNEL_5_REG
|
||||
* @arg @ref LL_ADC_AWD_CHANNEL_6_REG
|
||||
* @arg @ref LL_ADC_AWD_CHANNEL_7_REG
|
||||
* @arg @ref LL_ADC_AWD_CHANNEL_8_REG
|
||||
* @arg @ref LL_ADC_AWD_CHANNEL_9_REG
|
||||
* @arg @ref LL_ADC_AWD_CHANNEL_11_REG
|
||||
* @arg @ref LL_ADC_AWD_CHANNEL_12_REG
|
||||
* @arg @ref LL_ADC_AWD_CH_VREFINT_REG
|
||||
* @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG
|
||||
*/
|
||||
#define __LL_ADC_ANALOGWD_CHANNEL_GROUP(__CHANNEL__, __GROUP__)\
|
||||
(((__CHANNEL__) & ADC_CHANNEL_ID_MASK) | ADC_CFGR1_AWDEN | ADC_CFGR1_AWDSGL)
|
||||
|
||||
/**
|
||||
* @brief Helper macro to set the value of ADC analog watchdog threshold high
|
||||
* or low in function of ADC resolution, when ADC resolution is
|
||||
* different of 12 bits.
|
||||
* @note To be used with function @ref LL_ADC_ConfigAnalogWDThresholds()
|
||||
* or @ref LL_ADC_SetAnalogWDThresholds().
|
||||
* Example, with a ADC resolution of 8 bits, to set the value of
|
||||
* analog watchdog threshold high (on 8 bits):
|
||||
* LL_ADC_SetAnalogWDThresholds
|
||||
* (< ADCx param >,
|
||||
* __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION(LL_ADC_RESOLUTION_8B, <threshold_value_8_bits>)
|
||||
* );
|
||||
* @param __ADC_RESOLUTION__ This parameter can be one of the following values:
|
||||
* @arg @ref LL_ADC_RESOLUTION_12B
|
||||
* @arg @ref LL_ADC_RESOLUTION_10B
|
||||
* @arg @ref LL_ADC_RESOLUTION_8B
|
||||
* @arg @ref LL_ADC_RESOLUTION_6B
|
||||
* @param __AWD_THRESHOLD__ Value between Min_Data=0x000 and Max_Data=0xFFF
|
||||
* @retval Value between Min_Data=0x000 and Max_Data=0xFFF
|
||||
*/
|
||||
#define __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION(__ADC_RESOLUTION__, __AWD_THRESHOLD__) \
|
||||
((__AWD_THRESHOLD__) << ((__ADC_RESOLUTION__) >> (ADC_CFGR1_RES_BITOFFSET_POS - 1U )))
|
||||
|
||||
/**
|
||||
* @brief Helper macro to get the value of ADC analog watchdog threshold high
|
||||
* or low in function of ADC resolution, when ADC resolution is
|
||||
* different of 12 bits.
|
||||
* @note To be used with function @ref LL_ADC_GetAnalogWDThresholds().
|
||||
* Example, with a ADC resolution of 8 bits, to get the value of
|
||||
* analog watchdog threshold high (on 8 bits):
|
||||
* < threshold_value_6_bits > = __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION
|
||||
* (LL_ADC_RESOLUTION_8B,
|
||||
* LL_ADC_GetAnalogWDThresholds(<ADCx param>, LL_ADC_AWD_THRESHOLD_HIGH)
|
||||
* );
|
||||
* @param __ADC_RESOLUTION__ This parameter can be one of the following values:
|
||||
* @arg @ref LL_ADC_RESOLUTION_12B
|
||||
* @arg @ref LL_ADC_RESOLUTION_10B
|
||||
* @arg @ref LL_ADC_RESOLUTION_8B
|
||||
* @arg @ref LL_ADC_RESOLUTION_6B
|
||||
* @param __AWD_THRESHOLD_12_BITS__ Value between Min_Data=0x000 and Max_Data=0xFFF
|
||||
* @retval Value between Min_Data=0x000 and Max_Data=0xFFF
|
||||
*/
|
||||
#define __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION(__ADC_RESOLUTION__, __AWD_THRESHOLD_12_BITS__) \
|
||||
((__AWD_THRESHOLD_12_BITS__) >> ((__ADC_RESOLUTION__) >> (ADC_CFGR1_RES_BITOFFSET_POS - 1U )))
|
||||
|
||||
/**
|
||||
* @brief Helper macro to get the ADC analog watchdog threshold high
|
||||
* or low from raw value containing both thresholds concatenated.
|
||||
* @note To be used with function @ref LL_ADC_GetAnalogWDThresholds().
|
||||
* Example, to get analog watchdog threshold high from the register raw value:
|
||||
* __LL_ADC_ANALOGWD_THRESHOLDS_HIGH_LOW(LL_ADC_AWD_THRESHOLD_HIGH, <raw_value_with_both_thresholds>);
|
||||
* @param __AWD_THRESHOLD_TYPE__ This parameter can be one of the following values:
|
||||
* @arg @ref LL_ADC_AWD_THRESHOLD_HIGH
|
||||
* @arg @ref LL_ADC_AWD_THRESHOLD_LOW
|
||||
* @param __AWD_THRESHOLDS__ Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF
|
||||
* @retval Value between Min_Data=0x000 and Max_Data=0xFFF
|
||||
*/
|
||||
#define __LL_ADC_ANALOGWD_THRESHOLDS_HIGH_LOW(__AWD_THRESHOLD_TYPE__, __AWD_THRESHOLDS__) \
|
||||
(((__AWD_THRESHOLD_TYPE__) == LL_ADC_AWD_THRESHOLD_LOW) \
|
||||
? ( \
|
||||
(__AWD_THRESHOLDS__) & LL_ADC_AWD_THRESHOLD_LOW \
|
||||
) \
|
||||
: \
|
||||
( \
|
||||
((__AWD_THRESHOLDS__) >> ADC_TR_HT_BITOFFSET_POS) & LL_ADC_AWD_THRESHOLD_LOW \
|
||||
) \
|
||||
)
|
||||
|
||||
/**
|
||||
* @brief Helper macro to select the ADC common instance
|
||||
* to which is belonging the selected ADC instance.
|
||||
* @note ADC common register instance can be used for:
|
||||
* - Set parameters common to several ADC instances
|
||||
* - Multimode (for devices with several ADC instances)
|
||||
* Refer to functions having argument "ADCxy_COMMON" as parameter.
|
||||
* @param __ADCx__ ADC instance
|
||||
* @retval ADC common register instance
|
||||
*/
|
||||
#define __LL_ADC_COMMON_INSTANCE(__ADCx__) \
|
||||
(ADC1_COMMON)
|
||||
|
||||
/**
|
||||
* @brief Helper macro to check if all ADC instances sharing the same
|
||||
* ADC common instance are disabled.
|
||||
* @note This check is required by functions with setting conditioned to
|
||||
* ADC state:
|
||||
* All ADC instances of the ADC common group must be disabled.
|
||||
* Refer to functions having argument "ADCxy_COMMON" as parameter.
|
||||
* @note On devices with only 1 ADC common instance, parameter of this macro
|
||||
* is useless and can be ignored (parameter kept for compatibility
|
||||
* with devices featuring several ADC common instances).
|
||||
* @param __ADCXY_COMMON__ ADC common instance
|
||||
* (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
|
||||
* @retval Value "0" if all ADC instances sharing the same ADC common instance
|
||||
* are disabled.
|
||||
* Value "1" if at least one ADC instance sharing the same ADC common instance
|
||||
* is enabled.
|
||||
*/
|
||||
#define __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE(__ADCXY_COMMON__) \
|
||||
LL_ADC_IsEnabled(ADC1)
|
||||
|
||||
/**
|
||||
* @brief Helper macro to define the ADC conversion data full-scale digital
|
||||
* value corresponding to the selected ADC resolution.
|
||||
* @note ADC conversion data full-scale corresponds to voltage range
|
||||
* determined by analog voltage references Vref+ and Vref-
|
||||
* (refer to reference manual).
|
||||
* @param __ADC_RESOLUTION__ This parameter can be one of the following values:
|
||||
* @arg @ref LL_ADC_RESOLUTION_12B
|
||||
* @arg @ref LL_ADC_RESOLUTION_10B
|
||||
* @arg @ref LL_ADC_RESOLUTION_8B
|
||||
* @arg @ref LL_ADC_RESOLUTION_6B
|
||||
* @retval ADC conversion data equivalent voltage value (unit: mVolt)
|
||||
*/
|
||||
#define __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__) \
|
||||
(0xFFFU >> ((__ADC_RESOLUTION__) >> (ADC_CFGR1_RES_BITOFFSET_POS - 1U)))
|
||||
|
||||
/**
|
||||
* @brief Helper macro to convert the ADC conversion data from
|
||||
* a resolution to another resolution.
|
||||
* @param __DATA__ ADC conversion data to be converted
|
||||
* @param __ADC_RESOLUTION_CURRENT__ Resolution of to the data to be converted
|
||||
* This parameter can be one of the following values:
|
||||
* @arg @ref LL_ADC_RESOLUTION_12B
|
||||
* @arg @ref LL_ADC_RESOLUTION_10B
|
||||
* @arg @ref LL_ADC_RESOLUTION_8B
|
||||
* @arg @ref LL_ADC_RESOLUTION_6B
|
||||
* @param __ADC_RESOLUTION_TARGET__ Resolution of the data after conversion
|
||||
* This parameter can be one of the following values:
|
||||
* @arg @ref LL_ADC_RESOLUTION_12B
|
||||
* @arg @ref LL_ADC_RESOLUTION_10B
|
||||
* @arg @ref LL_ADC_RESOLUTION_8B
|
||||
* @arg @ref LL_ADC_RESOLUTION_6B
|
||||
* @retval ADC conversion data to the requested resolution
|
||||
*/
|
||||
#define __LL_ADC_CONVERT_DATA_RESOLUTION(__DATA__, __ADC_RESOLUTION_CURRENT__, __ADC_RESOLUTION_TARGET__) \
|
||||
(((__DATA__) \
|
||||
<< ((__ADC_RESOLUTION_CURRENT__) >> (ADC_CFGR1_RES_BITOFFSET_POS - 1U))) \
|
||||
>> ((__ADC_RESOLUTION_TARGET__) >> (ADC_CFGR1_RES_BITOFFSET_POS - 1U)) \
|
||||
)
|
||||
|
||||
/**
|
||||
* @brief Helper macro to calculate the voltage (unit: mVolt)
|
||||
* corresponding to a ADC conversion data (unit: digital value).
|
||||
* @note Analog reference voltage (Vref+) must be either known from
|
||||
* user board environment or can be calculated using ADC measurement
|
||||
* and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
|
||||
* @param __VREFANALOG_VOLTAGE__ Analog reference voltage (unit: mV)
|
||||
* @param __ADC_DATA__ ADC conversion data (resolution 12 bits)
|
||||
* (unit: digital value).
|
||||
* @param __ADC_RESOLUTION__ This parameter can be one of the following values:
|
||||
* @arg @ref LL_ADC_RESOLUTION_12B
|
||||
* @arg @ref LL_ADC_RESOLUTION_10B
|
||||
* @arg @ref LL_ADC_RESOLUTION_8B
|
||||
* @arg @ref LL_ADC_RESOLUTION_6B
|
||||
* @retval ADC conversion data equivalent voltage value (unit: mVolt)
|
||||
*/
|
||||
#define __LL_ADC_CALC_DATA_TO_VOLTAGE(__VREFANALOG_VOLTAGE__,__ADC_DATA__,__ADC_RESOLUTION__) \
|
||||
((__ADC_DATA__) * (__VREFANALOG_VOLTAGE__)/ __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__))
|
||||
|
||||
/**
|
||||
* @brief Helper macro to calculate analog reference voltage (Vref+)
|
||||
* (unit: mVolt) from ADC conversion data of internal voltage
|
||||
* reference VrefInt.
|
||||
* @note Computation is using VrefInt calibration value
|
||||
* stored in system memory for each device during production.
|
||||
* @note This voltage depends on user board environment: voltage level
|
||||
* connected to pin Vref+.
|
||||
* On devices with small package, the pin Vref+ is not present
|
||||
* and internally bonded to pin Vdda.
|
||||
* @note On this PY32 serie, calibration data of internal voltage reference
|
||||
* VrefInt corresponds to a resolution of 12 bits,
|
||||
* this is the recommended ADC resolution to convert voltage of
|
||||
* internal voltage reference VrefInt.
|
||||
* Otherwise, this macro performs the processing to scale
|
||||
* ADC conversion data to 12 bits.
|
||||
* @param __VREFINT_ADC_DATA__ ADC conversion data (resolution 12 bits)
|
||||
* of internal voltage reference VrefInt (unit: digital value).
|
||||
* @param __ADC_RESOLUTION__ This parameter can be one of the following values:
|
||||
* @arg @ref LL_ADC_RESOLUTION_12B
|
||||
* @arg @ref LL_ADC_RESOLUTION_10B
|
||||
* @arg @ref LL_ADC_RESOLUTION_8B
|
||||
* @arg @ref LL_ADC_RESOLUTION_6B
|
||||
* @retval Analog reference voltage (unit: mV)
|
||||
*/
|
||||
#define __LL_ADC_CALC_VREFANALOG_VOLTAGE(__VREFINT_ADC_DATA__,__ADC_RESOLUTION__) \
|
||||
(4095*( VREFINT_CAL_VREF)/ __LL_ADC_CONVERT_DATA_RESOLUTION((__VREFINT_ADC_DATA__),(__ADC_RESOLUTION__),LL_ADC_RESOLUTION_12B))
|
||||
|
||||
/**
|
||||
* @brief Helper macro to calculate the temperature (unit: degree Celsius)
|
||||
* from ADC conversion data of internal temperature sensor.
|
||||
* @note Computation is using temperature sensor calibration values
|
||||
* stored in system memory for each device during production.
|
||||
* @note Calculation formula:
|
||||
* Temperature = ((TS_ADC_DATA - TS_CAL1)
|
||||
* * (TS_CAL2_TEMP - TS_CAL1_TEMP))
|
||||
* / (TS_CAL2 - TS_CAL1) + TS_CAL1_TEMP
|
||||
* with TS_ADC_DATA = temperature sensor raw data measured by ADC
|
||||
* Avg_Slope = (TS_CAL2 - TS_CAL1)
|
||||
* / (TS_CAL2_TEMP - TS_CAL1_TEMP)
|
||||
* TS_CAL1 = equivalent TS_ADC_DATA at temperature
|
||||
* TEMP_DEGC_CAL1 (calibrated in factory)
|
||||
* TS_CAL2 = equivalent TS_ADC_DATA at temperature
|
||||
* TEMP_DEGC_CAL2 (calibrated in factory)
|
||||
* Caution: Calculation relevancy under reserve that calibration
|
||||
* parameters are correct (address and data).
|
||||
* To calculate temperature using temperature sensor
|
||||
* datasheet typical values (generic values less, therefore
|
||||
* less accurate than calibrated values),
|
||||
* use helper macro @ref __LL_ADC_CALC_TEMPERATURE_TYP_PARAMS().
|
||||
* @note As calculation input, the analog reference voltage (Vref+) must be
|
||||
* defined as it impacts the ADC LSB equivalent voltage.
|
||||
* @note Analog reference voltage (Vref+) must be either known from
|
||||
* user board environment or can be calculated using ADC measurement
|
||||
* and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
|
||||
* @note On this PY32 serie, calibration data of temperature sensor
|
||||
* corresponds to a resolution of 12 bits,
|
||||
* this is the recommended ADC resolution to convert voltage of
|
||||
* temperature sensor.
|
||||
* Otherwise, this macro performs the processing to scale
|
||||
* ADC conversion data to 12 bits.
|
||||
* @param __VREFANALOG_VOLTAGE__ Analog reference voltage (unit: mV)
|
||||
* @param __TEMPSENSOR_ADC_DATA__ ADC conversion data of internal
|
||||
* temperature sensor (unit: digital value).
|
||||
* @param __ADC_RESOLUTION__ ADC resolution at which internal temperature
|
||||
* sensor voltage has been measured.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg @ref LL_ADC_RESOLUTION_12B
|
||||
* @arg @ref LL_ADC_RESOLUTION_10B
|
||||
* @arg @ref LL_ADC_RESOLUTION_8B
|
||||
* @arg @ref LL_ADC_RESOLUTION_6B
|
||||
* @retval Temperature (unit: degree Celsius)
|
||||
*/
|
||||
#define __LL_ADC_CALC_TEMPERATURE(__VREFANALOG_VOLTAGE__,\
|
||||
__TEMPSENSOR_ADC_DATA__,\
|
||||
__ADC_RESOLUTION__) \
|
||||
(((( ((int32_t)((__LL_ADC_CONVERT_DATA_RESOLUTION((__TEMPSENSOR_ADC_DATA__), \
|
||||
(__ADC_RESOLUTION__), \
|
||||
LL_ADC_RESOLUTION_12B) \
|
||||
* (__VREFANALOG_VOLTAGE__)) \
|
||||
/ TEMPSENSOR_CAL_VREFANALOG) \
|
||||
- (int32_t) *TEMPSENSOR_CAL1_ADDR) \
|
||||
) * (int32_t)(TEMPSENSOR_CAL2_TEMP - TEMPSENSOR_CAL1_TEMP) \
|
||||
) / (int32_t)((int32_t)*TEMPSENSOR_CAL2_ADDR - (int32_t)*TEMPSENSOR_CAL1_ADDR) \
|
||||
) + TEMPSENSOR_CAL1_TEMP \
|
||||
)
|
||||
|
||||
/**
|
||||
* @brief Helper macro to calculate the temperature (unit: degree Celsius)
|
||||
* from ADC conversion data of internal temperature sensor.
|
||||
* @note Computation is using temperature sensor typical values
|
||||
* (refer to device datasheet).
|
||||
* @note Calculation formula:
|
||||
* Temperature = (TS_ADC_DATA * Conversion_uV-TS_TYP_CALx_VOLT(uV) )
|
||||
* / Avg_Slope + CALx_TEMP
|
||||
* with TS_ADC_DATA = temperature sensor raw data measured by ADC
|
||||
* (unit: digital value)
|
||||
* Avg_Slope = temperature sensor slope
|
||||
* (unit: uV/Degree Celsius)
|
||||
* TS_TYP_CALx_VOLT = temperature sensor digital value at
|
||||
* temperature CALx_TEMP (unit: mV)
|
||||
* Caution: Calculation relevancy under reserve the temperature sensor
|
||||
* of the current device has characteristics in line with
|
||||
* datasheet typical values.
|
||||
* If temperature sensor calibration values are available on
|
||||
* on this device (presence of macro __LL_ADC_CALC_TEMPERATURE()),
|
||||
* temperature calculation will be more accurate using
|
||||
* helper macro @ref __LL_ADC_CALC_TEMPERATURE().
|
||||
* @note As calculation input, the analog reference voltage (Vref+) must be
|
||||
* defined as it impacts the ADC LSB equivalent voltage.
|
||||
* @note Analog reference voltage (Vref+) must be either known from
|
||||
* user board environment or can be calculated using ADC measurement
|
||||
* and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
|
||||
* @note ADC measurement data must correspond to a resolution of 12bits
|
||||
* (full scale digital value 4095). If not the case, the data must be
|
||||
* preliminarily rescaled to an equivalent resolution of 12 bits.
|
||||
* @param __TEMPSENSOR_TYP_AVGSLOPE__ Device datasheet data: Temperature sensor slope typical value (unit: uV/DegCelsius).
|
||||
* On PY32F0, refer to device datasheet parameter "Avg_Slope".
|
||||
* @param __TEMPSENSOR_TYP_CALX_V__ Device datasheet data: Temperature sensor voltage typical value (at temperature and Vref+ defined in parameters below) (unit: mV).
|
||||
* On PY32F0, refer to device datasheet parameter "V30" (corresponding to TS_CAL1).
|
||||
* @param __TEMPSENSOR_CALX_TEMP__ Device datasheet data: Temperature at which temperature sensor voltage (see parameter above) is corresponding (unit: mV)
|
||||
* @param __VREFANALOG_VOLTAGE__ Analog voltage reference (Vref+) voltage (unit: mV)
|
||||
* @param __TEMPSENSOR_ADC_DATA__ ADC conversion data of internal temperature sensor (unit: digital value).
|
||||
* @param __ADC_RESOLUTION__ ADC resolution at which internal temperature sensor voltage has been measured.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg @ref LL_ADC_RESOLUTION_12B
|
||||
* @arg @ref LL_ADC_RESOLUTION_10B
|
||||
* @arg @ref LL_ADC_RESOLUTION_8B
|
||||
* @arg @ref LL_ADC_RESOLUTION_6B
|
||||
* @retval Temperature (unit: degree Celsius)
|
||||
*/
|
||||
|
||||
#define __LL_ADC_CALC_TEMPERATURE_TYP_PARAMS(__TEMPSENSOR_TYP_AVGSLOPE__,\
|
||||
__TEMPSENSOR_TYP_CALX_V__,\
|
||||
__TEMPSENSOR_CALX_TEMP__,\
|
||||
__VREFANALOG_VOLTAGE__,\
|
||||
__TEMPSENSOR_ADC_DATA__,\
|
||||
__ADC_RESOLUTION__) \
|
||||
(((( (int32_t)((((__TEMPSENSOR_ADC_DATA__) * (__VREFANALOG_VOLTAGE__)) \
|
||||
/ __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__)) \
|
||||
* 1000)- (int32_t)(((__TEMPSENSOR_TYP_CALX_V__)) \
|
||||
* 1000))) / (__TEMPSENSOR_TYP_AVGSLOPE__) \
|
||||
) + (__TEMPSENSOR_CALX_TEMP__) \
|
||||
)
|
||||
|
||||
#if (defined(DMA) || defined(DMA1))
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/** @defgroup ADC_LL_Exported_Functions ADC Exported Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_LL_EF_DMA_Management ADC DMA management
|
||||
* @{
|
||||
*/
|
||||
/* Note: LL ADC functions to set DMA transfer are located into sections of */
|
||||
/* configuration of ADC instance, groups and multimode (if available): */
|
||||
/* @ref LL_ADC_REG_SetDMATransfer(), ... */
|
||||
|
||||
/**
|
||||
* @brief Function to help to configure DMA transfer from ADC: retrieve the
|
||||
* ADC register address from ADC instance and a list of ADC registers
|
||||
* intended to be used (most commonly) with DMA transfer.
|
||||
* @note These ADC registers are data registers:
|
||||
* when ADC conversion data is available in ADC data registers,
|
||||
* ADC generates a DMA transfer request.
|
||||
* @note This macro is intended to be used with LL DMA driver, refer to
|
||||
* function "LL_DMA_ConfigAddresses()".
|
||||
* Example:
|
||||
* LL_DMA_ConfigAddresses(DMA1,
|
||||
* LL_DMA_CHANNEL_1,
|
||||
* LL_ADC_DMA_GetRegAddr(ADC1, LL_ADC_DMA_REG_REGULAR_DATA),
|
||||
* (uint32_t)&< array or variable >,
|
||||
* LL_DMA_DIRECTION_PERIPH_TO_MEMORY);
|
||||
* @note For devices with several ADC: in multimode, some devices
|
||||
* use a different data register outside of ADC instance scope
|
||||
* (common data register). This macro manages this register difference,
|
||||
* only ADC instance has to be set as parameter.
|
||||
* @note Depending on devices and packages, DMA may not be available.
|
||||
* Refer to device datasheet for DMA availability.
|
||||
* @rmtoll DR DATA LL_ADC_DMA_GetRegAddr
|
||||
* @param ADCx ADC instance
|
||||
* @param Register This parameter can be one of the following values:
|
||||
* @arg @ref LL_ADC_DMA_REG_REGULAR_DATA
|
||||
* @retval ADC register address
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_ADC_DMA_GetRegAddr(ADC_TypeDef *ADCx, uint32_t Register)
|
||||
{
|
||||
/* Retrieve address of register DR */
|
||||
return (uint32_t)&(ADCx->DR);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_LL_EF_Configuration_ADC_Common Configuration of ADC hierarchical scope: common to several ADC instances
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Set parameter common to several ADC: measurement path to internal
|
||||
* channels (VrefInt, temperature sensor, ...).
|
||||
* @note One or several values can be selected.
|
||||
* Example: (LL_ADC_PATH_INTERNAL_VREFINT |
|
||||
* LL_ADC_PATH_INTERNAL_TEMPSENSOR)
|
||||
* @note Stabilization time of measurement path to internal channel:
|
||||
* After enabling internal paths, before starting ADC conversion,
|
||||
* a delay is required for internal voltage reference and
|
||||
* temperature sensor stabilization time.
|
||||
* Refer to device datasheet.
|
||||
* Refer to literal @ref LL_ADC_DELAY_VREFINT_STAB_US.
|
||||
* Refer to literal @ref LL_ADC_DELAY_TEMPSENSOR_STAB_US.
|
||||
* @note ADC internal channel sampling time constraint:
|
||||
* For ADC conversion of internal channels,
|
||||
* a sampling time minimum value is required.
|
||||
* Refer to device datasheet.
|
||||
* @note On this PY32 serie, setting of this feature is conditioned to
|
||||
* ADC state:
|
||||
* All ADC instances of the ADC common group must be disabled.
|
||||
* This check can be done with function @ref LL_ADC_IsEnabled() for each
|
||||
* ADC instance or by using helper macro helper macro
|
||||
* @ref __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE().
|
||||
* @rmtoll CCR VREFEN LL_ADC_SetCommonPathInternalCh\n
|
||||
* CCR TSEN LL_ADC_SetCommonPathInternalCh
|
||||
* @param ADCxy_COMMON ADC common instance
|
||||
* (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
|
||||
* @param PathInternal This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_ADC_PATH_INTERNAL_NONE
|
||||
* @arg @ref LL_ADC_PATH_INTERNAL_VREFINT
|
||||
* @arg @ref LL_ADC_PATH_INTERNAL_TEMPSENSOR
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_ADC_SetCommonPathInternalCh(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t PathInternal)
|
||||
{
|
||||
MODIFY_REG(ADCxy_COMMON->CCR, ADC_CCR_VREFEN | ADC_CCR_TSEN, PathInternal);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get parameter common to several ADC: measurement path to internal
|
||||
* channels (VrefInt, temperature sensor, ...).
|
||||
* @note One or several values can be selected.
|
||||
* Example: (LL_ADC_PATH_INTERNAL_VREFINT |
|
||||
* LL_ADC_PATH_INTERNAL_TEMPSENSOR)
|
||||
* @rmtoll CCR VREFEN LL_ADC_GetCommonPathInternalCh\n
|
||||
* CCR TSEN LL_ADC_GetCommonPathInternalCh
|
||||
* @param ADCxy_COMMON ADC common instance
|
||||
* (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
|
||||
* @retval Returned value can be a combination of the following values:
|
||||
* @arg @ref LL_ADC_PATH_INTERNAL_NONE
|
||||
* @arg @ref LL_ADC_PATH_INTERNAL_VREFINT
|
||||
* @arg @ref LL_ADC_PATH_INTERNAL_TEMPSENSOR
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_ADC_GetCommonPathInternalCh(ADC_Common_TypeDef *ADCxy_COMMON)
|
||||
{
|
||||
return (uint32_t)(READ_BIT(ADCxy_COMMON->CCR, ADC_CCR_VREFEN | ADC_CCR_TSEN));
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_LL_EF_Configuration_ADC_Instance Configuration of ADC hierarchical scope: ADC instance
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Set ADC instance clock source and prescaler.
|
||||
* @note On this PY32 serie, setting of this feature is conditioned to
|
||||
* ADC state:
|
||||
* ADC must be disabled.
|
||||
* @rmtoll CFGR2 CKMODE LL_ADC_SetClock
|
||||
* @param ADCx ADC instance
|
||||
* @param ClockSource This parameter can be one of the following values:
|
||||
* @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV1
|
||||
* @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV2
|
||||
* @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV4
|
||||
* @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV8
|
||||
* @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV16
|
||||
* @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV32
|
||||
* @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV64
|
||||
* @arg @ref LL_ADC_CLOCK_ASYNC_HSI_DIV1
|
||||
* @arg @ref LL_ADC_CLOCK_ASYNC_HSI_DIV2
|
||||
* @arg @ref LL_ADC_CLOCK_ASYNC_HSI_DIV4
|
||||
* @arg @ref LL_ADC_CLOCK_ASYNC_HSI_DIV8
|
||||
* @arg @ref LL_ADC_CLOCK_ASYNC_HSI_DIV16
|
||||
* @arg @ref LL_ADC_CLOCK_ASYNC_HSI_DIV32
|
||||
* @arg @ref LL_ADC_CLOCK_ASYNC_HSI_DIV64
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_ADC_SetClock(ADC_TypeDef *ADCx, uint32_t ClockSource)
|
||||
{
|
||||
MODIFY_REG(ADCx->CFGR2, ADC_CFGR2_CKMODE, ClockSource);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get ADC instance clock source and prescaler.
|
||||
* @rmtoll CFGR2 CKMODE LL_ADC_GetClock
|
||||
* @param ADCx ADC instance
|
||||
* @retval Returned value can be one of the following values:
|
||||
* @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV1
|
||||
* @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV2
|
||||
* @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV4
|
||||
* @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV8
|
||||
* @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV16
|
||||
* @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV32
|
||||
* @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV64
|
||||
* @arg @ref LL_ADC_CLOCK_ASYNC_HSI_DIV1
|
||||
* @arg @ref LL_ADC_CLOCK_ASYNC_HSI_DIV2
|
||||
* @arg @ref LL_ADC_CLOCK_ASYNC_HSI_DIV4
|
||||
* @arg @ref LL_ADC_CLOCK_ASYNC_HSI_DIV8
|
||||
* @arg @ref LL_ADC_CLOCK_ASYNC_HSI_DIV16
|
||||
* @arg @ref LL_ADC_CLOCK_ASYNC_HSI_DIV32
|
||||
* @arg @ref LL_ADC_CLOCK_ASYNC_HSI_DIV64
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_ADC_GetClock(ADC_TypeDef *ADCx)
|
||||
{
|
||||
return (uint32_t)(READ_BIT(ADCx->CFGR2, ADC_CFGR2_CKMODE));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set ADC resolution.
|
||||
* Refer to reference manual for alignments formats
|
||||
* dependencies to ADC resolutions.
|
||||
* @note On this PY32 serie, setting of this feature is conditioned to
|
||||
* ADC state:
|
||||
* ADC must be disabled or enabled without conversion on going
|
||||
* on group regular.
|
||||
* @rmtoll CFGR1 RES LL_ADC_SetResolution
|
||||
* @param ADCx ADC instance
|
||||
* @param Resolution This parameter can be one of the following values:
|
||||
* @arg @ref LL_ADC_RESOLUTION_12B
|
||||
* @arg @ref LL_ADC_RESOLUTION_10B
|
||||
* @arg @ref LL_ADC_RESOLUTION_8B
|
||||
* @arg @ref LL_ADC_RESOLUTION_6B
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_ADC_SetResolution(ADC_TypeDef *ADCx, uint32_t Resolution)
|
||||
{
|
||||
MODIFY_REG(ADCx->CFGR1, ADC_CFGR1_RESSEL, Resolution);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get ADC resolution.
|
||||
* Refer to reference manual for alignments formats
|
||||
* dependencies to ADC resolutions.
|
||||
* @rmtoll CFGR1 RES LL_ADC_GetResolution
|
||||
* @param ADCx ADC instance
|
||||
* @retval Returned value can be one of the following values:
|
||||
* @arg @ref LL_ADC_RESOLUTION_12B
|
||||
* @arg @ref LL_ADC_RESOLUTION_10B
|
||||
* @arg @ref LL_ADC_RESOLUTION_8B
|
||||
* @arg @ref LL_ADC_RESOLUTION_6B
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_ADC_GetResolution(ADC_TypeDef *ADCx)
|
||||
{
|
||||
return (uint32_t)(READ_BIT(ADCx->CFGR1, ADC_CFGR1_RESSEL));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set ADC conversion data alignment.
|
||||
* @note Refer to reference manual for alignments formats
|
||||
* dependencies to ADC resolutions.
|
||||
* @note On this PY32 serie, setting of this feature is conditioned to
|
||||
* ADC state:
|
||||
* ADC must be disabled or enabled without conversion on going
|
||||
* on group regular.
|
||||
* @rmtoll CFGR1 ALIGN LL_ADC_SetDataAlignment
|
||||
* @param ADCx ADC instance
|
||||
* @param DataAlignment This parameter can be one of the following values:
|
||||
* @arg @ref LL_ADC_DATA_ALIGN_RIGHT
|
||||
* @arg @ref LL_ADC_DATA_ALIGN_LEFT
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_ADC_SetDataAlignment(ADC_TypeDef *ADCx, uint32_t DataAlignment)
|
||||
{
|
||||
MODIFY_REG(ADCx->CFGR1, ADC_CFGR1_ALIGN, DataAlignment);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get ADC conversion data alignment.
|
||||
* @note Refer to reference manual for alignments formats
|
||||
* dependencies to ADC resolutions.
|
||||
* @rmtoll CFGR1 ALIGN LL_ADC_GetDataAlignment
|
||||
* @param ADCx ADC instance
|
||||
* @retval Returned value can be one of the following values:
|
||||
* @arg @ref LL_ADC_DATA_ALIGN_RIGHT
|
||||
* @arg @ref LL_ADC_DATA_ALIGN_LEFT
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_ADC_GetDataAlignment(ADC_TypeDef *ADCx)
|
||||
{
|
||||
return (uint32_t)(READ_BIT(ADCx->CFGR1, ADC_CFGR1_ALIGN));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set ADC low power mode.
|
||||
* @note Description of ADC low power modes:
|
||||
* - ADC low power mode "auto wait": Dynamic low power mode,
|
||||
* ADC conversions occurrences are limited to the minimum necessary
|
||||
* in order to reduce power consumption.
|
||||
* New ADC conversion starts only when the previous
|
||||
* unitary conversion data (for ADC group regular)
|
||||
* has been retrieved by user software.
|
||||
* In the meantime, ADC remains idle: does not performs any
|
||||
* other conversion.
|
||||
* This mode allows to automatically adapt the ADC conversions
|
||||
* triggers to the speed of the software that reads the data.
|
||||
* Moreover, this avoids risk of overrun for low frequency
|
||||
* applications.
|
||||
* How to use this low power mode:
|
||||
* - Do not use with interruption or DMA since these modes
|
||||
* have to clear immediately the EOC flag to free the
|
||||
* IRQ vector sequencer.
|
||||
* - Do use with polling: 1. Start conversion,
|
||||
* 2. Later on, when conversion data is needed: poll for end of
|
||||
* conversion to ensure that conversion is completed and
|
||||
* retrieve ADC conversion data. This will trig another
|
||||
* ADC conversion start.
|
||||
*
|
||||
* @note With ADC low power mode "auto wait", the ADC conversion data read
|
||||
* is corresponding to previous ADC conversion start, independently
|
||||
* of delay during which ADC was idle.
|
||||
* Therefore, the ADC conversion data may be outdated: does not
|
||||
* correspond to the current voltage level on the selected
|
||||
* ADC channel.
|
||||
* @note On this PY32 serie, setting of this feature is conditioned to
|
||||
* ADC state:
|
||||
* ADC must be disabled or enabled without conversion on going
|
||||
* on group regular.
|
||||
* @note Depending on devices and packages, DMA may not be available.
|
||||
* Refer to device datasheet for DMA availability.
|
||||
* @rmtoll CFGR1 WAIT LL_ADC_SetLowPowerMode
|
||||
* @param ADCx ADC instance
|
||||
* @param LowPowerMode This parameter can be one of the following values:
|
||||
* @arg @ref LL_ADC_LP_MODE_NONE
|
||||
* @arg @ref LL_ADC_LP_AUTOWAIT
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_ADC_SetLowPowerMode(ADC_TypeDef *ADCx, uint32_t LowPowerMode)
|
||||
{
|
||||
MODIFY_REG(ADCx->CFGR1, (ADC_CFGR1_WAIT), LowPowerMode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get ADC low power mode:
|
||||
* @note Description of ADC low power modes:
|
||||
* - ADC low power mode "auto wait": Dynamic low power mode,
|
||||
* ADC conversions occurrences are limited to the minimum necessary
|
||||
* in order to reduce power consumption.
|
||||
* New ADC conversion starts only when the previous
|
||||
* unitary conversion data (for ADC group regular)
|
||||
* has been retrieved by user software.
|
||||
* In the meantime, ADC remains idle: does not performs any
|
||||
* other conversion.
|
||||
* This mode allows to automatically adapt the ADC conversions
|
||||
* triggers to the speed of the software that reads the data.
|
||||
* Moreover, this avoids risk of overrun for low frequency
|
||||
* applications.
|
||||
* How to use this low power mode:
|
||||
* - Do not use with interruption or DMA since these modes
|
||||
* have to clear immediately the EOC flag to free the
|
||||
* IRQ vector sequencer.
|
||||
* - Do use with polling: 1. Start conversion,
|
||||
* 2. Later on, when conversion data is needed: poll for end of
|
||||
* conversion to ensure that conversion is completed and
|
||||
* retrieve ADC conversion data. This will trig another
|
||||
* ADC conversion start.
|
||||
* This feature can be combined with low power mode "auto wait".
|
||||
* @note With ADC low power mode "auto wait", the ADC conversion data read
|
||||
* is corresponding to previous ADC conversion start, independently
|
||||
* of delay during which ADC was idle.
|
||||
* Therefore, the ADC conversion data may be outdated: does not
|
||||
* correspond to the current voltage level on the selected
|
||||
* ADC channel.
|
||||
* @note Depending on devices and packages, DMA may not be available.
|
||||
* Refer to device datasheet for DMA availability.
|
||||
* @rmtoll CFGR1 WAIT LL_ADC_GetLowPowerMode
|
||||
* @param ADCx ADC instance
|
||||
* @retval Returned value can be one of the following values:
|
||||
* @arg @ref LL_ADC_LP_MODE_NONE
|
||||
* @arg @ref LL_ADC_LP_AUTOWAIT
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_ADC_GetLowPowerMode(ADC_TypeDef *ADCx)
|
||||
{
|
||||
return (uint32_t)(READ_BIT(ADCx->CFGR1, (ADC_CFGR1_WAIT )));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set sampling time common to a group of channels.
|
||||
* @note Unit: ADC clock cycles.
|
||||
* @note On this PY32 serie, sampling time scope is on ADC instance:
|
||||
* Sampling time common to all channels.
|
||||
* (on some other PY32 families, sampling time is channel wise)
|
||||
* @note In case of internal channel (VrefInt, TempSensor, ...) to be
|
||||
* converted:
|
||||
* sampling time constraints must be respected (sampling time can be
|
||||
* adjusted in function of ADC clock frequency and sampling time
|
||||
* setting).
|
||||
* Refer to device datasheet for timings values (parameters TS_vrefint,
|
||||
* TS_temp, ...).
|
||||
* @note Conversion time is the addition of sampling time and processing time.
|
||||
* On this PY32 serie, ADC processing time is:
|
||||
* - 12.5 ADC clock cycles at ADC resolution 12 bits
|
||||
* - 10.5 ADC clock cycles at ADC resolution 10 bits
|
||||
* - 8.5 ADC clock cycles at ADC resolution 8 bits
|
||||
* - 6.5 ADC clock cycles at ADC resolution 6 bits
|
||||
* @note In case of ADC conversion of internal channel (VrefInt,
|
||||
* temperature sensor, ...), a sampling time minimum value
|
||||
* is required.
|
||||
* Refer to device datasheet.
|
||||
* @note On this PY32 serie, setting of this feature is conditioned to
|
||||
* ADC state:
|
||||
* ADC must be disabled or enabled without conversion on going
|
||||
* on group regular.
|
||||
* @rmtoll SMPR SMP LL_ADC_SetSamplingTimeCommonChannels
|
||||
* @param ADCx ADC instance
|
||||
* @param SamplingTime This parameter can be one of the following values:
|
||||
* @arg @ref LL_ADC_SAMPLINGTIME_3CYCLES_5
|
||||
* @arg @ref LL_ADC_SAMPLINGTIME_5CYCLES_5
|
||||
* @arg @ref LL_ADC_SAMPLINGTIME_7CYCLES_5
|
||||
* @arg @ref LL_ADC_SAMPLINGTIME_13CYCLES_5
|
||||
* @arg @ref LL_ADC_SAMPLINGTIME_28CYCLES_5
|
||||
* @arg @ref LL_ADC_SAMPLINGTIME_41CYCLES_5
|
||||
* @arg @ref LL_ADC_SAMPLINGTIME_71CYCLES_5
|
||||
* @arg @ref LL_ADC_SAMPLINGTIME_239CYCLES_5
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_ADC_SetSamplingTimeCommonChannels(ADC_TypeDef *ADCx, uint32_t SamplingTime)
|
||||
{
|
||||
MODIFY_REG(ADCx->SMPR, ADC_SMPR_SMP, SamplingTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sampling time common to a group of channels.
|
||||
* @note Unit: ADC clock cycles.
|
||||
* @note On this PY32 serie, sampling time scope is on ADC instance:
|
||||
* Sampling time common to all channels.
|
||||
* (on some other PY32 families, sampling time is channel wise)
|
||||
* @note Conversion time is the addition of sampling time and processing time.
|
||||
* Refer to reference manual for ADC processing time of
|
||||
* this PY32 serie.
|
||||
* @rmtoll SMPR SMP LL_ADC_GetSamplingTimeCommonChannels
|
||||
* @param ADCx ADC instance
|
||||
* @retval Returned value can be one of the following values:
|
||||
* @arg @ref LL_ADC_SAMPLINGTIME_3CYCLES_5
|
||||
* @arg @ref LL_ADC_SAMPLINGTIME_5CYCLES_5
|
||||
* @arg @ref LL_ADC_SAMPLINGTIME_7CYCLES_5
|
||||
* @arg @ref LL_ADC_SAMPLINGTIME_13CYCLES_5
|
||||
* @arg @ref LL_ADC_SAMPLINGTIME_28CYCLES_5
|
||||
* @arg @ref LL_ADC_SAMPLINGTIME_41CYCLES_5
|
||||
* @arg @ref LL_ADC_SAMPLINGTIME_71CYCLES_5
|
||||
* @arg @ref LL_ADC_SAMPLINGTIME_239CYCLES_5
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_ADC_GetSamplingTimeCommonChannels(ADC_TypeDef *ADCx)
|
||||
{
|
||||
return (uint32_t)(READ_BIT(ADCx->SMPR, ADC_SMPR_SMP));
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_LL_EF_Configuration_ADC_Group_Regular Configuration of ADC hierarchical scope: group regular
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Set ADC group regular conversion trigger source:
|
||||
* internal (SW start) or from external IP (timer event,
|
||||
* external interrupt line).
|
||||
* @note On this PY32 serie, setting trigger source to external trigger
|
||||
* also set trigger polarity to rising edge
|
||||
* (default setting for compatibility with some ADC on other
|
||||
* PY32 families having this setting set by HW default value).
|
||||
* In case of need to modify trigger edge, use
|
||||
* function @ref LL_ADC_REG_SetTriggerEdge().
|
||||
* @note Availability of parameters of trigger sources from timer
|
||||
* depends on timers availability on the selected device.
|
||||
* @note On this PY32 serie, setting of this feature is conditioned to
|
||||
* ADC state:
|
||||
* ADC must be disabled or enabled without conversion on going
|
||||
* on group regular.
|
||||
* @rmtoll CFGR1 EXTSEL LL_ADC_REG_SetTriggerSource\n
|
||||
* CFGR1 EXTEN LL_ADC_REG_SetTriggerSource
|
||||
* @param ADCx ADC instance
|
||||
* @param TriggerSource This parameter can be one of the following values:
|
||||
* @arg @ref LL_ADC_REG_TRIG_SOFTWARE
|
||||
* @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_TRGO
|
||||
* @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH4
|
||||
* @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_TRGO
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_ADC_REG_SetTriggerSource(ADC_TypeDef *ADCx, uint32_t TriggerSource)
|
||||
{
|
||||
MODIFY_REG(ADCx->CFGR1, ADC_CFGR1_EXTEN | ADC_CFGR1_EXTSEL, TriggerSource);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get ADC group regular conversion trigger source:
|
||||
* internal (SW start) or from external IP (timer event,
|
||||
* external interrupt line).
|
||||
* @note To determine whether group regular trigger source is
|
||||
* internal (SW start) or external, without detail
|
||||
* of which peripheral is selected as external trigger,
|
||||
* (equivalent to
|
||||
* "if(LL_ADC_REG_GetTriggerSource(ADC1) == LL_ADC_REG_TRIG_SOFTWARE)")
|
||||
* use function @ref LL_ADC_REG_IsTriggerSourceSWStart.
|
||||
* @note Availability of parameters of trigger sources from timer
|
||||
* depends on timers availability on the selected device.
|
||||
* @rmtoll CFGR1 EXTSEL LL_ADC_REG_GetTriggerSource\n
|
||||
* CFGR1 EXTEN LL_ADC_REG_GetTriggerSource
|
||||
* @param ADCx ADC instance
|
||||
* @retval Returned value can be one of the following values:
|
||||
* @arg @ref LL_ADC_REG_TRIG_SOFTWARE
|
||||
* @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_TRGO
|
||||
* @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH4
|
||||
* @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_TRGO
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_ADC_REG_GetTriggerSource(ADC_TypeDef *ADCx)
|
||||
{
|
||||
register uint32_t TriggerSource = READ_BIT(ADCx->CFGR1, ADC_CFGR1_EXTSEL | ADC_CFGR1_EXTEN);
|
||||
|
||||
/* Value for shift of {0; 4; 8; 12} depending on value of bitfield */
|
||||
/* corresponding to ADC_CFGR1_EXTEN {0; 1; 2; 3}. */
|
||||
register uint32_t ShiftExten = ((TriggerSource & ADC_CFGR1_EXTEN) >> (ADC_REG_TRIG_EXTEN_BITOFFSET_POS - 2U));
|
||||
|
||||
/* Set bitfield corresponding to ADC_CFGR1_EXTEN and ADC_CFGR1_EXTSEL */
|
||||
/* to match with triggers literals definition. */
|
||||
return ((TriggerSource
|
||||
& (ADC_REG_TRIG_SOURCE_MASK >> ShiftExten) & ADC_CFGR1_EXTSEL)
|
||||
| ((ADC_REG_TRIG_EDGE_MASK >> ShiftExten) & ADC_CFGR1_EXTEN)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get ADC group regular conversion trigger source internal (SW start)
|
||||
* or external.
|
||||
* @note In case of group regular trigger source set to external trigger,
|
||||
* to determine which peripheral is selected as external trigger,
|
||||
* use function @ref LL_ADC_REG_GetTriggerSource().
|
||||
* @rmtoll CFGR1 EXTEN LL_ADC_REG_IsTriggerSourceSWStart
|
||||
* @param ADCx ADC instance
|
||||
* @retval Value "0" if trigger source external trigger
|
||||
* Value "1" if trigger source SW start.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_ADC_REG_IsTriggerSourceSWStart(ADC_TypeDef *ADCx)
|
||||
{
|
||||
return (READ_BIT(ADCx->CFGR1, ADC_CFGR1_EXTEN) == (LL_ADC_REG_TRIG_SOFTWARE & ADC_CFGR1_EXTEN));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set ADC group regular conversion trigger polarity.
|
||||
* @note Applicable only for trigger source set to external trigger.
|
||||
* @note On this PY32 serie, setting of this feature is conditioned to
|
||||
* ADC state:
|
||||
* ADC must be disabled or enabled without conversion on going
|
||||
* on group regular.
|
||||
* @rmtoll CFGR1 EXTEN LL_ADC_REG_SetTriggerEdge
|
||||
* @param ADCx ADC instance
|
||||
* @param ExternalTriggerEdge This parameter can be one of the following values:
|
||||
* @arg @ref LL_ADC_REG_TRIG_EXT_RISING
|
||||
* @arg @ref LL_ADC_REG_TRIG_EXT_FALLING
|
||||
* @arg @ref LL_ADC_REG_TRIG_EXT_RISINGFALLING
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_ADC_REG_SetTriggerEdge(ADC_TypeDef *ADCx, uint32_t ExternalTriggerEdge)
|
||||
{
|
||||
MODIFY_REG(ADCx->CFGR1, ADC_CFGR1_EXTEN, ExternalTriggerEdge);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get ADC group regular conversion trigger polarity.
|
||||
* @note Applicable only for trigger source set to external trigger.
|
||||
* @rmtoll CFGR1 EXTEN LL_ADC_REG_GetTriggerEdge
|
||||
* @param ADCx ADC instance
|
||||
* @retval Returned value can be one of the following values:
|
||||
* @arg @ref LL_ADC_REG_TRIG_EXT_RISING
|
||||
* @arg @ref LL_ADC_REG_TRIG_EXT_FALLING
|
||||
* @arg @ref LL_ADC_REG_TRIG_EXT_RISINGFALLING
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_ADC_REG_GetTriggerEdge(ADC_TypeDef *ADCx)
|
||||
{
|
||||
return (uint32_t)(READ_BIT(ADCx->CFGR1, ADC_CFGR1_EXTEN));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Set ADC group regular sequencer scan direction.
|
||||
* @note On some other PY32 families, this setting is not available and
|
||||
* the default scan direction is forward.
|
||||
* @note On this PY32 serie, setting of this feature is conditioned to
|
||||
* ADC state:
|
||||
* ADC must be disabled or enabled without conversion on going
|
||||
* on group regular.
|
||||
* @rmtoll CFGR1 SCANDIR LL_ADC_REG_SetSequencerScanDirection
|
||||
* @param ADCx ADC instance
|
||||
* @param ScanDirection This parameter can be one of the following values:
|
||||
* @arg @ref LL_ADC_REG_SEQ_SCAN_DIR_FORWARD
|
||||
* @arg @ref LL_ADC_REG_SEQ_SCAN_DIR_BACKWARD
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_ADC_REG_SetSequencerScanDirection(ADC_TypeDef *ADCx, uint32_t ScanDirection)
|
||||
{
|
||||
MODIFY_REG(ADCx->CFGR1, ADC_CFGR1_SCANDIR, ScanDirection);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get ADC group regular sequencer scan direction.
|
||||
* @note On some other PY32 families, this setting is not available and
|
||||
* the default scan direction is forward.
|
||||
* @rmtoll CFGR1 SCANDIR LL_ADC_REG_GetSequencerScanDirection
|
||||
* @param ADCx ADC instance
|
||||
* @retval Returned value can be one of the following values:
|
||||
* @arg @ref LL_ADC_REG_SEQ_SCAN_DIR_FORWARD
|
||||
* @arg @ref LL_ADC_REG_SEQ_SCAN_DIR_BACKWARD
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerScanDirection(ADC_TypeDef *ADCx)
|
||||
{
|
||||
return (uint32_t)(READ_BIT(ADCx->CFGR1, ADC_CFGR1_SCANDIR));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set ADC group regular sequencer discontinuous mode:
|
||||
* sequence subdivided and scan conversions interrupted every selected
|
||||
* number of ranks.
|
||||
* @note It is not possible to enable both ADC group regular
|
||||
* continuous mode and sequencer discontinuous mode.
|
||||
* @note On this PY32 serie, setting of this feature is conditioned to
|
||||
* ADC state:
|
||||
* ADC must be disabled or enabled without conversion on going
|
||||
* on group regular.
|
||||
* @rmtoll CFGR1 DISCEN LL_ADC_REG_SetSequencerDiscont\n
|
||||
* @param ADCx ADC instance
|
||||
* @param SeqDiscont This parameter can be one of the following values:
|
||||
* @arg @ref LL_ADC_REG_SEQ_DISCONT_DISABLE
|
||||
* @arg @ref LL_ADC_REG_SEQ_DISCONT_1RANK
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_ADC_REG_SetSequencerDiscont(ADC_TypeDef *ADCx, uint32_t SeqDiscont)
|
||||
{
|
||||
MODIFY_REG(ADCx->CFGR1, ADC_CFGR1_DISCEN, SeqDiscont);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get ADC group regular sequencer discontinuous mode:
|
||||
* sequence subdivided and scan conversions interrupted every selected
|
||||
* number of ranks.
|
||||
* @rmtoll CFGR1 DISCEN LL_ADC_REG_GetSequencerDiscont\n
|
||||
* @param ADCx ADC instance
|
||||
* @retval Returned value can be one of the following values:
|
||||
* @arg @ref LL_ADC_REG_SEQ_DISCONT_DISABLE
|
||||
* @arg @ref LL_ADC_REG_SEQ_DISCONT_1RANK
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerDiscont(ADC_TypeDef *ADCx)
|
||||
{
|
||||
return (uint32_t)(READ_BIT(ADCx->CFGR1, ADC_CFGR1_DISCEN));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set ADC group regular sequence: channel on rank corresponding to
|
||||
* channel number.
|
||||
* @note This function performs:
|
||||
* - Channels ordering into each rank of scan sequence:
|
||||
* rank of each channel is fixed by channel HW number
|
||||
* (channel 0 fixed on rank 0, channel 1 fixed on rank1, ...).
|
||||
* - Set channels selected by overwriting the current sequencer
|
||||
* configuration.
|
||||
* @note On this PY32 serie, ADC group regular sequencer is
|
||||
* not fully configurable: sequencer length and each rank
|
||||
* affectation to a channel are fixed by channel HW number.
|
||||
* @note Depending on devices and packages, some channels may not be available.
|
||||
* Refer to device datasheet for channels availability.
|
||||
* @note On this PY32 serie, to measure internal channels (VrefInt,
|
||||
* TempSensor, ...), measurement paths to internal channels must be
|
||||
* enabled separately.
|
||||
* This can be done using function @ref LL_ADC_SetCommonPathInternalCh().
|
||||
* @note On this PY32 serie, setting of this feature is conditioned to
|
||||
* ADC state:
|
||||
* ADC must be disabled or enabled without conversion on going
|
||||
* on group regular.
|
||||
* @note One or several values can be selected.
|
||||
* Example: (LL_ADC_CHANNEL_4 | LL_ADC_CHANNEL_12 | ...)
|
||||
* @rmtoll CHSELR CHSEL0 LL_ADC_REG_SetSequencerChannels\n
|
||||
* CHSELR CHSEL1 LL_ADC_REG_SetSequencerChannels\n
|
||||
* CHSELR CHSEL2 LL_ADC_REG_SetSequencerChannels\n
|
||||
* CHSELR CHSEL3 LL_ADC_REG_SetSequencerChannels\n
|
||||
* CHSELR CHSEL4 LL_ADC_REG_SetSequencerChannels\n
|
||||
* CHSELR CHSEL5 LL_ADC_REG_SetSequencerChannels\n
|
||||
* CHSELR CHSEL6 LL_ADC_REG_SetSequencerChannels\n
|
||||
* CHSELR CHSEL7 LL_ADC_REG_SetSequencerChannels\n
|
||||
* CHSELR CHSEL8 LL_ADC_REG_SetSequencerChannels\n
|
||||
* CHSELR CHSEL9 LL_ADC_REG_SetSequencerChannels\n
|
||||
* CHSELR CHSEL11 LL_ADC_REG_SetSequencerChannels\n
|
||||
* CHSELR CHSEL12 LL_ADC_REG_SetSequencerChannels
|
||||
* @param ADCx ADC instance
|
||||
* @param Channel This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_ADC_CHANNEL_0
|
||||
* @arg @ref LL_ADC_CHANNEL_1
|
||||
* @arg @ref LL_ADC_CHANNEL_2
|
||||
* @arg @ref LL_ADC_CHANNEL_3
|
||||
* @arg @ref LL_ADC_CHANNEL_4
|
||||
* @arg @ref LL_ADC_CHANNEL_5
|
||||
* @arg @ref LL_ADC_CHANNEL_6
|
||||
* @arg @ref LL_ADC_CHANNEL_7
|
||||
* @arg @ref LL_ADC_CHANNEL_8
|
||||
* @arg @ref LL_ADC_CHANNEL_9
|
||||
* @arg @ref LL_ADC_CHANNEL_11
|
||||
* @arg @ref LL_ADC_CHANNEL_12
|
||||
* @arg @ref LL_ADC_CHANNEL_VREFINT
|
||||
* @arg @ref LL_ADC_CHANNEL_TEMPSENSOR
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_ADC_REG_SetSequencerChannels(ADC_TypeDef *ADCx, uint32_t Channel)
|
||||
{
|
||||
/* Parameter "Channel" is used with masks because containing */
|
||||
/* other bits reserved for other purpose. */
|
||||
WRITE_REG(ADCx->CHSELR, (Channel & ADC_CHANNEL_ID_BITFIELD_MASK));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Add channel to ADC group regular sequence: channel on rank corresponding to
|
||||
* channel number.
|
||||
* @note This function performs:
|
||||
* - Channels ordering into each rank of scan sequence:
|
||||
* rank of each channel is fixed by channel HW number
|
||||
* (channel 0 fixed on rank 0, channel 1 fixed on rank1, ...).
|
||||
* - Set channels selected by adding them to the current sequencer
|
||||
* configuration.
|
||||
* @note On this PY32 serie, ADC group regular sequencer is
|
||||
* not fully configurable: sequencer length and each rank
|
||||
* affectation to a channel are fixed by channel HW number.
|
||||
* @note Depending on devices and packages, some channels may not be available.
|
||||
* Refer to device datasheet for channels availability.
|
||||
* @note On this PY32 serie, to measure internal channels (VrefInt,
|
||||
* TempSensor, ...), measurement paths to internal channels must be
|
||||
* enabled separately.
|
||||
* This can be done using function @ref LL_ADC_SetCommonPathInternalCh().
|
||||
* @note On this PY32 serie, setting of this feature is conditioned to
|
||||
* ADC state:
|
||||
* ADC must be disabled or enabled without conversion on going
|
||||
* on group regular.
|
||||
* @note One or several values can be selected.
|
||||
* Example: (LL_ADC_CHANNEL_4 | LL_ADC_CHANNEL_12 | ...)
|
||||
* @rmtoll CHSELR CHSEL0 LL_ADC_REG_SetSequencerChAdd\n
|
||||
* CHSELR CHSEL1 LL_ADC_REG_SetSequencerChAdd\n
|
||||
* CHSELR CHSEL2 LL_ADC_REG_SetSequencerChAdd\n
|
||||
* CHSELR CHSEL3 LL_ADC_REG_SetSequencerChAdd\n
|
||||
* CHSELR CHSEL4 LL_ADC_REG_SetSequencerChAdd\n
|
||||
* CHSELR CHSEL5 LL_ADC_REG_SetSequencerChAdd\n
|
||||
* CHSELR CHSEL6 LL_ADC_REG_SetSequencerChAdd\n
|
||||
* CHSELR CHSEL7 LL_ADC_REG_SetSequencerChAdd\n
|
||||
* CHSELR CHSEL8 LL_ADC_REG_SetSequencerChAdd\n
|
||||
* CHSELR CHSEL9 LL_ADC_REG_SetSequencerChAdd\n
|
||||
* CHSELR CHSEL11 LL_ADC_REG_SetSequencerChAdd\n
|
||||
* CHSELR CHSEL12 LL_ADC_REG_SetSequencerChAdd
|
||||
* @param ADCx ADC instance
|
||||
* @param Channel This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_ADC_CHANNEL_0
|
||||
* @arg @ref LL_ADC_CHANNEL_1
|
||||
* @arg @ref LL_ADC_CHANNEL_2
|
||||
* @arg @ref LL_ADC_CHANNEL_3
|
||||
* @arg @ref LL_ADC_CHANNEL_4
|
||||
* @arg @ref LL_ADC_CHANNEL_5
|
||||
* @arg @ref LL_ADC_CHANNEL_6
|
||||
* @arg @ref LL_ADC_CHANNEL_7
|
||||
* @arg @ref LL_ADC_CHANNEL_8
|
||||
* @arg @ref LL_ADC_CHANNEL_9
|
||||
* @arg @ref LL_ADC_CHANNEL_11
|
||||
* @arg @ref LL_ADC_CHANNEL_12
|
||||
* @arg @ref LL_ADC_CHANNEL_VREFINT
|
||||
* @arg @ref LL_ADC_CHANNEL_TEMPSENSOR
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_ADC_REG_SetSequencerChAdd(ADC_TypeDef *ADCx, uint32_t Channel)
|
||||
{
|
||||
/* Parameter "Channel" is used with masks because containing */
|
||||
/* other bits reserved for other purpose. */
|
||||
SET_BIT(ADCx->CHSELR, (Channel & ADC_CHANNEL_ID_BITFIELD_MASK));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Remove channel to ADC group regular sequence: channel on rank corresponding to
|
||||
* channel number.
|
||||
* @note This function performs:
|
||||
* - Channels ordering into each rank of scan sequence:
|
||||
* rank of each channel is fixed by channel HW number
|
||||
* (channel 0 fixed on rank 0, channel 1 fixed on rank1, ...).
|
||||
* - Set channels selected by removing them to the current sequencer
|
||||
* configuration.
|
||||
* @note On this PY32 serie, ADC group regular sequencer is
|
||||
* not fully configurable: sequencer length and each rank
|
||||
* affectation to a channel are fixed by channel HW number.
|
||||
* @note Depending on devices and packages, some channels may not be available.
|
||||
* Refer to device datasheet for channels availability.
|
||||
* @note On this PY32 serie, to measure internal channels (VrefInt,
|
||||
* TempSensor, ...), measurement paths to internal channels must be
|
||||
* enabled separately.
|
||||
* This can be done using function @ref LL_ADC_SetCommonPathInternalCh().
|
||||
* @note On this PY32 serie, setting of this feature is conditioned to
|
||||
* ADC state:
|
||||
* ADC must be disabled or enabled without conversion on going
|
||||
* on group regular.
|
||||
* @note One or several values can be selected.
|
||||
* Example: (LL_ADC_CHANNEL_4 | LL_ADC_CHANNEL_12 | ...)
|
||||
* @rmtoll CHSELR CHSEL0 LL_ADC_REG_SetSequencerChRem\n
|
||||
* CHSELR CHSEL1 LL_ADC_REG_SetSequencerChRem\n
|
||||
* CHSELR CHSEL2 LL_ADC_REG_SetSequencerChRem\n
|
||||
* CHSELR CHSEL3 LL_ADC_REG_SetSequencerChRem\n
|
||||
* CHSELR CHSEL4 LL_ADC_REG_SetSequencerChRem\n
|
||||
* CHSELR CHSEL5 LL_ADC_REG_SetSequencerChRem\n
|
||||
* CHSELR CHSEL6 LL_ADC_REG_SetSequencerChRem\n
|
||||
* CHSELR CHSEL7 LL_ADC_REG_SetSequencerChRem\n
|
||||
* CHSELR CHSEL8 LL_ADC_REG_SetSequencerChRem\n
|
||||
* CHSELR CHSEL9 LL_ADC_REG_SetSequencerChRem\n
|
||||
* CHSELR CHSEL11 LL_ADC_REG_SetSequencerChRem\n
|
||||
* CHSELR CHSEL12 LL_ADC_REG_SetSequencerChRem
|
||||
* @param ADCx ADC instance
|
||||
* @param Channel This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_ADC_CHANNEL_0
|
||||
* @arg @ref LL_ADC_CHANNEL_1
|
||||
* @arg @ref LL_ADC_CHANNEL_2
|
||||
* @arg @ref LL_ADC_CHANNEL_3
|
||||
* @arg @ref LL_ADC_CHANNEL_4
|
||||
* @arg @ref LL_ADC_CHANNEL_5
|
||||
* @arg @ref LL_ADC_CHANNEL_6
|
||||
* @arg @ref LL_ADC_CHANNEL_7
|
||||
* @arg @ref LL_ADC_CHANNEL_8
|
||||
* @arg @ref LL_ADC_CHANNEL_9
|
||||
* @arg @ref LL_ADC_CHANNEL_11
|
||||
* @arg @ref LL_ADC_CHANNEL_12
|
||||
* @arg @ref LL_ADC_CHANNEL_VREFINT
|
||||
* @arg @ref LL_ADC_CHANNEL_TEMPSENSOR
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_ADC_REG_SetSequencerChRem(ADC_TypeDef *ADCx, uint32_t Channel)
|
||||
{
|
||||
/* Parameter "Channel" is used with masks because containing */
|
||||
/* other bits reserved for other purpose. */
|
||||
CLEAR_BIT(ADCx->CHSELR, (Channel & ADC_CHANNEL_ID_BITFIELD_MASK));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get ADC group regular sequence: channel on rank corresponding to
|
||||
* channel number.
|
||||
* @note This function performs:
|
||||
* - Channels order reading into each rank of scan sequence:
|
||||
* rank of each channel is fixed by channel HW number
|
||||
* (channel 0 fixed on rank 0, channel 1 fixed on rank1, ...).
|
||||
* @note On this PY32 serie, ADC group regular sequencer is
|
||||
* not fully configurable: sequencer length and each rank
|
||||
* affectation to a channel are fixed by channel HW number.
|
||||
* @note Depending on devices and packages, some channels may not be available.
|
||||
* Refer to device datasheet for channels availability.
|
||||
* @note On this PY32 serie, to measure internal channels (VrefInt,
|
||||
* TempSensor, ...), measurement paths to internal channels must be
|
||||
* enabled separately.
|
||||
* This can be done using function @ref LL_ADC_SetCommonPathInternalCh().
|
||||
* @note On this PY32 serie, setting of this feature is conditioned to
|
||||
* ADC state:
|
||||
* ADC must be disabled or enabled without conversion on going
|
||||
* on group regular.
|
||||
* @note One or several values can be retrieved.
|
||||
* Example: (LL_ADC_CHANNEL_4 | LL_ADC_CHANNEL_12 | ...)
|
||||
* @rmtoll CHSELR CHSEL0 LL_ADC_REG_GetSequencerChannels\n
|
||||
* CHSELR CHSEL1 LL_ADC_REG_GetSequencerChannels\n
|
||||
* CHSELR CHSEL2 LL_ADC_REG_GetSequencerChannels\n
|
||||
* CHSELR CHSEL3 LL_ADC_REG_GetSequencerChannels\n
|
||||
* CHSELR CHSEL4 LL_ADC_REG_GetSequencerChannels\n
|
||||
* CHSELR CHSEL5 LL_ADC_REG_GetSequencerChannels\n
|
||||
* CHSELR CHSEL6 LL_ADC_REG_GetSequencerChannels\n
|
||||
* CHSELR CHSEL7 LL_ADC_REG_GetSequencerChannels\n
|
||||
* CHSELR CHSEL8 LL_ADC_REG_GetSequencerChannels\n
|
||||
* CHSELR CHSEL9 LL_ADC_REG_GetSequencerChannels\n
|
||||
* CHSELR CHSEL11 LL_ADC_REG_GetSequencerChannels\n
|
||||
* CHSELR CHSEL12 LL_ADC_REG_GetSequencerChannels
|
||||
* @param ADCx ADC instance
|
||||
* @retval Returned value can be a combination of the following values:
|
||||
* @arg @ref LL_ADC_CHANNEL_0
|
||||
* @arg @ref LL_ADC_CHANNEL_1
|
||||
* @arg @ref LL_ADC_CHANNEL_2
|
||||
* @arg @ref LL_ADC_CHANNEL_3
|
||||
* @arg @ref LL_ADC_CHANNEL_4
|
||||
* @arg @ref LL_ADC_CHANNEL_5
|
||||
* @arg @ref LL_ADC_CHANNEL_6
|
||||
* @arg @ref LL_ADC_CHANNEL_7
|
||||
* @arg @ref LL_ADC_CHANNEL_8
|
||||
* @arg @ref LL_ADC_CHANNEL_9
|
||||
* @arg @ref LL_ADC_CHANNEL_10
|
||||
* @arg @ref LL_ADC_CHANNEL_11
|
||||
* @arg @ref LL_ADC_CHANNEL_12
|
||||
* @arg @ref LL_ADC_CHANNEL_VREFINT
|
||||
* @arg @ref LL_ADC_CHANNEL_TEMPSENSOR
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerChannels(ADC_TypeDef *ADCx)
|
||||
{
|
||||
register uint32_t ChannelsBitfield = READ_BIT(ADCx->CHSELR, ADC_CHSELR_CHSEL);
|
||||
|
||||
return ( (((ChannelsBitfield & ADC_CHSELR_CHSEL0) >> ADC_CHSELR_CHSEL0_BITOFFSET_POS) * LL_ADC_CHANNEL_0)
|
||||
| (((ChannelsBitfield & ADC_CHSELR_CHSEL1) >> ADC_CHSELR_CHSEL1_BITOFFSET_POS) * LL_ADC_CHANNEL_1)
|
||||
| (((ChannelsBitfield & ADC_CHSELR_CHSEL2) >> ADC_CHSELR_CHSEL2_BITOFFSET_POS) * LL_ADC_CHANNEL_2)
|
||||
| (((ChannelsBitfield & ADC_CHSELR_CHSEL3) >> ADC_CHSELR_CHSEL3_BITOFFSET_POS) * LL_ADC_CHANNEL_3)
|
||||
| (((ChannelsBitfield & ADC_CHSELR_CHSEL4) >> ADC_CHSELR_CHSEL4_BITOFFSET_POS) * LL_ADC_CHANNEL_4)
|
||||
| (((ChannelsBitfield & ADC_CHSELR_CHSEL5) >> ADC_CHSELR_CHSEL5_BITOFFSET_POS) * LL_ADC_CHANNEL_5)
|
||||
| (((ChannelsBitfield & ADC_CHSELR_CHSEL6) >> ADC_CHSELR_CHSEL6_BITOFFSET_POS) * LL_ADC_CHANNEL_6)
|
||||
| (((ChannelsBitfield & ADC_CHSELR_CHSEL7) >> ADC_CHSELR_CHSEL7_BITOFFSET_POS) * LL_ADC_CHANNEL_7)
|
||||
| (((ChannelsBitfield & ADC_CHSELR_CHSEL8) >> ADC_CHSELR_CHSEL8_BITOFFSET_POS) * LL_ADC_CHANNEL_8)
|
||||
| (((ChannelsBitfield & ADC_CHSELR_CHSEL9) >> ADC_CHSELR_CHSEL9_BITOFFSET_POS) * LL_ADC_CHANNEL_9)
|
||||
| (((ChannelsBitfield & ADC_CHSELR_CHSEL11) >> ADC_CHSELR_CHSEL11_BITOFFSET_POS) * LL_ADC_CHANNEL_11)
|
||||
| (((ChannelsBitfield & ADC_CHSELR_CHSEL12) >> ADC_CHSELR_CHSEL12_BITOFFSET_POS) * LL_ADC_CHANNEL_12)
|
||||
);
|
||||
|
||||
}
|
||||
/**
|
||||
* @brief Set ADC continuous conversion mode on ADC group regular.
|
||||
* @note Description of ADC continuous conversion mode:
|
||||
* - single mode: one conversion per trigger
|
||||
* - continuous mode: after the first trigger, following
|
||||
* conversions launched successively automatically.
|
||||
* @note It is not possible to enable both ADC group regular
|
||||
* continuous mode and sequencer discontinuous mode.
|
||||
* @note On this PY32 serie, setting of this feature is conditioned to
|
||||
* ADC state:
|
||||
* ADC must be disabled or enabled without conversion on going
|
||||
* on group regular.
|
||||
* @rmtoll CFGR1 CONT LL_ADC_REG_SetContinuousMode
|
||||
* @param ADCx ADC instance
|
||||
* @param Continuous This parameter can be one of the following values:
|
||||
* @arg @ref LL_ADC_REG_CONV_SINGLE
|
||||
* @arg @ref LL_ADC_REG_CONV_CONTINUOUS
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_ADC_REG_SetContinuousMode(ADC_TypeDef *ADCx, uint32_t Continuous)
|
||||
{
|
||||
MODIFY_REG(ADCx->CFGR1, ADC_CFGR1_CONT, Continuous);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get ADC continuous conversion mode on ADC group regular.
|
||||
* @note Description of ADC continuous conversion mode:
|
||||
* - single mode: one conversion per trigger
|
||||
* - continuous mode: after the first trigger, following
|
||||
* conversions launched successively automatically.
|
||||
* @rmtoll CFGR1 CONT LL_ADC_REG_GetContinuousMode
|
||||
* @param ADCx ADC instance
|
||||
* @retval Returned value can be one of the following values:
|
||||
* @arg @ref LL_ADC_REG_CONV_SINGLE
|
||||
* @arg @ref LL_ADC_REG_CONV_CONTINUOUS
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_ADC_REG_GetContinuousMode(ADC_TypeDef *ADCx)
|
||||
{
|
||||
return (uint32_t)(READ_BIT(ADCx->CFGR1, ADC_CFGR1_CONT));
|
||||
}
|
||||
|
||||
#if (defined(DMA) || defined(DMA1))
|
||||
/**
|
||||
* @brief Set ADC group regular conversion data transfer: no transfer or
|
||||
* transfer by DMA, and DMA requests mode.
|
||||
* @note If transfer by DMA selected, specifies the DMA requests
|
||||
* mode:
|
||||
* - Limited mode (One shot mode): DMA transfer requests are stopped
|
||||
* when number of DMA data transfers (number of
|
||||
* ADC conversions) is reached.
|
||||
* This ADC mode is intended to be used with DMA mode non-circular.
|
||||
* - Unlimited mode: DMA transfer requests are unlimited,
|
||||
* whatever number of DMA data transfers (number of
|
||||
* ADC conversions).
|
||||
* This ADC mode is intended to be used with DMA mode circular.
|
||||
* @note If ADC DMA requests mode is set to unlimited and DMA is set to
|
||||
* mode non-circular:
|
||||
* when DMA transfers size will be reached, DMA will stop transfers of
|
||||
* ADC conversions data ADC will raise an overrun error
|
||||
* (overrun flag and interruption if enabled).
|
||||
* @note To configure DMA source address (peripheral address),
|
||||
* use function @ref LL_ADC_DMA_GetRegAddr().
|
||||
* @note On this PY32 serie, setting of this feature is conditioned to
|
||||
* ADC state:
|
||||
* ADC must be disabled or enabled without conversion on going
|
||||
* on group regular.
|
||||
* @note Depending on devices and packages, DMA may not be available.
|
||||
* Refer to device datasheet for DMA availability.
|
||||
* @rmtoll CFGR1 DMAEN LL_ADC_REG_SetDMATransfer\n
|
||||
* CFGR1 DMACFG LL_ADC_REG_SetDMATransfer
|
||||
* @param ADCx ADC instance
|
||||
* @param DMATransfer This parameter can be one of the following values:
|
||||
* @arg @ref LL_ADC_REG_DMA_TRANSFER_NONE
|
||||
* @arg @ref LL_ADC_REG_DMA_TRANSFER_LIMITED
|
||||
* @arg @ref LL_ADC_REG_DMA_TRANSFER_UNLIMITED
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_ADC_REG_SetDMATransfer(ADC_TypeDef *ADCx, uint32_t DMATransfer)
|
||||
{
|
||||
MODIFY_REG(ADCx->CFGR1, ADC_CFGR1_DMAEN | ADC_CFGR1_DMACFG, DMATransfer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get ADC group regular conversion data transfer: no transfer or
|
||||
* transfer by DMA, and DMA requests mode.
|
||||
* @note If transfer by DMA selected, specifies the DMA requests
|
||||
* mode:
|
||||
* - Limited mode (One shot mode): DMA transfer requests are stopped
|
||||
* when number of DMA data transfers (number of
|
||||
* ADC conversions) is reached.
|
||||
* This ADC mode is intended to be used with DMA mode non-circular.
|
||||
* - Unlimited mode: DMA transfer requests are unlimited,
|
||||
* whatever number of DMA data transfers (number of
|
||||
* ADC conversions).
|
||||
* This ADC mode is intended to be used with DMA mode circular.
|
||||
* @note If ADC DMA requests mode is set to unlimited and DMA is set to
|
||||
* mode non-circular:
|
||||
* when DMA transfers size will be reached, DMA will stop transfers of
|
||||
* ADC conversions data ADC will raise an overrun error
|
||||
* (overrun flag and interruption if enabled).
|
||||
* @note To configure DMA source address (peripheral address),
|
||||
* use function @ref LL_ADC_DMA_GetRegAddr().
|
||||
* @note Depending on devices and packages, DMA may not be available.
|
||||
* Refer to device datasheet for DMA availability.
|
||||
* @rmtoll CFGR1 DMAEN LL_ADC_REG_GetDMATransfer\n
|
||||
* CFGR1 DMACFG LL_ADC_REG_GetDMATransfer
|
||||
* @param ADCx ADC instance
|
||||
* @retval Returned value can be one of the following values:
|
||||
* @arg @ref LL_ADC_REG_DMA_TRANSFER_NONE
|
||||
* @arg @ref LL_ADC_REG_DMA_TRANSFER_LIMITED
|
||||
* @arg @ref LL_ADC_REG_DMA_TRANSFER_UNLIMITED
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_ADC_REG_GetDMATransfer(ADC_TypeDef *ADCx)
|
||||
{
|
||||
return (uint32_t)(READ_BIT(ADCx->CFGR1, ADC_CFGR1_DMAEN | ADC_CFGR1_DMACFG));
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Set ADC group regular behavior in case of overrun:
|
||||
* data preserved or overwritten.
|
||||
* @note Compatibility with devices without feature overrun:
|
||||
* other devices without this feature have a behavior
|
||||
* equivalent to data overwritten.
|
||||
* The default setting of overrun is data preserved.
|
||||
* Therefore, for compatibility with all devices, parameter
|
||||
* overrun should be set to data overwritten.
|
||||
* @note On this PY32 serie, setting of this feature is conditioned to
|
||||
* ADC state:
|
||||
* ADC must be disabled or enabled without conversion on going
|
||||
* on group regular.
|
||||
* @rmtoll CFGR1 OVRMOD LL_ADC_REG_SetOverrun
|
||||
* @param ADCx ADC instance
|
||||
* @param Overrun This parameter can be one of the following values:
|
||||
* @arg @ref LL_ADC_REG_OVR_DATA_PRESERVED
|
||||
* @arg @ref LL_ADC_REG_OVR_DATA_OVERWRITTEN
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_ADC_REG_SetOverrun(ADC_TypeDef *ADCx, uint32_t Overrun)
|
||||
{
|
||||
MODIFY_REG(ADCx->CFGR1, ADC_CFGR1_OVRMOD, Overrun);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get ADC group regular behavior in case of overrun:
|
||||
* data preserved or overwritten.
|
||||
* @rmtoll CFGR1 OVRMOD LL_ADC_REG_GetOverrun
|
||||
* @param ADCx ADC instance
|
||||
* @retval Returned value can be one of the following values:
|
||||
* @arg @ref LL_ADC_REG_OVR_DATA_PRESERVED
|
||||
* @arg @ref LL_ADC_REG_OVR_DATA_OVERWRITTEN
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_ADC_REG_GetOverrun(ADC_TypeDef *ADCx)
|
||||
{
|
||||
return (uint32_t)(READ_BIT(ADCx->CFGR1, ADC_CFGR1_OVRMOD));
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_LL_EF_Configuration_ADC_AnalogWatchdog Configuration of ADC transversal scope: analog watchdog
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Set ADC analog watchdog monitored channels:
|
||||
* a single channel or all channels,
|
||||
* on ADC group regular.
|
||||
* @note Once monitored channels are selected, analog watchdog
|
||||
* is enabled.
|
||||
* @note In case of need to define a single channel to monitor
|
||||
* with analog watchdog from sequencer channel definition,
|
||||
* use helper macro @ref __LL_ADC_ANALOGWD_CHANNEL_GROUP().
|
||||
* @note On this PY32 serie, there is only 1 kind of analog watchdog
|
||||
* instance:
|
||||
* - AWD standard (instance AWD):
|
||||
* - channels monitored: can monitor 1 channel or all channels.
|
||||
* - groups monitored: ADC group regular.
|
||||
* - resolution: resolution is not limited (corresponds to
|
||||
* ADC resolution configured).
|
||||
* @note On this PY32 serie, setting of this feature is conditioned to
|
||||
* ADC state:
|
||||
* ADC must be disabled or enabled without conversion on going
|
||||
* on group regular.
|
||||
* @note Depending on devices and packages, some channels may not be available.
|
||||
* Refer to device datasheet for channels availability.
|
||||
* @rmtoll CFGR1 AWDCH LL_ADC_SetAnalogWDMonitChannels\n
|
||||
* CFGR1 AWDSGL LL_ADC_SetAnalogWDMonitChannels\n
|
||||
* CFGR1 AWDEN LL_ADC_SetAnalogWDMonitChannels
|
||||
* @param ADCx ADC instance
|
||||
* @param AWDChannelGroup This parameter can be one of the following values:
|
||||
* @arg @ref LL_ADC_AWD_DISABLE
|
||||
* @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG
|
||||
* @arg @ref LL_ADC_AWD_CHANNEL_0_REG
|
||||
* @arg @ref LL_ADC_AWD_CHANNEL_1_REG
|
||||
* @arg @ref LL_ADC_AWD_CHANNEL_2_REG
|
||||
* @arg @ref LL_ADC_AWD_CHANNEL_3_REG
|
||||
* @arg @ref LL_ADC_AWD_CHANNEL_4_REG
|
||||
* @arg @ref LL_ADC_AWD_CHANNEL_5_REG
|
||||
* @arg @ref LL_ADC_AWD_CHANNEL_6_REG
|
||||
* @arg @ref LL_ADC_AWD_CHANNEL_7_REG
|
||||
* @arg @ref LL_ADC_AWD_CHANNEL_8_REG
|
||||
* @arg @ref LL_ADC_AWD_CHANNEL_9_REG
|
||||
* @arg @ref LL_ADC_AWD_CHANNEL_11_REG
|
||||
* @arg @ref LL_ADC_AWD_CHANNEL_12_REG
|
||||
* @arg @ref LL_ADC_AWD_CH_VREFINT_REG
|
||||
* @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_ADC_SetAnalogWDMonitChannels(ADC_TypeDef *ADCx, uint32_t AWDChannelGroup)
|
||||
{
|
||||
MODIFY_REG(ADCx->CFGR1,
|
||||
(ADC_CFGR1_AWDCH | ADC_CFGR1_AWDSGL | ADC_CFGR1_AWDEN),
|
||||
(AWDChannelGroup & ADC_AWD_CR_ALL_CHANNEL_MASK));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get ADC analog watchdog monitored channel.
|
||||
* @note Usage of the returned channel number:
|
||||
* - To reinject this channel into another function LL_ADC_xxx:
|
||||
* the returned channel number is only partly formatted on definition
|
||||
* of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared
|
||||
* with parts of literals LL_ADC_CHANNEL_x or using
|
||||
* helper macro @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
|
||||
* Then the selected literal LL_ADC_CHANNEL_x can be used
|
||||
* as parameter for another function.
|
||||
* - To get the channel number in decimal format:
|
||||
* process the returned value with the helper macro
|
||||
* @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
|
||||
* Applicable only when the analog watchdog is set to monitor
|
||||
* one channel.
|
||||
* @note On this PY32 serie, there is only 1 kind of analog watchdog
|
||||
* instance:
|
||||
* - AWD standard (instance AWD):
|
||||
* - channels monitored: can monitor 1 channel or all channels.
|
||||
* - groups monitored: ADC group regular.
|
||||
* - resolution: resolution is not limited (corresponds to
|
||||
* ADC resolution configured).
|
||||
* @note On this PY32 serie, setting of this feature is conditioned to
|
||||
* ADC state:
|
||||
* ADC must be disabled or enabled without conversion on going
|
||||
* on group regular.
|
||||
* @note Depending on devices and packages, some channels may not be available.
|
||||
* Refer to device datasheet for channels availability.
|
||||
* @rmtoll CFGR1 AWDCH LL_ADC_GetAnalogWDMonitChannels\n
|
||||
* CFGR1 AWDSGL LL_ADC_GetAnalogWDMonitChannels\n
|
||||
* CFGR1 AWDEN LL_ADC_GetAnalogWDMonitChannels
|
||||
* @param ADCx ADC instance
|
||||
* @retval Returned value can be one of the following values:
|
||||
* @arg @ref LL_ADC_AWD_DISABLE
|
||||
* @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG
|
||||
* @arg @ref LL_ADC_AWD_CHANNEL_0_REG
|
||||
* @arg @ref LL_ADC_AWD_CHANNEL_1_REG
|
||||
* @arg @ref LL_ADC_AWD_CHANNEL_2_REG
|
||||
* @arg @ref LL_ADC_AWD_CHANNEL_3_REG
|
||||
* @arg @ref LL_ADC_AWD_CHANNEL_4_REG
|
||||
* @arg @ref LL_ADC_AWD_CHANNEL_5_REG
|
||||
* @arg @ref LL_ADC_AWD_CHANNEL_6_REG
|
||||
* @arg @ref LL_ADC_AWD_CHANNEL_7_REG
|
||||
* @arg @ref LL_ADC_AWD_CHANNEL_8_REG
|
||||
* @arg @ref LL_ADC_AWD_CHANNEL_9_REG
|
||||
* @arg @ref LL_ADC_AWD_CHANNEL_11_REG
|
||||
* @arg @ref LL_ADC_AWD_CHANNEL_12_REG
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_ADC_GetAnalogWDMonitChannels(ADC_TypeDef *ADCx)
|
||||
{
|
||||
register uint32_t AWDChannelGroup = READ_BIT(ADCx->CFGR1, (ADC_CFGR1_AWDCH | ADC_CFGR1_AWDSGL | ADC_CFGR1_AWDEN));
|
||||
|
||||
/* Note: Set variable according to channel definition including channel ID */
|
||||
/* with bitfield. */
|
||||
register uint32_t AWDChannelSingle = ((AWDChannelGroup & ADC_CFGR1_AWDSGL) >> ADC_CFGR1_AWDSGL_BITOFFSET_POS);
|
||||
register uint32_t AWDChannelBitField = (ADC_CHANNEL_0_BITFIELD << ((AWDChannelGroup & ADC_CHANNEL_ID_NUMBER_MASK) >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS));
|
||||
|
||||
return (AWDChannelGroup | (AWDChannelBitField * AWDChannelSingle));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set ADC analog watchdog thresholds value of both thresholds
|
||||
* high and low.
|
||||
* @note If value of only one threshold high or low must be set,
|
||||
* use function @ref LL_ADC_SetAnalogWDThresholds().
|
||||
* @note In case of ADC resolution different of 12 bits,
|
||||
* analog watchdog thresholds data require a specific shift.
|
||||
* Use helper macro @ref __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION().
|
||||
* @note On this PY32 serie, there is only 1 kind of analog watchdog
|
||||
* instance:
|
||||
* - AWD standard (instance AWD):
|
||||
* - channels monitored: can monitor 1 channel or all channels.
|
||||
* - groups monitored: ADC group regular.
|
||||
* - resolution: resolution is not limited (corresponds to
|
||||
* ADC resolution configured).
|
||||
* @note On this PY32 serie, setting of this feature is conditioned to
|
||||
* ADC state:
|
||||
* ADC must be disabled or enabled without conversion on going
|
||||
* on group regular.
|
||||
* @rmtoll TR HT LL_ADC_ConfigAnalogWDThresholds\n
|
||||
* TR LT LL_ADC_ConfigAnalogWDThresholds
|
||||
* @param ADCx ADC instance
|
||||
* @param AWDThresholdHighValue Value between Min_Data=0x000 and Max_Data=0xFFF
|
||||
* @param AWDThresholdLowValue Value between Min_Data=0x000 and Max_Data=0xFFF
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_ADC_ConfigAnalogWDThresholds(ADC_TypeDef *ADCx, uint32_t AWDThresholdHighValue, uint32_t AWDThresholdLowValue)
|
||||
{
|
||||
MODIFY_REG(ADCx->TR,ADC_TR_HT | ADC_TR_LT,(AWDThresholdHighValue << ADC_TR_HT_BITOFFSET_POS) | AWDThresholdLowValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set ADC analog watchdog threshold value of threshold
|
||||
* high or low.
|
||||
* @note If values of both thresholds high or low must be set,
|
||||
* use function @ref LL_ADC_ConfigAnalogWDThresholds().
|
||||
* @note In case of ADC resolution different of 12 bits,
|
||||
* analog watchdog thresholds data require a specific shift.
|
||||
* Use helper macro @ref __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION().
|
||||
* @note On this PY32 serie, there is only 1 kind of analog watchdog
|
||||
* instance:
|
||||
* - AWD standard (instance AWD):
|
||||
* - channels monitored: can monitor 1 channel or all channels.
|
||||
* - groups monitored: ADC group regular.
|
||||
* - resolution: resolution is not limited (corresponds to
|
||||
* ADC resolution configured).
|
||||
* @note On this PY32 serie, setting of this feature is conditioned to
|
||||
* ADC state:
|
||||
* ADC must be disabled or enabled without conversion on going
|
||||
* on group regular.
|
||||
* @rmtoll TR HT LL_ADC_SetAnalogWDThresholds\n
|
||||
* TR LT LL_ADC_SetAnalogWDThresholds
|
||||
* @param ADCx ADC instance
|
||||
* @param AWDThresholdsHighLow This parameter can be one of the following values:
|
||||
* @arg @ref LL_ADC_AWD_THRESHOLD_HIGH
|
||||
* @arg @ref LL_ADC_AWD_THRESHOLD_LOW
|
||||
* @param AWDThresholdValue Value between Min_Data=0x000 and Max_Data=0xFFF
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_ADC_SetAnalogWDThresholds(ADC_TypeDef *ADCx, uint32_t AWDThresholdsHighLow, uint32_t AWDThresholdValue)
|
||||
{
|
||||
/* Parameter "AWDThresholdsHighLow" is used with mask "0x00000010" */
|
||||
/* to be equivalent to "POSITION_VAL(AWDThresholdsHighLow)": if threshold */
|
||||
/* high is selected, then data is shifted to LSB. Else(threshold low), */
|
||||
/* data is not shifted. */
|
||||
MODIFY_REG(ADCx->TR, AWDThresholdsHighLow,AWDThresholdValue << ((AWDThresholdsHighLow >> ADC_TR_HT_BITOFFSET_POS) & 0x00000010U));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get ADC analog watchdog threshold value of threshold high,
|
||||
* threshold low or raw data with ADC thresholds high and low
|
||||
* concatenated.
|
||||
* @note If raw data with ADC thresholds high and low is retrieved,
|
||||
* the data of each threshold high or low can be isolated
|
||||
* using helper macro:
|
||||
* @ref __LL_ADC_ANALOGWD_THRESHOLDS_HIGH_LOW().
|
||||
* @note In case of ADC resolution different of 12 bits,
|
||||
* analog watchdog thresholds data require a specific shift.
|
||||
* Use helper macro @ref __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION().
|
||||
* @rmtoll TR HT LL_ADC_GetAnalogWDThresholds\n
|
||||
* TR LT LL_ADC_GetAnalogWDThresholds
|
||||
* @param ADCx ADC instance
|
||||
* @param AWDThresholdsHighLow This parameter can be one of the following values:
|
||||
* @arg @ref LL_ADC_AWD_THRESHOLD_HIGH
|
||||
* @arg @ref LL_ADC_AWD_THRESHOLD_LOW
|
||||
* @arg @ref LL_ADC_AWD_THRESHOLDS_HIGH_LOW
|
||||
* @retval Value between Min_Data=0x000 and Max_Data=0xFFF
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_ADC_GetAnalogWDThresholds(ADC_TypeDef *ADCx, uint32_t AWDThresholdsHighLow)
|
||||
{
|
||||
/* Parameter "AWDThresholdsHighLow" is used with mask "0x00000010" */
|
||||
/* to be equivalent to "POSITION_VAL(AWDThresholdsHighLow)": if threshold */
|
||||
/* high is selected, then data is shifted to LSB. Else(threshold low or */
|
||||
/* both thresholds), data is not shifted. */
|
||||
return (uint32_t)(READ_BIT(ADCx->TR,(AWDThresholdsHighLow | ADC_TR_LT))>> ((~AWDThresholdsHighLow) & 0x00000010U));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Start ADC calibration in the mode single-ended
|
||||
* or differential (for devices with differential mode available).
|
||||
* @note On this PY32 serie, a minimum number of ADC clock cycles
|
||||
* are required between ADC end of calibration and ADC enable.
|
||||
* Refer to literal @ref LL_ADC_DELAY_CALIB_ENABLE_ADC_CYCLES.
|
||||
* @note In case of usage of ADC with DMA transfer:
|
||||
* On this PY32 serie, ADC DMA transfer request should be disabled
|
||||
* during calibration:
|
||||
* Calibration factor is available in data register
|
||||
* and also transfered by DMA.
|
||||
* To not insert ADC calibration factor among ADC conversion data
|
||||
* in array variable, DMA transfer must be disabled during
|
||||
* calibration.
|
||||
* (DMA transfer setting backup and disable before calibration,
|
||||
* DMA transfer setting restore after calibration.
|
||||
* Refer to functions @ref LL_ADC_REG_GetDMATransfer(),
|
||||
* @ref LL_ADC_REG_SetDMATransfer() ).
|
||||
* @note On this PY32 serie, setting of this feature is conditioned to
|
||||
* ADC state:
|
||||
* ADC must be ADC disabled.
|
||||
* @note Depending on devices and packages, DMA may not be available.
|
||||
* Refer to device datasheet for DMA availability.
|
||||
* @rmtoll CR ADCAL LL_ADC_StartCalibration
|
||||
* @param ADCx ADC instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_ADC_StartCalibration(ADC_TypeDef *ADCx)
|
||||
{
|
||||
/* Note: Write register with some additional bits forced to state reset */
|
||||
/* instead of modifying only the selected bit for this function, */
|
||||
/* to not interfere with bits with HW property "rs". */
|
||||
MODIFY_REG(ADCx->CR,ADC_CR_BITS_PROPERTY_RS,ADC_CR_ADCAL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get ADC calibration state.
|
||||
* @rmtoll CR ADCAL LL_ADC_IsCalibrationOnGoing
|
||||
* @param ADCx ADC instance
|
||||
* @retval 0: calibration complete, 1: calibration in progress.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_ADC_IsCalibrationOnGoing(ADC_TypeDef *ADCx)
|
||||
{
|
||||
return (READ_BIT(ADCx->CR, ADC_CR_ADCAL) == (ADC_CR_ADCAL));
|
||||
}
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_LL_EF_Operation_ADC_Instance Operation on ADC hierarchical scope: ADC instance
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Enable the selected ADC instance.
|
||||
* @note On this PY32 serie, after ADC enable, a delay for
|
||||
* ADC internal analog stabilization is required before performing a
|
||||
* ADC conversion start.
|
||||
* Refer to device datasheet, parameter tSTAB.
|
||||
* @note On this PY32 serie, setting of this feature is conditioned to
|
||||
* ADC state:
|
||||
* ADC must be ADC disabled and ADC internal voltage regulator enabled.
|
||||
* @rmtoll CR ADEN LL_ADC_Enable
|
||||
* @param ADCx ADC instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_ADC_Enable(ADC_TypeDef *ADCx)
|
||||
{
|
||||
/* Note: Write register with some additional bits forced to state reset */
|
||||
/* instead of modifying only the selected bit for this function, */
|
||||
/* to not interfere with bits with HW property "rs". */
|
||||
MODIFY_REG(ADCx->CR,ADC_CR_BITS_PROPERTY_RS,ADC_CR_ADEN);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reset the selected ADC instance.
|
||||
* @note On this PY32 serie, Reset the ADC
|
||||
* @param ADCx ADC instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_ADC_Reset(ADC_TypeDef *ADCx)
|
||||
{
|
||||
/* Note: Write register with some additional bits forced to state reset */
|
||||
/* instead of modifying only the selected bit for this function */
|
||||
|
||||
/* Force reset of ADC clock (core clock) */
|
||||
LL_APB1_GRP2_ForceReset(LL_APB1_GRP2_PERIPH_ADC1);
|
||||
|
||||
/* Release reset of ADC clock (core clock) */
|
||||
LL_APB1_GRP2_ReleaseReset(LL_APB1_GRP2_PERIPH_ADC1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the selected ADC instance enable state.
|
||||
* (not only core clock: this ADC has a dual clock domain)
|
||||
* @rmtoll CR ADEN LL_ADC_IsEnabled
|
||||
* @param ADCx ADC instance
|
||||
* @retval 0: ADC is disabled, 1: ADC is enabled.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_ADC_IsEnabled(ADC_TypeDef *ADCx)
|
||||
{
|
||||
return (READ_BIT(ADCx->CR, ADC_CR_ADEN) == (ADC_CR_ADEN));
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_LL_EF_Operation_ADC_Group_Regular Operation on ADC hierarchical scope: group regular
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Start ADC group regular conversion.
|
||||
* @note On this PY32 serie, this function is relevant for both
|
||||
* internal trigger (SW start) and external trigger:
|
||||
* - If ADC trigger has been set to software start, ADC conversion
|
||||
* starts immediately.
|
||||
* - If ADC trigger has been set to external trigger, ADC conversion
|
||||
* will start at next trigger event (on the selected trigger edge)
|
||||
* following the ADC start conversion command.
|
||||
* @note On this PY32 serie, setting of this feature is conditioned to
|
||||
* ADC state:
|
||||
* ADC must be enabled without conversion on going on group regular,
|
||||
* without conversion stop command on going on group regular,
|
||||
* without ADC disable command on going.
|
||||
* @rmtoll CR ADSTART LL_ADC_REG_StartConversion
|
||||
* @param ADCx ADC instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_ADC_REG_StartConversion(ADC_TypeDef *ADCx)
|
||||
{
|
||||
/* Note: Write register with some additional bits forced to state reset */
|
||||
/* instead of modifying only the selected bit for this function, */
|
||||
/* to not interfere with bits with HW property "rs". */
|
||||
MODIFY_REG(ADCx->CR, ADC_CR_BITS_PROPERTY_RS,ADC_CR_ADSTART);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Stop ADC group regular conversion.
|
||||
* @note On this PY32 serie, setting of this feature is conditioned to
|
||||
* ADC state:
|
||||
* ADC must be enabled with conversion on going on group regular,
|
||||
* without ADC disable command on going.
|
||||
* @rmtoll CR ADSTP LL_ADC_REG_StopConversion
|
||||
* @param ADCx ADC instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_ADC_REG_StopConversion(ADC_TypeDef *ADCx)
|
||||
{
|
||||
/* Note: Write register with some additional bits forced to state reset */
|
||||
/* instead of modifying only the selected bit for this function, */
|
||||
/* to not interfere with bits with HW property "rs". */
|
||||
MODIFY_REG(ADCx->CR,ADC_CR_BITS_PROPERTY_RS,ADC_CR_ADSTP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get ADC group regular conversion state.
|
||||
* @rmtoll CR ADSTART LL_ADC_REG_IsConversionOngoing
|
||||
* @param ADCx ADC instance
|
||||
* @retval 0: no conversion is on going on ADC group regular.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_ADC_REG_IsConversionOngoing(ADC_TypeDef *ADCx)
|
||||
{
|
||||
return (READ_BIT(ADCx->CR, ADC_CR_ADSTART) == (ADC_CR_ADSTART));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get ADC group regular command of conversion stop state
|
||||
* @rmtoll CR ADSTP LL_ADC_REG_IsStopConversionOngoing
|
||||
* @param ADCx ADC instance
|
||||
* @retval 0: no command of conversion stop is on going on ADC group regular.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_ADC_REG_IsStopConversionOngoing(ADC_TypeDef *ADCx)
|
||||
{
|
||||
return (READ_BIT(ADCx->CR, ADC_CR_ADSTP) == (ADC_CR_ADSTP));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get ADC group regular conversion data, range fit for
|
||||
* all ADC configurations: all ADC resolutions and
|
||||
* all oversampling increased data width (for devices
|
||||
* with feature oversampling).
|
||||
* @rmtoll DR DATA LL_ADC_REG_ReadConversionData32
|
||||
* @param ADCx ADC instance
|
||||
* @retval Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_ADC_REG_ReadConversionData32(ADC_TypeDef *ADCx)
|
||||
{
|
||||
return (uint32_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get ADC group regular conversion data, range fit for
|
||||
* ADC resolution 12 bits.
|
||||
* @note For devices with feature oversampling: Oversampling
|
||||
* can increase data width, function for extended range
|
||||
* may be needed: @ref LL_ADC_REG_ReadConversionData32.
|
||||
* @rmtoll DR DATA LL_ADC_REG_ReadConversionData12
|
||||
* @param ADCx ADC instance
|
||||
* @retval Value between Min_Data=0x000 and Max_Data=0xFFF
|
||||
*/
|
||||
__STATIC_INLINE uint16_t LL_ADC_REG_ReadConversionData12(ADC_TypeDef *ADCx)
|
||||
{
|
||||
return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get ADC group regular conversion data, range fit for
|
||||
* ADC resolution 10 bits.
|
||||
* @note For devices with feature oversampling: Oversampling
|
||||
* can increase data width, function for extended range
|
||||
* may be needed: @ref LL_ADC_REG_ReadConversionData32.
|
||||
* @rmtoll DR DATA LL_ADC_REG_ReadConversionData10
|
||||
* @param ADCx ADC instance
|
||||
* @retval Value between Min_Data=0x000 and Max_Data=0x3FF
|
||||
*/
|
||||
__STATIC_INLINE uint16_t LL_ADC_REG_ReadConversionData10(ADC_TypeDef *ADCx)
|
||||
{
|
||||
return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get ADC group regular conversion data, range fit for
|
||||
* ADC resolution 8 bits.
|
||||
* @note For devices with feature oversampling: Oversampling
|
||||
* can increase data width, function for extended range
|
||||
* may be needed: @ref LL_ADC_REG_ReadConversionData32.
|
||||
* @rmtoll DR DATA LL_ADC_REG_ReadConversionData8
|
||||
* @param ADCx ADC instance
|
||||
* @retval Value between Min_Data=0x00 and Max_Data=0xFF
|
||||
*/
|
||||
__STATIC_INLINE uint8_t LL_ADC_REG_ReadConversionData8(ADC_TypeDef *ADCx)
|
||||
{
|
||||
return (uint8_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get ADC group regular conversion data, range fit for
|
||||
* ADC resolution 6 bits.
|
||||
* @note For devices with feature oversampling: Oversampling
|
||||
* can increase data width, function for extended range
|
||||
* may be needed: @ref LL_ADC_REG_ReadConversionData32.
|
||||
* @rmtoll DR DATA LL_ADC_REG_ReadConversionData6
|
||||
* @param ADCx ADC instance
|
||||
* @retval Value between Min_Data=0x00 and Max_Data=0x3F
|
||||
*/
|
||||
__STATIC_INLINE uint8_t LL_ADC_REG_ReadConversionData6(ADC_TypeDef *ADCx)
|
||||
{
|
||||
return (uint8_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable the selected ADC instance.
|
||||
* @note On this PY32 serie, Disable the selected ADC instance
|
||||
* @param ADCx ADC instance
|
||||
* @retval 0: ADC Disable Failed,1:ADC Disable Success.
|
||||
*/
|
||||
__STATIC_INLINE ErrorStatus LL_ADC_Disable(ADC_TypeDef *ADCx)
|
||||
{
|
||||
ErrorStatus status = SUCCESS;
|
||||
uint32_t tmpCFGR1=ADCx->CFGR1;
|
||||
__IO uint32_t timeout_cpu_cycles = 0U;
|
||||
|
||||
/* Check the parameters */
|
||||
/* Disable ADC instance if not already disabled. */
|
||||
if(LL_ADC_IsEnabled(ADCx) == 1U)
|
||||
{
|
||||
/* Set ADC group regular trigger source to SW start to ensure to not */
|
||||
/* have an external trigger event occurring during the conversion stop */
|
||||
/* ADC disable process. */
|
||||
LL_ADC_REG_SetTriggerSource(ADCx, LL_ADC_REG_TRIG_SOFTWARE);
|
||||
|
||||
/* Stop potential ADC conversion on going on ADC group regular. */
|
||||
if(LL_ADC_REG_IsConversionOngoing(ADCx) != 0U)
|
||||
{
|
||||
if(LL_ADC_REG_IsStopConversionOngoing(ADCx) == 0U)
|
||||
{
|
||||
LL_ADC_REG_StopConversion(ADCx);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
(ADCx->CFGR1)|=(0x7<<6);
|
||||
(ADCx->CFGR1)|=(0x3<<10);
|
||||
__disable_irq();
|
||||
LL_ADC_REG_StartConversion(ADCx);
|
||||
LL_ADC_REG_StopConversion(ADCx);
|
||||
__enable_irq();
|
||||
}
|
||||
|
||||
/* Wait for ADC conversions are effectively stopped */
|
||||
timeout_cpu_cycles =LL_ADC_TIMEOUT_STOP_CONVERSION_CPU_CYCLES;
|
||||
while (LL_ADC_REG_IsStopConversionOngoing(ADCx) == 1U)
|
||||
{
|
||||
if(timeout_cpu_cycles-- == 0U)
|
||||
{
|
||||
/* Time-out error */
|
||||
status = ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
/* Wait for ADC instance is effectively disabled */
|
||||
timeout_cpu_cycles =LL_ADC_TIMEOUT_DISABLE_CPU_CYCLES;
|
||||
while (LL_ADC_IsEnabled(ADCx) == 1U)
|
||||
{
|
||||
if(timeout_cpu_cycles-- == 0U)
|
||||
{
|
||||
/* Time-out error */
|
||||
status = ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
/* Restore the CFGR1 Configure */
|
||||
ADCx->CFGR1=tmpCFGR1;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_LL_EF_FLAG_Management ADC flag management
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Get flag ADC group regular end of unitary conversion.
|
||||
* @rmtoll ISR EOC LL_ADC_IsActiveFlag_EOC
|
||||
* @param ADCx ADC instance
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_EOC(ADC_TypeDef *ADCx)
|
||||
{
|
||||
return (READ_BIT(ADCx->ISR, ADC_ISR_EOC) == (ADC_ISR_EOC));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get flag ADC group regular end of sequence conversions.
|
||||
* @rmtoll ISR EOSEQ LL_ADC_IsActiveFlag_EOS
|
||||
* @param ADCx ADC instance
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_EOS(ADC_TypeDef *ADCx)
|
||||
{
|
||||
return (READ_BIT(ADCx->ISR, LL_ADC_FLAG_EOS) == (LL_ADC_FLAG_EOS));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get flag ADC group regular overrun.
|
||||
* @rmtoll ISR OVR LL_ADC_IsActiveFlag_OVR
|
||||
* @param ADCx ADC instance
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_OVR(ADC_TypeDef *ADCx)
|
||||
{
|
||||
return (READ_BIT(ADCx->ISR, LL_ADC_FLAG_OVR) == (LL_ADC_FLAG_OVR));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get flag ADC group regular end of sampling phase.
|
||||
* @rmtoll ISR EOSMP LL_ADC_IsActiveFlag_EOSMP
|
||||
* @param ADCx ADC instance
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_EOSMP(ADC_TypeDef *ADCx)
|
||||
{
|
||||
return (READ_BIT(ADCx->ISR, LL_ADC_FLAG_EOSMP) == (LL_ADC_FLAG_EOSMP));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get flag ADC analog watchdog 1 flag
|
||||
* @rmtoll ISR AWD LL_ADC_IsActiveFlag_AWD
|
||||
* @param ADCx ADC instance
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_AWD(ADC_TypeDef *ADCx)
|
||||
{
|
||||
return (READ_BIT(ADCx->ISR, LL_ADC_FLAG_AWD) == (LL_ADC_FLAG_AWD));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear flag ADC group regular end of unitary conversion.
|
||||
* @rmtoll ISR EOC LL_ADC_ClearFlag_EOC
|
||||
* @param ADCx ADC instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_ADC_ClearFlag_EOC(ADC_TypeDef *ADCx)
|
||||
{
|
||||
WRITE_REG(ADCx->ISR, LL_ADC_FLAG_EOC);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear flag ADC group regular end of sequence conversions.
|
||||
* @rmtoll ISR EOSEQ LL_ADC_ClearFlag_EOS
|
||||
* @param ADCx ADC instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_ADC_ClearFlag_EOS(ADC_TypeDef *ADCx)
|
||||
{
|
||||
WRITE_REG(ADCx->ISR, LL_ADC_FLAG_EOS);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear flag ADC group regular overrun.
|
||||
* @rmtoll ISR OVR LL_ADC_ClearFlag_OVR
|
||||
* @param ADCx ADC instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_ADC_ClearFlag_OVR(ADC_TypeDef *ADCx)
|
||||
{
|
||||
WRITE_REG(ADCx->ISR, LL_ADC_FLAG_OVR);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear flag ADC group regular end of sampling phase.
|
||||
* @rmtoll ISR EOSMP LL_ADC_ClearFlag_EOSMP
|
||||
* @param ADCx ADC instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_ADC_ClearFlag_EOSMP(ADC_TypeDef *ADCx)
|
||||
{
|
||||
WRITE_REG(ADCx->ISR, LL_ADC_FLAG_EOSMP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear flag ADC analog watchdog 1.
|
||||
* @rmtoll ISR AWD LL_ADC_ClearFlag_AWD
|
||||
* @param ADCx ADC instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_ADC_ClearFlag_AWD(ADC_TypeDef *ADCx)
|
||||
{
|
||||
WRITE_REG(ADCx->ISR, LL_ADC_FLAG_AWD);
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_LL_EF_IT_Management ADC IT management
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief Enable interruption ADC group regular end of unitary conversion.
|
||||
* @rmtoll IER EOCIE LL_ADC_EnableIT_EOC
|
||||
* @param ADCx ADC instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_ADC_EnableIT_EOC(ADC_TypeDef *ADCx)
|
||||
{
|
||||
SET_BIT(ADCx->IER, LL_ADC_IT_EOC);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable interruption ADC group regular end of sequence conversions.
|
||||
* @rmtoll IER EOSEQIE LL_ADC_EnableIT_EOS
|
||||
* @param ADCx ADC instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_ADC_EnableIT_EOS(ADC_TypeDef *ADCx)
|
||||
{
|
||||
SET_BIT(ADCx->IER, LL_ADC_IT_EOS);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable ADC group regular interruption overrun.
|
||||
* @rmtoll IER OVRIE LL_ADC_EnableIT_OVR
|
||||
* @param ADCx ADC instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_ADC_EnableIT_OVR(ADC_TypeDef *ADCx)
|
||||
{
|
||||
SET_BIT(ADCx->IER, LL_ADC_IT_OVR);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable interruption ADC group regular end of sampling.
|
||||
* @rmtoll IER EOSMPIE LL_ADC_EnableIT_EOSMP
|
||||
* @param ADCx ADC instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_ADC_EnableIT_EOSMP(ADC_TypeDef *ADCx)
|
||||
{
|
||||
SET_BIT(ADCx->IER, LL_ADC_IT_EOSMP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable interruption ADC analog watchdog 1.
|
||||
* @rmtoll IER AWDIE LL_ADC_EnableIT_AWD
|
||||
* @param ADCx ADC instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_ADC_EnableIT_AWD(ADC_TypeDef *ADCx)
|
||||
{
|
||||
SET_BIT(ADCx->IER, LL_ADC_IT_AWD);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable interruption ADC group regular end of unitary conversion.
|
||||
* @rmtoll IER EOCIE LL_ADC_DisableIT_EOC
|
||||
* @param ADCx ADC instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_ADC_DisableIT_EOC(ADC_TypeDef *ADCx)
|
||||
{
|
||||
CLEAR_BIT(ADCx->IER, LL_ADC_IT_EOC);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable interruption ADC group regular end of sequence conversions.
|
||||
* @rmtoll IER EOSEQIE LL_ADC_DisableIT_EOS
|
||||
* @param ADCx ADC instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_ADC_DisableIT_EOS(ADC_TypeDef *ADCx)
|
||||
{
|
||||
CLEAR_BIT(ADCx->IER, LL_ADC_IT_EOS);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable interruption ADC group regular overrun.
|
||||
* @rmtoll IER OVRIE LL_ADC_DisableIT_OVR
|
||||
* @param ADCx ADC instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_ADC_DisableIT_OVR(ADC_TypeDef *ADCx)
|
||||
{
|
||||
CLEAR_BIT(ADCx->IER, LL_ADC_IT_OVR);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable interruption ADC group regular end of sampling.
|
||||
* @rmtoll IER EOSMPIE LL_ADC_DisableIT_EOSMP
|
||||
* @param ADCx ADC instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_ADC_DisableIT_EOSMP(ADC_TypeDef *ADCx)
|
||||
{
|
||||
CLEAR_BIT(ADCx->IER, LL_ADC_IT_EOSMP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable interruption ADC analog watchdog 1.
|
||||
* @rmtoll IER AWDIE LL_ADC_DisableIT_AWD
|
||||
* @param ADCx ADC instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_ADC_DisableIT_AWD(ADC_TypeDef *ADCx)
|
||||
{
|
||||
CLEAR_BIT(ADCx->IER, LL_ADC_IT_AWD);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get state of interruption ADC group regular end of unitary conversion
|
||||
* (0: interrupt disabled, 1: interrupt enabled).
|
||||
* @rmtoll IER EOCIE LL_ADC_IsEnabledIT_EOC
|
||||
* @param ADCx ADC instance
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_EOC(ADC_TypeDef *ADCx)
|
||||
{
|
||||
return (READ_BIT(ADCx->IER, LL_ADC_IT_EOC) == (LL_ADC_IT_EOC));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get state of interruption ADC group regular end of sequence conversions
|
||||
* (0: interrupt disabled, 1: interrupt enabled).
|
||||
* @rmtoll IER EOSEQIE LL_ADC_IsEnabledIT_EOS
|
||||
* @param ADCx ADC instance
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_EOS(ADC_TypeDef *ADCx)
|
||||
{
|
||||
return (READ_BIT(ADCx->IER, LL_ADC_IT_EOS) == (LL_ADC_IT_EOS));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get state of interruption ADC group regular overrun
|
||||
* (0: interrupt disabled, 1: interrupt enabled).
|
||||
* @rmtoll IER OVRIE LL_ADC_IsEnabledIT_OVR
|
||||
* @param ADCx ADC instance
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_OVR(ADC_TypeDef *ADCx)
|
||||
{
|
||||
return (READ_BIT(ADCx->IER, LL_ADC_IT_OVR) == (LL_ADC_IT_OVR));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get state of interruption ADC group regular end of sampling
|
||||
* (0: interrupt disabled, 1: interrupt enabled).
|
||||
* @rmtoll IER EOSMPIE LL_ADC_IsEnabledIT_EOSMP
|
||||
* @param ADCx ADC instance
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_EOSMP(ADC_TypeDef *ADCx)
|
||||
{
|
||||
return (READ_BIT(ADCx->IER, LL_ADC_IT_EOSMP) == (LL_ADC_IT_EOSMP));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get state of interruption ADC analog watchdog 1
|
||||
* (0: interrupt disabled, 1: interrupt enabled).
|
||||
* @rmtoll IER AWDIE LL_ADC_IsEnabledIT_AWD
|
||||
* @param ADCx ADC instance
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_AWD(ADC_TypeDef *ADCx)
|
||||
{
|
||||
return (READ_BIT(ADCx->IER, LL_ADC_IT_AWD) == (LL_ADC_IT_AWD));
|
||||
}
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADC_LL_EF_Calibration_Management ADC Calibration management
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief Set calibration sample time
|
||||
* @note Unit: ADC clock cycles.
|
||||
* @rmtoll CCSR CALSMP LL_ADC_SetCalSamplingTime
|
||||
* @param ADCx ADC instance
|
||||
* @param SamplingTime This parameter can be one of the following values:
|
||||
* @arg @ref LL_ADC_CAL_SAMPLINGTIME_2CYCLES
|
||||
* @arg @ref LL_ADC_CAL_SAMPLINGTIME_4CYCLES
|
||||
* @arg @ref LL_ADC_CAL_SAMPLINGTIME_8CYCLES
|
||||
* @arg @ref LL_ADC_CAL_SAMPLINGTIME_1CYCLE
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_ADC_SetCalibrationSamplingTime(ADC_TypeDef *ADCx, uint32_t CalibrationSamplingTime)
|
||||
{
|
||||
MODIFY_REG(ADCx->CCSR, ADC_CCSR_CALSMP, CalibrationSamplingTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sampling time common to a group of channels.
|
||||
* @note Unit: ADC clock cycles.
|
||||
* @rmtoll CCSR CALSMP LL_ADC_GetCalSamplingTime
|
||||
* @param ADCx ADC instance
|
||||
* @retval Returned value can be one of the following values:
|
||||
* @arg @ref LL_ADC_CAL_SAMPLINGTIME_2CYCLES
|
||||
* @arg @ref LL_ADC_CAL_SAMPLINGTIME_4CYCLES
|
||||
* @arg @ref LL_ADC_CAL_SAMPLINGTIME_8CYCLES
|
||||
* @arg @ref LL_ADC_CAL_SAMPLINGTIME_1CYCLE
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_ADC_GetCalibrationSamplingTime(ADC_TypeDef *ADCx)
|
||||
{
|
||||
return (uint32_t)(READ_BIT(ADCx->CCSR, ADC_CCSR_CALSMP));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear the calibration status
|
||||
* @rmtoll CCSR CALFAIL LL_ADC_ClearCalibarionStatus
|
||||
* @param ADCx ADC instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_ADC_ClearCalibarionStatus(ADC_TypeDef *ADCx)
|
||||
{
|
||||
SET_BIT(ADCx->CCSR, ADC_CCSR_CALFAIL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the calibration status
|
||||
* @rmtoll CCSR CALFAIL LL_ADC_GetCalibrationStatus
|
||||
* @param ADCx ADC instance
|
||||
* @retval Returned value can be one of the following values:
|
||||
* @arg @ref LL_ADC_CAL_STATUS_SUCCESS
|
||||
* @arg @ref LL_ADC_CAL_STATUS_FAIL
|
||||
* @arg @ref LL_ADC_CAL_STATUS_ONGOING
|
||||
* @arg @ref LL_ADC_CAL_STATUS_INVALID
|
||||
*/
|
||||
|
||||
__STATIC_INLINE uint32_t LL_ADC_GetCalibrationStatus(ADC_TypeDef *ADCx)
|
||||
{
|
||||
return (uint32_t)(READ_BIT(ADCx->CCSR, ADC_CCSR_CALFAIL)) | (uint32_t)(READ_BIT(ADCx->CCSR, ADC_CCSR_CALON));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the calibration mode
|
||||
* @rmtoll CCSR CALSEL LL_ADC_SetCalibrationMode
|
||||
* @param ADCx ADC instance
|
||||
* @param This parameter can be one of the following values:
|
||||
@arg @ref LL_ADC_CAL_MODE_OFFSET
|
||||
* @arg @ref LL_ADC_CAL_MODE_OFFSETANDLINEARITY
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_ADC_SetCalibrationMode(ADC_TypeDef *ADCx,uint32_t CalibrationMode)
|
||||
{
|
||||
MODIFY_REG(ADCx->CCSR,ADC_CCSR_CALSEL, CalibrationMode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the calibration contents
|
||||
* @rmtoll CCSR CALSEL LL_ADC_GetCalibrationMode
|
||||
* @param ADCx ADC instance
|
||||
* @retval Returned value can be one of the following values:
|
||||
* @arg @ref LL_ADC_CAL_MODE_OFFSET
|
||||
* @arg @ref LL_ADC_CAL_MODE_OFFSETANDLINEARITY
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_ADC_GetCalibrationMode(ADC_TypeDef *ADCx)
|
||||
{
|
||||
return (uint32_t)(READ_BIT(ADCx->CCSR, ADC_CCSR_CALSEL));
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#if defined(USE_FULL_LL_DRIVER)
|
||||
/** @defgroup ADC_LL_EF_Init Initialization and de-initialization functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Initialization of some features of ADC common parameters and multimode */
|
||||
/* Note: On this PY32 serie, there is no ADC common initialization */
|
||||
/* function. */
|
||||
ErrorStatus LL_ADC_CommonDeInit(ADC_Common_TypeDef *ADCxy_COMMON);
|
||||
|
||||
/* De-initialization of ADC instance */
|
||||
ErrorStatus LL_ADC_DeInit(ADC_TypeDef *ADCx);
|
||||
|
||||
/* Initialization of some features of ADC instance */
|
||||
ErrorStatus LL_ADC_Init(ADC_TypeDef *ADCx, LL_ADC_InitTypeDef *ADC_InitStruct);
|
||||
void LL_ADC_StructInit(LL_ADC_InitTypeDef *ADC_InitStruct);
|
||||
|
||||
/* Initialization of some features of ADC instance and ADC group regular */
|
||||
ErrorStatus LL_ADC_REG_Init(ADC_TypeDef *ADCx, LL_ADC_REG_InitTypeDef *ADC_REG_InitStruct);
|
||||
void LL_ADC_REG_StructInit(LL_ADC_REG_InitTypeDef *ADC_REG_InitStruct);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif /* USE_FULL_LL_DRIVER */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* ADC1 */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __PY32F0xx_LL_ADC_H */
|
||||
|
||||
/************************ (C) COPYRIGHT Puya *****END OF FILE****/
|
||||
596
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_ll_bus.h
Normal file
596
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_ll_bus.h
Normal file
@@ -0,0 +1,596 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file py32f0xx_ll_bus.h
|
||||
* @author MCU Application Team
|
||||
* @brief Header file of BUS LL module.
|
||||
|
||||
@verbatim
|
||||
##### RCC Limitations #####
|
||||
==============================================================================
|
||||
[..]
|
||||
A delay between an RCC peripheral clock enable and the effective peripheral
|
||||
enabling should be taken into account in order to manage the peripheral read/write
|
||||
from/to registers.
|
||||
(+) This delay depends on the peripheral mapping.
|
||||
(++) AHB & APB1 peripherals, 1 dummy read is necessary
|
||||
|
||||
[..]
|
||||
Workarounds:
|
||||
(#) For AHB & APB1 peripherals, a dummy read to the peripheral register has been
|
||||
inserted in each LL_{BUS}_GRP{x}_EnableClock() function.
|
||||
|
||||
@endverbatim
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) Puya Semiconductor Co.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef PY32F0XX_LL_BUS_H
|
||||
#define PY32F0XX_LL_BUS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "py32f0xx.h"
|
||||
|
||||
/** @addtogroup py32f0xx_LL_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if defined(RCC)
|
||||
|
||||
/** @defgroup BUS_LL BUS
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Private types -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
|
||||
/* Private macros ------------------------------------------------------------*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/** @defgroup BUS_LL_Exported_Constants BUS Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup BUS_LL_EC_AHB1_GRP1_PERIPH AHB1 GRP1 PERIPH
|
||||
* @{
|
||||
*/
|
||||
#define LL_AHB1_GRP1_PERIPH_ALL 0xFFFFFFFFU
|
||||
#if (defined(DMA) || defined(DMA1))
|
||||
#define LL_AHB1_GRP1_PERIPH_DMA1 RCC_AHBENR_DMAEN
|
||||
#endif
|
||||
#define LL_AHB1_GRP1_PERIPH_FLASH RCC_AHBENR_FLASHEN
|
||||
#define LL_AHB1_GRP1_PERIPH_SRAM RCC_AHBENR_SRAMEN
|
||||
#define LL_AHB1_GRP1_PERIPH_CRC RCC_AHBENR_CRCEN
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup BUS_LL_EC_APB1_GRP1_PERIPH APB1 GRP1 PERIPH
|
||||
* @{
|
||||
*/
|
||||
#define LL_APB1_GRP1_PERIPH_ALL 0xFFFFFFFFU
|
||||
#if defined(TIM3)
|
||||
#define LL_APB1_GRP1_PERIPH_TIM3 RCC_APBENR1_TIM3EN
|
||||
#endif
|
||||
#if defined(RTC)
|
||||
#define LL_APB1_GRP1_PERIPH_RTC RCC_APBENR1_RTCAPBEN
|
||||
#endif
|
||||
#if defined(WWDG)
|
||||
#define LL_APB1_GRP1_PERIPH_WWDG RCC_APBENR1_WWDGEN
|
||||
#endif
|
||||
#if defined(SPI2)
|
||||
#define LL_APB1_GRP1_PERIPH_SPI2 RCC_APBENR1_SPI2EN
|
||||
#endif
|
||||
#if defined(USART2)
|
||||
#define LL_APB1_GRP1_PERIPH_USART2 RCC_APBENR1_USART2EN
|
||||
#endif
|
||||
#define LL_APB1_GRP1_PERIPH_I2C1 RCC_APBENR1_I2CEN
|
||||
#define LL_APB1_GRP1_PERIPH_DBGMCU RCC_APBENR1_DBGEN
|
||||
#define LL_APB1_GRP1_PERIPH_PWR RCC_APBENR1_PWREN
|
||||
#define LL_APB1_GRP1_PERIPH_LPTIM1 RCC_APBENR1_LPTIMEN
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup BUS_LL_EC_APB1_GRP2_PERIPH APB1 GRP2 PERIPH
|
||||
* @{
|
||||
*/
|
||||
#define LL_APB1_GRP2_PERIPH_ALL 0xFFFFFFFFU
|
||||
#define LL_APB1_GRP2_PERIPH_SYSCFG RCC_APBENR2_SYSCFGEN
|
||||
#define LL_APB1_GRP2_PERIPH_TIM1 RCC_APBENR2_TIM1EN
|
||||
#define LL_APB1_GRP2_PERIPH_SPI1 RCC_APBENR2_SPI1EN
|
||||
#define LL_APB1_GRP2_PERIPH_USART1 RCC_APBENR2_USART1EN
|
||||
#if defined(TIM14)
|
||||
#define LL_APB1_GRP2_PERIPH_TIM14 RCC_APBENR2_TIM14EN
|
||||
#endif
|
||||
#define LL_APB1_GRP2_PERIPH_TIM16 RCC_APBENR2_TIM16EN
|
||||
#if defined(TIM17)
|
||||
#define LL_APB1_GRP2_PERIPH_TIM17 RCC_APBENR2_TIM17EN
|
||||
#endif
|
||||
#define LL_APB1_GRP2_PERIPH_ADC1 RCC_APBENR2_ADCEN
|
||||
#if defined(COMP1)
|
||||
#define LL_APB1_GRP2_PERIPH_COMP1 RCC_APBENR2_COMP1EN
|
||||
#endif
|
||||
#if defined(COMP2)
|
||||
#define LL_APB1_GRP2_PERIPH_COMP2 RCC_APBENR2_COMP2EN
|
||||
#endif
|
||||
#if defined(LED)
|
||||
#define LL_APB1_GRP2_PERIPH_LED RCC_APBENR2_LEDEN
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup BUS_LL_EC_IOP_GRP1_PERIPH IOP GRP1 PERIPH
|
||||
* @{
|
||||
*/
|
||||
#define LL_IOP_GRP1_PERIPH_ALL 0xFFFFFFFFU
|
||||
#define LL_IOP_GRP1_PERIPH_GPIOA RCC_IOPENR_GPIOAEN
|
||||
#define LL_IOP_GRP1_PERIPH_GPIOB RCC_IOPENR_GPIOBEN
|
||||
#define LL_IOP_GRP1_PERIPH_GPIOF RCC_IOPENR_GPIOFEN
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/** @defgroup BUS_LL_Exported_Functions BUS Exported Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup BUS_LL_EF_AHB1 AHB1
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Enable AHB1 peripherals clock.
|
||||
* @param Periphs This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_AHB1_GRP1_PERIPH_DMA1
|
||||
* @arg @ref LL_AHB1_GRP1_PERIPH_FLASH
|
||||
* @arg @ref LL_AHB1_GRP1_PERIPH_SRAM
|
||||
* @arg @ref LL_AHB1_GRP1_PERIPH_CRC
|
||||
* @note Depending on devices and packages, some peripherals may not be available.
|
||||
* Refer to device datasheet for peripherals availability.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_AHB1_GRP1_EnableClock(uint32_t Periphs)
|
||||
{
|
||||
__IO uint32_t tmpreg;
|
||||
SET_BIT(RCC->AHBENR, Periphs);
|
||||
/* Delay after an RCC peripheral clock enabling */
|
||||
tmpreg = READ_BIT(RCC->AHBENR, Periphs);
|
||||
(void)tmpreg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if AHB1 peripheral clock is enabled or not
|
||||
* @param Periphs This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_AHB1_GRP1_PERIPH_DMA1
|
||||
* @arg @ref LL_AHB1_GRP1_PERIPH_FLASH
|
||||
* @arg @ref LL_AHB1_GRP1_PERIPH_SRAM
|
||||
* @arg @ref LL_AHB1_GRP1_PERIPH_CRC
|
||||
* @note Depending on devices and packages, some peripherals may not be available.
|
||||
* Refer to device datasheet for peripherals availability.
|
||||
* @retval State of Periphs (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_AHB1_GRP1_IsEnabledClock(uint32_t Periphs)
|
||||
{
|
||||
return ((READ_BIT(RCC->AHBENR, Periphs) == Periphs) ? 1UL : 0UL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable AHB1 peripherals clock.
|
||||
* @param Periphs This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_AHB1_GRP1_PERIPH_DMA1
|
||||
* @arg @ref LL_AHB1_GRP1_PERIPH_FLASH
|
||||
* @arg @ref LL_AHB1_GRP1_PERIPH_SRAM
|
||||
* @arg @ref LL_AHB1_GRP1_PERIPH_CRC
|
||||
* @note Depending on devices and packages, some peripherals may not be available.
|
||||
* Refer to device datasheet for peripherals availability.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_AHB1_GRP1_DisableClock(uint32_t Periphs)
|
||||
{
|
||||
CLEAR_BIT(RCC->AHBENR, Periphs);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Force AHB1 peripherals reset.
|
||||
* @param Periphs This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_AHB1_GRP1_PERIPH_ALL
|
||||
* @arg @ref LL_AHB1_GRP1_PERIPH_DMA1
|
||||
* @arg @ref LL_AHB1_GRP1_PERIPH_CRC
|
||||
* @note Depending on devices and packages, some peripherals may not be available.
|
||||
* Refer to device datasheet for peripherals availability.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_AHB1_GRP1_ForceReset(uint32_t Periphs)
|
||||
{
|
||||
SET_BIT(RCC->AHBRSTR, Periphs);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Release AHB1 peripherals reset.
|
||||
* @param Periphs This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_AHB1_GRP1_PERIPH_ALL
|
||||
* @arg @ref LL_AHB1_GRP1_PERIPH_DMA1
|
||||
* @arg @ref LL_AHB1_GRP1_PERIPH_CRC
|
||||
* @note Depending on devices and packages, some peripherals may not be available.
|
||||
* Refer to device datasheet for peripherals availability.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_AHB1_GRP1_ReleaseReset(uint32_t Periphs)
|
||||
{
|
||||
CLEAR_BIT(RCC->AHBRSTR, Periphs);
|
||||
}
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup BUS_LL_EF_APB1_GRP1 APB1 GRP1
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Enable APB1 GRP1 peripherals clock.
|
||||
* @param Periphs This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_APB1_GRP1_PERIPH_TIM3
|
||||
* @arg @ref LL_APB1_GRP1_PERIPH_RTC
|
||||
* @arg @ref LL_APB1_GRP1_PERIPH_WWDG
|
||||
* @arg @ref LL_APB1_GRP1_PERIPH_SPI2
|
||||
* @arg @ref LL_APB1_GRP1_PERIPH_USART2
|
||||
* @arg @ref LL_APB1_GRP1_PERIPH_I2C1
|
||||
* @arg @ref LL_APB1_GRP1_PERIPH_DBGMCU
|
||||
* @arg @ref LL_APB1_GRP1_PERIPH_PWR
|
||||
* @arg @ref LL_APB1_GRP1_PERIPH_LPTIM1
|
||||
* @note Depending on devices and packages, some peripherals may not be available.
|
||||
* Refer to device datasheet for peripherals availability.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_APB1_GRP1_EnableClock(uint32_t Periphs)
|
||||
{
|
||||
__IO uint32_t tmpreg;
|
||||
SET_BIT(RCC->APBENR1, Periphs);
|
||||
/* Delay after an RCC peripheral clock enabling */
|
||||
tmpreg = READ_BIT(RCC->APBENR1, Periphs);
|
||||
(void)tmpreg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if APB1 GRP1 peripheral clock is enabled or not
|
||||
* @param Periphs This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_APB1_GRP1_PERIPH_TIM3
|
||||
* @arg @ref LL_APB1_GRP1_PERIPH_RTC
|
||||
* @arg @ref LL_APB1_GRP1_PERIPH_WWDG
|
||||
* @arg @ref LL_APB1_GRP1_PERIPH_SPI2
|
||||
* @arg @ref LL_APB1_GRP1_PERIPH_USART2
|
||||
* @arg @ref LL_APB1_GRP1_PERIPH_I2C1
|
||||
* @arg @ref LL_APB1_GRP1_PERIPH_DBGMCU
|
||||
* @arg @ref LL_APB1_GRP1_PERIPH_PWR
|
||||
* @arg @ref LL_APB1_GRP1_PERIPH_LPTIM1
|
||||
* @note Depending on devices and packages, some peripherals may not be available.
|
||||
* Refer to device datasheet for peripherals availability.
|
||||
* @retval State of Periphs (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_APB1_GRP1_IsEnabledClock(uint32_t Periphs)
|
||||
{
|
||||
return ((READ_BIT(RCC->APBENR1, Periphs) == (Periphs)) ? 1UL : 0UL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable APB1 GRP1 peripherals clock.
|
||||
* @param Periphs This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_APB1_GRP1_PERIPH_TIM3
|
||||
* @arg @ref LL_APB1_GRP1_PERIPH_RTC
|
||||
* @arg @ref LL_APB1_GRP1_PERIPH_WWDG
|
||||
* @arg @ref LL_APB1_GRP1_PERIPH_SPI2
|
||||
* @arg @ref LL_APB1_GRP1_PERIPH_USART2
|
||||
* @arg @ref LL_APB1_GRP1_PERIPH_I2C1
|
||||
* @arg @ref LL_APB1_GRP1_PERIPH_DBGMCU
|
||||
* @arg @ref LL_APB1_GRP1_PERIPH_PWR
|
||||
* @arg @ref LL_APB1_GRP1_PERIPH_LPTIM1
|
||||
* @note Depending on devices and packages, some peripherals may not be available.
|
||||
* Refer to device datasheet for peripherals availability.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_APB1_GRP1_DisableClock(uint32_t Periphs)
|
||||
{
|
||||
CLEAR_BIT(RCC->APBENR1, Periphs);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Force APB1 GRP1 peripherals reset.
|
||||
* @param Periphs This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_APB1_GRP1_PERIPH_TIM3
|
||||
* @arg @ref LL_APB1_GRP1_PERIPH_SPI2
|
||||
* @arg @ref LL_APB1_GRP1_PERIPH_USART2
|
||||
* @arg @ref LL_APB1_GRP1_PERIPH_I2C1
|
||||
* @arg @ref LL_APB1_GRP1_PERIPH_DBGMCU
|
||||
* @arg @ref LL_APB1_GRP1_PERIPH_PWR
|
||||
* @arg @ref LL_APB1_GRP1_PERIPH_LPTIM1
|
||||
* @note Depending on devices and packages, some peripherals may not be available.
|
||||
* Refer to device datasheet for peripherals availability.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_APB1_GRP1_ForceReset(uint32_t Periphs)
|
||||
{
|
||||
SET_BIT(RCC->APBRSTR1, Periphs);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Release APB1 GRP1 peripherals reset.
|
||||
* @param Periphs This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_APB1_GRP1_PERIPH_TIM3
|
||||
* @arg @ref LL_APB1_GRP1_PERIPH_SPI2
|
||||
* @arg @ref LL_APB1_GRP1_PERIPH_USART2
|
||||
* @arg @ref LL_APB1_GRP1_PERIPH_I2C1
|
||||
* @arg @ref LL_APB1_GRP1_PERIPH_DBGMCU
|
||||
* @arg @ref LL_APB1_GRP1_PERIPH_PWR
|
||||
* @arg @ref LL_APB1_GRP1_PERIPH_LPTIM1
|
||||
* @note Depending on devices and packages, some peripherals may not be available.
|
||||
* Refer to device datasheet for peripherals availability.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_APB1_GRP1_ReleaseReset(uint32_t Periphs)
|
||||
{
|
||||
CLEAR_BIT(RCC->APBRSTR1, Periphs);
|
||||
}
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup BUS_LL_EF_APB1_GRP2 APB1 GRP2
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Enable APB1 GRP2 peripherals clock.
|
||||
* @param Periphs This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_SYSCFG
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_TIM1
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_SPI1
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_USART1
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_TIM14
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_TIM16
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_TIM17
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_ADC1
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_COMP1
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_COMP2
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_LED
|
||||
* @note Depending on devices and packages, some peripherals may not be available.
|
||||
* Refer to device datasheet for peripherals availability.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_APB1_GRP2_EnableClock(uint32_t Periphs)
|
||||
{
|
||||
__IO uint32_t tmpreg;
|
||||
SET_BIT(RCC->APBENR2, Periphs);
|
||||
/* Delay after an RCC peripheral clock enabling */
|
||||
tmpreg = READ_BIT(RCC->APBENR2, Periphs);
|
||||
(void)tmpreg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if APB1 GRP2 peripheral clock is enabled or not
|
||||
* @param Periphs This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_SYSCFG
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_TIM1
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_SPI1
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_USART1
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_TIM14
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_TIM16
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_TIM17
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_ADC1
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_COMP1
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_COMP2
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_LED
|
||||
* @note Depending on devices and packages, some peripherals may not be available.
|
||||
* Refer to device datasheet for peripherals availability.
|
||||
* @retval State of Periphs (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_APB1_GRP2_IsEnabledClock(uint32_t Periphs)
|
||||
{
|
||||
return ((READ_BIT(RCC->APBENR2, Periphs) == (Periphs)) ? 1UL : 0UL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable APB1 GRP2 peripherals clock.
|
||||
* @param Periphs This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_SYSCFG
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_TIM1
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_SPI1
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_USART1
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_TIM14
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_TIM16
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_TIM17
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_ADC1
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_COMP1
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_COMP2
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_LED
|
||||
* @note Depending on devices and packages, some peripherals may not be available.
|
||||
* Refer to device datasheet for peripherals availability.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_APB1_GRP2_DisableClock(uint32_t Periphs)
|
||||
{
|
||||
CLEAR_BIT(RCC->APBENR2, Periphs);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Force APB1 GRP2 peripherals reset.
|
||||
* @param Periphs This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_ALL
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_SYSCFG
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_TIM1
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_SPI1
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_USART1
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_TIM14
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_TIM16
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_TIM17
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_ADC1
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_COMP1
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_COMP2
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_LED
|
||||
* @note Depending on devices and packages, some peripherals may not be available.
|
||||
* Refer to device datasheet for peripherals availability.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_APB1_GRP2_ForceReset(uint32_t Periphs)
|
||||
{
|
||||
SET_BIT(RCC->APBRSTR2, Periphs);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Release APB1 GRP2 peripherals reset.
|
||||
* @param Periphs This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_ALL
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_SYSCFG
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_TIM1
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_SPI1
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_USART1
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_TIM14
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_TIM16
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_TIM17
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_ADC1
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_COMP1
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_COMP2
|
||||
* @arg @ref LL_APB1_GRP2_PERIPH_LED
|
||||
* @note Depending on devices and packages, some peripherals may not be available.
|
||||
* Refer to device datasheet for peripherals availability.
|
||||
* @note (*) peripheral not available on all devices
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_APB1_GRP2_ReleaseReset(uint32_t Periphs)
|
||||
{
|
||||
CLEAR_BIT(RCC->APBRSTR2, Periphs);
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup BUS_LL_EF_IOP IOP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Enable IOP peripherals clock.
|
||||
* @param Periphs This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_IOP_GRP1_PERIPH_GPIOA
|
||||
* @arg @ref LL_IOP_GRP1_PERIPH_GPIOB
|
||||
* @arg @ref LL_IOP_GRP1_PERIPH_GPIOF
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_IOP_GRP1_EnableClock(uint32_t Periphs)
|
||||
{
|
||||
__IO uint32_t tmpreg;
|
||||
SET_BIT(RCC->IOPENR, Periphs);
|
||||
/* Delay after an RCC peripheral clock enabling */
|
||||
tmpreg = READ_BIT(RCC->IOPENR, Periphs);
|
||||
(void)tmpreg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if IOP peripheral clock is enabled or not
|
||||
* @param Periphs This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_IOP_GRP1_PERIPH_GPIOA
|
||||
* @arg @ref LL_IOP_GRP1_PERIPH_GPIOB
|
||||
* @arg @ref LL_IOP_GRP1_PERIPH_GPIOF
|
||||
* @retval State of Periphs (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_IOP_GRP1_IsEnabledClock(uint32_t Periphs)
|
||||
{
|
||||
return ((READ_BIT(RCC->IOPENR, Periphs) == Periphs) ? 1UL : 0UL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable IOP peripherals clock.
|
||||
* @param Periphs This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_IOP_GRP1_PERIPH_GPIOA
|
||||
* @arg @ref LL_IOP_GRP1_PERIPH_GPIOB
|
||||
* @arg @ref LL_IOP_GRP1_PERIPH_GPIOF
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_IOP_GRP1_DisableClock(uint32_t Periphs)
|
||||
{
|
||||
CLEAR_BIT(RCC->IOPENR, Periphs);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable IOP peripherals clock.
|
||||
* @param Periphs This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_IOP_GRP1_PERIPH_ALL
|
||||
* @arg @ref LL_IOP_GRP1_PERIPH_GPIOA
|
||||
* @arg @ref LL_IOP_GRP1_PERIPH_GPIOB
|
||||
* @arg @ref LL_IOP_GRP1_PERIPH_GPIOF
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_IOP_GRP1_ForceReset(uint32_t Periphs)
|
||||
{
|
||||
SET_BIT(RCC->IOPRSTR, Periphs);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Release IOP peripherals reset.
|
||||
* @param Periphs This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_IOP_GRP1_PERIPH_ALL
|
||||
* @arg @ref LL_IOP_GRP1_PERIPH_GPIOA
|
||||
* @arg @ref LL_IOP_GRP1_PERIPH_GPIOB
|
||||
* @arg @ref LL_IOP_GRP1_PERIPH_GPIOF
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_IOP_GRP1_ReleaseReset(uint32_t Periphs)
|
||||
{
|
||||
CLEAR_BIT(RCC->IOPRSTR, Periphs);
|
||||
}
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* RCC */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* PY32F0XX_LL_BUS_H */
|
||||
|
||||
/************************ (C) COPYRIGHT Puya *****END OF FILE****/
|
||||
833
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_ll_comp.h
Normal file
833
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_ll_comp.h
Normal file
File diff suppressed because one or more lines are too long
310
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_ll_cortex.h
Normal file
310
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_ll_cortex.h
Normal file
@@ -0,0 +1,310 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file py32f0xx_ll_cortex.h
|
||||
* @author MCU Application Team
|
||||
* @brief Header file of CORTEX LL module.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) Puya Semiconductor Co.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __PY32F0XX_LL_CORTEX_H
|
||||
#define __PY32F0XX_LL_CORTEX_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "py32f0xx.h"
|
||||
|
||||
/** @addtogroup PY32F0XX_LL_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup CORTEX_LL CORTEX
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Private types -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
|
||||
/* Private macros ------------------------------------------------------------*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/** @defgroup CORTEX_LL_Exported_Constants CORTEX Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup CORTEX_LL_EC_CLKSOURCE_HCLK SYSTICK Clock Source
|
||||
* @{
|
||||
*/
|
||||
#define LL_SYSTICK_CLKSOURCE_HCLK_DIV8 0x00000000U /*!< AHB clock divided by 8 selected as SysTick clock source.*/
|
||||
#define LL_SYSTICK_CLKSOURCE_HCLK SysTick_CTRL_CLKSOURCE_Msk /*!< AHB clock selected as SysTick clock source. */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/** @defgroup CORTEX_LL_Exported_Functions CORTEX Exported Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup CORTEX_LL_EF_SYSTICK SYSTICK
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief This function checks if the Systick counter flag is active or not.
|
||||
* @note It can be used in timeout function on application side.
|
||||
* @rmtoll STK_CTRL COUNTFLAG LL_SYSTICK_IsActiveCounterFlag
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_SYSTICK_IsActiveCounterFlag(void)
|
||||
{
|
||||
return (((SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) == (SysTick_CTRL_COUNTFLAG_Msk)) ? 1UL : 0UL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configures the SysTick clock source
|
||||
* @rmtoll STK_CTRL CLKSOURCE LL_SYSTICK_SetClkSource
|
||||
* @param Source This parameter can be one of the following values:
|
||||
* @arg @ref LL_SYSTICK_CLKSOURCE_HCLK_DIV8
|
||||
* @arg @ref LL_SYSTICK_CLKSOURCE_HCLK
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_SYSTICK_SetClkSource(uint32_t Source)
|
||||
{
|
||||
if (Source == LL_SYSTICK_CLKSOURCE_HCLK)
|
||||
{
|
||||
SET_BIT(SysTick->CTRL, LL_SYSTICK_CLKSOURCE_HCLK);
|
||||
}
|
||||
else
|
||||
{
|
||||
CLEAR_BIT(SysTick->CTRL, LL_SYSTICK_CLKSOURCE_HCLK);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the SysTick clock source
|
||||
* @rmtoll STK_CTRL CLKSOURCE LL_SYSTICK_GetClkSource
|
||||
* @retval Returned value can be one of the following values:
|
||||
* @arg @ref LL_SYSTICK_CLKSOURCE_HCLK_DIV8
|
||||
* @arg @ref LL_SYSTICK_CLKSOURCE_HCLK
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_SYSTICK_GetClkSource(void)
|
||||
{
|
||||
return READ_BIT(SysTick->CTRL, LL_SYSTICK_CLKSOURCE_HCLK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable SysTick exception request
|
||||
* @rmtoll STK_CTRL TICKINT LL_SYSTICK_EnableIT
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_SYSTICK_EnableIT(void)
|
||||
{
|
||||
SET_BIT(SysTick->CTRL, SysTick_CTRL_TICKINT_Msk);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable SysTick exception request
|
||||
* @rmtoll STK_CTRL TICKINT LL_SYSTICK_DisableIT
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_SYSTICK_DisableIT(void)
|
||||
{
|
||||
CLEAR_BIT(SysTick->CTRL, SysTick_CTRL_TICKINT_Msk);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Checks if the SYSTICK interrupt is enabled or disabled.
|
||||
* @rmtoll STK_CTRL TICKINT LL_SYSTICK_IsEnabledIT
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_SYSTICK_IsEnabledIT(void)
|
||||
{
|
||||
return ((READ_BIT(SysTick->CTRL, SysTick_CTRL_TICKINT_Msk) == (SysTick_CTRL_TICKINT_Msk)) ? 1UL : 0UL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup CORTEX_LL_EF_LOW_POWER_MODE LOW POWER MODE
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Processor uses sleep as its low power mode
|
||||
* @rmtoll SCB_SCR SLEEPDEEP LL_LPM_EnableSleep
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_LPM_EnableSleep(void)
|
||||
{
|
||||
/* Clear SLEEPDEEP bit of Cortex System Control Register */
|
||||
CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Processor uses deep sleep as its low power mode
|
||||
* @rmtoll SCB_SCR SLEEPDEEP LL_LPM_EnableDeepSleep
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_LPM_EnableDeepSleep(void)
|
||||
{
|
||||
/* Set SLEEPDEEP bit of Cortex System Control Register */
|
||||
SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configures sleep-on-exit when returning from Handler mode to Thread mode.
|
||||
* @note Setting this bit to 1 enables an interrupt-driven application to avoid returning to an
|
||||
* empty main application.
|
||||
* @rmtoll SCB_SCR SLEEPONEXIT LL_LPM_EnableSleepOnExit
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_LPM_EnableSleepOnExit(void)
|
||||
{
|
||||
/* Set SLEEPONEXIT bit of Cortex System Control Register */
|
||||
SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPONEXIT_Msk));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Do not sleep when returning to Thread mode.
|
||||
* @rmtoll SCB_SCR SLEEPONEXIT LL_LPM_DisableSleepOnExit
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_LPM_DisableSleepOnExit(void)
|
||||
{
|
||||
/* Clear SLEEPONEXIT bit of Cortex System Control Register */
|
||||
CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPONEXIT_Msk));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enabled events and all interrupts, including disabled interrupts, can wakeup the
|
||||
* processor.
|
||||
* @rmtoll SCB_SCR SEVEONPEND LL_LPM_EnableEventOnPend
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_LPM_EnableEventOnPend(void)
|
||||
{
|
||||
/* Set SEVEONPEND bit of Cortex System Control Register */
|
||||
SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SEVONPEND_Msk));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Only enabled interrupts or events can wakeup the processor, disabled interrupts are
|
||||
* excluded
|
||||
* @rmtoll SCB_SCR SEVEONPEND LL_LPM_DisableEventOnPend
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_LPM_DisableEventOnPend(void)
|
||||
{
|
||||
/* Clear SEVEONPEND bit of Cortex System Control Register */
|
||||
CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SEVONPEND_Msk));
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup CORTEX_LL_EF_MCU_INFO MCU INFO
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Get Implementer code
|
||||
* @rmtoll SCB_CPUID IMPLEMENTER LL_CPUID_GetImplementer
|
||||
* @retval Value should be equal to 0x41 for ARM
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_CPUID_GetImplementer(void)
|
||||
{
|
||||
return (uint32_t)(READ_BIT(SCB->CPUID, SCB_CPUID_IMPLEMENTER_Msk) >> SCB_CPUID_IMPLEMENTER_Pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get Variant number (The r value in the rnpn product revision identifier)
|
||||
* @rmtoll SCB_CPUID VARIANT LL_CPUID_GetVariant
|
||||
* @retval Value between 0 and 255 (0x0: revision 0)
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_CPUID_GetVariant(void)
|
||||
{
|
||||
return (uint32_t)(READ_BIT(SCB->CPUID, SCB_CPUID_VARIANT_Msk) >> SCB_CPUID_VARIANT_Pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get Architecture number
|
||||
* @rmtoll SCB_CPUID ARCHITECTURE LL_CPUID_GetArchitecture
|
||||
* @retval Value should be equal to 0xC for Cortex-M0+ devices
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_CPUID_GetArchitecture(void)
|
||||
{
|
||||
return (uint32_t)(READ_BIT(SCB->CPUID, SCB_CPUID_ARCHITECTURE_Msk) >> SCB_CPUID_ARCHITECTURE_Pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get Part number
|
||||
* @rmtoll SCB_CPUID PARTNO LL_CPUID_GetParNo
|
||||
* @retval Value should be equal to 0xC60 for Cortex-M0+
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_CPUID_GetParNo(void)
|
||||
{
|
||||
return (uint32_t)(READ_BIT(SCB->CPUID, SCB_CPUID_PARTNO_Msk) >> SCB_CPUID_PARTNO_Pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get Revision number (The p value in the rnpn product revision identifier, indicates patch release)
|
||||
* @rmtoll SCB_CPUID REVISION LL_CPUID_GetRevision
|
||||
* @retval Value between 0 and 255 (0x1: patch 1)
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_CPUID_GetRevision(void)
|
||||
{
|
||||
return (uint32_t)(READ_BIT(SCB->CPUID, SCB_CPUID_REVISION_Msk) >> SCB_CPUID_REVISION_Pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __PY32F0XX_LL_CORTEX_H */
|
||||
|
||||
/************************ (C) COPYRIGHT Puya *****END OF FILE****/
|
||||
204
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_ll_crc.h
Normal file
204
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_ll_crc.h
Normal file
@@ -0,0 +1,204 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file py32f0xx_ll_crc.h
|
||||
* @author MCU Application Team
|
||||
* @brief Header file of CRC LL module.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) Puya Semiconductor Co.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef PY32F0xx_LL_CRC_H
|
||||
#define PY32F0xx_LL_CRC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "py32f0xx.h"
|
||||
|
||||
/** @addtogroup PY32F0xx_LL_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if defined(CRC)
|
||||
|
||||
/** @defgroup CRC_LL CRC
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Private types -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
/* Private macros ------------------------------------------------------------*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/** @defgroup CRC_LL_Exported_Constants CRC Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/** @defgroup CRC_LL_Exported_Macros CRC Exported Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup CRC_LL_EM_WRITE_READ Common Write and read registers Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Write a value in CRC register
|
||||
* @param __INSTANCE__ CRC Instance
|
||||
* @param __REG__ Register to be written
|
||||
* @param __VALUE__ Value to be written in the register
|
||||
* @retval None
|
||||
*/
|
||||
#define LL_CRC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, __VALUE__)
|
||||
|
||||
/**
|
||||
* @brief Read a value in CRC register
|
||||
* @param __INSTANCE__ CRC Instance
|
||||
* @param __REG__ Register to be read
|
||||
* @retval Register value
|
||||
*/
|
||||
#define LL_CRC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/** @defgroup CRC_LL_Exported_Functions CRC Exported Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup CRC_LL_EF_Configuration CRC Configuration functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Reset the CRC calculation unit.
|
||||
* @rmtoll CR RESET LL_CRC_ResetCRCCalculationUnit
|
||||
* @param CRCx CRC Instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_CRC_ResetCRCCalculationUnit(CRC_TypeDef *CRCx)
|
||||
{
|
||||
SET_BIT(CRCx->CR, CRC_CR_RESET);
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup CRC_LL_EF_Data_Management Data_Management
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Write given 32-bit data to the CRC calculator
|
||||
* @rmtoll DR DR LL_CRC_FeedData32
|
||||
* @param CRCx CRC Instance
|
||||
* @param InData value to be provided to CRC calculator between between Min_Data=0 and Max_Data=0xFFFFFFFF
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_CRC_FeedData32(CRC_TypeDef *CRCx, uint32_t InData)
|
||||
{
|
||||
WRITE_REG(CRCx->DR, InData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return current CRC calculation result. 32 bits value is returned.
|
||||
* @rmtoll DR DR LL_CRC_ReadData32
|
||||
* @param CRCx CRC Instance
|
||||
* @retval Current CRC calculation result as stored in CRC_DR register (32 bits).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_CRC_ReadData32(CRC_TypeDef *CRCx)
|
||||
{
|
||||
return (uint32_t)(READ_REG(CRCx->DR));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return data stored in the Independent Data(IDR) register.
|
||||
* @note This register can be used as a temporary storage location for one byte.
|
||||
* @rmtoll IDR IDR LL_CRC_Read_IDR
|
||||
* @param CRCx CRC Instance
|
||||
* @retval Value stored in CRC_IDR register (General-purpose 8-bit data register).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_CRC_Read_IDR(CRC_TypeDef *CRCx)
|
||||
{
|
||||
return (uint32_t)(READ_REG(CRCx->IDR));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Store data in the Independent Data(IDR) register.
|
||||
* @note This register can be used as a temporary storage location for one byte.
|
||||
* @rmtoll IDR IDR LL_CRC_Write_IDR
|
||||
* @param CRCx CRC Instance
|
||||
* @param InData value to be stored in CRC_IDR register (8-bit) between Min_Data=0 and Max_Data=0xFF
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_CRC_Write_IDR(CRC_TypeDef *CRCx, uint32_t InData)
|
||||
{
|
||||
*((uint8_t __IO *)(&CRCx->IDR)) = (uint8_t) InData;
|
||||
}
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#if defined(USE_FULL_LL_DRIVER)
|
||||
/** @defgroup CRC_LL_EF_Init Initialization and de-initialization functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
ErrorStatus LL_CRC_DeInit(CRC_TypeDef *CRCx);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif /* USE_FULL_LL_DRIVER */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* defined(CRC) */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* PY32F0xx_LL_CRC_H */
|
||||
|
||||
/************************ (C) COPYRIGHT Puya *****END OF FILE****/
|
||||
1370
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_ll_dma.h
Normal file
1370
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_ll_dma.h
Normal file
@@ -0,0 +1,1370 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file py32f0xx_ll_dma.h
|
||||
* @author MCU Application Team
|
||||
* @brief Header file of DMA LL module.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) Puya Semiconductor Co.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __PY32F0XX_LL_DMA_H
|
||||
#define __PY32F0XX_LL_DMA_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "py32f0xx.h"
|
||||
|
||||
/** @addtogroup PY32F0XX_LL_Driver
|
||||
* @{
|
||||
*/
|
||||
#if defined (DMA1)
|
||||
|
||||
/** @defgroup DMA_LL DMA
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Private types -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/** @defgroup DMA_LL_Private_Variables DMA Private Variables
|
||||
* @{
|
||||
*/
|
||||
/* Array used to get the DMA channel register offset versus channel index LL_DMA_CHANNEL_x */
|
||||
static const uint8_t CHANNEL_OFFSET_TAB[] =
|
||||
{
|
||||
(uint8_t)(DMA1_Channel1_BASE - DMA1_BASE),
|
||||
(uint8_t)(DMA1_Channel2_BASE - DMA1_BASE),
|
||||
(uint8_t)(DMA1_Channel3_BASE - DMA1_BASE),
|
||||
};
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
/* Private macros ------------------------------------------------------------*/
|
||||
#if defined(USE_FULL_LL_DRIVER)
|
||||
/** @defgroup DMA_LL_Private_Macros DMA Private Macros
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif /*USE_FULL_LL_DRIVER*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
#if defined(USE_FULL_LL_DRIVER)
|
||||
/** @defgroup DMA_LL_ES_INIT DMA Exported Init structure
|
||||
* @{
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t PeriphOrM2MSrcAddress; /*!< Specifies the peripheral base address for DMA transfer
|
||||
or as Source base address in case of memory to memory transfer direction.
|
||||
|
||||
This parameter must be a value between Min_Data = 0 and Max_Data = 0xFFFFFFFF. */
|
||||
|
||||
uint32_t MemoryOrM2MDstAddress; /*!< Specifies the memory base address for DMA transfer
|
||||
or as Destination base address in case of memory to memory transfer direction.
|
||||
|
||||
This parameter must be a value between Min_Data = 0 and Max_Data = 0xFFFFFFFF. */
|
||||
|
||||
uint32_t Direction; /*!< Specifies if the data will be transferred from memory to peripheral,
|
||||
from memory to memory or from peripheral to memory.
|
||||
This parameter can be a value of @ref DMA_LL_EC_DIRECTION
|
||||
|
||||
This feature can be modified afterwards using unitary function @ref LL_DMA_SetDataTransferDirection(). */
|
||||
|
||||
uint32_t Mode; /*!< Specifies the normal or circular operation mode.
|
||||
This parameter can be a value of @ref DMA_LL_EC_MODE
|
||||
@note: The circular buffer mode cannot be used if the memory to memory
|
||||
data transfer direction is configured on the selected Channel
|
||||
|
||||
This feature can be modified afterwards using unitary function @ref LL_DMA_SetMode(). */
|
||||
|
||||
uint32_t PeriphOrM2MSrcIncMode; /*!< Specifies whether the Peripheral address or Source address in case of memory to memory transfer direction
|
||||
is incremented or not.
|
||||
This parameter can be a value of @ref DMA_LL_EC_PERIPH
|
||||
|
||||
This feature can be modified afterwards using unitary function @ref LL_DMA_SetPeriphIncMode(). */
|
||||
|
||||
uint32_t MemoryOrM2MDstIncMode; /*!< Specifies whether the Memory address or Destination address in case of memory to memory transfer direction
|
||||
is incremented or not.
|
||||
This parameter can be a value of @ref DMA_LL_EC_MEMORY
|
||||
|
||||
This feature can be modified afterwards using unitary function @ref LL_DMA_SetMemoryIncMode(). */
|
||||
|
||||
uint32_t PeriphOrM2MSrcDataSize; /*!< Specifies the Peripheral data size alignment or Source data size alignment (byte, half word, word)
|
||||
in case of memory to memory transfer direction.
|
||||
This parameter can be a value of @ref DMA_LL_EC_PDATAALIGN
|
||||
|
||||
This feature can be modified afterwards using unitary function @ref LL_DMA_SetPeriphSize(). */
|
||||
|
||||
uint32_t MemoryOrM2MDstDataSize; /*!< Specifies the Memory data size alignment or Destination data size alignment (byte, half word, word)
|
||||
in case of memory to memory transfer direction.
|
||||
This parameter can be a value of @ref DMA_LL_EC_MDATAALIGN
|
||||
|
||||
This feature can be modified afterwards using unitary function @ref LL_DMA_SetMemorySize(). */
|
||||
|
||||
uint32_t NbData; /*!< Specifies the number of data to transfer, in data unit.
|
||||
The data unit is equal to the source buffer configuration set in PeripheralSize
|
||||
or MemorySize parameters depending in the transfer direction.
|
||||
This parameter must be a value between Min_Data = 0 and Max_Data = 0x0000FFFF
|
||||
|
||||
This feature can be modified afterwards using unitary function @ref LL_DMA_SetDataLength(). */
|
||||
|
||||
uint32_t Priority; /*!< Specifies the channel priority level.
|
||||
This parameter can be a value of @ref DMA_LL_EC_PRIORITY
|
||||
|
||||
This feature can be modified afterwards using unitary function @ref LL_DMA_SetChannelPriorityLevel(). */
|
||||
|
||||
} LL_DMA_InitTypeDef;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif /*USE_FULL_LL_DRIVER*/
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/** @defgroup DMA_LL_Exported_Constants DMA Exported Constants
|
||||
* @{
|
||||
*/
|
||||
/** @defgroup DMA_LL_EC_CLEAR_FLAG Clear Flags Defines
|
||||
* @brief Flags defines which can be used with LL_DMA_WriteReg function
|
||||
* @{
|
||||
*/
|
||||
#define LL_DMA_IFCR_CGIF1 DMA_IFCR_CGIF1 /*!< Channel 1 global flag */
|
||||
#define LL_DMA_IFCR_CTCIF1 DMA_IFCR_CTCIF1 /*!< Channel 1 transfer complete flag */
|
||||
#define LL_DMA_IFCR_CHTIF1 DMA_IFCR_CHTIF1 /*!< Channel 1 half transfer flag */
|
||||
#define LL_DMA_IFCR_CTEIF1 DMA_IFCR_CTEIF1 /*!< Channel 1 transfer error flag */
|
||||
#define LL_DMA_IFCR_CGIF2 DMA_IFCR_CGIF2 /*!< Channel 2 global flag */
|
||||
#define LL_DMA_IFCR_CTCIF2 DMA_IFCR_CTCIF2 /*!< Channel 2 transfer complete flag */
|
||||
#define LL_DMA_IFCR_CHTIF2 DMA_IFCR_CHTIF2 /*!< Channel 2 half transfer flag */
|
||||
#define LL_DMA_IFCR_CTEIF2 DMA_IFCR_CTEIF2 /*!< Channel 2 transfer error flag */
|
||||
#define LL_DMA_IFCR_CGIF3 DMA_IFCR_CGIF3 /*!< Channel 3 global flag */
|
||||
#define LL_DMA_IFCR_CTCIF3 DMA_IFCR_CTCIF3 /*!< Channel 3 transfer complete flag */
|
||||
#define LL_DMA_IFCR_CHTIF3 DMA_IFCR_CHTIF3 /*!< Channel 3 half transfer flag */
|
||||
#define LL_DMA_IFCR_CTEIF3 DMA_IFCR_CTEIF3 /*!< Channel 3 transfer error flag */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup DMA_LL_EC_GET_FLAG Get Flags Defines
|
||||
* @brief Flags defines which can be used with LL_DMA_ReadReg function
|
||||
* @{
|
||||
*/
|
||||
#define LL_DMA_ISR_GIF1 DMA_ISR_GIF1 /*!< Channel 1 global flag */
|
||||
#define LL_DMA_ISR_TCIF1 DMA_ISR_TCIF1 /*!< Channel 1 transfer complete flag */
|
||||
#define LL_DMA_ISR_HTIF1 DMA_ISR_HTIF1 /*!< Channel 1 half transfer flag */
|
||||
#define LL_DMA_ISR_TEIF1 DMA_ISR_TEIF1 /*!< Channel 1 transfer error flag */
|
||||
#define LL_DMA_ISR_GIF2 DMA_ISR_GIF2 /*!< Channel 2 global flag */
|
||||
#define LL_DMA_ISR_TCIF2 DMA_ISR_TCIF2 /*!< Channel 2 transfer complete flag */
|
||||
#define LL_DMA_ISR_HTIF2 DMA_ISR_HTIF2 /*!< Channel 2 half transfer flag */
|
||||
#define LL_DMA_ISR_TEIF2 DMA_ISR_TEIF2 /*!< Channel 2 transfer error flag */
|
||||
#define LL_DMA_ISR_GIF3 DMA_ISR_GIF3 /*!< Channel 3 global flag */
|
||||
#define LL_DMA_ISR_TCIF3 DMA_ISR_TCIF3 /*!< Channel 3 transfer complete flag */
|
||||
#define LL_DMA_ISR_HTIF3 DMA_ISR_HTIF3 /*!< Channel 3 half transfer flag */
|
||||
#define LL_DMA_ISR_TEIF3 DMA_ISR_TEIF3 /*!< Channel 3 transfer error flag */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup DMA_LL_EC_IT IT Defines
|
||||
* @brief IT defines which can be used with LL_DMA_ReadReg and LL_DMA_WriteReg functions
|
||||
* @{
|
||||
*/
|
||||
#define LL_DMA_CCR_TCIE DMA_CCR_TCIE /*!< Transfer complete interrupt */
|
||||
#define LL_DMA_CCR_HTIE DMA_CCR_HTIE /*!< Half Transfer interrupt */
|
||||
#define LL_DMA_CCR_TEIE DMA_CCR_TEIE /*!< Transfer error interrupt */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup DMA_LL_EC_CHANNEL CHANNEL
|
||||
* @{
|
||||
*/
|
||||
#define LL_DMA_CHANNEL_1 0x00000001U /*!< DMA Channel 1 */
|
||||
#define LL_DMA_CHANNEL_2 0x00000002U /*!< DMA Channel 2 */
|
||||
#define LL_DMA_CHANNEL_3 0x00000003U /*!< DMA Channel 3 */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup DMA_LL_EC_DIRECTION Transfer Direction
|
||||
* @{
|
||||
*/
|
||||
#define LL_DMA_DIRECTION_PERIPH_TO_MEMORY 0x00000000U /*!< Peripheral to memory direction */
|
||||
#define LL_DMA_DIRECTION_MEMORY_TO_PERIPH DMA_CCR_DIR /*!< Memory to peripheral direction */
|
||||
#define LL_DMA_DIRECTION_MEMORY_TO_MEMORY DMA_CCR_MEM2MEM /*!< Memory to memory direction */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup DMA_LL_EC_MODE Transfer mode
|
||||
* @{
|
||||
*/
|
||||
#define LL_DMA_MODE_NORMAL 0x00000000U /*!< Normal Mode */
|
||||
#define LL_DMA_MODE_CIRCULAR DMA_CCR_CIRC /*!< Circular Mode */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup DMA_LL_EC_PERIPH Peripheral increment mode
|
||||
* @{
|
||||
*/
|
||||
#define LL_DMA_PERIPH_INCREMENT DMA_CCR_PINC /*!< Peripheral increment mode Enable */
|
||||
#define LL_DMA_PERIPH_NOINCREMENT 0x00000000U /*!< Peripheral increment mode Disable */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup DMA_LL_EC_MEMORY Memory increment mode
|
||||
* @{
|
||||
*/
|
||||
#define LL_DMA_MEMORY_INCREMENT DMA_CCR_MINC /*!< Memory increment mode Enable */
|
||||
#define LL_DMA_MEMORY_NOINCREMENT 0x00000000U /*!< Memory increment mode Disable */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup DMA_LL_EC_PDATAALIGN Peripheral data alignment
|
||||
* @{
|
||||
*/
|
||||
#define LL_DMA_PDATAALIGN_BYTE 0x00000000U /*!< Peripheral data alignment : Byte */
|
||||
#define LL_DMA_PDATAALIGN_HALFWORD DMA_CCR_PSIZE_0 /*!< Peripheral data alignment : HalfWord */
|
||||
#define LL_DMA_PDATAALIGN_WORD DMA_CCR_PSIZE_1 /*!< Peripheral data alignment : Word */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup DMA_LL_EC_MDATAALIGN Memory data alignment
|
||||
* @{
|
||||
*/
|
||||
#define LL_DMA_MDATAALIGN_BYTE 0x00000000U /*!< Memory data alignment : Byte */
|
||||
#define LL_DMA_MDATAALIGN_HALFWORD DMA_CCR_MSIZE_0 /*!< Memory data alignment : HalfWord */
|
||||
#define LL_DMA_MDATAALIGN_WORD DMA_CCR_MSIZE_1 /*!< Memory data alignment : Word */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup DMA_LL_EC_PRIORITY Transfer Priority level
|
||||
* @{
|
||||
*/
|
||||
#define LL_DMA_PRIORITY_LOW 0x00000000U /*!< Priority level : Low */
|
||||
#define LL_DMA_PRIORITY_MEDIUM DMA_CCR_PL_0 /*!< Priority level : Medium */
|
||||
#define LL_DMA_PRIORITY_HIGH DMA_CCR_PL_1 /*!< Priority level : High */
|
||||
#define LL_DMA_PRIORITY_VERYHIGH DMA_CCR_PL /*!< Priority level : Very_High */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/** @defgroup DMA_LL_Exported_Macros DMA Exported Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup DMA_LL_EM_WRITE_READ Common Write and read registers macros
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief Write a value in DMA register
|
||||
* @param __INSTANCE__ DMA Instance
|
||||
* @param __REG__ Register to be written
|
||||
* @param __VALUE__ Value to be written in the register
|
||||
* @retval None
|
||||
*/
|
||||
#define LL_DMA_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
|
||||
|
||||
/**
|
||||
* @brief Read a value in DMA register
|
||||
* @param __INSTANCE__ DMA Instance
|
||||
* @param __REG__ Register to be read
|
||||
* @retval Register value
|
||||
*/
|
||||
#define LL_DMA_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup DMA_LL_EM_CONVERT_DMAxCHANNELy Convert DMAxChannely
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Convert DMAx_Channely into DMAx
|
||||
* @param __CHANNEL_INSTANCE__ DMAx_Channely
|
||||
* @retval DMAx
|
||||
*/
|
||||
#define __LL_DMA_GET_INSTANCE(__CHANNEL_INSTANCE__) (DMA1)
|
||||
|
||||
/**
|
||||
* @brief Convert DMAx_Channely into LL_DMA_CHANNEL_y
|
||||
* @param __CHANNEL_INSTANCE__ DMAx_Channely
|
||||
* @retval LL_DMA_CHANNEL_y
|
||||
*/
|
||||
#define __LL_DMA_GET_CHANNEL(__CHANNEL_INSTANCE__) \
|
||||
(((uint32_t)(__CHANNEL_INSTANCE__) == ((uint32_t)DMA1_Channel1)) ? LL_DMA_CHANNEL_1 : \
|
||||
((uint32_t)(__CHANNEL_INSTANCE__) == ((uint32_t)DMA1_Channel2)) ? LL_DMA_CHANNEL_2 : \
|
||||
LL_DMA_CHANNEL_3 )
|
||||
|
||||
/**
|
||||
* @brief Convert DMA Instance DMAx and LL_DMA_CHANNEL_y into DMAx_Channely
|
||||
* @param __DMA_INSTANCE__ DMAx
|
||||
* @param __CHANNEL__ LL_DMA_CHANNEL_y
|
||||
* @retval DMAx_Channely
|
||||
*/
|
||||
#define __LL_DMA_GET_CHANNEL_INSTANCE(__DMA_INSTANCE__, __CHANNEL__) \
|
||||
((((uint32_t)(__DMA_INSTANCE__) == ((uint32_t)DMA1)) && ((uint32_t)(__CHANNEL__) == ((uint32_t)LL_DMA_CHANNEL_1))) ? DMA1_Channel1 : \
|
||||
(((uint32_t)(__DMA_INSTANCE__) == ((uint32_t)DMA1)) && ((uint32_t)(__CHANNEL__) == ((uint32_t)LL_DMA_CHANNEL_2))) ? DMA1_Channel2 : \
|
||||
DMA1_Channel3 )
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/** @defgroup DMA_LL_Exported_Functions DMA Exported Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup DMA_LL_EF_Configuration Configuration
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief Enable DMA channel.
|
||||
* @rmtoll CCR EN LL_DMA_EnableChannel
|
||||
* @param DMAx DMAx Instance
|
||||
* @param Channel This parameter can be one of the following values:
|
||||
* @arg @ref LL_DMA_CHANNEL_1
|
||||
* @arg @ref LL_DMA_CHANNEL_2
|
||||
* @arg @ref LL_DMA_CHANNEL_3
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_DMA_EnableChannel(DMA_TypeDef *DMAx, uint32_t Channel)
|
||||
{
|
||||
SET_BIT(((DMA_Channel_TypeDef *)((uint32_t)((uint32_t)DMAx + CHANNEL_OFFSET_TAB[Channel - 1U])))->CCR, DMA_CCR_EN);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable DMA channel.
|
||||
* @rmtoll CCR EN LL_DMA_DisableChannel
|
||||
* @param DMAx DMAx Instance
|
||||
* @param Channel This parameter can be one of the following values:
|
||||
* @arg @ref LL_DMA_CHANNEL_1
|
||||
* @arg @ref LL_DMA_CHANNEL_2
|
||||
* @arg @ref LL_DMA_CHANNEL_3
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_DMA_DisableChannel(DMA_TypeDef *DMAx, uint32_t Channel)
|
||||
{
|
||||
CLEAR_BIT(((DMA_Channel_TypeDef *)((uint32_t)((uint32_t)DMAx + CHANNEL_OFFSET_TAB[Channel - 1U])))->CCR, DMA_CCR_EN);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if DMA channel is enabled or disabled.
|
||||
* @rmtoll CCR EN LL_DMA_IsEnabledChannel
|
||||
* @param DMAx DMAx Instance
|
||||
* @param Channel This parameter can be one of the following values:
|
||||
* @arg @ref LL_DMA_CHANNEL_1
|
||||
* @arg @ref LL_DMA_CHANNEL_2
|
||||
* @arg @ref LL_DMA_CHANNEL_3
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_DMA_IsEnabledChannel(DMA_TypeDef *DMAx, uint32_t Channel)
|
||||
{
|
||||
return (READ_BIT(((DMA_Channel_TypeDef *)((uint32_t)((uint32_t)DMAx + CHANNEL_OFFSET_TAB[Channel - 1U])))->CCR,
|
||||
DMA_CCR_EN) == (DMA_CCR_EN));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure all parameters link to DMA transfer.
|
||||
* @rmtoll CCR DIR LL_DMA_ConfigTransfer\n
|
||||
* CCR MEM2MEM LL_DMA_ConfigTransfer\n
|
||||
* CCR CIRC LL_DMA_ConfigTransfer\n
|
||||
* CCR PINC LL_DMA_ConfigTransfer\n
|
||||
* CCR MINC LL_DMA_ConfigTransfer\n
|
||||
* CCR PSIZE LL_DMA_ConfigTransfer\n
|
||||
* CCR MSIZE LL_DMA_ConfigTransfer\n
|
||||
* CCR PL LL_DMA_ConfigTransfer
|
||||
* @param DMAx DMAx Instance
|
||||
* @param Channel This parameter can be one of the following values:
|
||||
* @arg @ref LL_DMA_CHANNEL_1
|
||||
* @arg @ref LL_DMA_CHANNEL_2
|
||||
* @arg @ref LL_DMA_CHANNEL_3
|
||||
* @param Configuration This parameter must be a combination of all the following values:
|
||||
* @arg @ref LL_DMA_DIRECTION_PERIPH_TO_MEMORY or @ref LL_DMA_DIRECTION_MEMORY_TO_PERIPH or @ref LL_DMA_DIRECTION_MEMORY_TO_MEMORY
|
||||
* @arg @ref LL_DMA_MODE_NORMAL or @ref LL_DMA_MODE_CIRCULAR
|
||||
* @arg @ref LL_DMA_PERIPH_INCREMENT or @ref LL_DMA_PERIPH_NOINCREMENT
|
||||
* @arg @ref LL_DMA_MEMORY_INCREMENT or @ref LL_DMA_MEMORY_NOINCREMENT
|
||||
* @arg @ref LL_DMA_PDATAALIGN_BYTE or @ref LL_DMA_PDATAALIGN_HALFWORD or @ref LL_DMA_PDATAALIGN_WORD
|
||||
* @arg @ref LL_DMA_MDATAALIGN_BYTE or @ref LL_DMA_MDATAALIGN_HALFWORD or @ref LL_DMA_MDATAALIGN_WORD
|
||||
* @arg @ref LL_DMA_PRIORITY_LOW or @ref LL_DMA_PRIORITY_MEDIUM or @ref LL_DMA_PRIORITY_HIGH or @ref LL_DMA_PRIORITY_VERYHIGH
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_DMA_ConfigTransfer(DMA_TypeDef *DMAx, uint32_t Channel, uint32_t Configuration)
|
||||
{
|
||||
MODIFY_REG(((DMA_Channel_TypeDef *)((uint32_t)((uint32_t)DMAx + CHANNEL_OFFSET_TAB[Channel - 1U])))->CCR,
|
||||
DMA_CCR_DIR | DMA_CCR_MEM2MEM | DMA_CCR_CIRC | DMA_CCR_PINC | DMA_CCR_MINC | DMA_CCR_PSIZE | DMA_CCR_MSIZE | DMA_CCR_PL,
|
||||
Configuration);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set Data transfer direction (read from peripheral or from memory).
|
||||
* @rmtoll CCR DIR LL_DMA_SetDataTransferDirection\n
|
||||
* CCR MEM2MEM LL_DMA_SetDataTransferDirection
|
||||
* @param DMAx DMAx Instance
|
||||
* @param Channel This parameter can be one of the following values:
|
||||
* @arg @ref LL_DMA_CHANNEL_1
|
||||
* @arg @ref LL_DMA_CHANNEL_2
|
||||
* @arg @ref LL_DMA_CHANNEL_3
|
||||
* @param Direction This parameter can be one of the following values:
|
||||
* @arg @ref LL_DMA_DIRECTION_PERIPH_TO_MEMORY
|
||||
* @arg @ref LL_DMA_DIRECTION_MEMORY_TO_PERIPH
|
||||
* @arg @ref LL_DMA_DIRECTION_MEMORY_TO_MEMORY
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_DMA_SetDataTransferDirection(DMA_TypeDef *DMAx, uint32_t Channel, uint32_t Direction)
|
||||
{
|
||||
MODIFY_REG(((DMA_Channel_TypeDef *)((uint32_t)((uint32_t)DMAx + CHANNEL_OFFSET_TAB[Channel - 1U])))->CCR,
|
||||
DMA_CCR_DIR | DMA_CCR_MEM2MEM, Direction);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get Data transfer direction (read from peripheral or from memory).
|
||||
* @rmtoll CCR DIR LL_DMA_GetDataTransferDirection\n
|
||||
* CCR MEM2MEM LL_DMA_GetDataTransferDirection
|
||||
* @param DMAx DMAx Instance
|
||||
* @param Channel This parameter can be one of the following values:
|
||||
* @arg @ref LL_DMA_CHANNEL_1
|
||||
* @arg @ref LL_DMA_CHANNEL_2
|
||||
* @arg @ref LL_DMA_CHANNEL_3
|
||||
* @retval Returned value can be one of the following values:
|
||||
* @arg @ref LL_DMA_DIRECTION_PERIPH_TO_MEMORY
|
||||
* @arg @ref LL_DMA_DIRECTION_MEMORY_TO_PERIPH
|
||||
* @arg @ref LL_DMA_DIRECTION_MEMORY_TO_MEMORY
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_DMA_GetDataTransferDirection(DMA_TypeDef *DMAx, uint32_t Channel)
|
||||
{
|
||||
return (READ_BIT(((DMA_Channel_TypeDef *)((uint32_t)((uint32_t)DMAx + CHANNEL_OFFSET_TAB[Channel - 1U])))->CCR,
|
||||
DMA_CCR_DIR | DMA_CCR_MEM2MEM));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set DMA mode circular or normal.
|
||||
* @note The circular buffer mode cannot be used if the memory-to-memory
|
||||
* data transfer is configured on the selected Channel.
|
||||
* @rmtoll CCR CIRC LL_DMA_SetMode
|
||||
* @param DMAx DMAx Instance
|
||||
* @param Channel This parameter can be one of the following values:
|
||||
* @arg @ref LL_DMA_CHANNEL_1
|
||||
* @arg @ref LL_DMA_CHANNEL_2
|
||||
* @arg @ref LL_DMA_CHANNEL_3
|
||||
* @param Mode This parameter can be one of the following values:
|
||||
* @arg @ref LL_DMA_MODE_NORMAL
|
||||
* @arg @ref LL_DMA_MODE_CIRCULAR
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_DMA_SetMode(DMA_TypeDef *DMAx, uint32_t Channel, uint32_t Mode)
|
||||
{
|
||||
MODIFY_REG(((DMA_Channel_TypeDef *)((uint32_t)((uint32_t)DMAx + CHANNEL_OFFSET_TAB[Channel - 1U])))->CCR, DMA_CCR_CIRC,
|
||||
Mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get DMA mode circular or normal.
|
||||
* @rmtoll CCR CIRC LL_DMA_GetMode
|
||||
* @param DMAx DMAx Instance
|
||||
* @param Channel This parameter can be one of the following values:
|
||||
* @arg @ref LL_DMA_CHANNEL_1
|
||||
* @arg @ref LL_DMA_CHANNEL_2
|
||||
* @arg @ref LL_DMA_CHANNEL_3
|
||||
* @retval Returned value can be one of the following values:
|
||||
* @arg @ref LL_DMA_MODE_NORMAL
|
||||
* @arg @ref LL_DMA_MODE_CIRCULAR
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_DMA_GetMode(DMA_TypeDef *DMAx, uint32_t Channel)
|
||||
{
|
||||
return (READ_BIT(((DMA_Channel_TypeDef *)((uint32_t)((uint32_t)DMAx + CHANNEL_OFFSET_TAB[Channel - 1U])))->CCR,
|
||||
DMA_CCR_CIRC));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set Peripheral increment mode.
|
||||
* @rmtoll CCR PINC LL_DMA_SetPeriphIncMode
|
||||
* @param DMAx DMAx Instance
|
||||
* @param Channel This parameter can be one of the following values:
|
||||
* @arg @ref LL_DMA_CHANNEL_1
|
||||
* @arg @ref LL_DMA_CHANNEL_2
|
||||
* @arg @ref LL_DMA_CHANNEL_3
|
||||
* @param PeriphOrM2MSrcIncMode This parameter can be one of the following values:
|
||||
* @arg @ref LL_DMA_PERIPH_INCREMENT
|
||||
* @arg @ref LL_DMA_PERIPH_NOINCREMENT
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_DMA_SetPeriphIncMode(DMA_TypeDef *DMAx, uint32_t Channel, uint32_t PeriphOrM2MSrcIncMode)
|
||||
{
|
||||
MODIFY_REG(((DMA_Channel_TypeDef *)((uint32_t)((uint32_t)DMAx + CHANNEL_OFFSET_TAB[Channel - 1U])))->CCR, DMA_CCR_PINC,
|
||||
PeriphOrM2MSrcIncMode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get Peripheral increment mode.
|
||||
* @rmtoll CCR PINC LL_DMA_GetPeriphIncMode
|
||||
* @param DMAx DMAx Instance
|
||||
* @param Channel This parameter can be one of the following values:
|
||||
* @arg @ref LL_DMA_CHANNEL_1
|
||||
* @arg @ref LL_DMA_CHANNEL_2
|
||||
* @arg @ref LL_DMA_CHANNEL_3
|
||||
* @retval Returned value can be one of the following values:
|
||||
* @arg @ref LL_DMA_PERIPH_INCREMENT
|
||||
* @arg @ref LL_DMA_PERIPH_NOINCREMENT
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_DMA_GetPeriphIncMode(DMA_TypeDef *DMAx, uint32_t Channel)
|
||||
{
|
||||
return (READ_BIT(((DMA_Channel_TypeDef *)((uint32_t)((uint32_t)DMAx + CHANNEL_OFFSET_TAB[Channel - 1U])))->CCR,
|
||||
DMA_CCR_PINC));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set Memory increment mode.
|
||||
* @rmtoll CCR MINC LL_DMA_SetMemoryIncMode
|
||||
* @param DMAx DMAx Instance
|
||||
* @param Channel This parameter can be one of the following values:
|
||||
* @arg @ref LL_DMA_CHANNEL_1
|
||||
* @arg @ref LL_DMA_CHANNEL_2
|
||||
* @arg @ref LL_DMA_CHANNEL_3
|
||||
* @param MemoryOrM2MDstIncMode This parameter can be one of the following values:
|
||||
* @arg @ref LL_DMA_MEMORY_INCREMENT
|
||||
* @arg @ref LL_DMA_MEMORY_NOINCREMENT
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_DMA_SetMemoryIncMode(DMA_TypeDef *DMAx, uint32_t Channel, uint32_t MemoryOrM2MDstIncMode)
|
||||
{
|
||||
MODIFY_REG(((DMA_Channel_TypeDef *)((uint32_t)((uint32_t)DMAx + CHANNEL_OFFSET_TAB[Channel - 1U])))->CCR, DMA_CCR_MINC,
|
||||
MemoryOrM2MDstIncMode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get Memory increment mode.
|
||||
* @rmtoll CCR MINC LL_DMA_GetMemoryIncMode
|
||||
* @param DMAx DMAx Instance
|
||||
* @param Channel This parameter can be one of the following values:
|
||||
* @arg @ref LL_DMA_CHANNEL_1
|
||||
* @arg @ref LL_DMA_CHANNEL_2
|
||||
* @arg @ref LL_DMA_CHANNEL_3
|
||||
* @retval Returned value can be one of the following values:
|
||||
* @arg @ref LL_DMA_MEMORY_INCREMENT
|
||||
* @arg @ref LL_DMA_MEMORY_NOINCREMENT
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_DMA_GetMemoryIncMode(DMA_TypeDef *DMAx, uint32_t Channel)
|
||||
{
|
||||
return (READ_BIT(((DMA_Channel_TypeDef *)((uint32_t)((uint32_t)DMAx + CHANNEL_OFFSET_TAB[Channel - 1U])))->CCR,
|
||||
DMA_CCR_MINC));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set Peripheral size.
|
||||
* @rmtoll CCR PSIZE LL_DMA_SetPeriphSize
|
||||
* @param DMAx DMAx Instance
|
||||
* @param Channel This parameter can be one of the following values:
|
||||
* @arg @ref LL_DMA_CHANNEL_1
|
||||
* @arg @ref LL_DMA_CHANNEL_2
|
||||
* @arg @ref LL_DMA_CHANNEL_3
|
||||
* @param PeriphOrM2MSrcDataSize This parameter can be one of the following values:
|
||||
* @arg @ref LL_DMA_PDATAALIGN_BYTE
|
||||
* @arg @ref LL_DMA_PDATAALIGN_HALFWORD
|
||||
* @arg @ref LL_DMA_PDATAALIGN_WORD
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_DMA_SetPeriphSize(DMA_TypeDef *DMAx, uint32_t Channel, uint32_t PeriphOrM2MSrcDataSize)
|
||||
{
|
||||
MODIFY_REG(((DMA_Channel_TypeDef *)((uint32_t)((uint32_t)DMAx + CHANNEL_OFFSET_TAB[Channel - 1U])))->CCR, DMA_CCR_PSIZE,
|
||||
PeriphOrM2MSrcDataSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get Peripheral size.
|
||||
* @rmtoll CCR PSIZE LL_DMA_GetPeriphSize
|
||||
* @param DMAx DMAx Instance
|
||||
* @param Channel This parameter can be one of the following values:
|
||||
* @arg @ref LL_DMA_CHANNEL_1
|
||||
* @arg @ref LL_DMA_CHANNEL_2
|
||||
* @arg @ref LL_DMA_CHANNEL_3
|
||||
* @retval Returned value can be one of the following values:
|
||||
* @arg @ref LL_DMA_PDATAALIGN_BYTE
|
||||
* @arg @ref LL_DMA_PDATAALIGN_HALFWORD
|
||||
* @arg @ref LL_DMA_PDATAALIGN_WORD
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_DMA_GetPeriphSize(DMA_TypeDef *DMAx, uint32_t Channel)
|
||||
{
|
||||
return (READ_BIT(((DMA_Channel_TypeDef *)((uint32_t)((uint32_t)DMAx + CHANNEL_OFFSET_TAB[Channel - 1U])))->CCR,
|
||||
DMA_CCR_PSIZE));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set Memory size.
|
||||
* @rmtoll CCR MSIZE LL_DMA_SetMemorySize
|
||||
* @param DMAx DMAx Instance
|
||||
* @param Channel This parameter can be one of the following values:
|
||||
* @arg @ref LL_DMA_CHANNEL_1
|
||||
* @arg @ref LL_DMA_CHANNEL_2
|
||||
* @arg @ref LL_DMA_CHANNEL_3
|
||||
* @param MemoryOrM2MDstDataSize This parameter can be one of the following values:
|
||||
* @arg @ref LL_DMA_MDATAALIGN_BYTE
|
||||
* @arg @ref LL_DMA_MDATAALIGN_HALFWORD
|
||||
* @arg @ref LL_DMA_MDATAALIGN_WORD
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_DMA_SetMemorySize(DMA_TypeDef *DMAx, uint32_t Channel, uint32_t MemoryOrM2MDstDataSize)
|
||||
{
|
||||
MODIFY_REG(((DMA_Channel_TypeDef *)((uint32_t)((uint32_t)DMAx + CHANNEL_OFFSET_TAB[Channel - 1U])))->CCR, DMA_CCR_MSIZE,
|
||||
MemoryOrM2MDstDataSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get Memory size.
|
||||
* @rmtoll CCR MSIZE LL_DMA_GetMemorySize
|
||||
* @param DMAx DMAx Instance
|
||||
* @param Channel This parameter can be one of the following values:
|
||||
* @arg @ref LL_DMA_CHANNEL_1
|
||||
* @arg @ref LL_DMA_CHANNEL_2
|
||||
* @arg @ref LL_DMA_CHANNEL_3
|
||||
* @retval Returned value can be one of the following values:
|
||||
* @arg @ref LL_DMA_MDATAALIGN_BYTE
|
||||
* @arg @ref LL_DMA_MDATAALIGN_HALFWORD
|
||||
* @arg @ref LL_DMA_MDATAALIGN_WORD
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_DMA_GetMemorySize(DMA_TypeDef *DMAx, uint32_t Channel)
|
||||
{
|
||||
return (READ_BIT(((DMA_Channel_TypeDef *)((uint32_t)((uint32_t)DMAx + CHANNEL_OFFSET_TAB[Channel - 1U])))->CCR,
|
||||
DMA_CCR_MSIZE));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set Channel priority level.
|
||||
* @rmtoll CCR PL LL_DMA_SetChannelPriorityLevel
|
||||
* @param DMAx DMAx Instance
|
||||
* @param Channel This parameter can be one of the following values:
|
||||
* @arg @ref LL_DMA_CHANNEL_1
|
||||
* @arg @ref LL_DMA_CHANNEL_2
|
||||
* @arg @ref LL_DMA_CHANNEL_3
|
||||
* @param Priority This parameter can be one of the following values:
|
||||
* @arg @ref LL_DMA_PRIORITY_LOW
|
||||
* @arg @ref LL_DMA_PRIORITY_MEDIUM
|
||||
* @arg @ref LL_DMA_PRIORITY_HIGH
|
||||
* @arg @ref LL_DMA_PRIORITY_VERYHIGH
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_DMA_SetChannelPriorityLevel(DMA_TypeDef *DMAx, uint32_t Channel, uint32_t Priority)
|
||||
{
|
||||
MODIFY_REG(((DMA_Channel_TypeDef *)((uint32_t)((uint32_t)DMAx + CHANNEL_OFFSET_TAB[Channel - 1U])))->CCR, DMA_CCR_PL,
|
||||
Priority);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get Channel priority level.
|
||||
* @rmtoll CCR PL LL_DMA_GetChannelPriorityLevel
|
||||
* @param DMAx DMAx Instance
|
||||
* @param Channel This parameter can be one of the following values:
|
||||
* @arg @ref LL_DMA_CHANNEL_1
|
||||
* @arg @ref LL_DMA_CHANNEL_2
|
||||
* @arg @ref LL_DMA_CHANNEL_3
|
||||
* @retval Returned value can be one of the following values:
|
||||
* @arg @ref LL_DMA_PRIORITY_LOW
|
||||
* @arg @ref LL_DMA_PRIORITY_MEDIUM
|
||||
* @arg @ref LL_DMA_PRIORITY_HIGH
|
||||
* @arg @ref LL_DMA_PRIORITY_VERYHIGH
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_DMA_GetChannelPriorityLevel(DMA_TypeDef *DMAx, uint32_t Channel)
|
||||
{
|
||||
return (READ_BIT(((DMA_Channel_TypeDef *)((uint32_t)((uint32_t)DMAx + CHANNEL_OFFSET_TAB[Channel - 1U])))->CCR,
|
||||
DMA_CCR_PL));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set Number of data to transfer.
|
||||
* @note This action has no effect if
|
||||
* channel is enabled.
|
||||
* @rmtoll CNDTR NDT LL_DMA_SetDataLength
|
||||
* @param DMAx DMAx Instance
|
||||
* @param Channel This parameter can be one of the following values:
|
||||
* @arg @ref LL_DMA_CHANNEL_1
|
||||
* @arg @ref LL_DMA_CHANNEL_2
|
||||
* @arg @ref LL_DMA_CHANNEL_3
|
||||
* @param NbData Between Min_Data = 0 and Max_Data = 0x0000FFFF
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_DMA_SetDataLength(DMA_TypeDef *DMAx, uint32_t Channel, uint32_t NbData)
|
||||
{
|
||||
MODIFY_REG(((DMA_Channel_TypeDef *)((uint32_t)((uint32_t)DMAx + CHANNEL_OFFSET_TAB[Channel - 1U])))->CNDTR,
|
||||
DMA_CNDTR_NDT, NbData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get Number of data to transfer.
|
||||
* @note Once the channel is enabled, the return value indicate the
|
||||
* remaining bytes to be transmitted.
|
||||
* @rmtoll CNDTR NDT LL_DMA_GetDataLength
|
||||
* @param DMAx DMAx Instance
|
||||
* @param Channel This parameter can be one of the following values:
|
||||
* @arg @ref LL_DMA_CHANNEL_1
|
||||
* @arg @ref LL_DMA_CHANNEL_2
|
||||
* @arg @ref LL_DMA_CHANNEL_3
|
||||
* @retval Between Min_Data = 0 and Max_Data = 0xFFFFFFFF
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_DMA_GetDataLength(DMA_TypeDef *DMAx, uint32_t Channel)
|
||||
{
|
||||
return (READ_BIT(((DMA_Channel_TypeDef *)((uint32_t)((uint32_t)DMAx + CHANNEL_OFFSET_TAB[Channel - 1U])))->CNDTR,
|
||||
DMA_CNDTR_NDT));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure the Source and Destination addresses.
|
||||
* @note This API must not be called when the DMA channel is enabled.
|
||||
* @note Each IP using DMA provides an API to get directly the register adress (LL_PPP_DMA_GetRegAddr).
|
||||
* @rmtoll CPAR PA LL_DMA_ConfigAddresses\n
|
||||
* CMAR MA LL_DMA_ConfigAddresses
|
||||
* @param DMAx DMAx Instance
|
||||
* @param Channel This parameter can be one of the following values:
|
||||
* @arg @ref LL_DMA_CHANNEL_1
|
||||
* @arg @ref LL_DMA_CHANNEL_2
|
||||
* @arg @ref LL_DMA_CHANNEL_3
|
||||
* @param SrcAddress Between Min_Data = 0 and Max_Data = 0xFFFFFFFF
|
||||
* @param DstAddress Between Min_Data = 0 and Max_Data = 0xFFFFFFFF
|
||||
* @param Direction This parameter can be one of the following values:
|
||||
* @arg @ref LL_DMA_DIRECTION_PERIPH_TO_MEMORY
|
||||
* @arg @ref LL_DMA_DIRECTION_MEMORY_TO_PERIPH
|
||||
* @arg @ref LL_DMA_DIRECTION_MEMORY_TO_MEMORY
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_DMA_ConfigAddresses(DMA_TypeDef *DMAx, uint32_t Channel, uint32_t SrcAddress,
|
||||
uint32_t DstAddress, uint32_t Direction)
|
||||
{
|
||||
/* Direction Memory to Periph */
|
||||
if (Direction == LL_DMA_DIRECTION_MEMORY_TO_PERIPH)
|
||||
{
|
||||
WRITE_REG(((DMA_Channel_TypeDef *)((uint32_t)((uint32_t)DMAx + CHANNEL_OFFSET_TAB[Channel - 1U])))->CMAR, SrcAddress);
|
||||
WRITE_REG(((DMA_Channel_TypeDef *)((uint32_t)((uint32_t)DMAx + CHANNEL_OFFSET_TAB[Channel - 1U])))->CPAR, DstAddress);
|
||||
}
|
||||
/* Direction Periph to Memory and Memory to Memory */
|
||||
else
|
||||
{
|
||||
WRITE_REG(((DMA_Channel_TypeDef *)((uint32_t)((uint32_t)DMAx + CHANNEL_OFFSET_TAB[Channel - 1U])))->CPAR, SrcAddress);
|
||||
WRITE_REG(((DMA_Channel_TypeDef *)((uint32_t)((uint32_t)DMAx + CHANNEL_OFFSET_TAB[Channel - 1U])))->CMAR, DstAddress);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the Memory address.
|
||||
* @note Interface used for direction LL_DMA_DIRECTION_PERIPH_TO_MEMORY or LL_DMA_DIRECTION_MEMORY_TO_PERIPH only.
|
||||
* @note This API must not be called when the DMA channel is enabled.
|
||||
* @rmtoll CMAR MA LL_DMA_SetMemoryAddress
|
||||
* @param DMAx DMAx Instance
|
||||
* @param Channel This parameter can be one of the following values:
|
||||
* @arg @ref LL_DMA_CHANNEL_1
|
||||
* @arg @ref LL_DMA_CHANNEL_2
|
||||
* @arg @ref LL_DMA_CHANNEL_3
|
||||
* @param MemoryAddress Between Min_Data = 0 and Max_Data = 0xFFFFFFFF
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_DMA_SetMemoryAddress(DMA_TypeDef *DMAx, uint32_t Channel, uint32_t MemoryAddress)
|
||||
{
|
||||
WRITE_REG(((DMA_Channel_TypeDef *)((uint32_t)((uint32_t)DMAx + CHANNEL_OFFSET_TAB[Channel - 1U])))->CMAR, MemoryAddress);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the Peripheral address.
|
||||
* @note Interface used for direction LL_DMA_DIRECTION_PERIPH_TO_MEMORY or LL_DMA_DIRECTION_MEMORY_TO_PERIPH only.
|
||||
* @note This API must not be called when the DMA channel is enabled.
|
||||
* @rmtoll CPAR PA LL_DMA_SetPeriphAddress
|
||||
* @param DMAx DMAx Instance
|
||||
* @param Channel This parameter can be one of the following values:
|
||||
* @arg @ref LL_DMA_CHANNEL_1
|
||||
* @arg @ref LL_DMA_CHANNEL_2
|
||||
* @arg @ref LL_DMA_CHANNEL_3
|
||||
* @param PeriphAddress Between Min_Data = 0 and Max_Data = 0xFFFFFFFF
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_DMA_SetPeriphAddress(DMA_TypeDef *DMAx, uint32_t Channel, uint32_t PeriphAddress)
|
||||
{
|
||||
WRITE_REG(((DMA_Channel_TypeDef *)((uint32_t)((uint32_t)DMAx + CHANNEL_OFFSET_TAB[Channel - 1U])))->CPAR, PeriphAddress);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get Memory address.
|
||||
* @note Interface used for direction LL_DMA_DIRECTION_PERIPH_TO_MEMORY or LL_DMA_DIRECTION_MEMORY_TO_PERIPH only.
|
||||
* @rmtoll CMAR MA LL_DMA_GetMemoryAddress
|
||||
* @param DMAx DMAx Instance
|
||||
* @param Channel This parameter can be one of the following values:
|
||||
* @arg @ref LL_DMA_CHANNEL_1
|
||||
* @arg @ref LL_DMA_CHANNEL_2
|
||||
* @arg @ref LL_DMA_CHANNEL_3
|
||||
* @retval Between Min_Data = 0 and Max_Data = 0xFFFFFFFF
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_DMA_GetMemoryAddress(DMA_TypeDef *DMAx, uint32_t Channel)
|
||||
{
|
||||
return (READ_REG(((DMA_Channel_TypeDef *)((uint32_t)((uint32_t)DMAx + CHANNEL_OFFSET_TAB[Channel - 1U])))->CMAR));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get Peripheral address.
|
||||
* @note Interface used for direction LL_DMA_DIRECTION_PERIPH_TO_MEMORY or LL_DMA_DIRECTION_MEMORY_TO_PERIPH only.
|
||||
* @rmtoll CPAR PA LL_DMA_GetPeriphAddress
|
||||
* @param DMAx DMAx Instance
|
||||
* @param Channel This parameter can be one of the following values:
|
||||
* @arg @ref LL_DMA_CHANNEL_1
|
||||
* @arg @ref LL_DMA_CHANNEL_2
|
||||
* @arg @ref LL_DMA_CHANNEL_3
|
||||
* @retval Between Min_Data = 0 and Max_Data = 0xFFFFFFFF
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_DMA_GetPeriphAddress(DMA_TypeDef *DMAx, uint32_t Channel)
|
||||
{
|
||||
return (READ_REG(((DMA_Channel_TypeDef *)((uint32_t)((uint32_t)DMAx + CHANNEL_OFFSET_TAB[Channel - 1U])))->CPAR));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the Memory to Memory Source address.
|
||||
* @note Interface used for direction LL_DMA_DIRECTION_MEMORY_TO_MEMORY only.
|
||||
* @note This API must not be called when the DMA channel is enabled.
|
||||
* @rmtoll CPAR PA LL_DMA_SetM2MSrcAddress
|
||||
* @param DMAx DMAx Instance
|
||||
* @param Channel This parameter can be one of the following values:
|
||||
* @arg @ref LL_DMA_CHANNEL_1
|
||||
* @arg @ref LL_DMA_CHANNEL_2
|
||||
* @arg @ref LL_DMA_CHANNEL_3
|
||||
* @param MemoryAddress Between Min_Data = 0 and Max_Data = 0xFFFFFFFF
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_DMA_SetM2MSrcAddress(DMA_TypeDef *DMAx, uint32_t Channel, uint32_t MemoryAddress)
|
||||
{
|
||||
WRITE_REG(((DMA_Channel_TypeDef *)((uint32_t)((uint32_t)DMAx + CHANNEL_OFFSET_TAB[Channel - 1U])))->CPAR, MemoryAddress);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the Memory to Memory Destination address.
|
||||
* @note Interface used for direction LL_DMA_DIRECTION_MEMORY_TO_MEMORY only.
|
||||
* @note This API must not be called when the DMA channel is enabled.
|
||||
* @rmtoll CMAR MA LL_DMA_SetM2MDstAddress
|
||||
* @param DMAx DMAx Instance
|
||||
* @param Channel This parameter can be one of the following values:
|
||||
* @arg @ref LL_DMA_CHANNEL_1
|
||||
* @arg @ref LL_DMA_CHANNEL_2
|
||||
* @arg @ref LL_DMA_CHANNEL_3
|
||||
* @param MemoryAddress Between Min_Data = 0 and Max_Data = 0xFFFFFFFF
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_DMA_SetM2MDstAddress(DMA_TypeDef *DMAx, uint32_t Channel, uint32_t MemoryAddress)
|
||||
{
|
||||
WRITE_REG(((DMA_Channel_TypeDef *)((uint32_t)((uint32_t)DMAx + CHANNEL_OFFSET_TAB[Channel - 1U])))->CMAR, MemoryAddress);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the Memory to Memory Source address.
|
||||
* @note Interface used for direction LL_DMA_DIRECTION_MEMORY_TO_MEMORY only.
|
||||
* @rmtoll CPAR PA LL_DMA_GetM2MSrcAddress
|
||||
* @param DMAx DMAx Instance
|
||||
* @param Channel This parameter can be one of the following values:
|
||||
* @arg @ref LL_DMA_CHANNEL_1
|
||||
* @arg @ref LL_DMA_CHANNEL_2
|
||||
* @arg @ref LL_DMA_CHANNEL_3
|
||||
* @retval Between Min_Data = 0 and Max_Data = 0xFFFFFFFF
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_DMA_GetM2MSrcAddress(DMA_TypeDef *DMAx, uint32_t Channel)
|
||||
{
|
||||
return (READ_REG(((DMA_Channel_TypeDef *)((uint32_t)((uint32_t)DMAx + CHANNEL_OFFSET_TAB[Channel - 1U])))->CPAR));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the Memory to Memory Destination address.
|
||||
* @note Interface used for direction LL_DMA_DIRECTION_MEMORY_TO_MEMORY only.
|
||||
* @rmtoll CMAR MA LL_DMA_GetM2MDstAddress
|
||||
* @param DMAx DMAx Instance
|
||||
* @param Channel This parameter can be one of the following values:
|
||||
* @arg @ref LL_DMA_CHANNEL_1
|
||||
* @arg @ref LL_DMA_CHANNEL_2
|
||||
* @arg @ref LL_DMA_CHANNEL_3
|
||||
* @retval Between Min_Data = 0 and Max_Data = 0xFFFFFFFF
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_DMA_GetM2MDstAddress(DMA_TypeDef *DMAx, uint32_t Channel)
|
||||
{
|
||||
return (READ_REG(((DMA_Channel_TypeDef *)((uint32_t)((uint32_t)DMAx + CHANNEL_OFFSET_TAB[Channel - 1U])))->CMAR));
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup DMA_LL_EF_FLAG_Management FLAG_Management
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Get Channel 1 global interrupt flag.
|
||||
* @rmtoll ISR GIF1 LL_DMA_IsActiveFlag_GI1
|
||||
* @param DMAx DMAx Instance
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_DMA_IsActiveFlag_GI1(DMA_TypeDef *DMAx)
|
||||
{
|
||||
return (READ_BIT(DMAx->ISR, DMA_ISR_GIF1) == (DMA_ISR_GIF1));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get Channel 2 global interrupt flag.
|
||||
* @rmtoll ISR GIF2 LL_DMA_IsActiveFlag_GI2
|
||||
* @param DMAx DMAx Instance
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_DMA_IsActiveFlag_GI2(DMA_TypeDef *DMAx)
|
||||
{
|
||||
return (READ_BIT(DMAx->ISR, DMA_ISR_GIF2) == (DMA_ISR_GIF2));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get Channel 3 global interrupt flag.
|
||||
* @rmtoll ISR GIF3 LL_DMA_IsActiveFlag_GI3
|
||||
* @param DMAx DMAx Instance
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_DMA_IsActiveFlag_GI3(DMA_TypeDef *DMAx)
|
||||
{
|
||||
return (READ_BIT(DMAx->ISR, DMA_ISR_GIF3) == (DMA_ISR_GIF3));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get Channel 1 transfer complete flag.
|
||||
* @rmtoll ISR TCIF1 LL_DMA_IsActiveFlag_TC1
|
||||
* @param DMAx DMAx Instance
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_DMA_IsActiveFlag_TC1(DMA_TypeDef *DMAx)
|
||||
{
|
||||
return (READ_BIT(DMAx->ISR, DMA_ISR_TCIF1) == (DMA_ISR_TCIF1));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get Channel 2 transfer complete flag.
|
||||
* @rmtoll ISR TCIF2 LL_DMA_IsActiveFlag_TC2
|
||||
* @param DMAx DMAx Instance
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_DMA_IsActiveFlag_TC2(DMA_TypeDef *DMAx)
|
||||
{
|
||||
return (READ_BIT(DMAx->ISR, DMA_ISR_TCIF2) == (DMA_ISR_TCIF2));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get Channel 3 transfer complete flag.
|
||||
* @rmtoll ISR TCIF3 LL_DMA_IsActiveFlag_TC3
|
||||
* @param DMAx DMAx Instance
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_DMA_IsActiveFlag_TC3(DMA_TypeDef *DMAx)
|
||||
{
|
||||
return (READ_BIT(DMAx->ISR, DMA_ISR_TCIF3) == (DMA_ISR_TCIF3));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get Channel 1 half transfer flag.
|
||||
* @rmtoll ISR HTIF1 LL_DMA_IsActiveFlag_HT1
|
||||
* @param DMAx DMAx Instance
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_DMA_IsActiveFlag_HT1(DMA_TypeDef *DMAx)
|
||||
{
|
||||
return (READ_BIT(DMAx->ISR, DMA_ISR_HTIF1) == (DMA_ISR_HTIF1));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get Channel 2 half transfer flag.
|
||||
* @rmtoll ISR HTIF2 LL_DMA_IsActiveFlag_HT2
|
||||
* @param DMAx DMAx Instance
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_DMA_IsActiveFlag_HT2(DMA_TypeDef *DMAx)
|
||||
{
|
||||
return (READ_BIT(DMAx->ISR, DMA_ISR_HTIF2) == (DMA_ISR_HTIF2));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get Channel 3 half transfer flag.
|
||||
* @rmtoll ISR HTIF3 LL_DMA_IsActiveFlag_HT3
|
||||
* @param DMAx DMAx Instance
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_DMA_IsActiveFlag_HT3(DMA_TypeDef *DMAx)
|
||||
{
|
||||
return (READ_BIT(DMAx->ISR, DMA_ISR_HTIF3) == (DMA_ISR_HTIF3));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get Channel 1 transfer error flag.
|
||||
* @rmtoll ISR TEIF1 LL_DMA_IsActiveFlag_TE1
|
||||
* @param DMAx DMAx Instance
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_DMA_IsActiveFlag_TE1(DMA_TypeDef *DMAx)
|
||||
{
|
||||
return (READ_BIT(DMAx->ISR, DMA_ISR_TEIF1) == (DMA_ISR_TEIF1));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get Channel 2 transfer error flag.
|
||||
* @rmtoll ISR TEIF2 LL_DMA_IsActiveFlag_TE2
|
||||
* @param DMAx DMAx Instance
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_DMA_IsActiveFlag_TE2(DMA_TypeDef *DMAx)
|
||||
{
|
||||
return (READ_BIT(DMAx->ISR, DMA_ISR_TEIF2) == (DMA_ISR_TEIF2));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get Channel 3 transfer error flag.
|
||||
* @rmtoll ISR TEIF3 LL_DMA_IsActiveFlag_TE3
|
||||
* @param DMAx DMAx Instance
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_DMA_IsActiveFlag_TE3(DMA_TypeDef *DMAx)
|
||||
{
|
||||
return (READ_BIT(DMAx->ISR, DMA_ISR_TEIF3) == (DMA_ISR_TEIF3));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear Channel 1 global interrupt flag.
|
||||
* @rmtoll IFCR CGIF1 LL_DMA_ClearFlag_GI1
|
||||
* @param DMAx DMAx Instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_DMA_ClearFlag_GI1(DMA_TypeDef *DMAx)
|
||||
{
|
||||
WRITE_REG(DMAx->IFCR, DMA_IFCR_CGIF1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear Channel 2 global interrupt flag.
|
||||
* @rmtoll IFCR CGIF2 LL_DMA_ClearFlag_GI2
|
||||
* @param DMAx DMAx Instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_DMA_ClearFlag_GI2(DMA_TypeDef *DMAx)
|
||||
{
|
||||
WRITE_REG(DMAx->IFCR, DMA_IFCR_CGIF2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear Channel 3 global interrupt flag.
|
||||
* @rmtoll IFCR CGIF3 LL_DMA_ClearFlag_GI3
|
||||
* @param DMAx DMAx Instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_DMA_ClearFlag_GI3(DMA_TypeDef *DMAx)
|
||||
{
|
||||
WRITE_REG(DMAx->IFCR, DMA_IFCR_CGIF3);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear Channel 1 transfer complete flag.
|
||||
* @rmtoll IFCR CTCIF1 LL_DMA_ClearFlag_TC1
|
||||
* @param DMAx DMAx Instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_DMA_ClearFlag_TC1(DMA_TypeDef *DMAx)
|
||||
{
|
||||
WRITE_REG(DMAx->IFCR, DMA_IFCR_CTCIF1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear Channel 2 transfer complete flag.
|
||||
* @rmtoll IFCR CTCIF2 LL_DMA_ClearFlag_TC2
|
||||
* @param DMAx DMAx Instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_DMA_ClearFlag_TC2(DMA_TypeDef *DMAx)
|
||||
{
|
||||
WRITE_REG(DMAx->IFCR, DMA_IFCR_CTCIF2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear Channel 3 transfer complete flag.
|
||||
* @rmtoll IFCR CTCIF3 LL_DMA_ClearFlag_TC3
|
||||
* @param DMAx DMAx Instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_DMA_ClearFlag_TC3(DMA_TypeDef *DMAx)
|
||||
{
|
||||
WRITE_REG(DMAx->IFCR, DMA_IFCR_CTCIF3);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear Channel 1 half transfer flag.
|
||||
* @rmtoll IFCR CHTIF1 LL_DMA_ClearFlag_HT1
|
||||
* @param DMAx DMAx Instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_DMA_ClearFlag_HT1(DMA_TypeDef *DMAx)
|
||||
{
|
||||
WRITE_REG(DMAx->IFCR, DMA_IFCR_CHTIF1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear Channel 2 half transfer flag.
|
||||
* @rmtoll IFCR CHTIF2 LL_DMA_ClearFlag_HT2
|
||||
* @param DMAx DMAx Instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_DMA_ClearFlag_HT2(DMA_TypeDef *DMAx)
|
||||
{
|
||||
WRITE_REG(DMAx->IFCR, DMA_IFCR_CHTIF2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear Channel 3 half transfer flag.
|
||||
* @rmtoll IFCR CHTIF3 LL_DMA_ClearFlag_HT3
|
||||
* @param DMAx DMAx Instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_DMA_ClearFlag_HT3(DMA_TypeDef *DMAx)
|
||||
{
|
||||
WRITE_REG(DMAx->IFCR, DMA_IFCR_CHTIF3);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear Channel 1 transfer error flag.
|
||||
* @rmtoll IFCR CTEIF1 LL_DMA_ClearFlag_TE1
|
||||
* @param DMAx DMAx Instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_DMA_ClearFlag_TE1(DMA_TypeDef *DMAx)
|
||||
{
|
||||
WRITE_REG(DMAx->IFCR, DMA_IFCR_CTEIF1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear Channel 2 transfer error flag.
|
||||
* @rmtoll IFCR CTEIF2 LL_DMA_ClearFlag_TE2
|
||||
* @param DMAx DMAx Instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_DMA_ClearFlag_TE2(DMA_TypeDef *DMAx)
|
||||
{
|
||||
WRITE_REG(DMAx->IFCR, DMA_IFCR_CTEIF2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear Channel 3 transfer error flag.
|
||||
* @rmtoll IFCR CTEIF3 LL_DMA_ClearFlag_TE3
|
||||
* @param DMAx DMAx Instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_DMA_ClearFlag_TE3(DMA_TypeDef *DMAx)
|
||||
{
|
||||
WRITE_REG(DMAx->IFCR, DMA_IFCR_CTEIF3);
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup DMA_LL_EF_IT_Management IT_Management
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Enable Transfer complete interrupt.
|
||||
* @rmtoll CCR TCIE LL_DMA_EnableIT_TC
|
||||
* @param DMAx DMAx Instance
|
||||
* @param Channel This parameter can be one of the following values:
|
||||
* @arg @ref LL_DMA_CHANNEL_1
|
||||
* @arg @ref LL_DMA_CHANNEL_2
|
||||
* @arg @ref LL_DMA_CHANNEL_3
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_DMA_EnableIT_TC(DMA_TypeDef *DMAx, uint32_t Channel)
|
||||
{
|
||||
SET_BIT(((DMA_Channel_TypeDef *)((uint32_t)((uint32_t)DMAx + CHANNEL_OFFSET_TAB[Channel - 1U])))->CCR, DMA_CCR_TCIE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable Half transfer interrupt.
|
||||
* @rmtoll CCR HTIE LL_DMA_EnableIT_HT
|
||||
* @param DMAx DMAx Instance
|
||||
* @param Channel This parameter can be one of the following values:
|
||||
* @arg @ref LL_DMA_CHANNEL_1
|
||||
* @arg @ref LL_DMA_CHANNEL_2
|
||||
* @arg @ref LL_DMA_CHANNEL_3
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_DMA_EnableIT_HT(DMA_TypeDef *DMAx, uint32_t Channel)
|
||||
{
|
||||
SET_BIT(((DMA_Channel_TypeDef *)((uint32_t)((uint32_t)DMAx + CHANNEL_OFFSET_TAB[Channel - 1U])))->CCR, DMA_CCR_HTIE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable Transfer error interrupt.
|
||||
* @rmtoll CCR TEIE LL_DMA_EnableIT_TE
|
||||
* @param DMAx DMAx Instance
|
||||
* @param Channel This parameter can be one of the following values:
|
||||
* @arg @ref LL_DMA_CHANNEL_1
|
||||
* @arg @ref LL_DMA_CHANNEL_2
|
||||
* @arg @ref LL_DMA_CHANNEL_3
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_DMA_EnableIT_TE(DMA_TypeDef *DMAx, uint32_t Channel)
|
||||
{
|
||||
SET_BIT(((DMA_Channel_TypeDef *)((uint32_t)((uint32_t)DMAx + CHANNEL_OFFSET_TAB[Channel - 1U])))->CCR, DMA_CCR_TEIE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable Transfer complete interrupt.
|
||||
* @rmtoll CCR TCIE LL_DMA_DisableIT_TC
|
||||
* @param DMAx DMAx Instance
|
||||
* @param Channel This parameter can be one of the following values:
|
||||
* @arg @ref LL_DMA_CHANNEL_1
|
||||
* @arg @ref LL_DMA_CHANNEL_2
|
||||
* @arg @ref LL_DMA_CHANNEL_3
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_DMA_DisableIT_TC(DMA_TypeDef *DMAx, uint32_t Channel)
|
||||
{
|
||||
CLEAR_BIT(((DMA_Channel_TypeDef *)((uint32_t)((uint32_t)DMAx + CHANNEL_OFFSET_TAB[Channel - 1U])))->CCR, DMA_CCR_TCIE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable Half transfer interrupt.
|
||||
* @rmtoll CCR HTIE LL_DMA_DisableIT_HT
|
||||
* @param DMAx DMAx Instance
|
||||
* @param Channel This parameter can be one of the following values:
|
||||
* @arg @ref LL_DMA_CHANNEL_1
|
||||
* @arg @ref LL_DMA_CHANNEL_2
|
||||
* @arg @ref LL_DMA_CHANNEL_3
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_DMA_DisableIT_HT(DMA_TypeDef *DMAx, uint32_t Channel)
|
||||
{
|
||||
CLEAR_BIT(((DMA_Channel_TypeDef *)((uint32_t)((uint32_t)DMAx + CHANNEL_OFFSET_TAB[Channel - 1U])))->CCR, DMA_CCR_HTIE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable Transfer error interrupt.
|
||||
* @rmtoll CCR TEIE LL_DMA_DisableIT_TE
|
||||
* @param DMAx DMAx Instance
|
||||
* @param Channel This parameter can be one of the following values:
|
||||
* @arg @ref LL_DMA_CHANNEL_1
|
||||
* @arg @ref LL_DMA_CHANNEL_2
|
||||
* @arg @ref LL_DMA_CHANNEL_3
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_DMA_DisableIT_TE(DMA_TypeDef *DMAx, uint32_t Channel)
|
||||
{
|
||||
CLEAR_BIT(((DMA_Channel_TypeDef *)((uint32_t)((uint32_t)DMAx + CHANNEL_OFFSET_TAB[Channel - 1U])))->CCR, DMA_CCR_TEIE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if Transfer complete Interrupt is enabled.
|
||||
* @rmtoll CCR TCIE LL_DMA_IsEnabledIT_TC
|
||||
* @param DMAx DMAx Instance
|
||||
* @param Channel This parameter can be one of the following values:
|
||||
* @arg @ref LL_DMA_CHANNEL_1
|
||||
* @arg @ref LL_DMA_CHANNEL_2
|
||||
* @arg @ref LL_DMA_CHANNEL_3
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_DMA_IsEnabledIT_TC(DMA_TypeDef *DMAx, uint32_t Channel)
|
||||
{
|
||||
return (READ_BIT(((DMA_Channel_TypeDef *)((uint32_t)((uint32_t)DMAx + CHANNEL_OFFSET_TAB[Channel - 1U])))->CCR,
|
||||
DMA_CCR_TCIE) == (DMA_CCR_TCIE));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if Half transfer Interrupt is enabled.
|
||||
* @rmtoll CCR HTIE LL_DMA_IsEnabledIT_HT
|
||||
* @param DMAx DMAx Instance
|
||||
* @param Channel This parameter can be one of the following values:
|
||||
* @arg @ref LL_DMA_CHANNEL_1
|
||||
* @arg @ref LL_DMA_CHANNEL_2
|
||||
* @arg @ref LL_DMA_CHANNEL_3
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_DMA_IsEnabledIT_HT(DMA_TypeDef *DMAx, uint32_t Channel)
|
||||
{
|
||||
return (READ_BIT(((DMA_Channel_TypeDef *)((uint32_t)((uint32_t)DMAx + CHANNEL_OFFSET_TAB[Channel - 1U])))->CCR,
|
||||
DMA_CCR_HTIE) == (DMA_CCR_HTIE));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if Transfer error Interrupt is enabled.
|
||||
* @rmtoll CCR TEIE LL_DMA_IsEnabledIT_TE
|
||||
* @param DMAx DMAx Instance
|
||||
* @param Channel This parameter can be one of the following values:
|
||||
* @arg @ref LL_DMA_CHANNEL_1
|
||||
* @arg @ref LL_DMA_CHANNEL_2
|
||||
* @arg @ref LL_DMA_CHANNEL_3
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_DMA_IsEnabledIT_TE(DMA_TypeDef *DMAx, uint32_t Channel)
|
||||
{
|
||||
return (READ_BIT(((DMA_Channel_TypeDef *)((uint32_t)((uint32_t)DMAx + CHANNEL_OFFSET_TAB[Channel - 1U])))->CCR,
|
||||
DMA_CCR_TEIE) == (DMA_CCR_TEIE));
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#if defined(USE_FULL_LL_DRIVER)
|
||||
/** @defgroup DMA_LL_EF_Init Initialization and de-initialization functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
uint32_t LL_DMA_Init(DMA_TypeDef *DMAx, uint32_t Channel, LL_DMA_InitTypeDef *DMA_InitStruct);
|
||||
uint32_t LL_DMA_DeInit(DMA_TypeDef *DMAx, uint32_t Channel);
|
||||
void LL_DMA_StructInit(LL_DMA_InitTypeDef *DMA_InitStruct);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif /* USE_FULL_LL_DRIVER */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* DMA1 */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __PY32F0XX_LL_DMA_H */
|
||||
|
||||
/************************ (C) COPYRIGHT Puya *****END OF FILE****/
|
||||
886
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_ll_exti.h
Normal file
886
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_ll_exti.h
Normal file
@@ -0,0 +1,886 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file py32f0xx_ll_exti.h
|
||||
* @author MCU Application Team
|
||||
* @brief Header file of RCC LL module.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) Puya Semiconductor Co.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef PY32F0XX_LL_EXTI_H
|
||||
#define PY32F0XX_LL_EXTI_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "py32f0xx.h"
|
||||
|
||||
/** @addtogroup py32f0xx_LL_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if defined (EXTI)
|
||||
|
||||
/** @defgroup EXTI_LL EXTI
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Private types -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
#define LL_EXTI_REGISTER_PINPOS_SHFT 8U /*!< Define used to shift pin position in EXTICR register */
|
||||
#define LL_EXTI_REGISTER_PINMASK_SHFT 16U /*!< Define used to shift pin mask in EXTICR register */
|
||||
|
||||
/* Private Macros ------------------------------------------------------------*/
|
||||
#if defined(USE_FULL_LL_DRIVER)
|
||||
/** @defgroup EXTI_LL_Private_Macros EXTI Private Macros
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif /*USE_FULL_LL_DRIVER*/
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
#if defined(USE_FULL_LL_DRIVER)
|
||||
/** @defgroup EXTI_LL_ES_INIT EXTI Exported Init structure
|
||||
* @{
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
|
||||
uint32_t Line; /*!< Specifies the EXTI lines to be enabled or disabled for Lines
|
||||
This parameter can be any combination of @ref EXTI_LL_EC_LINE */
|
||||
|
||||
FunctionalState LineCommand; /*!< Specifies the new state of the selected EXTI lines.
|
||||
This parameter can be set either to ENABLE or DISABLE */
|
||||
|
||||
uint8_t Mode; /*!< Specifies the mode for the EXTI lines.
|
||||
This parameter can be a value of @ref EXTI_LL_EC_MODE. */
|
||||
|
||||
uint8_t Trigger; /*!< Specifies the trigger signal active edge for the EXTI lines.
|
||||
This parameter can be a value of @ref EXTI_LL_EC_TRIGGER. */
|
||||
} LL_EXTI_InitTypeDef;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif /*USE_FULL_LL_DRIVER*/
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/** @defgroup EXTI_LL_Exported_Constants EXTI Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup EXTI_LL_EC_LINE LINE
|
||||
* @{
|
||||
*/
|
||||
#define LL_EXTI_LINE_0 EXTI_IMR_IM0 /*!< Extended line 0 */
|
||||
#define LL_EXTI_LINE_1 EXTI_IMR_IM1 /*!< Extended line 1 */
|
||||
#define LL_EXTI_LINE_2 EXTI_IMR_IM2 /*!< Extended line 2 */
|
||||
#define LL_EXTI_LINE_3 EXTI_IMR_IM3 /*!< Extended line 3 */
|
||||
#define LL_EXTI_LINE_4 EXTI_IMR_IM4 /*!< Extended line 4 */
|
||||
#define LL_EXTI_LINE_5 EXTI_IMR_IM5 /*!< Extended line 5 */
|
||||
#define LL_EXTI_LINE_6 EXTI_IMR_IM6 /*!< Extended line 6 */
|
||||
#define LL_EXTI_LINE_7 EXTI_IMR_IM7 /*!< Extended line 7 */
|
||||
#define LL_EXTI_LINE_8 EXTI_IMR_IM8 /*!< Extended line 8 */
|
||||
#define LL_EXTI_LINE_9 EXTI_IMR_IM9 /*!< Extended line 9 */
|
||||
#define LL_EXTI_LINE_10 EXTI_IMR_IM10 /*!< Extended line 10 */
|
||||
#define LL_EXTI_LINE_11 EXTI_IMR_IM11 /*!< Extended line 11 */
|
||||
#define LL_EXTI_LINE_12 EXTI_IMR_IM12 /*!< Extended line 12 */
|
||||
#define LL_EXTI_LINE_13 EXTI_IMR_IM13 /*!< Extended line 13 */
|
||||
#define LL_EXTI_LINE_14 EXTI_IMR_IM14 /*!< Extended line 14 */
|
||||
#define LL_EXTI_LINE_15 EXTI_IMR_IM15 /*!< Extended line 15 */
|
||||
#define LL_EXTI_LINE_16 EXTI_IMR_IM16 /*!< Extended line 16 */
|
||||
#define LL_EXTI_LINE_17 EXTI_IMR_IM17 /*!< Extended line 17 */
|
||||
#define LL_EXTI_LINE_18 EXTI_IMR_IM18 /*!< Extended line 18 */
|
||||
#define LL_EXTI_LINE_19 EXTI_IMR_IM19 /*!< Extended line 19 */
|
||||
#define LL_EXTI_LINE_29 EXTI_IMR_IM29 /*!< Extended line 29 */
|
||||
|
||||
#if defined(USE_FULL_LL_DRIVER)
|
||||
#define LL_EXTI_LINE_NONE 0x00000000U /*!< None Extended line */
|
||||
#endif /*USE_FULL_LL_DRIVER*/
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#if defined(USE_FULL_LL_DRIVER)
|
||||
|
||||
/** @defgroup EXTI_LL_EC_MODE Mode
|
||||
* @{
|
||||
*/
|
||||
#define LL_EXTI_MODE_IT ((uint8_t)0x00U) /*!< Interrupt Mode */
|
||||
#define LL_EXTI_MODE_EVENT ((uint8_t)0x01U) /*!< Event Mode */
|
||||
#define LL_EXTI_MODE_IT_EVENT ((uint8_t)0x02U) /*!< Interrupt & Event Mode */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup EXTI_LL_EC_TRIGGER Edge Trigger
|
||||
* @{
|
||||
*/
|
||||
#define LL_EXTI_TRIGGER_NONE ((uint8_t)0x00U) /*!< No Trigger Mode */
|
||||
#define LL_EXTI_TRIGGER_RISING ((uint8_t)0x01U) /*!< Trigger Rising Mode */
|
||||
#define LL_EXTI_TRIGGER_FALLING ((uint8_t)0x02U) /*!< Trigger Falling Mode */
|
||||
#define LL_EXTI_TRIGGER_RISING_FALLING ((uint8_t)0x03U) /*!< Trigger Rising & Falling Mode */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#endif /*USE_FULL_LL_DRIVER*/
|
||||
|
||||
/** @defgroup EXTI_LL_EC_CONFIG_PORT EXTI CONFIG PORT
|
||||
* @{
|
||||
*/
|
||||
#define LL_EXTI_CONFIG_PORTA 0x0U /*!< EXTI PORT A */
|
||||
#define LL_EXTI_CONFIG_PORTB 0x1U /*!< EXTI PORT B */
|
||||
#define LL_EXTI_CONFIG_PORTF 0x2U /*!< EXTI PORT F */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup EXTI_LL_EC_CONFIG_LINE EXTI CONFIG LINE
|
||||
* @{
|
||||
*/
|
||||
#define LL_EXTI_CONFIG_LINE0 ((0x3U << LL_EXTI_REGISTER_PINMASK_SHFT) | ( 0U << LL_EXTI_REGISTER_PINPOS_SHFT) | 0U) /*!< EXTI_MASK_3 | EXTI_POSITION_0 | EXTICR[0] */
|
||||
#define LL_EXTI_CONFIG_LINE1 ((0x3U << LL_EXTI_REGISTER_PINMASK_SHFT) | ( 8U << LL_EXTI_REGISTER_PINPOS_SHFT) | 0U) /*!< EXTI_MASK_3 | EXTI_POSITION_8 | EXTICR[0] */
|
||||
#define LL_EXTI_CONFIG_LINE2 ((0x3U << LL_EXTI_REGISTER_PINMASK_SHFT) | (16U << LL_EXTI_REGISTER_PINPOS_SHFT) | 0U) /*!< EXTI_MASK_3 | EXTI_POSITION_16 | EXTICR[0] */
|
||||
#define LL_EXTI_CONFIG_LINE3 ((0x3U << LL_EXTI_REGISTER_PINMASK_SHFT) | (24U << LL_EXTI_REGISTER_PINPOS_SHFT) | 0U) /*!< EXTI_MASK_3 | EXTI_POSITION_24 | EXTICR[0] */
|
||||
#define LL_EXTI_CONFIG_LINE4 ((0x3U << LL_EXTI_REGISTER_PINMASK_SHFT) | ( 0U << LL_EXTI_REGISTER_PINPOS_SHFT) | 1U) /*!< EXTI_MASK_3 | EXTI_POSITION_0 | EXTICR[1] */
|
||||
#define LL_EXTI_CONFIG_LINE5 ((0x1U << LL_EXTI_REGISTER_PINMASK_SHFT) | ( 8U << LL_EXTI_REGISTER_PINPOS_SHFT) | 1U) /*!< EXTI_MASK_1 | EXTI_POSITION_8 | EXTICR[1] */
|
||||
#define LL_EXTI_CONFIG_LINE6 ((0x1U << LL_EXTI_REGISTER_PINMASK_SHFT) | (16U << LL_EXTI_REGISTER_PINPOS_SHFT) | 1U) /*!< EXTI_MASK_1 | EXTI_POSITION_16 | EXTICR[1] */
|
||||
#define LL_EXTI_CONFIG_LINE7 ((0x1U << LL_EXTI_REGISTER_PINMASK_SHFT) | (24U << LL_EXTI_REGISTER_PINPOS_SHFT) | 1U) /*!< EXTI_MASK_1 | EXTI_POSITION_19 | EXTICR[1] */
|
||||
#define LL_EXTI_CONFIG_LINE8 ((0x1U << LL_EXTI_REGISTER_PINMASK_SHFT) | ( 0U << LL_EXTI_REGISTER_PINPOS_SHFT) | 2U) /*!< EXTI_MASK_1 | EXTI_POSITION_0 | EXTICR[2] */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/** @defgroup EXTI_LL_Exported_Macros EXTI Exported Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup EXTI_LL_EM_WRITE_READ Common Write and read registers Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Write a value in EXTI register
|
||||
* @param __REG__ Register to be written
|
||||
* @param __VALUE__ Value to be written in the register
|
||||
* @retval None
|
||||
*/
|
||||
#define LL_EXTI_WriteReg(__REG__, __VALUE__) WRITE_REG(EXTI->__REG__, (__VALUE__))
|
||||
|
||||
/**
|
||||
* @brief Read a value in EXTI register
|
||||
* @param __REG__ Register to be read
|
||||
* @retval Register value
|
||||
*/
|
||||
#define LL_EXTI_ReadReg(__REG__) READ_REG(EXTI->__REG__)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/** @defgroup EXTI_LL_Exported_Functions EXTI Exported Functions
|
||||
* @{
|
||||
*/
|
||||
/** @defgroup EXTI_LL_EF_IT_Management IT_Management
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Enable ExtiLine Interrupt request for Lines
|
||||
* @param ExtiLine This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_EXTI_LINE_0
|
||||
* @arg @ref LL_EXTI_LINE_1
|
||||
* @arg @ref LL_EXTI_LINE_2
|
||||
* @arg @ref LL_EXTI_LINE_3
|
||||
* @arg @ref LL_EXTI_LINE_4
|
||||
* @arg @ref LL_EXTI_LINE_5
|
||||
* @arg @ref LL_EXTI_LINE_6
|
||||
* @arg @ref LL_EXTI_LINE_7
|
||||
* @arg @ref LL_EXTI_LINE_8
|
||||
* @arg @ref LL_EXTI_LINE_9
|
||||
* @arg @ref LL_EXTI_LINE_10
|
||||
* @arg @ref LL_EXTI_LINE_11
|
||||
* @arg @ref LL_EXTI_LINE_12
|
||||
* @arg @ref LL_EXTI_LINE_13
|
||||
* @arg @ref LL_EXTI_LINE_14
|
||||
* @arg @ref LL_EXTI_LINE_15
|
||||
* @arg @ref LL_EXTI_LINE_16
|
||||
* @arg @ref LL_EXTI_LINE_17
|
||||
* @arg @ref LL_EXTI_LINE_18
|
||||
* @arg @ref LL_EXTI_LINE_19
|
||||
* @arg @ref LL_EXTI_LINE_29
|
||||
* @note Please check each device line mapping for EXTI Line availability
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_EXTI_EnableIT(uint32_t ExtiLine)
|
||||
{
|
||||
SET_BIT(EXTI->IMR, ExtiLine);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable ExtiLine Interrupt request for Lines
|
||||
* @param ExtiLine This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_EXTI_LINE_0
|
||||
* @arg @ref LL_EXTI_LINE_1
|
||||
* @arg @ref LL_EXTI_LINE_2
|
||||
* @arg @ref LL_EXTI_LINE_3
|
||||
* @arg @ref LL_EXTI_LINE_4
|
||||
* @arg @ref LL_EXTI_LINE_5
|
||||
* @arg @ref LL_EXTI_LINE_6
|
||||
* @arg @ref LL_EXTI_LINE_7
|
||||
* @arg @ref LL_EXTI_LINE_8
|
||||
* @arg @ref LL_EXTI_LINE_9
|
||||
* @arg @ref LL_EXTI_LINE_10
|
||||
* @arg @ref LL_EXTI_LINE_11
|
||||
* @arg @ref LL_EXTI_LINE_12
|
||||
* @arg @ref LL_EXTI_LINE_13
|
||||
* @arg @ref LL_EXTI_LINE_14
|
||||
* @arg @ref LL_EXTI_LINE_15
|
||||
* @arg @ref LL_EXTI_LINE_16
|
||||
* @arg @ref LL_EXTI_LINE_17
|
||||
* @arg @ref LL_EXTI_LINE_18
|
||||
* @arg @ref LL_EXTI_LINE_19
|
||||
* @arg @ref LL_EXTI_LINE_29
|
||||
* @note Please check each device line mapping for EXTI Line availability
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_EXTI_DisableIT(uint32_t ExtiLine)
|
||||
{
|
||||
CLEAR_BIT(EXTI->IMR, ExtiLine);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Indicate if ExtiLine Interrupt request is enabled for Lines
|
||||
* Bits are set automatically at Power on.
|
||||
* @rmtoll IMR1 IMx LL_EXTI_IsEnabledIT_0_31
|
||||
* @param ExtiLine This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_EXTI_LINE_0
|
||||
* @arg @ref LL_EXTI_LINE_1
|
||||
* @arg @ref LL_EXTI_LINE_2
|
||||
* @arg @ref LL_EXTI_LINE_3
|
||||
* @arg @ref LL_EXTI_LINE_4
|
||||
* @arg @ref LL_EXTI_LINE_5
|
||||
* @arg @ref LL_EXTI_LINE_6
|
||||
* @arg @ref LL_EXTI_LINE_7
|
||||
* @arg @ref LL_EXTI_LINE_8
|
||||
* @arg @ref LL_EXTI_LINE_9
|
||||
* @arg @ref LL_EXTI_LINE_10
|
||||
* @arg @ref LL_EXTI_LINE_11
|
||||
* @arg @ref LL_EXTI_LINE_12
|
||||
* @arg @ref LL_EXTI_LINE_13
|
||||
* @arg @ref LL_EXTI_LINE_14
|
||||
* @arg @ref LL_EXTI_LINE_15
|
||||
* @arg @ref LL_EXTI_LINE_16
|
||||
* @arg @ref LL_EXTI_LINE_17
|
||||
* @arg @ref LL_EXTI_LINE_18
|
||||
* @arg @ref LL_EXTI_LINE_19
|
||||
* @arg @ref LL_EXTI_LINE_29
|
||||
* @note Please check each device line mapping for EXTI Line availability
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_EXTI_IsEnabledIT(uint32_t ExtiLine)
|
||||
{
|
||||
return (READ_BIT(EXTI->IMR, ExtiLine) == (ExtiLine));
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup EXTI_LL_EF_Event_Management Event_Management
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Enable ExtiLine Event request for Lines
|
||||
* @param ExtiLine This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_EXTI_LINE_0
|
||||
* @arg @ref LL_EXTI_LINE_1
|
||||
* @arg @ref LL_EXTI_LINE_2
|
||||
* @arg @ref LL_EXTI_LINE_3
|
||||
* @arg @ref LL_EXTI_LINE_4
|
||||
* @arg @ref LL_EXTI_LINE_5
|
||||
* @arg @ref LL_EXTI_LINE_6
|
||||
* @arg @ref LL_EXTI_LINE_7
|
||||
* @arg @ref LL_EXTI_LINE_8
|
||||
* @arg @ref LL_EXTI_LINE_9
|
||||
* @arg @ref LL_EXTI_LINE_10
|
||||
* @arg @ref LL_EXTI_LINE_11
|
||||
* @arg @ref LL_EXTI_LINE_12
|
||||
* @arg @ref LL_EXTI_LINE_13
|
||||
* @arg @ref LL_EXTI_LINE_14
|
||||
* @arg @ref LL_EXTI_LINE_15
|
||||
* @arg @ref LL_EXTI_LINE_16
|
||||
* @arg @ref LL_EXTI_LINE_17
|
||||
* @arg @ref LL_EXTI_LINE_18
|
||||
* @arg @ref LL_EXTI_LINE_19
|
||||
* @arg @ref LL_EXTI_LINE_29
|
||||
* @note Please check each device line mapping for EXTI Line availability
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_EXTI_EnableEvent(uint32_t ExtiLine)
|
||||
{
|
||||
SET_BIT(EXTI->EMR, ExtiLine);
|
||||
|
||||
}
|
||||
/**
|
||||
* @brief Disable ExtiLine Event request for Lines
|
||||
* @param ExtiLine This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_EXTI_LINE_0
|
||||
* @arg @ref LL_EXTI_LINE_1
|
||||
* @arg @ref LL_EXTI_LINE_2
|
||||
* @arg @ref LL_EXTI_LINE_3
|
||||
* @arg @ref LL_EXTI_LINE_4
|
||||
* @arg @ref LL_EXTI_LINE_5
|
||||
* @arg @ref LL_EXTI_LINE_6
|
||||
* @arg @ref LL_EXTI_LINE_7
|
||||
* @arg @ref LL_EXTI_LINE_8
|
||||
* @arg @ref LL_EXTI_LINE_9
|
||||
* @arg @ref LL_EXTI_LINE_10
|
||||
* @arg @ref LL_EXTI_LINE_11
|
||||
* @arg @ref LL_EXTI_LINE_12
|
||||
* @arg @ref LL_EXTI_LINE_13
|
||||
* @arg @ref LL_EXTI_LINE_14
|
||||
* @arg @ref LL_EXTI_LINE_15
|
||||
* @arg @ref LL_EXTI_LINE_16
|
||||
* @arg @ref LL_EXTI_LINE_17
|
||||
* @arg @ref LL_EXTI_LINE_18
|
||||
* @arg @ref LL_EXTI_LINE_19
|
||||
* @arg @ref LL_EXTI_LINE_29
|
||||
* @note Please check each device line mapping for EXTI Line availability
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_EXTI_DisableEvent(uint32_t ExtiLine)
|
||||
{
|
||||
CLEAR_BIT(EXTI->EMR, ExtiLine);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Indicate if ExtiLine Event request is enabled for Lines
|
||||
* @param ExtiLine This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_EXTI_LINE_0
|
||||
* @arg @ref LL_EXTI_LINE_1
|
||||
* @arg @ref LL_EXTI_LINE_2
|
||||
* @arg @ref LL_EXTI_LINE_3
|
||||
* @arg @ref LL_EXTI_LINE_4
|
||||
* @arg @ref LL_EXTI_LINE_5
|
||||
* @arg @ref LL_EXTI_LINE_6
|
||||
* @arg @ref LL_EXTI_LINE_7
|
||||
* @arg @ref LL_EXTI_LINE_8
|
||||
* @arg @ref LL_EXTI_LINE_9
|
||||
* @arg @ref LL_EXTI_LINE_10
|
||||
* @arg @ref LL_EXTI_LINE_11
|
||||
* @arg @ref LL_EXTI_LINE_12
|
||||
* @arg @ref LL_EXTI_LINE_13
|
||||
* @arg @ref LL_EXTI_LINE_14
|
||||
* @arg @ref LL_EXTI_LINE_15
|
||||
* @arg @ref LL_EXTI_LINE_16
|
||||
* @arg @ref LL_EXTI_LINE_17
|
||||
* @arg @ref LL_EXTI_LINE_18
|
||||
* @arg @ref LL_EXTI_LINE_19
|
||||
* @arg @ref LL_EXTI_LINE_29
|
||||
* @note Please check each device line mapping for EXTI Line availability
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_EXTI_IsEnabledEvent(uint32_t ExtiLine)
|
||||
{
|
||||
return (READ_BIT(EXTI->EMR, ExtiLine) == (ExtiLine));
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup EXTI_LL_EF_Rising_Trigger_Management Rising_Trigger_Management
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Enable ExtiLine Rising Edge Trigger for Lines
|
||||
* @note The configurable wakeup lines are edge-triggered. No glitch must be
|
||||
* generated on these lines. If a rising edge on a configurable interrupt
|
||||
* line occurs during a write operation in the EXTI_RTSR register, the
|
||||
* pending bit is not set.
|
||||
* Rising and falling edge triggers can be set for
|
||||
* the same interrupt line. In this case, both generate a trigger
|
||||
* condition.
|
||||
* @param ExtiLine This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_EXTI_LINE_0
|
||||
* @arg @ref LL_EXTI_LINE_1
|
||||
* @arg @ref LL_EXTI_LINE_2
|
||||
* @arg @ref LL_EXTI_LINE_3
|
||||
* @arg @ref LL_EXTI_LINE_4
|
||||
* @arg @ref LL_EXTI_LINE_5
|
||||
* @arg @ref LL_EXTI_LINE_6
|
||||
* @arg @ref LL_EXTI_LINE_7
|
||||
* @arg @ref LL_EXTI_LINE_8
|
||||
* @arg @ref LL_EXTI_LINE_9
|
||||
* @arg @ref LL_EXTI_LINE_10
|
||||
* @arg @ref LL_EXTI_LINE_11
|
||||
* @arg @ref LL_EXTI_LINE_12
|
||||
* @arg @ref LL_EXTI_LINE_13
|
||||
* @arg @ref LL_EXTI_LINE_14
|
||||
* @arg @ref LL_EXTI_LINE_15
|
||||
* @arg @ref LL_EXTI_LINE_16
|
||||
* @arg @ref LL_EXTI_LINE_17
|
||||
* @arg @ref LL_EXTI_LINE_18
|
||||
* @note Please check each device line mapping for EXTI Line availability
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_EXTI_EnableRisingTrig(uint32_t ExtiLine)
|
||||
{
|
||||
SET_BIT(EXTI->RTSR, ExtiLine);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable ExtiLine Rising Edge Trigger for Lines
|
||||
* @note The configurable wakeup lines are edge-triggered. No glitch must be
|
||||
* generated on these lines. If a rising edge on a configurable interrupt
|
||||
* line occurs during a write operation in the EXTI_RTSR register, the
|
||||
* pending bit is not set.
|
||||
* Rising and falling edge triggers can be set for
|
||||
* the same interrupt line. In this case, both generate a trigger
|
||||
* condition.
|
||||
* @param ExtiLine This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_EXTI_LINE_0
|
||||
* @arg @ref LL_EXTI_LINE_1
|
||||
* @arg @ref LL_EXTI_LINE_2
|
||||
* @arg @ref LL_EXTI_LINE_3
|
||||
* @arg @ref LL_EXTI_LINE_4
|
||||
* @arg @ref LL_EXTI_LINE_5
|
||||
* @arg @ref LL_EXTI_LINE_6
|
||||
* @arg @ref LL_EXTI_LINE_7
|
||||
* @arg @ref LL_EXTI_LINE_8
|
||||
* @arg @ref LL_EXTI_LINE_9
|
||||
* @arg @ref LL_EXTI_LINE_10
|
||||
* @arg @ref LL_EXTI_LINE_11
|
||||
* @arg @ref LL_EXTI_LINE_12
|
||||
* @arg @ref LL_EXTI_LINE_13
|
||||
* @arg @ref LL_EXTI_LINE_14
|
||||
* @arg @ref LL_EXTI_LINE_15
|
||||
* @arg @ref LL_EXTI_LINE_16
|
||||
* @arg @ref LL_EXTI_LINE_17
|
||||
* @arg @ref LL_EXTI_LINE_18
|
||||
* @note Please check each device line mapping for EXTI Line availability
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_EXTI_DisableRisingTrig(uint32_t ExtiLine)
|
||||
{
|
||||
CLEAR_BIT(EXTI->RTSR, ExtiLine);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Check if rising edge trigger is enabled for Lines
|
||||
* @param ExtiLine This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_EXTI_LINE_0
|
||||
* @arg @ref LL_EXTI_LINE_1
|
||||
* @arg @ref LL_EXTI_LINE_2
|
||||
* @arg @ref LL_EXTI_LINE_3
|
||||
* @arg @ref LL_EXTI_LINE_4
|
||||
* @arg @ref LL_EXTI_LINE_5
|
||||
* @arg @ref LL_EXTI_LINE_6
|
||||
* @arg @ref LL_EXTI_LINE_7
|
||||
* @arg @ref LL_EXTI_LINE_8
|
||||
* @arg @ref LL_EXTI_LINE_9
|
||||
* @arg @ref LL_EXTI_LINE_10
|
||||
* @arg @ref LL_EXTI_LINE_11
|
||||
* @arg @ref LL_EXTI_LINE_12
|
||||
* @arg @ref LL_EXTI_LINE_13
|
||||
* @arg @ref LL_EXTI_LINE_14
|
||||
* @arg @ref LL_EXTI_LINE_15
|
||||
* @arg @ref LL_EXTI_LINE_16
|
||||
* @arg @ref LL_EXTI_LINE_17
|
||||
* @arg @ref LL_EXTI_LINE_18
|
||||
* @note Please check each device line mapping for EXTI Line availability
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_EXTI_IsEnabledRisingTrig(uint32_t ExtiLine)
|
||||
{
|
||||
return (READ_BIT(EXTI->RTSR, ExtiLine) == (ExtiLine));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup EXTI_LL_EF_Falling_Trigger_Management Falling_Trigger_Management
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Enable ExtiLine Falling Edge Trigger for Lines
|
||||
* @note The configurable wakeup lines are edge-triggered. No glitch must be
|
||||
* generated on these lines. If a falling edge on a configurable interrupt
|
||||
* line occurs during a write operation in the EXTI_FTSR register, the
|
||||
* pending bit is not set.
|
||||
* Rising and falling edge triggers can be set for
|
||||
* the same interrupt line. In this case, both generate a trigger
|
||||
* condition.
|
||||
* @param ExtiLine This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_EXTI_LINE_0
|
||||
* @arg @ref LL_EXTI_LINE_1
|
||||
* @arg @ref LL_EXTI_LINE_2
|
||||
* @arg @ref LL_EXTI_LINE_3
|
||||
* @arg @ref LL_EXTI_LINE_4
|
||||
* @arg @ref LL_EXTI_LINE_5
|
||||
* @arg @ref LL_EXTI_LINE_6
|
||||
* @arg @ref LL_EXTI_LINE_7
|
||||
* @arg @ref LL_EXTI_LINE_8
|
||||
* @arg @ref LL_EXTI_LINE_9
|
||||
* @arg @ref LL_EXTI_LINE_10
|
||||
* @arg @ref LL_EXTI_LINE_11
|
||||
* @arg @ref LL_EXTI_LINE_12
|
||||
* @arg @ref LL_EXTI_LINE_13
|
||||
* @arg @ref LL_EXTI_LINE_14
|
||||
* @arg @ref LL_EXTI_LINE_15
|
||||
* @arg @ref LL_EXTI_LINE_16
|
||||
* @arg @ref LL_EXTI_LINE_17
|
||||
* @arg @ref LL_EXTI_LINE_18
|
||||
* @note Please check each device line mapping for EXTI Line availability
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_EXTI_EnableFallingTrig(uint32_t ExtiLine)
|
||||
{
|
||||
SET_BIT(EXTI->FTSR, ExtiLine);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable ExtiLine Falling Edge Trigger for Lines
|
||||
* @note The configurable wakeup lines are edge-triggered. No glitch must be
|
||||
* generated on these lines. If a Falling edge on a configurable interrupt
|
||||
* line occurs during a write operation in the EXTI_FTSR register, the
|
||||
* pending bit is not set.
|
||||
* Rising and falling edge triggers can be set for the same interrupt line.
|
||||
* In this case, both generate a trigger condition.
|
||||
* @param ExtiLine This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_EXTI_LINE_0
|
||||
* @arg @ref LL_EXTI_LINE_1
|
||||
* @arg @ref LL_EXTI_LINE_2
|
||||
* @arg @ref LL_EXTI_LINE_3
|
||||
* @arg @ref LL_EXTI_LINE_4
|
||||
* @arg @ref LL_EXTI_LINE_5
|
||||
* @arg @ref LL_EXTI_LINE_6
|
||||
* @arg @ref LL_EXTI_LINE_7
|
||||
* @arg @ref LL_EXTI_LINE_8
|
||||
* @arg @ref LL_EXTI_LINE_9
|
||||
* @arg @ref LL_EXTI_LINE_10
|
||||
* @arg @ref LL_EXTI_LINE_11
|
||||
* @arg @ref LL_EXTI_LINE_12
|
||||
* @arg @ref LL_EXTI_LINE_13
|
||||
* @arg @ref LL_EXTI_LINE_14
|
||||
* @arg @ref LL_EXTI_LINE_15
|
||||
* @arg @ref LL_EXTI_LINE_16
|
||||
* @arg @ref LL_EXTI_LINE_17
|
||||
* @arg @ref LL_EXTI_LINE_18
|
||||
* @note Please check each device line mapping for EXTI Line availability
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_EXTI_DisableFallingTrig(uint32_t ExtiLine)
|
||||
{
|
||||
CLEAR_BIT(EXTI->FTSR, ExtiLine);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if falling edge trigger is enabled for Lines
|
||||
* @param ExtiLine This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_EXTI_LINE_0
|
||||
* @arg @ref LL_EXTI_LINE_1
|
||||
* @arg @ref LL_EXTI_LINE_2
|
||||
* @arg @ref LL_EXTI_LINE_3
|
||||
* @arg @ref LL_EXTI_LINE_4
|
||||
* @arg @ref LL_EXTI_LINE_5
|
||||
* @arg @ref LL_EXTI_LINE_6
|
||||
* @arg @ref LL_EXTI_LINE_7
|
||||
* @arg @ref LL_EXTI_LINE_8
|
||||
* @arg @ref LL_EXTI_LINE_9
|
||||
* @arg @ref LL_EXTI_LINE_10
|
||||
* @arg @ref LL_EXTI_LINE_11
|
||||
* @arg @ref LL_EXTI_LINE_12
|
||||
* @arg @ref LL_EXTI_LINE_13
|
||||
* @arg @ref LL_EXTI_LINE_14
|
||||
* @arg @ref LL_EXTI_LINE_15
|
||||
* @arg @ref LL_EXTI_LINE_16
|
||||
* @arg @ref LL_EXTI_LINE_17
|
||||
* @arg @ref LL_EXTI_LINE_18
|
||||
* @note Please check each device line mapping for EXTI Line availability
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_EXTI_IsEnabledFallingTrig(uint32_t ExtiLine)
|
||||
{
|
||||
return (READ_BIT(EXTI->FTSR, ExtiLine) == (ExtiLine));
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup EXTI_LL_EF_Software_Interrupt_Management Software_Interrupt_Management
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Generate a software Interrupt Event for Lines
|
||||
* @note If the interrupt is enabled on this line in the EXTI_IMR, writing a 1 to
|
||||
* this bit when it is at '0' sets the corresponding pending bit in EXTI_PR
|
||||
* resulting in an interrupt request generation.
|
||||
* This bit is cleared by clearing the corresponding bit in the EXTI_PR
|
||||
* register (by writing a 1 into the bit)
|
||||
* @param ExtiLine This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_EXTI_LINE_0
|
||||
* @arg @ref LL_EXTI_LINE_1
|
||||
* @arg @ref LL_EXTI_LINE_2
|
||||
* @arg @ref LL_EXTI_LINE_3
|
||||
* @arg @ref LL_EXTI_LINE_4
|
||||
* @arg @ref LL_EXTI_LINE_5
|
||||
* @arg @ref LL_EXTI_LINE_6
|
||||
* @arg @ref LL_EXTI_LINE_7
|
||||
* @arg @ref LL_EXTI_LINE_8
|
||||
* @arg @ref LL_EXTI_LINE_9
|
||||
* @arg @ref LL_EXTI_LINE_10
|
||||
* @arg @ref LL_EXTI_LINE_11
|
||||
* @arg @ref LL_EXTI_LINE_12
|
||||
* @arg @ref LL_EXTI_LINE_13
|
||||
* @arg @ref LL_EXTI_LINE_14
|
||||
* @arg @ref LL_EXTI_LINE_15
|
||||
* @arg @ref LL_EXTI_LINE_16
|
||||
* @arg @ref LL_EXTI_LINE_17
|
||||
* @arg @ref LL_EXTI_LINE_18
|
||||
* @note Please check each device line mapping for EXTI Line availability
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_EXTI_GenerateSWI(uint32_t ExtiLine)
|
||||
{
|
||||
SET_BIT(EXTI->SWIER, ExtiLine);
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup EXTI_LL_EF_Flag_Management Flag_Management
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Check if the ExtLine Flag is set or not for Lines
|
||||
* @param ExtiLine This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_EXTI_LINE_0
|
||||
* @arg @ref LL_EXTI_LINE_1
|
||||
* @arg @ref LL_EXTI_LINE_2
|
||||
* @arg @ref LL_EXTI_LINE_3
|
||||
* @arg @ref LL_EXTI_LINE_4
|
||||
* @arg @ref LL_EXTI_LINE_5
|
||||
* @arg @ref LL_EXTI_LINE_6
|
||||
* @arg @ref LL_EXTI_LINE_7
|
||||
* @arg @ref LL_EXTI_LINE_8
|
||||
* @arg @ref LL_EXTI_LINE_9
|
||||
* @arg @ref LL_EXTI_LINE_10
|
||||
* @arg @ref LL_EXTI_LINE_11
|
||||
* @arg @ref LL_EXTI_LINE_12
|
||||
* @arg @ref LL_EXTI_LINE_13
|
||||
* @arg @ref LL_EXTI_LINE_14
|
||||
* @arg @ref LL_EXTI_LINE_15
|
||||
* @arg @ref LL_EXTI_LINE_16
|
||||
* @arg @ref LL_EXTI_LINE_17
|
||||
* @arg @ref LL_EXTI_LINE_18
|
||||
* @note Please check each device line mapping for EXTI Line availability
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_EXTI_IsActiveFlag(uint32_t ExtiLine)
|
||||
{
|
||||
return (READ_BIT(EXTI->PR, ExtiLine) == (ExtiLine));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read ExtLine Combination Flag for Lines
|
||||
* @param ExtiLine This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_EXTI_LINE_0
|
||||
* @arg @ref LL_EXTI_LINE_1
|
||||
* @arg @ref LL_EXTI_LINE_2
|
||||
* @arg @ref LL_EXTI_LINE_3
|
||||
* @arg @ref LL_EXTI_LINE_4
|
||||
* @arg @ref LL_EXTI_LINE_5
|
||||
* @arg @ref LL_EXTI_LINE_6
|
||||
* @arg @ref LL_EXTI_LINE_7
|
||||
* @arg @ref LL_EXTI_LINE_8
|
||||
* @arg @ref LL_EXTI_LINE_9
|
||||
* @arg @ref LL_EXTI_LINE_10
|
||||
* @arg @ref LL_EXTI_LINE_11
|
||||
* @arg @ref LL_EXTI_LINE_12
|
||||
* @arg @ref LL_EXTI_LINE_13
|
||||
* @arg @ref LL_EXTI_LINE_14
|
||||
* @arg @ref LL_EXTI_LINE_15
|
||||
* @arg @ref LL_EXTI_LINE_16
|
||||
* @arg @ref LL_EXTI_LINE_17
|
||||
* @arg @ref LL_EXTI_LINE_18
|
||||
* @note Please check each device line mapping for EXTI Line availability
|
||||
* @retval @note This bit is set when the selected edge event arrives on the interrupt
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_EXTI_ReadFlag(uint32_t ExtiLine)
|
||||
{
|
||||
return (READ_BIT(EXTI->PR, ExtiLine));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear ExtLine Flags for Lines
|
||||
* @param ExtiLine This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_EXTI_LINE_0
|
||||
* @arg @ref LL_EXTI_LINE_1
|
||||
* @arg @ref LL_EXTI_LINE_2
|
||||
* @arg @ref LL_EXTI_LINE_3
|
||||
* @arg @ref LL_EXTI_LINE_4
|
||||
* @arg @ref LL_EXTI_LINE_5
|
||||
* @arg @ref LL_EXTI_LINE_6
|
||||
* @arg @ref LL_EXTI_LINE_7
|
||||
* @arg @ref LL_EXTI_LINE_8
|
||||
* @arg @ref LL_EXTI_LINE_9
|
||||
* @arg @ref LL_EXTI_LINE_10
|
||||
* @arg @ref LL_EXTI_LINE_11
|
||||
* @arg @ref LL_EXTI_LINE_12
|
||||
* @arg @ref LL_EXTI_LINE_13
|
||||
* @arg @ref LL_EXTI_LINE_14
|
||||
* @arg @ref LL_EXTI_LINE_15
|
||||
* @arg @ref LL_EXTI_LINE_16
|
||||
* @arg @ref LL_EXTI_LINE_17
|
||||
* @arg @ref LL_EXTI_LINE_18
|
||||
* @note Please check each device line mapping for EXTI Line availability
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_EXTI_ClearFlag(uint32_t ExtiLine)
|
||||
{
|
||||
WRITE_REG(EXTI->PR, ExtiLine);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure source input for the EXTI external interrupt.
|
||||
* @param Port This parameter can be one of the following values:
|
||||
* @arg @ref LL_EXTI_CONFIG_PORTA
|
||||
* @arg @ref LL_EXTI_CONFIG_PORTB
|
||||
* @arg @ref LL_EXTI_CONFIG_PORTF
|
||||
* @param Line This parameter can be one of the following values:
|
||||
* @arg @ref LL_EXTI_CONFIG_LINE0
|
||||
* @arg @ref LL_EXTI_CONFIG_LINE1
|
||||
* @arg @ref LL_EXTI_CONFIG_LINE2
|
||||
* @arg @ref LL_EXTI_CONFIG_LINE3
|
||||
* @arg @ref LL_EXTI_CONFIG_LINE4
|
||||
* @arg @ref LL_EXTI_CONFIG_LINE5
|
||||
* @arg @ref LL_EXTI_CONFIG_LINE6
|
||||
* @arg @ref LL_EXTI_CONFIG_LINE7
|
||||
* @arg @ref LL_EXTI_CONFIG_LINE8
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_EXTI_SetEXTISource(uint32_t Port, uint32_t Line)
|
||||
{
|
||||
uint32_t mask = (Line >> LL_EXTI_REGISTER_PINMASK_SHFT) & 0xFF;
|
||||
uint32_t pos = (Line >> LL_EXTI_REGISTER_PINPOS_SHFT) & 0xFF;
|
||||
MODIFY_REG(EXTI->EXTICR[Line & 0x03u], (mask << pos), (Port << pos));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the configured defined for specific EXTI Line
|
||||
* @param Line This parameter can be one of the following values:
|
||||
* @arg @ref LL_EXTI_CONFIG_LINE0
|
||||
* @arg @ref LL_EXTI_CONFIG_LINE1
|
||||
* @arg @ref LL_EXTI_CONFIG_LINE2
|
||||
* @arg @ref LL_EXTI_CONFIG_LINE3
|
||||
* @arg @ref LL_EXTI_CONFIG_LINE4
|
||||
* @arg @ref LL_EXTI_CONFIG_LINE5
|
||||
* @arg @ref LL_EXTI_CONFIG_LINE6
|
||||
* @arg @ref LL_EXTI_CONFIG_LINE7
|
||||
* @arg @ref LL_EXTI_CONFIG_LINE8
|
||||
* @retval Returned value can be one of the following values:
|
||||
* @arg @ref LL_EXTI_CONFIG_PORTA
|
||||
* @arg @ref LL_EXTI_CONFIG_PORTB
|
||||
* @arg @ref LL_EXTI_CONFIG_PORTF
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_EXTI_GetEXTISource(uint32_t Line)
|
||||
{
|
||||
uint32_t mask = (Line >> LL_EXTI_REGISTER_PINMASK_SHFT) & 0xFF;
|
||||
uint32_t pos = (Line >> LL_EXTI_REGISTER_PINPOS_SHFT) & 0xFF;
|
||||
return (READ_BIT(EXTI->EXTICR[Line & 0x03u], (mask << pos)) >> pos);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/** @defgroup EXTI_LL_EF_Config EF configuration functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
#if defined(USE_FULL_LL_DRIVER)
|
||||
/** @defgroup EXTI_LL_EF_Init Initialization and de-initialization functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
uint32_t LL_EXTI_Init(LL_EXTI_InitTypeDef *EXTI_InitStruct);
|
||||
uint32_t LL_EXTI_DeInit(void);
|
||||
void LL_EXTI_StructInit(LL_EXTI_InitTypeDef *EXTI_InitStruct);
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif /* USE_FULL_LL_DRIVER */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* EXTI */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* PY32F0XX_LL_EXTI_H */
|
||||
|
||||
/************************ (C) COPYRIGHT Puya *****END OF FILE****/
|
||||
1108
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_ll_gpio.h
Normal file
1108
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_ll_gpio.h
Normal file
@@ -0,0 +1,1108 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file py32f0xx_ll_gpio.h
|
||||
* @author MCU Application Team
|
||||
* @brief Header file of GPIO LL module.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) Puya Semiconductor Co.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __PY32F0xx_LL_GPIO_H
|
||||
#define __PY32F0xx_LL_GPIO_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "py32f0xx.h"
|
||||
/** @addtogroup PY32F0xx_LL_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if defined (GPIOA) || defined (GPIOB) || defined (GPIOF)
|
||||
|
||||
/** @defgroup GPIO_LL GPIO
|
||||
* @{
|
||||
*/
|
||||
/** MISRA C:2012 deviation rule has been granted for following rules:
|
||||
* Rule-18.1_d - Medium: Array pointer `GPIOx' is accessed with index [..,..]
|
||||
* which may be out of array bounds [..,UNKNOWN] in following APIs:
|
||||
* LL_GPIO_GetAFPin_0_7
|
||||
* LL_GPIO_SetAFPin_0_7
|
||||
* LL_GPIO_SetAFPin_8_15
|
||||
* LL_GPIO_GetAFPin_8_15
|
||||
*/
|
||||
|
||||
/* Private types -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
/* Private macros ------------------------------------------------------------*/
|
||||
#if defined(USE_FULL_LL_DRIVER)
|
||||
/** @defgroup GPIO_LL_Private_Macros GPIO Private Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif /*USE_FULL_LL_DRIVER*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
#if defined(USE_FULL_LL_DRIVER)
|
||||
/** @defgroup GPIO_LL_ES_INIT GPIO Exported Init structures
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief LL GPIO Init Structure definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t Pin; /*!< Specifies the GPIO pins to be configured.
|
||||
This parameter can be any value of @ref GPIO_LL_EC_PIN */
|
||||
|
||||
uint32_t Mode; /*!< Specifies the operating mode for the selected pins.
|
||||
This parameter can be a value of @ref GPIO_LL_EC_MODE.
|
||||
|
||||
GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetPinMode().*/
|
||||
|
||||
uint32_t Speed; /*!< Specifies the speed for the selected pins.
|
||||
This parameter can be a value of @ref GPIO_LL_EC_SPEED.
|
||||
|
||||
GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetPinSpeed().*/
|
||||
|
||||
uint32_t OutputType; /*!< Specifies the operating output type for the selected pins.
|
||||
This parameter can be a value of @ref GPIO_LL_EC_OUTPUT.
|
||||
|
||||
GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetPinOutputType().*/
|
||||
|
||||
uint32_t Pull; /*!< Specifies the operating Pull-up/Pull down for the selected pins.
|
||||
This parameter can be a value of @ref GPIO_LL_EC_PULL.
|
||||
|
||||
GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetPinPull().*/
|
||||
|
||||
uint32_t Alternate; /*!< Specifies the Peripheral to be connected to the selected pins.
|
||||
This parameter can be a value of @ref GPIO_LL_EC_AF.
|
||||
|
||||
GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetAFPin_0_7() and LL_GPIO_SetAFPin_8_15().*/
|
||||
} LL_GPIO_InitTypeDef;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif /* USE_FULL_LL_DRIVER */
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/** @defgroup GPIO_LL_Exported_Constants GPIO Exported Constants
|
||||
* @{
|
||||
*/
|
||||
#define LL_GPIO_LCKR_LCKK 0x00030000U
|
||||
|
||||
/** @defgroup GPIO_LL_EC_PIN PIN
|
||||
* @{
|
||||
*/
|
||||
#define LL_GPIO_PIN_0 GPIO_BSRR_BS0 /*!< Select pin 0 */
|
||||
#define LL_GPIO_PIN_1 GPIO_BSRR_BS1 /*!< Select pin 1 */
|
||||
#define LL_GPIO_PIN_2 GPIO_BSRR_BS2 /*!< Select pin 2 */
|
||||
#define LL_GPIO_PIN_3 GPIO_BSRR_BS3 /*!< Select pin 3 */
|
||||
#define LL_GPIO_PIN_4 GPIO_BSRR_BS4 /*!< Select pin 4 */
|
||||
#define LL_GPIO_PIN_5 GPIO_BSRR_BS5 /*!< Select pin 5 */
|
||||
#define LL_GPIO_PIN_6 GPIO_BSRR_BS6 /*!< Select pin 6 */
|
||||
#define LL_GPIO_PIN_7 GPIO_BSRR_BS7 /*!< Select pin 7 */
|
||||
#define LL_GPIO_PIN_8 GPIO_BSRR_BS8 /*!< Select pin 8 */
|
||||
#define LL_GPIO_PIN_9 GPIO_BSRR_BS9 /*!< Select pin 9 */
|
||||
#define LL_GPIO_PIN_10 GPIO_BSRR_BS10 /*!< Select pin 10 */
|
||||
#define LL_GPIO_PIN_11 GPIO_BSRR_BS11 /*!< Select pin 11 */
|
||||
#define LL_GPIO_PIN_12 GPIO_BSRR_BS12 /*!< Select pin 12 */
|
||||
#define LL_GPIO_PIN_13 GPIO_BSRR_BS13 /*!< Select pin 13 */
|
||||
#define LL_GPIO_PIN_14 GPIO_BSRR_BS14 /*!< Select pin 14 */
|
||||
#define LL_GPIO_PIN_15 GPIO_BSRR_BS15 /*!< Select pin 15 */
|
||||
#define LL_GPIO_PIN_ALL (GPIO_BSRR_BS0 | GPIO_BSRR_BS1 | GPIO_BSRR_BS2 | \
|
||||
GPIO_BSRR_BS3 | GPIO_BSRR_BS4 | GPIO_BSRR_BS5 | \
|
||||
GPIO_BSRR_BS6 | GPIO_BSRR_BS7 | GPIO_BSRR_BS8 | \
|
||||
GPIO_BSRR_BS9 | GPIO_BSRR_BS10 | GPIO_BSRR_BS11 | \
|
||||
GPIO_BSRR_BS12 | GPIO_BSRR_BS13 | GPIO_BSRR_BS14 | \
|
||||
GPIO_BSRR_BS15) /*!< Select all pins */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup GPIO_LL_EC_MODE Mode
|
||||
* @{
|
||||
*/
|
||||
#define LL_GPIO_MODE_INPUT (0x00000000U) /*!< Select input mode */
|
||||
#define LL_GPIO_MODE_OUTPUT GPIO_MODER_MODE0_0 /*!< Select output mode */
|
||||
#define LL_GPIO_MODE_ALTERNATE GPIO_MODER_MODE0_1 /*!< Select alternate function mode */
|
||||
#define LL_GPIO_MODE_ANALOG GPIO_MODER_MODE0 /*!< Select analog mode */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup GPIO_LL_EC_OUTPUT Output Type
|
||||
* @{
|
||||
*/
|
||||
#define LL_GPIO_OUTPUT_PUSHPULL (0x00000000U) /*!< Select push-pull as output type */
|
||||
#define LL_GPIO_OUTPUT_OPENDRAIN GPIO_OTYPER_OT0 /*!< Select open-drain as output type */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup GPIO_LL_EC_SPEED Output Speed
|
||||
* @{
|
||||
*/
|
||||
#define LL_GPIO_SPEED_FREQ_LOW (0x00000000U) /*!< Select I/O low output speed */
|
||||
#define LL_GPIO_SPEED_FREQ_MEDIUM GPIO_OSPEEDR_OSPEED0_0 /*!< Select I/O medium output speed */
|
||||
#define LL_GPIO_SPEED_FREQ_HIGH GPIO_OSPEEDR_OSPEED0_1 /*!< Select I/O fast output speed */
|
||||
#define LL_GPIO_SPEED_FREQ_VERY_HIGH GPIO_OSPEEDR_OSPEED0 /*!< Select I/O high output speed */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup GPIO_LL_EC_PULL Pull Up Pull Down
|
||||
* @{
|
||||
*/
|
||||
#define LL_GPIO_PULL_NO (0x00000000U) /*!< Select I/O no pull */
|
||||
#define LL_GPIO_PULL_UP GPIO_PUPDR_PUPD0_0 /*!< Select I/O pull up */
|
||||
#define LL_GPIO_PULL_DOWN GPIO_PUPDR_PUPD0_1 /*!< Select I/O pull down */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup GPIO_LL_EC_AF Alternate Function
|
||||
* @{
|
||||
*/
|
||||
#define LL_GPIO_AF_0 (0x0000000U) /*!< Select alternate function 0 */
|
||||
#define LL_GPIO_AF_1 (0x0000001U) /*!< Select alternate function 1 */
|
||||
#define LL_GPIO_AF_2 (0x0000002U) /*!< Select alternate function 2 */
|
||||
#define LL_GPIO_AF_3 (0x0000003U) /*!< Select alternate function 3 */
|
||||
#define LL_GPIO_AF_4 (0x0000004U) /*!< Select alternate function 4 */
|
||||
#define LL_GPIO_AF_5 (0x0000005U) /*!< Select alternate function 5 */
|
||||
#define LL_GPIO_AF_6 (0x0000006U) /*!< Select alternate function 6 */
|
||||
#define LL_GPIO_AF_7 (0x0000007U) /*!< Select alternate function 7 */
|
||||
#define LL_GPIO_AF_8 (0x0000008U) /*!< Select alternate function 8 */
|
||||
#define LL_GPIO_AF_9 (0x0000009U) /*!< Select alternate function 9 */
|
||||
#define LL_GPIO_AF_10 (0x000000AU) /*!< Select alternate function 10 */
|
||||
#define LL_GPIO_AF_11 (0x000000BU) /*!< Select alternate function 11 */
|
||||
#define LL_GPIO_AF_12 (0x000000CU) /*!< Select alternate function 12 */
|
||||
#define LL_GPIO_AF_13 (0x000000DU) /*!< Select alternate function 13 */
|
||||
#define LL_GPIO_AF_14 (0x000000EU) /*!< Select alternate function 14 */
|
||||
#define LL_GPIO_AF_15 (0x000000FU) /*!< Select alternate function 15 */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup GPIO_LL_Alternate_function_selection Alternate function selection
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief AF 0 selection
|
||||
*/
|
||||
|
||||
#define LL_GPIO_AF0_SWJ LL_GPIO_AF_0 /*!< SWJ (SWD) Alternate Function mapping */
|
||||
#define LL_GPIO_AF0_SPI1 LL_GPIO_AF_0 /*!< SPI1 Alternate Function mapping */
|
||||
#define LL_GPIO_AF0_SPI2 LL_GPIO_AF_0 /*!< SPI2 Alternate Function mapping */
|
||||
#define LL_GPIO_AF0_TIM14 LL_GPIO_AF_0 /*!< TIM14 Alternate Function mapping */
|
||||
#define LL_GPIO_AF0_USART1 LL_GPIO_AF_0 /*!< USART1 Alternate Function mapping */
|
||||
|
||||
/**
|
||||
* @brief AF 1 selection
|
||||
*/
|
||||
#define LL_GPIO_AF1_IR LL_GPIO_AF_1 /*!< IR Alternate Function mapping */
|
||||
#define LL_GPIO_AF1_SPI2 LL_GPIO_AF_1 /*!< SPI2 Alternate Function mapping */
|
||||
#define LL_GPIO_AF1_TIM1 LL_GPIO_AF_1 /*!< TIM1 Alternate Function mapping */
|
||||
#define LL_GPIO_AF1_TIM3 LL_GPIO_AF_1 /*!< TIM3 Alternate Function mapping */
|
||||
#define LL_GPIO_AF1_USART1 LL_GPIO_AF_1 /*!< USART1 Alternate Function mapping */
|
||||
|
||||
/**
|
||||
* @brief AF 2 selection
|
||||
*/
|
||||
#define LL_GPIO_AF2_SPI2 LL_GPIO_AF_2 /*!< SPI2 Alternate Function mapping */
|
||||
#define LL_GPIO_AF2_TIM1 LL_GPIO_AF_2 /*!< TIM1 Alternate Function mapping */
|
||||
#define LL_GPIO_AF2_TIM14 LL_GPIO_AF_2 /*!< TIM14 Alternate Function mapping */
|
||||
#define LL_GPIO_AF2_TIM16 LL_GPIO_AF_2 /*!< TIM16 Alternate Function mapping */
|
||||
#define LL_GPIO_AF2_TIM17 LL_GPIO_AF_2 /*!< TIM17 Alternate Function mapping */
|
||||
|
||||
/**
|
||||
* @brief AF 3 selection
|
||||
*/
|
||||
#define LL_GPIO_AF3_LED LL_GPIO_AF_3 /*!< AF3: LED Alternate Function mapping*/
|
||||
#define LL_GPIO_AF3_USART1 LL_GPIO_AF_3 /*!< AF3: USART1 Alternate Function mapping*/
|
||||
#define LL_GPIO_AF3_USART2 LL_GPIO_AF_3 /*!< AF3: USART2 Alternate Function mapping*/
|
||||
#define LL_GPIO_AF3_SPI2 LL_GPIO_AF_3 /*!< AF3: SPI2 Alternate Function mapping*/
|
||||
|
||||
/**
|
||||
* @brief AF 4 selection
|
||||
*/
|
||||
#define LL_GPIO_AF4_TIM14 LL_GPIO_AF_4 /*!< TIM14 Alternate Function mapping*/
|
||||
#define LL_GPIO_AF4_USART2 LL_GPIO_AF_4 /*!< USART2 Alternate Function mapping*/
|
||||
|
||||
/**
|
||||
* @brief AF 5 selection
|
||||
*/
|
||||
#define LL_GPIO_AF5_LPTIM LL_GPIO_AF_5 /*!< LPTIM1 Alternate Function mapping*/
|
||||
#define LL_GPIO_AF5_USART2 LL_GPIO_AF_5 /*!< USART2 Alternate Function mapping*/
|
||||
#define LL_GPIO_AF5_EVENTOUT LL_GPIO_AF_5 /*!< EVENTOUT Alternate Function mapping*/
|
||||
#define LL_GPIO_AF5_TIM16 LL_GPIO_AF_5 /*!< TIM16 Alternate Function mapping*/
|
||||
#define LL_GPIO_AF5_TIM17 LL_GPIO_AF_5 /*!< TIM17 Alternate Function mapping*/
|
||||
#define LL_GPIO_AF5_MCO LL_GPIO_AF_5 /*!< MCO Alternate Function mapping*/
|
||||
|
||||
/**
|
||||
* @brief AF 6 selection
|
||||
*/
|
||||
#define LL_GPIO_AF6_I2C LL_GPIO_AF_6 /*!< I2C1 Alternate Function mapping */
|
||||
#define LL_GPIO_AF6_LED LL_GPIO_AF_6 /*!< AF6: LED Alternate Function mapping*/
|
||||
#define LL_GPIO_AF6_MCO LL_GPIO_AF_6 /*!< MCO Alternate Function mapping */
|
||||
#define LL_GPIO_AF6_EVENTOUT LL_GPIO_AF_6 /*!< AF6: EVENTOUT Alternate Function mapping*/
|
||||
|
||||
/**
|
||||
* @brief AF 7 selection
|
||||
*/
|
||||
#define LL_GPIO_AF7_EVENTOUT LL_GPIO_AF_7 /*!< EVENTOUT Alternate Function mapping */
|
||||
#define LL_GPIO_AF7_COMP1 LL_GPIO_AF_7 /*!< AF7: COMP1 Alternate Function mapping*/
|
||||
#define LL_GPIO_AF7_COMP2 LL_GPIO_AF_7 /*!< AF7: COMP2 Alternate Function mapping*/
|
||||
|
||||
/**
|
||||
* @brief AF 8 selection
|
||||
*/
|
||||
#define LL_GPIO_AF8_USART1 LL_GPIO_AF_8 /*!< AF8: USART1 Alternate Function mapping*/
|
||||
|
||||
/**
|
||||
* @brief AF 9 selection
|
||||
*/
|
||||
#define LL_GPIO_AF9_USART2 LL_GPIO_AF_9 /*!< USART2 Alternate Function mapping*/
|
||||
|
||||
/**
|
||||
* @brief AF 10 selection
|
||||
*/
|
||||
#define LL_GPIO_AF10_SPI1 LL_GPIO_AF_10 /*!< SPI2 Alternate Function mapping*/
|
||||
|
||||
/**
|
||||
* @brief AF 11 selection
|
||||
*/
|
||||
#define LL_GPIO_AF11_SPI2 LL_GPIO_AF_11 /*!< SPI2 Alternate Function mapping*/
|
||||
|
||||
/**
|
||||
* @brief AF 12 selection
|
||||
*/
|
||||
#define LL_GPIO_AF12_I2C LL_GPIO_AF_12 /*!< I2C1 Alternate Function mapping*/
|
||||
|
||||
/**
|
||||
* @brief AF 13 selection
|
||||
*/
|
||||
#define LL_GPIO_AF13_TIM1 LL_GPIO_AF_13 /*!< TIM1 Alternate Function mapping*/
|
||||
#define LL_GPIO_AF13_TIM3 LL_GPIO_AF_13 /*!< TIM3 Alternate Function mapping*/
|
||||
#define LL_GPIO_AF13_TIM14 LL_GPIO_AF_13 /*!< TIM14 Alternate Function mapping*/
|
||||
#define LL_GPIO_AF13_TIM17 LL_GPIO_AF_13 /*!< TIM17 Alternate Function mapping*/
|
||||
|
||||
/**
|
||||
* @brief AF 14 selection
|
||||
*/
|
||||
#define LL_GPIO_AF14_TIM1 LL_GPIO_AF_14 /*!< TIM1 Alternate Function mapping*/
|
||||
|
||||
/**
|
||||
* @brief AF 15 selection
|
||||
*/
|
||||
#define LL_GPIO_AF15_RTCOUT LL_GPIO_AF_15
|
||||
#define LL_GPIO_AF15_MCO LL_GPIO_AF_15 /*!< MCO Alternate Function mapping*/
|
||||
#define LL_GPIO_AF15_IR LL_GPIO_AF_15 /*!< IR Alternate Function mapping*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/** @defgroup GPIO_LL_Exported_Macros GPIO Exported Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup GPIO_LL_EM_WRITE_READ Common Write and read registers Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Write a value in GPIO register
|
||||
* @param __INSTANCE__ GPIO Instance
|
||||
* @param __REG__ Register to be written
|
||||
* @param __VALUE__ Value to be written in the register
|
||||
* @retval None
|
||||
*/
|
||||
#define LL_GPIO_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
|
||||
|
||||
/**
|
||||
* @brief Read a value in GPIO register
|
||||
* @param __INSTANCE__ GPIO Instance
|
||||
* @param __REG__ Register to be read
|
||||
* @retval Register value
|
||||
*/
|
||||
#define LL_GPIO_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/** @defgroup GPIO_LL_Exported_Functions GPIO Exported Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup GPIO_LL_EF_Port_Configuration Port Configuration
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Configure gpio mode for a dedicated pin on dedicated port.
|
||||
* @note I/O mode can be Input mode, General purpose output, Alternate function mode or Analog.
|
||||
* @note Warning: only one pin can be passed as parameter.
|
||||
* @rmtoll MODER MODEy LL_GPIO_SetPinMode
|
||||
* @param GPIOx GPIO Port
|
||||
* @param Pin This parameter can be one of the following values:
|
||||
* @arg @ref LL_GPIO_PIN_0
|
||||
* @arg @ref LL_GPIO_PIN_1
|
||||
* @arg @ref LL_GPIO_PIN_2
|
||||
* @arg @ref LL_GPIO_PIN_3
|
||||
* @arg @ref LL_GPIO_PIN_4
|
||||
* @arg @ref LL_GPIO_PIN_5
|
||||
* @arg @ref LL_GPIO_PIN_6
|
||||
* @arg @ref LL_GPIO_PIN_7
|
||||
* @arg @ref LL_GPIO_PIN_8
|
||||
* @arg @ref LL_GPIO_PIN_9
|
||||
* @arg @ref LL_GPIO_PIN_10
|
||||
* @arg @ref LL_GPIO_PIN_11
|
||||
* @arg @ref LL_GPIO_PIN_12
|
||||
* @arg @ref LL_GPIO_PIN_13
|
||||
* @arg @ref LL_GPIO_PIN_14
|
||||
* @arg @ref LL_GPIO_PIN_15
|
||||
* @param Mode This parameter can be one of the following values:
|
||||
* @arg @ref LL_GPIO_MODE_INPUT
|
||||
* @arg @ref LL_GPIO_MODE_OUTPUT
|
||||
* @arg @ref LL_GPIO_MODE_ALTERNATE
|
||||
* @arg @ref LL_GPIO_MODE_ANALOG
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_GPIO_SetPinMode(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Mode)
|
||||
{
|
||||
MODIFY_REG(GPIOx->MODER, ((Pin * Pin) * GPIO_MODER_MODE0), ((Pin * Pin) * Mode));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return gpio mode for a dedicated pin on dedicated port.
|
||||
* @note I/O mode can be Input mode, General purpose output, Alternate function mode or Analog.
|
||||
* @note Warning: only one pin can be passed as parameter.
|
||||
* @rmtoll MODER MODEy LL_GPIO_GetPinMode
|
||||
* @param GPIOx GPIO Port
|
||||
* @param Pin This parameter can be one of the following values:
|
||||
* @arg @ref LL_GPIO_PIN_0
|
||||
* @arg @ref LL_GPIO_PIN_1
|
||||
* @arg @ref LL_GPIO_PIN_2
|
||||
* @arg @ref LL_GPIO_PIN_3
|
||||
* @arg @ref LL_GPIO_PIN_4
|
||||
* @arg @ref LL_GPIO_PIN_5
|
||||
* @arg @ref LL_GPIO_PIN_6
|
||||
* @arg @ref LL_GPIO_PIN_7
|
||||
* @arg @ref LL_GPIO_PIN_8
|
||||
* @arg @ref LL_GPIO_PIN_9
|
||||
* @arg @ref LL_GPIO_PIN_10
|
||||
* @arg @ref LL_GPIO_PIN_11
|
||||
* @arg @ref LL_GPIO_PIN_12
|
||||
* @arg @ref LL_GPIO_PIN_13
|
||||
* @arg @ref LL_GPIO_PIN_14
|
||||
* @arg @ref LL_GPIO_PIN_15
|
||||
* @retval Returned value can be one of the following values:
|
||||
* @arg @ref LL_GPIO_MODE_INPUT
|
||||
* @arg @ref LL_GPIO_MODE_OUTPUT
|
||||
* @arg @ref LL_GPIO_MODE_ALTERNATE
|
||||
* @arg @ref LL_GPIO_MODE_ANALOG
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_GPIO_GetPinMode(GPIO_TypeDef *GPIOx, uint32_t Pin)
|
||||
{
|
||||
return (uint32_t)(READ_BIT(GPIOx->MODER, ((Pin * Pin) * GPIO_MODER_MODE0)) / (Pin * Pin));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure gpio output type for several pins on dedicated port.
|
||||
* @note Output type as to be set when gpio pin is in output or
|
||||
* alternate modes. Possible type are Push-pull or Open-drain.
|
||||
* @rmtoll OTYPER OTy LL_GPIO_SetPinOutputType
|
||||
* @param GPIOx GPIO Port
|
||||
* @param PinMask This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_GPIO_PIN_0
|
||||
* @arg @ref LL_GPIO_PIN_1
|
||||
* @arg @ref LL_GPIO_PIN_2
|
||||
* @arg @ref LL_GPIO_PIN_3
|
||||
* @arg @ref LL_GPIO_PIN_4
|
||||
* @arg @ref LL_GPIO_PIN_5
|
||||
* @arg @ref LL_GPIO_PIN_6
|
||||
* @arg @ref LL_GPIO_PIN_7
|
||||
* @arg @ref LL_GPIO_PIN_8
|
||||
* @arg @ref LL_GPIO_PIN_9
|
||||
* @arg @ref LL_GPIO_PIN_10
|
||||
* @arg @ref LL_GPIO_PIN_11
|
||||
* @arg @ref LL_GPIO_PIN_12
|
||||
* @arg @ref LL_GPIO_PIN_13
|
||||
* @arg @ref LL_GPIO_PIN_14
|
||||
* @arg @ref LL_GPIO_PIN_15
|
||||
* @arg @ref LL_GPIO_PIN_ALL
|
||||
* @param OutputType This parameter can be one of the following values:
|
||||
* @arg @ref LL_GPIO_OUTPUT_PUSHPULL
|
||||
* @arg @ref LL_GPIO_OUTPUT_OPENDRAIN
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_GPIO_SetPinOutputType(GPIO_TypeDef *GPIOx, uint32_t PinMask, uint32_t OutputType)
|
||||
{
|
||||
MODIFY_REG(GPIOx->OTYPER, PinMask, (PinMask * OutputType));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return gpio output type for several pins on dedicated port.
|
||||
* @note Output type as to be set when gpio pin is in output or
|
||||
* alternate modes. Possible type are Push-pull or Open-drain.
|
||||
* @note Warning: only one pin can be passed as parameter.
|
||||
* @rmtoll OTYPER OTy LL_GPIO_GetPinOutputType
|
||||
* @param GPIOx GPIO Port
|
||||
* @param Pin This parameter can be one of the following values:
|
||||
* @arg @ref LL_GPIO_PIN_0
|
||||
* @arg @ref LL_GPIO_PIN_1
|
||||
* @arg @ref LL_GPIO_PIN_2
|
||||
* @arg @ref LL_GPIO_PIN_3
|
||||
* @arg @ref LL_GPIO_PIN_4
|
||||
* @arg @ref LL_GPIO_PIN_5
|
||||
* @arg @ref LL_GPIO_PIN_6
|
||||
* @arg @ref LL_GPIO_PIN_7
|
||||
* @arg @ref LL_GPIO_PIN_8
|
||||
* @arg @ref LL_GPIO_PIN_9
|
||||
* @arg @ref LL_GPIO_PIN_10
|
||||
* @arg @ref LL_GPIO_PIN_11
|
||||
* @arg @ref LL_GPIO_PIN_12
|
||||
* @arg @ref LL_GPIO_PIN_13
|
||||
* @arg @ref LL_GPIO_PIN_14
|
||||
* @arg @ref LL_GPIO_PIN_15
|
||||
* @arg @ref LL_GPIO_PIN_ALL
|
||||
* @retval Returned value can be one of the following values:
|
||||
* @arg @ref LL_GPIO_OUTPUT_PUSHPULL
|
||||
* @arg @ref LL_GPIO_OUTPUT_OPENDRAIN
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_GPIO_GetPinOutputType(GPIO_TypeDef *GPIOx, uint32_t Pin)
|
||||
{
|
||||
return (uint32_t)(READ_BIT(GPIOx->OTYPER, Pin) / Pin);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure gpio speed for a dedicated pin on dedicated port.
|
||||
* @note I/O speed can be Low, Medium, High or Very High speed.
|
||||
* @note Warning: only one pin can be passed as parameter.
|
||||
* @note Refer to datasheet for frequency specifications and the power
|
||||
* supply and load conditions for each speed.
|
||||
* @rmtoll OSPEEDR OSPEEDy LL_GPIO_SetPinSpeed
|
||||
* @param GPIOx GPIO Port
|
||||
* @param Pin This parameter can be one of the following values:
|
||||
* @arg @ref LL_GPIO_PIN_0
|
||||
* @arg @ref LL_GPIO_PIN_1
|
||||
* @arg @ref LL_GPIO_PIN_2
|
||||
* @arg @ref LL_GPIO_PIN_3
|
||||
* @arg @ref LL_GPIO_PIN_4
|
||||
* @arg @ref LL_GPIO_PIN_5
|
||||
* @arg @ref LL_GPIO_PIN_6
|
||||
* @arg @ref LL_GPIO_PIN_7
|
||||
* @arg @ref LL_GPIO_PIN_8
|
||||
* @arg @ref LL_GPIO_PIN_9
|
||||
* @arg @ref LL_GPIO_PIN_10
|
||||
* @arg @ref LL_GPIO_PIN_11
|
||||
* @arg @ref LL_GPIO_PIN_12
|
||||
* @arg @ref LL_GPIO_PIN_13
|
||||
* @arg @ref LL_GPIO_PIN_14
|
||||
* @arg @ref LL_GPIO_PIN_15
|
||||
* @param Speed This parameter can be one of the following values:
|
||||
* @arg @ref LL_GPIO_SPEED_FREQ_LOW
|
||||
* @arg @ref LL_GPIO_SPEED_FREQ_MEDIUM
|
||||
* @arg @ref LL_GPIO_SPEED_FREQ_HIGH
|
||||
* @arg @ref LL_GPIO_SPEED_FREQ_VERY_HIGH
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_GPIO_SetPinSpeed(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Speed)
|
||||
{
|
||||
MODIFY_REG(GPIOx->OSPEEDR, ((Pin * Pin) * GPIO_OSPEEDR_OSPEED0), ((Pin * Pin) * Speed));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return gpio speed for a dedicated pin on dedicated port.
|
||||
* @note I/O speed can be Low, Medium, High or Very High speed.
|
||||
* @note Warning: only one pin can be passed as parameter.
|
||||
* @note Refer to datasheet for frequency specifications and the power
|
||||
* supply and load conditions for each speed.
|
||||
* @rmtoll OSPEEDR OSPEEDy LL_GPIO_GetPinSpeed
|
||||
* @param GPIOx GPIO Port
|
||||
* @param Pin This parameter can be one of the following values:
|
||||
* @arg @ref LL_GPIO_PIN_0
|
||||
* @arg @ref LL_GPIO_PIN_1
|
||||
* @arg @ref LL_GPIO_PIN_2
|
||||
* @arg @ref LL_GPIO_PIN_3
|
||||
* @arg @ref LL_GPIO_PIN_4
|
||||
* @arg @ref LL_GPIO_PIN_5
|
||||
* @arg @ref LL_GPIO_PIN_6
|
||||
* @arg @ref LL_GPIO_PIN_7
|
||||
* @arg @ref LL_GPIO_PIN_8
|
||||
* @arg @ref LL_GPIO_PIN_9
|
||||
* @arg @ref LL_GPIO_PIN_10
|
||||
* @arg @ref LL_GPIO_PIN_11
|
||||
* @arg @ref LL_GPIO_PIN_12
|
||||
* @arg @ref LL_GPIO_PIN_13
|
||||
* @arg @ref LL_GPIO_PIN_14
|
||||
* @arg @ref LL_GPIO_PIN_15
|
||||
* @retval Returned value can be one of the following values:
|
||||
* @arg @ref LL_GPIO_SPEED_FREQ_LOW
|
||||
* @arg @ref LL_GPIO_SPEED_FREQ_MEDIUM
|
||||
* @arg @ref LL_GPIO_SPEED_FREQ_HIGH
|
||||
* @arg @ref LL_GPIO_SPEED_FREQ_VERY_HIGH
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_GPIO_GetPinSpeed(GPIO_TypeDef *GPIOx, uint32_t Pin)
|
||||
{
|
||||
return (uint32_t)(READ_BIT(GPIOx->OSPEEDR, ((Pin * Pin) * GPIO_OSPEEDR_OSPEED0)) / (Pin * Pin));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure gpio pull-up or pull-down for a dedicated pin on a dedicated port.
|
||||
* @note Warning: only one pin can be passed as parameter.
|
||||
* @rmtoll PUPDR PUPDy LL_GPIO_SetPinPull
|
||||
* @param GPIOx GPIO Port
|
||||
* @param Pin This parameter can be one of the following values:
|
||||
* @arg @ref LL_GPIO_PIN_0
|
||||
* @arg @ref LL_GPIO_PIN_1
|
||||
* @arg @ref LL_GPIO_PIN_2
|
||||
* @arg @ref LL_GPIO_PIN_3
|
||||
* @arg @ref LL_GPIO_PIN_4
|
||||
* @arg @ref LL_GPIO_PIN_5
|
||||
* @arg @ref LL_GPIO_PIN_6
|
||||
* @arg @ref LL_GPIO_PIN_7
|
||||
* @arg @ref LL_GPIO_PIN_8
|
||||
* @arg @ref LL_GPIO_PIN_9
|
||||
* @arg @ref LL_GPIO_PIN_10
|
||||
* @arg @ref LL_GPIO_PIN_11
|
||||
* @arg @ref LL_GPIO_PIN_12
|
||||
* @arg @ref LL_GPIO_PIN_13
|
||||
* @arg @ref LL_GPIO_PIN_14
|
||||
* @arg @ref LL_GPIO_PIN_15
|
||||
* @param Pull This parameter can be one of the following values:
|
||||
* @arg @ref LL_GPIO_PULL_NO
|
||||
* @arg @ref LL_GPIO_PULL_UP
|
||||
* @arg @ref LL_GPIO_PULL_DOWN
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_GPIO_SetPinPull(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Pull)
|
||||
{
|
||||
MODIFY_REG(GPIOx->PUPDR, ((Pin * Pin) * GPIO_PUPDR_PUPD0), ((Pin * Pin) * Pull));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return gpio pull-up or pull-down for a dedicated pin on a dedicated port
|
||||
* @note Warning: only one pin can be passed as parameter.
|
||||
* @rmtoll PUPDR PUPDy LL_GPIO_GetPinPull
|
||||
* @param GPIOx GPIO Port
|
||||
* @param Pin This parameter can be one of the following values:
|
||||
* @arg @ref LL_GPIO_PIN_0
|
||||
* @arg @ref LL_GPIO_PIN_1
|
||||
* @arg @ref LL_GPIO_PIN_2
|
||||
* @arg @ref LL_GPIO_PIN_3
|
||||
* @arg @ref LL_GPIO_PIN_4
|
||||
* @arg @ref LL_GPIO_PIN_5
|
||||
* @arg @ref LL_GPIO_PIN_6
|
||||
* @arg @ref LL_GPIO_PIN_7
|
||||
* @arg @ref LL_GPIO_PIN_8
|
||||
* @arg @ref LL_GPIO_PIN_9
|
||||
* @arg @ref LL_GPIO_PIN_10
|
||||
* @arg @ref LL_GPIO_PIN_11
|
||||
* @arg @ref LL_GPIO_PIN_12
|
||||
* @arg @ref LL_GPIO_PIN_13
|
||||
* @arg @ref LL_GPIO_PIN_14
|
||||
* @arg @ref LL_GPIO_PIN_15
|
||||
* @retval Returned value can be one of the following values:
|
||||
* @arg @ref LL_GPIO_PULL_NO
|
||||
* @arg @ref LL_GPIO_PULL_UP
|
||||
* @arg @ref LL_GPIO_PULL_DOWN
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_GPIO_GetPinPull(GPIO_TypeDef *GPIOx, uint32_t Pin)
|
||||
{
|
||||
return (uint32_t)(READ_BIT(GPIOx->PUPDR, ((Pin * Pin) * GPIO_PUPDR_PUPD0)) / (Pin * Pin));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure gpio alternate function of a dedicated pin from 0 to 7 for a dedicated port.
|
||||
* @note Possible values are from AF0 to AF7 depending on target.
|
||||
* @note Warning: only one pin can be passed as parameter.
|
||||
* @rmtoll AFRL AFSELy LL_GPIO_SetAFPin_0_7
|
||||
* @param GPIOx GPIO Port
|
||||
* @param Pin This parameter can be one of the following values:
|
||||
* @arg @ref LL_GPIO_PIN_0
|
||||
* @arg @ref LL_GPIO_PIN_1
|
||||
* @arg @ref LL_GPIO_PIN_2
|
||||
* @arg @ref LL_GPIO_PIN_3
|
||||
* @arg @ref LL_GPIO_PIN_4
|
||||
* @arg @ref LL_GPIO_PIN_5
|
||||
* @arg @ref LL_GPIO_PIN_6
|
||||
* @arg @ref LL_GPIO_PIN_7
|
||||
* @param Alternate This parameter can be one of the following values:
|
||||
* @arg @ref LL_GPIO_AF_0
|
||||
* @arg @ref LL_GPIO_AF_1
|
||||
* @arg @ref LL_GPIO_AF_2
|
||||
* @arg @ref LL_GPIO_AF_3
|
||||
* @arg @ref LL_GPIO_AF_4
|
||||
* @arg @ref LL_GPIO_AF_5
|
||||
* @arg @ref LL_GPIO_AF_6
|
||||
* @arg @ref LL_GPIO_AF_7
|
||||
* @arg @ref LL_GPIO_AF_8
|
||||
* @arg @ref LL_GPIO_AF_9
|
||||
* @arg @ref LL_GPIO_AF_10
|
||||
* @arg @ref LL_GPIO_AF_11
|
||||
* @arg @ref LL_GPIO_AF_12
|
||||
* @arg @ref LL_GPIO_AF_13
|
||||
* @arg @ref LL_GPIO_AF_14
|
||||
* @arg @ref LL_GPIO_AF_15
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_GPIO_SetAFPin_0_7(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Alternate)
|
||||
{
|
||||
MODIFY_REG(GPIOx->AFR[0], ((((Pin * Pin) * Pin) * Pin) * GPIO_AFRL_AFSEL0),
|
||||
((((Pin * Pin) * Pin) * Pin) * Alternate));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return gpio alternate function of a dedicated pin from 0 to 7 for a dedicated port.
|
||||
* @rmtoll AFRL AFSELy LL_GPIO_GetAFPin_0_7
|
||||
* @param GPIOx GPIO Port
|
||||
* @param Pin This parameter can be one of the following values:
|
||||
* @arg @ref LL_GPIO_PIN_0
|
||||
* @arg @ref LL_GPIO_PIN_1
|
||||
* @arg @ref LL_GPIO_PIN_2
|
||||
* @arg @ref LL_GPIO_PIN_3
|
||||
* @arg @ref LL_GPIO_PIN_4
|
||||
* @arg @ref LL_GPIO_PIN_5
|
||||
* @arg @ref LL_GPIO_PIN_6
|
||||
* @arg @ref LL_GPIO_PIN_7
|
||||
* @retval Returned value can be one of the following values:
|
||||
* @arg @ref LL_GPIO_AF_0
|
||||
* @arg @ref LL_GPIO_AF_1
|
||||
* @arg @ref LL_GPIO_AF_2
|
||||
* @arg @ref LL_GPIO_AF_3
|
||||
* @arg @ref LL_GPIO_AF_4
|
||||
* @arg @ref LL_GPIO_AF_5
|
||||
* @arg @ref LL_GPIO_AF_6
|
||||
* @arg @ref LL_GPIO_AF_7
|
||||
* @arg @ref LL_GPIO_AF_8
|
||||
* @arg @ref LL_GPIO_AF_9
|
||||
* @arg @ref LL_GPIO_AF_10
|
||||
* @arg @ref LL_GPIO_AF_11
|
||||
* @arg @ref LL_GPIO_AF_12
|
||||
* @arg @ref LL_GPIO_AF_13
|
||||
* @arg @ref LL_GPIO_AF_14
|
||||
* @arg @ref LL_GPIO_AF_15
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_GPIO_GetAFPin_0_7(GPIO_TypeDef *GPIOx, uint32_t Pin)
|
||||
{
|
||||
return (uint32_t)(READ_BIT(GPIOx->AFR[0],
|
||||
((((Pin * Pin) * Pin) * Pin) * GPIO_AFRL_AFSEL0)) / (((Pin * Pin) * Pin) * Pin));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure gpio alternate function of a dedicated pin from 8 to 15 for a dedicated port.
|
||||
* @note Possible values are from AF0 to AF7 depending on target.
|
||||
* @note Warning: only one pin can be passed as parameter.
|
||||
* @rmtoll AFRH AFSELy LL_GPIO_SetAFPin_8_15
|
||||
* @param GPIOx GPIO Port
|
||||
* @param Pin This parameter can be one of the following values:
|
||||
* @arg @ref LL_GPIO_PIN_8
|
||||
* @arg @ref LL_GPIO_PIN_9
|
||||
* @arg @ref LL_GPIO_PIN_10
|
||||
* @arg @ref LL_GPIO_PIN_11
|
||||
* @arg @ref LL_GPIO_PIN_12
|
||||
* @arg @ref LL_GPIO_PIN_13
|
||||
* @arg @ref LL_GPIO_PIN_14
|
||||
* @arg @ref LL_GPIO_PIN_15
|
||||
* @param Alternate This parameter can be one of the following values:
|
||||
* @arg @ref LL_GPIO_AF_0
|
||||
* @arg @ref LL_GPIO_AF_1
|
||||
* @arg @ref LL_GPIO_AF_2
|
||||
* @arg @ref LL_GPIO_AF_3
|
||||
* @arg @ref LL_GPIO_AF_4
|
||||
* @arg @ref LL_GPIO_AF_5
|
||||
* @arg @ref LL_GPIO_AF_6
|
||||
* @arg @ref LL_GPIO_AF_7
|
||||
* @arg @ref LL_GPIO_AF_8
|
||||
* @arg @ref LL_GPIO_AF_9
|
||||
* @arg @ref LL_GPIO_AF_10
|
||||
* @arg @ref LL_GPIO_AF_11
|
||||
* @arg @ref LL_GPIO_AF_12
|
||||
* @arg @ref LL_GPIO_AF_13
|
||||
* @arg @ref LL_GPIO_AF_14
|
||||
* @arg @ref LL_GPIO_AF_15
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_GPIO_SetAFPin_8_15(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Alternate)
|
||||
{
|
||||
MODIFY_REG(GPIOx->AFR[1], (((((Pin >> 8U) * (Pin >> 8U)) * (Pin >> 8U)) * (Pin >> 8U)) * GPIO_AFRH_AFSEL8),
|
||||
(((((Pin >> 8U) * (Pin >> 8U)) * (Pin >> 8U)) * (Pin >> 8U)) * Alternate));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return gpio alternate function of a dedicated pin from 8 to 15 for a dedicated port.
|
||||
* @note Possible values are from AF0 to AF7 depending on target.
|
||||
* @rmtoll AFRH AFSELy LL_GPIO_GetAFPin_8_15
|
||||
* @param GPIOx GPIO Port
|
||||
* @param Pin This parameter can be one of the following values:
|
||||
* @arg @ref LL_GPIO_PIN_8
|
||||
* @arg @ref LL_GPIO_PIN_9
|
||||
* @arg @ref LL_GPIO_PIN_10
|
||||
* @arg @ref LL_GPIO_PIN_11
|
||||
* @arg @ref LL_GPIO_PIN_12
|
||||
* @arg @ref LL_GPIO_PIN_13
|
||||
* @arg @ref LL_GPIO_PIN_14
|
||||
* @arg @ref LL_GPIO_PIN_15
|
||||
* @retval Returned value can be one of the following values:
|
||||
* @arg @ref LL_GPIO_AF_0
|
||||
* @arg @ref LL_GPIO_AF_1
|
||||
* @arg @ref LL_GPIO_AF_2
|
||||
* @arg @ref LL_GPIO_AF_3
|
||||
* @arg @ref LL_GPIO_AF_4
|
||||
* @arg @ref LL_GPIO_AF_5
|
||||
* @arg @ref LL_GPIO_AF_6
|
||||
* @arg @ref LL_GPIO_AF_7
|
||||
* @arg @ref LL_GPIO_AF_8
|
||||
* @arg @ref LL_GPIO_AF_9
|
||||
* @arg @ref LL_GPIO_AF_10
|
||||
* @arg @ref LL_GPIO_AF_11
|
||||
* @arg @ref LL_GPIO_AF_12
|
||||
* @arg @ref LL_GPIO_AF_13
|
||||
* @arg @ref LL_GPIO_AF_14
|
||||
* @arg @ref LL_GPIO_AF_15
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_GPIO_GetAFPin_8_15(GPIO_TypeDef *GPIOx, uint32_t Pin)
|
||||
{
|
||||
return (uint32_t)(READ_BIT(GPIOx->AFR[1],
|
||||
(((((Pin >> 8U) * (Pin >> 8U)) * (Pin >> 8U)) * (Pin >> 8U)) * GPIO_AFRH_AFSEL8)) /
|
||||
((((Pin >> 8U) * (Pin >> 8U)) * (Pin >> 8U)) * (Pin >> 8U)));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Lock configuration of several pins for a dedicated port.
|
||||
* @note When the lock sequence has been applied on a port bit, the
|
||||
* value of this port bit can no longer be modified until the
|
||||
* next reset.
|
||||
* @note Each lock bit freezes a specific configuration register
|
||||
* (control and alternate function registers).
|
||||
* @rmtoll LCKR LCKK LL_GPIO_LockPin
|
||||
* @param GPIOx GPIO Port
|
||||
* @param PinMask This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_GPIO_PIN_0
|
||||
* @arg @ref LL_GPIO_PIN_1
|
||||
* @arg @ref LL_GPIO_PIN_2
|
||||
* @arg @ref LL_GPIO_PIN_3
|
||||
* @arg @ref LL_GPIO_PIN_4
|
||||
* @arg @ref LL_GPIO_PIN_5
|
||||
* @arg @ref LL_GPIO_PIN_6
|
||||
* @arg @ref LL_GPIO_PIN_7
|
||||
* @arg @ref LL_GPIO_PIN_8
|
||||
* @arg @ref LL_GPIO_PIN_9
|
||||
* @arg @ref LL_GPIO_PIN_10
|
||||
* @arg @ref LL_GPIO_PIN_11
|
||||
* @arg @ref LL_GPIO_PIN_12
|
||||
* @arg @ref LL_GPIO_PIN_13
|
||||
* @arg @ref LL_GPIO_PIN_14
|
||||
* @arg @ref LL_GPIO_PIN_15
|
||||
* @arg @ref LL_GPIO_PIN_ALL
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_GPIO_LockPin(GPIO_TypeDef *GPIOx, uint32_t PinMask)
|
||||
{
|
||||
__IO uint32_t temp;
|
||||
WRITE_REG(GPIOx->LCKR, GPIO_LCKR_LCKK | PinMask);
|
||||
WRITE_REG(GPIOx->LCKR, PinMask);
|
||||
WRITE_REG(GPIOx->LCKR, GPIO_LCKR_LCKK | PinMask);
|
||||
/* Read LCKK register. This read is mandatory to complete key lock sequence */
|
||||
temp = READ_REG(GPIOx->LCKR);
|
||||
(void) temp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return 1 if all pins passed as parameter, of a dedicated port, are locked. else Return 0.
|
||||
* @rmtoll LCKR LCKy LL_GPIO_IsPinLocked
|
||||
* @param GPIOx GPIO Port
|
||||
* @param PinMask This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_GPIO_PIN_0
|
||||
* @arg @ref LL_GPIO_PIN_1
|
||||
* @arg @ref LL_GPIO_PIN_2
|
||||
* @arg @ref LL_GPIO_PIN_3
|
||||
* @arg @ref LL_GPIO_PIN_4
|
||||
* @arg @ref LL_GPIO_PIN_5
|
||||
* @arg @ref LL_GPIO_PIN_6
|
||||
* @arg @ref LL_GPIO_PIN_7
|
||||
* @arg @ref LL_GPIO_PIN_8
|
||||
* @arg @ref LL_GPIO_PIN_9
|
||||
* @arg @ref LL_GPIO_PIN_10
|
||||
* @arg @ref LL_GPIO_PIN_11
|
||||
* @arg @ref LL_GPIO_PIN_12
|
||||
* @arg @ref LL_GPIO_PIN_13
|
||||
* @arg @ref LL_GPIO_PIN_14
|
||||
* @arg @ref LL_GPIO_PIN_15
|
||||
* @arg @ref LL_GPIO_PIN_ALL
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_GPIO_IsPinLocked(GPIO_TypeDef *GPIOx, uint32_t PinMask)
|
||||
{
|
||||
return (READ_BIT(GPIOx->LCKR, PinMask) == (PinMask));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return 1 if one of the pin of a dedicated port is locked. else return 0.
|
||||
* @rmtoll LCKR LCKK LL_GPIO_IsAnyPinLocked
|
||||
* @param GPIOx GPIO Port
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_GPIO_IsAnyPinLocked(GPIO_TypeDef *GPIOx)
|
||||
{
|
||||
return (READ_BIT(GPIOx->LCKR, LL_GPIO_LCKR_LCKK) != 0U);
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup GPIO_LL_EF_Data_Access Data Access
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Return full input data register value for a dedicated port.
|
||||
* @rmtoll IDR IDy LL_GPIO_ReadInputPort
|
||||
* @param GPIOx GPIO Port
|
||||
* @retval Input data register value of port
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_GPIO_ReadInputPort(GPIO_TypeDef *GPIOx)
|
||||
{
|
||||
return (uint32_t)(READ_REG(GPIOx->IDR));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return if input data level for several pins of dedicated port is high or low.
|
||||
* @rmtoll IDR IDy LL_GPIO_IsInputPinSet
|
||||
* @param GPIOx GPIO Port
|
||||
* @param PinMask This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_GPIO_PIN_0
|
||||
* @arg @ref LL_GPIO_PIN_1
|
||||
* @arg @ref LL_GPIO_PIN_2
|
||||
* @arg @ref LL_GPIO_PIN_3
|
||||
* @arg @ref LL_GPIO_PIN_4
|
||||
* @arg @ref LL_GPIO_PIN_5
|
||||
* @arg @ref LL_GPIO_PIN_6
|
||||
* @arg @ref LL_GPIO_PIN_7
|
||||
* @arg @ref LL_GPIO_PIN_8
|
||||
* @arg @ref LL_GPIO_PIN_9
|
||||
* @arg @ref LL_GPIO_PIN_10
|
||||
* @arg @ref LL_GPIO_PIN_11
|
||||
* @arg @ref LL_GPIO_PIN_12
|
||||
* @arg @ref LL_GPIO_PIN_13
|
||||
* @arg @ref LL_GPIO_PIN_14
|
||||
* @arg @ref LL_GPIO_PIN_15
|
||||
* @arg @ref LL_GPIO_PIN_ALL
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_GPIO_IsInputPinSet(GPIO_TypeDef *GPIOx, uint32_t PinMask)
|
||||
{
|
||||
return (READ_BIT(GPIOx->IDR, PinMask) == (PinMask));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Write output data register for the port.
|
||||
* @rmtoll ODR ODy LL_GPIO_WriteOutputPort
|
||||
* @param GPIOx GPIO Port
|
||||
* @param PortValue Level value for each pin of the port
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_GPIO_WriteOutputPort(GPIO_TypeDef *GPIOx, uint32_t PortValue)
|
||||
{
|
||||
WRITE_REG(GPIOx->ODR, PortValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return full output data register value for a dedicated port.
|
||||
* @rmtoll ODR ODy LL_GPIO_ReadOutputPort
|
||||
* @param GPIOx GPIO Port
|
||||
* @retval Output data register value of port
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_GPIO_ReadOutputPort(GPIO_TypeDef *GPIOx)
|
||||
{
|
||||
return (uint32_t)(READ_REG(GPIOx->ODR));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return if input data level for several pins of dedicated port is high or low.
|
||||
* @rmtoll ODR ODy LL_GPIO_IsOutputPinSet
|
||||
* @param GPIOx GPIO Port
|
||||
* @param PinMask This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_GPIO_PIN_0
|
||||
* @arg @ref LL_GPIO_PIN_1
|
||||
* @arg @ref LL_GPIO_PIN_2
|
||||
* @arg @ref LL_GPIO_PIN_3
|
||||
* @arg @ref LL_GPIO_PIN_4
|
||||
* @arg @ref LL_GPIO_PIN_5
|
||||
* @arg @ref LL_GPIO_PIN_6
|
||||
* @arg @ref LL_GPIO_PIN_7
|
||||
* @arg @ref LL_GPIO_PIN_8
|
||||
* @arg @ref LL_GPIO_PIN_9
|
||||
* @arg @ref LL_GPIO_PIN_10
|
||||
* @arg @ref LL_GPIO_PIN_11
|
||||
* @arg @ref LL_GPIO_PIN_12
|
||||
* @arg @ref LL_GPIO_PIN_13
|
||||
* @arg @ref LL_GPIO_PIN_14
|
||||
* @arg @ref LL_GPIO_PIN_15
|
||||
* @arg @ref LL_GPIO_PIN_ALL
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_GPIO_IsOutputPinSet(GPIO_TypeDef *GPIOx, uint32_t PinMask)
|
||||
{
|
||||
return (READ_BIT(GPIOx->ODR, PinMask) == (PinMask));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set several pins to high level on dedicated gpio port.
|
||||
* @rmtoll BSRR BSy LL_GPIO_SetOutputPin
|
||||
* @param GPIOx GPIO Port
|
||||
* @param PinMask This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_GPIO_PIN_0
|
||||
* @arg @ref LL_GPIO_PIN_1
|
||||
* @arg @ref LL_GPIO_PIN_2
|
||||
* @arg @ref LL_GPIO_PIN_3
|
||||
* @arg @ref LL_GPIO_PIN_4
|
||||
* @arg @ref LL_GPIO_PIN_5
|
||||
* @arg @ref LL_GPIO_PIN_6
|
||||
* @arg @ref LL_GPIO_PIN_7
|
||||
* @arg @ref LL_GPIO_PIN_8
|
||||
* @arg @ref LL_GPIO_PIN_9
|
||||
* @arg @ref LL_GPIO_PIN_10
|
||||
* @arg @ref LL_GPIO_PIN_11
|
||||
* @arg @ref LL_GPIO_PIN_12
|
||||
* @arg @ref LL_GPIO_PIN_13
|
||||
* @arg @ref LL_GPIO_PIN_14
|
||||
* @arg @ref LL_GPIO_PIN_15
|
||||
* @arg @ref LL_GPIO_PIN_ALL
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_GPIO_SetOutputPin(GPIO_TypeDef *GPIOx, uint32_t PinMask)
|
||||
{
|
||||
WRITE_REG(GPIOx->BSRR, PinMask);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set several pins to low level on dedicated gpio port.
|
||||
* @rmtoll BRR BRy LL_GPIO_ResetOutputPin
|
||||
* @param GPIOx GPIO Port
|
||||
* @param PinMask This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_GPIO_PIN_0
|
||||
* @arg @ref LL_GPIO_PIN_1
|
||||
* @arg @ref LL_GPIO_PIN_2
|
||||
* @arg @ref LL_GPIO_PIN_3
|
||||
* @arg @ref LL_GPIO_PIN_4
|
||||
* @arg @ref LL_GPIO_PIN_5
|
||||
* @arg @ref LL_GPIO_PIN_6
|
||||
* @arg @ref LL_GPIO_PIN_7
|
||||
* @arg @ref LL_GPIO_PIN_8
|
||||
* @arg @ref LL_GPIO_PIN_9
|
||||
* @arg @ref LL_GPIO_PIN_10
|
||||
* @arg @ref LL_GPIO_PIN_11
|
||||
* @arg @ref LL_GPIO_PIN_12
|
||||
* @arg @ref LL_GPIO_PIN_13
|
||||
* @arg @ref LL_GPIO_PIN_14
|
||||
* @arg @ref LL_GPIO_PIN_15
|
||||
* @arg @ref LL_GPIO_PIN_ALL
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_GPIO_ResetOutputPin(GPIO_TypeDef *GPIOx, uint32_t PinMask)
|
||||
{
|
||||
WRITE_REG(GPIOx->BRR, PinMask);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Toggle data value for several pin of dedicated port.
|
||||
* @rmtoll ODR ODy LL_GPIO_TogglePin
|
||||
* @param GPIOx GPIO Port
|
||||
* @param PinMask This parameter can be a combination of the following values:
|
||||
* @arg @ref LL_GPIO_PIN_0
|
||||
* @arg @ref LL_GPIO_PIN_1
|
||||
* @arg @ref LL_GPIO_PIN_2
|
||||
* @arg @ref LL_GPIO_PIN_3
|
||||
* @arg @ref LL_GPIO_PIN_4
|
||||
* @arg @ref LL_GPIO_PIN_5
|
||||
* @arg @ref LL_GPIO_PIN_6
|
||||
* @arg @ref LL_GPIO_PIN_7
|
||||
* @arg @ref LL_GPIO_PIN_8
|
||||
* @arg @ref LL_GPIO_PIN_9
|
||||
* @arg @ref LL_GPIO_PIN_10
|
||||
* @arg @ref LL_GPIO_PIN_11
|
||||
* @arg @ref LL_GPIO_PIN_12
|
||||
* @arg @ref LL_GPIO_PIN_13
|
||||
* @arg @ref LL_GPIO_PIN_14
|
||||
* @arg @ref LL_GPIO_PIN_15
|
||||
* @arg @ref LL_GPIO_PIN_ALL
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_GPIO_TogglePin(GPIO_TypeDef *GPIOx, uint32_t PinMask)
|
||||
{
|
||||
WRITE_REG(GPIOx->ODR, READ_REG(GPIOx->ODR) ^ PinMask);
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#if defined(USE_FULL_LL_DRIVER)
|
||||
/** @defgroup GPIO_LL_EF_Init Initialization and de-initialization functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
ErrorStatus LL_GPIO_DeInit(GPIO_TypeDef *GPIOx);
|
||||
ErrorStatus LL_GPIO_Init(GPIO_TypeDef *GPIOx, LL_GPIO_InitTypeDef *GPIO_InitStruct);
|
||||
void LL_GPIO_StructInit(LL_GPIO_InitTypeDef *GPIO_InitStruct);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif /* USE_FULL_LL_DRIVER */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* defined (GPIOA) || defined (GPIOB) || defined (GPIOF) */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __PY32F0xx_LL_GPIO_H */
|
||||
|
||||
/************************ (C) COPYRIGHT Puya *****END OF FILE****/
|
||||
1406
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_ll_i2c.h
Normal file
1406
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_ll_i2c.h
Normal file
@@ -0,0 +1,1406 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file py32f0xx_ll_i2c.h
|
||||
* @author MCU Application Team
|
||||
* @brief Header file of I2C LL module.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) Puya Semiconductor Co.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __PY32F0xx_LL_I2C_H
|
||||
#define __PY32F0xx_LL_I2C_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "py32f0xx.h"
|
||||
/** @addtogroup PY32F0xx_LL_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if defined (I2C1) || defined (I2C2)
|
||||
|
||||
/** @defgroup I2C_LL I2C
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Private types -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
/** @defgroup I2C_LL_Private_Constants I2C Private Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Defines used to perform compute and check in the macros */
|
||||
#define LL_I2C_MAX_SPEED_STANDARD 100000U
|
||||
#define LL_I2C_MAX_SPEED_FAST 400000U
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Private macros ------------------------------------------------------------*/
|
||||
#if defined(USE_FULL_LL_DRIVER)
|
||||
/** @defgroup I2C_LL_Private_Macros I2C Private Macros
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif /*USE_FULL_LL_DRIVER*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
#if defined(USE_FULL_LL_DRIVER)
|
||||
/** @defgroup I2C_LL_ES_INIT I2C Exported Init structure
|
||||
* @{
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t ClockSpeed; /*!< Specifies the clock frequency.
|
||||
This parameter must be set to a value lower than 400kHz (in Hz)
|
||||
|
||||
This feature can be modified afterwards using unitary function @ref LL_I2C_SetClockPeriod()
|
||||
or @ref LL_I2C_SetDutyCycle() or @ref LL_I2C_SetClockSpeedMode() or @ref LL_I2C_ConfigSpeed(). */
|
||||
|
||||
uint32_t DutyCycle; /*!< Specifies the I2C fast mode duty cycle.
|
||||
This parameter can be a value of @ref I2C_LL_EC_DUTYCYCLE
|
||||
|
||||
This feature can be modified afterwards using unitary function @ref LL_I2C_SetDutyCycle(). */
|
||||
|
||||
uint32_t OwnAddress1; /*!< Specifies the device own address 1.
|
||||
This parameter must be a value between Min_Data = 0x00 and Max_Data = 0x3FF
|
||||
|
||||
This feature can be modified afterwards using unitary function @ref LL_I2C_SetOwnAddress1(). */
|
||||
|
||||
uint32_t TypeAcknowledge; /*!< Specifies the ACKnowledge or Non ACKnowledge condition after the address receive match code or next received byte.
|
||||
This parameter can be a value of @ref I2C_LL_EC_I2C_ACKNOWLEDGE
|
||||
|
||||
This feature can be modified afterwards using unitary function @ref LL_I2C_AcknowledgeNextData(). */
|
||||
} LL_I2C_InitTypeDef;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif /*USE_FULL_LL_DRIVER*/
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/** @defgroup I2C_LL_Exported_Constants I2C Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup I2C_LL_EC_GET_FLAG Get Flags Defines
|
||||
* @brief Flags defines which can be used with LL_I2C_ReadReg function
|
||||
* @{
|
||||
*/
|
||||
#define LL_I2C_SR1_SB I2C_SR1_SB /*!< Start Bit (master mode) */
|
||||
#define LL_I2C_SR1_ADDR I2C_SR1_ADDR /*!< Address sent (master mode) or
|
||||
Address matched flag (slave mode) */
|
||||
#define LL_I2C_SR1_BTF I2C_SR1_BTF /*!< Byte Transfer Finished flag */
|
||||
#define LL_I2C_SR1_STOPF I2C_SR1_STOPF /*!< Stop detection flag (slave mode) */
|
||||
#define LL_I2C_SR1_RXNE I2C_SR1_RXNE /*!< Data register not empty (receivers) */
|
||||
#define LL_I2C_SR1_TXE I2C_SR1_TXE /*!< Data register empty (transmitters) */
|
||||
#define LL_I2C_SR1_BERR I2C_SR1_BERR /*!< Bus error */
|
||||
#define LL_I2C_SR1_ARLO I2C_SR1_ARLO /*!< Arbitration lost */
|
||||
#define LL_I2C_SR1_AF I2C_SR1_AF /*!< Acknowledge failure flag */
|
||||
#define LL_I2C_SR1_OVR I2C_SR1_OVR /*!< Overrun/Underrun */
|
||||
#define LL_I2C_SR1_PECERR I2C_SR1_PECERR /*!< PEC Error in reception (SMBus mode) */
|
||||
#define LL_I2C_SR2_MSL I2C_SR2_MSL /*!< Master/Slave flag */
|
||||
#define LL_I2C_SR2_BUSY I2C_SR2_BUSY /*!< Bus busy flag */
|
||||
#define LL_I2C_SR2_TRA I2C_SR2_TRA /*!< Transmitter/receiver direction */
|
||||
#define LL_I2C_SR2_GENCALL I2C_SR2_GENCALL /*!< General call address (Slave mode) */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup I2C_LL_EC_IT IT Defines
|
||||
* @brief IT defines which can be used with LL_I2C_ReadReg and LL_I2C_WriteReg functions
|
||||
* @{
|
||||
*/
|
||||
#define LL_I2C_CR2_ITEVTEN I2C_CR2_ITEVTEN /*!< Events interrupts enable */
|
||||
#define LL_I2C_CR2_ITBUFEN I2C_CR2_ITBUFEN /*!< Buffer interrupts enable */
|
||||
#define LL_I2C_CR2_ITERREN I2C_CR2_ITERREN /*!< Error interrupts enable */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup I2C_LL_EC_DUTYCYCLE Fast Mode Duty Cycle
|
||||
* @{
|
||||
*/
|
||||
#define LL_I2C_DUTYCYCLE_2 0x00000000U /*!< I2C fast mode Tlow/Thigh = 2 */
|
||||
#define LL_I2C_DUTYCYCLE_16_9 I2C_CCR_DUTY /*!< I2C fast mode Tlow/Thigh = 16/9 */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup I2C_LL_EC_CLOCK_SPEED_MODE Master Clock Speed Mode
|
||||
* @{
|
||||
*/
|
||||
#define LL_I2C_CLOCK_SPEED_STANDARD_MODE 0x00000000U /*!< Master clock speed range is standard mode */
|
||||
#define LL_I2C_CLOCK_SPEED_FAST_MODE I2C_CCR_FS /*!< Master clock speed range is fast mode */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup I2C_LL_EC_I2C_ACKNOWLEDGE Acknowledge Generation
|
||||
* @{
|
||||
*/
|
||||
#define LL_I2C_ACK I2C_CR1_ACK /*!< ACK is sent after current received byte. */
|
||||
#define LL_I2C_NACK 0x00000000U /*!< NACK is sent after current received byte.*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup I2C_LL_EC_DIRECTION Read Write Direction
|
||||
* @{
|
||||
*/
|
||||
#define LL_I2C_DIRECTION_WRITE I2C_SR2_TRA /*!< Bus is in write transfer */
|
||||
#define LL_I2C_DIRECTION_READ 0x00000000U /*!< Bus is in read transfer */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/** @defgroup I2C_LL_Exported_Macros I2C Exported Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup I2C_LL_EM_WRITE_READ Common Write and read registers Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Write a value in I2C register
|
||||
* @param __INSTANCE__ I2C Instance
|
||||
* @param __REG__ Register to be written
|
||||
* @param __VALUE__ Value to be written in the register
|
||||
* @retval None
|
||||
*/
|
||||
#define LL_I2C_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
|
||||
|
||||
/**
|
||||
* @brief Read a value in I2C register
|
||||
* @param __INSTANCE__ I2C Instance
|
||||
* @param __REG__ Register to be read
|
||||
* @retval Register value
|
||||
*/
|
||||
#define LL_I2C_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup I2C_LL_EM_Exported_Macros_Helper Exported_Macros_Helper
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Convert Peripheral Clock Frequency in MHz.
|
||||
* @param __PCLK__ This parameter must be a value of peripheral clock (in Hz).
|
||||
* @retval Value of peripheral clock (in MHz)
|
||||
*/
|
||||
#define __LL_I2C_FREQ_HZ_TO_MHZ(__PCLK__) (uint32_t)((__PCLK__)/1000000U)
|
||||
|
||||
/**
|
||||
* @brief Convert Peripheral Clock Frequency in Hz.
|
||||
* @param __PCLK__ This parameter must be a value of peripheral clock (in MHz).
|
||||
* @retval Value of peripheral clock (in Hz)
|
||||
*/
|
||||
#define __LL_I2C_FREQ_MHZ_TO_HZ(__PCLK__) (uint32_t)((__PCLK__)*1000000U)
|
||||
|
||||
/**
|
||||
* @brief Compute I2C Clock rising time.
|
||||
* @param __FREQRANGE__ This parameter must be a value of peripheral clock (in MHz).
|
||||
* @param __SPEED__ This parameter must be a value lower than 400kHz (in Hz).
|
||||
* @retval Value between Min_Data=0x02 and Max_Data=0x3F
|
||||
*/
|
||||
#define __LL_I2C_RISE_TIME(__FREQRANGE__, __SPEED__) (uint32_t)(((__SPEED__) <= LL_I2C_MAX_SPEED_STANDARD) ? ((__FREQRANGE__) + 1U) : ((((__FREQRANGE__) * 300U) / 1000U) + 1U))
|
||||
|
||||
/**
|
||||
* @brief Compute Speed clock range to a Clock Control Register (I2C_CCR_CCR) value.
|
||||
* @param __PCLK__ This parameter must be a value of peripheral clock (in Hz).
|
||||
* @param __SPEED__ This parameter must be a value lower than 400kHz (in Hz).
|
||||
* @param __DUTYCYCLE__ This parameter can be one of the following values:
|
||||
* @arg @ref LL_I2C_DUTYCYCLE_2
|
||||
* @arg @ref LL_I2C_DUTYCYCLE_16_9
|
||||
* @retval Value between Min_Data=0x004 and Max_Data=0xFFF, except in FAST DUTY mode where Min_Data=0x001.
|
||||
*/
|
||||
#define __LL_I2C_SPEED_TO_CCR(__PCLK__, __SPEED__, __DUTYCYCLE__) (uint32_t)(((__SPEED__) <= LL_I2C_MAX_SPEED_STANDARD)? \
|
||||
(__LL_I2C_SPEED_STANDARD_TO_CCR((__PCLK__), (__SPEED__))) : \
|
||||
(__LL_I2C_SPEED_FAST_TO_CCR((__PCLK__), (__SPEED__), (__DUTYCYCLE__))))
|
||||
|
||||
/**
|
||||
* @brief Compute Speed Standard clock range to a Clock Control Register (I2C_CCR_CCR) value.
|
||||
* @param __PCLK__ This parameter must be a value of peripheral clock (in Hz).
|
||||
* @param __SPEED__ This parameter must be a value lower than 100kHz (in Hz).
|
||||
* @retval Value between Min_Data=0x004 and Max_Data=0xFFF.
|
||||
*/
|
||||
#define __LL_I2C_SPEED_STANDARD_TO_CCR(__PCLK__, __SPEED__) (uint32_t)(((((__PCLK__)/((__SPEED__) << 1U)) & I2C_CCR_CCR) < 4U)? 4U:((__PCLK__) / ((__SPEED__) << 1U)))
|
||||
|
||||
/**
|
||||
* @brief Compute Speed Fast clock range to a Clock Control Register (I2C_CCR_CCR) value.
|
||||
* @param __PCLK__ This parameter must be a value of peripheral clock (in Hz).
|
||||
* @param __SPEED__ This parameter must be a value between Min_Data=100Khz and Max_Data=400Khz (in Hz).
|
||||
* @param __DUTYCYCLE__ This parameter can be one of the following values:
|
||||
* @arg @ref LL_I2C_DUTYCYCLE_2
|
||||
* @arg @ref LL_I2C_DUTYCYCLE_16_9
|
||||
* @retval Value between Min_Data=0x001 and Max_Data=0xFFF
|
||||
*/
|
||||
#define __LL_I2C_SPEED_FAST_TO_CCR(__PCLK__, __SPEED__, __DUTYCYCLE__) (uint32_t)(((__DUTYCYCLE__) == LL_I2C_DUTYCYCLE_2)? \
|
||||
(((((__PCLK__) / ((__SPEED__) * 3U)) & I2C_CCR_CCR) == 0U)? 1U:((__PCLK__) / ((__SPEED__) * 3U))) : \
|
||||
(((((__PCLK__) / ((__SPEED__) * 25U)) & I2C_CCR_CCR) == 0U)? 1U:((__PCLK__) / ((__SPEED__) * 25U))))
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
|
||||
/** @defgroup I2C_LL_Exported_Functions I2C Exported Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup I2C_LL_EF_Configuration Configuration
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Enable I2C peripheral (PE = 1).
|
||||
* @rmtoll CR1 PE LL_I2C_Enable
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_I2C_Enable(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
SET_BIT(I2Cx->CR1, I2C_CR1_PE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable I2C peripheral (PE = 0).
|
||||
* @rmtoll CR1 PE LL_I2C_Disable
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_I2C_Disable(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
CLEAR_BIT(I2Cx->CR1, I2C_CR1_PE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if the I2C peripheral is enabled or disabled.
|
||||
* @rmtoll CR1 PE LL_I2C_IsEnabled
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_I2C_IsEnabled(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
return (READ_BIT(I2Cx->CR1, I2C_CR1_PE) == (I2C_CR1_PE));
|
||||
}
|
||||
|
||||
|
||||
#if (defined(DMA1) || defined(DMA))
|
||||
/**
|
||||
* @brief Enable DMA transmission requests.
|
||||
* @note Depending on devices and packages, DMA may not be available.
|
||||
* Refer to device datasheet for DMA availability.
|
||||
* @rmtoll CR2 DMAEN LL_I2C_EnableDMAReq_TX
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_I2C_EnableDMAReq_TX(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
SET_BIT(I2Cx->CR2, I2C_CR2_DMAEN);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable DMA transmission requests.
|
||||
* @note Depending on devices and packages, DMA may not be available.
|
||||
* Refer to device datasheet for DMA availability.
|
||||
* @rmtoll CR2 DMAEN LL_I2C_DisableDMAReq_TX
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_I2C_DisableDMAReq_TX(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
CLEAR_BIT(I2Cx->CR2, I2C_CR2_DMAEN);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if DMA transmission requests are enabled or disabled.
|
||||
* @note Depending on devices and packages, DMA may not be available.
|
||||
* Refer to device datasheet for DMA availability.
|
||||
* @rmtoll CR2 DMAEN LL_I2C_IsEnabledDMAReq_TX
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_I2C_IsEnabledDMAReq_TX(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
return (READ_BIT(I2Cx->CR2, I2C_CR2_DMAEN) == (I2C_CR2_DMAEN));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable DMA reception requests.
|
||||
* @note Depending on devices and packages, DMA may not be available.
|
||||
* Refer to device datasheet for DMA availability.
|
||||
* @rmtoll CR2 DMAEN LL_I2C_EnableDMAReq_RX
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_I2C_EnableDMAReq_RX(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
SET_BIT(I2Cx->CR2, I2C_CR2_DMAEN);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable DMA reception requests.
|
||||
* @note Depending on devices and packages, DMA may not be available.
|
||||
* Refer to device datasheet for DMA availability.
|
||||
* @rmtoll CR2 DMAEN LL_I2C_DisableDMAReq_RX
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_I2C_DisableDMAReq_RX(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
CLEAR_BIT(I2Cx->CR2, I2C_CR2_DMAEN);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if DMA reception requests are enabled or disabled.
|
||||
* @note Depending on devices and packages, DMA may not be available.
|
||||
* Refer to device datasheet for DMA availability.
|
||||
* @rmtoll CR2 DMAEN LL_I2C_IsEnabledDMAReq_RX
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_I2C_IsEnabledDMAReq_RX(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
return (READ_BIT(I2Cx->CR2, I2C_CR2_DMAEN) == (I2C_CR2_DMAEN));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the data register address used for DMA transfer.
|
||||
* @note Depending on devices and packages, DMA may not be available.
|
||||
* Refer to device datasheet for DMA availability.
|
||||
* @rmtoll DR DR LL_I2C_DMA_GetRegAddr
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval Address of data register
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_I2C_DMA_GetRegAddr(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
return (uint32_t) & (I2Cx->DR);
|
||||
}
|
||||
#endif /* DMA1 or DMA */
|
||||
|
||||
/**
|
||||
* @brief Enable Clock stretching.
|
||||
* @note This bit can only be programmed when the I2C is disabled (PE = 0).
|
||||
* @rmtoll CR1 NOSTRETCH LL_I2C_EnableClockStretching
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_I2C_EnableClockStretching(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
CLEAR_BIT(I2Cx->CR1, I2C_CR1_NOSTRETCH);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable Clock stretching.
|
||||
* @note This bit can only be programmed when the I2C is disabled (PE = 0).
|
||||
* @rmtoll CR1 NOSTRETCH LL_I2C_DisableClockStretching
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_I2C_DisableClockStretching(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
SET_BIT(I2Cx->CR1, I2C_CR1_NOSTRETCH);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if Clock stretching is enabled or disabled.
|
||||
* @rmtoll CR1 NOSTRETCH LL_I2C_IsEnabledClockStretching
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_I2C_IsEnabledClockStretching(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
return (READ_BIT(I2Cx->CR1, I2C_CR1_NOSTRETCH) != (I2C_CR1_NOSTRETCH));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable General Call.
|
||||
* @note When enabled the Address 0x00 is ACKed.
|
||||
* @rmtoll CR1 ENGC LL_I2C_EnableGeneralCall
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_I2C_EnableGeneralCall(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
SET_BIT(I2Cx->CR1, I2C_CR1_ENGC);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable General Call.
|
||||
* @note When disabled the Address 0x00 is NACKed.
|
||||
* @rmtoll CR1 ENGC LL_I2C_DisableGeneralCall
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_I2C_DisableGeneralCall(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
CLEAR_BIT(I2Cx->CR1, I2C_CR1_ENGC);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if General Call is enabled or disabled.
|
||||
* @rmtoll CR1 ENGC LL_I2C_IsEnabledGeneralCall
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_I2C_IsEnabledGeneralCall(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
return (READ_BIT(I2Cx->CR1, I2C_CR1_ENGC) == (I2C_CR1_ENGC));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the Own Address1.
|
||||
* @param I2Cx I2C Instance.
|
||||
* @param OwnAddress1 This parameter must be a value between Min_Data=0 and Max_Data=0x3FF.
|
||||
* @param OwnAddrSize This parameter is not used, can pass 0.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_I2C_SetOwnAddress1(I2C_TypeDef *I2Cx, uint32_t OwnAddress1, uint32_t OwnAddrSize)
|
||||
{
|
||||
(void)OwnAddrSize;
|
||||
MODIFY_REG(I2Cx->OAR1, I2C_OAR1_ADD1_7, OwnAddress1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure the Peripheral clock frequency.
|
||||
* @rmtoll CR2 FREQ LL_I2C_SetPeriphClock
|
||||
* @param I2Cx I2C Instance.
|
||||
* @param PeriphClock Peripheral Clock (in Hz)
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_I2C_SetPeriphClock(I2C_TypeDef *I2Cx, uint32_t PeriphClock)
|
||||
{
|
||||
MODIFY_REG(I2Cx->CR2, I2C_CR2_FREQ, __LL_I2C_FREQ_HZ_TO_MHZ(PeriphClock));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the Peripheral clock frequency.
|
||||
* @rmtoll CR2 FREQ LL_I2C_GetPeriphClock
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval Value of Peripheral Clock (in Hz)
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_I2C_GetPeriphClock(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
return (uint32_t)(__LL_I2C_FREQ_MHZ_TO_HZ(READ_BIT(I2Cx->CR2, I2C_CR2_FREQ)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure the Duty cycle (Fast mode only).
|
||||
* @rmtoll CCR DUTY LL_I2C_SetDutyCycle
|
||||
* @param I2Cx I2C Instance.
|
||||
* @param DutyCycle This parameter can be one of the following values:
|
||||
* @arg @ref LL_I2C_DUTYCYCLE_2
|
||||
* @arg @ref LL_I2C_DUTYCYCLE_16_9
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_I2C_SetDutyCycle(I2C_TypeDef *I2Cx, uint32_t DutyCycle)
|
||||
{
|
||||
MODIFY_REG(I2Cx->CCR, I2C_CCR_DUTY, DutyCycle);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the Duty cycle (Fast mode only).
|
||||
* @rmtoll CCR DUTY LL_I2C_GetDutyCycle
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval Returned value can be one of the following values:
|
||||
* @arg @ref LL_I2C_DUTYCYCLE_2
|
||||
* @arg @ref LL_I2C_DUTYCYCLE_16_9
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_I2C_GetDutyCycle(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
return (uint32_t)(READ_BIT(I2Cx->CCR, I2C_CCR_DUTY));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure the I2C master clock speed mode.
|
||||
* @rmtoll CCR FS LL_I2C_SetClockSpeedMode
|
||||
* @param I2Cx I2C Instance.
|
||||
* @param ClockSpeedMode This parameter can be one of the following values:
|
||||
* @arg @ref LL_I2C_CLOCK_SPEED_STANDARD_MODE
|
||||
* @arg @ref LL_I2C_CLOCK_SPEED_FAST_MODE
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_I2C_SetClockSpeedMode(I2C_TypeDef *I2Cx, uint32_t ClockSpeedMode)
|
||||
{
|
||||
MODIFY_REG(I2Cx->CCR, I2C_CCR_FS, ClockSpeedMode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the the I2C master speed mode.
|
||||
* @rmtoll CCR FS LL_I2C_GetClockSpeedMode
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval Returned value can be one of the following values:
|
||||
* @arg @ref LL_I2C_CLOCK_SPEED_STANDARD_MODE
|
||||
* @arg @ref LL_I2C_CLOCK_SPEED_FAST_MODE
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_I2C_GetClockSpeedMode(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
return (uint32_t)(READ_BIT(I2Cx->CCR, I2C_CCR_FS));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure the SCL, SDA rising time.
|
||||
* @note This bit can only be programmed when the I2C is disabled (PE = 0).
|
||||
* @rmtoll TRISE TRISE LL_I2C_SetRiseTime
|
||||
* @param I2Cx I2C Instance.
|
||||
* @param RiseTime This parameter must be a value between Min_Data=0x02 and Max_Data=0x3F.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_I2C_SetRiseTime(I2C_TypeDef *I2Cx, uint32_t RiseTime)
|
||||
{
|
||||
MODIFY_REG(I2Cx->TRISE, I2C_TRISE_TRISE, RiseTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the SCL, SDA rising time.
|
||||
* @rmtoll TRISE TRISE LL_I2C_GetRiseTime
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval Value between Min_Data=0x02 and Max_Data=0x3F
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_I2C_GetRiseTime(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
return (uint32_t)(READ_BIT(I2Cx->TRISE, I2C_TRISE_TRISE));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure the SCL high and low period.
|
||||
* @note This bit can only be programmed when the I2C is disabled (PE = 0).
|
||||
* @rmtoll CCR CCR LL_I2C_SetClockPeriod
|
||||
* @param I2Cx I2C Instance.
|
||||
* @param ClockPeriod This parameter must be a value between Min_Data=0x004 and Max_Data=0xFFF, except in FAST DUTY mode where Min_Data=0x001.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_I2C_SetClockPeriod(I2C_TypeDef *I2Cx, uint32_t ClockPeriod)
|
||||
{
|
||||
MODIFY_REG(I2Cx->CCR, I2C_CCR_CCR, ClockPeriod);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the SCL high and low period.
|
||||
* @rmtoll CCR CCR LL_I2C_GetClockPeriod
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval Value between Min_Data=0x004 and Max_Data=0xFFF, except in FAST DUTY mode where Min_Data=0x001.
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_I2C_GetClockPeriod(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
return (uint32_t)(READ_BIT(I2Cx->CCR, I2C_CCR_CCR));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure the SCL speed.
|
||||
* @note This bit can only be programmed when the I2C is disabled (PE = 0).
|
||||
* @rmtoll CR2 FREQ LL_I2C_ConfigSpeed\n
|
||||
* TRISE TRISE LL_I2C_ConfigSpeed\n
|
||||
* CCR FS LL_I2C_ConfigSpeed\n
|
||||
* CCR DUTY LL_I2C_ConfigSpeed\n
|
||||
* CCR CCR LL_I2C_ConfigSpeed
|
||||
* @param I2Cx I2C Instance.
|
||||
* @param PeriphClock Peripheral Clock (in Hz)
|
||||
* @param ClockSpeed This parameter must be a value lower than 400kHz (in Hz).
|
||||
* @param DutyCycle This parameter can be one of the following values:
|
||||
* @arg @ref LL_I2C_DUTYCYCLE_2
|
||||
* @arg @ref LL_I2C_DUTYCYCLE_16_9
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_I2C_ConfigSpeed(I2C_TypeDef *I2Cx, uint32_t PeriphClock, uint32_t ClockSpeed,
|
||||
uint32_t DutyCycle)
|
||||
{
|
||||
register uint32_t freqrange = 0x0U;
|
||||
register uint32_t clockconfig = 0x0U;
|
||||
|
||||
/* Compute frequency range */
|
||||
freqrange = __LL_I2C_FREQ_HZ_TO_MHZ(PeriphClock);
|
||||
|
||||
/* Configure I2Cx: Frequency range register */
|
||||
MODIFY_REG(I2Cx->CR2, I2C_CR2_FREQ, freqrange);
|
||||
|
||||
/* Configure I2Cx: Rise Time register */
|
||||
MODIFY_REG(I2Cx->TRISE, I2C_TRISE_TRISE, __LL_I2C_RISE_TIME(freqrange, ClockSpeed));
|
||||
|
||||
/* Configure Speed mode, Duty Cycle and Clock control register value */
|
||||
if (ClockSpeed > LL_I2C_MAX_SPEED_STANDARD)
|
||||
{
|
||||
/* Set Speed mode at fast and duty cycle for Clock Speed request in fast clock range */
|
||||
clockconfig = LL_I2C_CLOCK_SPEED_FAST_MODE | \
|
||||
__LL_I2C_SPEED_FAST_TO_CCR(PeriphClock, ClockSpeed, DutyCycle) | \
|
||||
DutyCycle;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Set Speed mode at standard for Clock Speed request in standard clock range */
|
||||
clockconfig = LL_I2C_CLOCK_SPEED_STANDARD_MODE | \
|
||||
__LL_I2C_SPEED_STANDARD_TO_CCR(PeriphClock, ClockSpeed);
|
||||
}
|
||||
|
||||
/* Configure I2Cx: Clock control register */
|
||||
MODIFY_REG(I2Cx->CCR, (I2C_CCR_FS | I2C_CCR_DUTY | I2C_CCR_CCR), clockconfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup I2C_LL_EF_IT_Management IT_Management
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Enable TXE interrupt.
|
||||
* @rmtoll CR2 ITEVTEN LL_I2C_EnableIT_TX\n
|
||||
* CR2 ITBUFEN LL_I2C_EnableIT_TX
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_I2C_EnableIT_TX(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
SET_BIT(I2Cx->CR2, I2C_CR2_ITEVTEN | I2C_CR2_ITBUFEN);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable TXE interrupt.
|
||||
* @rmtoll CR2 ITEVTEN LL_I2C_DisableIT_TX\n
|
||||
* CR2 ITBUFEN LL_I2C_DisableIT_TX
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_I2C_DisableIT_TX(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
CLEAR_BIT(I2Cx->CR2, I2C_CR2_ITEVTEN | I2C_CR2_ITBUFEN);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if the TXE Interrupt is enabled or disabled.
|
||||
* @rmtoll CR2 ITEVTEN LL_I2C_IsEnabledIT_TX\n
|
||||
* CR2 ITBUFEN LL_I2C_IsEnabledIT_TX
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_I2C_IsEnabledIT_TX(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
return (READ_BIT(I2Cx->CR2, I2C_CR2_ITEVTEN | I2C_CR2_ITBUFEN) == (I2C_CR2_ITEVTEN | I2C_CR2_ITBUFEN));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable RXNE interrupt.
|
||||
* @rmtoll CR2 ITEVTEN LL_I2C_EnableIT_RX\n
|
||||
* CR2 ITBUFEN LL_I2C_EnableIT_RX
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_I2C_EnableIT_RX(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
SET_BIT(I2Cx->CR2, I2C_CR2_ITEVTEN | I2C_CR2_ITBUFEN);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable RXNE interrupt.
|
||||
* @rmtoll CR2 ITEVTEN LL_I2C_DisableIT_RX\n
|
||||
* CR2 ITBUFEN LL_I2C_DisableIT_RX
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_I2C_DisableIT_RX(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
CLEAR_BIT(I2Cx->CR2, I2C_CR2_ITEVTEN | I2C_CR2_ITBUFEN);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if the RXNE Interrupt is enabled or disabled.
|
||||
* @rmtoll CR2 ITEVTEN LL_I2C_IsEnabledIT_RX\n
|
||||
* CR2 ITBUFEN LL_I2C_IsEnabledIT_RX
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_I2C_IsEnabledIT_RX(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
return (READ_BIT(I2Cx->CR2, I2C_CR2_ITEVTEN | I2C_CR2_ITBUFEN) == (I2C_CR2_ITEVTEN | I2C_CR2_ITBUFEN));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable Events interrupts.
|
||||
* @note Any of these events will generate interrupt :
|
||||
* Start Bit (SB)
|
||||
* Address sent, Address matched (ADDR)
|
||||
* Stop detection (STOPF)
|
||||
* Byte transfer finished (BTF)
|
||||
*
|
||||
* @note Any of these events will generate interrupt if Buffer interrupts are enabled too(using unitary function @ref LL_I2C_EnableIT_BUF()) :
|
||||
* Receive buffer not empty (RXNE)
|
||||
* Transmit buffer empty (TXE)
|
||||
* @rmtoll CR2 ITEVTEN LL_I2C_EnableIT_EVT
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_I2C_EnableIT_EVT(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
SET_BIT(I2Cx->CR2, I2C_CR2_ITEVTEN);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable Events interrupts.
|
||||
* @note Any of these events will generate interrupt :
|
||||
* Start Bit (SB)
|
||||
* Address sent, Address matched (ADDR)
|
||||
* Stop detection (STOPF)
|
||||
* Byte transfer finished (BTF)
|
||||
* Receive buffer not empty (RXNE)
|
||||
* Transmit buffer empty (TXE)
|
||||
* @rmtoll CR2 ITEVTEN LL_I2C_DisableIT_EVT
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_I2C_DisableIT_EVT(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
CLEAR_BIT(I2Cx->CR2, I2C_CR2_ITEVTEN);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if Events interrupts are enabled or disabled.
|
||||
* @rmtoll CR2 ITEVTEN LL_I2C_IsEnabledIT_EVT
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_I2C_IsEnabledIT_EVT(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
return (READ_BIT(I2Cx->CR2, I2C_CR2_ITEVTEN) == (I2C_CR2_ITEVTEN));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable Buffer interrupts.
|
||||
* @note Any of these Buffer events will generate interrupt if Events interrupts are enabled too(using unitary function @ref LL_I2C_EnableIT_EVT()) :
|
||||
* Receive buffer not empty (RXNE)
|
||||
* Transmit buffer empty (TXE)
|
||||
* @rmtoll CR2 ITBUFEN LL_I2C_EnableIT_BUF
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_I2C_EnableIT_BUF(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
SET_BIT(I2Cx->CR2, I2C_CR2_ITBUFEN);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable Buffer interrupts.
|
||||
* @note Any of these Buffer events will generate interrupt :
|
||||
* Receive buffer not empty (RXNE)
|
||||
* Transmit buffer empty (TXE)
|
||||
* @rmtoll CR2 ITBUFEN LL_I2C_DisableIT_BUF
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_I2C_DisableIT_BUF(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
CLEAR_BIT(I2Cx->CR2, I2C_CR2_ITBUFEN);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if Buffer interrupts are enabled or disabled.
|
||||
* @rmtoll CR2 ITBUFEN LL_I2C_IsEnabledIT_BUF
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_I2C_IsEnabledIT_BUF(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
return (READ_BIT(I2Cx->CR2, I2C_CR2_ITBUFEN) == (I2C_CR2_ITBUFEN));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable Error interrupts.
|
||||
* @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
|
||||
* SMBus feature is supported by the I2Cx Instance.
|
||||
* @note Any of these errors will generate interrupt :
|
||||
* Bus Error detection (BERR)
|
||||
* Arbitration Loss (ARLO)
|
||||
* Acknowledge Failure(AF)
|
||||
* Overrun/Underrun (OVR)
|
||||
* @rmtoll CR2 ITERREN LL_I2C_EnableIT_ERR
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_I2C_EnableIT_ERR(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
SET_BIT(I2Cx->CR2, I2C_CR2_ITERREN);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable Error interrupts.
|
||||
* @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
|
||||
* SMBus feature is supported by the I2Cx Instance.
|
||||
* @note Any of these errors will generate interrupt :
|
||||
* Bus Error detection (BERR)
|
||||
* Arbitration Loss (ARLO)
|
||||
* Acknowledge Failure(AF)
|
||||
* Overrun/Underrun (OVR)
|
||||
* SMBus Timeout detection (TIMEOUT)
|
||||
* SMBus PEC error detection (PECERR)
|
||||
* SMBus Alert pin event detection (SMBALERT)
|
||||
* @rmtoll CR2 ITERREN LL_I2C_DisableIT_ERR
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_I2C_DisableIT_ERR(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
CLEAR_BIT(I2Cx->CR2, I2C_CR2_ITERREN);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if Error interrupts are enabled or disabled.
|
||||
* @rmtoll CR2 ITERREN LL_I2C_IsEnabledIT_ERR
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_I2C_IsEnabledIT_ERR(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
return (READ_BIT(I2Cx->CR2, I2C_CR2_ITERREN) == (I2C_CR2_ITERREN));
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup I2C_LL_EF_FLAG_management FLAG_management
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Indicate the status of Transmit data register empty flag.
|
||||
* @note RESET: When next data is written in Transmit data register.
|
||||
* SET: When Transmit data register is empty.
|
||||
* @rmtoll SR1 TXE LL_I2C_IsActiveFlag_TXE
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_TXE(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
return (READ_BIT(I2Cx->SR1, I2C_SR1_TXE) == (I2C_SR1_TXE));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Indicate the status of Byte Transfer Finished flag.
|
||||
* RESET: When Data byte transfer not done.
|
||||
* SET: When Data byte transfer succeeded.
|
||||
* @rmtoll SR1 BTF LL_I2C_IsActiveFlag_BTF
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_BTF(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
return (READ_BIT(I2Cx->SR1, I2C_SR1_BTF) == (I2C_SR1_BTF));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Indicate the status of Receive data register not empty flag.
|
||||
* @note RESET: When Receive data register is read.
|
||||
* SET: When the received data is copied in Receive data register.
|
||||
* @rmtoll SR1 RXNE LL_I2C_IsActiveFlag_RXNE
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_RXNE(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
return (READ_BIT(I2Cx->SR1, I2C_SR1_RXNE) == (I2C_SR1_RXNE));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Indicate the status of Start Bit (master mode).
|
||||
* @note RESET: When No Start condition.
|
||||
* SET: When Start condition is generated.
|
||||
* @rmtoll SR1 SB LL_I2C_IsActiveFlag_SB
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_SB(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
return (READ_BIT(I2Cx->SR1, I2C_SR1_SB) == (I2C_SR1_SB));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Indicate the status of Address sent (master mode) or Address matched flag (slave mode).
|
||||
* @note RESET: Clear default value.
|
||||
* SET: When the address is fully sent (master mode) or when the received slave address matched with one of the enabled slave address (slave mode).
|
||||
* @rmtoll SR1 ADDR LL_I2C_IsActiveFlag_ADDR
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_ADDR(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
return (READ_BIT(I2Cx->SR1, I2C_SR1_ADDR) == (I2C_SR1_ADDR));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Indicate the status of Acknowledge failure flag.
|
||||
* @note RESET: No acknowledge failure.
|
||||
* SET: When an acknowledge failure is received after a byte transmission.
|
||||
* @rmtoll SR1 AF LL_I2C_IsActiveFlag_AF
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_AF(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
return (READ_BIT(I2Cx->SR1, I2C_SR1_AF) == (I2C_SR1_AF));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Indicate the status of Stop detection flag (slave mode).
|
||||
* @note RESET: Clear default value.
|
||||
* SET: When a Stop condition is detected.
|
||||
* @rmtoll SR1 STOPF LL_I2C_IsActiveFlag_STOP
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_STOP(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
return (READ_BIT(I2Cx->SR1, I2C_SR1_STOPF) == (I2C_SR1_STOPF));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Indicate the status of Bus error flag.
|
||||
* @note RESET: Clear default value.
|
||||
* SET: When a misplaced Start or Stop condition is detected.
|
||||
* @rmtoll SR1 BERR LL_I2C_IsActiveFlag_BERR
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_BERR(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
return (READ_BIT(I2Cx->SR1, I2C_SR1_BERR) == (I2C_SR1_BERR));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Indicate the status of Arbitration lost flag.
|
||||
* @note RESET: Clear default value.
|
||||
* SET: When arbitration lost.
|
||||
* @rmtoll SR1 ARLO LL_I2C_IsActiveFlag_ARLO
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_ARLO(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
return (READ_BIT(I2Cx->SR1, I2C_SR1_ARLO) == (I2C_SR1_ARLO));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Indicate the status of Overrun/Underrun flag.
|
||||
* @note RESET: Clear default value.
|
||||
* SET: When an overrun/underrun error occurs (Clock Stretching Disabled).
|
||||
* @rmtoll SR1 OVR LL_I2C_IsActiveFlag_OVR
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_OVR(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
return (READ_BIT(I2Cx->SR1, I2C_SR1_OVR) == (I2C_SR1_OVR));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Indicate the status of SMBus PEC error flag in reception.
|
||||
* @note Macro @ref IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
|
||||
* SMBus feature is supported by the I2Cx Instance.
|
||||
* @rmtoll SR1 PECERR LL_I2C_IsActiveSMBusFlag_PECERR
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_I2C_IsActiveSMBusFlag_PECERR(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
return (READ_BIT(I2Cx->SR1, I2C_SR1_PECERR) == (I2C_SR1_PECERR));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Indicate the status of Bus Busy flag.
|
||||
* @note RESET: Clear default value.
|
||||
* SET: When a Start condition is detected.
|
||||
* @rmtoll SR2 BUSY LL_I2C_IsActiveFlag_BUSY
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_BUSY(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
return (READ_BIT(I2Cx->SR2, I2C_SR2_BUSY) == (I2C_SR2_BUSY));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Indicate the status of General call address reception (Slave mode).
|
||||
* @note RESET: No Generall call address
|
||||
* SET: General call address received.
|
||||
* @note This status is cleared by hardware after a STOP condition or repeated START condition.
|
||||
* @rmtoll SR2 GENCALL LL_I2C_IsActiveFlag_GENCALL
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_GENCALL(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
return (READ_BIT(I2Cx->SR2, I2C_SR2_GENCALL) == (I2C_SR2_GENCALL));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Indicate the status of Master/Slave flag.
|
||||
* @note RESET: Slave Mode.
|
||||
* SET: Master Mode.
|
||||
* @rmtoll SR2 MSL LL_I2C_IsActiveFlag_MSL
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_MSL(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
return (READ_BIT(I2Cx->SR2, I2C_SR2_MSL) == (I2C_SR2_MSL));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear Address Matched flag.
|
||||
* @note Clearing this flag is done by a read access to the I2Cx_SR1
|
||||
* register followed by a read access to the I2Cx_SR2 register.
|
||||
* @rmtoll SR1 ADDR LL_I2C_ClearFlag_ADDR
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_I2C_ClearFlag_ADDR(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
__IO uint32_t tmpreg;
|
||||
tmpreg = I2Cx->SR1;
|
||||
(void) tmpreg;
|
||||
tmpreg = I2Cx->SR2;
|
||||
(void) tmpreg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear Acknowledge failure flag.
|
||||
* @rmtoll SR1 AF LL_I2C_ClearFlag_AF
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_I2C_ClearFlag_AF(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
CLEAR_BIT(I2Cx->SR1, I2C_SR1_AF);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear Stop detection flag.
|
||||
* @note Clearing this flag is done by a read access to the I2Cx_SR1
|
||||
* register followed by a write access to I2Cx_CR1 register.
|
||||
* @rmtoll SR1 STOPF LL_I2C_ClearFlag_STOP\n
|
||||
* CR1 PE LL_I2C_ClearFlag_STOP
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_I2C_ClearFlag_STOP(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
__IO uint32_t tmpreg;
|
||||
tmpreg = I2Cx->SR1;
|
||||
(void) tmpreg;
|
||||
SET_BIT(I2Cx->CR1, I2C_CR1_PE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear Bus error flag.
|
||||
* @rmtoll SR1 BERR LL_I2C_ClearFlag_BERR
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_I2C_ClearFlag_BERR(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
CLEAR_BIT(I2Cx->SR1, I2C_SR1_BERR);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear Arbitration lost flag.
|
||||
* @rmtoll SR1 ARLO LL_I2C_ClearFlag_ARLO
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_I2C_ClearFlag_ARLO(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
CLEAR_BIT(I2Cx->SR1, I2C_SR1_ARLO);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear Overrun/Underrun flag.
|
||||
* @rmtoll SR1 OVR LL_I2C_ClearFlag_OVR
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_I2C_ClearFlag_OVR(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
CLEAR_BIT(I2Cx->SR1, I2C_SR1_OVR);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clear SMBus PEC error flag.
|
||||
* @rmtoll SR1 PECERR LL_I2C_ClearSMBusFlag_PECERR
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_I2C_ClearSMBusFlag_PECERR(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
CLEAR_BIT(I2Cx->SR1, I2C_SR1_PECERR);
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup I2C_LL_EF_Data_Management Data_Management
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Enable Reset of I2C peripheral.
|
||||
* @rmtoll CR1 SWRST LL_I2C_EnableReset
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_I2C_EnableReset(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
SET_BIT(I2Cx->CR1, I2C_CR1_SWRST);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable Reset of I2C peripheral.
|
||||
* @rmtoll CR1 SWRST LL_I2C_DisableReset
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_I2C_DisableReset(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
CLEAR_BIT(I2Cx->CR1, I2C_CR1_SWRST);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if the I2C peripheral is under reset state or not.
|
||||
* @rmtoll CR1 SWRST LL_I2C_IsResetEnabled
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_I2C_IsResetEnabled(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
return (READ_BIT(I2Cx->CR1, I2C_CR1_SWRST) == (I2C_CR1_SWRST));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Prepare the generation of a ACKnowledge or Non ACKnowledge condition after the address receive match code or next received byte.
|
||||
* @note Usage in Slave or Master mode.
|
||||
* @rmtoll CR1 ACK LL_I2C_AcknowledgeNextData
|
||||
* @param I2Cx I2C Instance.
|
||||
* @param TypeAcknowledge This parameter can be one of the following values:
|
||||
* @arg @ref LL_I2C_ACK
|
||||
* @arg @ref LL_I2C_NACK
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_I2C_AcknowledgeNextData(I2C_TypeDef *I2Cx, uint32_t TypeAcknowledge)
|
||||
{
|
||||
MODIFY_REG(I2Cx->CR1, I2C_CR1_ACK, TypeAcknowledge);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Generate a START or RESTART condition
|
||||
* @note The START bit can be set even if bus is BUSY or I2C is in slave mode.
|
||||
* This action has no effect when RELOAD is set.
|
||||
* @rmtoll CR1 START LL_I2C_GenerateStartCondition
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_I2C_GenerateStartCondition(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
SET_BIT(I2Cx->CR1, I2C_CR1_START);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Generate a STOP condition after the current byte transfer (master mode).
|
||||
* @rmtoll CR1 STOP LL_I2C_GenerateStopCondition
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_I2C_GenerateStopCondition(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
SET_BIT(I2Cx->CR1, I2C_CR1_STOP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable bit POS (master/host mode).
|
||||
* @note In that case, the ACK bit controls the (N)ACK of the next byte received or the PEC bit indicates that the next byte in shift register is a PEC.
|
||||
* @rmtoll CR1 POS LL_I2C_EnableBitPOS
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_I2C_EnableBitPOS(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
SET_BIT(I2Cx->CR1, I2C_CR1_POS);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable bit POS (master/host mode).
|
||||
* @note In that case, the ACK bit controls the (N)ACK of the current byte received or the PEC bit indicates that the current byte in shift register is a PEC.
|
||||
* @rmtoll CR1 POS LL_I2C_DisableBitPOS
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_I2C_DisableBitPOS(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
CLEAR_BIT(I2Cx->CR1, I2C_CR1_POS);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if bit POS is enabled or disabled.
|
||||
* @rmtoll CR1 POS LL_I2C_IsEnabledBitPOS
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_I2C_IsEnabledBitPOS(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
return (READ_BIT(I2Cx->CR1, I2C_CR1_POS) == (I2C_CR1_POS));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Indicate the value of transfer direction.
|
||||
* @note RESET: Bus is in read transfer (peripheral point of view).
|
||||
* SET: Bus is in write transfer (peripheral point of view).
|
||||
* @rmtoll SR2 TRA LL_I2C_GetTransferDirection
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval Returned value can be one of the following values:
|
||||
* @arg @ref LL_I2C_DIRECTION_WRITE
|
||||
* @arg @ref LL_I2C_DIRECTION_READ
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_I2C_GetTransferDirection(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
return (uint32_t)(READ_BIT(I2Cx->SR2, I2C_SR2_TRA));
|
||||
}
|
||||
|
||||
#if (defined(DMA1) || defined(DMA))
|
||||
/**
|
||||
* @brief Enable DMA last transfer.
|
||||
* @note This action mean that next DMA EOT is the last transfer.
|
||||
* @note Depending on devices and packages, DMA may not be available.
|
||||
* Refer to device datasheet for DMA availability.
|
||||
* @rmtoll CR2 LAST LL_I2C_EnableLastDMA
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_I2C_EnableLastDMA(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
SET_BIT(I2Cx->CR2, I2C_CR2_LAST);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable DMA last transfer.
|
||||
* @note This action mean that next DMA EOT is not the last transfer.
|
||||
* @note Depending on devices and packages, DMA may not be available.
|
||||
* Refer to device datasheet for DMA availability.
|
||||
* @rmtoll CR2 LAST LL_I2C_DisableLastDMA
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_I2C_DisableLastDMA(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
CLEAR_BIT(I2Cx->CR2, I2C_CR2_LAST);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if DMA last transfer is enabled or disabled.
|
||||
* @note Depending on devices and packages, DMA may not be available.
|
||||
* Refer to device datasheet for DMA availability.
|
||||
* @rmtoll CR2 LAST LL_I2C_IsEnabledLastDMA
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_I2C_IsEnabledLastDMA(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
return (READ_BIT(I2Cx->CR2, I2C_CR2_LAST) == (I2C_CR2_LAST));
|
||||
}
|
||||
#endif /* DMA1 or DMA */
|
||||
|
||||
/**
|
||||
* @brief Read Receive Data register.
|
||||
* @rmtoll DR DR LL_I2C_ReceiveData8
|
||||
* @param I2Cx I2C Instance.
|
||||
* @retval Value between Min_Data=0x0 and Max_Data=0xFF
|
||||
*/
|
||||
__STATIC_INLINE uint8_t LL_I2C_ReceiveData8(I2C_TypeDef *I2Cx)
|
||||
{
|
||||
return (uint8_t)(READ_BIT(I2Cx->DR, I2C_DR_DR));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Write in Transmit Data Register .
|
||||
* @rmtoll DR DR LL_I2C_TransmitData8
|
||||
* @param I2Cx I2C Instance.
|
||||
* @param Data Value between Min_Data=0x0 and Max_Data=0xFF
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_I2C_TransmitData8(I2C_TypeDef *I2Cx, uint8_t Data)
|
||||
{
|
||||
MODIFY_REG(I2Cx->DR, I2C_DR_DR, Data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#if defined(USE_FULL_LL_DRIVER)
|
||||
/** @defgroup I2C_LL_EF_Init Initialization and de-initialization functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
uint32_t LL_I2C_Init(I2C_TypeDef *I2Cx, LL_I2C_InitTypeDef *I2C_InitStruct);
|
||||
uint32_t LL_I2C_DeInit(I2C_TypeDef *I2Cx);
|
||||
void LL_I2C_StructInit(LL_I2C_InitTypeDef *I2C_InitStruct);
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif /* USE_FULL_LL_DRIVER */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* I2C1 || I2C2 */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __PY32F0xx_LL_I2C_H */
|
||||
|
||||
/************************ (C) COPYRIGHT Puya *****END OF FILE****/
|
||||
313
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_ll_iwdg.h
Normal file
313
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_ll_iwdg.h
Normal file
@@ -0,0 +1,313 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file py32f0xx_ll_iwdg.h
|
||||
* @author MCU Application Team
|
||||
* @brief Header file of IWDG LL module.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) Puya Semiconductor Co.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef PY32F0XX_LL_IWDG_H
|
||||
#define PY32F0XX_LL_IWDG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "py32f0xx.h"
|
||||
|
||||
/** @addtogroup PY32F0XX_LL_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if defined(IWDG)
|
||||
|
||||
/** @defgroup IWDG_LL IWDG
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Private types -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
/** @defgroup IWDG_LL_Private_Constants IWDG Private Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define LL_IWDG_KEY_RELOAD 0x0000AAAAU /*!< IWDG Reload Counter Enable */
|
||||
#define LL_IWDG_KEY_ENABLE 0x0000CCCCU /*!< IWDG Peripheral Enable */
|
||||
#define LL_IWDG_KEY_WR_ACCESS_ENABLE 0x00005555U /*!< IWDG KR Write Access Enable */
|
||||
#define LL_IWDG_KEY_WR_ACCESS_DISABLE 0x00000000U /*!< IWDG KR Write Access Disable */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Private macros ------------------------------------------------------------*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/** @defgroup IWDG_LL_Exported_Constants IWDG Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup IWDG_LL_EC_GET_FLAG Get Flags Defines
|
||||
* @brief Flags defines which can be used with LL_IWDG_ReadReg function
|
||||
* @{
|
||||
*/
|
||||
#define LL_IWDG_SR_PVU IWDG_SR_PVU /*!< Watchdog prescaler value update */
|
||||
#define LL_IWDG_SR_RVU IWDG_SR_RVU /*!< Watchdog counter reload value update */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup IWDG_LL_EC_PRESCALER Prescaler Divider
|
||||
* @{
|
||||
*/
|
||||
#define LL_IWDG_PRESCALER_4 0x00000000U /*!< Divider by 4 */
|
||||
#define LL_IWDG_PRESCALER_8 ( IWDG_PR_PR_0) /*!< Divider by 8 */
|
||||
#define LL_IWDG_PRESCALER_16 ( IWDG_PR_PR_1 ) /*!< Divider by 16 */
|
||||
#define LL_IWDG_PRESCALER_32 ( IWDG_PR_PR_1 | IWDG_PR_PR_0) /*!< Divider by 32 */
|
||||
#define LL_IWDG_PRESCALER_64 (IWDG_PR_PR_2 ) /*!< Divider by 64 */
|
||||
#define LL_IWDG_PRESCALER_128 (IWDG_PR_PR_2 | IWDG_PR_PR_0) /*!< Divider by 128 */
|
||||
#define LL_IWDG_PRESCALER_256 (IWDG_PR_PR_2 | IWDG_PR_PR_1 ) /*!< Divider by 256 */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/** @defgroup IWDG_LL_Exported_Macros IWDG Exported Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup IWDG_LL_EM_WRITE_READ Common Write and read registers Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Write a value in IWDG register
|
||||
* @param __INSTANCE__ IWDG Instance
|
||||
* @param __REG__ Register to be written
|
||||
* @param __VALUE__ Value to be written in the register
|
||||
* @retval None
|
||||
*/
|
||||
#define LL_IWDG_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
|
||||
|
||||
/**
|
||||
* @brief Read a value in IWDG register
|
||||
* @param __INSTANCE__ IWDG Instance
|
||||
* @param __REG__ Register to be read
|
||||
* @retval Register value
|
||||
*/
|
||||
#define LL_IWDG_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/** @defgroup IWDG_LL_Exported_Functions IWDG Exported Functions
|
||||
* @{
|
||||
*/
|
||||
/** @defgroup IWDG_LL_EF_Configuration Configuration
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Start the Independent Watchdog
|
||||
* @note Except if the hardware watchdog option is selected
|
||||
* @rmtoll KR KEY LL_IWDG_Enable
|
||||
* @param IWDGx IWDG Instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_IWDG_Enable(IWDG_TypeDef *IWDGx)
|
||||
{
|
||||
WRITE_REG(IWDGx->KR, LL_IWDG_KEY_ENABLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reloads IWDG counter with value defined in the reload register
|
||||
* @rmtoll KR KEY LL_IWDG_ReloadCounter
|
||||
* @param IWDGx IWDG Instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_IWDG_ReloadCounter(IWDG_TypeDef *IWDGx)
|
||||
{
|
||||
WRITE_REG(IWDGx->KR, LL_IWDG_KEY_RELOAD);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers
|
||||
* @rmtoll KR KEY LL_IWDG_EnableWriteAccess
|
||||
* @param IWDGx IWDG Instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_IWDG_EnableWriteAccess(IWDG_TypeDef *IWDGx)
|
||||
{
|
||||
WRITE_REG(IWDGx->KR, LL_IWDG_KEY_WR_ACCESS_ENABLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers
|
||||
* @rmtoll KR KEY LL_IWDG_DisableWriteAccess
|
||||
* @param IWDGx IWDG Instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_IWDG_DisableWriteAccess(IWDG_TypeDef *IWDGx)
|
||||
{
|
||||
WRITE_REG(IWDGx->KR, LL_IWDG_KEY_WR_ACCESS_DISABLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Select the prescaler of the IWDG
|
||||
* @rmtoll PR PR LL_IWDG_SetPrescaler
|
||||
* @param IWDGx IWDG Instance
|
||||
* @param Prescaler This parameter can be one of the following values:
|
||||
* @arg @ref LL_IWDG_PRESCALER_4
|
||||
* @arg @ref LL_IWDG_PRESCALER_8
|
||||
* @arg @ref LL_IWDG_PRESCALER_16
|
||||
* @arg @ref LL_IWDG_PRESCALER_32
|
||||
* @arg @ref LL_IWDG_PRESCALER_64
|
||||
* @arg @ref LL_IWDG_PRESCALER_128
|
||||
* @arg @ref LL_IWDG_PRESCALER_256
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_IWDG_SetPrescaler(IWDG_TypeDef *IWDGx, uint32_t Prescaler)
|
||||
{
|
||||
WRITE_REG(IWDGx->PR, IWDG_PR_PR & Prescaler);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the selected prescaler of the IWDG
|
||||
* @rmtoll PR PR LL_IWDG_GetPrescaler
|
||||
* @param IWDGx IWDG Instance
|
||||
* @retval Returned value can be one of the following values:
|
||||
* @arg @ref LL_IWDG_PRESCALER_4
|
||||
* @arg @ref LL_IWDG_PRESCALER_8
|
||||
* @arg @ref LL_IWDG_PRESCALER_16
|
||||
* @arg @ref LL_IWDG_PRESCALER_32
|
||||
* @arg @ref LL_IWDG_PRESCALER_64
|
||||
* @arg @ref LL_IWDG_PRESCALER_128
|
||||
* @arg @ref LL_IWDG_PRESCALER_256
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_IWDG_GetPrescaler(IWDG_TypeDef *IWDGx)
|
||||
{
|
||||
return (uint32_t)(READ_REG(IWDGx->PR));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Specify the IWDG down-counter reload value
|
||||
* @rmtoll RLR RL LL_IWDG_SetReloadCounter
|
||||
* @param IWDGx IWDG Instance
|
||||
* @param Counter Value between Min_Data=0 and Max_Data=0x0FFF
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_IWDG_SetReloadCounter(IWDG_TypeDef *IWDGx, uint32_t Counter)
|
||||
{
|
||||
WRITE_REG(IWDGx->RLR, IWDG_RLR_RL & Counter);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the specified IWDG down-counter reload value
|
||||
* @rmtoll RLR RL LL_IWDG_GetReloadCounter
|
||||
* @param IWDGx IWDG Instance
|
||||
* @retval Value between Min_Data=0 and Max_Data=0x0FFF
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_IWDG_GetReloadCounter(IWDG_TypeDef *IWDGx)
|
||||
{
|
||||
return (uint32_t)(READ_REG(IWDGx->RLR));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup IWDG_LL_EF_FLAG_Management FLAG_Management
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Check if flag Prescaler Value Update is set or not
|
||||
* @rmtoll SR PVU LL_IWDG_IsActiveFlag_PVU
|
||||
* @param IWDGx IWDG Instance
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_IWDG_IsActiveFlag_PVU(IWDG_TypeDef *IWDGx)
|
||||
{
|
||||
return (READ_BIT(IWDGx->SR, IWDG_SR_PVU) == (IWDG_SR_PVU));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if flag Reload Value Update is set or not
|
||||
* @rmtoll SR RVU LL_IWDG_IsActiveFlag_RVU
|
||||
* @param IWDGx IWDG Instance
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_IWDG_IsActiveFlag_RVU(IWDG_TypeDef *IWDGx)
|
||||
{
|
||||
return (READ_BIT(IWDGx->SR, IWDG_SR_RVU) == (IWDG_SR_RVU));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if all flags Prescaler, Reload & Window Value Update are reset or not
|
||||
* @rmtoll SR PVU LL_IWDG_IsReady\n
|
||||
* SR RVU LL_IWDG_IsReady
|
||||
* @param IWDGx IWDG Instance
|
||||
* @retval State of bits (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_IWDG_IsReady(IWDG_TypeDef *IWDGx)
|
||||
{
|
||||
return (READ_BIT(IWDGx->SR, IWDG_SR_PVU | IWDG_SR_RVU) == 0U);
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* IWDG */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* PY32F0XX_LL_IWDG_H */
|
||||
|
||||
/************************ (C) COPYRIGHT Puya *****END OF FILE****/
|
||||
475
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_ll_led.h
Normal file
475
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_ll_led.h
Normal file
@@ -0,0 +1,475 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file py32f0xx_ll_led.h
|
||||
* @author MCU Application Team
|
||||
* @brief Header file of LED LL module.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) Puya Semiconductor Co.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef PY32F0XX_LL_LED_H
|
||||
#define PY32F0XX_LL_LED_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "py32f0xx.h"
|
||||
|
||||
/** @addtogroup PY32F0XX_LL_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if defined (LED)
|
||||
/** @defgroup LED_LL LED
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Private types -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
/* Private macros ------------------------------------------------------------*/
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief LED Init Structure definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t ComDrive; /*!< Specifies the LED COM drive capability.
|
||||
This parameter can be a value of @ref LED_LL_EC_ComDrive */
|
||||
|
||||
uint32_t Prescaler; /*!< Specifies the prescaler value used to divide the LED clock.
|
||||
This parameter can be a number between Min_Data = 0x00(div1) and Max_Data = 0xFF(div256) */
|
||||
|
||||
uint32_t ComSelect; /*!< Specifies the number of COM open.
|
||||
This parameter can be a value of @ref LED_LL_EC_ComSelct */
|
||||
|
||||
uint32_t LightTime; /*!< Specifies LED Lighting time.
|
||||
This parameter can be a number between Min_Data = 1 and Max_Data = 0xFF */
|
||||
|
||||
uint32_t DeadTime; /*!< Specifies LED Dead time.
|
||||
This parameter can be a number between Min_Data = 1 and Max_Data = 0xFF */
|
||||
|
||||
} LL_LED_InitTypeDef;
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/** @defgroup LED_LL_EC_ComDrive ComDrive
|
||||
* @{
|
||||
*/
|
||||
#define LL_LED_COMDRIVE_LOW 0x00000000U
|
||||
#define LL_LED_COMDRIVE_HIGH LED_CR_EHS
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup LED_LL_EC_ComSelct the number of COM open
|
||||
* @{
|
||||
*/
|
||||
#define LL_LED_COMSELECT_1COM 0x00000000U
|
||||
#define LL_LED_COMSELECT_2COM LED_CR_LED_COM_SEL_0
|
||||
#define LL_LED_COMSELECT_3COM LED_CR_LED_COM_SEL_1
|
||||
#define LL_LED_COMSELECT_4COM (LED_CR_LED_COM_SEL_1 | LED_CR_LED_COM_SEL_0)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup LED_LL_EC_DisplayValue LED display value
|
||||
* @{
|
||||
*/
|
||||
#define LL_LED_DISP_NONE 0x00U
|
||||
#define LL_LED_DISP_FULL 0xFFU
|
||||
|
||||
#define LL_LED_DISP_0 0x3FU
|
||||
#define LL_LED_DISP_1 0x06U
|
||||
#define LL_LED_DISP_2 0x5BU
|
||||
#define LL_LED_DISP_3 0x4FU
|
||||
#define LL_LED_DISP_4 0x66U
|
||||
#define LL_LED_DISP_5 0x6DU
|
||||
#define LL_LED_DISP_6 0x7DU
|
||||
#define LL_LED_DISP_7 0x07U
|
||||
#define LL_LED_DISP_8 0x7FU
|
||||
#define LL_LED_DISP_9 0x6FU
|
||||
#define LL_LED_DISP_A 0x77U
|
||||
#define LL_LED_DISP_B 0x7CU
|
||||
#define LL_LED_DISP_C 0x39U
|
||||
#define LL_LED_DISP_D 0x5EU
|
||||
#define LL_LED_DISP_E 0x79U
|
||||
#define LL_LED_DISP_F 0x71U
|
||||
#define LL_LED_DISP_H 0x76U
|
||||
#define LL_LED_DISP_P 0x73U
|
||||
#define LL_LED_DISP_U 0x3EU
|
||||
#define LL_LED_DISP_DOT 0x80U
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup LED_LL_EC_ComDisplay LED COM Select
|
||||
* @{
|
||||
*/
|
||||
#define LL_LED_COM0 0x00000000U
|
||||
#define LL_LED_COM1 0x00000004U
|
||||
#define LL_LED_COM2 0x00000008U
|
||||
#define LL_LED_COM3 0x0000000CU
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup LED_LL_EC_DataReg Data Register Mask and position
|
||||
* @{
|
||||
*/
|
||||
#define LL_LED_DR_DATA LED_DR0_DATA0
|
||||
#define LL_LED_DR_DATA_Pos LED_DR0_DATA0_Pos
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Set the LED COM drive capability.
|
||||
* @param LEDx LED Instance
|
||||
* @param ComDrive This parameter can be one of the following values:
|
||||
* @arg @ref LL_LED_COMDRIVE_LOW
|
||||
* @arg @ref LL_LED_COMDRIVE_HIGH
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_LED_SetComDrive(LED_TypeDef *LEDx, uint32_t ComDrive)
|
||||
{
|
||||
MODIFY_REG(LEDx->CR, LED_CR_EHS, ComDrive);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the LED COM drive capability.
|
||||
* @param LEDx LED Instance
|
||||
* @retval Returned value can be one of the following values:
|
||||
* @arg @ref LL_LED_COMDRIVE_LOW
|
||||
* @arg @ref LL_LED_COMDRIVE_HIGH
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_LED_GetComDrive(LED_TypeDef *LEDx)
|
||||
{
|
||||
return (READ_BIT(LEDx->CR, LED_CR_EHS));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable LED Interrupt.
|
||||
* @param LEDx LED Instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_LED_EnableIT(LED_TypeDef *LEDx)
|
||||
{
|
||||
SET_BIT(LEDx->CR, LED_CR_IE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable LED Interrupt.
|
||||
* @param LEDx LED Instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_LED_DisableIT(LED_TypeDef *LEDx)
|
||||
{
|
||||
CLEAR_BIT(LEDx->CR, LED_CR_IE);
|
||||
}
|
||||
/**
|
||||
* @brief Check if LED Interrupt is enabled
|
||||
* @param LEDx LED Instance
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_LED_IsEnabledIT(LED_TypeDef *LEDx)
|
||||
{
|
||||
return ((READ_BIT(LEDx->CR, LED_CR_IE) == (LED_CR_IE)) ? 1UL : 0UL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set he number of COM open.
|
||||
* @param LEDx LED Instance
|
||||
* @param ComNum This parameter can be one of the following values:
|
||||
* @arg @ref LL_LED_COMSELECT_1COM
|
||||
* @arg @ref LL_LED_COMSELECT_2COM
|
||||
* @arg @ref LL_LED_COMSELECT_3COM
|
||||
* @arg @ref LL_LED_COMSELECT_4COM
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_LED_SetComNum(LED_TypeDef *LEDx, uint32_t ComNum)
|
||||
{
|
||||
MODIFY_REG(LEDx->CR, LED_CR_LED_COM_SEL, ComNum);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the number of COM open.
|
||||
* @param LEDx LED Instance
|
||||
* @retval Returned value can be one of the following values:
|
||||
* @arg @ref LL_LED_COMSELECT_1COM
|
||||
* @arg @ref LL_LED_COMSELECT_2COM
|
||||
* @arg @ref LL_LED_COMSELECT_3COM
|
||||
* @arg @ref LL_LED_COMSELECT_4COM
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_LED_GetComNum(LED_TypeDef *LEDx)
|
||||
{
|
||||
return (READ_BIT(LEDx->CR, LED_CR_LED_COM_SEL));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Enable LED.
|
||||
* @param LEDx LED Instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_LED_Enable(LED_TypeDef *LEDx)
|
||||
{
|
||||
SET_BIT(LEDx->CR, LED_CR_LEDON);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable LED.
|
||||
* @param LEDx LED Instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_LED_Disable(LED_TypeDef *LEDx)
|
||||
{
|
||||
CLEAR_BIT(LEDx->CR, LED_CR_LEDON);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Checks if LED is enabled
|
||||
* @param LEDx LED Instance
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_LED_IsEnabled(LED_TypeDef *LEDx)
|
||||
{
|
||||
return ((READ_BIT(LEDx->CR, LED_CR_LEDON) == (LED_CR_LEDON)) ? 1UL : 0UL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the LED prescale Value.
|
||||
* @param LEDx LED Instance
|
||||
* @param Prescaler This parameter can be a number between Min_Data = 0x00(div1)
|
||||
* and Max_Data = 0xFF(div256)
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_LED_SetPrescaler(LED_TypeDef *LEDx, uint32_t Prescaler)
|
||||
{
|
||||
MODIFY_REG(LEDx->PR, LED_PR_PR, (Prescaler << LED_PR_PR_Pos));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return LED Prescaler Value.
|
||||
* @param LEDx LED Instance
|
||||
* @retval Returned value can be a number between Min_Data = 0x00(div1)
|
||||
* and Max_Data = 0xFF(div256)
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_LED_GetPrescaler(LED_TypeDef *LEDx)
|
||||
{
|
||||
return (READ_BIT(LEDx->PR, LED_PR_PR) >> LED_PR_PR_Pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the LED Lighting and Dead time.
|
||||
* @param LEDx LED Instance
|
||||
* @param LightTime This parameter can be a number between Min_Data = 1 and
|
||||
* Max_Data = 0xFF
|
||||
* @param DeadTime This parameter can be a number between Min_Data = 1 and
|
||||
* Max_Data = 0xFF
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_LED_SetLightAndDeadTime(LED_TypeDef *LEDx,\
|
||||
uint32_t LightTime, uint32_t DeadTime)
|
||||
{
|
||||
MODIFY_REG(LEDx->TR, (LED_TR_T1 | LED_TR_T2), ((LightTime << LED_TR_T1_Pos) |\
|
||||
(DeadTime << LED_TR_T2_Pos)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the LED Lighting time.
|
||||
* @param LEDx LED Instance
|
||||
* @param LightTime This parameter can be a number between Min_Data = 1 and
|
||||
* Max_Data = 0xFF
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_LED_SetLightTime(LED_TypeDef *LEDx, uint32_t LightTime)
|
||||
{
|
||||
MODIFY_REG(LEDx->TR, LED_TR_T1, (LightTime << LED_TR_T1_Pos));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the LED Dead time.
|
||||
* @param LEDx LED Instance
|
||||
* @param DeadTime This parameter can be a number between Min_Data = 1 and
|
||||
* Max_Data = 0xFF
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_LED_SetDeadTime(LED_TypeDef *LEDx, uint32_t DeadTime)
|
||||
{
|
||||
MODIFY_REG(LEDx->TR, LED_TR_T2, (DeadTime << LED_TR_T2_Pos));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the LED Lighting time.
|
||||
* @param LEDx LED Instance
|
||||
* @retval Returned value can be a number between Min_Data = 1 and
|
||||
* Max_Data = 0xFF
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_LED_GetLightTime(LED_TypeDef *LEDx)
|
||||
{
|
||||
return (READ_BIT(LEDx->TR, LED_TR_T1) >> LED_TR_T1_Pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the LED Dead time.
|
||||
* @param LEDx LED Instance
|
||||
* @retval Returned value can be a number between Min_Data = 1 and
|
||||
* Max_Data = 0xFF
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_LED_GetDeadTime(LED_TypeDef *LEDx)
|
||||
{
|
||||
return (READ_BIT(LEDx->TR, LED_TR_T2) >> LED_TR_T2_Pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the LED display value.
|
||||
* @param LEDx LED Instance
|
||||
* @param comCh Specify COM channels.This parameter can be one of the following values:
|
||||
* @arg @ref LL_LED_COM0
|
||||
* @arg @ref LL_LED_COM1
|
||||
* @arg @ref LL_LED_COM2
|
||||
* @arg @ref LL_LED_COM3
|
||||
* @param data Specify display values.This parameter can be one of the following values:
|
||||
* @arg @ref LL_LED_DISP_NONE
|
||||
* @arg @ref LL_LED_DISP_FULL
|
||||
* @arg @ref LL_LED_DISP_0
|
||||
* @arg @ref LL_LED_DISP_1
|
||||
* @arg @ref LL_LED_DISP_2
|
||||
* @arg @ref LL_LED_DISP_3
|
||||
* @arg @ref LL_LED_DISP_4
|
||||
* @arg @ref LL_LED_DISP_5
|
||||
* @arg @ref LL_LED_DISP_6
|
||||
* @arg @ref LL_LED_DISP_7
|
||||
* @arg @ref LL_LED_DISP_8
|
||||
* @arg @ref LL_LED_DISP_9
|
||||
* @arg @ref LL_LED_DISP_A
|
||||
* @arg @ref LL_LED_DISP_B
|
||||
* @arg @ref LL_LED_DISP_C
|
||||
* @arg @ref LL_LED_DISP_D
|
||||
* @arg @ref LL_LED_DISP_E
|
||||
* @arg @ref LL_LED_DISP_F
|
||||
* @arg @ref LL_LED_DISP_H
|
||||
* @arg @ref LL_LED_DISP_P
|
||||
* @arg @ref LL_LED_DISP_U
|
||||
* @arg @ref LL_LED_DISP_DOT
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_LED_SetDisplayValue(LED_TypeDef *LEDx,uint32_t comCh,\
|
||||
uint32_t data)
|
||||
{
|
||||
MODIFY_REG((*((uint32_t *)((uint32_t)&(LEDx->DR0) + comCh))), LL_LED_DR_DATA,\
|
||||
(data << LL_LED_DR_DATA_Pos));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the LED display value.
|
||||
* @param LEDx LED Instance
|
||||
* @param comCh Specify COM channels.This parameter can be one of the following values:
|
||||
* @arg @ref LL_LED_COM0
|
||||
* @arg @ref LL_LED_COM1
|
||||
* @arg @ref LL_LED_COM2
|
||||
* @arg @ref LL_LED_COM3
|
||||
* @retval Returned value can be one of the following values:
|
||||
* @arg @ref LL_LED_DISP_NONE
|
||||
* @arg @ref LL_LED_DISP_FULL
|
||||
* @arg @ref LL_LED_DISP_0
|
||||
* @arg @ref LL_LED_DISP_1
|
||||
* @arg @ref LL_LED_DISP_2
|
||||
* @arg @ref LL_LED_DISP_3
|
||||
* @arg @ref LL_LED_DISP_4
|
||||
* @arg @ref LL_LED_DISP_5
|
||||
* @arg @ref LL_LED_DISP_6
|
||||
* @arg @ref LL_LED_DISP_7
|
||||
* @arg @ref LL_LED_DISP_8
|
||||
* @arg @ref LL_LED_DISP_9
|
||||
* @arg @ref LL_LED_DISP_A
|
||||
* @arg @ref LL_LED_DISP_B
|
||||
* @arg @ref LL_LED_DISP_C
|
||||
* @arg @ref LL_LED_DISP_D
|
||||
* @arg @ref LL_LED_DISP_E
|
||||
* @arg @ref LL_LED_DISP_F
|
||||
* @arg @ref LL_LED_DISP_H
|
||||
* @arg @ref LL_LED_DISP_P
|
||||
* @arg @ref LL_LED_DISP_U
|
||||
* @arg @ref LL_LED_DISP_DOT
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_LED_GetDisplayValue(LED_TypeDef *LEDx, uint32_t comCh)
|
||||
{
|
||||
return ((READ_BIT((*((uint32_t *)((uint32_t)&(LEDx->DR0) + comCh))), LL_LED_DR_DATA))\
|
||||
>> LL_LED_DR_DATA_Pos);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get the LED interrupt flag.
|
||||
* @param LEDx LED Instance
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_LED_IsActiveFlag_IT(LED_TypeDef *LEDx)
|
||||
{
|
||||
return ((READ_BIT(LEDx->IR, LED_IR_FLAG) == (LED_IR_FLAG)) ? 1UL : 0UL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief the LED interrupt flag.
|
||||
* @param LEDx LED Instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_LED_ClearFlag_IT(LED_TypeDef *LEDx)
|
||||
{
|
||||
SET_BIT(LEDx->IR, LED_IR_FLAG);
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#if defined(USE_FULL_LL_DRIVER)
|
||||
/** @defgroup LED_LL_EF_Init Initialization and de-initialization functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
ErrorStatus LL_LED_DeInit(LED_TypeDef *LEDx);
|
||||
ErrorStatus LL_LED_Init(LED_TypeDef *LEDx, LL_LED_InitTypeDef *LED_InitStruct);
|
||||
void LL_LED_StructInit(LL_LED_InitTypeDef *LED_InitStruct);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif /* USE_FULL_LL_DRIVER */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* LED */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* PY32F0xx_LL_LED_H */
|
||||
|
||||
/************************ (C) COPYRIGHT Puya *****END OF FILE****/
|
||||
499
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_ll_lptim.h
Normal file
499
py_project/Drivers/PY32F0xx_HAL_Driver/Inc/py32f0xx_ll_lptim.h
Normal file
@@ -0,0 +1,499 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file py32f0xx_ll_lptim.h
|
||||
* @author MCU Application Team
|
||||
* @brief Header file of LPTIM LL module.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) Puya Semiconductor Co.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef PY32F0XX_LL_LPTIM_H
|
||||
#define PY32F0XX_LL_LPTIM_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "py32f0xx.h"
|
||||
|
||||
/** @addtogroup PY32F0XX_LL_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if defined (LPTIM)
|
||||
|
||||
/** @defgroup LPTIM_LL LPTIM
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Private types -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
|
||||
/* Private constants ---------------------------------------------------------*/
|
||||
|
||||
/* Private macros ------------------------------------------------------------*/
|
||||
#if defined(USE_FULL_LL_DRIVER)
|
||||
/** @defgroup LPTIM_LL_Private_Macros LPTIM Private Macros
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif /*USE_FULL_LL_DRIVER*/
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
#if defined(USE_FULL_LL_DRIVER)
|
||||
/** @defgroup LPTIM_LL_ES_INIT LPTIM Exported Init structure
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief LPTIM Init structure definition
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
|
||||
uint32_t Prescaler; /*!< Specifies the prescaler division ratio.
|
||||
This parameter can be a value of @ref LPTIM_LL_EC_PRESCALER.
|
||||
|
||||
This feature can be modified afterwards using using unitary
|
||||
function @ref LL_LPTIM_SetPrescaler().*/
|
||||
|
||||
uint32_t UpdateMode; /*!< Specifies whether to update immediately or after the end
|
||||
of current period.
|
||||
This parameter can be a value of @ref LPTIM_LL_EC_UPDATE_MODE
|
||||
|
||||
This feature can be modified afterwards using using unitary
|
||||
function @ref LL_LPTIM_SetUpdateMode().*/
|
||||
} LL_LPTIM_InitTypeDef;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif /* USE_FULL_LL_DRIVER */
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/** @defgroup LPTIM_LL_Exported_Constants LPTIM Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup LPTIM_LL_EC_GET_FLAG Get Flags Defines
|
||||
* @brief Flags defines which can be used with LL_LPTIM_ReadReg function
|
||||
* @{
|
||||
*/
|
||||
#define LL_LPTIM_ISR_ARRM LPTIM_ISR_ARRM /*!< Autoreload match */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup LPTIM_LL_EC_IT IT Defines
|
||||
* @brief IT defines which can be used with LL_LPTIM_ReadReg and LL_LPTIM_WriteReg functions
|
||||
* @{
|
||||
*/
|
||||
#define LL_LPTIM_IER_ARRMIE LPTIM_IER_ARRMIE /*!< Autoreload match */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup LPTIM_LL_EC_OPERATING_MODE Operating Mode
|
||||
* @{
|
||||
*/
|
||||
#define LL_LPTIM_OPERATING_MODE_ONESHOT LPTIM_CR_SNGSTRT /*!<LP Tilmer starts in single mode*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup LPTIM_LL_EC_UPDATE_MODE Update Mode
|
||||
* @{
|
||||
*/
|
||||
#define LL_LPTIM_UPDATE_MODE_IMMEDIATE 0x00000000U /*!<Preload is disabled: registers are updated after each APB bus write access*/
|
||||
#define LL_LPTIM_UPDATE_MODE_ENDOFPERIOD LPTIM_CFGR_PRELOAD /*!<preload is enabled: registers are updated at the end of the current LPTIM period*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup LPTIM_LL_EC_PRESCALER Prescaler Value
|
||||
* @{
|
||||
*/
|
||||
#define LL_LPTIM_PRESCALER_DIV1 0x00000000U /*!<Prescaler division factor is set to 1*/
|
||||
#define LL_LPTIM_PRESCALER_DIV2 LPTIM_CFGR_PRESC_0 /*!<Prescaler division factor is set to 2*/
|
||||
#define LL_LPTIM_PRESCALER_DIV4 LPTIM_CFGR_PRESC_1 /*!<Prescaler division factor is set to 4*/
|
||||
#define LL_LPTIM_PRESCALER_DIV8 (LPTIM_CFGR_PRESC_1 | LPTIM_CFGR_PRESC_0) /*!<Prescaler division factor is set to 8*/
|
||||
#define LL_LPTIM_PRESCALER_DIV16 LPTIM_CFGR_PRESC_2 /*!<Prescaler division factor is set to 16*/
|
||||
#define LL_LPTIM_PRESCALER_DIV32 (LPTIM_CFGR_PRESC_2 | LPTIM_CFGR_PRESC_0) /*!<Prescaler division factor is set to 32*/
|
||||
#define LL_LPTIM_PRESCALER_DIV64 (LPTIM_CFGR_PRESC_2 | LPTIM_CFGR_PRESC_1) /*!<Prescaler division factor is set to 64*/
|
||||
#define LL_LPTIM_PRESCALER_DIV128 LPTIM_CFGR_PRESC /*!<Prescaler division factor is set to 128*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/** @defgroup LPTIM_LL_Exported_Macros LPTIM Exported Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup LPTIM_LL_EM_WRITE_READ Common Write and read registers Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Write a value in LPTIM register
|
||||
* @param __INSTANCE__ LPTIM Instance
|
||||
* @param __REG__ Register to be written
|
||||
* @param __VALUE__ Value to be written in the register
|
||||
* @retval None
|
||||
*/
|
||||
#define LL_LPTIM_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG((__INSTANCE__)->__REG__, (__VALUE__))
|
||||
|
||||
/**
|
||||
* @brief Read a value in LPTIM register
|
||||
* @param __INSTANCE__ LPTIM Instance
|
||||
* @param __REG__ Register to be read
|
||||
* @retval Register value
|
||||
*/
|
||||
#define LL_LPTIM_ReadReg(__INSTANCE__, __REG__) READ_REG((__INSTANCE__)->__REG__)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
/** @defgroup LPTIM_LL_Exported_Functions LPTIM Exported Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if defined(USE_FULL_LL_DRIVER)
|
||||
/** @defgroup LPTIM_LL_EF_Init Initialisation and deinitialisation functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
ErrorStatus LL_LPTIM_DeInit(LPTIM_TypeDef *LPTIMx);
|
||||
void LL_LPTIM_StructInit(LL_LPTIM_InitTypeDef *LPTIM_InitStruct);
|
||||
ErrorStatus LL_LPTIM_Init(LPTIM_TypeDef *LPTIMx, LL_LPTIM_InitTypeDef *LPTIM_InitStruct);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif /* USE_FULL_LL_DRIVER */
|
||||
|
||||
/** @defgroup LPTIM_LL_EF_LPTIM_Configuration LPTIM Configuration
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Enable the LPTIM instance
|
||||
* @note After setting the ENABLE bit, a delay of two counter clock is needed
|
||||
* before the LPTIM instance is actually enabled.
|
||||
* @rmtoll CR ENABLE LL_LPTIM_Enable
|
||||
* @param LPTIMx Low-Power Timer instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_LPTIM_Enable(LPTIM_TypeDef *LPTIMx)
|
||||
{
|
||||
SET_BIT(LPTIMx->CR, LPTIM_CR_ENABLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable the LPTIM instance
|
||||
* @rmtoll CR ENABLE LL_LPTIM_Disable
|
||||
* @param LPTIMx Low-Power Timer instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_LPTIM_Disable(LPTIM_TypeDef *LPTIMx)
|
||||
{
|
||||
CLEAR_BIT(LPTIMx->CR, LPTIM_CR_ENABLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Indicates whether the LPTIM instance is enabled.
|
||||
* @rmtoll CR ENABLE LL_LPTIM_IsEnabled
|
||||
* @param LPTIMx Low-Power Timer instance
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_LPTIM_IsEnabled(LPTIM_TypeDef *LPTIMx)
|
||||
{
|
||||
return (((READ_BIT(LPTIMx->CR, LPTIM_CR_ENABLE) == LPTIM_CR_ENABLE) ? 1UL : 0UL));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Starts the LPTIM counter in the desired mode.
|
||||
* @note LPTIM instance must be enabled before starting the counter.
|
||||
* @rmtoll CR SNGSTRT LL_LPTIM_StartCounter
|
||||
* @param LPTIMx Low-Power Timer instance
|
||||
* @param OperatingMode This parameter can be one of the following values:
|
||||
* @arg @ref LL_LPTIM_OPERATING_MODE_ONESHOT
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_LPTIM_StartCounter(LPTIM_TypeDef *LPTIMx, uint32_t OperatingMode)
|
||||
{
|
||||
MODIFY_REG(LPTIMx->CR, LPTIM_CR_SNGSTRT, OperatingMode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable reset after read.
|
||||
* @note After calling this function any read access to LPTIM_CNT
|
||||
* register will asynchronously reset the LPTIM_CNT register content.
|
||||
* @rmtoll CR RSTARE LL_LPTIM_EnableResetAfterRead
|
||||
* @param LPTIMx Low-Power Timer instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_LPTIM_EnableResetAfterRead(LPTIM_TypeDef *LPTIMx)
|
||||
{
|
||||
SET_BIT(LPTIMx->CR, LPTIM_CR_RSTARE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable reset after read.
|
||||
* @rmtoll CR RSTARE LL_LPTIM_DisableResetAfterRead
|
||||
* @param LPTIMx Low-Power Timer instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_LPTIM_DisableResetAfterRead(LPTIM_TypeDef *LPTIMx)
|
||||
{
|
||||
CLEAR_BIT(LPTIMx->CR, LPTIM_CR_RSTARE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Indicate whether the reset after read feature is enabled.
|
||||
* @rmtoll CR RSTARE LL_LPTIM_IsEnabledResetAfterRead
|
||||
* @param LPTIMx Low-Power Timer instance
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_LPTIM_IsEnabledResetAfterRead(LPTIM_TypeDef *LPTIMx)
|
||||
{
|
||||
return (((READ_BIT(LPTIMx->CR, LPTIM_CR_RSTARE) == LPTIM_CR_RSTARE) ? 1UL : 0UL));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the LPTIM registers update mode (enable/disable register preload)
|
||||
* @note This function must be called when the LPTIM instance is disabled.
|
||||
* @rmtoll CFGR PRELOAD LL_LPTIM_SetUpdateMode
|
||||
* @param LPTIMx Low-Power Timer instance
|
||||
* @param UpdateMode This parameter can be one of the following values:
|
||||
* @arg @ref LL_LPTIM_UPDATE_MODE_IMMEDIATE
|
||||
* @arg @ref LL_LPTIM_UPDATE_MODE_ENDOFPERIOD
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_LPTIM_SetUpdateMode(LPTIM_TypeDef *LPTIMx, uint32_t UpdateMode)
|
||||
{
|
||||
MODIFY_REG(LPTIMx->CFGR, LPTIM_CFGR_PRELOAD, UpdateMode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the LPTIM registers update mode
|
||||
* @rmtoll CFGR PRELOAD LL_LPTIM_GetUpdateMode
|
||||
* @param LPTIMx Low-Power Timer instance
|
||||
* @retval Returned value can be one of the following values:
|
||||
* @arg @ref LL_LPTIM_UPDATE_MODE_IMMEDIATE
|
||||
* @arg @ref LL_LPTIM_UPDATE_MODE_ENDOFPERIOD
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_LPTIM_GetUpdateMode(LPTIM_TypeDef *LPTIMx)
|
||||
{
|
||||
return (uint32_t)(READ_BIT(LPTIMx->CFGR, LPTIM_CFGR_PRELOAD));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the auto reload value
|
||||
* @note The LPTIMx_ARR register content must only be modified when the LPTIM is enabled
|
||||
* @note After a write to the LPTIMx_ARR register a new write operation to the
|
||||
* same register can only be performed when the previous write operation
|
||||
* is completed. Any successive write before the ARROK flag is set, will
|
||||
* lead to unpredictable results.
|
||||
* @note autoreload value be strictly greater than the compare value.
|
||||
* @rmtoll ARR ARR LL_LPTIM_SetAutoReload
|
||||
* @param LPTIMx Low-Power Timer instance
|
||||
* @param AutoReload Value between Min_Data=0x00 and Max_Data=0xFFFF
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_LPTIM_SetAutoReload(LPTIM_TypeDef *LPTIMx, uint32_t AutoReload)
|
||||
{
|
||||
MODIFY_REG(LPTIMx->ARR, LPTIM_ARR_ARR, AutoReload);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get actual auto reload value
|
||||
* @rmtoll ARR ARR LL_LPTIM_GetAutoReload
|
||||
* @param LPTIMx Low-Power Timer instance
|
||||
* @retval AutoReload Value between Min_Data=0x00 and Max_Data=0xFFFF
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_LPTIM_GetAutoReload(LPTIM_TypeDef *LPTIMx)
|
||||
{
|
||||
return (uint32_t)(READ_BIT(LPTIMx->ARR, LPTIM_ARR_ARR));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get actual counter value
|
||||
* @note When the LPTIM instance is running with an asynchronous clock, reading
|
||||
* the LPTIMx_CNT register may return unreliable values. So in this case
|
||||
* it is necessary to perform two consecutive read accesses and verify
|
||||
* that the two returned values are identical.
|
||||
* @rmtoll CNT CNT LL_LPTIM_GetCounter
|
||||
* @param LPTIMx Low-Power Timer instance
|
||||
* @retval Counter value
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_LPTIM_GetCounter(LPTIM_TypeDef *LPTIMx)
|
||||
{
|
||||
return (uint32_t)(READ_BIT(LPTIMx->CNT, LPTIM_CNT_CNT));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set actual prescaler division ratio.
|
||||
* @note This function must be called when the LPTIM instance is disabled.
|
||||
* @note When the LPTIM is configured to be clocked by an internal clock source
|
||||
* and the LPTIM counter is configured to be updated by active edges
|
||||
* detected on the LPTIM external Input1, the internal clock provided to
|
||||
* the LPTIM must be not be prescaled.
|
||||
* @rmtoll CFGR PRESC LL_LPTIM_SetPrescaler
|
||||
* @param LPTIMx Low-Power Timer instance
|
||||
* @param Prescaler This parameter can be one of the following values:
|
||||
* @arg @ref LL_LPTIM_PRESCALER_DIV1
|
||||
* @arg @ref LL_LPTIM_PRESCALER_DIV2
|
||||
* @arg @ref LL_LPTIM_PRESCALER_DIV4
|
||||
* @arg @ref LL_LPTIM_PRESCALER_DIV8
|
||||
* @arg @ref LL_LPTIM_PRESCALER_DIV16
|
||||
* @arg @ref LL_LPTIM_PRESCALER_DIV32
|
||||
* @arg @ref LL_LPTIM_PRESCALER_DIV64
|
||||
* @arg @ref LL_LPTIM_PRESCALER_DIV128
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_LPTIM_SetPrescaler(LPTIM_TypeDef *LPTIMx, uint32_t Prescaler)
|
||||
{
|
||||
MODIFY_REG(LPTIMx->CFGR, LPTIM_CFGR_PRESC, Prescaler);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get actual prescaler division ratio.
|
||||
* @rmtoll CFGR PRESC LL_LPTIM_GetPrescaler
|
||||
* @param LPTIMx Low-Power Timer instance
|
||||
* @retval Returned value can be one of the following values:
|
||||
* @arg @ref LL_LPTIM_PRESCALER_DIV1
|
||||
* @arg @ref LL_LPTIM_PRESCALER_DIV2
|
||||
* @arg @ref LL_LPTIM_PRESCALER_DIV4
|
||||
* @arg @ref LL_LPTIM_PRESCALER_DIV8
|
||||
* @arg @ref LL_LPTIM_PRESCALER_DIV16
|
||||
* @arg @ref LL_LPTIM_PRESCALER_DIV32
|
||||
* @arg @ref LL_LPTIM_PRESCALER_DIV64
|
||||
* @arg @ref LL_LPTIM_PRESCALER_DIV128
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_LPTIM_GetPrescaler(LPTIM_TypeDef *LPTIMx)
|
||||
{
|
||||
return (uint32_t)(READ_BIT(LPTIMx->CFGR, LPTIM_CFGR_PRESC));
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup LPTIM_LL_EF_FLAG_Management FLAG Management
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Clear the autoreload match flag (ARRMCF)
|
||||
* @rmtoll ICR ARRMCF LL_LPTIM_ClearFLAG_ARRM
|
||||
* @param LPTIMx Low-Power Timer instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_LPTIM_ClearFLAG_ARRM(LPTIM_TypeDef *LPTIMx)
|
||||
{
|
||||
SET_BIT(LPTIMx->ICR, LPTIM_ICR_ARRMCF);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Inform application whether a autoreload match interrupt has occurred.
|
||||
* @rmtoll ISR ARRM LL_LPTIM_IsActiveFlag_ARRM
|
||||
* @param LPTIMx Low-Power Timer instance
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_LPTIM_IsActiveFlag_ARRM(LPTIM_TypeDef *LPTIMx)
|
||||
{
|
||||
return (((READ_BIT(LPTIMx->ISR, LPTIM_ISR_ARRM) == LPTIM_ISR_ARRM) ? 1UL : 0UL));
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup LPTIM_LL_EF_IT_Management Interrupt Management
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Enable autoreload match interrupt (ARRMIE).
|
||||
* @rmtoll IER ARRMIE LL_LPTIM_EnableIT_ARRM
|
||||
* @param LPTIMx Low-Power Timer instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_LPTIM_EnableIT_ARRM(LPTIM_TypeDef *LPTIMx)
|
||||
{
|
||||
SET_BIT(LPTIMx->IER, LPTIM_IER_ARRMIE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable autoreload match interrupt (ARRMIE).
|
||||
* @rmtoll IER ARRMIE LL_LPTIM_DisableIT_ARRM
|
||||
* @param LPTIMx Low-Power Timer instance
|
||||
* @retval None
|
||||
*/
|
||||
__STATIC_INLINE void LL_LPTIM_DisableIT_ARRM(LPTIM_TypeDef *LPTIMx)
|
||||
{
|
||||
CLEAR_BIT(LPTIMx->IER, LPTIM_IER_ARRMIE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Indicates whether the autoreload match interrupt (ARRMIE) is enabled.
|
||||
* @rmtoll IER ARRMIE LL_LPTIM_IsEnabledIT_ARRM
|
||||
* @param LPTIMx Low-Power Timer instance
|
||||
* @retval State of bit (1 or 0).
|
||||
*/
|
||||
__STATIC_INLINE uint32_t LL_LPTIM_IsEnabledIT_ARRM(LPTIM_TypeDef *LPTIMx)
|
||||
{
|
||||
return (((READ_BIT(LPTIMx->IER, LPTIM_IER_ARRMIE) == LPTIM_IER_ARRMIE) ? 1UL : 0UL));
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* LPTIM */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* PY32F0XX_LL_LPTIM_H */
|
||||
|
||||
/************************ (C) COPYRIGHT Puya *****END OF FILE****/
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user