feat: ll lib option

This commit is contained in:
IOsetting 2022-12-12 23:07:35 +08:00
parent 061ec26799
commit dafe61f45e
47 changed files with 27483 additions and 26983 deletions

View File

@ -0,0 +1,130 @@
/**
******************************************************************************
* @file main.c
* @author MCU Application Team
* @brief Main program body
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) Puya Semiconductor Co.
* All rights reserved.</center></h2>
*
* <h2><center>&copy; 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
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "py32f003xx_ll_Start_Kit.h"
/* Private define ------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private user code ---------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
static void APP_SystemClockConfig(void);
static void APP_GpioConfig(void);
/**
* @brief .
* @retval int
*/
int main(void)
{
/* 配置系统时钟 */
APP_SystemClockConfig();
/* 初始化GPIO */
APP_GpioConfig();
while (1)
{
/* LED灯闪烁 */
LL_mDelay(500);
LL_GPIO_TogglePin(GPIOB,LL_GPIO_PIN_5);
}
}
/**
* @brief
* @param
* @retval
*/
static void APP_SystemClockConfig(void)
{
/* 使能HSI */
LL_RCC_HSI_Enable();
while(LL_RCC_HSI_IsReady() != 1)
{
}
/* 设置 AHB 分频*/
LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1);
/* 配置HSISYS作为系统时钟源 */
LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_HSISYS);
while(LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_HSISYS)
{
}
/* 设置 APB1 分频*/
LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_1);
LL_Init1msTick(8000000);
/* 更新系统时钟全局变量SystemCoreClock(也可以通过调用SystemCoreClockUpdate函数更新) */
LL_SetSystemCoreClock(8000000);
}
/**
* @brief GPIO
* @param
* @retval
*/
static void APP_GpioConfig(void)
{
/* 使能时钟 */
LL_IOP_GRP1_EnableClock(LL_IOP_GRP1_PERIPH_GPIOB);
/* 将PA5引脚配置为输出 */
LL_GPIO_SetPinMode(GPIOB, LL_GPIO_PIN_5, LL_GPIO_MODE_OUTPUT);
}
/**
* @brief
* @param
* @retval
*/
void APP_ErrorHandler(void)
{
/* 无限循环 */
while (1)
{
}
}
#ifdef USE_FULL_ASSERT
/**
* @brief
* @param file
* @param line
* @retval
*/
void assert_failed(uint8_t *file, uint32_t line)
{
/* 用户可以根据需要添加自己的打印信息,
: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* 无限循环 */
while (1)
{
}
}
#endif /* USE_FULL_ASSERT */
/************************ (C) COPYRIGHT Puya *****END OF FILE******************/

View File

@ -0,0 +1,59 @@
/**
******************************************************************************
* @file main.h
* @author MCU Application Team
* @brief Header for main.c file.
* This file contains the common defines of the application.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) Puya Semiconductor Co.
* All rights reserved.</center></h2>
*
* <h2><center>&copy; 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 __MAIN_H
#define __MAIN_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "py32f0xx_ll_rcc.h"
#include "py32f0xx_ll_bus.h"
#include "py32f0xx_ll_system.h"
#include "py32f0xx_ll_exti.h"
#include "py32f0xx_ll_cortex.h"
#include "py32f0xx_ll_utils.h"
#include "py32f0xx_ll_pwr.h"
#include "py32f0xx_ll_dma.h"
#include "py32f0xx_ll_gpio.h"
#if defined(USE_FULL_ASSERT)
#include "py32_assert.h"
#endif /* USE_FULL_ASSERT */
/* Private includes ----------------------------------------------------------*/
/* Private defines -----------------------------------------------------------*/
/* Exported variables prototypes ---------------------------------------------*/
/* Exported functions prototypes ---------------------------------------------*/
void APP_ErrorHandler(void);
#ifdef __cplusplus
}
#endif
#endif /* __MAIN_H */
/************************ (C) COPYRIGHT Puya *****END OF FILE******************/

View File

@ -0,0 +1,59 @@
/**
******************************************************************************
* @file py32_assert.h
* @brief PY32 assert file.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) Puya Semiconductor Co.
* All rights reserved.</center></h2>
*
* <h2><center>&copy; 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 __PY32_ASSERT_H
#define __PY32_ASSERT_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef USE_FULL_ASSERT
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Includes ------------------------------------------------------------------*/
#include "stdint.h"
/* Exported macro ------------------------------------------------------------*/
/**
* @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 /* __PY32_ASSERT_H */
/************************ (C) COPYRIGHT Puya *****END OF FILE******************/

View File

@ -0,0 +1,84 @@
/**
******************************************************************************
* @file py32f0xx_it.c
* @author MCU Application Team
* @brief Interrupt Service Routines.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) Puya Semiconductor Co.
* All rights reserved.</center></h2>
*
* <h2><center>&copy; 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
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "py32f0xx_it.h"
/* Private includes ----------------------------------------------------------*/
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private user code ---------------------------------------------------------*/
/* External variables --------------------------------------------------------*/
/******************************************************************************/
/* Cortex-M0+ Processor Interruption and Exception Handlers */
/******************************************************************************/
/**
* @brief This function handles Non maskable interrupt.
*/
void NMI_Handler(void)
{
}
/**
* @brief This function handles Hard fault interrupt.
*/
void HardFault_Handler(void)
{
while (1)
{
}
}
/**
* @brief This function handles System service call via SWI instruction.
*/
void SVC_Handler(void)
{
}
/**
* @brief This function handles Pendable request for system service.
*/
void PendSV_Handler(void)
{
}
/**
* @brief This function handles System tick timer.
*/
void SysTick_Handler(void)
{
}
/******************************************************************************/
/* PY32F0xx Peripheral Interrupt Handlers */
/* Add here the Interrupt Handlers for the used peripherals. */
/* For the available peripheral interrupt handler names, */
/* please refer to the startup file. */
/******************************************************************************/
/************************ (C) COPYRIGHT Puya *****END OF FILE******************/

View File

@ -0,0 +1,49 @@
/**
******************************************************************************
* @file py32f0xx_it.h
* @author MCU Application Team
* @brief This file contains the headers of the interrupt handlers.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) Puya Semiconductor Co.
* All rights reserved.</center></h2>
*
* <h2><center>&copy; 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_IT_H
#define __PY32F0XX_IT_H
#ifdef __cplusplus
extern "C" {
#endif
/* Private includes ----------------------------------------------------------*/
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
/* Exported functions prototypes ---------------------------------------------*/
void NMI_Handler(void);
void HardFault_Handler(void);
void SVC_Handler(void);
void PendSV_Handler(void);
void SysTick_Handler(void);
#ifdef __cplusplus
}
#endif
#endif /* __PY32F0XX_IT_H */
/************************ (C) COPYRIGHT Puya *****END OF FILE******************/

View File

@ -1,9 +1,9 @@
/** /**
****************************************************************************** ******************************************************************************
* @file py32f003xx_ll_Start_Kit.h * @file py32f003xx_ll_Start_Kit.h
* @author MCU Application Team * @author MCU Application Team
* @brief This file provides set of firmware functions to manage Leds, * @brief This file provides set of firmware functions to manage Leds,
* push-button available on Start Kit. * push-button available on Start Kit.
****************************************************************************** ******************************************************************************
* @attention * @attention
* *
@ -19,153 +19,126 @@
* opensource.org/licenses/BSD-3-Clause * opensource.org/licenses/BSD-3-Clause
* *
****************************************************************************** ******************************************************************************
*/ */
/* Define to prevent recursive inclusion -------------------------------------*/ /* Define to prevent recursive inclusion -------------------------------------*/
#ifndef PY32F0XX_LL_START_KIT_H #ifndef PY32F0XX_LL_START_KIT_H
#define PY32F0XX_LL_START_KIT_H #define PY32F0XX_LL_START_KIT_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/* Includes ------------------------------------------------------------------*/ /* Includes ------------------------------------------------------------------*/
#include <stdio.h> #include <stdio.h>
#include "py32f0xx_ll_rcc.h" #include "py32f0xx_ll_rcc.h"
#include "py32f0xx_ll_bus.h" #include "py32f0xx_ll_bus.h"
#include "py32f0xx_ll_system.h" #include "py32f0xx_ll_system.h"
#include "py32f0xx_ll_exti.h" #include "py32f0xx_ll_exti.h"
#include "py32f0xx_ll_cortex.h" #include "py32f0xx_ll_cortex.h"
#include "py32f0xx_ll_utils.h" #include "py32f0xx_ll_utils.h"
#include "py32f0xx_ll_pwr.h" #include "py32f0xx_ll_pwr.h"
#include "py32f0xx_ll_dma.h" #include "py32f0xx_ll_dma.h"
#include "py32f0xx_ll_gpio.h" #include "py32f0xx_ll_gpio.h"
#include "py32f0xx_ll_usart.h" #include "py32f0xx_ll_usart.h"
/** @addtogroup BSP /** @addtogroup BSP
* @{ * @{
*/ */
/** @defgroup py32f0xx_Start_Kit /** @defgroup py32f0xx_Start_Kit
* @brief This section contains the exported types, contants and functions * @brief This section contains the exported types, contants and functions
* required to use the Nucleo 32 board. * required to use the Nucleo 32 board.
* @{ * @{
*/ */
/** @defgroup py32f0xx_Start_Kit_Exported_Types Exported Types /** @defgroup py32f0xx_Start_Kit_Exported_Types Exported Types
* @{ * @{
*/ */
typedef enum typedef enum
{ {
LED3 = 0, LED3 = 0,
LED_GREEN = LED3 LED_GREEN = LED3
} Led_TypeDef; } Led_TypeDef;
typedef enum typedef enum
{ {
BUTTON_USER = 0, BUTTON_USER = 0,
/* Alias */ /* Alias */
BUTTON_KEY = BUTTON_USER BUTTON_KEY = BUTTON_USER
} Button_TypeDef; } Button_TypeDef;
typedef enum typedef enum
{ {
BUTTON_MODE_GPIO = 0, BUTTON_MODE_GPIO = 0,
BUTTON_MODE_EXTI = 1 BUTTON_MODE_EXTI = 1
} ButtonMode_TypeDef; } ButtonMode_TypeDef;
#define LEDn 1 #define LEDn 1
#define LED3_PIN LL_GPIO_PIN_5 #define LED3_PIN LL_GPIO_PIN_5
#define LED3_GPIO_PORT GPIOB #define LED3_GPIO_PORT GPIOB
#define LED3_GPIO_CLK_ENABLE() LL_IOP_GRP1_EnableClock(LL_IOP_GRP1_PERIPH_GPIOB) #define LED3_GPIO_CLK_ENABLE() LL_IOP_GRP1_EnableClock(LL_IOP_GRP1_PERIPH_GPIOB)
#define LED3_GPIO_CLK_DISABLE() LL_IOP_GRP1_DisableClock(LL_IOP_GRP1_PERIPH_GPIOB) #define LED3_GPIO_CLK_DISABLE() LL_IOP_GRP1_DisableClock(LL_IOP_GRP1_PERIPH_GPIOB)
#define LEDx_GPIO_CLK_ENABLE(__INDEX__) do {LED3_GPIO_CLK_ENABLE(); } while(0U) #define LEDx_GPIO_CLK_ENABLE(__INDEX__) do {LED3_GPIO_CLK_ENABLE(); } while(0U)
#define LEDx_GPIO_CLK_DISABLE(__INDEX__) LED3_GPIO_CLK_DISABLE()) #define LEDx_GPIO_CLK_DISABLE(__INDEX__) LED3_GPIO_CLK_DISABLE())
#define BUTTONn 1 #define BUTTONn 1
/** /**
* @brief User push-button * @brief User push-button
*/ */
#define USER_BUTTON_PIN LL_GPIO_PIN_12 #define USER_BUTTON_PIN LL_GPIO_PIN_12
#define USER_BUTTON_GPIO_PORT GPIOA #define USER_BUTTON_GPIO_PORT GPIOA
#define USER_BUTTON_GPIO_CLK_ENABLE() LL_IOP_GRP1_EnableClock(LL_IOP_GRP1_PERIPH_GPIOA) #define USER_BUTTON_GPIO_CLK_ENABLE() LL_IOP_GRP1_EnableClock(LL_IOP_GRP1_PERIPH_GPIOA)
#define USER_BUTTON_GPIO_CLK_DISABLE() LL_IOP_GRP1_DisableClock(LL_IOP_GRP1_PERIPH_GPIOA) #define USER_BUTTON_GPIO_CLK_DISABLE() LL_IOP_GRP1_DisableClock(LL_IOP_GRP1_PERIPH_GPIOA)
#define USER_BUTTON_EXTI_IRQn EXTI4_15_IRQn #define USER_BUTTON_EXTI_IRQn EXTI4_15_IRQn
#define USER_BUTTON_EXTI_LINE LL_EXTI_LINE_12 #define USER_BUTTON_EXTI_LINE LL_EXTI_LINE_12
#define USER_BUTTON_EXTI_LINE_ENABLE() LL_EXTI_EnableIT(USER_BUTTON_EXTI_LINE) #define USER_BUTTON_EXTI_LINE_ENABLE() LL_EXTI_EnableIT(USER_BUTTON_EXTI_LINE)
#define USER_BUTTON_EXTI_FALLING_TRIG_ENABLE() LL_EXTI_EnableFallingTrig(USER_BUTTON_EXTI_LINE) #define USER_BUTTON_EXTI_FALLING_TRIG_ENABLE() LL_EXTI_EnableFallingTrig(USER_BUTTON_EXTI_LINE)
#define USER_BUTTON_IRQHANDLER EXTI4_15_IRQHandler #define USER_BUTTON_IRQHANDLER EXTI4_15_IRQHandler
/* Aliases */ /* Aliases */
#define KEY_BUTTON_PIN USER_BUTTON_PIN #define KEY_BUTTON_PIN USER_BUTTON_PIN
#define KEY_BUTTON_GPIO_PORT USER_BUTTON_GPIO_PORT #define KEY_BUTTON_GPIO_PORT USER_BUTTON_GPIO_PORT
#define KEY_BUTTON_GPIO_CLK_ENABLE() USER_BUTTON_GPIO_CLK_ENABLE() #define KEY_BUTTON_GPIO_CLK_ENABLE() USER_BUTTON_GPIO_CLK_ENABLE()
#define KEY_BUTTON_GPIO_CLK_DISABLE() USER_BUTTON_GPIO_CLK_DISABLE() #define KEY_BUTTON_GPIO_CLK_DISABLE() USER_BUTTON_GPIO_CLK_DISABLE()
#define KEY_BUTTON_EXTI_IRQn USER_BUTTON_EXTI_IRQn #define KEY_BUTTON_EXTI_IRQn USER_BUTTON_EXTI_IRQn
#define BUTTONx_GPIO_CLK_ENABLE(__INDEX__) do { if((__INDEX__) == 0) USER_BUTTON_GPIO_CLK_ENABLE();} while(0) #define BUTTONx_GPIO_CLK_ENABLE(__INDEX__) do { if((__INDEX__) == 0) USER_BUTTON_GPIO_CLK_ENABLE();} while(0)
#define BUTTONx_GPIO_CLK_DISABLE(__INDEX__) (((__INDEX__) == 0) ? USER_BUTTON_GPIO_CLK_DISABLE() : 0) #define BUTTONx_GPIO_CLK_DISABLE(__INDEX__) (((__INDEX__) == 0) ? USER_BUTTON_GPIO_CLK_DISABLE() : 0)
//debug printf redirect config /************************************************************/
#define DEBUG_USART_BAUDRATE 115200
/** @defgroup Functions
#define DEBUG_USART USART2 * @{
#define DEBUG_USART_CLK_ENABLE() LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_USART2) */
uint32_t BSP_GetVersion(void);
#define __GPIOA_CLK_ENABLE() do { \
__IO uint32_t tmpreg = 0x00U; \ void BSP_LED_Init(Led_TypeDef Led);
SET_BIT(RCC->IOPENR, RCC_IOPENR_GPIOAEN);\ void BSP_LED_DeInit(Led_TypeDef Led);
/* Delay after an RCC peripheral clock enabling */ \ void BSP_LED_On(Led_TypeDef Led);
tmpreg = READ_BIT(RCC->IOPENR, RCC_IOPENR_GPIOAEN);\ void BSP_LED_Off(Led_TypeDef Led);
UNUSED(tmpreg); \ void BSP_LED_Toggle(Led_TypeDef Led);
} while(0U)
void BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef ButtonMode);
#define DEBUG_USART_RX_GPIO_PORT GPIOA void BSP_PB_DeInit(Button_TypeDef Button);
#define DEBUG_USART_RX_GPIO_CLK_ENABLE() LL_IOP_GRP1_EnableClock(LL_IOP_GRP1_PERIPH_GPIOA) uint32_t BSP_PB_GetState(Button_TypeDef Button);
#define DEBUG_USART_RX_PIN LL_GPIO_PIN_3
#define DEBUG_USART_RX_AF LL_GPIO_AF_4 /**
* @}
#define DEBUG_USART_TX_GPIO_PORT GPIOA */
#define DEBUG_USART_TX_GPIO_CLK_ENABLE() LL_IOP_GRP1_EnableClock(LL_IOP_GRP1_PERIPH_GPIOA)
#define DEBUG_USART_TX_PIN LL_GPIO_PIN_2 /**
#define DEBUG_USART_TX_AF LL_GPIO_AF_4 * @}
*/
#define DEBUG_USART_IRQHandler USART2_IRQHandler
#define DEBUG_USART_IRQ USART2_IRQn #ifdef __cplusplus
/************************************************************/ }
#endif
/** @defgroup Functions
* @{ #endif /* PY32F003XX_LL_START_KIT_H */
*/
uint32_t BSP_GetVersion(void); /************************ (C) COPYRIGHT Puya *****END OF FILE****/
void BSP_LED_Init(Led_TypeDef Led);
void BSP_LED_DeInit(Led_TypeDef Led);
void BSP_LED_On(Led_TypeDef Led);
void BSP_LED_Off(Led_TypeDef Led);
void BSP_LED_Toggle(Led_TypeDef Led);
void BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef ButtonMode);
void BSP_PB_DeInit(Button_TypeDef Button);
uint32_t BSP_PB_GetState(Button_TypeDef Button);
void BSP_USART_Config(void);
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* PY32F003XX_LL_START_KIT_H */
/************************ (C) COPYRIGHT Puya *****END OF FILE****/

View File

@ -0,0 +1,69 @@
/**
******************************************************************************
* @file py32f0xx_bsp_printf.h
* @author MCU Application Team
* @brief
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef PY32F003_BSP_PRINTF_H
#define PY32F003_BSP_PRINTF_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdio.h>
#include "py32f0xx_ll_rcc.h"
#include "py32f0xx_ll_bus.h"
#include "py32f0xx_ll_system.h"
#include "py32f0xx_ll_exti.h"
#include "py32f0xx_ll_cortex.h"
#include "py32f0xx_ll_utils.h"
#include "py32f0xx_ll_pwr.h"
#include "py32f0xx_ll_dma.h"
#include "py32f0xx_ll_gpio.h"
#include "py32f0xx_ll_usart.h"
//debug printf redirect config
#define DEBUG_USART_BAUDRATE 115200
#define DEBUG_USART USART2
#define DEBUG_USART_CLK_ENABLE() LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_USART2)
#define __GPIOA_CLK_ENABLE() do { \
__IO uint32_t tmpreg = 0x00U; \
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 DEBUG_USART_RX_GPIO_PORT GPIOA
#define DEBUG_USART_RX_GPIO_CLK_ENABLE() LL_IOP_GRP1_EnableClock(LL_IOP_GRP1_PERIPH_GPIOA)
#define DEBUG_USART_RX_PIN LL_GPIO_PIN_3
#define DEBUG_USART_RX_AF LL_GPIO_AF_4
#define DEBUG_USART_TX_GPIO_PORT GPIOA
#define DEBUG_USART_TX_GPIO_CLK_ENABLE() LL_IOP_GRP1_EnableClock(LL_IOP_GRP1_PERIPH_GPIOA)
#define DEBUG_USART_TX_PIN LL_GPIO_PIN_2
#define DEBUG_USART_TX_AF LL_GPIO_AF_4
#define DEBUG_USART_IRQHandler USART2_IRQHandler
#define DEBUG_USART_IRQ USART2_IRQn
/************************************************************/
void BSP_USART_Config(void);
#ifdef __cplusplus
}
#endif
#endif /* PY32F003_BSP_PRINTF_H */

View File

@ -1,9 +1,9 @@
/** /**
****************************************************************************** ******************************************************************************
* @file py32f003xx_ll_Start_Kit.c * @file py32f003xx_ll_Start_Kit.c
* @author MCU Application Team * @author MCU Application Team
* @brief This file provides set of firmware functions to manage Leds, * @brief This file provides set of firmware functions to manage Leds,
* push-button available on Start Kit. * push-button available on Start Kit.
****************************************************************************** ******************************************************************************
* @attention * @attention
* *
@ -20,279 +20,195 @@
* *
****************************************************************************** ******************************************************************************
*/ */
/* Includes ------------------------------------------------------------------*/ /* Includes ------------------------------------------------------------------*/
#include "py32f003xx_ll_Start_Kit.h" #include "py32f003xx_ll_Start_Kit.h"
/** /**
* @brief PY32F003xx STK BSP Driver version number * @brief PY32F003xx STK BSP Driver version number
*/ */
#define __PY32F003xx_STK_BSP_VERSION_MAIN (0x01U) /*!< [31:24] main version */ #define __PY32F003xx_STK_BSP_VERSION_MAIN (0x01U) /*!< [31:24] main version */
#define __PY32F003xx_STK_BSP_VERSION_SUB1 (0x00U) /*!< [23:16] sub1 version */ #define __PY32F003xx_STK_BSP_VERSION_SUB1 (0x00U) /*!< [23:16] sub1 version */
#define __PY32F003xx_STK_BSP_VERSION_SUB2 (0x00U) /*!< [15:8] sub2 version */ #define __PY32F003xx_STK_BSP_VERSION_SUB2 (0x00U) /*!< [15:8] sub2 version */
#define __PY32F003xx_STK_BSP_VERSION_RC (0x00U) /*!< [7:0] release candidate */ #define __PY32F003xx_STK_BSP_VERSION_RC (0x00U) /*!< [7:0] release candidate */
#define __PY32F003xx_STK_BSP_VERSION ((__PY32F003xx_STK_BSP_VERSION_MAIN << 24) \ #define __PY32F003xx_STK_BSP_VERSION ((__PY32F003xx_STK_BSP_VERSION_MAIN << 24) \
|(__PY32F003xx_STK_BSP_VERSION_SUB1 << 16) \ |(__PY32F003xx_STK_BSP_VERSION_SUB1 << 16) \
|(__PY32F003xx_STK_BSP_VERSION_SUB2 << 8 ) \ |(__PY32F003xx_STK_BSP_VERSION_SUB2 << 8 ) \
|(__PY32F003xx_STK_BSP_VERSION_RC)) |(__PY32F003xx_STK_BSP_VERSION_RC))
GPIO_TypeDef* LED_PORT[LEDn] = {LED3_GPIO_PORT}; GPIO_TypeDef* LED_PORT[LEDn] = {LED3_GPIO_PORT};
const uint16_t LED_PIN[LEDn] = {LED3_PIN}; const uint16_t LED_PIN[LEDn] = {LED3_PIN};
GPIO_TypeDef* BUTTON_PORT[BUTTONn] = {USER_BUTTON_GPIO_PORT }; GPIO_TypeDef* BUTTON_PORT[BUTTONn] = {USER_BUTTON_GPIO_PORT };
const uint16_t BUTTON_PIN[BUTTONn] = {USER_BUTTON_PIN }; const uint16_t BUTTON_PIN[BUTTONn] = {USER_BUTTON_PIN };
const uint8_t BUTTON_IRQn[BUTTONn] = {USER_BUTTON_EXTI_IRQn }; const uint8_t BUTTON_IRQn[BUTTONn] = {USER_BUTTON_EXTI_IRQn };
const uint32_t BUTTON_EXTI_LINE[BUTTONn] = {USER_BUTTON_EXTI_LINE }; const uint32_t BUTTON_EXTI_LINE[BUTTONn] = {USER_BUTTON_EXTI_LINE };
/** @addtogroup PY32F003xx_STK_Exported_Functions /** @addtogroup PY32F003xx_STK_Exported_Functions
* @{ * @{
*/ */
/** /**
* @brief This method returns the PY32F003 STK BSP Driver revision. * @brief This method returns the PY32F003 STK BSP Driver revision.
* @retval version : 0xXYZR (8bits for each decimal, R for RC) * @retval version : 0xXYZR (8bits for each decimal, R for RC)
*/ */
uint32_t BSP_GetVersion(void) uint32_t BSP_GetVersion(void)
{ {
return __PY32F003xx_STK_BSP_VERSION; return __PY32F003xx_STK_BSP_VERSION;
} }
/** @addtogroup LED_Functions /** @addtogroup LED_Functions
* @{ * @{
*/ */
/** /**
* @brief Configures LED GPIO. * @brief Configures LED GPIO.
* @param Led Specifies the Led to be configured. * @param Led Specifies the Led to be configured.
* This parameter can be one of following parameters: * This parameter can be one of following parameters:
* @arg LED3 * @arg LED3
* @retval None * @retval None
*/ */
void BSP_LED_Init(Led_TypeDef Led) void BSP_LED_Init(Led_TypeDef Led)
{ {
/* Enable the GPIO_LED Clock */ /* Enable the GPIO_LED Clock */
LEDx_GPIO_CLK_ENABLE(Led); LEDx_GPIO_CLK_ENABLE(Led);
/* Configure the GPIO_LED pin */ /* Configure the GPIO_LED pin */
LL_GPIO_SetPinMode(LED_PORT[Led], LED_PIN[Led], LL_GPIO_MODE_OUTPUT); LL_GPIO_SetPinMode(LED_PORT[Led], LED_PIN[Led], LL_GPIO_MODE_OUTPUT);
/* LL_GPIO_SetPinOutputType(LED_PORT[Led], LED_PIN[Led], LL_GPIO_OUTPUT_PUSHPULL); */ /* LL_GPIO_SetPinOutputType(LED_PORT[Led], LED_PIN[Led], LL_GPIO_OUTPUT_PUSHPULL); */
/* LL_GPIO_SetPinSpeed(LED_PORT[Led], LED_PIN[Led], LL_GPIO_SPEED_FREQ_LOW); */ /* LL_GPIO_SetPinSpeed(LED_PORT[Led], LED_PIN[Led], LL_GPIO_SPEED_FREQ_LOW); */
/* LL_GPIO_SetPinPull(LED_PORT[Led], LED_PIN[Led], LL_GPIO_PULL_NO); */ /* LL_GPIO_SetPinPull(LED_PORT[Led], LED_PIN[Led], LL_GPIO_PULL_NO); */
LL_GPIO_SetOutputPin(LED_PORT[Led], LED_PIN[Led]); LL_GPIO_SetOutputPin(LED_PORT[Led], LED_PIN[Led]);
} }
/** /**
* @brief DeInitialize LED GPIO. * @brief DeInitialize LED GPIO.
* @param Led Specifies the Led to be deconfigured. * @param Led Specifies the Led to be deconfigured.
* This parameter can be one of the following values: * This parameter can be one of the following values:
* @arg LED3 * @arg LED3
* @note BSP_LED_DeInit() does not disable the GPIO clock * @note BSP_LED_DeInit() does not disable the GPIO clock
* @retval None * @retval None
*/ */
void BSP_LED_DeInit(Led_TypeDef Led) void BSP_LED_DeInit(Led_TypeDef Led)
{ {
/* Turn off LED */ /* Turn off LED */
LL_GPIO_ResetOutputPin(LED_PORT[Led], LED_PIN[Led]); LL_GPIO_ResetOutputPin(LED_PORT[Led], LED_PIN[Led]);
/* DeInit the GPIO_LED pin */ /* DeInit the GPIO_LED pin */
LL_GPIO_SetPinMode(LED_PORT[Led], LED_PIN[Led], LL_GPIO_MODE_ANALOG); LL_GPIO_SetPinMode(LED_PORT[Led], LED_PIN[Led], LL_GPIO_MODE_ANALOG);
/* LL_GPIO_SetPinOutputType(LED_PORT[Led], LED_PIN[Led], LL_GPIO_OUTPUT_PUSHPULL); */ /* LL_GPIO_SetPinOutputType(LED_PORT[Led], LED_PIN[Led], LL_GPIO_OUTPUT_PUSHPULL); */
/* LL_GPIO_SetPinSpeed(LED_PORT[Led], LED_PIN[Led], LL_GPIO_SPEED_FREQ_LOW); */ /* LL_GPIO_SetPinSpeed(LED_PORT[Led], LED_PIN[Led], LL_GPIO_SPEED_FREQ_LOW); */
/* LL_GPIO_SetPinPull(LED_PORT[Led], LED_PIN[Led], LL_GPIO_PULL_NO); */ /* LL_GPIO_SetPinPull(LED_PORT[Led], LED_PIN[Led], LL_GPIO_PULL_NO); */
} }
/** /**
* @brief Turns selected LED On. * @brief Turns selected LED On.
* @param Led Specifies the Led to be set on. * @param Led Specifies the Led to be set on.
* This parameter can be one of following parameters: * This parameter can be one of following parameters:
* @arg LED3 * @arg LED3
* @retval None * @retval None
*/ */
void BSP_LED_On(Led_TypeDef Led) void BSP_LED_On(Led_TypeDef Led)
{ {
LL_GPIO_ResetOutputPin(LED_PORT[Led], LED_PIN[Led]); LL_GPIO_ResetOutputPin(LED_PORT[Led], LED_PIN[Led]);
} }
/** /**
* @brief Turns selected LED Off. * @brief Turns selected LED Off.
* @param Led Specifies the Led to be set off. * @param Led Specifies the Led to be set off.
* This parameter can be one of following parameters: * This parameter can be one of following parameters:
* @arg LED3 * @arg LED3
* @retval None * @retval None
*/ */
void BSP_LED_Off(Led_TypeDef Led) void BSP_LED_Off(Led_TypeDef Led)
{ {
LL_GPIO_SetOutputPin(LED_PORT[Led], LED_PIN[Led]); LL_GPIO_SetOutputPin(LED_PORT[Led], LED_PIN[Led]);
} }
/** /**
* @brief Toggles the selected LED. * @brief Toggles the selected LED.
* @param Led Specifies the Led to be toggled. * @param Led Specifies the Led to be toggled.
* This parameter can be one of following parameters: * This parameter can be one of following parameters:
* @arg LED3 * @arg LED3
* @retval None * @retval None
*/ */
void BSP_LED_Toggle(Led_TypeDef Led) void BSP_LED_Toggle(Led_TypeDef Led)
{ {
LL_GPIO_TogglePin(LED_PORT[Led], LED_PIN[Led]); LL_GPIO_TogglePin(LED_PORT[Led], LED_PIN[Led]);
} }
/** /**
* @brief Configures Button GPIO and EXTI Line. * @brief Configures Button GPIO and EXTI Line.
* @param Button: Specifies the Button to be configured. * @param Button: Specifies the Button to be configured.
* This parameter should be: BUTTON_USER * This parameter should be: BUTTON_USER
* @param ButtonMode: Specifies Button mode. * @param ButtonMode: Specifies Button mode.
* This parameter can be one of following parameters: * This parameter can be one of following parameters:
* @arg BUTTON_MODE_GPIO: Button will be used as simple IO * @arg BUTTON_MODE_GPIO: Button will be used as simple IO
* @arg BUTTON_MODE_EXTI: Button will be connected to EXTI line with interrupt * @arg BUTTON_MODE_EXTI: Button will be connected to EXTI line with interrupt
* generation capability * generation capability
* @retval None * @retval None
*/ */
void BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef ButtonMode) void BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef ButtonMode)
{ {
/* Enable the BUTTON Clock */ /* Enable the BUTTON Clock */
BUTTONx_GPIO_CLK_ENABLE(Button); BUTTONx_GPIO_CLK_ENABLE(Button);
/* Configure GPIO for BUTTON */ /* Configure GPIO for BUTTON */
LL_GPIO_SetPinMode(BUTTON_PORT[Button], BUTTON_PIN[Button], LL_GPIO_MODE_INPUT); LL_GPIO_SetPinMode(BUTTON_PORT[Button], BUTTON_PIN[Button], LL_GPIO_MODE_INPUT);
LL_GPIO_SetPinPull(BUTTON_PORT[Button], BUTTON_PIN[Button], LL_GPIO_PULL_NO); LL_GPIO_SetPinPull(BUTTON_PORT[Button], BUTTON_PIN[Button], LL_GPIO_PULL_NO);
/* LL_GPIO_SetPinSpeed(BUTTON_PORT[Button], BUTTON_PIN[Button], LL_GPIO_SPEED_FREQ_HIGH); */ /* LL_GPIO_SetPinSpeed(BUTTON_PORT[Button], BUTTON_PIN[Button], LL_GPIO_SPEED_FREQ_HIGH); */
if(ButtonMode == BUTTON_MODE_EXTI) if(ButtonMode == BUTTON_MODE_EXTI)
{ {
/* Configure Button pin as input with External interrupt */ /* Configure Button pin as input with External interrupt */
LL_EXTI_EnableIT(BUTTON_EXTI_LINE[Button]); LL_EXTI_EnableIT(BUTTON_EXTI_LINE[Button]);
LL_EXTI_EnableFallingTrig(BUTTON_EXTI_LINE[Button]); LL_EXTI_EnableFallingTrig(BUTTON_EXTI_LINE[Button]);
/* Enable and set Button EXTI Interrupt to the lowest priority */ /* Enable and set Button EXTI Interrupt to the lowest priority */
NVIC_SetPriority((IRQn_Type)(BUTTON_IRQn[Button]), 0x0F); NVIC_SetPriority((IRQn_Type)(BUTTON_IRQn[Button]), 0x0F);
NVIC_EnableIRQ((IRQn_Type)(BUTTON_IRQn[Button])); NVIC_EnableIRQ((IRQn_Type)(BUTTON_IRQn[Button]));
} }
} }
/** /**
* @brief Push Button DeInit. * @brief Push Button DeInit.
* @param Button: Button to be configured * @param Button: Button to be configured
* This parameter should be: BUTTON_USER * This parameter should be: BUTTON_USER
* @note PB DeInit does not disable the GPIO clock * @note PB DeInit does not disable the GPIO clock
* @retval None * @retval None
*/ */
void BSP_PB_DeInit(Button_TypeDef Button) void BSP_PB_DeInit(Button_TypeDef Button)
{ {
NVIC_DisableIRQ((IRQn_Type)(BUTTON_IRQn[Button])); NVIC_DisableIRQ((IRQn_Type)(BUTTON_IRQn[Button]));
LL_GPIO_SetPinMode(BUTTON_PORT[Button], BUTTON_PIN[Button], LL_GPIO_MODE_ANALOG); LL_GPIO_SetPinMode(BUTTON_PORT[Button], BUTTON_PIN[Button], LL_GPIO_MODE_ANALOG);
/* LL_GPIO_SetPinSpeed(BUTTON_PORT[Button], BUTTON_PIN[Button], LL_GPIO_SPEED_FREQ_LOW); */ /* LL_GPIO_SetPinSpeed(BUTTON_PORT[Button], BUTTON_PIN[Button], LL_GPIO_SPEED_FREQ_LOW); */
/* LL_GPIO_SetPinPull(BUTTON_PORT[Button], BUTTON_PIN[Button], LL_GPIO_PULL_NO); */ /* LL_GPIO_SetPinPull(BUTTON_PORT[Button], BUTTON_PIN[Button], LL_GPIO_PULL_NO); */
/* LL_GPIO_SetAFPin_8_15(BUTTON_PORT[Button], BUTTON_PIN[Button], LL_GPIO_AF_0); */ /* LL_GPIO_SetAFPin_8_15(BUTTON_PORT[Button], BUTTON_PIN[Button], LL_GPIO_AF_0); */
} }
/** /**
* @brief Returns the selected Button state. * @brief Returns the selected Button state.
* @param Button: Specifies the Button to be checked. * @param Button: Specifies the Button to be checked.
* This parameter should be: BUTTON_USER * This parameter should be: BUTTON_USER
* @retval Button state. * @retval Button state.
*/ */
uint32_t BSP_PB_GetState(Button_TypeDef Button) uint32_t BSP_PB_GetState(Button_TypeDef Button)
{ {
return LL_GPIO_IsInputPinSet(BUTTON_PORT[Button], BUTTON_PIN[Button]); return LL_GPIO_IsInputPinSet(BUTTON_PORT[Button], BUTTON_PIN[Button]);
} }
/**
* @brief DEBUG_USART GPIO Config,Mode Config,115200 8-N-1 //#endif
* @param None /**
* @retval None * @}
*/ */
void BSP_USART_Config(void)
{ /**
DEBUG_USART_CLK_ENABLE(); * @}
*/
/* USART Init */
LL_USART_SetBaudRate(DEBUG_USART, SystemCoreClock, LL_USART_OVERSAMPLING_16, DEBUG_USART_BAUDRATE); /**
LL_USART_SetDataWidth(DEBUG_USART, LL_USART_DATAWIDTH_8B); * @}
LL_USART_SetStopBitsLength(DEBUG_USART, LL_USART_STOPBITS_1); */
LL_USART_SetParity(DEBUG_USART, LL_USART_PARITY_NONE);
LL_USART_SetHWFlowCtrl(DEBUG_USART, LL_USART_HWCONTROL_NONE); /************************ (C) COPYRIGHT Puya *****END OF FILE****/
LL_USART_SetTransferDirection(DEBUG_USART, LL_USART_DIRECTION_TX_RX);
LL_USART_Enable(DEBUG_USART);
LL_USART_ClearFlag_TC(DEBUG_USART);
/**USART GPIO Configuration
PA2 ------> USART1_TX
PA3 ------> USART1_RX
*/
DEBUG_USART_RX_GPIO_CLK_ENABLE();
DEBUG_USART_TX_GPIO_CLK_ENABLE();
LL_GPIO_SetPinMode(DEBUG_USART_TX_GPIO_PORT, DEBUG_USART_TX_PIN, LL_GPIO_MODE_ALTERNATE);
LL_GPIO_SetPinSpeed(DEBUG_USART_TX_GPIO_PORT, DEBUG_USART_TX_PIN, LL_GPIO_SPEED_FREQ_VERY_HIGH);
LL_GPIO_SetPinPull(DEBUG_USART_TX_GPIO_PORT, DEBUG_USART_TX_PIN, LL_GPIO_PULL_UP);
LL_GPIO_SetAFPin_0_7(DEBUG_USART_TX_GPIO_PORT, DEBUG_USART_TX_PIN, DEBUG_USART_TX_AF);
LL_GPIO_SetPinMode(DEBUG_USART_RX_GPIO_PORT, DEBUG_USART_RX_PIN, LL_GPIO_MODE_ALTERNATE);
LL_GPIO_SetPinSpeed(DEBUG_USART_RX_GPIO_PORT, DEBUG_USART_RX_PIN, LL_GPIO_SPEED_FREQ_VERY_HIGH);
LL_GPIO_SetPinPull(DEBUG_USART_RX_GPIO_PORT, DEBUG_USART_RX_PIN, LL_GPIO_PULL_UP);
LL_GPIO_SetAFPin_0_7(DEBUG_USART_RX_GPIO_PORT, DEBUG_USART_RX_PIN, DEBUG_USART_RX_AF);
}
#if (defined (__CC_ARM)) || (defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
/**
* @brief writes a character to the usart
* @param ch
* *f
* @retval the character
*/
int fputc(int ch, FILE *f)
{
/* Send a byte to USART */
LL_USART_TransmitData8(DEBUG_USART, ch);
while (!LL_USART_IsActiveFlag_TC(DEBUG_USART));
LL_USART_ClearFlag_TC(DEBUG_USART);
return (ch);
}
/**
* @brief get a character from the usart
* @param *f
* @retval a character
*/
int fgetc(FILE *f)
{
int ch;
while (!LL_USART_IsActiveFlag_RXNE(DEBUG_USART));
ch = LL_USART_ReceiveData8(DEBUG_USART);
return (ch);
}
#elif defined(__ICCARM__)
/**
* @brief writes a character to the usart
* @param ch
* *f
* @retval the character
*/
int putchar(int ch)
{
/* Send a byte to USART */
LL_USART_TransmitData8(DEBUG_USART, ch);
while (!LL_USART_IsActiveFlag_TC(DEBUG_USART));
LL_USART_ClearFlag_TC(DEBUG_USART);
return (ch);
}
#endif
//#endif
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT Puya *****END OF FILE****/

View File

@ -0,0 +1,151 @@
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
#include "py32f0xx_bsp_printf.h"
/**
* @brief DEBUG_USART GPIO Config,Mode Config,115200 8-N-1
* @param None
* @retval None
*/
void BSP_USART_Config(void)
{
DEBUG_USART_CLK_ENABLE();
/* USART Init */
LL_USART_SetBaudRate(DEBUG_USART, SystemCoreClock, LL_USART_OVERSAMPLING_16, DEBUG_USART_BAUDRATE);
LL_USART_SetDataWidth(DEBUG_USART, LL_USART_DATAWIDTH_8B);
LL_USART_SetStopBitsLength(DEBUG_USART, LL_USART_STOPBITS_1);
LL_USART_SetParity(DEBUG_USART, LL_USART_PARITY_NONE);
LL_USART_SetHWFlowCtrl(DEBUG_USART, LL_USART_HWCONTROL_NONE);
LL_USART_SetTransferDirection(DEBUG_USART, LL_USART_DIRECTION_TX_RX);
LL_USART_Enable(DEBUG_USART);
LL_USART_ClearFlag_TC(DEBUG_USART);
/**USART GPIO Configuration
PA2 ------> USART1_TX
PA3 ------> USART1_RX
*/
DEBUG_USART_RX_GPIO_CLK_ENABLE();
DEBUG_USART_TX_GPIO_CLK_ENABLE();
LL_GPIO_SetPinMode(DEBUG_USART_TX_GPIO_PORT, DEBUG_USART_TX_PIN, LL_GPIO_MODE_ALTERNATE);
LL_GPIO_SetPinSpeed(DEBUG_USART_TX_GPIO_PORT, DEBUG_USART_TX_PIN, LL_GPIO_SPEED_FREQ_VERY_HIGH);
LL_GPIO_SetPinPull(DEBUG_USART_TX_GPIO_PORT, DEBUG_USART_TX_PIN, LL_GPIO_PULL_UP);
LL_GPIO_SetAFPin_0_7(DEBUG_USART_TX_GPIO_PORT, DEBUG_USART_TX_PIN, DEBUG_USART_TX_AF);
LL_GPIO_SetPinMode(DEBUG_USART_RX_GPIO_PORT, DEBUG_USART_RX_PIN, LL_GPIO_MODE_ALTERNATE);
LL_GPIO_SetPinSpeed(DEBUG_USART_RX_GPIO_PORT, DEBUG_USART_RX_PIN, LL_GPIO_SPEED_FREQ_VERY_HIGH);
LL_GPIO_SetPinPull(DEBUG_USART_RX_GPIO_PORT, DEBUG_USART_RX_PIN, LL_GPIO_PULL_UP);
LL_GPIO_SetAFPin_0_7(DEBUG_USART_RX_GPIO_PORT, DEBUG_USART_RX_PIN, DEBUG_USART_RX_AF);
}
#if defined (__GNUC__) && !defined (__clang__)
#define GETCHAR_PROTOTYPE int __io_getchar (void)
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#else
#define GETCHAR_PROTOTYPE int fgetc(FILE * f)
#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
#endif
/**
* @brief retargets the c library printf function to the usart.
* @param none
* @retval none
*/
PUTCHAR_PROTOTYPE
{
/* Send a byte to USART */
LL_USART_TransmitData8(DEBUG_USART, ch);
while (!LL_USART_IsActiveFlag_TC(DEBUG_USART));
LL_USART_ClearFlag_TC(DEBUG_USART);
return (ch);
}
GETCHAR_PROTOTYPE
{
int ch;
while (!LL_USART_IsActiveFlag_RXNE(DEBUG_USART));
ch = LL_USART_ReceiveData8(DEBUG_USART);
return (ch);
}
#if defined (__GNUC__) && !defined (__clang__)
__attribute__((weak)) int _write(int file, char *ptr, int len)
{
(void)file;
int DataIdx;
for (DataIdx = 0; DataIdx < len; DataIdx++)
{
__io_putchar(*ptr++);
}
return len;
}
#endif
__attribute__((weak)) int _read(int file, char *ptr, int len)
{
(void)file;
int DataIdx;
for (DataIdx = 0; DataIdx < len; DataIdx++)
{
*ptr++ = __io_getchar();
}
return len;
}
__attribute__((weak)) int _isatty(int fd)
{
if (fd >= STDIN_FILENO && fd <= STDERR_FILENO)
return 1;
errno = EBADF;
return 0;
}
__attribute__((weak)) int _close(int fd)
{
if (fd >= STDIN_FILENO && fd <= STDERR_FILENO)
return 0;
errno = EBADF;
return -1;
}
__attribute__((weak)) int _lseek(int fd, int ptr, int dir)
{
(void)fd;
(void)ptr;
(void)dir;
errno = EBADF;
return -1;
}
__attribute__((weak)) int _fstat(int fd, struct stat *st)
{
if (fd >= STDIN_FILENO && fd <= STDERR_FILENO)
{
st->st_mode = S_IFCHR;
return 0;
}
errno = EBADF;
return 0;
}
__attribute__((weak)) int _getpid(void)
{
errno = ENOSYS;
return -1;
}
__attribute__((weak)) int _kill(pid_t pid, int sig)
{
(void)pid;
(void)sig;
errno = ENOSYS;
return -1;
}

View File

@ -4,18 +4,18 @@
* @author MCU Application Team * @author MCU Application Team
* @brief Header file of COMP LL module. * @brief Header file of COMP LL module.
****************************************************************************** ******************************************************************************
* @attention * @attention
* *
* <h2><center>&copy; Copyright (c) Puya Semiconductor Co. * <h2><center>&copy; Copyright (c) Puya Semiconductor Co.
* All rights reserved.</center></h2> * All rights reserved.</center></h2>
* *
* <h2><center>&copy; Copyright (c) 2016 STMicroelectronics. * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
* All rights reserved.</center></h2> * All rights reserved.</center></h2>
* *
* This software component is licensed by ST under BSD 3-Clause license, * 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 * the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at: * License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause * opensource.org/licenses/BSD-3-Clause
* *
****************************************************************************** ******************************************************************************
*/ */

View File

@ -1,310 +1,310 @@
/** /**
****************************************************************************** ******************************************************************************
* @file py32f0xx_ll_cortex.h * @file py32f0xx_ll_cortex.h
* @author MCU Application Team * @author MCU Application Team
* @brief Header file of CORTEX LL module. * @brief Header file of CORTEX LL module.
****************************************************************************** ******************************************************************************
* @attention * @attention
* *
* <h2><center>&copy; Copyright (c) Puya Semiconductor Co. * <h2><center>&copy; Copyright (c) Puya Semiconductor Co.
* All rights reserved.</center></h2> * All rights reserved.</center></h2>
* *
* <h2><center>&copy; Copyright (c) 2016 STMicroelectronics. * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
* All rights reserved.</center></h2> * All rights reserved.</center></h2>
* *
* This software component is licensed by ST under BSD 3-Clause license, * 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 * the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at: * License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause * opensource.org/licenses/BSD-3-Clause
* *
****************************************************************************** ******************************************************************************
*/ */
/* Define to prevent recursive inclusion -------------------------------------*/ /* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __PY32F0XX_LL_CORTEX_H #ifndef __PY32F0XX_LL_CORTEX_H
#define __PY32F0XX_LL_CORTEX_H #define __PY32F0XX_LL_CORTEX_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/* Includes ------------------------------------------------------------------*/ /* Includes ------------------------------------------------------------------*/
#include "py32f0xx.h" #include "py32f0xx.h"
/** @addtogroup PY32F0XX_LL_Driver /** @addtogroup PY32F0XX_LL_Driver
* @{ * @{
*/ */
/** @defgroup CORTEX_LL CORTEX /** @defgroup CORTEX_LL CORTEX
* @{ * @{
*/ */
/* Private types -------------------------------------------------------------*/ /* Private types -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/
/* Private constants ---------------------------------------------------------*/ /* Private constants ---------------------------------------------------------*/
/* Private macros ------------------------------------------------------------*/ /* Private macros ------------------------------------------------------------*/
/* Exported types ------------------------------------------------------------*/ /* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/
/** @defgroup CORTEX_LL_Exported_Constants CORTEX Exported Constants /** @defgroup CORTEX_LL_Exported_Constants CORTEX Exported Constants
* @{ * @{
*/ */
/** @defgroup CORTEX_LL_EC_CLKSOURCE_HCLK SYSTICK Clock Source /** @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_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. */ #define LL_SYSTICK_CLKSOURCE_HCLK SysTick_CTRL_CLKSOURCE_Msk /*!< AHB clock selected as SysTick clock source. */
/** /**
* @} * @}
*/ */
/** /**
* @} * @}
*/ */
/* Exported macro ------------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/
/* Exported functions --------------------------------------------------------*/ /* Exported functions --------------------------------------------------------*/
/** @defgroup CORTEX_LL_Exported_Functions CORTEX Exported Functions /** @defgroup CORTEX_LL_Exported_Functions CORTEX Exported Functions
* @{ * @{
*/ */
/** @defgroup CORTEX_LL_EF_SYSTICK SYSTICK /** @defgroup CORTEX_LL_EF_SYSTICK SYSTICK
* @{ * @{
*/ */
/** /**
* @brief This function checks if the Systick counter flag is active or not. * @brief This function checks if the Systick counter flag is active or not.
* @note It can be used in timeout function on application side. * @note It can be used in timeout function on application side.
* @rmtoll STK_CTRL COUNTFLAG LL_SYSTICK_IsActiveCounterFlag * @rmtoll STK_CTRL COUNTFLAG LL_SYSTICK_IsActiveCounterFlag
* @retval State of bit (1 or 0). * @retval State of bit (1 or 0).
*/ */
__STATIC_INLINE uint32_t LL_SYSTICK_IsActiveCounterFlag(void) __STATIC_INLINE uint32_t LL_SYSTICK_IsActiveCounterFlag(void)
{ {
return (((SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) == (SysTick_CTRL_COUNTFLAG_Msk)) ? 1UL : 0UL); return (((SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) == (SysTick_CTRL_COUNTFLAG_Msk)) ? 1UL : 0UL);
} }
/** /**
* @brief Configures the SysTick clock source * @brief Configures the SysTick clock source
* @rmtoll STK_CTRL CLKSOURCE LL_SYSTICK_SetClkSource * @rmtoll STK_CTRL CLKSOURCE LL_SYSTICK_SetClkSource
* @param Source This parameter can be one of the following values: * @param Source This parameter can be one of the following values:
* @arg @ref LL_SYSTICK_CLKSOURCE_HCLK_DIV8 * @arg @ref LL_SYSTICK_CLKSOURCE_HCLK_DIV8
* @arg @ref LL_SYSTICK_CLKSOURCE_HCLK * @arg @ref LL_SYSTICK_CLKSOURCE_HCLK
* @retval None * @retval None
*/ */
__STATIC_INLINE void LL_SYSTICK_SetClkSource(uint32_t Source) __STATIC_INLINE void LL_SYSTICK_SetClkSource(uint32_t Source)
{ {
if (Source == LL_SYSTICK_CLKSOURCE_HCLK) if (Source == LL_SYSTICK_CLKSOURCE_HCLK)
{ {
SET_BIT(SysTick->CTRL, LL_SYSTICK_CLKSOURCE_HCLK); SET_BIT(SysTick->CTRL, LL_SYSTICK_CLKSOURCE_HCLK);
} }
else else
{ {
CLEAR_BIT(SysTick->CTRL, LL_SYSTICK_CLKSOURCE_HCLK); CLEAR_BIT(SysTick->CTRL, LL_SYSTICK_CLKSOURCE_HCLK);
} }
} }
/** /**
* @brief Get the SysTick clock source * @brief Get the SysTick clock source
* @rmtoll STK_CTRL CLKSOURCE LL_SYSTICK_GetClkSource * @rmtoll STK_CTRL CLKSOURCE LL_SYSTICK_GetClkSource
* @retval Returned value can be one of the following values: * @retval Returned value can be one of the following values:
* @arg @ref LL_SYSTICK_CLKSOURCE_HCLK_DIV8 * @arg @ref LL_SYSTICK_CLKSOURCE_HCLK_DIV8
* @arg @ref LL_SYSTICK_CLKSOURCE_HCLK * @arg @ref LL_SYSTICK_CLKSOURCE_HCLK
*/ */
__STATIC_INLINE uint32_t LL_SYSTICK_GetClkSource(void) __STATIC_INLINE uint32_t LL_SYSTICK_GetClkSource(void)
{ {
return READ_BIT(SysTick->CTRL, LL_SYSTICK_CLKSOURCE_HCLK); return READ_BIT(SysTick->CTRL, LL_SYSTICK_CLKSOURCE_HCLK);
} }
/** /**
* @brief Enable SysTick exception request * @brief Enable SysTick exception request
* @rmtoll STK_CTRL TICKINT LL_SYSTICK_EnableIT * @rmtoll STK_CTRL TICKINT LL_SYSTICK_EnableIT
* @retval None * @retval None
*/ */
__STATIC_INLINE void LL_SYSTICK_EnableIT(void) __STATIC_INLINE void LL_SYSTICK_EnableIT(void)
{ {
SET_BIT(SysTick->CTRL, SysTick_CTRL_TICKINT_Msk); SET_BIT(SysTick->CTRL, SysTick_CTRL_TICKINT_Msk);
} }
/** /**
* @brief Disable SysTick exception request * @brief Disable SysTick exception request
* @rmtoll STK_CTRL TICKINT LL_SYSTICK_DisableIT * @rmtoll STK_CTRL TICKINT LL_SYSTICK_DisableIT
* @retval None * @retval None
*/ */
__STATIC_INLINE void LL_SYSTICK_DisableIT(void) __STATIC_INLINE void LL_SYSTICK_DisableIT(void)
{ {
CLEAR_BIT(SysTick->CTRL, SysTick_CTRL_TICKINT_Msk); CLEAR_BIT(SysTick->CTRL, SysTick_CTRL_TICKINT_Msk);
} }
/** /**
* @brief Checks if the SYSTICK interrupt is enabled or disabled. * @brief Checks if the SYSTICK interrupt is enabled or disabled.
* @rmtoll STK_CTRL TICKINT LL_SYSTICK_IsEnabledIT * @rmtoll STK_CTRL TICKINT LL_SYSTICK_IsEnabledIT
* @retval State of bit (1 or 0). * @retval State of bit (1 or 0).
*/ */
__STATIC_INLINE uint32_t LL_SYSTICK_IsEnabledIT(void) __STATIC_INLINE uint32_t LL_SYSTICK_IsEnabledIT(void)
{ {
return ((READ_BIT(SysTick->CTRL, SysTick_CTRL_TICKINT_Msk) == (SysTick_CTRL_TICKINT_Msk)) ? 1UL : 0UL); 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 /** @defgroup CORTEX_LL_EF_LOW_POWER_MODE LOW POWER MODE
* @{ * @{
*/ */
/** /**
* @brief Processor uses sleep as its low power mode * @brief Processor uses sleep as its low power mode
* @rmtoll SCB_SCR SLEEPDEEP LL_LPM_EnableSleep * @rmtoll SCB_SCR SLEEPDEEP LL_LPM_EnableSleep
* @retval None * @retval None
*/ */
__STATIC_INLINE void LL_LPM_EnableSleep(void) __STATIC_INLINE void LL_LPM_EnableSleep(void)
{ {
/* Clear SLEEPDEEP bit of Cortex System Control Register */ /* Clear SLEEPDEEP bit of Cortex System Control Register */
CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk)); CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
} }
/** /**
* @brief Processor uses deep sleep as its low power mode * @brief Processor uses deep sleep as its low power mode
* @rmtoll SCB_SCR SLEEPDEEP LL_LPM_EnableDeepSleep * @rmtoll SCB_SCR SLEEPDEEP LL_LPM_EnableDeepSleep
* @retval None * @retval None
*/ */
__STATIC_INLINE void LL_LPM_EnableDeepSleep(void) __STATIC_INLINE void LL_LPM_EnableDeepSleep(void)
{ {
/* Set SLEEPDEEP bit of Cortex System Control Register */ /* Set SLEEPDEEP bit of Cortex System Control Register */
SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk)); SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
} }
/** /**
* @brief Configures sleep-on-exit when returning from Handler mode to Thread mode. * @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 * @note Setting this bit to 1 enables an interrupt-driven application to avoid returning to an
* empty main application. * empty main application.
* @rmtoll SCB_SCR SLEEPONEXIT LL_LPM_EnableSleepOnExit * @rmtoll SCB_SCR SLEEPONEXIT LL_LPM_EnableSleepOnExit
* @retval None * @retval None
*/ */
__STATIC_INLINE void LL_LPM_EnableSleepOnExit(void) __STATIC_INLINE void LL_LPM_EnableSleepOnExit(void)
{ {
/* Set SLEEPONEXIT bit of Cortex System Control Register */ /* Set SLEEPONEXIT bit of Cortex System Control Register */
SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPONEXIT_Msk)); SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPONEXIT_Msk));
} }
/** /**
* @brief Do not sleep when returning to Thread mode. * @brief Do not sleep when returning to Thread mode.
* @rmtoll SCB_SCR SLEEPONEXIT LL_LPM_DisableSleepOnExit * @rmtoll SCB_SCR SLEEPONEXIT LL_LPM_DisableSleepOnExit
* @retval None * @retval None
*/ */
__STATIC_INLINE void LL_LPM_DisableSleepOnExit(void) __STATIC_INLINE void LL_LPM_DisableSleepOnExit(void)
{ {
/* Clear SLEEPONEXIT bit of Cortex System Control Register */ /* Clear SLEEPONEXIT bit of Cortex System Control Register */
CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPONEXIT_Msk)); CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPONEXIT_Msk));
} }
/** /**
* @brief Enabled events and all interrupts, including disabled interrupts, can wakeup the * @brief Enabled events and all interrupts, including disabled interrupts, can wakeup the
* processor. * processor.
* @rmtoll SCB_SCR SEVEONPEND LL_LPM_EnableEventOnPend * @rmtoll SCB_SCR SEVEONPEND LL_LPM_EnableEventOnPend
* @retval None * @retval None
*/ */
__STATIC_INLINE void LL_LPM_EnableEventOnPend(void) __STATIC_INLINE void LL_LPM_EnableEventOnPend(void)
{ {
/* Set SEVEONPEND bit of Cortex System Control Register */ /* Set SEVEONPEND bit of Cortex System Control Register */
SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SEVONPEND_Msk)); SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SEVONPEND_Msk));
} }
/** /**
* @brief Only enabled interrupts or events can wakeup the processor, disabled interrupts are * @brief Only enabled interrupts or events can wakeup the processor, disabled interrupts are
* excluded * excluded
* @rmtoll SCB_SCR SEVEONPEND LL_LPM_DisableEventOnPend * @rmtoll SCB_SCR SEVEONPEND LL_LPM_DisableEventOnPend
* @retval None * @retval None
*/ */
__STATIC_INLINE void LL_LPM_DisableEventOnPend(void) __STATIC_INLINE void LL_LPM_DisableEventOnPend(void)
{ {
/* Clear SEVEONPEND bit of Cortex System Control Register */ /* Clear SEVEONPEND bit of Cortex System Control Register */
CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SEVONPEND_Msk)); CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SEVONPEND_Msk));
} }
/** /**
* @} * @}
*/ */
/** @defgroup CORTEX_LL_EF_MCU_INFO MCU INFO /** @defgroup CORTEX_LL_EF_MCU_INFO MCU INFO
* @{ * @{
*/ */
/** /**
* @brief Get Implementer code * @brief Get Implementer code
* @rmtoll SCB_CPUID IMPLEMENTER LL_CPUID_GetImplementer * @rmtoll SCB_CPUID IMPLEMENTER LL_CPUID_GetImplementer
* @retval Value should be equal to 0x41 for ARM * @retval Value should be equal to 0x41 for ARM
*/ */
__STATIC_INLINE uint32_t LL_CPUID_GetImplementer(void) __STATIC_INLINE uint32_t LL_CPUID_GetImplementer(void)
{ {
return (uint32_t)(READ_BIT(SCB->CPUID, SCB_CPUID_IMPLEMENTER_Msk) >> SCB_CPUID_IMPLEMENTER_Pos); 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) * @brief Get Variant number (The r value in the rnpn product revision identifier)
* @rmtoll SCB_CPUID VARIANT LL_CPUID_GetVariant * @rmtoll SCB_CPUID VARIANT LL_CPUID_GetVariant
* @retval Value between 0 and 255 (0x0: revision 0) * @retval Value between 0 and 255 (0x0: revision 0)
*/ */
__STATIC_INLINE uint32_t LL_CPUID_GetVariant(void) __STATIC_INLINE uint32_t LL_CPUID_GetVariant(void)
{ {
return (uint32_t)(READ_BIT(SCB->CPUID, SCB_CPUID_VARIANT_Msk) >> SCB_CPUID_VARIANT_Pos); return (uint32_t)(READ_BIT(SCB->CPUID, SCB_CPUID_VARIANT_Msk) >> SCB_CPUID_VARIANT_Pos);
} }
/** /**
* @brief Get Architecture number * @brief Get Architecture number
* @rmtoll SCB_CPUID ARCHITECTURE LL_CPUID_GetArchitecture * @rmtoll SCB_CPUID ARCHITECTURE LL_CPUID_GetArchitecture
* @retval Value should be equal to 0xC for Cortex-M0+ devices * @retval Value should be equal to 0xC for Cortex-M0+ devices
*/ */
__STATIC_INLINE uint32_t LL_CPUID_GetArchitecture(void) __STATIC_INLINE uint32_t LL_CPUID_GetArchitecture(void)
{ {
return (uint32_t)(READ_BIT(SCB->CPUID, SCB_CPUID_ARCHITECTURE_Msk) >> SCB_CPUID_ARCHITECTURE_Pos); return (uint32_t)(READ_BIT(SCB->CPUID, SCB_CPUID_ARCHITECTURE_Msk) >> SCB_CPUID_ARCHITECTURE_Pos);
} }
/** /**
* @brief Get Part number * @brief Get Part number
* @rmtoll SCB_CPUID PARTNO LL_CPUID_GetParNo * @rmtoll SCB_CPUID PARTNO LL_CPUID_GetParNo
* @retval Value should be equal to 0xC60 for Cortex-M0+ * @retval Value should be equal to 0xC60 for Cortex-M0+
*/ */
__STATIC_INLINE uint32_t LL_CPUID_GetParNo(void) __STATIC_INLINE uint32_t LL_CPUID_GetParNo(void)
{ {
return (uint32_t)(READ_BIT(SCB->CPUID, SCB_CPUID_PARTNO_Msk) >> SCB_CPUID_PARTNO_Pos); 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) * @brief Get Revision number (The p value in the rnpn product revision identifier, indicates patch release)
* @rmtoll SCB_CPUID REVISION LL_CPUID_GetRevision * @rmtoll SCB_CPUID REVISION LL_CPUID_GetRevision
* @retval Value between 0 and 255 (0x1: patch 1) * @retval Value between 0 and 255 (0x1: patch 1)
*/ */
__STATIC_INLINE uint32_t LL_CPUID_GetRevision(void) __STATIC_INLINE uint32_t LL_CPUID_GetRevision(void)
{ {
return (uint32_t)(READ_BIT(SCB->CPUID, SCB_CPUID_REVISION_Msk) >> SCB_CPUID_REVISION_Pos); return (uint32_t)(READ_BIT(SCB->CPUID, SCB_CPUID_REVISION_Msk) >> SCB_CPUID_REVISION_Pos);
} }
/** /**
* @} * @}
*/ */
/** /**
* @} * @}
*/ */
/** /**
* @} * @}
*/ */
/** /**
* @} * @}
*/ */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* __PY32F0XX_LL_CORTEX_H */ #endif /* __PY32F0XX_LL_CORTEX_H */
/************************ (C) COPYRIGHT Puya *****END OF FILE****/ /************************ (C) COPYRIGHT Puya *****END OF FILE****/

View File

@ -1,204 +1,204 @@
/** /**
****************************************************************************** ******************************************************************************
* @file py32f0xx_ll_crc.h * @file py32f0xx_ll_crc.h
* @author MCU Application Team * @author MCU Application Team
* @brief Header file of CRC LL module. * @brief Header file of CRC LL module.
****************************************************************************** ******************************************************************************
* @attention * @attention
* *
* <h2><center>&copy; Copyright (c) Puya Semiconductor Co. * <h2><center>&copy; Copyright (c) Puya Semiconductor Co.
* All rights reserved.</center></h2> * All rights reserved.</center></h2>
* *
* <h2><center>&copy; Copyright (c) 2016 STMicroelectronics. * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
* All rights reserved.</center></h2> * All rights reserved.</center></h2>
* *
* This software component is licensed by ST under BSD 3-Clause license, * 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 * the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at: * License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause * opensource.org/licenses/BSD-3-Clause
* *
****************************************************************************** ******************************************************************************
*/ */
/* Define to prevent recursive inclusion -------------------------------------*/ /* Define to prevent recursive inclusion -------------------------------------*/
#ifndef PY32F0xx_LL_CRC_H #ifndef PY32F0xx_LL_CRC_H
#define PY32F0xx_LL_CRC_H #define PY32F0xx_LL_CRC_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/* Includes ------------------------------------------------------------------*/ /* Includes ------------------------------------------------------------------*/
#include "py32f0xx.h" #include "py32f0xx.h"
/** @addtogroup PY32F0xx_LL_Driver /** @addtogroup PY32F0xx_LL_Driver
* @{ * @{
*/ */
#if defined(CRC) #if defined(CRC)
/** @defgroup CRC_LL CRC /** @defgroup CRC_LL CRC
* @{ * @{
*/ */
/* Private types -------------------------------------------------------------*/ /* Private types -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/
/* Private constants ---------------------------------------------------------*/ /* Private constants ---------------------------------------------------------*/
/* Private macros ------------------------------------------------------------*/ /* Private macros ------------------------------------------------------------*/
/* Exported types ------------------------------------------------------------*/ /* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/
/** @defgroup CRC_LL_Exported_Constants CRC Exported Constants /** @defgroup CRC_LL_Exported_Constants CRC Exported Constants
* @{ * @{
*/ */
/** /**
* @} * @}
*/ */
/* Exported macro ------------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/
/** @defgroup CRC_LL_Exported_Macros CRC Exported Macros /** @defgroup CRC_LL_Exported_Macros CRC Exported Macros
* @{ * @{
*/ */
/** @defgroup CRC_LL_EM_WRITE_READ Common Write and read registers Macros /** @defgroup CRC_LL_EM_WRITE_READ Common Write and read registers Macros
* @{ * @{
*/ */
/** /**
* @brief Write a value in CRC register * @brief Write a value in CRC register
* @param __INSTANCE__ CRC Instance * @param __INSTANCE__ CRC Instance
* @param __REG__ Register to be written * @param __REG__ Register to be written
* @param __VALUE__ Value to be written in the register * @param __VALUE__ Value to be written in the register
* @retval None * @retval None
*/ */
#define LL_CRC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, __VALUE__) #define LL_CRC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, __VALUE__)
/** /**
* @brief Read a value in CRC register * @brief Read a value in CRC register
* @param __INSTANCE__ CRC Instance * @param __INSTANCE__ CRC Instance
* @param __REG__ Register to be read * @param __REG__ Register to be read
* @retval Register value * @retval Register value
*/ */
#define LL_CRC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__) #define LL_CRC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
/** /**
* @} * @}
*/ */
/** /**
* @} * @}
*/ */
/* Exported functions --------------------------------------------------------*/ /* Exported functions --------------------------------------------------------*/
/** @defgroup CRC_LL_Exported_Functions CRC Exported Functions /** @defgroup CRC_LL_Exported_Functions CRC Exported Functions
* @{ * @{
*/ */
/** @defgroup CRC_LL_EF_Configuration CRC Configuration functions /** @defgroup CRC_LL_EF_Configuration CRC Configuration functions
* @{ * @{
*/ */
/** /**
* @brief Reset the CRC calculation unit. * @brief Reset the CRC calculation unit.
* @rmtoll CR RESET LL_CRC_ResetCRCCalculationUnit * @rmtoll CR RESET LL_CRC_ResetCRCCalculationUnit
* @param CRCx CRC Instance * @param CRCx CRC Instance
* @retval None * @retval None
*/ */
__STATIC_INLINE void LL_CRC_ResetCRCCalculationUnit(CRC_TypeDef *CRCx) __STATIC_INLINE void LL_CRC_ResetCRCCalculationUnit(CRC_TypeDef *CRCx)
{ {
SET_BIT(CRCx->CR, CRC_CR_RESET); SET_BIT(CRCx->CR, CRC_CR_RESET);
} }
/** /**
* @} * @}
*/ */
/** @defgroup CRC_LL_EF_Data_Management Data_Management /** @defgroup CRC_LL_EF_Data_Management Data_Management
* @{ * @{
*/ */
/** /**
* @brief Write given 32-bit data to the CRC calculator * @brief Write given 32-bit data to the CRC calculator
* @rmtoll DR DR LL_CRC_FeedData32 * @rmtoll DR DR LL_CRC_FeedData32
* @param CRCx CRC Instance * @param CRCx CRC Instance
* @param InData value to be provided to CRC calculator between between Min_Data=0 and Max_Data=0xFFFFFFFF * @param InData value to be provided to CRC calculator between between Min_Data=0 and Max_Data=0xFFFFFFFF
* @retval None * @retval None
*/ */
__STATIC_INLINE void LL_CRC_FeedData32(CRC_TypeDef *CRCx, uint32_t InData) __STATIC_INLINE void LL_CRC_FeedData32(CRC_TypeDef *CRCx, uint32_t InData)
{ {
WRITE_REG(CRCx->DR, InData); WRITE_REG(CRCx->DR, InData);
} }
/** /**
* @brief Return current CRC calculation result. 32 bits value is returned. * @brief Return current CRC calculation result. 32 bits value is returned.
* @rmtoll DR DR LL_CRC_ReadData32 * @rmtoll DR DR LL_CRC_ReadData32
* @param CRCx CRC Instance * @param CRCx CRC Instance
* @retval Current CRC calculation result as stored in CRC_DR register (32 bits). * @retval Current CRC calculation result as stored in CRC_DR register (32 bits).
*/ */
__STATIC_INLINE uint32_t LL_CRC_ReadData32(CRC_TypeDef *CRCx) __STATIC_INLINE uint32_t LL_CRC_ReadData32(CRC_TypeDef *CRCx)
{ {
return (uint32_t)(READ_REG(CRCx->DR)); return (uint32_t)(READ_REG(CRCx->DR));
} }
/** /**
* @brief Return data stored in the Independent Data(IDR) register. * @brief Return data stored in the Independent Data(IDR) register.
* @note This register can be used as a temporary storage location for one byte. * @note This register can be used as a temporary storage location for one byte.
* @rmtoll IDR IDR LL_CRC_Read_IDR * @rmtoll IDR IDR LL_CRC_Read_IDR
* @param CRCx CRC Instance * @param CRCx CRC Instance
* @retval Value stored in CRC_IDR register (General-purpose 8-bit data register). * @retval Value stored in CRC_IDR register (General-purpose 8-bit data register).
*/ */
__STATIC_INLINE uint32_t LL_CRC_Read_IDR(CRC_TypeDef *CRCx) __STATIC_INLINE uint32_t LL_CRC_Read_IDR(CRC_TypeDef *CRCx)
{ {
return (uint32_t)(READ_REG(CRCx->IDR)); return (uint32_t)(READ_REG(CRCx->IDR));
} }
/** /**
* @brief Store data in the Independent Data(IDR) register. * @brief Store data in the Independent Data(IDR) register.
* @note This register can be used as a temporary storage location for one byte. * @note This register can be used as a temporary storage location for one byte.
* @rmtoll IDR IDR LL_CRC_Write_IDR * @rmtoll IDR IDR LL_CRC_Write_IDR
* @param CRCx CRC Instance * @param CRCx CRC Instance
* @param InData value to be stored in CRC_IDR register (8-bit) between Min_Data=0 and Max_Data=0xFF * @param InData value to be stored in CRC_IDR register (8-bit) between Min_Data=0 and Max_Data=0xFF
* @retval None * @retval None
*/ */
__STATIC_INLINE void LL_CRC_Write_IDR(CRC_TypeDef *CRCx, uint32_t InData) __STATIC_INLINE void LL_CRC_Write_IDR(CRC_TypeDef *CRCx, uint32_t InData)
{ {
*((uint8_t __IO *)(&CRCx->IDR)) = (uint8_t) InData; *((uint8_t __IO *)(&CRCx->IDR)) = (uint8_t) InData;
} }
/** /**
* @} * @}
*/ */
#if defined(USE_FULL_LL_DRIVER) #if defined(USE_FULL_LL_DRIVER)
/** @defgroup CRC_LL_EF_Init Initialization and de-initialization functions /** @defgroup CRC_LL_EF_Init Initialization and de-initialization functions
* @{ * @{
*/ */
ErrorStatus LL_CRC_DeInit(CRC_TypeDef *CRCx); ErrorStatus LL_CRC_DeInit(CRC_TypeDef *CRCx);
/** /**
* @} * @}
*/ */
#endif /* USE_FULL_LL_DRIVER */ #endif /* USE_FULL_LL_DRIVER */
/** /**
* @} * @}
*/ */
/** /**
* @} * @}
*/ */
#endif /* defined(CRC) */ #endif /* defined(CRC) */
/** /**
* @} * @}
*/ */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* PY32F0xx_LL_CRC_H */ #endif /* PY32F0xx_LL_CRC_H */
/************************ (C) COPYRIGHT Puya *****END OF FILE****/ /************************ (C) COPYRIGHT Puya *****END OF FILE****/

View File

@ -1,313 +1,313 @@
/** /**
****************************************************************************** ******************************************************************************
* @file py32f0xx_ll_iwdg.h * @file py32f0xx_ll_iwdg.h
* @author MCU Application Team * @author MCU Application Team
* @brief Header file of IWDG LL module. * @brief Header file of IWDG LL module.
****************************************************************************** ******************************************************************************
* @attention * @attention
* *
* <h2><center>&copy; Copyright (c) Puya Semiconductor Co. * <h2><center>&copy; Copyright (c) Puya Semiconductor Co.
* All rights reserved.</center></h2> * All rights reserved.</center></h2>
* *
* <h2><center>&copy; Copyright (c) 2016 STMicroelectronics. * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
* All rights reserved.</center></h2> * All rights reserved.</center></h2>
* *
* This software component is licensed by ST under BSD 3-Clause license, * 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 * the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at: * License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause * opensource.org/licenses/BSD-3-Clause
* *
****************************************************************************** ******************************************************************************
*/ */
/* Define to prevent recursive inclusion -------------------------------------*/ /* Define to prevent recursive inclusion -------------------------------------*/
#ifndef PY32F0XX_LL_IWDG_H #ifndef PY32F0XX_LL_IWDG_H
#define PY32F0XX_LL_IWDG_H #define PY32F0XX_LL_IWDG_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/* Includes ------------------------------------------------------------------*/ /* Includes ------------------------------------------------------------------*/
#include "py32f0xx.h" #include "py32f0xx.h"
/** @addtogroup PY32F0XX_LL_Driver /** @addtogroup PY32F0XX_LL_Driver
* @{ * @{
*/ */
#if defined(IWDG) #if defined(IWDG)
/** @defgroup IWDG_LL IWDG /** @defgroup IWDG_LL IWDG
* @{ * @{
*/ */
/* Private types -------------------------------------------------------------*/ /* Private types -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/
/* Private constants ---------------------------------------------------------*/ /* Private constants ---------------------------------------------------------*/
/** @defgroup IWDG_LL_Private_Constants IWDG Private Constants /** @defgroup IWDG_LL_Private_Constants IWDG Private Constants
* @{ * @{
*/ */
#define LL_IWDG_KEY_RELOAD 0x0000AAAAU /*!< IWDG Reload Counter Enable */ #define LL_IWDG_KEY_RELOAD 0x0000AAAAU /*!< IWDG Reload Counter Enable */
#define LL_IWDG_KEY_ENABLE 0x0000CCCCU /*!< IWDG Peripheral 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_ENABLE 0x00005555U /*!< IWDG KR Write Access Enable */
#define LL_IWDG_KEY_WR_ACCESS_DISABLE 0x00000000U /*!< IWDG KR Write Access Disable */ #define LL_IWDG_KEY_WR_ACCESS_DISABLE 0x00000000U /*!< IWDG KR Write Access Disable */
/** /**
* @} * @}
*/ */
/* Private macros ------------------------------------------------------------*/ /* Private macros ------------------------------------------------------------*/
/* Exported types ------------------------------------------------------------*/ /* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/
/** @defgroup IWDG_LL_Exported_Constants IWDG Exported Constants /** @defgroup IWDG_LL_Exported_Constants IWDG Exported Constants
* @{ * @{
*/ */
/** @defgroup IWDG_LL_EC_GET_FLAG Get Flags Defines /** @defgroup IWDG_LL_EC_GET_FLAG Get Flags Defines
* @brief Flags defines which can be used with LL_IWDG_ReadReg function * @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_PVU IWDG_SR_PVU /*!< Watchdog prescaler value update */
#define LL_IWDG_SR_RVU IWDG_SR_RVU /*!< Watchdog counter reload value update */ #define LL_IWDG_SR_RVU IWDG_SR_RVU /*!< Watchdog counter reload value update */
/** /**
* @} * @}
*/ */
/** @defgroup IWDG_LL_EC_PRESCALER Prescaler Divider /** @defgroup IWDG_LL_EC_PRESCALER Prescaler Divider
* @{ * @{
*/ */
#define LL_IWDG_PRESCALER_4 0x00000000U /*!< Divider by 4 */ #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_8 ( IWDG_PR_PR_0) /*!< Divider by 8 */
#define LL_IWDG_PRESCALER_16 ( IWDG_PR_PR_1 ) /*!< Divider by 16 */ #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_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_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_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 */ #define LL_IWDG_PRESCALER_256 (IWDG_PR_PR_2 | IWDG_PR_PR_1 ) /*!< Divider by 256 */
/** /**
* @} * @}
*/ */
/** /**
* @} * @}
*/ */
/* Exported macro ------------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/
/** @defgroup IWDG_LL_Exported_Macros IWDG Exported Macros /** @defgroup IWDG_LL_Exported_Macros IWDG Exported Macros
* @{ * @{
*/ */
/** @defgroup IWDG_LL_EM_WRITE_READ Common Write and read registers Macros /** @defgroup IWDG_LL_EM_WRITE_READ Common Write and read registers Macros
* @{ * @{
*/ */
/** /**
* @brief Write a value in IWDG register * @brief Write a value in IWDG register
* @param __INSTANCE__ IWDG Instance * @param __INSTANCE__ IWDG Instance
* @param __REG__ Register to be written * @param __REG__ Register to be written
* @param __VALUE__ Value to be written in the register * @param __VALUE__ Value to be written in the register
* @retval None * @retval None
*/ */
#define LL_IWDG_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__)) #define LL_IWDG_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
/** /**
* @brief Read a value in IWDG register * @brief Read a value in IWDG register
* @param __INSTANCE__ IWDG Instance * @param __INSTANCE__ IWDG Instance
* @param __REG__ Register to be read * @param __REG__ Register to be read
* @retval Register value * @retval Register value
*/ */
#define LL_IWDG_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__) #define LL_IWDG_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
/** /**
* @} * @}
*/ */
/** /**
* @} * @}
*/ */
/* Exported functions --------------------------------------------------------*/ /* Exported functions --------------------------------------------------------*/
/** @defgroup IWDG_LL_Exported_Functions IWDG Exported Functions /** @defgroup IWDG_LL_Exported_Functions IWDG Exported Functions
* @{ * @{
*/ */
/** @defgroup IWDG_LL_EF_Configuration Configuration /** @defgroup IWDG_LL_EF_Configuration Configuration
* @{ * @{
*/ */
/** /**
* @brief Start the Independent Watchdog * @brief Start the Independent Watchdog
* @note Except if the hardware watchdog option is selected * @note Except if the hardware watchdog option is selected
* @rmtoll KR KEY LL_IWDG_Enable * @rmtoll KR KEY LL_IWDG_Enable
* @param IWDGx IWDG Instance * @param IWDGx IWDG Instance
* @retval None * @retval None
*/ */
__STATIC_INLINE void LL_IWDG_Enable(IWDG_TypeDef *IWDGx) __STATIC_INLINE void LL_IWDG_Enable(IWDG_TypeDef *IWDGx)
{ {
WRITE_REG(IWDGx->KR, LL_IWDG_KEY_ENABLE); WRITE_REG(IWDGx->KR, LL_IWDG_KEY_ENABLE);
} }
/** /**
* @brief Reloads IWDG counter with value defined in the reload register * @brief Reloads IWDG counter with value defined in the reload register
* @rmtoll KR KEY LL_IWDG_ReloadCounter * @rmtoll KR KEY LL_IWDG_ReloadCounter
* @param IWDGx IWDG Instance * @param IWDGx IWDG Instance
* @retval None * @retval None
*/ */
__STATIC_INLINE void LL_IWDG_ReloadCounter(IWDG_TypeDef *IWDGx) __STATIC_INLINE void LL_IWDG_ReloadCounter(IWDG_TypeDef *IWDGx)
{ {
WRITE_REG(IWDGx->KR, LL_IWDG_KEY_RELOAD); WRITE_REG(IWDGx->KR, LL_IWDG_KEY_RELOAD);
} }
/** /**
* @brief Enable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers * @brief Enable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers
* @rmtoll KR KEY LL_IWDG_EnableWriteAccess * @rmtoll KR KEY LL_IWDG_EnableWriteAccess
* @param IWDGx IWDG Instance * @param IWDGx IWDG Instance
* @retval None * @retval None
*/ */
__STATIC_INLINE void LL_IWDG_EnableWriteAccess(IWDG_TypeDef *IWDGx) __STATIC_INLINE void LL_IWDG_EnableWriteAccess(IWDG_TypeDef *IWDGx)
{ {
WRITE_REG(IWDGx->KR, LL_IWDG_KEY_WR_ACCESS_ENABLE); WRITE_REG(IWDGx->KR, LL_IWDG_KEY_WR_ACCESS_ENABLE);
} }
/** /**
* @brief Disable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers * @brief Disable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers
* @rmtoll KR KEY LL_IWDG_DisableWriteAccess * @rmtoll KR KEY LL_IWDG_DisableWriteAccess
* @param IWDGx IWDG Instance * @param IWDGx IWDG Instance
* @retval None * @retval None
*/ */
__STATIC_INLINE void LL_IWDG_DisableWriteAccess(IWDG_TypeDef *IWDGx) __STATIC_INLINE void LL_IWDG_DisableWriteAccess(IWDG_TypeDef *IWDGx)
{ {
WRITE_REG(IWDGx->KR, LL_IWDG_KEY_WR_ACCESS_DISABLE); WRITE_REG(IWDGx->KR, LL_IWDG_KEY_WR_ACCESS_DISABLE);
} }
/** /**
* @brief Select the prescaler of the IWDG * @brief Select the prescaler of the IWDG
* @rmtoll PR PR LL_IWDG_SetPrescaler * @rmtoll PR PR LL_IWDG_SetPrescaler
* @param IWDGx IWDG Instance * @param IWDGx IWDG Instance
* @param Prescaler This parameter can be one of the following values: * @param Prescaler This parameter can be one of the following values:
* @arg @ref LL_IWDG_PRESCALER_4 * @arg @ref LL_IWDG_PRESCALER_4
* @arg @ref LL_IWDG_PRESCALER_8 * @arg @ref LL_IWDG_PRESCALER_8
* @arg @ref LL_IWDG_PRESCALER_16 * @arg @ref LL_IWDG_PRESCALER_16
* @arg @ref LL_IWDG_PRESCALER_32 * @arg @ref LL_IWDG_PRESCALER_32
* @arg @ref LL_IWDG_PRESCALER_64 * @arg @ref LL_IWDG_PRESCALER_64
* @arg @ref LL_IWDG_PRESCALER_128 * @arg @ref LL_IWDG_PRESCALER_128
* @arg @ref LL_IWDG_PRESCALER_256 * @arg @ref LL_IWDG_PRESCALER_256
* @retval None * @retval None
*/ */
__STATIC_INLINE void LL_IWDG_SetPrescaler(IWDG_TypeDef *IWDGx, uint32_t Prescaler) __STATIC_INLINE void LL_IWDG_SetPrescaler(IWDG_TypeDef *IWDGx, uint32_t Prescaler)
{ {
WRITE_REG(IWDGx->PR, IWDG_PR_PR & Prescaler); WRITE_REG(IWDGx->PR, IWDG_PR_PR & Prescaler);
} }
/** /**
* @brief Get the selected prescaler of the IWDG * @brief Get the selected prescaler of the IWDG
* @rmtoll PR PR LL_IWDG_GetPrescaler * @rmtoll PR PR LL_IWDG_GetPrescaler
* @param IWDGx IWDG Instance * @param IWDGx IWDG Instance
* @retval Returned value can be one of the following values: * @retval Returned value can be one of the following values:
* @arg @ref LL_IWDG_PRESCALER_4 * @arg @ref LL_IWDG_PRESCALER_4
* @arg @ref LL_IWDG_PRESCALER_8 * @arg @ref LL_IWDG_PRESCALER_8
* @arg @ref LL_IWDG_PRESCALER_16 * @arg @ref LL_IWDG_PRESCALER_16
* @arg @ref LL_IWDG_PRESCALER_32 * @arg @ref LL_IWDG_PRESCALER_32
* @arg @ref LL_IWDG_PRESCALER_64 * @arg @ref LL_IWDG_PRESCALER_64
* @arg @ref LL_IWDG_PRESCALER_128 * @arg @ref LL_IWDG_PRESCALER_128
* @arg @ref LL_IWDG_PRESCALER_256 * @arg @ref LL_IWDG_PRESCALER_256
*/ */
__STATIC_INLINE uint32_t LL_IWDG_GetPrescaler(IWDG_TypeDef *IWDGx) __STATIC_INLINE uint32_t LL_IWDG_GetPrescaler(IWDG_TypeDef *IWDGx)
{ {
return (uint32_t)(READ_REG(IWDGx->PR)); return (uint32_t)(READ_REG(IWDGx->PR));
} }
/** /**
* @brief Specify the IWDG down-counter reload value * @brief Specify the IWDG down-counter reload value
* @rmtoll RLR RL LL_IWDG_SetReloadCounter * @rmtoll RLR RL LL_IWDG_SetReloadCounter
* @param IWDGx IWDG Instance * @param IWDGx IWDG Instance
* @param Counter Value between Min_Data=0 and Max_Data=0x0FFF * @param Counter Value between Min_Data=0 and Max_Data=0x0FFF
* @retval None * @retval None
*/ */
__STATIC_INLINE void LL_IWDG_SetReloadCounter(IWDG_TypeDef *IWDGx, uint32_t Counter) __STATIC_INLINE void LL_IWDG_SetReloadCounter(IWDG_TypeDef *IWDGx, uint32_t Counter)
{ {
WRITE_REG(IWDGx->RLR, IWDG_RLR_RL & Counter); WRITE_REG(IWDGx->RLR, IWDG_RLR_RL & Counter);
} }
/** /**
* @brief Get the specified IWDG down-counter reload value * @brief Get the specified IWDG down-counter reload value
* @rmtoll RLR RL LL_IWDG_GetReloadCounter * @rmtoll RLR RL LL_IWDG_GetReloadCounter
* @param IWDGx IWDG Instance * @param IWDGx IWDG Instance
* @retval Value between Min_Data=0 and Max_Data=0x0FFF * @retval Value between Min_Data=0 and Max_Data=0x0FFF
*/ */
__STATIC_INLINE uint32_t LL_IWDG_GetReloadCounter(IWDG_TypeDef *IWDGx) __STATIC_INLINE uint32_t LL_IWDG_GetReloadCounter(IWDG_TypeDef *IWDGx)
{ {
return (uint32_t)(READ_REG(IWDGx->RLR)); return (uint32_t)(READ_REG(IWDGx->RLR));
} }
/** /**
* @} * @}
*/ */
/** @defgroup IWDG_LL_EF_FLAG_Management FLAG_Management /** @defgroup IWDG_LL_EF_FLAG_Management FLAG_Management
* @{ * @{
*/ */
/** /**
* @brief Check if flag Prescaler Value Update is set or not * @brief Check if flag Prescaler Value Update is set or not
* @rmtoll SR PVU LL_IWDG_IsActiveFlag_PVU * @rmtoll SR PVU LL_IWDG_IsActiveFlag_PVU
* @param IWDGx IWDG Instance * @param IWDGx IWDG Instance
* @retval State of bit (1 or 0). * @retval State of bit (1 or 0).
*/ */
__STATIC_INLINE uint32_t LL_IWDG_IsActiveFlag_PVU(IWDG_TypeDef *IWDGx) __STATIC_INLINE uint32_t LL_IWDG_IsActiveFlag_PVU(IWDG_TypeDef *IWDGx)
{ {
return (READ_BIT(IWDGx->SR, IWDG_SR_PVU) == (IWDG_SR_PVU)); return (READ_BIT(IWDGx->SR, IWDG_SR_PVU) == (IWDG_SR_PVU));
} }
/** /**
* @brief Check if flag Reload Value Update is set or not * @brief Check if flag Reload Value Update is set or not
* @rmtoll SR RVU LL_IWDG_IsActiveFlag_RVU * @rmtoll SR RVU LL_IWDG_IsActiveFlag_RVU
* @param IWDGx IWDG Instance * @param IWDGx IWDG Instance
* @retval State of bit (1 or 0). * @retval State of bit (1 or 0).
*/ */
__STATIC_INLINE uint32_t LL_IWDG_IsActiveFlag_RVU(IWDG_TypeDef *IWDGx) __STATIC_INLINE uint32_t LL_IWDG_IsActiveFlag_RVU(IWDG_TypeDef *IWDGx)
{ {
return (READ_BIT(IWDGx->SR, IWDG_SR_RVU) == (IWDG_SR_RVU)); 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 * @brief Check if all flags Prescaler, Reload & Window Value Update are reset or not
* @rmtoll SR PVU LL_IWDG_IsReady\n * @rmtoll SR PVU LL_IWDG_IsReady\n
* SR RVU LL_IWDG_IsReady * SR RVU LL_IWDG_IsReady
* @param IWDGx IWDG Instance * @param IWDGx IWDG Instance
* @retval State of bits (1 or 0). * @retval State of bits (1 or 0).
*/ */
__STATIC_INLINE uint32_t LL_IWDG_IsReady(IWDG_TypeDef *IWDGx) __STATIC_INLINE uint32_t LL_IWDG_IsReady(IWDG_TypeDef *IWDGx)
{ {
return (READ_BIT(IWDGx->SR, IWDG_SR_PVU | IWDG_SR_RVU) == 0U); return (READ_BIT(IWDGx->SR, IWDG_SR_PVU | IWDG_SR_RVU) == 0U);
} }
/** /**
* @} * @}
*/ */
/** /**
* @} * @}
*/ */
/** /**
* @} * @}
*/ */
#endif /* IWDG */ #endif /* IWDG */
/** /**
* @} * @}
*/ */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* PY32F0XX_LL_IWDG_H */ #endif /* PY32F0XX_LL_IWDG_H */
/************************ (C) COPYRIGHT Puya *****END OF FILE****/ /************************ (C) COPYRIGHT Puya *****END OF FILE****/

View File

@ -1,475 +1,475 @@
/** /**
****************************************************************************** ******************************************************************************
* @file py32f0xx_ll_led.h * @file py32f0xx_ll_led.h
* @author MCU Application Team * @author MCU Application Team
* @brief Header file of LED LL module. * @brief Header file of LED LL module.
****************************************************************************** ******************************************************************************
* @attention * @attention
* *
* <h2><center>&copy; Copyright (c) Puya Semiconductor Co. * <h2><center>&copy; Copyright (c) Puya Semiconductor Co.
* All rights reserved.</center></h2> * All rights reserved.</center></h2>
* *
* <h2><center>&copy; Copyright (c) 2016 STMicroelectronics. * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
* All rights reserved.</center></h2> * All rights reserved.</center></h2>
* *
* This software component is licensed by ST under BSD 3-Clause license, * 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 * the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at: * License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause * opensource.org/licenses/BSD-3-Clause
* *
****************************************************************************** ******************************************************************************
*/ */
/* Define to prevent recursive inclusion -------------------------------------*/ /* Define to prevent recursive inclusion -------------------------------------*/
#ifndef PY32F0XX_LL_LED_H #ifndef PY32F0XX_LL_LED_H
#define PY32F0XX_LL_LED_H #define PY32F0XX_LL_LED_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/* Includes ------------------------------------------------------------------*/ /* Includes ------------------------------------------------------------------*/
#include "py32f0xx.h" #include "py32f0xx.h"
/** @addtogroup PY32F0XX_LL_Driver /** @addtogroup PY32F0XX_LL_Driver
* @{ * @{
*/ */
#if defined (LED) #if defined (LED)
/** @defgroup LED_LL LED /** @defgroup LED_LL LED
* @{ * @{
*/ */
/* Private types -------------------------------------------------------------*/ /* Private types -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/
/* Private constants ---------------------------------------------------------*/ /* Private constants ---------------------------------------------------------*/
/* Private macros ------------------------------------------------------------*/ /* Private macros ------------------------------------------------------------*/
/* Exported types ------------------------------------------------------------*/ /* Exported types ------------------------------------------------------------*/
/** /**
* @brief LED Init Structure definition * @brief LED Init Structure definition
*/ */
typedef struct typedef struct
{ {
uint32_t ComDrive; /*!< Specifies the LED COM drive capability. uint32_t ComDrive; /*!< Specifies the LED COM drive capability.
This parameter can be a value of @ref LED_LL_EC_ComDrive */ 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. 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) */ 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. uint32_t ComSelect; /*!< Specifies the number of COM open.
This parameter can be a value of @ref LED_LL_EC_ComSelct */ This parameter can be a value of @ref LED_LL_EC_ComSelct */
uint32_t LightTime; /*!< Specifies LED Lighting time. uint32_t LightTime; /*!< Specifies LED Lighting time.
This parameter can be a number between Min_Data = 1 and Max_Data = 0xFF */ This parameter can be a number between Min_Data = 1 and Max_Data = 0xFF */
uint32_t DeadTime; /*!< Specifies LED Dead time. uint32_t DeadTime; /*!< Specifies LED Dead time.
This parameter can be a number between Min_Data = 1 and Max_Data = 0xFF */ This parameter can be a number between Min_Data = 1 and Max_Data = 0xFF */
} LL_LED_InitTypeDef; } LL_LED_InitTypeDef;
/* Exported constants --------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/
/** @defgroup LED_LL_EC_ComDrive ComDrive /** @defgroup LED_LL_EC_ComDrive ComDrive
* @{ * @{
*/ */
#define LL_LED_COMDRIVE_LOW 0x00000000U #define LL_LED_COMDRIVE_LOW 0x00000000U
#define LL_LED_COMDRIVE_HIGH LED_CR_EHS #define LL_LED_COMDRIVE_HIGH LED_CR_EHS
/** /**
* @} * @}
*/ */
/** @defgroup LED_LL_EC_ComSelct the number of COM open /** @defgroup LED_LL_EC_ComSelct the number of COM open
* @{ * @{
*/ */
#define LL_LED_COMSELECT_1COM 0x00000000U #define LL_LED_COMSELECT_1COM 0x00000000U
#define LL_LED_COMSELECT_2COM LED_CR_LED_COM_SEL_0 #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_3COM LED_CR_LED_COM_SEL_1
#define LL_LED_COMSELECT_4COM (LED_CR_LED_COM_SEL_1 | LED_CR_LED_COM_SEL_0) #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 /** @defgroup LED_LL_EC_DisplayValue LED display value
* @{ * @{
*/ */
#define LL_LED_DISP_NONE 0x00U #define LL_LED_DISP_NONE 0x00U
#define LL_LED_DISP_FULL 0xFFU #define LL_LED_DISP_FULL 0xFFU
#define LL_LED_DISP_0 0x3FU #define LL_LED_DISP_0 0x3FU
#define LL_LED_DISP_1 0x06U #define LL_LED_DISP_1 0x06U
#define LL_LED_DISP_2 0x5BU #define LL_LED_DISP_2 0x5BU
#define LL_LED_DISP_3 0x4FU #define LL_LED_DISP_3 0x4FU
#define LL_LED_DISP_4 0x66U #define LL_LED_DISP_4 0x66U
#define LL_LED_DISP_5 0x6DU #define LL_LED_DISP_5 0x6DU
#define LL_LED_DISP_6 0x7DU #define LL_LED_DISP_6 0x7DU
#define LL_LED_DISP_7 0x07U #define LL_LED_DISP_7 0x07U
#define LL_LED_DISP_8 0x7FU #define LL_LED_DISP_8 0x7FU
#define LL_LED_DISP_9 0x6FU #define LL_LED_DISP_9 0x6FU
#define LL_LED_DISP_A 0x77U #define LL_LED_DISP_A 0x77U
#define LL_LED_DISP_B 0x7CU #define LL_LED_DISP_B 0x7CU
#define LL_LED_DISP_C 0x39U #define LL_LED_DISP_C 0x39U
#define LL_LED_DISP_D 0x5EU #define LL_LED_DISP_D 0x5EU
#define LL_LED_DISP_E 0x79U #define LL_LED_DISP_E 0x79U
#define LL_LED_DISP_F 0x71U #define LL_LED_DISP_F 0x71U
#define LL_LED_DISP_H 0x76U #define LL_LED_DISP_H 0x76U
#define LL_LED_DISP_P 0x73U #define LL_LED_DISP_P 0x73U
#define LL_LED_DISP_U 0x3EU #define LL_LED_DISP_U 0x3EU
#define LL_LED_DISP_DOT 0x80U #define LL_LED_DISP_DOT 0x80U
/** /**
* @} * @}
*/ */
/** @defgroup LED_LL_EC_ComDisplay LED COM Select /** @defgroup LED_LL_EC_ComDisplay LED COM Select
* @{ * @{
*/ */
#define LL_LED_COM0 0x00000000U #define LL_LED_COM0 0x00000000U
#define LL_LED_COM1 0x00000004U #define LL_LED_COM1 0x00000004U
#define LL_LED_COM2 0x00000008U #define LL_LED_COM2 0x00000008U
#define LL_LED_COM3 0x0000000CU #define LL_LED_COM3 0x0000000CU
/** /**
* @} * @}
*/ */
/** @defgroup LED_LL_EC_DataReg Data Register Mask and position /** @defgroup LED_LL_EC_DataReg Data Register Mask and position
* @{ * @{
*/ */
#define LL_LED_DR_DATA LED_DR0_DATA0 #define LL_LED_DR_DATA LED_DR0_DATA0
#define LL_LED_DR_DATA_Pos LED_DR0_DATA0_Pos #define LL_LED_DR_DATA_Pos LED_DR0_DATA0_Pos
/** /**
* @} * @}
*/ */
/* Exported functions --------------------------------------------------------*/ /* Exported functions --------------------------------------------------------*/
/** /**
* @brief Set the LED COM drive capability. * @brief Set the LED COM drive capability.
* @param LEDx LED Instance * @param LEDx LED Instance
* @param ComDrive This parameter can be one of the following values: * @param ComDrive This parameter can be one of the following values:
* @arg @ref LL_LED_COMDRIVE_LOW * @arg @ref LL_LED_COMDRIVE_LOW
* @arg @ref LL_LED_COMDRIVE_HIGH * @arg @ref LL_LED_COMDRIVE_HIGH
* @retval None * @retval None
*/ */
__STATIC_INLINE void LL_LED_SetComDrive(LED_TypeDef *LEDx, uint32_t ComDrive) __STATIC_INLINE void LL_LED_SetComDrive(LED_TypeDef *LEDx, uint32_t ComDrive)
{ {
MODIFY_REG(LEDx->CR, LED_CR_EHS, ComDrive); MODIFY_REG(LEDx->CR, LED_CR_EHS, ComDrive);
} }
/** /**
* @brief Get the LED COM drive capability. * @brief Get the LED COM drive capability.
* @param LEDx LED Instance * @param LEDx LED Instance
* @retval Returned value can be one of the following values: * @retval Returned value can be one of the following values:
* @arg @ref LL_LED_COMDRIVE_LOW * @arg @ref LL_LED_COMDRIVE_LOW
* @arg @ref LL_LED_COMDRIVE_HIGH * @arg @ref LL_LED_COMDRIVE_HIGH
*/ */
__STATIC_INLINE uint32_t LL_LED_GetComDrive(LED_TypeDef *LEDx) __STATIC_INLINE uint32_t LL_LED_GetComDrive(LED_TypeDef *LEDx)
{ {
return (READ_BIT(LEDx->CR, LED_CR_EHS)); return (READ_BIT(LEDx->CR, LED_CR_EHS));
} }
/** /**
* @brief Enable LED Interrupt. * @brief Enable LED Interrupt.
* @param LEDx LED Instance * @param LEDx LED Instance
* @retval None * @retval None
*/ */
__STATIC_INLINE void LL_LED_EnableIT(LED_TypeDef *LEDx) __STATIC_INLINE void LL_LED_EnableIT(LED_TypeDef *LEDx)
{ {
SET_BIT(LEDx->CR, LED_CR_IE); SET_BIT(LEDx->CR, LED_CR_IE);
} }
/** /**
* @brief Disable LED Interrupt. * @brief Disable LED Interrupt.
* @param LEDx LED Instance * @param LEDx LED Instance
* @retval None * @retval None
*/ */
__STATIC_INLINE void LL_LED_DisableIT(LED_TypeDef *LEDx) __STATIC_INLINE void LL_LED_DisableIT(LED_TypeDef *LEDx)
{ {
CLEAR_BIT(LEDx->CR, LED_CR_IE); CLEAR_BIT(LEDx->CR, LED_CR_IE);
} }
/** /**
* @brief Check if LED Interrupt is enabled * @brief Check if LED Interrupt is enabled
* @param LEDx LED Instance * @param LEDx LED Instance
* @retval State of bit (1 or 0). * @retval State of bit (1 or 0).
*/ */
__STATIC_INLINE uint32_t LL_LED_IsEnabledIT(LED_TypeDef *LEDx) __STATIC_INLINE uint32_t LL_LED_IsEnabledIT(LED_TypeDef *LEDx)
{ {
return ((READ_BIT(LEDx->CR, LED_CR_IE) == (LED_CR_IE)) ? 1UL : 0UL); return ((READ_BIT(LEDx->CR, LED_CR_IE) == (LED_CR_IE)) ? 1UL : 0UL);
} }
/** /**
* @brief Set he number of COM open. * @brief Set he number of COM open.
* @param LEDx LED Instance * @param LEDx LED Instance
* @param ComNum This parameter can be one of the following values: * @param ComNum This parameter can be one of the following values:
* @arg @ref LL_LED_COMSELECT_1COM * @arg @ref LL_LED_COMSELECT_1COM
* @arg @ref LL_LED_COMSELECT_2COM * @arg @ref LL_LED_COMSELECT_2COM
* @arg @ref LL_LED_COMSELECT_3COM * @arg @ref LL_LED_COMSELECT_3COM
* @arg @ref LL_LED_COMSELECT_4COM * @arg @ref LL_LED_COMSELECT_4COM
* @retval None * @retval None
*/ */
__STATIC_INLINE void LL_LED_SetComNum(LED_TypeDef *LEDx, uint32_t ComNum) __STATIC_INLINE void LL_LED_SetComNum(LED_TypeDef *LEDx, uint32_t ComNum)
{ {
MODIFY_REG(LEDx->CR, LED_CR_LED_COM_SEL, ComNum); MODIFY_REG(LEDx->CR, LED_CR_LED_COM_SEL, ComNum);
} }
/** /**
* @brief Get the number of COM open. * @brief Get the number of COM open.
* @param LEDx LED Instance * @param LEDx LED Instance
* @retval Returned value can be one of the following values: * @retval Returned value can be one of the following values:
* @arg @ref LL_LED_COMSELECT_1COM * @arg @ref LL_LED_COMSELECT_1COM
* @arg @ref LL_LED_COMSELECT_2COM * @arg @ref LL_LED_COMSELECT_2COM
* @arg @ref LL_LED_COMSELECT_3COM * @arg @ref LL_LED_COMSELECT_3COM
* @arg @ref LL_LED_COMSELECT_4COM * @arg @ref LL_LED_COMSELECT_4COM
*/ */
__STATIC_INLINE uint32_t LL_LED_GetComNum(LED_TypeDef *LEDx) __STATIC_INLINE uint32_t LL_LED_GetComNum(LED_TypeDef *LEDx)
{ {
return (READ_BIT(LEDx->CR, LED_CR_LED_COM_SEL)); return (READ_BIT(LEDx->CR, LED_CR_LED_COM_SEL));
} }
/** /**
* @brief Enable LED. * @brief Enable LED.
* @param LEDx LED Instance * @param LEDx LED Instance
* @retval None * @retval None
*/ */
__STATIC_INLINE void LL_LED_Enable(LED_TypeDef *LEDx) __STATIC_INLINE void LL_LED_Enable(LED_TypeDef *LEDx)
{ {
SET_BIT(LEDx->CR, LED_CR_LEDON); SET_BIT(LEDx->CR, LED_CR_LEDON);
} }
/** /**
* @brief Disable LED. * @brief Disable LED.
* @param LEDx LED Instance * @param LEDx LED Instance
* @retval None * @retval None
*/ */
__STATIC_INLINE void LL_LED_Disable(LED_TypeDef *LEDx) __STATIC_INLINE void LL_LED_Disable(LED_TypeDef *LEDx)
{ {
CLEAR_BIT(LEDx->CR, LED_CR_LEDON); CLEAR_BIT(LEDx->CR, LED_CR_LEDON);
} }
/** /**
* @brief Checks if LED is enabled * @brief Checks if LED is enabled
* @param LEDx LED Instance * @param LEDx LED Instance
* @retval State of bit (1 or 0). * @retval State of bit (1 or 0).
*/ */
__STATIC_INLINE uint32_t LL_LED_IsEnabled(LED_TypeDef *LEDx) __STATIC_INLINE uint32_t LL_LED_IsEnabled(LED_TypeDef *LEDx)
{ {
return ((READ_BIT(LEDx->CR, LED_CR_LEDON) == (LED_CR_LEDON)) ? 1UL : 0UL); return ((READ_BIT(LEDx->CR, LED_CR_LEDON) == (LED_CR_LEDON)) ? 1UL : 0UL);
} }
/** /**
* @brief Set the LED prescale Value. * @brief Set the LED prescale Value.
* @param LEDx LED Instance * @param LEDx LED Instance
* @param Prescaler This parameter can be a number between Min_Data = 0x00(div1) * @param Prescaler This parameter can be a number between Min_Data = 0x00(div1)
* and Max_Data = 0xFF(div256) * and Max_Data = 0xFF(div256)
* @retval None * @retval None
*/ */
__STATIC_INLINE void LL_LED_SetPrescaler(LED_TypeDef *LEDx, uint32_t Prescaler) __STATIC_INLINE void LL_LED_SetPrescaler(LED_TypeDef *LEDx, uint32_t Prescaler)
{ {
MODIFY_REG(LEDx->PR, LED_PR_PR, (Prescaler << LED_PR_PR_Pos)); MODIFY_REG(LEDx->PR, LED_PR_PR, (Prescaler << LED_PR_PR_Pos));
} }
/** /**
* @brief Return LED Prescaler Value. * @brief Return LED Prescaler Value.
* @param LEDx LED Instance * @param LEDx LED Instance
* @retval Returned value can be a number between Min_Data = 0x00(div1) * @retval Returned value can be a number between Min_Data = 0x00(div1)
* and Max_Data = 0xFF(div256) * and Max_Data = 0xFF(div256)
*/ */
__STATIC_INLINE uint32_t LL_LED_GetPrescaler(LED_TypeDef *LEDx) __STATIC_INLINE uint32_t LL_LED_GetPrescaler(LED_TypeDef *LEDx)
{ {
return (READ_BIT(LEDx->PR, LED_PR_PR) >> LED_PR_PR_Pos); return (READ_BIT(LEDx->PR, LED_PR_PR) >> LED_PR_PR_Pos);
} }
/** /**
* @brief Set the LED Lighting and Dead time. * @brief Set the LED Lighting and Dead time.
* @param LEDx LED Instance * @param LEDx LED Instance
* @param LightTime This parameter can be a number between Min_Data = 1 and * @param LightTime This parameter can be a number between Min_Data = 1 and
* Max_Data = 0xFF * Max_Data = 0xFF
* @param DeadTime This parameter can be a number between Min_Data = 1 and * @param DeadTime This parameter can be a number between Min_Data = 1 and
* Max_Data = 0xFF * Max_Data = 0xFF
* @retval None * @retval None
*/ */
__STATIC_INLINE void LL_LED_SetLightAndDeadTime(LED_TypeDef *LEDx,\ __STATIC_INLINE void LL_LED_SetLightAndDeadTime(LED_TypeDef *LEDx,\
uint32_t LightTime, uint32_t DeadTime) uint32_t LightTime, uint32_t DeadTime)
{ {
MODIFY_REG(LEDx->TR, (LED_TR_T1 | LED_TR_T2), ((LightTime << LED_TR_T1_Pos) |\ MODIFY_REG(LEDx->TR, (LED_TR_T1 | LED_TR_T2), ((LightTime << LED_TR_T1_Pos) |\
(DeadTime << LED_TR_T2_Pos))); (DeadTime << LED_TR_T2_Pos)));
} }
/** /**
* @brief Set the LED Lighting time. * @brief Set the LED Lighting time.
* @param LEDx LED Instance * @param LEDx LED Instance
* @param LightTime This parameter can be a number between Min_Data = 1 and * @param LightTime This parameter can be a number between Min_Data = 1 and
* Max_Data = 0xFF * Max_Data = 0xFF
* @retval None * @retval None
*/ */
__STATIC_INLINE void LL_LED_SetLightTime(LED_TypeDef *LEDx, uint32_t LightTime) __STATIC_INLINE void LL_LED_SetLightTime(LED_TypeDef *LEDx, uint32_t LightTime)
{ {
MODIFY_REG(LEDx->TR, LED_TR_T1, (LightTime << LED_TR_T1_Pos)); MODIFY_REG(LEDx->TR, LED_TR_T1, (LightTime << LED_TR_T1_Pos));
} }
/** /**
* @brief Set the LED Dead time. * @brief Set the LED Dead time.
* @param LEDx LED Instance * @param LEDx LED Instance
* @param DeadTime This parameter can be a number between Min_Data = 1 and * @param DeadTime This parameter can be a number between Min_Data = 1 and
* Max_Data = 0xFF * Max_Data = 0xFF
* @retval None * @retval None
*/ */
__STATIC_INLINE void LL_LED_SetDeadTime(LED_TypeDef *LEDx, uint32_t DeadTime) __STATIC_INLINE void LL_LED_SetDeadTime(LED_TypeDef *LEDx, uint32_t DeadTime)
{ {
MODIFY_REG(LEDx->TR, LED_TR_T2, (DeadTime << LED_TR_T2_Pos)); MODIFY_REG(LEDx->TR, LED_TR_T2, (DeadTime << LED_TR_T2_Pos));
} }
/** /**
* @brief Get the LED Lighting time. * @brief Get the LED Lighting time.
* @param LEDx LED Instance * @param LEDx LED Instance
* @retval Returned value can be a number between Min_Data = 1 and * @retval Returned value can be a number between Min_Data = 1 and
* Max_Data = 0xFF * Max_Data = 0xFF
*/ */
__STATIC_INLINE uint32_t LL_LED_GetLightTime(LED_TypeDef *LEDx) __STATIC_INLINE uint32_t LL_LED_GetLightTime(LED_TypeDef *LEDx)
{ {
return (READ_BIT(LEDx->TR, LED_TR_T1) >> LED_TR_T1_Pos); return (READ_BIT(LEDx->TR, LED_TR_T1) >> LED_TR_T1_Pos);
} }
/** /**
* @brief Get the LED Dead time. * @brief Get the LED Dead time.
* @param LEDx LED Instance * @param LEDx LED Instance
* @retval Returned value can be a number between Min_Data = 1 and * @retval Returned value can be a number between Min_Data = 1 and
* Max_Data = 0xFF * Max_Data = 0xFF
*/ */
__STATIC_INLINE uint32_t LL_LED_GetDeadTime(LED_TypeDef *LEDx) __STATIC_INLINE uint32_t LL_LED_GetDeadTime(LED_TypeDef *LEDx)
{ {
return (READ_BIT(LEDx->TR, LED_TR_T2) >> LED_TR_T2_Pos); return (READ_BIT(LEDx->TR, LED_TR_T2) >> LED_TR_T2_Pos);
} }
/** /**
* @brief Set the LED display value. * @brief Set the LED display value.
* @param LEDx LED Instance * @param LEDx LED Instance
* @param comCh Specify COM channels.This parameter can be one of the following values: * @param comCh Specify COM channels.This parameter can be one of the following values:
* @arg @ref LL_LED_COM0 * @arg @ref LL_LED_COM0
* @arg @ref LL_LED_COM1 * @arg @ref LL_LED_COM1
* @arg @ref LL_LED_COM2 * @arg @ref LL_LED_COM2
* @arg @ref LL_LED_COM3 * @arg @ref LL_LED_COM3
* @param data Specify display values.This parameter can be one of the following values: * @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_NONE
* @arg @ref LL_LED_DISP_FULL * @arg @ref LL_LED_DISP_FULL
* @arg @ref LL_LED_DISP_0 * @arg @ref LL_LED_DISP_0
* @arg @ref LL_LED_DISP_1 * @arg @ref LL_LED_DISP_1
* @arg @ref LL_LED_DISP_2 * @arg @ref LL_LED_DISP_2
* @arg @ref LL_LED_DISP_3 * @arg @ref LL_LED_DISP_3
* @arg @ref LL_LED_DISP_4 * @arg @ref LL_LED_DISP_4
* @arg @ref LL_LED_DISP_5 * @arg @ref LL_LED_DISP_5
* @arg @ref LL_LED_DISP_6 * @arg @ref LL_LED_DISP_6
* @arg @ref LL_LED_DISP_7 * @arg @ref LL_LED_DISP_7
* @arg @ref LL_LED_DISP_8 * @arg @ref LL_LED_DISP_8
* @arg @ref LL_LED_DISP_9 * @arg @ref LL_LED_DISP_9
* @arg @ref LL_LED_DISP_A * @arg @ref LL_LED_DISP_A
* @arg @ref LL_LED_DISP_B * @arg @ref LL_LED_DISP_B
* @arg @ref LL_LED_DISP_C * @arg @ref LL_LED_DISP_C
* @arg @ref LL_LED_DISP_D * @arg @ref LL_LED_DISP_D
* @arg @ref LL_LED_DISP_E * @arg @ref LL_LED_DISP_E
* @arg @ref LL_LED_DISP_F * @arg @ref LL_LED_DISP_F
* @arg @ref LL_LED_DISP_H * @arg @ref LL_LED_DISP_H
* @arg @ref LL_LED_DISP_P * @arg @ref LL_LED_DISP_P
* @arg @ref LL_LED_DISP_U * @arg @ref LL_LED_DISP_U
* @arg @ref LL_LED_DISP_DOT * @arg @ref LL_LED_DISP_DOT
* @retval None * @retval None
*/ */
__STATIC_INLINE void LL_LED_SetDisplayValue(LED_TypeDef *LEDx,uint32_t comCh,\ __STATIC_INLINE void LL_LED_SetDisplayValue(LED_TypeDef *LEDx,uint32_t comCh,\
uint32_t data) uint32_t data)
{ {
MODIFY_REG((*((uint32_t *)((uint32_t)&(LEDx->DR0) + comCh))), LL_LED_DR_DATA,\ MODIFY_REG((*((uint32_t *)((uint32_t)&(LEDx->DR0) + comCh))), LL_LED_DR_DATA,\
(data << LL_LED_DR_DATA_Pos)); (data << LL_LED_DR_DATA_Pos));
} }
/** /**
* @brief Get the LED display value. * @brief Get the LED display value.
* @param LEDx LED Instance * @param LEDx LED Instance
* @param comCh Specify COM channels.This parameter can be one of the following values: * @param comCh Specify COM channels.This parameter can be one of the following values:
* @arg @ref LL_LED_COM0 * @arg @ref LL_LED_COM0
* @arg @ref LL_LED_COM1 * @arg @ref LL_LED_COM1
* @arg @ref LL_LED_COM2 * @arg @ref LL_LED_COM2
* @arg @ref LL_LED_COM3 * @arg @ref LL_LED_COM3
* @retval Returned value can be one of the following values: * @retval Returned value can be one of the following values:
* @arg @ref LL_LED_DISP_NONE * @arg @ref LL_LED_DISP_NONE
* @arg @ref LL_LED_DISP_FULL * @arg @ref LL_LED_DISP_FULL
* @arg @ref LL_LED_DISP_0 * @arg @ref LL_LED_DISP_0
* @arg @ref LL_LED_DISP_1 * @arg @ref LL_LED_DISP_1
* @arg @ref LL_LED_DISP_2 * @arg @ref LL_LED_DISP_2
* @arg @ref LL_LED_DISP_3 * @arg @ref LL_LED_DISP_3
* @arg @ref LL_LED_DISP_4 * @arg @ref LL_LED_DISP_4
* @arg @ref LL_LED_DISP_5 * @arg @ref LL_LED_DISP_5
* @arg @ref LL_LED_DISP_6 * @arg @ref LL_LED_DISP_6
* @arg @ref LL_LED_DISP_7 * @arg @ref LL_LED_DISP_7
* @arg @ref LL_LED_DISP_8 * @arg @ref LL_LED_DISP_8
* @arg @ref LL_LED_DISP_9 * @arg @ref LL_LED_DISP_9
* @arg @ref LL_LED_DISP_A * @arg @ref LL_LED_DISP_A
* @arg @ref LL_LED_DISP_B * @arg @ref LL_LED_DISP_B
* @arg @ref LL_LED_DISP_C * @arg @ref LL_LED_DISP_C
* @arg @ref LL_LED_DISP_D * @arg @ref LL_LED_DISP_D
* @arg @ref LL_LED_DISP_E * @arg @ref LL_LED_DISP_E
* @arg @ref LL_LED_DISP_F * @arg @ref LL_LED_DISP_F
* @arg @ref LL_LED_DISP_H * @arg @ref LL_LED_DISP_H
* @arg @ref LL_LED_DISP_P * @arg @ref LL_LED_DISP_P
* @arg @ref LL_LED_DISP_U * @arg @ref LL_LED_DISP_U
* @arg @ref LL_LED_DISP_DOT * @arg @ref LL_LED_DISP_DOT
*/ */
__STATIC_INLINE uint32_t LL_LED_GetDisplayValue(LED_TypeDef *LEDx, uint32_t comCh) __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))\ return ((READ_BIT((*((uint32_t *)((uint32_t)&(LEDx->DR0) + comCh))), LL_LED_DR_DATA))\
>> LL_LED_DR_DATA_Pos); >> LL_LED_DR_DATA_Pos);
} }
/** /**
* @brief Get the LED interrupt flag. * @brief Get the LED interrupt flag.
* @param LEDx LED Instance * @param LEDx LED Instance
* @retval State of bit (1 or 0). * @retval State of bit (1 or 0).
*/ */
__STATIC_INLINE uint32_t LL_LED_IsActiveFlag_IT(LED_TypeDef *LEDx) __STATIC_INLINE uint32_t LL_LED_IsActiveFlag_IT(LED_TypeDef *LEDx)
{ {
return ((READ_BIT(LEDx->IR, LED_IR_FLAG) == (LED_IR_FLAG)) ? 1UL : 0UL); return ((READ_BIT(LEDx->IR, LED_IR_FLAG) == (LED_IR_FLAG)) ? 1UL : 0UL);
} }
/** /**
* @brief the LED interrupt flag. * @brief the LED interrupt flag.
* @param LEDx LED Instance * @param LEDx LED Instance
* @retval None * @retval None
*/ */
__STATIC_INLINE void LL_LED_ClearFlag_IT(LED_TypeDef *LEDx) __STATIC_INLINE void LL_LED_ClearFlag_IT(LED_TypeDef *LEDx)
{ {
SET_BIT(LEDx->IR, LED_IR_FLAG); SET_BIT(LEDx->IR, LED_IR_FLAG);
} }
/** /**
* @} * @}
*/ */
#if defined(USE_FULL_LL_DRIVER) #if defined(USE_FULL_LL_DRIVER)
/** @defgroup LED_LL_EF_Init Initialization and de-initialization functions /** @defgroup LED_LL_EF_Init Initialization and de-initialization functions
* @{ * @{
*/ */
ErrorStatus LL_LED_DeInit(LED_TypeDef *LEDx); ErrorStatus LL_LED_DeInit(LED_TypeDef *LEDx);
ErrorStatus LL_LED_Init(LED_TypeDef *LEDx, LL_LED_InitTypeDef *LED_InitStruct); ErrorStatus LL_LED_Init(LED_TypeDef *LEDx, LL_LED_InitTypeDef *LED_InitStruct);
void LL_LED_StructInit(LL_LED_InitTypeDef *LED_InitStruct); void LL_LED_StructInit(LL_LED_InitTypeDef *LED_InitStruct);
/** /**
* @} * @}
*/ */
#endif /* USE_FULL_LL_DRIVER */ #endif /* USE_FULL_LL_DRIVER */
/** /**
* @} * @}
*/ */
#endif /* LED */ #endif /* LED */
/** /**
* @} * @}
*/ */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* PY32F0xx_LL_LED_H */ #endif /* PY32F0xx_LL_LED_H */
/************************ (C) COPYRIGHT Puya *****END OF FILE****/ /************************ (C) COPYRIGHT Puya *****END OF FILE****/

View File

@ -4,18 +4,18 @@
* @author MCU Application Team * @author MCU Application Team
* @brief Header file of LPTIM LL module. * @brief Header file of LPTIM LL module.
****************************************************************************** ******************************************************************************
* @attention * @attention
* *
* <h2><center>&copy; Copyright (c) Puya Semiconductor Co. * <h2><center>&copy; Copyright (c) Puya Semiconductor Co.
* All rights reserved.</center></h2> * All rights reserved.</center></h2>
* *
* <h2><center>&copy; Copyright (c) 2016 STMicroelectronics. * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
* All rights reserved.</center></h2> * All rights reserved.</center></h2>
* *
* This software component is licensed by ST under BSD 3-Clause license, * 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 * the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at: * License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause * opensource.org/licenses/BSD-3-Clause
* *
****************************************************************************** ******************************************************************************
*/ */

View File

@ -16,18 +16,18 @@
@endverbatim @endverbatim
****************************************************************************** ******************************************************************************
* @attention * @attention
* *
* <h2><center>&copy; Copyright (c) Puya Semiconductor Co. * <h2><center>&copy; Copyright (c) Puya Semiconductor Co.
* All rights reserved.</center></h2> * All rights reserved.</center></h2>
* *
* <h2><center>&copy; Copyright (c) 2016 STMicroelectronics. * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
* All rights reserved.</center></h2> * All rights reserved.</center></h2>
* *
* This software component is licensed by ST under BSD 3-Clause license, * 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 * the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at: * License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause * opensource.org/licenses/BSD-3-Clause
* *
****************************************************************************** ******************************************************************************
*/ */

View File

@ -1,321 +1,321 @@
/** /**
****************************************************************************** ******************************************************************************
* @file py32f0xx_ll_wwdg.h * @file py32f0xx_ll_wwdg.h
* @author MCU Application Team * @author MCU Application Team
* @brief Header file of WWDG LL module. * @brief Header file of WWDG LL module.
****************************************************************************** ******************************************************************************
* @attention * @attention
* *
* <h2><center>&copy; Copyright (c) Puya Semiconductor Co. * <h2><center>&copy; Copyright (c) Puya Semiconductor Co.
* All rights reserved.</center></h2> * All rights reserved.</center></h2>
* *
* <h2><center>&copy; Copyright (c) 2016 STMicroelectronics. * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
* All rights reserved.</center></h2> * All rights reserved.</center></h2>
* *
* This software component is licensed by ST under BSD 3-Clause license, * 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 * the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at: * License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause * opensource.org/licenses/BSD-3-Clause
* *
****************************************************************************** ******************************************************************************
*/ */
/* Define to prevent recursive inclusion -------------------------------------*/ /* Define to prevent recursive inclusion -------------------------------------*/
#ifndef PY32F0XX_LL_WWDG_H #ifndef PY32F0XX_LL_WWDG_H
#define PY32F0XX_LL_WWDG_H #define PY32F0XX_LL_WWDG_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/* Includes ------------------------------------------------------------------*/ /* Includes ------------------------------------------------------------------*/
#include "py32f0xx.h" #include "py32f0xx.h"
/** @addtogroup PY32F0XX_LL_Driver /** @addtogroup PY32F0XX_LL_Driver
* @{ * @{
*/ */
#if defined (WWDG) #if defined (WWDG)
/** @defgroup WWDG_LL WWDG /** @defgroup WWDG_LL WWDG
* @{ * @{
*/ */
/* Private types -------------------------------------------------------------*/ /* Private types -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/
/* Private constants ---------------------------------------------------------*/ /* Private constants ---------------------------------------------------------*/
/* Private macros ------------------------------------------------------------*/ /* Private macros ------------------------------------------------------------*/
/* Exported types ------------------------------------------------------------*/ /* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/
/** @defgroup WWDG_LL_Exported_Constants WWDG Exported Constants /** @defgroup WWDG_LL_Exported_Constants WWDG Exported Constants
* @{ * @{
*/ */
/** @defgroup WWDG_LL_EC_IT IT Defines /** @defgroup WWDG_LL_EC_IT IT Defines
* @brief IT defines which can be used with LL_WWDG_ReadReg and LL_WWDG_WriteReg functions * @brief IT defines which can be used with LL_WWDG_ReadReg and LL_WWDG_WriteReg functions
* @{ * @{
*/ */
#define LL_WWDG_CFR_EWI WWDG_CFR_EWI #define LL_WWDG_CFR_EWI WWDG_CFR_EWI
/** /**
* @} * @}
*/ */
/** @defgroup WWDG_LL_EC_PRESCALER PRESCALER /** @defgroup WWDG_LL_EC_PRESCALER PRESCALER
* @{ * @{
*/ */
#define LL_WWDG_PRESCALER_1 0x00000000U /*!< WWDG counter clock = (PCLK1/4096)/1 */ #define LL_WWDG_PRESCALER_1 0x00000000U /*!< WWDG counter clock = (PCLK1/4096)/1 */
#define LL_WWDG_PRESCALER_2 ( WWDG_CFR_WDGTB_0) /*!< WWDG counter clock = (PCLK1/4096)/2 */ #define LL_WWDG_PRESCALER_2 ( WWDG_CFR_WDGTB_0) /*!< WWDG counter clock = (PCLK1/4096)/2 */
#define LL_WWDG_PRESCALER_4 (WWDG_CFR_WDGTB_1 ) /*!< WWDG counter clock = (PCLK1/4096)/4 */ #define LL_WWDG_PRESCALER_4 (WWDG_CFR_WDGTB_1 ) /*!< WWDG counter clock = (PCLK1/4096)/4 */
#define LL_WWDG_PRESCALER_8 (WWDG_CFR_WDGTB_0 | WWDG_CFR_WDGTB_1) /*!< WWDG counter clock = (PCLK1/4096)/8 */ #define LL_WWDG_PRESCALER_8 (WWDG_CFR_WDGTB_0 | WWDG_CFR_WDGTB_1) /*!< WWDG counter clock = (PCLK1/4096)/8 */
/** /**
* @} * @}
*/ */
/** /**
* @} * @}
*/ */
/* Exported macro ------------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/
/** @defgroup WWDG_LL_Exported_Macros WWDG Exported Macros /** @defgroup WWDG_LL_Exported_Macros WWDG Exported Macros
* @{ * @{
*/ */
/** @defgroup WWDG_LL_EM_WRITE_READ Common Write and read registers macros /** @defgroup WWDG_LL_EM_WRITE_READ Common Write and read registers macros
* @{ * @{
*/ */
/** /**
* @brief Write a value in WWDG register * @brief Write a value in WWDG register
* @param __INSTANCE__ WWDG Instance * @param __INSTANCE__ WWDG Instance
* @param __REG__ Register to be written * @param __REG__ Register to be written
* @param __VALUE__ Value to be written in the register * @param __VALUE__ Value to be written in the register
* @retval None * @retval None
*/ */
#define LL_WWDG_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__)) #define LL_WWDG_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
/** /**
* @brief Read a value in WWDG register * @brief Read a value in WWDG register
* @param __INSTANCE__ WWDG Instance * @param __INSTANCE__ WWDG Instance
* @param __REG__ Register to be read * @param __REG__ Register to be read
* @retval Register value * @retval Register value
*/ */
#define LL_WWDG_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__) #define LL_WWDG_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
/** /**
* @} * @}
*/ */
/** /**
* @} * @}
*/ */
/* Exported functions --------------------------------------------------------*/ /* Exported functions --------------------------------------------------------*/
/** @defgroup WWDG_LL_Exported_Functions WWDG Exported Functions /** @defgroup WWDG_LL_Exported_Functions WWDG Exported Functions
* @{ * @{
*/ */
/** @defgroup WWDG_LL_EF_Configuration Configuration /** @defgroup WWDG_LL_EF_Configuration Configuration
* @{ * @{
*/ */
/** /**
* @brief Enable Window Watchdog. The watchdog is always disabled after a reset. * @brief Enable Window Watchdog. The watchdog is always disabled after a reset.
* @note It is enabled by setting the WDGA bit in the WWDG_CR register, * @note It is enabled by setting the WDGA bit in the WWDG_CR register,
* then it cannot be disabled again except by a reset. * then it cannot be disabled again except by a reset.
* This bit is set by software and only cleared by hardware after a reset. * This bit is set by software and only cleared by hardware after a reset.
* When WDGA = 1, the watchdog can generate a reset. * When WDGA = 1, the watchdog can generate a reset.
* @rmtoll CR WDGA LL_WWDG_Enable * @rmtoll CR WDGA LL_WWDG_Enable
* @param WWDGx WWDG Instance * @param WWDGx WWDG Instance
* @retval None * @retval None
*/ */
__STATIC_INLINE void LL_WWDG_Enable(WWDG_TypeDef *WWDGx) __STATIC_INLINE void LL_WWDG_Enable(WWDG_TypeDef *WWDGx)
{ {
SET_BIT(WWDGx->CR, WWDG_CR_WDGA); SET_BIT(WWDGx->CR, WWDG_CR_WDGA);
} }
/** /**
* @brief Checks if Window Watchdog is enabled * @brief Checks if Window Watchdog is enabled
* @rmtoll CR WDGA LL_WWDG_IsEnabled * @rmtoll CR WDGA LL_WWDG_IsEnabled
* @param WWDGx WWDG Instance * @param WWDGx WWDG Instance
* @retval State of bit (1 or 0). * @retval State of bit (1 or 0).
*/ */
__STATIC_INLINE uint32_t LL_WWDG_IsEnabled(WWDG_TypeDef *WWDGx) __STATIC_INLINE uint32_t LL_WWDG_IsEnabled(WWDG_TypeDef *WWDGx)
{ {
return (READ_BIT(WWDGx->CR, WWDG_CR_WDGA) == (WWDG_CR_WDGA)); return (READ_BIT(WWDGx->CR, WWDG_CR_WDGA) == (WWDG_CR_WDGA));
} }
/** /**
* @brief Set the Watchdog counter value to provided value (7-bits T[6:0]) * @brief Set the Watchdog counter value to provided value (7-bits T[6:0])
* @note When writing to the WWDG_CR register, always write 1 in the MSB b6 to avoid generating an immediate reset * @note When writing to the WWDG_CR register, always write 1 in the MSB b6 to avoid generating an immediate reset
* This counter is decremented every (4096 x 2expWDGTB) PCLK cycles * This counter is decremented every (4096 x 2expWDGTB) PCLK cycles
* A reset is produced when it rolls over from 0x40 to 0x3F (bit T6 becomes cleared) * A reset is produced when it rolls over from 0x40 to 0x3F (bit T6 becomes cleared)
* Setting the counter lower then 0x40 causes an immediate reset (if WWDG enabled) * Setting the counter lower then 0x40 causes an immediate reset (if WWDG enabled)
* @rmtoll CR T LL_WWDG_SetCounter * @rmtoll CR T LL_WWDG_SetCounter
* @param WWDGx WWDG Instance * @param WWDGx WWDG Instance
* @param Counter 0..0x7F (7 bit counter value) * @param Counter 0..0x7F (7 bit counter value)
* @retval None * @retval None
*/ */
__STATIC_INLINE void LL_WWDG_SetCounter(WWDG_TypeDef *WWDGx, uint32_t Counter) __STATIC_INLINE void LL_WWDG_SetCounter(WWDG_TypeDef *WWDGx, uint32_t Counter)
{ {
MODIFY_REG(WWDGx->CR, WWDG_CR_T, Counter); MODIFY_REG(WWDGx->CR, WWDG_CR_T, Counter);
} }
/** /**
* @brief Return current Watchdog Counter Value (7 bits counter value) * @brief Return current Watchdog Counter Value (7 bits counter value)
* @rmtoll CR T LL_WWDG_GetCounter * @rmtoll CR T LL_WWDG_GetCounter
* @param WWDGx WWDG Instance * @param WWDGx WWDG Instance
* @retval 7 bit Watchdog Counter value * @retval 7 bit Watchdog Counter value
*/ */
__STATIC_INLINE uint32_t LL_WWDG_GetCounter(WWDG_TypeDef *WWDGx) __STATIC_INLINE uint32_t LL_WWDG_GetCounter(WWDG_TypeDef *WWDGx)
{ {
return (READ_BIT(WWDGx->CR, WWDG_CR_T)); return (READ_BIT(WWDGx->CR, WWDG_CR_T));
} }
/** /**
* @brief Set the time base of the prescaler (WDGTB). * @brief Set the time base of the prescaler (WDGTB).
* @note Prescaler is used to apply ratio on PCLK clock, so that Watchdog counter * @note Prescaler is used to apply ratio on PCLK clock, so that Watchdog counter
* is decremented every (4096 x 2expWDGTB) PCLK cycles * is decremented every (4096 x 2expWDGTB) PCLK cycles
* @rmtoll CFR WDGTB LL_WWDG_SetPrescaler * @rmtoll CFR WDGTB LL_WWDG_SetPrescaler
* @param WWDGx WWDG Instance * @param WWDGx WWDG Instance
* @param Prescaler This parameter can be one of the following values: * @param Prescaler This parameter can be one of the following values:
* @arg @ref LL_WWDG_PRESCALER_1 * @arg @ref LL_WWDG_PRESCALER_1
* @arg @ref LL_WWDG_PRESCALER_2 * @arg @ref LL_WWDG_PRESCALER_2
* @arg @ref LL_WWDG_PRESCALER_4 * @arg @ref LL_WWDG_PRESCALER_4
* @arg @ref LL_WWDG_PRESCALER_8 * @arg @ref LL_WWDG_PRESCALER_8
* @retval None * @retval None
*/ */
__STATIC_INLINE void LL_WWDG_SetPrescaler(WWDG_TypeDef *WWDGx, uint32_t Prescaler) __STATIC_INLINE void LL_WWDG_SetPrescaler(WWDG_TypeDef *WWDGx, uint32_t Prescaler)
{ {
MODIFY_REG(WWDGx->CFR, WWDG_CFR_WDGTB, Prescaler); MODIFY_REG(WWDGx->CFR, WWDG_CFR_WDGTB, Prescaler);
} }
/** /**
* @brief Return current Watchdog Prescaler Value * @brief Return current Watchdog Prescaler Value
* @rmtoll CFR WDGTB LL_WWDG_GetPrescaler * @rmtoll CFR WDGTB LL_WWDG_GetPrescaler
* @param WWDGx WWDG Instance * @param WWDGx WWDG Instance
* @retval Returned value can be one of the following values: * @retval Returned value can be one of the following values:
* @arg @ref LL_WWDG_PRESCALER_1 * @arg @ref LL_WWDG_PRESCALER_1
* @arg @ref LL_WWDG_PRESCALER_2 * @arg @ref LL_WWDG_PRESCALER_2
* @arg @ref LL_WWDG_PRESCALER_4 * @arg @ref LL_WWDG_PRESCALER_4
* @arg @ref LL_WWDG_PRESCALER_8 * @arg @ref LL_WWDG_PRESCALER_8
*/ */
__STATIC_INLINE uint32_t LL_WWDG_GetPrescaler(WWDG_TypeDef *WWDGx) __STATIC_INLINE uint32_t LL_WWDG_GetPrescaler(WWDG_TypeDef *WWDGx)
{ {
return (READ_BIT(WWDGx->CFR, WWDG_CFR_WDGTB)); return (READ_BIT(WWDGx->CFR, WWDG_CFR_WDGTB));
} }
/** /**
* @brief Set the Watchdog Window value to be compared to the downcounter (7-bits W[6:0]). * @brief Set the Watchdog Window value to be compared to the downcounter (7-bits W[6:0]).
* @note This window value defines when write in the WWDG_CR register * @note This window value defines when write in the WWDG_CR register
* to program Watchdog counter is allowed. * to program Watchdog counter is allowed.
* Watchdog counter value update must occur only when the counter value * Watchdog counter value update must occur only when the counter value
* is lower than the Watchdog window register value. * is lower than the Watchdog window register value.
* Otherwise, a MCU reset is generated if the 7-bit Watchdog counter value * Otherwise, a MCU reset is generated if the 7-bit Watchdog counter value
* (in the control register) is refreshed before the downcounter has reached * (in the control register) is refreshed before the downcounter has reached
* the watchdog window register value. * the watchdog window register value.
* Physically is possible to set the Window lower then 0x40 but it is not recommended. * Physically is possible to set the Window lower then 0x40 but it is not recommended.
* To generate an immediate reset, it is possible to set the Counter lower than 0x40. * To generate an immediate reset, it is possible to set the Counter lower than 0x40.
* @rmtoll CFR W LL_WWDG_SetWindow * @rmtoll CFR W LL_WWDG_SetWindow
* @param WWDGx WWDG Instance * @param WWDGx WWDG Instance
* @param Window 0x00..0x7F (7 bit Window value) * @param Window 0x00..0x7F (7 bit Window value)
* @retval None * @retval None
*/ */
__STATIC_INLINE void LL_WWDG_SetWindow(WWDG_TypeDef *WWDGx, uint32_t Window) __STATIC_INLINE void LL_WWDG_SetWindow(WWDG_TypeDef *WWDGx, uint32_t Window)
{ {
MODIFY_REG(WWDGx->CFR, WWDG_CFR_W, Window); MODIFY_REG(WWDGx->CFR, WWDG_CFR_W, Window);
} }
/** /**
* @brief Return current Watchdog Window Value (7 bits value) * @brief Return current Watchdog Window Value (7 bits value)
* @rmtoll CFR W LL_WWDG_GetWindow * @rmtoll CFR W LL_WWDG_GetWindow
* @param WWDGx WWDG Instance * @param WWDGx WWDG Instance
* @retval 7 bit Watchdog Window value * @retval 7 bit Watchdog Window value
*/ */
__STATIC_INLINE uint32_t LL_WWDG_GetWindow(WWDG_TypeDef *WWDGx) __STATIC_INLINE uint32_t LL_WWDG_GetWindow(WWDG_TypeDef *WWDGx)
{ {
return (READ_BIT(WWDGx->CFR, WWDG_CFR_W)); return (READ_BIT(WWDGx->CFR, WWDG_CFR_W));
} }
/** /**
* @} * @}
*/ */
/** @defgroup WWDG_LL_EF_FLAG_Management FLAG_Management /** @defgroup WWDG_LL_EF_FLAG_Management FLAG_Management
* @{ * @{
*/ */
/** /**
* @brief Indicates if the WWDG Early Wakeup Interrupt Flag is set or not. * @brief Indicates if the WWDG Early Wakeup Interrupt Flag is set or not.
* @note This bit is set by hardware when the counter has reached the value 0x40. * @note This bit is set by hardware when the counter has reached the value 0x40.
* It must be cleared by software by writing 0. * It must be cleared by software by writing 0.
* A write of 1 has no effect. This bit is also set if the interrupt is not enabled. * A write of 1 has no effect. This bit is also set if the interrupt is not enabled.
* @rmtoll SR EWIF LL_WWDG_IsActiveFlag_EWKUP * @rmtoll SR EWIF LL_WWDG_IsActiveFlag_EWKUP
* @param WWDGx WWDG Instance * @param WWDGx WWDG Instance
* @retval State of bit (1 or 0). * @retval State of bit (1 or 0).
*/ */
__STATIC_INLINE uint32_t LL_WWDG_IsActiveFlag_EWKUP(WWDG_TypeDef *WWDGx) __STATIC_INLINE uint32_t LL_WWDG_IsActiveFlag_EWKUP(WWDG_TypeDef *WWDGx)
{ {
return (READ_BIT(WWDGx->SR, WWDG_SR_EWIF) == (WWDG_SR_EWIF)); return (READ_BIT(WWDGx->SR, WWDG_SR_EWIF) == (WWDG_SR_EWIF));
} }
/** /**
* @brief Clear WWDG Early Wakeup Interrupt Flag (EWIF) * @brief Clear WWDG Early Wakeup Interrupt Flag (EWIF)
* @rmtoll SR EWIF LL_WWDG_ClearFlag_EWKUP * @rmtoll SR EWIF LL_WWDG_ClearFlag_EWKUP
* @param WWDGx WWDG Instance * @param WWDGx WWDG Instance
* @retval None * @retval None
*/ */
__STATIC_INLINE void LL_WWDG_ClearFlag_EWKUP(WWDG_TypeDef *WWDGx) __STATIC_INLINE void LL_WWDG_ClearFlag_EWKUP(WWDG_TypeDef *WWDGx)
{ {
WRITE_REG(WWDGx->SR, ~WWDG_SR_EWIF); WRITE_REG(WWDGx->SR, ~WWDG_SR_EWIF);
} }
/** /**
* @} * @}
*/ */
/** @defgroup WWDG_LL_EF_IT_Management IT_Management /** @defgroup WWDG_LL_EF_IT_Management IT_Management
* @{ * @{
*/ */
/** /**
* @brief Enable the Early Wakeup Interrupt. * @brief Enable the Early Wakeup Interrupt.
* @note When set, an interrupt occurs whenever the counter reaches value 0x40. * @note When set, an interrupt occurs whenever the counter reaches value 0x40.
* This interrupt is only cleared by hardware after a reset * This interrupt is only cleared by hardware after a reset
* @rmtoll CFR EWI LL_WWDG_EnableIT_EWKUP * @rmtoll CFR EWI LL_WWDG_EnableIT_EWKUP
* @param WWDGx WWDG Instance * @param WWDGx WWDG Instance
* @retval None * @retval None
*/ */
__STATIC_INLINE void LL_WWDG_EnableIT_EWKUP(WWDG_TypeDef *WWDGx) __STATIC_INLINE void LL_WWDG_EnableIT_EWKUP(WWDG_TypeDef *WWDGx)
{ {
SET_BIT(WWDGx->CFR, WWDG_CFR_EWI); SET_BIT(WWDGx->CFR, WWDG_CFR_EWI);
} }
/** /**
* @brief Check if Early Wakeup Interrupt is enabled * @brief Check if Early Wakeup Interrupt is enabled
* @rmtoll CFR EWI LL_WWDG_IsEnabledIT_EWKUP * @rmtoll CFR EWI LL_WWDG_IsEnabledIT_EWKUP
* @param WWDGx WWDG Instance * @param WWDGx WWDG Instance
* @retval State of bit (1 or 0). * @retval State of bit (1 or 0).
*/ */
__STATIC_INLINE uint32_t LL_WWDG_IsEnabledIT_EWKUP(WWDG_TypeDef *WWDGx) __STATIC_INLINE uint32_t LL_WWDG_IsEnabledIT_EWKUP(WWDG_TypeDef *WWDGx)
{ {
return (READ_BIT(WWDGx->CFR, WWDG_CFR_EWI) == (WWDG_CFR_EWI)); return (READ_BIT(WWDGx->CFR, WWDG_CFR_EWI) == (WWDG_CFR_EWI));
} }
/** /**
* @} * @}
*/ */
/** /**
* @} * @}
*/ */
/** /**
* @} * @}
*/ */
#endif /* WWDG */ #endif /* WWDG */
/** /**
* @} * @}
*/ */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* PY32F0XX_LL_WWDG_H */ #endif /* PY32F0XX_LL_WWDG_H */
/************************ (C) COPYRIGHT Puya *****END OF FILE****/ /************************ (C) COPYRIGHT Puya *****END OF FILE****/

View File

@ -3,21 +3,21 @@
* @file py32f0xx_ll_comp.c * @file py32f0xx_ll_comp.c
* @author MCU Application Team * @author MCU Application Team
* @brief COMP LL module driver. * @brief COMP LL module driver.
****************************************************************************** ******************************************************************************
* @attention * @attention
* *
* <h2><center>&copy; Copyright (c) Puya Semiconductor Co. * <h2><center>&copy; Copyright (c) Puya Semiconductor Co.
* All rights reserved.</center></h2> * All rights reserved.</center></h2>
* *
* <h2><center>&copy; Copyright (c) 2016 STMicroelectronics. * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
* All rights reserved.</center></h2> * All rights reserved.</center></h2>
* *
* This software component is licensed by ST under BSD 3-Clause license, * 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 * the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at: * License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause * opensource.org/licenses/BSD-3-Clause
* *
****************************************************************************** ******************************************************************************
*/ */
#if defined(USE_FULL_LL_DRIVER) #if defined(USE_FULL_LL_DRIVER)

View File

@ -1,111 +1,111 @@
/** /**
****************************************************************************** ******************************************************************************
* @file py32f0xx_ll_crc.c * @file py32f0xx_ll_crc.c
* @author MCU Application Team * @author MCU Application Team
* @brief CRC LL module driver. * @brief CRC LL module driver.
****************************************************************************** ******************************************************************************
* @attention * @attention
* *
* <h2><center>&copy; Copyright (c) Puya Semiconductor Co. * <h2><center>&copy; Copyright (c) Puya Semiconductor Co.
* All rights reserved.</center></h2> * All rights reserved.</center></h2>
* *
* <h2><center>&copy; Copyright (c) 2016 STMicroelectronics. * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
* All rights reserved.</center></h2> * All rights reserved.</center></h2>
* *
* This software component is licensed by ST under BSD 3-Clause license, * 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 * the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at: * License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause * opensource.org/licenses/BSD-3-Clause
* *
****************************************************************************** ******************************************************************************
*/ */
#if defined(USE_FULL_LL_DRIVER) #if defined(USE_FULL_LL_DRIVER)
/* Includes ------------------------------------------------------------------*/ /* Includes ------------------------------------------------------------------*/
#include "py32f0xx_ll_crc.h" #include "py32f0xx_ll_crc.h"
#include "py32f0xx_ll_bus.h" #include "py32f0xx_ll_bus.h"
#ifdef USE_FULL_ASSERT #ifdef USE_FULL_ASSERT
#include "py32_assert.h" #include "py32_assert.h"
#else #else
#define assert_param(expr) ((void)0U) #define assert_param(expr) ((void)0U)
#endif #endif
/** @addtogroup PY32F0xx_LL_Driver /** @addtogroup PY32F0xx_LL_Driver
* @{ * @{
*/ */
#if defined (CRC) #if defined (CRC)
/** @addtogroup CRC_LL /** @addtogroup CRC_LL
* @{ * @{
*/ */
/* Private types -------------------------------------------------------------*/ /* Private types -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/
/* Private constants ---------------------------------------------------------*/ /* Private constants ---------------------------------------------------------*/
/* Private macros ------------------------------------------------------------*/ /* Private macros ------------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/
/* Exported functions --------------------------------------------------------*/ /* Exported functions --------------------------------------------------------*/
/** @addtogroup CRC_LL_Exported_Functions /** @addtogroup CRC_LL_Exported_Functions
* @{ * @{
*/ */
/** @addtogroup CRC_LL_EF_Init /** @addtogroup CRC_LL_EF_Init
* @{ * @{
*/ */
/** /**
* @brief De-initialize CRC registers (Registers restored to their default values). * @brief De-initialize CRC registers (Registers restored to their default values).
* @param CRCx CRC Instance * @param CRCx CRC Instance
* @retval An ErrorStatus enumeration value: * @retval An ErrorStatus enumeration value:
* - SUCCESS: CRC registers are de-initialized * - SUCCESS: CRC registers are de-initialized
* - ERROR: CRC registers are not de-initialized * - ERROR: CRC registers are not de-initialized
*/ */
ErrorStatus LL_CRC_DeInit(CRC_TypeDef *CRCx) ErrorStatus LL_CRC_DeInit(CRC_TypeDef *CRCx)
{ {
ErrorStatus status = SUCCESS; ErrorStatus status = SUCCESS;
/* Check the parameters */ /* Check the parameters */
assert_param(IS_CRC_ALL_INSTANCE(CRCx)); assert_param(IS_CRC_ALL_INSTANCE(CRCx));
if (CRCx == CRC) if (CRCx == CRC)
{ {
/* Reset the CRC calculation unit */ /* Reset the CRC calculation unit */
LL_CRC_ResetCRCCalculationUnit(CRCx); LL_CRC_ResetCRCCalculationUnit(CRCx);
/* Reset IDR register */ /* Reset IDR register */
LL_CRC_Write_IDR(CRCx, 0x00U); LL_CRC_Write_IDR(CRCx, 0x00U);
} }
else else
{ {
status = ERROR; status = ERROR;
} }
return (status); return (status);
} }
/** /**
* @} * @}
*/ */
/** /**
* @} * @}
*/ */
/** /**
* @} * @}
*/ */
#endif /* defined (CRC) */ #endif /* defined (CRC) */
/** /**
* @} * @}
*/ */
#endif /* USE_FULL_LL_DRIVER */ #endif /* USE_FULL_LL_DRIVER */
/************************ (C) COPYRIGHT Puya *****END OF FILE****/ /************************ (C) COPYRIGHT Puya *****END OF FILE****/

View File

@ -1,265 +1,265 @@
/** /**
****************************************************************************** ******************************************************************************
* @file py32f0xx_ll_dma.c * @file py32f0xx_ll_dma.c
* @author MCU Application Team * @author MCU Application Team
* @brief DMA LL module driver. * @brief DMA LL module driver.
****************************************************************************** ******************************************************************************
* @attention * @attention
* *
* <h2><center>&copy; Copyright (c) Puya Semiconductor Co. * <h2><center>&copy; Copyright (c) Puya Semiconductor Co.
* All rights reserved.</center></h2> * All rights reserved.</center></h2>
* *
* <h2><center>&copy; Copyright (c) 2016 STMicroelectronics. * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
* All rights reserved.</center></h2> * All rights reserved.</center></h2>
* *
* This software component is licensed by ST under BSD 3-Clause license, * 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 * the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at: * License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause * opensource.org/licenses/BSD-3-Clause
* *
****************************************************************************** ******************************************************************************
*/ */
#if defined(USE_FULL_LL_DRIVER) #if defined(USE_FULL_LL_DRIVER)
/* Includes ------------------------------------------------------------------*/ /* Includes ------------------------------------------------------------------*/
#include "py32f0xx_ll_dma.h" #include "py32f0xx_ll_dma.h"
#ifdef USE_FULL_ASSERT #ifdef USE_FULL_ASSERT
#include "py32_assert.h" #include "py32_assert.h"
#else #else
#define assert_param(expr) ((void)0U) #define assert_param(expr) ((void)0U)
#endif #endif
/** @addtogroup PY32F0xx_LL_Driver /** @addtogroup PY32F0xx_LL_Driver
* @{ * @{
*/ */
#if defined (DMA1) #if defined (DMA1)
/** @defgroup DMA_LL DMA /** @defgroup DMA_LL DMA
* @{ * @{
*/ */
/* Private types -------------------------------------------------------------*/ /* Private types -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/
/* Private constants ---------------------------------------------------------*/ /* Private constants ---------------------------------------------------------*/
/* Private macros ------------------------------------------------------------*/ /* Private macros ------------------------------------------------------------*/
/** @addtogroup DMA_LL_Private_Macros /** @addtogroup DMA_LL_Private_Macros
* @{ * @{
*/ */
#define IS_LL_DMA_DIRECTION(__VALUE__) (((__VALUE__) == LL_DMA_DIRECTION_PERIPH_TO_MEMORY) || \ #define IS_LL_DMA_DIRECTION(__VALUE__) (((__VALUE__) == LL_DMA_DIRECTION_PERIPH_TO_MEMORY) || \
((__VALUE__) == LL_DMA_DIRECTION_MEMORY_TO_PERIPH) || \ ((__VALUE__) == LL_DMA_DIRECTION_MEMORY_TO_PERIPH) || \
((__VALUE__) == LL_DMA_DIRECTION_MEMORY_TO_MEMORY)) ((__VALUE__) == LL_DMA_DIRECTION_MEMORY_TO_MEMORY))
#define IS_LL_DMA_MODE(__VALUE__) (((__VALUE__) == LL_DMA_MODE_NORMAL) || \ #define IS_LL_DMA_MODE(__VALUE__) (((__VALUE__) == LL_DMA_MODE_NORMAL) || \
((__VALUE__) == LL_DMA_MODE_CIRCULAR)) ((__VALUE__) == LL_DMA_MODE_CIRCULAR))
#define IS_LL_DMA_PERIPHINCMODE(__VALUE__) (((__VALUE__) == LL_DMA_PERIPH_INCREMENT) || \ #define IS_LL_DMA_PERIPHINCMODE(__VALUE__) (((__VALUE__) == LL_DMA_PERIPH_INCREMENT) || \
((__VALUE__) == LL_DMA_PERIPH_NOINCREMENT)) ((__VALUE__) == LL_DMA_PERIPH_NOINCREMENT))
#define IS_LL_DMA_MEMORYINCMODE(__VALUE__) (((__VALUE__) == LL_DMA_MEMORY_INCREMENT) || \ #define IS_LL_DMA_MEMORYINCMODE(__VALUE__) (((__VALUE__) == LL_DMA_MEMORY_INCREMENT) || \
((__VALUE__) == LL_DMA_MEMORY_NOINCREMENT)) ((__VALUE__) == LL_DMA_MEMORY_NOINCREMENT))
#define IS_LL_DMA_PERIPHDATASIZE(__VALUE__) (((__VALUE__) == LL_DMA_PDATAALIGN_BYTE) || \ #define IS_LL_DMA_PERIPHDATASIZE(__VALUE__) (((__VALUE__) == LL_DMA_PDATAALIGN_BYTE) || \
((__VALUE__) == LL_DMA_PDATAALIGN_HALFWORD) || \ ((__VALUE__) == LL_DMA_PDATAALIGN_HALFWORD) || \
((__VALUE__) == LL_DMA_PDATAALIGN_WORD)) ((__VALUE__) == LL_DMA_PDATAALIGN_WORD))
#define IS_LL_DMA_MEMORYDATASIZE(__VALUE__) (((__VALUE__) == LL_DMA_MDATAALIGN_BYTE) || \ #define IS_LL_DMA_MEMORYDATASIZE(__VALUE__) (((__VALUE__) == LL_DMA_MDATAALIGN_BYTE) || \
((__VALUE__) == LL_DMA_MDATAALIGN_HALFWORD) || \ ((__VALUE__) == LL_DMA_MDATAALIGN_HALFWORD) || \
((__VALUE__) == LL_DMA_MDATAALIGN_WORD)) ((__VALUE__) == LL_DMA_MDATAALIGN_WORD))
#define IS_LL_DMA_NBDATA(__VALUE__) ((__VALUE__) <= 0x0000FFFFU) #define IS_LL_DMA_NBDATA(__VALUE__) ((__VALUE__) <= 0x0000FFFFU)
#define IS_LL_DMA_PRIORITY(__VALUE__) (((__VALUE__) == LL_DMA_PRIORITY_LOW) || \ #define IS_LL_DMA_PRIORITY(__VALUE__) (((__VALUE__) == LL_DMA_PRIORITY_LOW) || \
((__VALUE__) == LL_DMA_PRIORITY_MEDIUM) || \ ((__VALUE__) == LL_DMA_PRIORITY_MEDIUM) || \
((__VALUE__) == LL_DMA_PRIORITY_HIGH) || \ ((__VALUE__) == LL_DMA_PRIORITY_HIGH) || \
((__VALUE__) == LL_DMA_PRIORITY_VERYHIGH)) ((__VALUE__) == LL_DMA_PRIORITY_VERYHIGH))
#define IS_LL_DMA_ALL_CHANNEL_INSTANCE(INSTANCE, CHANNEL) ((((INSTANCE) == DMA1) && \ #define IS_LL_DMA_ALL_CHANNEL_INSTANCE(INSTANCE, CHANNEL) ((((INSTANCE) == DMA1) && \
(((CHANNEL) == LL_DMA_CHANNEL_1) || \ (((CHANNEL) == LL_DMA_CHANNEL_1) || \
((CHANNEL) == LL_DMA_CHANNEL_2) || \ ((CHANNEL) == LL_DMA_CHANNEL_2) || \
((CHANNEL) == LL_DMA_CHANNEL_3)))) ((CHANNEL) == LL_DMA_CHANNEL_3))))
/** /**
* @} * @}
*/ */
/* Private function prototypes -----------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/
/* Exported functions --------------------------------------------------------*/ /* Exported functions --------------------------------------------------------*/
/** @addtogroup DMA_LL_Exported_Functions /** @addtogroup DMA_LL_Exported_Functions
* @{ * @{
*/ */
/** @addtogroup DMA_LL_EF_Init /** @addtogroup DMA_LL_EF_Init
* @{ * @{
*/ */
/** /**
* @brief De-initialize the DMA registers to their default reset values. * @brief De-initialize the DMA registers to their default reset values.
* @param DMAx DMAx Instance * @param DMAx DMAx Instance
* @param Channel This parameter can be one of the following values: * @param Channel This parameter can be one of the following values:
* @arg @ref LL_DMA_CHANNEL_1 * @arg @ref LL_DMA_CHANNEL_1
* @arg @ref LL_DMA_CHANNEL_2 * @arg @ref LL_DMA_CHANNEL_2
* @arg @ref LL_DMA_CHANNEL_3 * @arg @ref LL_DMA_CHANNEL_3
* @retval An ErrorStatus enumeration value: * @retval An ErrorStatus enumeration value:
* - SUCCESS: DMA registers are de-initialized * - SUCCESS: DMA registers are de-initialized
* - ERROR: DMA registers are not de-initialized * - ERROR: DMA registers are not de-initialized
*/ */
uint32_t LL_DMA_DeInit(DMA_TypeDef *DMAx, uint32_t Channel) uint32_t LL_DMA_DeInit(DMA_TypeDef *DMAx, uint32_t Channel)
{ {
DMA_Channel_TypeDef *tmp = (DMA_Channel_TypeDef *)DMA1_Channel1; DMA_Channel_TypeDef *tmp = (DMA_Channel_TypeDef *)DMA1_Channel1;
ErrorStatus status = SUCCESS; ErrorStatus status = SUCCESS;
/* Check the DMA Instance DMAx and Channel parameters*/ /* Check the DMA Instance DMAx and Channel parameters*/
assert_param(IS_LL_DMA_ALL_CHANNEL_INSTANCE(DMAx, Channel)); assert_param(IS_LL_DMA_ALL_CHANNEL_INSTANCE(DMAx, Channel));
tmp = (DMA_Channel_TypeDef *)(__LL_DMA_GET_CHANNEL_INSTANCE(DMAx, Channel)); tmp = (DMA_Channel_TypeDef *)(__LL_DMA_GET_CHANNEL_INSTANCE(DMAx, Channel));
/* Disable the selected DMAx_Channely */ /* Disable the selected DMAx_Channely */
CLEAR_BIT(tmp->CCR, DMA_CCR_EN); CLEAR_BIT(tmp->CCR, DMA_CCR_EN);
/* Reset DMAx_Channely control register */ /* Reset DMAx_Channely control register */
LL_DMA_WriteReg(tmp, CCR, 0U); LL_DMA_WriteReg(tmp, CCR, 0U);
/* Reset DMAx_Channely remaining bytes register */ /* Reset DMAx_Channely remaining bytes register */
LL_DMA_WriteReg(tmp, CNDTR, 0U); LL_DMA_WriteReg(tmp, CNDTR, 0U);
/* Reset DMAx_Channely peripheral address register */ /* Reset DMAx_Channely peripheral address register */
LL_DMA_WriteReg(tmp, CPAR, 0U); LL_DMA_WriteReg(tmp, CPAR, 0U);
/* Reset DMAx_Channely memory address register */ /* Reset DMAx_Channely memory address register */
LL_DMA_WriteReg(tmp, CMAR, 0U); LL_DMA_WriteReg(tmp, CMAR, 0U);
if (Channel == LL_DMA_CHANNEL_1) if (Channel == LL_DMA_CHANNEL_1)
{ {
/* Reset interrupt pending bits for DMAx Channel1 */ /* Reset interrupt pending bits for DMAx Channel1 */
LL_DMA_ClearFlag_GI1(DMAx); LL_DMA_ClearFlag_GI1(DMAx);
} }
else if (Channel == LL_DMA_CHANNEL_2) else if (Channel == LL_DMA_CHANNEL_2)
{ {
/* Reset interrupt pending bits for DMAx Channel2 */ /* Reset interrupt pending bits for DMAx Channel2 */
LL_DMA_ClearFlag_GI2(DMAx); LL_DMA_ClearFlag_GI2(DMAx);
} }
else if (Channel == LL_DMA_CHANNEL_3) else if (Channel == LL_DMA_CHANNEL_3)
{ {
/* Reset interrupt pending bits for DMAx Channel3 */ /* Reset interrupt pending bits for DMAx Channel3 */
LL_DMA_ClearFlag_GI3(DMAx); LL_DMA_ClearFlag_GI3(DMAx);
} }
else else
{ {
status = ERROR; status = ERROR;
} }
return status; return status;
} }
/** /**
* @brief Initialize the DMA registers according to the specified parameters in DMA_InitStruct. * @brief Initialize the DMA registers according to the specified parameters in DMA_InitStruct.
* @note To convert DMAx_Channely Instance to DMAx Instance and Channely, use helper macros : * @note To convert DMAx_Channely Instance to DMAx Instance and Channely, use helper macros :
* @arg @ref __LL_DMA_GET_INSTANCE * @arg @ref __LL_DMA_GET_INSTANCE
* @arg @ref __LL_DMA_GET_CHANNEL * @arg @ref __LL_DMA_GET_CHANNEL
* @param DMAx DMAx Instance * @param DMAx DMAx Instance
* @param Channel This parameter can be one of the following values: * @param Channel This parameter can be one of the following values:
* @arg @ref LL_DMA_CHANNEL_1 * @arg @ref LL_DMA_CHANNEL_1
* @arg @ref LL_DMA_CHANNEL_2 * @arg @ref LL_DMA_CHANNEL_2
* @arg @ref LL_DMA_CHANNEL_3 * @arg @ref LL_DMA_CHANNEL_3
* @param DMA_InitStruct pointer to a @ref LL_DMA_InitTypeDef structure. * @param DMA_InitStruct pointer to a @ref LL_DMA_InitTypeDef structure.
* @retval An ErrorStatus enumeration value: * @retval An ErrorStatus enumeration value:
* - SUCCESS: DMA registers are initialized * - SUCCESS: DMA registers are initialized
* - ERROR: Not applicable * - ERROR: Not applicable
*/ */
uint32_t LL_DMA_Init(DMA_TypeDef *DMAx, uint32_t Channel, LL_DMA_InitTypeDef *DMA_InitStruct) uint32_t LL_DMA_Init(DMA_TypeDef *DMAx, uint32_t Channel, LL_DMA_InitTypeDef *DMA_InitStruct)
{ {
/* Check the DMA Instance DMAx and Channel parameters*/ /* Check the DMA Instance DMAx and Channel parameters*/
assert_param(IS_LL_DMA_ALL_CHANNEL_INSTANCE(DMAx, Channel)); assert_param(IS_LL_DMA_ALL_CHANNEL_INSTANCE(DMAx, Channel));
/* Check the DMA parameters from DMA_InitStruct */ /* Check the DMA parameters from DMA_InitStruct */
assert_param(IS_LL_DMA_DIRECTION(DMA_InitStruct->Direction)); assert_param(IS_LL_DMA_DIRECTION(DMA_InitStruct->Direction));
assert_param(IS_LL_DMA_MODE(DMA_InitStruct->Mode)); assert_param(IS_LL_DMA_MODE(DMA_InitStruct->Mode));
assert_param(IS_LL_DMA_PERIPHINCMODE(DMA_InitStruct->PeriphOrM2MSrcIncMode)); assert_param(IS_LL_DMA_PERIPHINCMODE(DMA_InitStruct->PeriphOrM2MSrcIncMode));
assert_param(IS_LL_DMA_MEMORYINCMODE(DMA_InitStruct->MemoryOrM2MDstIncMode)); assert_param(IS_LL_DMA_MEMORYINCMODE(DMA_InitStruct->MemoryOrM2MDstIncMode));
assert_param(IS_LL_DMA_PERIPHDATASIZE(DMA_InitStruct->PeriphOrM2MSrcDataSize)); assert_param(IS_LL_DMA_PERIPHDATASIZE(DMA_InitStruct->PeriphOrM2MSrcDataSize));
assert_param(IS_LL_DMA_MEMORYDATASIZE(DMA_InitStruct->MemoryOrM2MDstDataSize)); assert_param(IS_LL_DMA_MEMORYDATASIZE(DMA_InitStruct->MemoryOrM2MDstDataSize));
assert_param(IS_LL_DMA_NBDATA(DMA_InitStruct->NbData)); assert_param(IS_LL_DMA_NBDATA(DMA_InitStruct->NbData));
assert_param(IS_LL_DMA_PRIORITY(DMA_InitStruct->Priority)); assert_param(IS_LL_DMA_PRIORITY(DMA_InitStruct->Priority));
/*---------------------------- DMAx CCR Configuration ------------------------ /*---------------------------- DMAx CCR Configuration ------------------------
* Configure DMAx_Channely: data transfer direction, data transfer mode, * Configure DMAx_Channely: data transfer direction, data transfer mode,
* peripheral and memory increment mode, * peripheral and memory increment mode,
* data size alignment and priority level with parameters : * data size alignment and priority level with parameters :
* - Direction: DMA_CCR_DIR and DMA_CCR_MEM2MEM bits * - Direction: DMA_CCR_DIR and DMA_CCR_MEM2MEM bits
* - Mode: DMA_CCR_CIRC bit * - Mode: DMA_CCR_CIRC bit
* - PeriphOrM2MSrcIncMode: DMA_CCR_PINC bit * - PeriphOrM2MSrcIncMode: DMA_CCR_PINC bit
* - MemoryOrM2MDstIncMode: DMA_CCR_MINC bit * - MemoryOrM2MDstIncMode: DMA_CCR_MINC bit
* - PeriphOrM2MSrcDataSize: DMA_CCR_PSIZE[1:0] bits * - PeriphOrM2MSrcDataSize: DMA_CCR_PSIZE[1:0] bits
* - MemoryOrM2MDstDataSize: DMA_CCR_MSIZE[1:0] bits * - MemoryOrM2MDstDataSize: DMA_CCR_MSIZE[1:0] bits
* - Priority: DMA_CCR_PL[1:0] bits * - Priority: DMA_CCR_PL[1:0] bits
*/ */
LL_DMA_ConfigTransfer(DMAx, Channel, DMA_InitStruct->Direction | \ LL_DMA_ConfigTransfer(DMAx, Channel, DMA_InitStruct->Direction | \
DMA_InitStruct->Mode | \ DMA_InitStruct->Mode | \
DMA_InitStruct->PeriphOrM2MSrcIncMode | \ DMA_InitStruct->PeriphOrM2MSrcIncMode | \
DMA_InitStruct->MemoryOrM2MDstIncMode | \ DMA_InitStruct->MemoryOrM2MDstIncMode | \
DMA_InitStruct->PeriphOrM2MSrcDataSize | \ DMA_InitStruct->PeriphOrM2MSrcDataSize | \
DMA_InitStruct->MemoryOrM2MDstDataSize | \ DMA_InitStruct->MemoryOrM2MDstDataSize | \
DMA_InitStruct->Priority); DMA_InitStruct->Priority);
/*-------------------------- DMAx CMAR Configuration ------------------------- /*-------------------------- DMAx CMAR Configuration -------------------------
* Configure the memory or destination base address with parameter : * Configure the memory or destination base address with parameter :
* - MemoryOrM2MDstAddress: DMA_CMAR_MA[31:0] bits * - MemoryOrM2MDstAddress: DMA_CMAR_MA[31:0] bits
*/ */
LL_DMA_SetMemoryAddress(DMAx, Channel, DMA_InitStruct->MemoryOrM2MDstAddress); LL_DMA_SetMemoryAddress(DMAx, Channel, DMA_InitStruct->MemoryOrM2MDstAddress);
/*-------------------------- DMAx CPAR Configuration ------------------------- /*-------------------------- DMAx CPAR Configuration -------------------------
* Configure the peripheral or source base address with parameter : * Configure the peripheral or source base address with parameter :
* - PeriphOrM2MSrcAddress: DMA_CPAR_PA[31:0] bits * - PeriphOrM2MSrcAddress: DMA_CPAR_PA[31:0] bits
*/ */
LL_DMA_SetPeriphAddress(DMAx, Channel, DMA_InitStruct->PeriphOrM2MSrcAddress); LL_DMA_SetPeriphAddress(DMAx, Channel, DMA_InitStruct->PeriphOrM2MSrcAddress);
/*--------------------------- DMAx CNDTR Configuration ----------------------- /*--------------------------- DMAx CNDTR Configuration -----------------------
* Configure the peripheral base address with parameter : * Configure the peripheral base address with parameter :
* - NbData: DMA_CNDTR_NDT[15:0] bits * - NbData: DMA_CNDTR_NDT[15:0] bits
*/ */
LL_DMA_SetDataLength(DMAx, Channel, DMA_InitStruct->NbData); LL_DMA_SetDataLength(DMAx, Channel, DMA_InitStruct->NbData);
return SUCCESS; return SUCCESS;
} }
/** /**
* @brief Set each @ref LL_DMA_InitTypeDef field to default value. * @brief Set each @ref LL_DMA_InitTypeDef field to default value.
* @param DMA_InitStruct Pointer to a @ref LL_DMA_InitTypeDef structure. * @param DMA_InitStruct Pointer to a @ref LL_DMA_InitTypeDef structure.
* @retval None * @retval None
*/ */
void LL_DMA_StructInit(LL_DMA_InitTypeDef *DMA_InitStruct) void LL_DMA_StructInit(LL_DMA_InitTypeDef *DMA_InitStruct)
{ {
/* Set DMA_InitStruct fields to default values */ /* Set DMA_InitStruct fields to default values */
DMA_InitStruct->PeriphOrM2MSrcAddress = 0x00000000U; DMA_InitStruct->PeriphOrM2MSrcAddress = 0x00000000U;
DMA_InitStruct->MemoryOrM2MDstAddress = 0x00000000U; DMA_InitStruct->MemoryOrM2MDstAddress = 0x00000000U;
DMA_InitStruct->Direction = LL_DMA_DIRECTION_PERIPH_TO_MEMORY; DMA_InitStruct->Direction = LL_DMA_DIRECTION_PERIPH_TO_MEMORY;
DMA_InitStruct->Mode = LL_DMA_MODE_NORMAL; DMA_InitStruct->Mode = LL_DMA_MODE_NORMAL;
DMA_InitStruct->PeriphOrM2MSrcIncMode = LL_DMA_PERIPH_NOINCREMENT; DMA_InitStruct->PeriphOrM2MSrcIncMode = LL_DMA_PERIPH_NOINCREMENT;
DMA_InitStruct->MemoryOrM2MDstIncMode = LL_DMA_MEMORY_NOINCREMENT; DMA_InitStruct->MemoryOrM2MDstIncMode = LL_DMA_MEMORY_NOINCREMENT;
DMA_InitStruct->PeriphOrM2MSrcDataSize = LL_DMA_PDATAALIGN_BYTE; DMA_InitStruct->PeriphOrM2MSrcDataSize = LL_DMA_PDATAALIGN_BYTE;
DMA_InitStruct->MemoryOrM2MDstDataSize = LL_DMA_MDATAALIGN_BYTE; DMA_InitStruct->MemoryOrM2MDstDataSize = LL_DMA_MDATAALIGN_BYTE;
DMA_InitStruct->NbData = 0x00000000U; DMA_InitStruct->NbData = 0x00000000U;
DMA_InitStruct->Priority = LL_DMA_PRIORITY_LOW; DMA_InitStruct->Priority = LL_DMA_PRIORITY_LOW;
} }
/** /**
* @} * @}
*/ */
/** /**
* @} * @}
*/ */
/** /**
* @} * @}
*/ */
#endif /* DMA1 || DMA2 */ #endif /* DMA1 || DMA2 */
/** /**
* @} * @}
*/ */
#endif /* USE_FULL_LL_DRIVER */ #endif /* USE_FULL_LL_DRIVER */
/************************ (C) COPYRIGHT Puya *****END OF FILE****/ /************************ (C) COPYRIGHT Puya *****END OF FILE****/

View File

@ -1,238 +1,238 @@
/** /**
****************************************************************************** ******************************************************************************
* @file py32f0xx_ll_exti.c * @file py32f0xx_ll_exti.c
* @author MCU Application Team * @author MCU Application Team
* @brief EXTI LL module driver. * @brief EXTI LL module driver.
****************************************************************************** ******************************************************************************
* @attention * @attention
* *
* <h2><center>&copy; Copyright (c) Puya Semiconductor Co. * <h2><center>&copy; Copyright (c) Puya Semiconductor Co.
* All rights reserved.</center></h2> * All rights reserved.</center></h2>
* *
* <h2><center>&copy; Copyright (c) 2016 STMicroelectronics. * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
* All rights reserved.</center></h2> * All rights reserved.</center></h2>
* *
* This software component is licensed by ST under BSD 3-Clause license, * 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 * the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at: * License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause * opensource.org/licenses/BSD-3-Clause
* *
****************************************************************************** ******************************************************************************
*/ */
#if defined(USE_FULL_LL_DRIVER) #if defined(USE_FULL_LL_DRIVER)
/* Includes ------------------------------------------------------------------*/ /* Includes ------------------------------------------------------------------*/
#include "py32f0xx_ll_exti.h" #include "py32f0xx_ll_exti.h"
#ifdef USE_FULL_ASSERT #ifdef USE_FULL_ASSERT
#include "py32_assert.h" #include "py32_assert.h"
#else #else
#define assert_param(expr) ((void)0U) #define assert_param(expr) ((void)0U)
#endif /* USE_FULL_ASSERT */ #endif /* USE_FULL_ASSERT */
/** @addtogroup PY32F0xx_LL_Driver /** @addtogroup PY32F0xx_LL_Driver
* @{ * @{
*/ */
#if defined (EXTI) #if defined (EXTI)
/** @defgroup EXTI_LL EXTI /** @defgroup EXTI_LL EXTI
* @{ * @{
*/ */
/* Private types -------------------------------------------------------------*/ /* Private types -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/
/* Private constants ---------------------------------------------------------*/ /* Private constants ---------------------------------------------------------*/
/* Private macros ------------------------------------------------------------*/ /* Private macros ------------------------------------------------------------*/
/** @addtogroup EXTI_LL_Private_Macros /** @addtogroup EXTI_LL_Private_Macros
* @{ * @{
*/ */
#define IS_LL_EXTI_LINE(__VALUE__) ((__VALUE__ == LL_EXTI_LINE_0 ) || \ #define IS_LL_EXTI_LINE(__VALUE__) ((__VALUE__ == LL_EXTI_LINE_0 ) || \
(__VALUE__ == LL_EXTI_LINE_1 ) || \ (__VALUE__ == LL_EXTI_LINE_1 ) || \
(__VALUE__ == LL_EXTI_LINE_2 ) || \ (__VALUE__ == LL_EXTI_LINE_2 ) || \
(__VALUE__ == LL_EXTI_LINE_3 ) || \ (__VALUE__ == LL_EXTI_LINE_3 ) || \
(__VALUE__ == LL_EXTI_LINE_4 ) || \ (__VALUE__ == LL_EXTI_LINE_4 ) || \
(__VALUE__ == LL_EXTI_LINE_5 ) || \ (__VALUE__ == LL_EXTI_LINE_5 ) || \
(__VALUE__ == LL_EXTI_LINE_6 ) || \ (__VALUE__ == LL_EXTI_LINE_6 ) || \
(__VALUE__ == LL_EXTI_LINE_7 ) || \ (__VALUE__ == LL_EXTI_LINE_7 ) || \
(__VALUE__ == LL_EXTI_LINE_8 ) || \ (__VALUE__ == LL_EXTI_LINE_8 ) || \
(__VALUE__ == LL_EXTI_LINE_9 ) || \ (__VALUE__ == LL_EXTI_LINE_9 ) || \
(__VALUE__ == LL_EXTI_LINE_10 ) || \ (__VALUE__ == LL_EXTI_LINE_10 ) || \
(__VALUE__ == LL_EXTI_LINE_11 ) || \ (__VALUE__ == LL_EXTI_LINE_11 ) || \
(__VALUE__ == LL_EXTI_LINE_12 ) || \ (__VALUE__ == LL_EXTI_LINE_12 ) || \
(__VALUE__ == LL_EXTI_LINE_13 ) || \ (__VALUE__ == LL_EXTI_LINE_13 ) || \
(__VALUE__ == LL_EXTI_LINE_14 ) || \ (__VALUE__ == LL_EXTI_LINE_14 ) || \
(__VALUE__ == LL_EXTI_LINE_15 ) || \ (__VALUE__ == LL_EXTI_LINE_15 ) || \
(__VALUE__ == LL_EXTI_LINE_16 ) || \ (__VALUE__ == LL_EXTI_LINE_16 ) || \
(__VALUE__ == LL_EXTI_LINE_17 ) || \ (__VALUE__ == LL_EXTI_LINE_17 ) || \
(__VALUE__ == LL_EXTI_LINE_18 ) || \ (__VALUE__ == LL_EXTI_LINE_18 ) || \
(__VALUE__ == LL_EXTI_LINE_19 ) || \ (__VALUE__ == LL_EXTI_LINE_19 ) || \
(__VALUE__ == LL_EXTI_LINE_29 )) (__VALUE__ == LL_EXTI_LINE_29 ))
#define IS_LL_EXTI_MODE(__VALUE__) (((__VALUE__) == LL_EXTI_MODE_IT) \ #define IS_LL_EXTI_MODE(__VALUE__) (((__VALUE__) == LL_EXTI_MODE_IT) \
|| ((__VALUE__) == LL_EXTI_MODE_EVENT) \ || ((__VALUE__) == LL_EXTI_MODE_EVENT) \
|| ((__VALUE__) == LL_EXTI_MODE_IT_EVENT)) || ((__VALUE__) == LL_EXTI_MODE_IT_EVENT))
#define IS_LL_EXTI_TRIGGER(__VALUE__) (((__VALUE__) == LL_EXTI_TRIGGER_NONE) \ #define IS_LL_EXTI_TRIGGER(__VALUE__) (((__VALUE__) == LL_EXTI_TRIGGER_NONE) \
|| ((__VALUE__) == LL_EXTI_TRIGGER_RISING) \ || ((__VALUE__) == LL_EXTI_TRIGGER_RISING) \
|| ((__VALUE__) == LL_EXTI_TRIGGER_FALLING) \ || ((__VALUE__) == LL_EXTI_TRIGGER_FALLING) \
|| ((__VALUE__) == LL_EXTI_TRIGGER_RISING_FALLING)) || ((__VALUE__) == LL_EXTI_TRIGGER_RISING_FALLING))
/** /**
* @} * @}
*/ */
/* Private function prototypes -----------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/
/* Exported functions --------------------------------------------------------*/ /* Exported functions --------------------------------------------------------*/
/** @addtogroup EXTI_LL_Exported_Functions /** @addtogroup EXTI_LL_Exported_Functions
* @{ * @{
*/ */
/** @addtogroup EXTI_LL_EF_Init /** @addtogroup EXTI_LL_EF_Init
* @{ * @{
*/ */
/** /**
* @brief De-initialize the EXTI registers to their default reset values. * @brief De-initialize the EXTI registers to their default reset values.
* @retval An ErrorStatus enumeration value: * @retval An ErrorStatus enumeration value:
* - 0x00: EXTI registers are de-initialized * - 0x00: EXTI registers are de-initialized
*/ */
uint32_t LL_EXTI_DeInit(void) uint32_t LL_EXTI_DeInit(void)
{ {
/* Interrupt mask register set to default reset values */ /* Interrupt mask register set to default reset values */
LL_EXTI_WriteReg(IMR, 0x20080000U); LL_EXTI_WriteReg(IMR, 0x20080000U);
/* Event mask register set to default reset values */ /* Event mask register set to default reset values */
LL_EXTI_WriteReg(EMR, 0x00000000U); LL_EXTI_WriteReg(EMR, 0x00000000U);
/* Rising Trigger selection register set to default reset values */ /* Rising Trigger selection register set to default reset values */
LL_EXTI_WriteReg(RTSR, 0x00000000U); LL_EXTI_WriteReg(RTSR, 0x00000000U);
/* Falling Trigger selection register set to default reset values */ /* Falling Trigger selection register set to default reset values */
LL_EXTI_WriteReg(FTSR, 0x00000000U); LL_EXTI_WriteReg(FTSR, 0x00000000U);
/* Software interrupt event register set to default reset values */ /* Software interrupt event register set to default reset values */
LL_EXTI_WriteReg(SWIER, 0x00000000U); LL_EXTI_WriteReg(SWIER, 0x00000000U);
/* Pending register set to default reset values */ /* Pending register set to default reset values */
LL_EXTI_WriteReg(PR, 0x00007FFFFU); LL_EXTI_WriteReg(PR, 0x00007FFFFU);
return 0x00u; return 0x00u;
} }
/** /**
* @brief Initialize the EXTI registers according to the specified parameters in EXTI_InitStruct. * @brief Initialize the EXTI registers according to the specified parameters in EXTI_InitStruct.
* @param EXTI_InitStruct pointer to a @ref LL_EXTI_InitTypeDef structure. * @param EXTI_InitStruct pointer to a @ref LL_EXTI_InitTypeDef structure.
* @retval An ErrorStatus enumeration value: * @retval An ErrorStatus enumeration value:
* - 0x00: EXTI registers are initialized * - 0x00: EXTI registers are initialized
* - any other value : wrong configuration * - any other value : wrong configuration
*/ */
uint32_t LL_EXTI_Init(LL_EXTI_InitTypeDef *EXTI_InitStruct) uint32_t LL_EXTI_Init(LL_EXTI_InitTypeDef *EXTI_InitStruct)
{ {
uint32_t status = 0x00u; uint32_t status = 0x00u;
/* Check the parameters */ /* Check the parameters */
assert_param(IS_LL_EXTI_LINE(EXTI_InitStruct->Line)); assert_param(IS_LL_EXTI_LINE(EXTI_InitStruct->Line));
assert_param(IS_FUNCTIONAL_STATE(EXTI_InitStruct->LineCommand)); assert_param(IS_FUNCTIONAL_STATE(EXTI_InitStruct->LineCommand));
assert_param(IS_LL_EXTI_MODE(EXTI_InitStruct->Mode)); assert_param(IS_LL_EXTI_MODE(EXTI_InitStruct->Mode));
/* ENABLE LineCommand */ /* ENABLE LineCommand */
if (EXTI_InitStruct->LineCommand != DISABLE) if (EXTI_InitStruct->LineCommand != DISABLE)
{ {
assert_param(IS_LL_EXTI_TRIGGER(EXTI_InitStruct->Trigger)); assert_param(IS_LL_EXTI_TRIGGER(EXTI_InitStruct->Trigger));
/* Configure EXTI Lines*/ /* Configure EXTI Lines*/
if (EXTI_InitStruct->Line != LL_EXTI_LINE_NONE) if (EXTI_InitStruct->Line != LL_EXTI_LINE_NONE)
{ {
switch (EXTI_InitStruct->Mode) switch (EXTI_InitStruct->Mode)
{ {
case LL_EXTI_MODE_IT: case LL_EXTI_MODE_IT:
/* First Disable Event on provided Lines */ /* First Disable Event on provided Lines */
LL_EXTI_DisableEvent(EXTI_InitStruct->Line); LL_EXTI_DisableEvent(EXTI_InitStruct->Line);
/* Then Enable IT on provided Lines */ /* Then Enable IT on provided Lines */
LL_EXTI_EnableIT(EXTI_InitStruct->Line); LL_EXTI_EnableIT(EXTI_InitStruct->Line);
break; break;
case LL_EXTI_MODE_EVENT: case LL_EXTI_MODE_EVENT:
/* First Disable IT on provided Lines */ /* First Disable IT on provided Lines */
LL_EXTI_DisableIT(EXTI_InitStruct->Line); LL_EXTI_DisableIT(EXTI_InitStruct->Line);
/* Then Enable Event on provided Lines */ /* Then Enable Event on provided Lines */
LL_EXTI_EnableEvent(EXTI_InitStruct->Line); LL_EXTI_EnableEvent(EXTI_InitStruct->Line);
break; break;
case LL_EXTI_MODE_IT_EVENT: case LL_EXTI_MODE_IT_EVENT:
/* Directly Enable IT & Event on provided Lines */ /* Directly Enable IT & Event on provided Lines */
LL_EXTI_EnableIT(EXTI_InitStruct->Line); LL_EXTI_EnableIT(EXTI_InitStruct->Line);
LL_EXTI_EnableEvent(EXTI_InitStruct->Line); LL_EXTI_EnableEvent(EXTI_InitStruct->Line);
break; break;
default: default:
status = 0x01u; status = 0x01u;
break; break;
} }
if (EXTI_InitStruct->Trigger != LL_EXTI_TRIGGER_NONE) if (EXTI_InitStruct->Trigger != LL_EXTI_TRIGGER_NONE)
{ {
switch (EXTI_InitStruct->Trigger) switch (EXTI_InitStruct->Trigger)
{ {
case LL_EXTI_TRIGGER_RISING: case LL_EXTI_TRIGGER_RISING:
/* First Disable Falling Trigger on provided Lines */ /* First Disable Falling Trigger on provided Lines */
LL_EXTI_DisableFallingTrig(EXTI_InitStruct->Line); LL_EXTI_DisableFallingTrig(EXTI_InitStruct->Line);
/* Then Enable Rising Trigger on provided Lines */ /* Then Enable Rising Trigger on provided Lines */
LL_EXTI_EnableRisingTrig(EXTI_InitStruct->Line); LL_EXTI_EnableRisingTrig(EXTI_InitStruct->Line);
break; break;
case LL_EXTI_TRIGGER_FALLING: case LL_EXTI_TRIGGER_FALLING:
/* First Disable Rising Trigger on provided Lines */ /* First Disable Rising Trigger on provided Lines */
LL_EXTI_DisableRisingTrig(EXTI_InitStruct->Line); LL_EXTI_DisableRisingTrig(EXTI_InitStruct->Line);
/* Then Enable Falling Trigger on provided Lines */ /* Then Enable Falling Trigger on provided Lines */
LL_EXTI_EnableFallingTrig(EXTI_InitStruct->Line); LL_EXTI_EnableFallingTrig(EXTI_InitStruct->Line);
break; break;
case LL_EXTI_TRIGGER_RISING_FALLING: case LL_EXTI_TRIGGER_RISING_FALLING:
LL_EXTI_EnableRisingTrig(EXTI_InitStruct->Line); LL_EXTI_EnableRisingTrig(EXTI_InitStruct->Line);
LL_EXTI_EnableFallingTrig(EXTI_InitStruct->Line); LL_EXTI_EnableFallingTrig(EXTI_InitStruct->Line);
break; break;
default: default:
status |= 0x02u; status |= 0x02u;
break; break;
} }
} }
} }
} }
/* DISABLE LineCommand */ /* DISABLE LineCommand */
else else
{ {
/* De-configure EXTI Lines*/ /* De-configure EXTI Lines*/
LL_EXTI_DisableIT(EXTI_InitStruct->Line); LL_EXTI_DisableIT(EXTI_InitStruct->Line);
LL_EXTI_DisableEvent(EXTI_InitStruct->Line); LL_EXTI_DisableEvent(EXTI_InitStruct->Line);
} }
return status; return status;
} }
/** /**
* @brief Set each @ref LL_EXTI_InitTypeDef field to default value. * @brief Set each @ref LL_EXTI_InitTypeDef field to default value.
* @param EXTI_InitStruct Pointer to a @ref LL_EXTI_InitTypeDef structure. * @param EXTI_InitStruct Pointer to a @ref LL_EXTI_InitTypeDef structure.
* @retval None * @retval None
*/ */
void LL_EXTI_StructInit(LL_EXTI_InitTypeDef *EXTI_InitStruct) void LL_EXTI_StructInit(LL_EXTI_InitTypeDef *EXTI_InitStruct)
{ {
EXTI_InitStruct->Line = LL_EXTI_LINE_NONE; EXTI_InitStruct->Line = LL_EXTI_LINE_NONE;
EXTI_InitStruct->LineCommand = DISABLE; EXTI_InitStruct->LineCommand = DISABLE;
EXTI_InitStruct->Mode = LL_EXTI_MODE_IT; EXTI_InitStruct->Mode = LL_EXTI_MODE_IT;
EXTI_InitStruct->Trigger = LL_EXTI_TRIGGER_FALLING; EXTI_InitStruct->Trigger = LL_EXTI_TRIGGER_FALLING;
} }
/** /**
* @} * @}
*/ */
/** /**
* @} * @}
*/ */
/** /**
* @} * @}
*/ */
#endif /* defined (EXTI) */ #endif /* defined (EXTI) */
/** /**
* @} * @}
*/ */
#endif /* USE_FULL_LL_DRIVER */ #endif /* USE_FULL_LL_DRIVER */
/************************ (C) COPYRIGHT Puya *****END OF FILE****/ /************************ (C) COPYRIGHT Puya *****END OF FILE****/

View File

@ -1,261 +1,261 @@
/** /**
****************************************************************************** ******************************************************************************
* @file py32f0xx_ll_gpio.c * @file py32f0xx_ll_gpio.c
* @author MCU Application Team * @author MCU Application Team
* @brief GPIO LL module driver. * @brief GPIO LL module driver.
****************************************************************************** ******************************************************************************
* @attention * @attention
* *
* <h2><center>&copy; Copyright (c) Puya Semiconductor Co. * <h2><center>&copy; Copyright (c) Puya Semiconductor Co.
* All rights reserved.</center></h2> * All rights reserved.</center></h2>
* *
* <h2><center>&copy; Copyright (c) 2016 STMicroelectronics. * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
* All rights reserved.</center></h2> * All rights reserved.</center></h2>
* *
* This software component is licensed by ST under BSD 3-Clause license, * 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 * the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at: * License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause * opensource.org/licenses/BSD-3-Clause
* *
****************************************************************************** ******************************************************************************
*/ */
#if defined(USE_FULL_LL_DRIVER) #if defined(USE_FULL_LL_DRIVER)
/* Includes ------------------------------------------------------------------*/ /* Includes ------------------------------------------------------------------*/
#include "py32f0xx_ll_gpio.h" #include "py32f0xx_ll_gpio.h"
#include "py32f0xx_ll_bus.h" #include "py32f0xx_ll_bus.h"
#ifdef USE_FULL_ASSERT #ifdef USE_FULL_ASSERT
#include "py32_assert.h" #include "py32_assert.h"
#else #else
#define assert_param(expr) ((void)0U) #define assert_param(expr) ((void)0U)
#endif #endif
/** @addtogroup PY32F0xx_LL_Driver /** @addtogroup PY32F0xx_LL_Driver
* @{ * @{
*/ */
#if defined (GPIOA) || defined (GPIOB) || defined (GPIOF) #if defined (GPIOA) || defined (GPIOB) || defined (GPIOF)
/** @addtogroup GPIO_LL /** @addtogroup GPIO_LL
* @{ * @{
*/ */
/** MISRA C:2012 deviation rule has been granted for following rules: /** MISRA C:2012 deviation rule has been granted for following rules:
* Rule-12.2 - Medium: RHS argument is in interval [0,INF] which is out of * Rule-12.2 - Medium: RHS argument is in interval [0,INF] which is out of
* range of the shift operator in following API : * range of the shift operator in following API :
* LL_GPIO_Init * LL_GPIO_Init
* LL_GPIO_DeInit * LL_GPIO_DeInit
* LL_GPIO_SetPinMode * LL_GPIO_SetPinMode
* LL_GPIO_GetPinMode * LL_GPIO_GetPinMode
* LL_GPIO_SetPinSpeed * LL_GPIO_SetPinSpeed
* LL_GPIO_GetPinSpeed * LL_GPIO_GetPinSpeed
* LL_GPIO_SetPinPull * LL_GPIO_SetPinPull
* LL_GPIO_GetPinPull * LL_GPIO_GetPinPull
* LL_GPIO_GetAFPin_0_7 * LL_GPIO_GetAFPin_0_7
* LL_GPIO_SetAFPin_0_7 * LL_GPIO_SetAFPin_0_7
* LL_GPIO_SetAFPin_8_15 * LL_GPIO_SetAFPin_8_15
* LL_GPIO_GetAFPin_8_15 * LL_GPIO_GetAFPin_8_15
*/ */
/* Private types -------------------------------------------------------------*/ /* Private types -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/
/* Private constants ---------------------------------------------------------*/ /* Private constants ---------------------------------------------------------*/
/* Private macros ------------------------------------------------------------*/ /* Private macros ------------------------------------------------------------*/
/** @addtogroup GPIO_LL_Private_Macros /** @addtogroup GPIO_LL_Private_Macros
* @{ * @{
*/ */
#define IS_LL_GPIO_PIN(__VALUE__) (((0x00u) < (__VALUE__)) && ((__VALUE__) <= (LL_GPIO_PIN_ALL))) #define IS_LL_GPIO_PIN(__VALUE__) (((0x00u) < (__VALUE__)) && ((__VALUE__) <= (LL_GPIO_PIN_ALL)))
#define IS_LL_GPIO_MODE(__VALUE__) (((__VALUE__) == LL_GPIO_MODE_INPUT) ||\ #define IS_LL_GPIO_MODE(__VALUE__) (((__VALUE__) == LL_GPIO_MODE_INPUT) ||\
((__VALUE__) == LL_GPIO_MODE_OUTPUT) ||\ ((__VALUE__) == LL_GPIO_MODE_OUTPUT) ||\
((__VALUE__) == LL_GPIO_MODE_ALTERNATE) ||\ ((__VALUE__) == LL_GPIO_MODE_ALTERNATE) ||\
((__VALUE__) == LL_GPIO_MODE_ANALOG)) ((__VALUE__) == LL_GPIO_MODE_ANALOG))
#define IS_LL_GPIO_OUTPUT_TYPE(__VALUE__) (((__VALUE__) == LL_GPIO_OUTPUT_PUSHPULL) ||\ #define IS_LL_GPIO_OUTPUT_TYPE(__VALUE__) (((__VALUE__) == LL_GPIO_OUTPUT_PUSHPULL) ||\
((__VALUE__) == LL_GPIO_OUTPUT_OPENDRAIN)) ((__VALUE__) == LL_GPIO_OUTPUT_OPENDRAIN))
#define IS_LL_GPIO_SPEED(__VALUE__) (((__VALUE__) == LL_GPIO_SPEED_FREQ_LOW) ||\ #define IS_LL_GPIO_SPEED(__VALUE__) (((__VALUE__) == LL_GPIO_SPEED_FREQ_LOW) ||\
((__VALUE__) == LL_GPIO_SPEED_FREQ_MEDIUM) ||\ ((__VALUE__) == LL_GPIO_SPEED_FREQ_MEDIUM) ||\
((__VALUE__) == LL_GPIO_SPEED_FREQ_HIGH) ||\ ((__VALUE__) == LL_GPIO_SPEED_FREQ_HIGH) ||\
((__VALUE__) == LL_GPIO_SPEED_FREQ_VERY_HIGH)) ((__VALUE__) == LL_GPIO_SPEED_FREQ_VERY_HIGH))
#define IS_LL_GPIO_PULL(__VALUE__) (((__VALUE__) == LL_GPIO_PULL_NO) ||\ #define IS_LL_GPIO_PULL(__VALUE__) (((__VALUE__) == LL_GPIO_PULL_NO) ||\
((__VALUE__) == LL_GPIO_PULL_UP) ||\ ((__VALUE__) == LL_GPIO_PULL_UP) ||\
((__VALUE__) == LL_GPIO_PULL_DOWN)) ((__VALUE__) == LL_GPIO_PULL_DOWN))
#define IS_LL_GPIO_ALTERNATE(__VALUE__) (((__VALUE__) == LL_GPIO_AF_0 ) ||\ #define IS_LL_GPIO_ALTERNATE(__VALUE__) (((__VALUE__) == LL_GPIO_AF_0 ) ||\
((__VALUE__) == LL_GPIO_AF_1 ) ||\ ((__VALUE__) == LL_GPIO_AF_1 ) ||\
((__VALUE__) == LL_GPIO_AF_2 ) ||\ ((__VALUE__) == LL_GPIO_AF_2 ) ||\
((__VALUE__) == LL_GPIO_AF_3 ) ||\ ((__VALUE__) == LL_GPIO_AF_3 ) ||\
((__VALUE__) == LL_GPIO_AF_4 ) ||\ ((__VALUE__) == LL_GPIO_AF_4 ) ||\
((__VALUE__) == LL_GPIO_AF_5 ) ||\ ((__VALUE__) == LL_GPIO_AF_5 ) ||\
((__VALUE__) == LL_GPIO_AF_6 ) ||\ ((__VALUE__) == LL_GPIO_AF_6 ) ||\
((__VALUE__) == LL_GPIO_AF_7 ) ||\ ((__VALUE__) == LL_GPIO_AF_7 ) ||\
((__VALUE__) == LL_GPIO_AF_8 ) ||\ ((__VALUE__) == LL_GPIO_AF_8 ) ||\
((__VALUE__) == LL_GPIO_AF_9 ) ||\ ((__VALUE__) == LL_GPIO_AF_9 ) ||\
((__VALUE__) == LL_GPIO_AF_10 ) ||\ ((__VALUE__) == LL_GPIO_AF_10 ) ||\
((__VALUE__) == LL_GPIO_AF_11 ) ||\ ((__VALUE__) == LL_GPIO_AF_11 ) ||\
((__VALUE__) == LL_GPIO_AF_12 ) ||\ ((__VALUE__) == LL_GPIO_AF_12 ) ||\
((__VALUE__) == LL_GPIO_AF_13 ) ||\ ((__VALUE__) == LL_GPIO_AF_13 ) ||\
((__VALUE__) == LL_GPIO_AF_14 ) ||\ ((__VALUE__) == LL_GPIO_AF_14 ) ||\
((__VALUE__) == LL_GPIO_AF_15 )) ((__VALUE__) == LL_GPIO_AF_15 ))
/** /**
* @} * @}
*/ */
/* Private function prototypes -----------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/
/* Exported functions --------------------------------------------------------*/ /* Exported functions --------------------------------------------------------*/
/** @addtogroup GPIO_LL_Exported_Functions /** @addtogroup GPIO_LL_Exported_Functions
* @{ * @{
*/ */
/** @addtogroup GPIO_LL_EF_Init /** @addtogroup GPIO_LL_EF_Init
* @{ * @{
*/ */
/** /**
* @brief De-initialize GPIO registers (Registers restored to their default values). * @brief De-initialize GPIO registers (Registers restored to their default values).
* @param GPIOx GPIO Port * @param GPIOx GPIO Port
* @retval An ErrorStatus enumeration value: * @retval An ErrorStatus enumeration value:
* - SUCCESS: GPIO registers are de-initialized * - SUCCESS: GPIO registers are de-initialized
* - ERROR: Wrong GPIO Port * - ERROR: Wrong GPIO Port
*/ */
ErrorStatus LL_GPIO_DeInit(GPIO_TypeDef *GPIOx) ErrorStatus LL_GPIO_DeInit(GPIO_TypeDef *GPIOx)
{ {
ErrorStatus status = SUCCESS; ErrorStatus status = SUCCESS;
/* Check the parameters */ /* Check the parameters */
assert_param(IS_GPIO_ALL_INSTANCE(GPIOx)); assert_param(IS_GPIO_ALL_INSTANCE(GPIOx));
/* Force and Release reset on clock of GPIOx Port */ /* Force and Release reset on clock of GPIOx Port */
if (GPIOx == GPIOA) if (GPIOx == GPIOA)
{ {
LL_IOP_GRP1_ForceReset(LL_IOP_GRP1_PERIPH_GPIOA); LL_IOP_GRP1_ForceReset(LL_IOP_GRP1_PERIPH_GPIOA);
LL_IOP_GRP1_ReleaseReset(LL_IOP_GRP1_PERIPH_GPIOA); LL_IOP_GRP1_ReleaseReset(LL_IOP_GRP1_PERIPH_GPIOA);
} }
else if (GPIOx == GPIOB) else if (GPIOx == GPIOB)
{ {
LL_IOP_GRP1_ForceReset(LL_IOP_GRP1_PERIPH_GPIOB); LL_IOP_GRP1_ForceReset(LL_IOP_GRP1_PERIPH_GPIOB);
LL_IOP_GRP1_ReleaseReset(LL_IOP_GRP1_PERIPH_GPIOB); LL_IOP_GRP1_ReleaseReset(LL_IOP_GRP1_PERIPH_GPIOB);
} }
else if (GPIOx == GPIOF) else if (GPIOx == GPIOF)
{ {
LL_IOP_GRP1_ForceReset(LL_IOP_GRP1_PERIPH_GPIOF); LL_IOP_GRP1_ForceReset(LL_IOP_GRP1_PERIPH_GPIOF);
LL_IOP_GRP1_ReleaseReset(LL_IOP_GRP1_PERIPH_GPIOF); LL_IOP_GRP1_ReleaseReset(LL_IOP_GRP1_PERIPH_GPIOF);
} }
else else
{ {
status = ERROR; status = ERROR;
} }
return (status); return (status);
} }
/** /**
* @brief Initialize GPIO registers according to the specified parameters in GPIO_InitStruct. * @brief Initialize GPIO registers according to the specified parameters in GPIO_InitStruct.
* @param GPIOx GPIO Port * @param GPIOx GPIO Port
* @param GPIO_InitStruct pointer to a @ref LL_GPIO_InitTypeDef structure * @param GPIO_InitStruct pointer to a @ref LL_GPIO_InitTypeDef structure
* that contains the configuration information for the specified GPIO peripheral. * that contains the configuration information for the specified GPIO peripheral.
* @retval An ErrorStatus enumeration value: * @retval An ErrorStatus enumeration value:
* - SUCCESS: GPIO registers are initialized according to GPIO_InitStruct content * - SUCCESS: GPIO registers are initialized according to GPIO_InitStruct content
* - ERROR: Not applicable * - ERROR: Not applicable
*/ */
ErrorStatus LL_GPIO_Init(GPIO_TypeDef *GPIOx, LL_GPIO_InitTypeDef *GPIO_InitStruct) ErrorStatus LL_GPIO_Init(GPIO_TypeDef *GPIOx, LL_GPIO_InitTypeDef *GPIO_InitStruct)
{ {
uint32_t pinpos; uint32_t pinpos;
uint32_t currentpin; uint32_t currentpin;
/* Check the parameters */ /* Check the parameters */
assert_param(IS_GPIO_ALL_INSTANCE(GPIOx)); assert_param(IS_GPIO_ALL_INSTANCE(GPIOx));
assert_param(IS_LL_GPIO_PIN(GPIO_InitStruct->Pin)); assert_param(IS_LL_GPIO_PIN(GPIO_InitStruct->Pin));
assert_param(IS_LL_GPIO_MODE(GPIO_InitStruct->Mode)); assert_param(IS_LL_GPIO_MODE(GPIO_InitStruct->Mode));
assert_param(IS_LL_GPIO_PULL(GPIO_InitStruct->Pull)); assert_param(IS_LL_GPIO_PULL(GPIO_InitStruct->Pull));
/* ------------------------- Configure the port pins ---------------- */ /* ------------------------- Configure the port pins ---------------- */
/* Initialize pinpos on first pin set */ /* Initialize pinpos on first pin set */
pinpos = 0; pinpos = 0;
/* Configure the port pins */ /* Configure the port pins */
while (((GPIO_InitStruct->Pin) >> pinpos) != 0x00u) while (((GPIO_InitStruct->Pin) >> pinpos) != 0x00u)
{ {
/* Get current io position */ /* Get current io position */
currentpin = (GPIO_InitStruct->Pin) & (0x00000001uL << pinpos); currentpin = (GPIO_InitStruct->Pin) & (0x00000001uL << pinpos);
if (currentpin != 0x00u) if (currentpin != 0x00u)
{ {
/* Pin Mode configuration */ /* Pin Mode configuration */
LL_GPIO_SetPinMode(GPIOx, currentpin, GPIO_InitStruct->Mode); LL_GPIO_SetPinMode(GPIOx, currentpin, GPIO_InitStruct->Mode);
if ((GPIO_InitStruct->Mode == LL_GPIO_MODE_OUTPUT) || (GPIO_InitStruct->Mode == LL_GPIO_MODE_ALTERNATE)) if ((GPIO_InitStruct->Mode == LL_GPIO_MODE_OUTPUT) || (GPIO_InitStruct->Mode == LL_GPIO_MODE_ALTERNATE))
{ {
/* Check Speed mode parameters */ /* Check Speed mode parameters */
assert_param(IS_LL_GPIO_SPEED(GPIO_InitStruct->Speed)); assert_param(IS_LL_GPIO_SPEED(GPIO_InitStruct->Speed));
/* Speed mode configuration */ /* Speed mode configuration */
LL_GPIO_SetPinSpeed(GPIOx, currentpin, GPIO_InitStruct->Speed); LL_GPIO_SetPinSpeed(GPIOx, currentpin, GPIO_InitStruct->Speed);
} }
/* Pull-up Pull down resistor configuration*/ /* Pull-up Pull down resistor configuration*/
LL_GPIO_SetPinPull(GPIOx, currentpin, GPIO_InitStruct->Pull); LL_GPIO_SetPinPull(GPIOx, currentpin, GPIO_InitStruct->Pull);
if (GPIO_InitStruct->Mode == LL_GPIO_MODE_ALTERNATE) if (GPIO_InitStruct->Mode == LL_GPIO_MODE_ALTERNATE)
{ {
/* Check Alternate parameter */ /* Check Alternate parameter */
assert_param(IS_LL_GPIO_ALTERNATE(GPIO_InitStruct->Alternate)); assert_param(IS_LL_GPIO_ALTERNATE(GPIO_InitStruct->Alternate));
/* Speed mode configuration */ /* Speed mode configuration */
if (currentpin < LL_GPIO_PIN_8) if (currentpin < LL_GPIO_PIN_8)
{ {
LL_GPIO_SetAFPin_0_7(GPIOx, currentpin, GPIO_InitStruct->Alternate); LL_GPIO_SetAFPin_0_7(GPIOx, currentpin, GPIO_InitStruct->Alternate);
} }
else else
{ {
LL_GPIO_SetAFPin_8_15(GPIOx, currentpin, GPIO_InitStruct->Alternate); LL_GPIO_SetAFPin_8_15(GPIOx, currentpin, GPIO_InitStruct->Alternate);
} }
} }
} }
pinpos++; pinpos++;
} }
if ((GPIO_InitStruct->Mode == LL_GPIO_MODE_OUTPUT) || (GPIO_InitStruct->Mode == LL_GPIO_MODE_ALTERNATE)) if ((GPIO_InitStruct->Mode == LL_GPIO_MODE_OUTPUT) || (GPIO_InitStruct->Mode == LL_GPIO_MODE_ALTERNATE))
{ {
/* Check Output mode parameters */ /* Check Output mode parameters */
assert_param(IS_LL_GPIO_OUTPUT_TYPE(GPIO_InitStruct->OutputType)); assert_param(IS_LL_GPIO_OUTPUT_TYPE(GPIO_InitStruct->OutputType));
/* Output mode configuration*/ /* Output mode configuration*/
LL_GPIO_SetPinOutputType(GPIOx, GPIO_InitStruct->Pin, GPIO_InitStruct->OutputType); LL_GPIO_SetPinOutputType(GPIOx, GPIO_InitStruct->Pin, GPIO_InitStruct->OutputType);
} }
return (SUCCESS); return (SUCCESS);
} }
/** /**
* @brief Set each @ref LL_GPIO_InitTypeDef field to default value. * @brief Set each @ref LL_GPIO_InitTypeDef field to default value.
* @param GPIO_InitStruct pointer to a @ref LL_GPIO_InitTypeDef structure * @param GPIO_InitStruct pointer to a @ref LL_GPIO_InitTypeDef structure
* whose fields will be set to default values. * whose fields will be set to default values.
* @retval None * @retval None
*/ */
void LL_GPIO_StructInit(LL_GPIO_InitTypeDef *GPIO_InitStruct) void LL_GPIO_StructInit(LL_GPIO_InitTypeDef *GPIO_InitStruct)
{ {
/* Reset GPIO init structure parameters values */ /* Reset GPIO init structure parameters values */
GPIO_InitStruct->Pin = LL_GPIO_PIN_ALL; GPIO_InitStruct->Pin = LL_GPIO_PIN_ALL;
GPIO_InitStruct->Mode = LL_GPIO_MODE_ANALOG; GPIO_InitStruct->Mode = LL_GPIO_MODE_ANALOG;
GPIO_InitStruct->Speed = LL_GPIO_SPEED_FREQ_LOW; GPIO_InitStruct->Speed = LL_GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct->OutputType = LL_GPIO_OUTPUT_PUSHPULL; GPIO_InitStruct->OutputType = LL_GPIO_OUTPUT_PUSHPULL;
GPIO_InitStruct->Pull = LL_GPIO_PULL_NO; GPIO_InitStruct->Pull = LL_GPIO_PULL_NO;
GPIO_InitStruct->Alternate = LL_GPIO_AF_0; GPIO_InitStruct->Alternate = LL_GPIO_AF_0;
} }
#endif /* defined (GPIOA) || defined (GPIOB) || defined (GPIOF) */ #endif /* defined (GPIOA) || defined (GPIOB) || defined (GPIOF) */
#endif /* USE_FULL_LL_DRIVER */ #endif /* USE_FULL_LL_DRIVER */
/************************ (C) COPYRIGHT Puya Semiconductor *****END OF FILE****/ /************************ (C) COPYRIGHT Puya Semiconductor *****END OF FILE****/

View File

@ -1,194 +1,194 @@
/** /**
****************************************************************************** ******************************************************************************
* @file py32f0xx_ll_i2c.c * @file py32f0xx_ll_i2c.c
* @author MCU Application Team * @author MCU Application Team
* @brief I2C LL module driver. * @brief I2C LL module driver.
****************************************************************************** ******************************************************************************
* @attention * @attention
* *
* <h2><center>&copy; Copyright (c) Puya Semiconductor Co. * <h2><center>&copy; Copyright (c) Puya Semiconductor Co.
* All rights reserved.</center></h2> * All rights reserved.</center></h2>
* *
* <h2><center>&copy; Copyright (c) 2016 STMicroelectronics. * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
* All rights reserved.</center></h2> * All rights reserved.</center></h2>
* *
* This software component is licensed by ST under BSD 3-Clause license, * 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 * the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at: * License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause * opensource.org/licenses/BSD-3-Clause
* *
****************************************************************************** ******************************************************************************
*/ */
#if defined(USE_FULL_LL_DRIVER) #if defined(USE_FULL_LL_DRIVER)
/* Includes ------------------------------------------------------------------*/ /* Includes ------------------------------------------------------------------*/
#include "py32f0xx_ll_i2c.h" #include "py32f0xx_ll_i2c.h"
#include "py32f0xx_ll_bus.h" #include "py32f0xx_ll_bus.h"
#include "py32f0xx_ll_rcc.h" #include "py32f0xx_ll_rcc.h"
#ifdef USE_FULL_ASSERT #ifdef USE_FULL_ASSERT
#include "py32_assert.h" #include "py32_assert.h"
#else #else
#define assert_param(expr) ((void)0U) #define assert_param(expr) ((void)0U)
#endif #endif
/** @addtogroup PY32F0xx_LL_Driver /** @addtogroup PY32F0xx_LL_Driver
* @{ * @{
*/ */
#if defined (I2C1) || defined (I2C2) #if defined (I2C1) || defined (I2C2)
/** @defgroup I2C_LL I2C /** @defgroup I2C_LL I2C
* @{ * @{
*/ */
/* Private types -------------------------------------------------------------*/ /* Private types -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/
/* Private constants ---------------------------------------------------------*/ /* Private constants ---------------------------------------------------------*/
/* Private macros ------------------------------------------------------------*/ /* Private macros ------------------------------------------------------------*/
/** @addtogroup I2C_LL_Private_Macros /** @addtogroup I2C_LL_Private_Macros
* @{ * @{
*/ */
#define IS_LL_I2C_CLOCK_SPEED(__VALUE__) (((__VALUE__) > 0U) && ((__VALUE__) <= LL_I2C_MAX_SPEED_FAST)) #define IS_LL_I2C_CLOCK_SPEED(__VALUE__) (((__VALUE__) > 0U) && ((__VALUE__) <= LL_I2C_MAX_SPEED_FAST))
#define IS_LL_I2C_DUTY_CYCLE(__VALUE__) (((__VALUE__) == LL_I2C_DUTYCYCLE_2) || \ #define IS_LL_I2C_DUTY_CYCLE(__VALUE__) (((__VALUE__) == LL_I2C_DUTYCYCLE_2) || \
((__VALUE__) == LL_I2C_DUTYCYCLE_16_9)) ((__VALUE__) == LL_I2C_DUTYCYCLE_16_9))
#define IS_LL_I2C_OWN_ADDRESS1(__VALUE__) ((__VALUE__) <= 0x000003FFU) #define IS_LL_I2C_OWN_ADDRESS1(__VALUE__) ((__VALUE__) <= 0x000003FFU)
#define IS_LL_I2C_TYPE_ACKNOWLEDGE(__VALUE__) (((__VALUE__) == LL_I2C_ACK) || \ #define IS_LL_I2C_TYPE_ACKNOWLEDGE(__VALUE__) (((__VALUE__) == LL_I2C_ACK) || \
((__VALUE__) == LL_I2C_NACK)) ((__VALUE__) == LL_I2C_NACK))
/** /**
* @} * @}
*/ */
/* Private function prototypes -----------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/
/* Exported functions --------------------------------------------------------*/ /* Exported functions --------------------------------------------------------*/
/** @addtogroup I2C_LL_Exported_Functions /** @addtogroup I2C_LL_Exported_Functions
* @{ * @{
*/ */
/** @addtogroup I2C_LL_EF_Init /** @addtogroup I2C_LL_EF_Init
* @{ * @{
*/ */
/** /**
* @brief De-initialize the I2C registers to their default reset values. * @brief De-initialize the I2C registers to their default reset values.
* @param I2Cx I2C Instance. * @param I2Cx I2C Instance.
* @retval An ErrorStatus enumeration value: * @retval An ErrorStatus enumeration value:
* - SUCCESS I2C registers are de-initialized * - SUCCESS I2C registers are de-initialized
* - ERROR I2C registers are not de-initialized * - ERROR I2C registers are not de-initialized
*/ */
uint32_t LL_I2C_DeInit(I2C_TypeDef *I2Cx) uint32_t LL_I2C_DeInit(I2C_TypeDef *I2Cx)
{ {
ErrorStatus status = SUCCESS; ErrorStatus status = SUCCESS;
/* Check the I2C Instance I2Cx */ /* Check the I2C Instance I2Cx */
assert_param(IS_I2C_ALL_INSTANCE(I2Cx)); assert_param(IS_I2C_ALL_INSTANCE(I2Cx));
if (I2Cx == I2C1) if (I2Cx == I2C1)
{ {
/* Force reset of I2C clock */ /* Force reset of I2C clock */
LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_I2C1); LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_I2C1);
/* Release reset of I2C clock */ /* Release reset of I2C clock */
LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_I2C1); LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_I2C1);
} }
else else
{ {
status = ERROR; status = ERROR;
} }
return status; return status;
} }
/** /**
* @brief Initialize the I2C registers according to the specified parameters in I2C_InitStruct. * @brief Initialize the I2C registers according to the specified parameters in I2C_InitStruct.
* @param I2Cx I2C Instance. * @param I2Cx I2C Instance.
* @param I2C_InitStruct pointer to a @ref LL_I2C_InitTypeDef structure. * @param I2C_InitStruct pointer to a @ref LL_I2C_InitTypeDef structure.
* @retval An ErrorStatus enumeration value: * @retval An ErrorStatus enumeration value:
* - SUCCESS I2C registers are initialized * - SUCCESS I2C registers are initialized
* - ERROR Not applicable * - ERROR Not applicable
*/ */
uint32_t LL_I2C_Init(I2C_TypeDef *I2Cx, LL_I2C_InitTypeDef *I2C_InitStruct) uint32_t LL_I2C_Init(I2C_TypeDef *I2Cx, LL_I2C_InitTypeDef *I2C_InitStruct)
{ {
LL_RCC_ClocksTypeDef rcc_clocks; LL_RCC_ClocksTypeDef rcc_clocks;
/* Check the I2C Instance I2Cx */ /* Check the I2C Instance I2Cx */
assert_param(IS_I2C_ALL_INSTANCE(I2Cx)); assert_param(IS_I2C_ALL_INSTANCE(I2Cx));
/* Check the I2C parameters from I2C_InitStruct */ /* Check the I2C parameters from I2C_InitStruct */
assert_param(IS_LL_I2C_CLOCK_SPEED(I2C_InitStruct->ClockSpeed)); assert_param(IS_LL_I2C_CLOCK_SPEED(I2C_InitStruct->ClockSpeed));
assert_param(IS_LL_I2C_DUTY_CYCLE(I2C_InitStruct->DutyCycle)); assert_param(IS_LL_I2C_DUTY_CYCLE(I2C_InitStruct->DutyCycle));
assert_param(IS_LL_I2C_OWN_ADDRESS1(I2C_InitStruct->OwnAddress1)); assert_param(IS_LL_I2C_OWN_ADDRESS1(I2C_InitStruct->OwnAddress1));
assert_param(IS_LL_I2C_TYPE_ACKNOWLEDGE(I2C_InitStruct->TypeAcknowledge)); assert_param(IS_LL_I2C_TYPE_ACKNOWLEDGE(I2C_InitStruct->TypeAcknowledge));
/* Disable the selected I2Cx Peripheral */ /* Disable the selected I2Cx Peripheral */
LL_I2C_Disable(I2Cx); LL_I2C_Disable(I2Cx);
/* Retrieve Clock frequencies */ /* Retrieve Clock frequencies */
LL_RCC_GetSystemClocksFreq(&rcc_clocks); LL_RCC_GetSystemClocksFreq(&rcc_clocks);
/*---------------------------- I2Cx SCL Clock Speed Configuration ------------ /*---------------------------- I2Cx SCL Clock Speed Configuration ------------
* Configure the SCL speed : * Configure the SCL speed :
* - ClockSpeed: I2C_CR2_FREQ[5:0], I2C_TRISE_TRISE[5:0], I2C_CCR_FS, * - ClockSpeed: I2C_CR2_FREQ[5:0], I2C_TRISE_TRISE[5:0], I2C_CCR_FS,
* and I2C_CCR_CCR[11:0] bits * and I2C_CCR_CCR[11:0] bits
* - DutyCycle: I2C_CCR_DUTY[7:0] bits * - DutyCycle: I2C_CCR_DUTY[7:0] bits
*/ */
LL_I2C_ConfigSpeed(I2Cx, rcc_clocks.PCLK1_Frequency, I2C_InitStruct->ClockSpeed, I2C_InitStruct->DutyCycle); LL_I2C_ConfigSpeed(I2Cx, rcc_clocks.PCLK1_Frequency, I2C_InitStruct->ClockSpeed, I2C_InitStruct->DutyCycle);
/*---------------------------- I2Cx OAR1 Configuration ----------------------- /*---------------------------- I2Cx OAR1 Configuration -----------------------
* Disable, Configure and Enable I2Cx device own address 1 with parameters : * Disable, Configure and Enable I2Cx device own address 1 with parameters :
* - OwnAddress1: I2C_OAR1_ADD[9:8], I2C_OAR1_ADD[7:1] and I2C_OAR1_ADD0 bits * - OwnAddress1: I2C_OAR1_ADD[9:8], I2C_OAR1_ADD[7:1] and I2C_OAR1_ADD0 bits
* - OwnAddrSize: I2C_OAR1_ADDMODE bit * - OwnAddrSize: I2C_OAR1_ADDMODE bit
*/ */
LL_I2C_SetOwnAddress1(I2Cx, I2C_InitStruct->OwnAddress1, 0); LL_I2C_SetOwnAddress1(I2Cx, I2C_InitStruct->OwnAddress1, 0);
/* Enable the selected I2Cx Peripheral */ /* Enable the selected I2Cx Peripheral */
LL_I2C_Enable(I2Cx); LL_I2C_Enable(I2Cx);
/*---------------------------- I2Cx CR2 Configuration ------------------------ /*---------------------------- I2Cx CR2 Configuration ------------------------
* Configure the ACKnowledge or Non ACKnowledge condition * Configure the ACKnowledge or Non ACKnowledge condition
* after the address receive match code or next received byte with parameter : * after the address receive match code or next received byte with parameter :
* - TypeAcknowledge: I2C_CR2_NACK bit * - TypeAcknowledge: I2C_CR2_NACK bit
*/ */
LL_I2C_AcknowledgeNextData(I2Cx, I2C_InitStruct->TypeAcknowledge); LL_I2C_AcknowledgeNextData(I2Cx, I2C_InitStruct->TypeAcknowledge);
return SUCCESS; return SUCCESS;
} }
/** /**
* @brief Set each @ref LL_I2C_InitTypeDef field to default value. * @brief Set each @ref LL_I2C_InitTypeDef field to default value.
* @param I2C_InitStruct Pointer to a @ref LL_I2C_InitTypeDef structure. * @param I2C_InitStruct Pointer to a @ref LL_I2C_InitTypeDef structure.
* @retval None * @retval None
*/ */
void LL_I2C_StructInit(LL_I2C_InitTypeDef *I2C_InitStruct) void LL_I2C_StructInit(LL_I2C_InitTypeDef *I2C_InitStruct)
{ {
/* Set I2C_InitStruct fields to default values */ /* Set I2C_InitStruct fields to default values */
I2C_InitStruct->ClockSpeed = 5000U; I2C_InitStruct->ClockSpeed = 5000U;
I2C_InitStruct->DutyCycle = LL_I2C_DUTYCYCLE_2; I2C_InitStruct->DutyCycle = LL_I2C_DUTYCYCLE_2;
I2C_InitStruct->OwnAddress1 = 0U; I2C_InitStruct->OwnAddress1 = 0U;
I2C_InitStruct->TypeAcknowledge = LL_I2C_NACK; I2C_InitStruct->TypeAcknowledge = LL_I2C_NACK;
} }
/** /**
* @} * @}
*/ */
/** /**
* @} * @}
*/ */
/** /**
* @} * @}
*/ */
#endif /* I2C1 || I2C2 */ #endif /* I2C1 || I2C2 */
/** /**
* @} * @}
*/ */
#endif /* USE_FULL_LL_DRIVER */ #endif /* USE_FULL_LL_DRIVER */
/************************ (C) COPYRIGHT Puya *****END OF FILE****/ /************************ (C) COPYRIGHT Puya *****END OF FILE****/

View File

@ -1,158 +1,158 @@
/** /**
****************************************************************************** ******************************************************************************
* @file py32f0xx_ll_led.c * @file py32f0xx_ll_led.c
* @author MCU Application Team * @author MCU Application Team
* @brief LED LL module driver. * @brief LED LL module driver.
****************************************************************************** ******************************************************************************
* @attention * @attention
* *
* <h2><center>&copy; Copyright (c) Puya Semiconductor Co. * <h2><center>&copy; Copyright (c) Puya Semiconductor Co.
* All rights reserved.</center></h2> * All rights reserved.</center></h2>
* *
* <h2><center>&copy; Copyright (c) 2016 STMicroelectronics. * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
* All rights reserved.</center></h2> * All rights reserved.</center></h2>
* *
* This software component is licensed by ST under BSD 3-Clause license, * 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 * the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at: * License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause * opensource.org/licenses/BSD-3-Clause
* *
****************************************************************************** ******************************************************************************
*/ */
#if defined(USE_FULL_LL_DRIVER) #if defined(USE_FULL_LL_DRIVER)
/* Includes ------------------------------------------------------------------*/ /* Includes ------------------------------------------------------------------*/
#include "py32f0xx_ll_led.h" #include "py32f0xx_ll_led.h"
#include "py32f0xx_ll_bus.h" #include "py32f0xx_ll_bus.h"
#ifdef USE_FULL_ASSERT #ifdef USE_FULL_ASSERT
#include "py32_assert.h" #include "py32_assert.h"
#else #else
#define assert_param(expr) ((void)0U) #define assert_param(expr) ((void)0U)
#endif #endif
/** @addtogroup PY32F0xx_LL_Driver /** @addtogroup PY32F0xx_LL_Driver
* @{ * @{
*/ */
#if defined (LED) #if defined (LED)
/** @addtogroup LED_LL /** @addtogroup LED_LL
* @{ * @{
*/ */
/* Private types -------------------------------------------------------------*/ /* Private types -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/
/* Private constants ---------------------------------------------------------*/ /* Private constants ---------------------------------------------------------*/
/* Private macros ------------------------------------------------------------*/ /* Private macros ------------------------------------------------------------*/
/** @addtogroup LED_LL_Private_Macros /** @addtogroup LED_LL_Private_Macros
* @{ * @{
*/ */
#define IS_LL_LED_COM_DRIVE(__VALUE__) (((__VALUE__) == LL_LED_COMDRIVE_LOW) ||\ #define IS_LL_LED_COM_DRIVE(__VALUE__) (((__VALUE__) == LL_LED_COMDRIVE_LOW) ||\
((__VALUE__) == LL_LED_COMDRIVE_HIGH)) ((__VALUE__) == LL_LED_COMDRIVE_HIGH))
#define IS_LL_LED_PRESCALER(__VALUE__) (((0x00u) < (__VALUE__)) && ((__VALUE__) <= (0xFFu))) #define IS_LL_LED_PRESCALER(__VALUE__) (((0x00u) < (__VALUE__)) && ((__VALUE__) <= (0xFFu)))
#define IS_LL_LED_COM_SELECT(__VALUE__) (((__VALUE__) == LL_LED_COMSELECT_1COM) ||\ #define IS_LL_LED_COM_SELECT(__VALUE__) (((__VALUE__) == LL_LED_COMSELECT_1COM) ||\
((__VALUE__) == LL_LED_COMSELECT_2COM) ||\ ((__VALUE__) == LL_LED_COMSELECT_2COM) ||\
((__VALUE__) == LL_LED_COMSELECT_3COM) ||\ ((__VALUE__) == LL_LED_COMSELECT_3COM) ||\
((__VALUE__) == LL_LED_COMSELECT_4COM)) ((__VALUE__) == LL_LED_COMSELECT_4COM))
#define IS_LL_LED_LIGHT_TIME(__VALUE__) (((0x01u) < (__VALUE__)) && ((__VALUE__) <= (0xFFu))) #define IS_LL_LED_LIGHT_TIME(__VALUE__) (((0x01u) < (__VALUE__)) && ((__VALUE__) <= (0xFFu)))
#define IS_LL_LED_DEAD_TIME(__VALUE__) (((0x01u) < (__VALUE__)) && ((__VALUE__) <= (0xFFu))) #define IS_LL_LED_DEAD_TIME(__VALUE__) (((0x01u) < (__VALUE__)) && ((__VALUE__) <= (0xFFu)))
/** /**
* @} * @}
*/ */
/* Private function prototypes -----------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/
/* Exported functions --------------------------------------------------------*/ /* Exported functions --------------------------------------------------------*/
/** @addtogroup LED_LL_Exported_Functions /** @addtogroup LED_LL_Exported_Functions
* @{ * @{
*/ */
/** @addtogroup LED_LL_EF_Init /** @addtogroup LED_LL_EF_Init
* @{ * @{
*/ */
/** /**
* @brief De-initialize LED registers. * @brief De-initialize LED registers.
* @param LEDx LED Port * @param LEDx LED Port
* @retval An ErrorStatus enumeration value: * @retval An ErrorStatus enumeration value:
* - SUCCESS: LED registers are de-initialized * - SUCCESS: LED registers are de-initialized
* - ERROR: Wrong LED * - ERROR: Wrong LED
*/ */
ErrorStatus LL_LED_DeInit(LED_TypeDef *LEDx) ErrorStatus LL_LED_DeInit(LED_TypeDef *LEDx)
{ {
ErrorStatus status = SUCCESS; ErrorStatus status = SUCCESS;
/* Check the parameters */ /* Check the parameters */
assert_param(IS_LED_ALL_INSTANCE(LEDx)); assert_param(IS_LED_ALL_INSTANCE(LEDx));
/* Force and Release reset on clock of LEDx */ /* Force and Release reset on clock of LEDx */
if (LEDx == LED) if (LEDx == LED)
{ {
LL_APB1_GRP2_ForceReset(LL_APB1_GRP2_PERIPH_LED); LL_APB1_GRP2_ForceReset(LL_APB1_GRP2_PERIPH_LED);
LL_APB1_GRP2_ReleaseReset(LL_APB1_GRP2_PERIPH_LED); LL_APB1_GRP2_ReleaseReset(LL_APB1_GRP2_PERIPH_LED);
} }
else else
{ {
status = ERROR; status = ERROR;
} }
return (status); return (status);
} }
/** /**
* @brief Initializes the LED registers according to the specified parameters in the LED_InitStruct. * @brief Initializes the LED registers according to the specified parameters in the LED_InitStruct.
* @param LEDx LEDx Instance * @param LEDx LEDx Instance
* @param LED_InitStruct pointer to a @ref LL_LED_InitTypeDef structure * @param LED_InitStruct pointer to a @ref LL_LED_InitTypeDef structure
* that contains the configuration information for the specified LED peripheral. * that contains the configuration information for the specified LED peripheral.
* @retval An ErrorStatus enumeration value: * @retval An ErrorStatus enumeration value:
* - SUCCESS: LED registers are initialized according to LED_InitStruct content * - SUCCESS: LED registers are initialized according to LED_InitStruct content
* - ERROR: Not applicable * - ERROR: Not applicable
*/ */
ErrorStatus LL_LED_Init(LED_TypeDef *LEDx, LL_LED_InitTypeDef *LED_InitStruct) ErrorStatus LL_LED_Init(LED_TypeDef *LEDx, LL_LED_InitTypeDef *LED_InitStruct)
{ {
/* Check the parameters */ /* Check the parameters */
assert_param(IS_LED_ALL_INSTANCE(LEDx)); assert_param(IS_LED_ALL_INSTANCE(LEDx));
assert_param(IS_LL_LED_COM_DRIVE(LED_InitStruct->ComDrive)); assert_param(IS_LL_LED_COM_DRIVE(LED_InitStruct->ComDrive));
assert_param(IS_LL_LED_PRESCALER(LED_InitStruct->Prescaler)); assert_param(IS_LL_LED_PRESCALER(LED_InitStruct->Prescaler));
assert_param(IS_LL_LED_COM_SELECT(LED_InitStruct->ComSelect)); assert_param(IS_LL_LED_COM_SELECT(LED_InitStruct->ComSelect));
assert_param(IS_LL_LED_LIGHT_TIME(LED_InitStruct->LightTime)); assert_param(IS_LL_LED_LIGHT_TIME(LED_InitStruct->LightTime));
assert_param(IS_LL_LED_DEAD_TIME(LED_InitStruct->DeadTime)); assert_param(IS_LL_LED_DEAD_TIME(LED_InitStruct->DeadTime));
/* LED Register config */ /* LED Register config */
MODIFY_REG(LEDx->CR, (uint32_t)(LED_CR_LED_COM_SEL | LED_CR_EHS), MODIFY_REG(LEDx->CR, (uint32_t)(LED_CR_LED_COM_SEL | LED_CR_EHS),
(LED_InitStruct->ComSelect | LED_InitStruct->ComDrive)); (LED_InitStruct->ComSelect | LED_InitStruct->ComDrive));
LL_LED_SetPrescaler(LEDx, LED_InitStruct->Prescaler); LL_LED_SetPrescaler(LEDx, LED_InitStruct->Prescaler);
LL_LED_SetLightAndDeadTime(LEDx, LED_InitStruct->LightTime, LED_InitStruct->DeadTime); LL_LED_SetLightAndDeadTime(LEDx, LED_InitStruct->LightTime, LED_InitStruct->DeadTime);
LL_LED_Enable(LEDx); LL_LED_Enable(LEDx);
return (SUCCESS); return (SUCCESS);
} }
/** /**
* @brief Set each @ref LL_LED_InitTypeDef field to default value. * @brief Set each @ref LL_LED_InitTypeDef field to default value.
* @param LED_InitStruct pointer to a @ref LL_LED_InitTypeDef structure * @param LED_InitStruct pointer to a @ref LL_LED_InitTypeDef structure
* whose fields will be set to default values. * whose fields will be set to default values.
* @retval None * @retval None
*/ */
void LL_LED_StructInit(LL_LED_InitTypeDef *LED_InitStruct) void LL_LED_StructInit(LL_LED_InitTypeDef *LED_InitStruct)
{ {
/* Reset LED init structure parameters values */ /* Reset LED init structure parameters values */
LED_InitStruct->ComDrive = LL_LED_COMDRIVE_LOW; LED_InitStruct->ComDrive = LL_LED_COMDRIVE_LOW;
LED_InitStruct->Prescaler = 0x0u; LED_InitStruct->Prescaler = 0x0u;
LED_InitStruct->ComSelect = LL_LED_COMSELECT_1COM; LED_InitStruct->ComSelect = LL_LED_COMSELECT_1COM;
LED_InitStruct->LightTime = 0x0u; LED_InitStruct->LightTime = 0x0u;
LED_InitStruct->DeadTime = 0x0u; LED_InitStruct->DeadTime = 0x0u;
} }
#endif /* defined (LED) */ #endif /* defined (LED) */
#endif /* USE_FULL_LL_DRIVER */ #endif /* USE_FULL_LL_DRIVER */
/************************ (C) COPYRIGHT Puya Semiconductor *****END OF FILE****/ /************************ (C) COPYRIGHT Puya Semiconductor *****END OF FILE****/

View File

@ -3,21 +3,21 @@
* @file py32f0xx_ll_lptim.c * @file py32f0xx_ll_lptim.c
* @author MCU Application Team * @author MCU Application Team
* @brief LPTIM LL module driver. * @brief LPTIM LL module driver.
****************************************************************************** ******************************************************************************
* @attention * @attention
* *
* <h2><center>&copy; Copyright (c) Puya Semiconductor Co. * <h2><center>&copy; Copyright (c) Puya Semiconductor Co.
* All rights reserved.</center></h2> * All rights reserved.</center></h2>
* *
* <h2><center>&copy; Copyright (c) 2016 STMicroelectronics. * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
* All rights reserved.</center></h2> * All rights reserved.</center></h2>
* *
* This software component is licensed by ST under BSD 3-Clause license, * 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 * the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at: * License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause * opensource.org/licenses/BSD-3-Clause
* *
****************************************************************************** ******************************************************************************
*/ */
#if defined(USE_FULL_LL_DRIVER) #if defined(USE_FULL_LL_DRIVER)

View File

@ -3,21 +3,21 @@
* @file py32f0xx_ll_pwr.c * @file py32f0xx_ll_pwr.c
* @author MCU Application Team * @author MCU Application Team
* @brief PWR LL module driver. * @brief PWR LL module driver.
****************************************************************************** ******************************************************************************
* @attention * @attention
* *
* <h2><center>&copy; Copyright (c) Puya Semiconductor Co. * <h2><center>&copy; Copyright (c) Puya Semiconductor Co.
* All rights reserved.</center></h2> * All rights reserved.</center></h2>
* *
* <h2><center>&copy; Copyright (c) 2016 STMicroelectronics. * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
* All rights reserved.</center></h2> * All rights reserved.</center></h2>
* *
* This software component is licensed by ST under BSD 3-Clause license, * 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 * the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at: * License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause * opensource.org/licenses/BSD-3-Clause
* *
****************************************************************************** ******************************************************************************
*/ */
#if defined(USE_FULL_LL_DRIVER) #if defined(USE_FULL_LL_DRIVER)

View File

@ -1,388 +1,388 @@
/** /**
****************************************************************************** ******************************************************************************
* @file py32f0xx_ll_usart.c * @file py32f0xx_ll_usart.c
* @author MCU Application Team * @author MCU Application Team
* @brief USART LL module driver. * @brief USART LL module driver.
****************************************************************************** ******************************************************************************
* @attention * @attention
* *
* <h2><center>&copy; Copyright (c) Puya Semiconductor Co. * <h2><center>&copy; Copyright (c) Puya Semiconductor Co.
* All rights reserved.</center></h2> * All rights reserved.</center></h2>
* *
* <h2><center>&copy; Copyright (c) 2016 STMicroelectronics. * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
* All rights reserved.</center></h2> * All rights reserved.</center></h2>
* *
* This software component is licensed by ST under BSD 3-Clause license, * 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 * the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at: * License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause * opensource.org/licenses/BSD-3-Clause
* *
****************************************************************************** ******************************************************************************
*/ */
#if defined(USE_FULL_LL_DRIVER) #if defined(USE_FULL_LL_DRIVER)
/* Includes ------------------------------------------------------------------*/ /* Includes ------------------------------------------------------------------*/
#include "py32f0xx_ll_usart.h" #include "py32f0xx_ll_usart.h"
#include "py32f0xx_ll_rcc.h" #include "py32f0xx_ll_rcc.h"
#include "py32f0xx_ll_bus.h" #include "py32f0xx_ll_bus.h"
#ifdef USE_FULL_ASSERT #ifdef USE_FULL_ASSERT
#include "py32_assert.h" #include "py32_assert.h"
#else #else
#define assert_param(expr) ((void)0U) #define assert_param(expr) ((void)0U)
#endif #endif
/** @addtogroup PY32F0xx_LL_Driver /** @addtogroup PY32F0xx_LL_Driver
* @{ * @{
*/ */
#if defined (USART1) || defined (USART2) #if defined (USART1) || defined (USART2)
/** @addtogroup USART_LL /** @addtogroup USART_LL
* @{ * @{
*/ */
/* Private types -------------------------------------------------------------*/ /* Private types -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/
/* Private constants ---------------------------------------------------------*/ /* Private constants ---------------------------------------------------------*/
/** @addtogroup USART_LL_Private_Constants /** @addtogroup USART_LL_Private_Constants
* @{ * @{
*/ */
/** /**
* @} * @}
*/ */
/* Private macros ------------------------------------------------------------*/ /* Private macros ------------------------------------------------------------*/
/** @addtogroup USART_LL_Private_Macros /** @addtogroup USART_LL_Private_Macros
* @{ * @{
*/ */
/* __BAUDRATE__ The maximum Baud Rate is derived from the maximum clock available /* __BAUDRATE__ The maximum Baud Rate is derived from the maximum clock available
* divided by the smallest oversampling used on the USART (i.e. 8) */ * divided by the smallest oversampling used on the USART (i.e. 8) */
#define IS_LL_USART_BAUDRATE(__BAUDRATE__) ((__BAUDRATE__) <= 4500000U) #define IS_LL_USART_BAUDRATE(__BAUDRATE__) ((__BAUDRATE__) <= 4500000U)
/* __VALUE__ In case of oversampling by 16 and 8, BRR content must be greater than or equal to 16d. */ /* __VALUE__ In case of oversampling by 16 and 8, BRR content must be greater than or equal to 16d. */
#define IS_LL_USART_BRR_MIN(__VALUE__) ((__VALUE__) >= 16U) #define IS_LL_USART_BRR_MIN(__VALUE__) ((__VALUE__) >= 16U)
/* __VALUE__ BRR content must be lower than or equal to 0xFFFF. */ /* __VALUE__ BRR content must be lower than or equal to 0xFFFF. */
#define IS_LL_USART_BRR_MAX(__VALUE__) ((__VALUE__) <= 0x0000FFFFU) #define IS_LL_USART_BRR_MAX(__VALUE__) ((__VALUE__) <= 0x0000FFFFU)
#define IS_LL_USART_DIRECTION(__VALUE__) (((__VALUE__) == LL_USART_DIRECTION_NONE) \ #define IS_LL_USART_DIRECTION(__VALUE__) (((__VALUE__) == LL_USART_DIRECTION_NONE) \
|| ((__VALUE__) == LL_USART_DIRECTION_RX) \ || ((__VALUE__) == LL_USART_DIRECTION_RX) \
|| ((__VALUE__) == LL_USART_DIRECTION_TX) \ || ((__VALUE__) == LL_USART_DIRECTION_TX) \
|| ((__VALUE__) == LL_USART_DIRECTION_TX_RX)) || ((__VALUE__) == LL_USART_DIRECTION_TX_RX))
#define IS_LL_USART_PARITY(__VALUE__) (((__VALUE__) == LL_USART_PARITY_NONE) \ #define IS_LL_USART_PARITY(__VALUE__) (((__VALUE__) == LL_USART_PARITY_NONE) \
|| ((__VALUE__) == LL_USART_PARITY_EVEN) \ || ((__VALUE__) == LL_USART_PARITY_EVEN) \
|| ((__VALUE__) == LL_USART_PARITY_ODD)) || ((__VALUE__) == LL_USART_PARITY_ODD))
#define IS_LL_USART_DATAWIDTH(__VALUE__) (((__VALUE__) == LL_USART_DATAWIDTH_8B) \ #define IS_LL_USART_DATAWIDTH(__VALUE__) (((__VALUE__) == LL_USART_DATAWIDTH_8B) \
|| ((__VALUE__) == LL_USART_DATAWIDTH_9B)) || ((__VALUE__) == LL_USART_DATAWIDTH_9B))
#define IS_LL_USART_OVERSAMPLING(__VALUE__) (((__VALUE__) == LL_USART_OVERSAMPLING_16) \ #define IS_LL_USART_OVERSAMPLING(__VALUE__) (((__VALUE__) == LL_USART_OVERSAMPLING_16) \
|| ((__VALUE__) == LL_USART_OVERSAMPLING_8)) || ((__VALUE__) == LL_USART_OVERSAMPLING_8))
#define IS_LL_USART_LASTBITCLKOUTPUT(__VALUE__) (((__VALUE__) == LL_USART_LASTCLKPULSE_NO_OUTPUT) \ #define IS_LL_USART_LASTBITCLKOUTPUT(__VALUE__) (((__VALUE__) == LL_USART_LASTCLKPULSE_NO_OUTPUT) \
|| ((__VALUE__) == LL_USART_LASTCLKPULSE_OUTPUT)) || ((__VALUE__) == LL_USART_LASTCLKPULSE_OUTPUT))
#define IS_LL_USART_CLOCKPHASE(__VALUE__) (((__VALUE__) == LL_USART_PHASE_1EDGE) \ #define IS_LL_USART_CLOCKPHASE(__VALUE__) (((__VALUE__) == LL_USART_PHASE_1EDGE) \
|| ((__VALUE__) == LL_USART_PHASE_2EDGE)) || ((__VALUE__) == LL_USART_PHASE_2EDGE))
#define IS_LL_USART_CLOCKPOLARITY(__VALUE__) (((__VALUE__) == LL_USART_POLARITY_LOW) \ #define IS_LL_USART_CLOCKPOLARITY(__VALUE__) (((__VALUE__) == LL_USART_POLARITY_LOW) \
|| ((__VALUE__) == LL_USART_POLARITY_HIGH)) || ((__VALUE__) == LL_USART_POLARITY_HIGH))
#define IS_LL_USART_CLOCKOUTPUT(__VALUE__) (((__VALUE__) == LL_USART_CLOCK_DISABLE) \ #define IS_LL_USART_CLOCKOUTPUT(__VALUE__) (((__VALUE__) == LL_USART_CLOCK_DISABLE) \
|| ((__VALUE__) == LL_USART_CLOCK_ENABLE)) || ((__VALUE__) == LL_USART_CLOCK_ENABLE))
#define IS_LL_USART_STOPBITS(__VALUE__) (((__VALUE__) == LL_USART_STOPBITS_1) \ #define IS_LL_USART_STOPBITS(__VALUE__) (((__VALUE__) == LL_USART_STOPBITS_1) \
|| ((__VALUE__) == LL_USART_STOPBITS_2)) || ((__VALUE__) == LL_USART_STOPBITS_2))
#define IS_LL_USART_HWCONTROL(__VALUE__) (((__VALUE__) == LL_USART_HWCONTROL_NONE) \ #define IS_LL_USART_HWCONTROL(__VALUE__) (((__VALUE__) == LL_USART_HWCONTROL_NONE) \
|| ((__VALUE__) == LL_USART_HWCONTROL_RTS) \ || ((__VALUE__) == LL_USART_HWCONTROL_RTS) \
|| ((__VALUE__) == LL_USART_HWCONTROL_CTS) \ || ((__VALUE__) == LL_USART_HWCONTROL_CTS) \
|| ((__VALUE__) == LL_USART_HWCONTROL_RTS_CTS)) || ((__VALUE__) == LL_USART_HWCONTROL_RTS_CTS))
/** /**
* @} * @}
*/ */
/* Private function prototypes -----------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/
/* Exported functions --------------------------------------------------------*/ /* Exported functions --------------------------------------------------------*/
/** @addtogroup USART_LL_Exported_Functions /** @addtogroup USART_LL_Exported_Functions
* @{ * @{
*/ */
/** @addtogroup USART_LL_EF_Init /** @addtogroup USART_LL_EF_Init
* @{ * @{
*/ */
/** /**
* @brief De-initialize USART registers (Registers restored to their default values). * @brief De-initialize USART registers (Registers restored to their default values).
* @param USARTx USART Instance * @param USARTx USART Instance
* @retval An ErrorStatus enumeration value: * @retval An ErrorStatus enumeration value:
* - SUCCESS: USART registers are de-initialized * - SUCCESS: USART registers are de-initialized
* - ERROR: USART registers are not de-initialized * - ERROR: USART registers are not de-initialized
*/ */
ErrorStatus LL_USART_DeInit(USART_TypeDef *USARTx) ErrorStatus LL_USART_DeInit(USART_TypeDef *USARTx)
{ {
ErrorStatus status = SUCCESS; ErrorStatus status = SUCCESS;
/* Check the parameters */ /* Check the parameters */
assert_param(IS_UART_INSTANCE(USARTx)); assert_param(IS_UART_INSTANCE(USARTx));
if (USARTx == USART1) if (USARTx == USART1)
{ {
/* Force reset of USART clock */ /* Force reset of USART clock */
LL_APB1_GRP2_ForceReset(LL_APB1_GRP2_PERIPH_USART1); LL_APB1_GRP2_ForceReset(LL_APB1_GRP2_PERIPH_USART1);
/* Release reset of USART clock */ /* Release reset of USART clock */
LL_APB1_GRP2_ReleaseReset(LL_APB1_GRP2_PERIPH_USART1); LL_APB1_GRP2_ReleaseReset(LL_APB1_GRP2_PERIPH_USART1);
} }
#if defined(USART2) #if defined(USART2)
else if (USARTx == USART2) else if (USARTx == USART2)
{ {
/* Force reset of USART clock */ /* Force reset of USART clock */
LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_USART2); LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_USART2);
/* Release reset of USART clock */ /* Release reset of USART clock */
LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_USART2); LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_USART2);
} }
#endif /* USART2 */ #endif /* USART2 */
else else
{ {
status = ERROR; status = ERROR;
} }
return (status); return (status);
} }
/** /**
* @brief Initialize USART registers according to the specified * @brief Initialize USART registers according to the specified
* parameters in USART_InitStruct. * parameters in USART_InitStruct.
* @note As some bits in USART configuration registers can only be written when the USART is disabled (USART_CR1_UE bit =0), * @note As some bits in USART configuration registers can only be written when the USART is disabled (USART_CR1_UE bit =0),
* USART IP should be in disabled state prior calling this function. Otherwise, ERROR result will be returned. * USART IP should be in disabled state prior calling this function. Otherwise, ERROR result will be returned.
* @note Baud rate value stored in USART_InitStruct BaudRate field, should be valid (different from 0). * @note Baud rate value stored in USART_InitStruct BaudRate field, should be valid (different from 0).
* @param USARTx USART Instance * @param USARTx USART Instance
* @param USART_InitStruct pointer to a LL_USART_InitTypeDef structure * @param USART_InitStruct pointer to a LL_USART_InitTypeDef structure
* that contains the configuration information for the specified USART peripheral. * that contains the configuration information for the specified USART peripheral.
* @retval An ErrorStatus enumeration value: * @retval An ErrorStatus enumeration value:
* - SUCCESS: USART registers are initialized according to USART_InitStruct content * - SUCCESS: USART registers are initialized according to USART_InitStruct content
* - ERROR: Problem occurred during USART Registers initialization * - ERROR: Problem occurred during USART Registers initialization
*/ */
ErrorStatus LL_USART_Init(USART_TypeDef *USARTx, LL_USART_InitTypeDef *USART_InitStruct) ErrorStatus LL_USART_Init(USART_TypeDef *USARTx, LL_USART_InitTypeDef *USART_InitStruct)
{ {
ErrorStatus status = ERROR; ErrorStatus status = ERROR;
uint32_t periphclk = LL_RCC_PERIPH_FREQUENCY_NO; uint32_t periphclk = LL_RCC_PERIPH_FREQUENCY_NO;
LL_RCC_ClocksTypeDef rcc_clocks; LL_RCC_ClocksTypeDef rcc_clocks;
/* Check the parameters */ /* Check the parameters */
assert_param(IS_UART_INSTANCE(USARTx)); assert_param(IS_UART_INSTANCE(USARTx));
assert_param(IS_LL_USART_BAUDRATE(USART_InitStruct->BaudRate)); assert_param(IS_LL_USART_BAUDRATE(USART_InitStruct->BaudRate));
assert_param(IS_LL_USART_DATAWIDTH(USART_InitStruct->DataWidth)); assert_param(IS_LL_USART_DATAWIDTH(USART_InitStruct->DataWidth));
assert_param(IS_LL_USART_STOPBITS(USART_InitStruct->StopBits)); assert_param(IS_LL_USART_STOPBITS(USART_InitStruct->StopBits));
assert_param(IS_LL_USART_PARITY(USART_InitStruct->Parity)); assert_param(IS_LL_USART_PARITY(USART_InitStruct->Parity));
assert_param(IS_LL_USART_DIRECTION(USART_InitStruct->TransferDirection)); assert_param(IS_LL_USART_DIRECTION(USART_InitStruct->TransferDirection));
assert_param(IS_LL_USART_HWCONTROL(USART_InitStruct->HardwareFlowControl)); assert_param(IS_LL_USART_HWCONTROL(USART_InitStruct->HardwareFlowControl));
#if defined(USART_CR3_OVER8) #if defined(USART_CR3_OVER8)
assert_param(IS_LL_USART_OVERSAMPLING(USART_InitStruct->OverSampling)); assert_param(IS_LL_USART_OVERSAMPLING(USART_InitStruct->OverSampling));
#endif /* USART_OverSampling_Feature */ #endif /* USART_OverSampling_Feature */
/* USART needs to be in disabled state, in order to be able to configure some bits in /* USART needs to be in disabled state, in order to be able to configure some bits in
CRx registers */ CRx registers */
if (LL_USART_IsEnabled(USARTx) == 0U) if (LL_USART_IsEnabled(USARTx) == 0U)
{ {
/*---------------------------- USART CR1 Configuration ----------------------- /*---------------------------- USART CR1 Configuration -----------------------
* Configure USARTx CR1 (USART Word Length, Parity, Mode and Oversampling bits) with parameters: * Configure USARTx CR1 (USART Word Length, Parity, Mode and Oversampling bits) with parameters:
* - DataWidth: USART_CR1_M bits according to USART_InitStruct->DataWidth value * - DataWidth: USART_CR1_M bits according to USART_InitStruct->DataWidth value
* - Parity: USART_CR1_PCE, USART_CR1_PS bits according to USART_InitStruct->Parity value * - Parity: USART_CR1_PCE, USART_CR1_PS bits according to USART_InitStruct->Parity value
* - TransferDirection: USART_CR1_TE, USART_CR1_RE bits according to USART_InitStruct->TransferDirection value * - TransferDirection: USART_CR1_TE, USART_CR1_RE bits according to USART_InitStruct->TransferDirection value
* - Oversampling: USART_CR3_OVER8 bit according to USART_InitStruct->OverSampling value. * - Oversampling: USART_CR3_OVER8 bit according to USART_InitStruct->OverSampling value.
*/ */
#if defined(USART_CR3_OVER8) #if defined(USART_CR3_OVER8)
MODIFY_REG(USARTx->CR1, MODIFY_REG(USARTx->CR1,
(USART_CR1_M | USART_CR1_PCE | USART_CR1_PS | (USART_CR1_M | USART_CR1_PCE | USART_CR1_PS |
USART_CR1_TE | USART_CR1_RE), USART_CR1_TE | USART_CR1_RE),
(USART_InitStruct->DataWidth | USART_InitStruct->Parity | (USART_InitStruct->DataWidth | USART_InitStruct->Parity |
USART_InitStruct->TransferDirection)); USART_InitStruct->TransferDirection));
MODIFY_REG(USARTx->CR3, USART_CR3_OVER8, USART_InitStruct->OverSampling); MODIFY_REG(USARTx->CR3, USART_CR3_OVER8, USART_InitStruct->OverSampling);
#else #else
MODIFY_REG(USARTx->CR1, MODIFY_REG(USARTx->CR1,
(USART_CR1_M | USART_CR1_PCE | USART_CR1_PS | (USART_CR1_M | USART_CR1_PCE | USART_CR1_PS |
USART_CR1_TE | USART_CR1_RE), USART_CR1_TE | USART_CR1_RE),
(USART_InitStruct->DataWidth | USART_InitStruct->Parity | (USART_InitStruct->DataWidth | USART_InitStruct->Parity |
USART_InitStruct->TransferDirection)); USART_InitStruct->TransferDirection));
#endif /* USART_OverSampling_Feature */ #endif /* USART_OverSampling_Feature */
/*---------------------------- USART CR2 Configuration ----------------------- /*---------------------------- USART CR2 Configuration -----------------------
* Configure USARTx CR2 (Stop bits) with parameters: * Configure USARTx CR2 (Stop bits) with parameters:
* - Stop Bits: USART_CR2_STOP bits according to USART_InitStruct->StopBits value. * - Stop Bits: USART_CR2_STOP bits according to USART_InitStruct->StopBits value.
* - CLKEN, CPOL, CPHA and LBCL bits are to be configured using LL_USART_ClockInit(). * - CLKEN, CPOL, CPHA and LBCL bits are to be configured using LL_USART_ClockInit().
*/ */
LL_USART_SetStopBitsLength(USARTx, USART_InitStruct->StopBits); LL_USART_SetStopBitsLength(USARTx, USART_InitStruct->StopBits);
/*---------------------------- USART CR3 Configuration ----------------------- /*---------------------------- USART CR3 Configuration -----------------------
* Configure USARTx CR3 (Hardware Flow Control) with parameters: * Configure USARTx CR3 (Hardware Flow Control) with parameters:
* - HardwareFlowControl: USART_CR3_RTSE, USART_CR3_CTSE bits according to USART_InitStruct->HardwareFlowControl value. * - HardwareFlowControl: USART_CR3_RTSE, USART_CR3_CTSE bits according to USART_InitStruct->HardwareFlowControl value.
*/ */
LL_USART_SetHWFlowCtrl(USARTx, USART_InitStruct->HardwareFlowControl); LL_USART_SetHWFlowCtrl(USARTx, USART_InitStruct->HardwareFlowControl);
/*---------------------------- USART BRR Configuration ----------------------- /*---------------------------- USART BRR Configuration -----------------------
* Retrieve Clock frequency used for USART Peripheral * Retrieve Clock frequency used for USART Peripheral
*/ */
LL_RCC_GetSystemClocksFreq(&rcc_clocks); LL_RCC_GetSystemClocksFreq(&rcc_clocks);
periphclk = rcc_clocks.PCLK1_Frequency; periphclk = rcc_clocks.PCLK1_Frequency;
/* Configure the USART Baud Rate : /* Configure the USART Baud Rate :
- valid baud rate value (different from 0) is required - valid baud rate value (different from 0) is required
- Peripheral clock as returned by RCC service, should be valid (different from 0). - Peripheral clock as returned by RCC service, should be valid (different from 0).
*/ */
if ((periphclk != LL_RCC_PERIPH_FREQUENCY_NO) if ((periphclk != LL_RCC_PERIPH_FREQUENCY_NO)
&& (USART_InitStruct->BaudRate != 0U)) && (USART_InitStruct->BaudRate != 0U))
{ {
status = SUCCESS; status = SUCCESS;
#if defined(USART_CR3_OVER8) #if defined(USART_CR3_OVER8)
LL_USART_SetBaudRate(USARTx, LL_USART_SetBaudRate(USARTx,
periphclk, periphclk,
USART_InitStruct->OverSampling, USART_InitStruct->OverSampling,
USART_InitStruct->BaudRate); USART_InitStruct->BaudRate);
#else #else
LL_USART_SetBaudRate(USARTx, LL_USART_SetBaudRate(USARTx,
periphclk, periphclk,
USART_InitStruct->BaudRate); USART_InitStruct->BaudRate);
#endif /* USART_OverSampling_Feature */ #endif /* USART_OverSampling_Feature */
/* Check BRR is greater than or equal to 16d */ /* Check BRR is greater than or equal to 16d */
assert_param(IS_LL_USART_BRR_MIN(USARTx->BRR)); assert_param(IS_LL_USART_BRR_MIN(USARTx->BRR));
/* Check BRR is greater than or equal to 16d */ /* Check BRR is greater than or equal to 16d */
assert_param(IS_LL_USART_BRR_MAX(USARTx->BRR)); assert_param(IS_LL_USART_BRR_MAX(USARTx->BRR));
} }
} }
/* Endif (=> USART not in Disabled state => return ERROR) */ /* Endif (=> USART not in Disabled state => return ERROR) */
return (status); return (status);
} }
/** /**
* @brief Set each @ref LL_USART_InitTypeDef field to default value. * @brief Set each @ref LL_USART_InitTypeDef field to default value.
* @param USART_InitStruct Pointer to a @ref LL_USART_InitTypeDef structure * @param USART_InitStruct Pointer to a @ref LL_USART_InitTypeDef structure
* whose fields will be set to default values. * whose fields will be set to default values.
* @retval None * @retval None
*/ */
void LL_USART_StructInit(LL_USART_InitTypeDef *USART_InitStruct) void LL_USART_StructInit(LL_USART_InitTypeDef *USART_InitStruct)
{ {
/* Set USART_InitStruct fields to default values */ /* Set USART_InitStruct fields to default values */
USART_InitStruct->BaudRate = 9600U; USART_InitStruct->BaudRate = 9600U;
USART_InitStruct->DataWidth = LL_USART_DATAWIDTH_8B; USART_InitStruct->DataWidth = LL_USART_DATAWIDTH_8B;
USART_InitStruct->StopBits = LL_USART_STOPBITS_1; USART_InitStruct->StopBits = LL_USART_STOPBITS_1;
USART_InitStruct->Parity = LL_USART_PARITY_NONE ; USART_InitStruct->Parity = LL_USART_PARITY_NONE ;
USART_InitStruct->TransferDirection = LL_USART_DIRECTION_TX_RX; USART_InitStruct->TransferDirection = LL_USART_DIRECTION_TX_RX;
USART_InitStruct->HardwareFlowControl = LL_USART_HWCONTROL_NONE; USART_InitStruct->HardwareFlowControl = LL_USART_HWCONTROL_NONE;
#if defined(USART_CR3_OVER8) #if defined(USART_CR3_OVER8)
USART_InitStruct->OverSampling = LL_USART_OVERSAMPLING_16; USART_InitStruct->OverSampling = LL_USART_OVERSAMPLING_16;
#endif /* USART_OverSampling_Feature */ #endif /* USART_OverSampling_Feature */
} }
/** /**
* @brief Initialize USART Clock related settings according to the * @brief Initialize USART Clock related settings according to the
* specified parameters in the USART_ClockInitStruct. * specified parameters in the USART_ClockInitStruct.
* @note As some bits in USART configuration registers can only be written when the USART is disabled (USART_CR1_UE bit =0), * @note As some bits in USART configuration registers can only be written when the USART is disabled (USART_CR1_UE bit =0),
* USART IP should be in disabled state prior calling this function. Otherwise, ERROR result will be returned. * USART IP should be in disabled state prior calling this function. Otherwise, ERROR result will be returned.
* @param USARTx USART Instance * @param USARTx USART Instance
* @param USART_ClockInitStruct Pointer to a @ref LL_USART_ClockInitTypeDef structure * @param USART_ClockInitStruct Pointer to a @ref LL_USART_ClockInitTypeDef structure
* that contains the Clock configuration information for the specified USART peripheral. * that contains the Clock configuration information for the specified USART peripheral.
* @retval An ErrorStatus enumeration value: * @retval An ErrorStatus enumeration value:
* - SUCCESS: USART registers related to Clock settings are initialized according to USART_ClockInitStruct content * - SUCCESS: USART registers related to Clock settings are initialized according to USART_ClockInitStruct content
* - ERROR: Problem occurred during USART Registers initialization * - ERROR: Problem occurred during USART Registers initialization
*/ */
ErrorStatus LL_USART_ClockInit(USART_TypeDef *USARTx, LL_USART_ClockInitTypeDef *USART_ClockInitStruct) ErrorStatus LL_USART_ClockInit(USART_TypeDef *USARTx, LL_USART_ClockInitTypeDef *USART_ClockInitStruct)
{ {
ErrorStatus status = SUCCESS; ErrorStatus status = SUCCESS;
/* Check USART Instance and Clock signal output parameters */ /* Check USART Instance and Clock signal output parameters */
assert_param(IS_UART_INSTANCE(USARTx)); assert_param(IS_UART_INSTANCE(USARTx));
assert_param(IS_LL_USART_CLOCKOUTPUT(USART_ClockInitStruct->ClockOutput)); assert_param(IS_LL_USART_CLOCKOUTPUT(USART_ClockInitStruct->ClockOutput));
/* USART needs to be in disabled state, in order to be able to configure some bits in /* USART needs to be in disabled state, in order to be able to configure some bits in
CRx registers */ CRx registers */
if (LL_USART_IsEnabled(USARTx) == 0U) if (LL_USART_IsEnabled(USARTx) == 0U)
{ {
/*---------------------------- USART CR2 Configuration -----------------------*/ /*---------------------------- USART CR2 Configuration -----------------------*/
/* If Clock signal has to be output */ /* If Clock signal has to be output */
if (USART_ClockInitStruct->ClockOutput == LL_USART_CLOCK_DISABLE) if (USART_ClockInitStruct->ClockOutput == LL_USART_CLOCK_DISABLE)
{ {
/* Deactivate Clock signal delivery : /* Deactivate Clock signal delivery :
* - Disable Clock Output: USART_CR2_CLKEN cleared * - Disable Clock Output: USART_CR2_CLKEN cleared
*/ */
LL_USART_DisableSCLKOutput(USARTx); LL_USART_DisableSCLKOutput(USARTx);
} }
else else
{ {
/* Ensure USART instance is USART capable */ /* Ensure USART instance is USART capable */
assert_param(IS_USART_INSTANCE(USARTx)); assert_param(IS_USART_INSTANCE(USARTx));
/* Check clock related parameters */ /* Check clock related parameters */
assert_param(IS_LL_USART_CLOCKPOLARITY(USART_ClockInitStruct->ClockPolarity)); assert_param(IS_LL_USART_CLOCKPOLARITY(USART_ClockInitStruct->ClockPolarity));
assert_param(IS_LL_USART_CLOCKPHASE(USART_ClockInitStruct->ClockPhase)); assert_param(IS_LL_USART_CLOCKPHASE(USART_ClockInitStruct->ClockPhase));
assert_param(IS_LL_USART_LASTBITCLKOUTPUT(USART_ClockInitStruct->LastBitClockPulse)); assert_param(IS_LL_USART_LASTBITCLKOUTPUT(USART_ClockInitStruct->LastBitClockPulse));
/*---------------------------- USART CR2 Configuration ----------------------- /*---------------------------- USART CR2 Configuration -----------------------
* Configure USARTx CR2 (Clock signal related bits) with parameters: * Configure USARTx CR2 (Clock signal related bits) with parameters:
* - Enable Clock Output: USART_CR2_CLKEN set * - Enable Clock Output: USART_CR2_CLKEN set
* - Clock Polarity: USART_CR2_CPOL bit according to USART_ClockInitStruct->ClockPolarity value * - Clock Polarity: USART_CR2_CPOL bit according to USART_ClockInitStruct->ClockPolarity value
* - Clock Phase: USART_CR2_CPHA bit according to USART_ClockInitStruct->ClockPhase value * - Clock Phase: USART_CR2_CPHA bit according to USART_ClockInitStruct->ClockPhase value
* - Last Bit Clock Pulse Output: USART_CR2_LBCL bit according to USART_ClockInitStruct->LastBitClockPulse value. * - Last Bit Clock Pulse Output: USART_CR2_LBCL bit according to USART_ClockInitStruct->LastBitClockPulse value.
*/ */
MODIFY_REG(USARTx->CR2, MODIFY_REG(USARTx->CR2,
USART_CR2_CLKEN | USART_CR2_CPHA | USART_CR2_CPOL | USART_CR2_LBCL, USART_CR2_CLKEN | USART_CR2_CPHA | USART_CR2_CPOL | USART_CR2_LBCL,
USART_CR2_CLKEN | USART_ClockInitStruct->ClockPolarity | USART_CR2_CLKEN | USART_ClockInitStruct->ClockPolarity |
USART_ClockInitStruct->ClockPhase | USART_ClockInitStruct->LastBitClockPulse); USART_ClockInitStruct->ClockPhase | USART_ClockInitStruct->LastBitClockPulse);
} }
} }
/* Else (USART not in Disabled state => return ERROR */ /* Else (USART not in Disabled state => return ERROR */
else else
{ {
status = ERROR; status = ERROR;
} }
return (status); return (status);
} }
/** /**
* @brief Set each field of a @ref LL_USART_ClockInitTypeDef type structure to default value. * @brief Set each field of a @ref LL_USART_ClockInitTypeDef type structure to default value.
* @param USART_ClockInitStruct Pointer to a @ref LL_USART_ClockInitTypeDef structure * @param USART_ClockInitStruct Pointer to a @ref LL_USART_ClockInitTypeDef structure
* whose fields will be set to default values. * whose fields will be set to default values.
* @retval None * @retval None
*/ */
void LL_USART_ClockStructInit(LL_USART_ClockInitTypeDef *USART_ClockInitStruct) void LL_USART_ClockStructInit(LL_USART_ClockInitTypeDef *USART_ClockInitStruct)
{ {
/* Set LL_USART_ClockInitStruct fields with default values */ /* Set LL_USART_ClockInitStruct fields with default values */
USART_ClockInitStruct->ClockOutput = LL_USART_CLOCK_DISABLE; USART_ClockInitStruct->ClockOutput = LL_USART_CLOCK_DISABLE;
USART_ClockInitStruct->ClockPolarity = LL_USART_POLARITY_LOW; /* Not relevant when ClockOutput = LL_USART_CLOCK_DISABLE */ USART_ClockInitStruct->ClockPolarity = LL_USART_POLARITY_LOW; /* Not relevant when ClockOutput = LL_USART_CLOCK_DISABLE */
USART_ClockInitStruct->ClockPhase = LL_USART_PHASE_1EDGE; /* Not relevant when ClockOutput = LL_USART_CLOCK_DISABLE */ USART_ClockInitStruct->ClockPhase = LL_USART_PHASE_1EDGE; /* Not relevant when ClockOutput = LL_USART_CLOCK_DISABLE */
USART_ClockInitStruct->LastBitClockPulse = LL_USART_LASTCLKPULSE_NO_OUTPUT; /* Not relevant when ClockOutput = LL_USART_CLOCK_DISABLE */ USART_ClockInitStruct->LastBitClockPulse = LL_USART_LASTCLKPULSE_NO_OUTPUT; /* Not relevant when ClockOutput = LL_USART_CLOCK_DISABLE */
} }
/** /**
* @} * @}
*/ */
/** /**
* @} * @}
*/ */
/** /**
* @} * @}
*/ */
#endif /* USART1 || USART2 || USART3 || UART4 || UART5 */ #endif /* USART1 || USART2 || USART3 || UART4 || UART5 */
/** /**
* @} * @}
*/ */
#endif /* USE_FULL_LL_DRIVER */ #endif /* USE_FULL_LL_DRIVER */
/************************ (C) COPYRIGHT Puya *****END OF FILE****/ /************************ (C) COPYRIGHT Puya *****END OF FILE****/

View File

@ -7,6 +7,8 @@ BUILD_DIR = Build
##### Options ##### ##### Options #####
# Use LL library instead of HAL
USE_LL_LIB ?= y
# Enable printf float %f support, y:yes, n:no # Enable printf float %f support, y:yes, n:no
ENABLE_PRINTF_FLOAT ?= n ENABLE_PRINTF_FLOAT ?= n
# Build with CMSIS DSP functions, y:yes, n:no # Build with CMSIS DSP functions, y:yes, n:no
@ -39,9 +41,7 @@ LIB_FLAGS = PY32F003x8
# C source folders # C source folders
CDIRS := User \ CDIRS := User \
Libraries/CMSIS/Device/PY32F0xx/Source \ Libraries/CMSIS/Device/PY32F0xx/Source
Libraries/PY32F0xx_HAL_Driver/Src \
Libraries/BSP/Src
# C source files (if there are any single ones) # C source files (if there are any single ones)
CFILES := CFILES :=
@ -53,10 +53,20 @@ AFILES := Libraries/CMSIS/Device/PY32F0xx/Source/gcc/startup_py32f003.s
# Include paths # Include paths
INCLUDES := Libraries/CMSIS/Include \ INCLUDES := Libraries/CMSIS/Include \
Libraries/CMSIS/Device/PY32F0xx/Include \ Libraries/CMSIS/Device/PY32F0xx/Include \
Libraries/PY32F0xx_HAL_Driver/Inc \
Libraries/BSP/Inc \
User User
ifeq ($(USE_LL_LIB),y)
CDIRS += Libraries/PY32F0xx_LL_Driver/Src \
Libraries/BSP_LL/Src
INCLUDES += Libraries/PY32F0xx_LL_Driver/Inc \
Libraries/BSP_LL/Inc
else
CDIRS += Libraries/PY32F0xx_HAL_Driver/Src \
Libraries/BSP/Src
INCLUDES += Libraries/PY32F0xx_HAL_Driver/Inc \
Libraries/BSP/Inc
endif
ifeq ($(USE_DSP),y) ifeq ($(USE_DSP),y)
LIB_FLAGS += ARM_MATH_CM0PLUS LIB_FLAGS += ARM_MATH_CM0PLUS
CDIRS += Libraries/CMSIS/DSP_Lib/Source/BasicMathFunctions \ CDIRS += Libraries/CMSIS/DSP_Lib/Source/BasicMathFunctions \