为复旦微电子FM33LC0XX添加BSP。包含UART驱动,已经在板子上测试通过。

This commit is contained in:
1
2021-08-20 16:37:50 +08:00
parent 05098bd5a1
commit 91ffe90af3
163 changed files with 68487 additions and 1101 deletions
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,40 @@
// File: STM32F0x1_0x2_0x8.dbgconf
// Version: 1.0.0
// Note: refer to STM32F0x1/STM32F0x2/STM32F0x8 Reference manual (RM0091)
// refer to STM32F031x4/x6, STM32F051x4/x6/x8, STM32F071x8/xB datasheets
// STM32F091xB/xC, STM32F042x4/x6, STM32F072x8/xB, STM32F038x6 datasheets
// STM32F048x6, STM32F058x8, STM32F078xB, STM32F098xC datasheets
// <<< Use Configuration Wizard in Context Menu >>>
// <h> Debug MCU configuration register (DBGMCU_CR)
// <o.2> DBG_STANDBY <i> Debug standby mode
// <o.1> DBG_STOP <i> Debug stop mode
// </h>
DbgMCU_CR = 0x00000006;
// <h> Debug MCU APB1 freeze register (DBGMCU_APB1_FZ)
// <i> Reserved bits must be kept at reset value
// <o.25> DBG_CAN_STOP <i> CAN stopped when core is halted
// <o.21> DBG_I2C1_TIMEOUT <i> I2C1 SMBUS timeout mode stopped when core is halted
// <o.12> DBG_IWDG_STOP <i> Independent watchdog stopped when core is halted
// <o.11> DBG_WWDG_STOP <i> Window watchdog stopped when core is halted
// <o.10> DBG_RTC_STOP <i> RTC stopped when core is halted
// <o.8> DBG_TIM14_STOP <i> TIM14 counter stopped when core is halted
// <o.5> DBG_TIM7_STOP <i> TIM7 counter stopped when core is halted
// <o.4> DBG_TIM6_STOP <i> TIM6 counter stopped when core is halted
// <o.1> DBG_TIM3_STOP <i> TIM3 counter stopped when core is halted
// <o.0> DBG_TIM2_STOP <i> TIM2 counter stopped when core is halted
// </h>
DbgMCU_APB1_Fz = 0x00000000;
// <h> Debug MCU APB2 freeze register (DBGMCU_APB2_FZ)
// <i> Reserved bits must be kept at reset value
// <o.18> DBG_TIM17_STOP <i> TIM17 counter stopped when core is halted
// <o.17> DBG_TIM16_STOP <i> TIM16 counter stopped when core is halted
// <o.16> DBG_TIM15_STOP <i> TIM15 counter stopped when core is halted
// <o.11> DBG_TIM1_STOP <i> TIM1 counter stopped when core is halted
// </h>
DbgMCU_APB2_Fz = 0x00000000;
// <<< end of configuration section >>>
+22
View File
@@ -0,0 +1,22 @@
mainmenu "RT-Thread Configuration"
config BSP_DIR
string
option env="BSP_ROOT"
default "."
config RTT_DIR
string
option env="RTT_ROOT"
default "../.."
config PKGS_DIR
string
option env="PKGS_ROOT"
default "packages"
source "$RTT_DIR/Kconfig"
source "$PKGS_DIR/Kconfig"
source "libraries/Kconfig"
source "board/Kconfig"
+15
View File
@@ -0,0 +1,15 @@
# for module compiling
import os
Import('RTT_ROOT')
from building import *
cwd = GetCurrentDir()
objs = []
list = os.listdir(cwd)
for d in list:
path = os.path.join(cwd, d)
if os.path.isfile(os.path.join(path, 'SConscript')):
objs = objs + SConscript(os.path.join(d, 'SConscript'))
Return('objs')
+60
View File
@@ -0,0 +1,60 @@
import os
import sys
import rtconfig
if os.getenv('RTT_ROOT'):
RTT_ROOT = os.getenv('RTT_ROOT')
else:
RTT_ROOT = os.path.normpath(os.getcwd() + '/../..')
sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
try:
from building import *
except:
print('Cannot found RT-Thread root directory, please check RTT_ROOT')
print(RTT_ROOT)
exit(-1)
TARGET = 'rt-thread.' + rtconfig.TARGET_EXT
DefaultEnvironment(tools=[])
env = Environment(tools = ['mingw'],
AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS,
AR = rtconfig.AR, ARFLAGS = '-rc',
CXX = rtconfig.CXX, CXXFLAGS = rtconfig.CXXFLAGS,
LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
if rtconfig.PLATFORM == 'iar':
env.Replace(CCCOM = ['$CC $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -o $TARGET $SOURCES'])
env.Replace(ARFLAGS = [''])
env.Replace(LINKCOM = ['$LINK $SOURCES $LINKFLAGS -o $TARGET --map rt-thread.map'])
Export('RTT_ROOT')
Export('rtconfig')
SDK_ROOT = os.path.abspath('./')
if os.path.exists(SDK_ROOT + '/libraries'):
libraries_path_prefix = SDK_ROOT + '/libraries'
else:
libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries'
SDK_LIB = libraries_path_prefix
Export('SDK_LIB')
# prepare building environment
objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False)
stm32_library = 'FM33LC0xx_FL_Driver'
rtconfig.BSP_LIBRARY_TYPE = stm32_library
# include libraries
objs.extend(SConscript(os.path.join(libraries_path_prefix, stm32_library, 'SConscript')))
# include drivers
objs.extend(SConscript(os.path.join(libraries_path_prefix, 'HAL_Drivers', 'SConscript')))
# make a building
DoBuilding(TARGET, objs)
+9
View File
@@ -0,0 +1,9 @@
from building import *
cwd = GetCurrentDir()
src = Glob('*.c') + Glob('*.cpp')
CPPPATH = [cwd]
group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH)
Return('group')
+45
View File
@@ -0,0 +1,45 @@
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-11-06 zylx first version
*/
#include <rtthread.h>
#include <rtdevice.h>
#include "fm33lc0xx_fl_gpio.h"
#include "fm33lc0xx_fl_flash.h"
#include "main.h"
static void LED_init(void)
{
FL_GPIO_InitTypeDef GPIO_InitStruct = {0};
FL_GPIO_SetOutputPin(GPIOD,FL_GPIO_PIN_4);
GPIO_InitStruct.pin = FL_GPIO_PIN_4;
GPIO_InitStruct.mode = FL_GPIO_MODE_OUTPUT;
GPIO_InitStruct.outputType = FL_GPIO_OUTPUT_PUSHPULL;
GPIO_InitStruct.pull = FL_DISABLE;
FL_GPIO_Init(GPIOD, &GPIO_InitStruct);
}
int main(void)
{
LED_init();
while (1)
{
FL_GPIO_SetOutputPin(GPIOD,FL_GPIO_PIN_4);
rt_thread_mdelay(500);
FL_GPIO_ResetOutputPin(GPIOD,FL_GPIO_PIN_4);
rt_thread_mdelay(500);
}
// return RT_EOK;
}
+39
View File
@@ -0,0 +1,39 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file : main.h
* @brief : Header for main.c file.
* This file contains the common defines of the application.
******************************************************************************
* @attention
*
* Copyright (c) [2019] [Fudan Microelectronics]
* THIS SOFTWARE is licensed under the Mulan PSL v1.
* can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MAIN_H
#define __MAIN_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif /* __MAIN_H */
/************************ (C) COPYRIGHT FMSH *****END OF FILE****/
+45
View File
@@ -0,0 +1,45 @@
menu "Hardware Drivers Config"
config SOC_FM33LC0XX
bool
select SOC_SERIES_FM33LC0XX
select RT_USING_COMPONENTS_INIT
select RT_USING_USER_MAIN
default y
menu "Onboard Peripheral Drivers"
endmenu
menu "On-chip Peripheral Drivers"
menuconfig BSP_USING_UART
bool "Enable UART"
default y
select RT_USING_SERIAL
if BSP_USING_UART
config BSP_USING_UART0
bool "Enable UART0"
default n
config BSP_USING_UART1
bool "Enable UART1"
default y
config BSP_USING_UART4
bool "Enable UART4"
default n
config BSP_USING_UART5
bool "Enable UART5"
default y
endif
source "libraries/HAL_Drivers/Kconfig"
endmenu
menu "Board extended module Drivers"
endmenu
endmenu
+29
View File
@@ -0,0 +1,29 @@
import os
import rtconfig
from building import *
Import('SDK_LIB')
cwd = GetCurrentDir()
# add general drivers
src = Split('''
board.c
''')
path = [cwd]
startup_path_prefix = SDK_LIB
if rtconfig.CROSS_TOOL == 'gcc':
src += [startup_path_prefix + '/FM/FM33xx/Source/Templates/gcc/startup_fm33lc0xx.s']
elif rtconfig.CROSS_TOOL == 'keil':
src += [startup_path_prefix + '/FM/FM33xx/Source/Templates/ARM/startup_fm33lc0xx.s']
elif rtconfig.CROSS_TOOL == 'iar':
src += [startup_path_prefix + '/FM/FM33xx/Source/Templates/iar/startup_fm33lc0xx.s']
# FM33LC0XX
# You can select chips from the list above
CPPDEFINES = ['FM33LC0XX']
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES)
Return('group')
+154
View File
@@ -0,0 +1,154 @@
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-12-21 zylx first version
*/
#include "board.h"
FL_ErrorStatus FL_UART_GPIO_Init(UART_Type *UARTx)
{
FL_ErrorStatus status = FL_FAIL;
FL_GPIO_InitTypeDef GPIO_InitStruct;
if(UARTx == UART0)
{
GPIO_InitStruct.pin = FL_GPIO_PIN_13;
GPIO_InitStruct.mode = FL_GPIO_MODE_DIGITAL;
GPIO_InitStruct.outputType = FL_GPIO_OUTPUT_PUSHPULL;
GPIO_InitStruct.pull = FL_DISABLE;
GPIO_InitStruct.remapPin = FL_DISABLE;
status = FL_GPIO_Init( GPIOA, &GPIO_InitStruct );
GPIO_InitStruct.pin = FL_GPIO_PIN_14;
GPIO_InitStruct.mode = FL_GPIO_MODE_DIGITAL;
GPIO_InitStruct.outputType = FL_GPIO_OUTPUT_PUSHPULL;
GPIO_InitStruct.pull = FL_DISABLE;
GPIO_InitStruct.remapPin = FL_DISABLE;
status = FL_GPIO_Init( GPIOA, &GPIO_InitStruct );
}
else if(UARTx == UART1)
{
GPIO_InitStruct.pin = FL_GPIO_PIN_13;
GPIO_InitStruct.mode = FL_GPIO_MODE_DIGITAL;
GPIO_InitStruct.outputType = FL_GPIO_OUTPUT_PUSHPULL;
GPIO_InitStruct.pull = FL_DISABLE;
GPIO_InitStruct.remapPin = FL_DISABLE;
status = FL_GPIO_Init( GPIOB, &GPIO_InitStruct );
GPIO_InitStruct.pin = FL_GPIO_PIN_14;
GPIO_InitStruct.mode = FL_GPIO_MODE_DIGITAL;
GPIO_InitStruct.outputType = FL_GPIO_OUTPUT_PUSHPULL;
GPIO_InitStruct.pull = FL_DISABLE;
GPIO_InitStruct.remapPin = FL_DISABLE;
status = FL_GPIO_Init( GPIOB, &GPIO_InitStruct );
}
else if(UARTx == UART4)
{
GPIO_InitStruct.pin = FL_GPIO_PIN_0;
GPIO_InitStruct.mode = FL_GPIO_MODE_DIGITAL;
GPIO_InitStruct.outputType = FL_GPIO_OUTPUT_PUSHPULL;
GPIO_InitStruct.pull = FL_DISABLE;
GPIO_InitStruct.remapPin = FL_DISABLE;
status = FL_GPIO_Init( GPIOA, &GPIO_InitStruct );
GPIO_InitStruct.pin = FL_GPIO_PIN_1;
GPIO_InitStruct.mode = FL_GPIO_MODE_DIGITAL;
GPIO_InitStruct.outputType = FL_GPIO_OUTPUT_PUSHPULL;
GPIO_InitStruct.pull = FL_DISABLE;
GPIO_InitStruct.remapPin = FL_DISABLE;
status = FL_GPIO_Init( GPIOA, &GPIO_InitStruct );
}
return status;
}
static void RCC_PLL_ConfigDomain_SYS(uint32_t Source, uint32_t PLL_R, uint32_t PLL_DB, uint32_t PLL_O)
{
MODIFY_REG(RCC->PLLCR, RCC_PLLCR_DB_Msk | RCC_PLLCR_REFPRSC_Msk | RCC_PLLCR_OSEL_Msk | RCC_PLLCR_INSEL_Msk,
(PLL_DB << RCC_PLLCR_DB_Pos) | PLL_R | PLL_O | Source);
}
static void RCHFInit(uint32_t clock)
{
switch(clock)
{
case FL_RCC_RCHF_FREQUENCY_8MHZ:
FL_RCC_RCHF_WriteTrimValue(RCHF8M_TRIM);
break;
case FL_RCC_RCHF_FREQUENCY_16MHZ:
FL_RCC_RCHF_WriteTrimValue(RCHF16M_TRIM);
break;
case FL_RCC_RCHF_FREQUENCY_24MHZ:
FL_RCC_RCHF_WriteTrimValue(RCHF24M_TRIM);
break;
default:
FL_RCC_RCHF_WriteTrimValue(RCHF8M_TRIM);
break;
}
FL_RCC_RCHF_SetFrequency(clock);
}
void SelRCHFToPLL(uint32_t rchf, uint32_t clock)
{
uint32_t div = FL_RCC_PLL_PSC_DIV8;
if(clock > 64) { return; }
RCHFInit(rchf);
switch(rchf)
{
case FL_RCC_RCHF_FREQUENCY_16MHZ:
div = FL_RCC_PLL_PSC_DIV16;
break;
case FL_RCC_RCHF_FREQUENCY_24MHZ:
div = FL_RCC_PLL_PSC_DIV24;
break;
default:
break;
}
if(clock <= 24)
{
FL_FLASH_SetReadWait(FLASH, FL_FLASH_READ_WAIT_0CYCLE);
}
else
if((clock > 24) && (clock <= 48))
{
FL_FLASH_SetReadWait(FLASH, FL_FLASH_READ_WAIT_1CYCLE);
}
else
{
FL_FLASH_SetReadWait(FLASH, FL_FLASH_READ_WAIT_1CYCLE);
}
RCC_PLL_ConfigDomain_SYS(FL_RCC_PLL_CLK_SOURCE_RCHF, div, clock, FL_RCC_PLL_OUTPUT_X1);
FL_RCC_PLL_Enable();
while(FL_RCC_IsActiveFlag_PLLReady() != FL_SET);
FL_RCC_SetAHBPrescaler(FL_RCC_AHBCLK_PSC_DIV1);
FL_RCC_SetAPB1Prescaler(FL_RCC_APB1CLK_PSC_DIV1);
FL_RCC_SetAPB2Prescaler(FL_RCC_APB2CLK_PSC_DIV1);
FL_RCC_SetSystemClockSource(FL_RCC_SYSTEM_CLK_SOURCE_PLL);
}
+26
View File
@@ -0,0 +1,26 @@
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-11-5 SummerGift first version
*/
#ifndef __BOARD_H__
#define __BOARD_H__
#include <rtthread.h>
#include "fm33lc0xx_fl.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif /* __BOARD_H__ */
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,41 @@
/**
****************************************************************************************************
* @file fm33_assert.h
* @author FMSH Application Team
* @brief Assert function define
****************************************************************************************************
* @attention
*
* Copyright (c) [2019] [Fudan Microelectronics]
* THIS SOFTWARE is licensed under the Mulan PSL v1.
* can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
*
****************************************************************************************************
*/
#ifndef __FM33_ASSERT_H
#define __FM33_ASSERT_H
#include "fm33xx.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef USE_FULL_ASSERT
#define assert_param(expr) do{if((expr) == 0)for(;;);}while(0)
#else
#define assert_param(expr) ((void)0U)
#endif
#ifdef __cplusplus
}
#endif
#endif
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,110 @@
/**
****************************************************************************************************
* @file fm33xx.h
* @author FMSH Application Team
* @brief Header file of FL Module
****************************************************************************************************
* @attention
*
* Copyright (c) [2019] [Fudan Microelectronics]
* THIS SOFTWARE is licensed under the Mulan PSL v1.
* can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
*
****************************************************************************************************
*/
/** @addtogroup CMSIS
* @{
*/
#ifndef __FM33xx_H
#define __FM33xx_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/** @addtogroup Library_configuration_section
* @{
*/
/**
* @brief FM33 Family
*/
#if !defined (FM33xx)
#define FM33xx
#endif /* FM33XX */
/**
* @brief CMSIS Device version number
*/
#define __FM33x0xx_CMSIS_VERSION_MAIN (0x02) /*!< [31:24] main version */
#define __FM33x0xx_CMSIS_VERSION_SUB1 (0x00) /*!< [23:16] sub1 version */
#define __FM33x0xx_CMSIS_VERSION_SUB2 (0x00) /*!< [15:8] sub2 version */
#define __FM33x0xx_CMSIS_VERSION_RC (0x00) /*!< [7:0] release candidate */
#define __FM33x0xx_CMSIS_VERSION ((__FM33x0xx_CMSIS_VERSION_MAIN << 24)\
|(__FM33x0xx_CMSIS_VERSION_SUB1 << 16)\
|(__FM33x0xx_CMSIS_VERSION_SUB2 << 8 )\
|(__FM33x0xx_CMSIS_VERSION_RC))
/**
* @}
*/
/** @addtogroup Device_Included
* @{
*/
#if defined(FM33L0XX)
#include "fm33l0xx.h"
#elif defined(FM33LC0XX)
#include "fm33lc0xx.h"
#elif defined(FM33LG0XX)
#include "fm33lg0xx.h"
#else
#error "Please select first the target FM33x0xx device used in your application (in FM33xxx.h file)"
#endif
/**
* @}
*/
/** @addtogroup Exported_macro
* @{
*/
#define SET_BIT(REG, BIT) ((REG) |= (BIT))
#define CLEAR_BIT(REG, BIT) ((REG) &= ~(BIT))
#define READ_BIT(REG, BIT) ((REG) & (BIT))
#define CLEAR_REG(REG) ((REG) = (0x0))
#define WRITE_REG(REG, VAL) ((REG) = (VAL))
#define READ_REG(REG) ((REG))
#define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK)))
/**
* @}
*/
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __FM33xx_H */
/**
* @}
*/
/************************ (C) COPYRIGHT Fudan Microelectronics *****END OF FILE****/
@@ -0,0 +1,155 @@
/**************************************************************************//**
* @file system_fm33lc0xx.h
* @brief CMSIS Cortex-M0 Device Peripheral Access Layer Header File for
* Device FM33LC0XX
* @version V2.00
* @date 15. March 2021
*
* @note
*
******************************************************************************/
/* Copyright (c) 2012 ARM LIMITED
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of ARM nor the names of its contributors may be used
to endorse or promote products derived from this software without
specific prior written permission.
*
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------*/
#ifndef SYSTEM_FM33LC0XX_H
#define SYSTEM_FM33LC0XX_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stdio.h>
#include "fm33lc0xx.h"
#define USE_LSCLK_CLOCK_SRC_XTLF
//#define SYSCLK_SRC_RC4M
//#define SYSCLK_SRC_XTHF
#define SYSCLK_SRC_RCHF
//#define SYSCLK_SRC_PLL
//#define USE_PLL_CLOCK_SRC_RCHF
//#define USE_PLL_CLOCK_SRC_XTHF
#if ((!defined(SYSCLK_SRC_RC4M)) && (!defined(SYSCLK_SRC_XTHF))&&(!defined(SYSCLK_SRC_PLL))&&(!defined(SYSCLK_SRC_RCHF)))
#error "Must select a clock source form the SYSCLK_SRC_RC4M or SYSCLK_SRC_XTHF or SYSCLK_SRC_PLL or SYSCLK_SRC_RCHF as the master clock."
#elif (((defined(SYSCLK_SRC_RC4M)) && ((defined(SYSCLK_SRC_XTHF))||(defined(SYSCLK_SRC_PLL))||(defined(SYSCLK_SRC_RCHF))))||\
((defined(SYSCLK_SRC_XTHF)) && ((defined(SYSCLK_SRC_RC4M))||(defined(SYSCLK_SRC_PLL))||(defined(SYSCLK_SRC_RCHF))))||\
((defined(SYSCLK_SRC_PLL)) && ((defined(SYSCLK_SRC_XTHF))||(defined(SYSCLK_SRC_RC4M))||(defined(SYSCLK_SRC_RCHF))))||\
((defined(SYSCLK_SRC_RCHF)) && ((defined(SYSCLK_SRC_XTHF))||(defined(SYSCLK_SRC_PLL))||(defined(SYSCLK_SRC_RC4M)))))
#error "Only one clock source can be selected as the master clock."
#endif
#if defined(SYSCLK_SRC_PLL) && !defined(USE_PLL_CLOCK_SRC_RCHF) && !defined(USE_PLL_CLOCK_SRC_XTHF)
#error "You have chosen to enable the PLL, so you need to specify the clock source for the PLL.."
#elif defined(SYSCLK_SRC_PLL) && (defined(USE_PLL_CLOCK_SRC_RCHF) && defined(USE_PLL_CLOCK_SRC_XTHF))
#error "Please select one of the USE_PLL_CLOCK_SRC_RCHF and USE_PLL_CLOCK_SRC_XTHF in your application"
#endif
#if !defined (XTHF_VALUE)
#define XTHF_VALUE ((uint32_t)8000000U) /*!< Value of the External oscillator in Hz */
#endif /* XTHF_VALUE */
#if !defined (XTLF_VALUE)
#define XTLF_VALUE ((uint32_t)32768U) /*!< Value of the Internal oscillator in Hz*/
#endif /* XTLF_VALUE */
#define LDT_CHECK(_N_VALUE_, _T_VALUE_) \
((((_N_VALUE_ >> 16) & 0xffff) == \
((~_N_VALUE_) & 0xffff)) ? _N_VALUE_ : _T_VALUE_)
#define LPOSC_LDT_TRIM (*(uint32_t *)0x1FFFFB20) // LPOSC 常温校准值
#define RCHF8M_LDT_TRIM (*(uint32_t *)0x1FFFFB40) // RC8M 常温校准值
#define RCHF16M_LDT_TRIM (*(uint32_t *)0x1FFFFB3C) // RC16M 常温校准值
#define RCHF24M_LDT_TRIM (*(uint32_t *)0x1FFFFB38) // RC24M 常温校准值
#define RCMF4M_LDT_TRIM (*(uint32_t *)0x1FFFFB44) // RCMF 常温校准值
#define LPOSC_TRIM (LDT_CHECK(LPOSC_LDT_TRIM, 0x80) & 0xff)
#define RCMF4M_TRIM (LDT_CHECK(RCMF4M_LDT_TRIM, 0x40) & 0x7f)
#define RCHF8M_TRIM (LDT_CHECK(RCHF8M_LDT_TRIM, 0x40) & 0x7f)
#define RCHF16M_TRIM (LDT_CHECK(RCHF16M_LDT_TRIM, 0x40) & 0x7f)
#define RCHF24M_TRIM (LDT_CHECK(RCHF24M_LDT_TRIM, 0x40) & 0x7f)
#define __SYSTEM_CLOCK (8000000)
/**
* @brief FL NVIC Init Sturcture definition
*/
typedef struct
{
/* 中断抢占优先级 */
uint32_t preemptPriority;
}NVIC_ConfigTypeDef;
/**
* Initialize the system
*
* @param none
* @return none
*
* @brief Setup the microcontroller system.
* Initialize the System and update the SystemCoreClock variable.
*/
void SystemInit (void);
/**
* Update SystemCoreClock variable
*
* @param none
* @return none
*
* @brief Updates the SystemCoreClock with current core Clock
* retrieved from cpu registers.
*/
extern uint32_t SystemCoreClock;
void SystemCoreClockUpdate (void);
/**
* @brief NVIC_Init config NVIC
*
* @param NVIC_configStruct configParams
*
* @param IRQn Interrupt number
*
* @retval None
*/
void NVIC_Init(NVIC_ConfigTypeDef *NVIC_configStruct,IRQn_Type IRQn);
#ifdef __cplusplus
}
#endif
#endif /* SYSTEM_FM33LC0XX_H */
@@ -0,0 +1,101 @@
/**************************************************************************//**
* @file system_FM33LG0XX.h
* @brief CMSIS Cortex-M# Device Peripheral Access Layer Header File for
* Device FM33LG0XX
* @version V1.02
* @date 31-8-2018
*
* @note
*
******************************************************************************/
/* Copyright (c) 2012 ARM LIMITED
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of ARM nor the names of its contributors may be used
to endorse or promote products derived from this software without
specific prior written permission.
*
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------*/
#ifndef SYSTEM_FM33LG0XX_H
#define SYSTEM_FM33LG0XX_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stdio.h>
#include "fm33lg0xx.h"
#if !defined (XTHF_VALUE)
#define XTHF_VALUE ((uint32_t)8000000U) /*!< Value of the External oscillator in Hz */
#endif /* XTHF_VALUE */
#if !defined (XTLF_VALUE)
#define XTLF_VALUE ((uint32_t)32768U) /*!< Value of the Internal oscillator in Hz*/
#endif /* XTLF_VALUE */
#define __SYSTEM_CLOCK (8000000)
#define DELAY_US (__SYSTEM_CLOCK/1000000)
#define DELAY_MS (__SYSTEM_CLOCK/1000)
#define Do_DelayStart() { \
uint32_t LastTick = SysTick->VAL; do {
#define While_DelayMsEnd(Count) }while(((LastTick - SysTick->VAL)&0xFFFFFF)<DELAY_MS*Count); \
}
#define While_DelayUsEnd(Count) }while(((LastTick - SysTick->VAL)&0xFFFFFF)<DELAY_US*Count); \
}
/**
* Initialize the system
*
* @param none
* @return none
*
* @brief Setup the microcontroller system.
* Initialize the System and update the SystemCoreClock variable.
*/
void SystemInit (void);
/**
* Update SystemCoreClock variable
*
* @param none
* @return none
*
* @brief Updates the SystemCoreClock with current core Clock
* retrieved from cpu registers.
*/
void SystemCoreClockUpdate (void);
#ifdef __cplusplus
}
#endif
#endif /* SYSTEM_MVCM3_H */
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,131 @@
/* Entry Point */
ENTRY(Reset_Handler)
/* Highest address of the user mode stack */
_estack = 0x20006000; /* end of RAM */
/* Generate a link error if heap and stack don't fit into RAM */
_Min_Heap_Size = 0x400; /* required amount of heap */
_Stack_Size = 0x400; /* amount of stack */
/* Specify the memory areas */
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 24K
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 64K
}
/* Define output sections */
SECTIONS
{
/* The startup code goes first into FLASH */
.isr_vector :
{
. = ALIGN(4);
KEEP(*(.isr_vector)) /* Startup code */
. = ALIGN(4);
} >FLASH
/* The program code and other data goes into FLASH */
.text :
{
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.glue_7) /* glue arm to thumb code */
*(.glue_7t) /* glue thumb to arm code */
*(.eh_frame)
KEEP (*(.init))
KEEP (*(.fini))
. = ALIGN(4);
_etext = .; /* define a global symbols at end of code */
} >FLASH
/* Constant data goes into FLASH */
.rodata :
{
. = ALIGN(4);
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
. = ALIGN(4);
} >FLASH
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
.ARM : {
__exidx_start = .;
*(.ARM.exidx*)
__exidx_end = .;
} >FLASH
.preinit_array :
{
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
} >FLASH
.init_array :
{
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
} >FLASH
.fini_array :
{
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(SORT(.fini_array.*)))
KEEP (*(.fini_array*))
PROVIDE_HIDDEN (__fini_array_end = .);
} >FLASH
/* used by the startup to initialize data */
_sidata = LOADADDR(.data);
/* Initialized data sections goes into RAM, load LMA copy after code */
.data :
{
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start */
*(.data) /* .data sections */
*(.data*) /* .data* sections */
. = ALIGN(4);
_edata = .; /* define a global symbol at data end */
} >RAM AT> FLASH
/* Uninitialized data section */
. = ALIGN(4);
.bss :
{
/* This is used by the startup in order to initialize the .bss secion */
_sbss = .; /* define a global symbol at bss start */
__bss_start__ = _sbss;
*(.bss)
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */
__bss_end__ = _ebss;
} >RAM
/* User_heap_stack section, used to check that there is enough RAM left */
. = ALIGN(8);
PROVIDE ( end = . );
PROVIDE ( _end = . );
/* system stack */
PROVIDE (_stack_base = _estack - _Stack_Size); /* _estack is top of stack*/
ASSERT ((_stack_base > end), "Error: No room left for the stack")
/* _estack is top of stack*/
/* left ram for heap */
PROVIDE (heap_start = _end);
PROVIDE (heap_end = _stack_base);
PROVIDE (heap_len = heap_end - heap_start);
ASSERT ((heap_len > _Min_Heap_Size), "Error: No room left for the heap")
.ARM.attributes 0 : { *(.ARM.attributes) }
}
@@ -0,0 +1,131 @@
/* Entry Point */
ENTRY(Reset_Handler)
/* Highest address of the user mode stack */
_estack = 0x20006000; /* end of RAM */
/* Generate a link error if heap and stack don't fit into RAM */
_Min_Heap_Size = 0x400; /* required amount of heap */
_Stack_Size = 0x400; /* amount of stack */
/* Specify the memory areas */
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 24K
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 128K
}
/* Define output sections */
SECTIONS
{
/* The startup code goes first into FLASH */
.isr_vector :
{
. = ALIGN(4);
KEEP(*(.isr_vector)) /* Startup code */
. = ALIGN(4);
} >FLASH
/* The program code and other data goes into FLASH */
.text :
{
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.glue_7) /* glue arm to thumb code */
*(.glue_7t) /* glue thumb to arm code */
*(.eh_frame)
KEEP (*(.init))
KEEP (*(.fini))
. = ALIGN(4);
_etext = .; /* define a global symbols at end of code */
} >FLASH
/* Constant data goes into FLASH */
.rodata :
{
. = ALIGN(4);
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
. = ALIGN(4);
} >FLASH
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
.ARM : {
__exidx_start = .;
*(.ARM.exidx*)
__exidx_end = .;
} >FLASH
.preinit_array :
{
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
} >FLASH
.init_array :
{
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
} >FLASH
.fini_array :
{
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(SORT(.fini_array.*)))
KEEP (*(.fini_array*))
PROVIDE_HIDDEN (__fini_array_end = .);
} >FLASH
/* used by the startup to initialize data */
_sidata = LOADADDR(.data);
/* Initialized data sections goes into RAM, load LMA copy after code */
.data :
{
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start */
*(.data) /* .data sections */
*(.data*) /* .data* sections */
. = ALIGN(4);
_edata = .; /* define a global symbol at data end */
} >RAM AT> FLASH
/* Uninitialized data section */
. = ALIGN(4);
.bss :
{
/* This is used by the startup in order to initialize the .bss secion */
_sbss = .; /* define a global symbol at bss start */
__bss_start__ = _sbss;
*(.bss)
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */
__bss_end__ = _ebss;
} >RAM
/* User_heap_stack section, used to check that there is enough RAM left */
. = ALIGN(8);
PROVIDE ( end = . );
PROVIDE ( _end = . );
/* system stack */
PROVIDE (_stack_base = _estack - _Stack_Size); /* _estack is top of stack*/
ASSERT ((_stack_base > end), "Error: No room left for the stack")
/* _estack is top of stack*/
/* left ram for heap */
PROVIDE (heap_start = _end);
PROVIDE (heap_end = _stack_base);
PROVIDE (heap_len = heap_end - heap_start);
ASSERT ((heap_len > _Min_Heap_Size), "Error: No room left for the heap")
.ARM.attributes 0 : { *(.ARM.attributes) }
}
@@ -0,0 +1,131 @@
/* Entry Point */
ENTRY(Reset_Handler)
/* Highest address of the user mode stack */
_estack = 0x20006000; /* end of RAM */
/* Generate a link error if heap and stack don't fit into RAM */
_Min_Heap_Size = 0x400; /* required amount of heap */
_Stack_Size = 0x400; /* amount of stack */
/* Specify the memory areas */
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 24K
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 256K
}
/* Define output sections */
SECTIONS
{
/* The startup code goes first into FLASH */
.isr_vector :
{
. = ALIGN(4);
KEEP(*(.isr_vector)) /* Startup code */
. = ALIGN(4);
} >FLASH
/* The program code and other data goes into FLASH */
.text :
{
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.glue_7) /* glue arm to thumb code */
*(.glue_7t) /* glue thumb to arm code */
*(.eh_frame)
KEEP (*(.init))
KEEP (*(.fini))
. = ALIGN(4);
_etext = .; /* define a global symbols at end of code */
} >FLASH
/* Constant data goes into FLASH */
.rodata :
{
. = ALIGN(4);
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
. = ALIGN(4);
} >FLASH
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
.ARM : {
__exidx_start = .;
*(.ARM.exidx*)
__exidx_end = .;
} >FLASH
.preinit_array :
{
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
} >FLASH
.init_array :
{
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
} >FLASH
.fini_array :
{
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(SORT(.fini_array.*)))
KEEP (*(.fini_array*))
PROVIDE_HIDDEN (__fini_array_end = .);
} >FLASH
/* used by the startup to initialize data */
_sidata = LOADADDR(.data);
/* Initialized data sections goes into RAM, load LMA copy after code */
.data :
{
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start */
*(.data) /* .data sections */
*(.data*) /* .data* sections */
. = ALIGN(4);
_edata = .; /* define a global symbol at data end */
} >RAM AT> FLASH
/* Uninitialized data section */
. = ALIGN(4);
.bss :
{
/* This is used by the startup in order to initialize the .bss secion */
_sbss = .; /* define a global symbol at bss start */
__bss_start__ = _sbss;
*(.bss)
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */
__bss_end__ = _ebss;
} >RAM
/* User_heap_stack section, used to check that there is enough RAM left */
. = ALIGN(8);
PROVIDE ( end = . );
PROVIDE ( _end = . );
/* system stack */
PROVIDE (_stack_base = _estack - _Stack_Size); /* _estack is top of stack*/
ASSERT ((_stack_base > end), "Error: No room left for the stack")
/* _estack is top of stack*/
/* left ram for heap */
PROVIDE (heap_start = _end);
PROVIDE (heap_end = _stack_base);
PROVIDE (heap_len = heap_end - heap_start);
ASSERT ((heap_len > _Min_Heap_Size), "Error: No room left for the heap")
.ARM.attributes 0 : { *(.ARM.attributes) }
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,41 @@
/**
****************************************************************************************************
* @file fm33_assert.h
* @author FMSH Application Team
* @brief Assert function define
****************************************************************************************************
* @attention
*
* Copyright (c) [2019] [Fudan Microelectronics]
* THIS SOFTWARE is licensed under the Mulan PSL v1.
* can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
*
****************************************************************************************************
*/
#ifndef __FM33_ASSERT_H
#define __FM33_ASSERT_H
#include "fm33xx.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef USE_FULL_ASSERT
#define assert_param(expr) do{if((expr) == 0)for(;;);}while(0)
#else
#define assert_param(expr) ((void)0U)
#endif
#ifdef __cplusplus
}
#endif
#endif
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,110 @@
/**
****************************************************************************************************
* @file fm33xx.h
* @author FMSH Application Team
* @brief Header file of FL Module
****************************************************************************************************
* @attention
*
* Copyright (c) [2019] [Fudan Microelectronics]
* THIS SOFTWARE is licensed under the Mulan PSL v1.
* can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
*
****************************************************************************************************
*/
/** @addtogroup CMSIS
* @{
*/
#ifndef __FM33xx_H
#define __FM33xx_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/** @addtogroup Library_configuration_section
* @{
*/
/**
* @brief FM33 Family
*/
#if !defined (FM33xx)
#define FM33xx
#endif /* FM33XX */
/**
* @brief CMSIS Device version number
*/
#define __FM33x0xx_CMSIS_VERSION_MAIN (0x02) /*!< [31:24] main version */
#define __FM33x0xx_CMSIS_VERSION_SUB1 (0x00) /*!< [23:16] sub1 version */
#define __FM33x0xx_CMSIS_VERSION_SUB2 (0x00) /*!< [15:8] sub2 version */
#define __FM33x0xx_CMSIS_VERSION_RC (0x00) /*!< [7:0] release candidate */
#define __FM33x0xx_CMSIS_VERSION ((__FM33x0xx_CMSIS_VERSION_MAIN << 24)\
|(__FM33x0xx_CMSIS_VERSION_SUB1 << 16)\
|(__FM33x0xx_CMSIS_VERSION_SUB2 << 8 )\
|(__FM33x0xx_CMSIS_VERSION_RC))
/**
* @}
*/
/** @addtogroup Device_Included
* @{
*/
#if defined(FM33L0XX)
#include "fm33l0xx.h"
#elif defined(FM33LC0XX)
#include "fm33lc0xx.h"
#elif defined(FM33LG0XX)
#include "fm33lg0xx.h"
#else
#error "Please select first the target FM33x0xx device used in your application (in FM33xxx.h file)"
#endif
/**
* @}
*/
/** @addtogroup Exported_macro
* @{
*/
#define SET_BIT(REG, BIT) ((REG) |= (BIT))
#define CLEAR_BIT(REG, BIT) ((REG) &= ~(BIT))
#define READ_BIT(REG, BIT) ((REG) & (BIT))
#define CLEAR_REG(REG) ((REG) = (0x0))
#define WRITE_REG(REG, VAL) ((REG) = (VAL))
#define READ_REG(REG) ((REG))
#define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK)))
/**
* @}
*/
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __FM33xx_H */
/**
* @}
*/
/************************ (C) COPYRIGHT Fudan Microelectronics *****END OF FILE****/
@@ -0,0 +1,155 @@
/**************************************************************************//**
* @file system_fm33lc0xx.h
* @brief CMSIS Cortex-M0 Device Peripheral Access Layer Header File for
* Device FM33LC0XX
* @version V2.00
* @date 15. March 2021
*
* @note
*
******************************************************************************/
/* Copyright (c) 2012 ARM LIMITED
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of ARM nor the names of its contributors may be used
to endorse or promote products derived from this software without
specific prior written permission.
*
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------*/
#ifndef SYSTEM_FM33LC0XX_H
#define SYSTEM_FM33LC0XX_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stdio.h>
#include "fm33lc0xx.h"
#define USE_LSCLK_CLOCK_SRC_XTLF
//#define SYSCLK_SRC_RC4M
//#define SYSCLK_SRC_XTHF
#define SYSCLK_SRC_RCHF
//#define SYSCLK_SRC_PLL
//#define USE_PLL_CLOCK_SRC_RCHF
//#define USE_PLL_CLOCK_SRC_XTHF
#if ((!defined(SYSCLK_SRC_RC4M)) && (!defined(SYSCLK_SRC_XTHF))&&(!defined(SYSCLK_SRC_PLL))&&(!defined(SYSCLK_SRC_RCHF)))
#error "Must select a clock source form the SYSCLK_SRC_RC4M or SYSCLK_SRC_XTHF or SYSCLK_SRC_PLL or SYSCLK_SRC_RCHF as the master clock."
#elif (((defined(SYSCLK_SRC_RC4M)) && ((defined(SYSCLK_SRC_XTHF))||(defined(SYSCLK_SRC_PLL))||(defined(SYSCLK_SRC_RCHF))))||\
((defined(SYSCLK_SRC_XTHF)) && ((defined(SYSCLK_SRC_RC4M))||(defined(SYSCLK_SRC_PLL))||(defined(SYSCLK_SRC_RCHF))))||\
((defined(SYSCLK_SRC_PLL)) && ((defined(SYSCLK_SRC_XTHF))||(defined(SYSCLK_SRC_RC4M))||(defined(SYSCLK_SRC_RCHF))))||\
((defined(SYSCLK_SRC_RCHF)) && ((defined(SYSCLK_SRC_XTHF))||(defined(SYSCLK_SRC_PLL))||(defined(SYSCLK_SRC_RC4M)))))
#error "Only one clock source can be selected as the master clock."
#endif
#if defined(SYSCLK_SRC_PLL) && !defined(USE_PLL_CLOCK_SRC_RCHF) && !defined(USE_PLL_CLOCK_SRC_XTHF)
#error "You have chosen to enable the PLL, so you need to specify the clock source for the PLL.."
#elif defined(SYSCLK_SRC_PLL) && (defined(USE_PLL_CLOCK_SRC_RCHF) && defined(USE_PLL_CLOCK_SRC_XTHF))
#error "Please select one of the USE_PLL_CLOCK_SRC_RCHF and USE_PLL_CLOCK_SRC_XTHF in your application"
#endif
#if !defined (XTHF_VALUE)
#define XTHF_VALUE ((uint32_t)8000000U) /*!< Value of the External oscillator in Hz */
#endif /* XTHF_VALUE */
#if !defined (XTLF_VALUE)
#define XTLF_VALUE ((uint32_t)32768U) /*!< Value of the Internal oscillator in Hz*/
#endif /* XTLF_VALUE */
#define LDT_CHECK(_N_VALUE_, _T_VALUE_) \
((((_N_VALUE_ >> 16) & 0xffff) == \
((~_N_VALUE_) & 0xffff)) ? _N_VALUE_ : _T_VALUE_)
#define LPOSC_LDT_TRIM (*(uint32_t *)0x1FFFFB20) // LPOSC 常温校准值
#define RCHF8M_LDT_TRIM (*(uint32_t *)0x1FFFFB40) // RC8M 常温校准值
#define RCHF16M_LDT_TRIM (*(uint32_t *)0x1FFFFB3C) // RC16M 常温校准值
#define RCHF24M_LDT_TRIM (*(uint32_t *)0x1FFFFB38) // RC24M 常温校准值
#define RCMF4M_LDT_TRIM (*(uint32_t *)0x1FFFFB44) // RCMF 常温校准值
#define LPOSC_TRIM (LDT_CHECK(LPOSC_LDT_TRIM, 0x80) & 0xff)
#define RCMF4M_TRIM (LDT_CHECK(RCMF4M_LDT_TRIM, 0x40) & 0x7f)
#define RCHF8M_TRIM (LDT_CHECK(RCHF8M_LDT_TRIM, 0x40) & 0x7f)
#define RCHF16M_TRIM (LDT_CHECK(RCHF16M_LDT_TRIM, 0x40) & 0x7f)
#define RCHF24M_TRIM (LDT_CHECK(RCHF24M_LDT_TRIM, 0x40) & 0x7f)
#define __SYSTEM_CLOCK (8000000)
/**
* @brief FL NVIC Init Sturcture definition
*/
typedef struct
{
/* 中断抢占优先级 */
uint32_t preemptPriority;
}NVIC_ConfigTypeDef;
/**
* Initialize the system
*
* @param none
* @return none
*
* @brief Setup the microcontroller system.
* Initialize the System and update the SystemCoreClock variable.
*/
void SystemInit (void);
/**
* Update SystemCoreClock variable
*
* @param none
* @return none
*
* @brief Updates the SystemCoreClock with current core Clock
* retrieved from cpu registers.
*/
extern uint32_t SystemCoreClock;
void SystemCoreClockUpdate (void);
/**
* @brief NVIC_Init config NVIC
*
* @param NVIC_configStruct configParams
*
* @param IRQn Interrupt number
*
* @retval None
*/
void NVIC_Init(NVIC_ConfigTypeDef *NVIC_configStruct,IRQn_Type IRQn);
#ifdef __cplusplus
}
#endif
#endif /* SYSTEM_FM33LC0XX_H */
@@ -0,0 +1,101 @@
/**************************************************************************//**
* @file system_FM33LG0XX.h
* @brief CMSIS Cortex-M# Device Peripheral Access Layer Header File for
* Device FM33LG0XX
* @version V1.02
* @date 31-8-2018
*
* @note
*
******************************************************************************/
/* Copyright (c) 2012 ARM LIMITED
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of ARM nor the names of its contributors may be used
to endorse or promote products derived from this software without
specific prior written permission.
*
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------*/
#ifndef SYSTEM_FM33LG0XX_H
#define SYSTEM_FM33LG0XX_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stdio.h>
#include "fm33lg0xx.h"
#if !defined (XTHF_VALUE)
#define XTHF_VALUE ((uint32_t)8000000U) /*!< Value of the External oscillator in Hz */
#endif /* XTHF_VALUE */
#if !defined (XTLF_VALUE)
#define XTLF_VALUE ((uint32_t)32768U) /*!< Value of the Internal oscillator in Hz*/
#endif /* XTLF_VALUE */
#define __SYSTEM_CLOCK (8000000)
#define DELAY_US (__SYSTEM_CLOCK/1000000)
#define DELAY_MS (__SYSTEM_CLOCK/1000)
#define Do_DelayStart() { \
uint32_t LastTick = SysTick->VAL; do {
#define While_DelayMsEnd(Count) }while(((LastTick - SysTick->VAL)&0xFFFFFF)<DELAY_MS*Count); \
}
#define While_DelayUsEnd(Count) }while(((LastTick - SysTick->VAL)&0xFFFFFF)<DELAY_US*Count); \
}
/**
* Initialize the system
*
* @param none
* @return none
*
* @brief Setup the microcontroller system.
* Initialize the System and update the SystemCoreClock variable.
*/
void SystemInit (void);
/**
* Update SystemCoreClock variable
*
* @param none
* @return none
*
* @brief Updates the SystemCoreClock with current core Clock
* retrieved from cpu registers.
*/
void SystemCoreClockUpdate (void);
#ifdef __cplusplus
}
#endif
#endif /* SYSTEM_MVCM3_H */
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,81 @@
/**************************************************************************//**
* @file system_<Device>.c
* @brief CMSIS Cortex-M# Device Peripheral Access Layer Source File for
* Device <Device>
* @version V3.10
* @date 23. November 2012
*
* @note
*
******************************************************************************/
/* Copyright (c) 2012 ARM LIMITED
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of ARM nor the names of its contributors may be used
to endorse or promote products derived from this software without
specific prior written permission.
*
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THES
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------*/
#include "fm33lg0xx.h"
/*----------------------------------------------------------------------------
DEFINES
*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
Define clocks
*----------------------------------------------------------------------------*/
/* ToDo: add here your necessary defines for device initialization
following is an example for different system frequencies */
/*----------------------------------------------------------------------------
Clock Variable definitions
*----------------------------------------------------------------------------*/
/* ToDo: initialize SystemCoreClock with the system core clock frequency value
achieved after system intitialization.
This means system core clock frequency after call to SystemInit() */
uint32_t SystemCoreClock = __SYSTEM_CLOCK; /*!< System Clock Frequency (Core Clock)*/
/*----------------------------------------------------------------------------
Clock functions
*----------------------------------------------------------------------------*/
void SystemCoreClockUpdate (void) /* Get Core Clock Frequency */
{
}
/**
* Initialize the system
*
* @param none
* @return none
*
* @brief Setup the microcontroller system.
* Initialize the System.
*/
void SystemInit (void)
{
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,123 @@
/**
*******************************************************************************************************
* @file fm33lc0xx_fl_exti.h
* @author FMSH Application Team
* @brief Head file of EXTI FL Module
*******************************************************************************************************
* @attention
*
* Copyright (c) [2019] [Fudan Microelectronics]
* THIS SOFTWARE is licensed under the Mulan PSL v1.
* can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
*
*******************************************************************************************************
*/
/* Define to prevent recursive inclusion---------------------------------------------------------------*/
#ifndef __FM33LC0XX_FL_EXTI_H
#define __FM33LC0XX_FL_EXTI_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes -------------------------------------------------------------------------------------------*/
#include "fm33lc0xx_fl.h"
/** @addtogroup FM33LC0XX_FL_Driver
* @{
*/
/* Exported types -------------------------------------------------------------------------------------*/
/** @defgroup EXTI_FL_ES_INIT EXTI Exported Init structures
* @{
*/
/**
* @brief FL EXTI Common Init Sturcture definition
*/
typedef struct
{
/*! EXTI时钟源配置 */
uint32_t clockSource;
} FL_EXTI_CommonInitTypeDef;
/**
* @brief FL EXTI Init Sturcture definition
*/
typedef struct
{
/*! EXTI输入配置 */
uint32_t input;
/*! EXTI触发边沿配置 */
uint32_t triggerEdge;
/*! EXTI数字滤波配置 */
uint32_t filter;
} FL_EXTI_InitTypeDef;
/**
* @}
*/
/* Exported constants ---------------------------------------------------------------------------------*/
/** @defgroup EXTI_FL_Exported_Constants EXTI Exported Constants
* @{
*/
#define FL_GPIO_EXTI_INPUT_GROUP0 (0x0U << 0U)
#define FL_GPIO_EXTI_INPUT_GROUP1 (0x1U << 0U)
#define FL_GPIO_EXTI_INPUT_GROUP2 (0x2U << 0U)
#define FL_GPIO_EXTI_INPUT_GROUP3 (0x3U << 0U)
/**
* @}
*/
/* Exported functions ---------------------------------------------------------------------------------*/
/** @defgroup EXTI_FL_Exported_Functions EXTI Exported Functions
* @{
*/
/**
* @}
*/
/** @defgroup EXTI_FL_EF_Init Initialization and de-initialization functions
* @{
*/
FL_ErrorStatus FL_EXTI_CommonInit(FL_EXTI_CommonInitTypeDef *init);
FL_ErrorStatus FL_EXTI_CommonDeinit(void);
void FL_EXTI_CommonStructInit(FL_EXTI_CommonInitTypeDef *init);
FL_ErrorStatus FL_EXTI_Init(uint32_t extiLineX, FL_EXTI_InitTypeDef *init);
FL_ErrorStatus FL_EXTI_DeInit(uint32_t extiLineX);
void FL_EXTI_StructInit(FL_EXTI_InitTypeDef *init);
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __FM33LC0XX_FL_EXTI_H */
/*************************Py_Code_Generator Version: 0.1-0.14-0.2 @ 2021-03-16*************************/
/*************************(C) COPYRIGHT Fudan Microelectronics **** END OF FILE*************************/
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,55 @@
import rtconfig
Import('RTT_ROOT')
from building import *
# get current directory
cwd = GetCurrentDir()
# The set of source files associated with this SConscript file.
src = Split("""
CMSIS/system_fm33lc0xx.c
Src/fm33lc0xx_fl_dma.c
Src/fm33lc0xx_fl_crc.c
Src/fm33lc0xx_fl_rcc.c
Src/fm33lc0xx_fl_gpio.c
""")
if GetDepend(['RT_USING_SERIAL']):
src += ['Src/fm33lc0xx_fl_uart.c']
src += ['Src/fm33lc0xx_fl_lpuart.c']
if GetDepend(['RT_USING_I2C']):
src += ['Src/fm33lc0xx_fl_i2c.c']
if GetDepend(['RT_USING_SPI']):
src += ['Src/fm33lc0xx_fl_spi.c']
#if GetDepend(['RT_USING_USB_HOST']) or GetDepend(['RT_USING_USB_DEVICE']):
# src += ['Src/fm33lc0xx_fl_pcd.c']
# src += ['Src/fm33lc0xx_fl_pcd_ex.c']
if GetDepend(['RT_USING_CAN']):
src += ['Src/fm33lc0xx_fl_can.c']
if GetDepend(['RT_USING_HWTIMER']) or GetDepend(['RT_USING_PWM']):
src += ['Src/fm33lc0xx_fl_tim.c']
if GetDepend(['RT_USING_ADC']):
src += ['Src/fm33lc0xx_fl_adc.c']
if GetDepend(['RT_USING_RTC']):
src += ['Src/fm33lc0xx_fl_rtc.c']
if GetDepend(['RT_USING_WDT']):
src += ['Src/fm33lc0xx_fl_wwdt.c']
if GetDepend(['BSP_USING_ON_CHIP_FLASH']):
src += ['Src/fm33lc0xx_fl_flash.c']
path = [cwd + '/CMSIS/Include',
cwd + '/Inc']
CPPDEFINES = ['USE_HAL_DRIVER']
group = DefineGroup('FM33LC0xx_FL_Driver', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES)
Return('group')
@@ -0,0 +1,137 @@
/**
****************************************************************************************************
* @file fm33lc0xx_fl.c
* @author FMSH Application Team
* @brief Source file of FL Driver Library
****************************************************************************************************
* @attention
*
* Copyright (c) [2019] [Fudan Microelectronics]
* THIS SOFTWARE is licensed under the Mulan PSL v1.
* can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
*
****************************************************************************************************
*/
/* Includes -------------------------------------------------------------------------------------------*/
#include "fm33lc0xx_fl.h"
/** @addtogroup FL_EF_DELAY
* @{
*/
/**
* @brief Initialize the timer(default is Systick) used as delay timer.
* @note The function is declared as __WEAK to be overwritten in case of other
* implementation in user file.
* @param None
* @retval None
*/
__WEAK void FL_DelayInit(void)
{
SysTick->CTRL |= SysTick_CTRL_CLKSOURCE_Msk;
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
}
/**
* @brief Provide block delay in microseconds.
* @note The function is declared as __WEAK to be overwritten in case of other
* implementation in user file.
* @param count specifies the delay count in microseconds.
* @retval None
*/
__WEAK void FL_DelayUs(uint32_t count)
{
count = FL_DELAY_US * count;
count = count > 16777216 ? 16777216 : count;
SysTick->LOAD = count - 1;
SysTick->VAL = 0;
while(!((SysTick->CTRL >> 16) & 0x1));
}
/**
* @brief Provide blocking delay in milliseconds.
* @note The function is declared as __WEAK to be overwritten in case of other
* implementation in user file.
* @param count specifies the delay count in milliseconds.
* @retval None
*/
__WEAK void FL_DelayMs(uint32_t count)
{
while(count--)
{
FL_DelayUs(1000);
}
}
/**
* @brief Provide no-blocking delay initialization in microseconds.
* @note Should be follow By while(!FL_DelayEnd()){ ** user code ** } immediately.
The function is declared as __WEAK to be overwritten in case of other
* implementation in user file.
* @param count specifies the delay count in microseconds.
* @retval None
*/
__WEAK void FL_DelayUsStart(uint32_t count)
{
count = FL_DELAY_US * count;
count = count > 16777216 ? 16777216 : count;
SysTick->LOAD = count - 1;
SysTick->VAL = 0;
}
/**
* @brief Provide no-blocking delay initialization in milliseconds.
* @note Should be followed By while(!FL_DelayEnd()){ ** user code ** }.
* The function is declared as __WEAK to be overwritten in case of other
* implementation in user file.
* @param count specifies the delay count in milliseconds.
* @retval None
*/
__WEAK void FL_DelayMsStart(uint32_t count)
{
FL_DelayUsStart(1000 * count);
}
/**
* @brief Showing if the no-blocking delay has ended.
* @note Should be used with FL_DelayMs/UsStart() function.
The function is declared as __WEAK to be overwritten in case of other
* implementation in user file.
* @param count specifies the delay count in milliseconds.
* @retval true - delay has ended
* false - delay is in progress
*/
__WEAK bool FL_DelayEnd(void)
{
return (((SysTick->CTRL >> 16) & 0x1) == 0x1);
}
/**
*@}
*/
/** @addtogroup FL_EF_DELAY
* @{
*/
void FL_Init(void)
{
// Init delay support function
FL_DelayInit();
}
/**
*@}
*/
/*************************(C) COPYRIGHT Fudan Microelectronics **** END OF FILE*************************/
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,152 @@
/**
****************************************************************************************************
* @file fm33lc0xx_fl_aes.c
* @author FMSH Application Team
* @brief Src file of AES FL Module
****************************************************************************************************
* @attention
*
* Copyright (c) [2019] [Fudan Microelectronics]
* THIS SOFTWARE is licensed under the Mulan PSL v1.
* can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
*
****************************************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "fm33lc0xx_fl_rcc.h"
#include "fm33lc0xx_fl_aes.h"
#include "fm33_assert.h"
/** @addtogroup FM33LC0XX_FL_Driver
* @{
*/
/** @addtogroup AES
* @{
*/
/* Private macros ------------------------------------------------------------*/
/** @addtogroup AES_FL_Private_Macros
* @{
*/
#define IS_FL_AES_INSTANCE(INSTANCE) (((INSTANCE) == AES))
#define IS_FL_AES_KEYLENGTH(__VALUE__) (((__VALUE__) == FL_AES_KEY_LENGTH_128B)||\
((__VALUE__) == FL_AES_KEY_LENGTH_192B)||\
((__VALUE__) == FL_AES_KEY_LENGTH_256B))
#define IS_FL_AES_CIPHERMODE(__VALUE__) (((__VALUE__) == FL_AES_CIPHER_ECB)||\
((__VALUE__) == FL_AES_CIPHER_CBC)||\
((__VALUE__) == FL_AES_CIPHER_CTR)||\
((__VALUE__) == FL_AES_CIPHER_MULTH))
#define IS_FL_AES_OPERATIONMODE(__VALUE__) (((__VALUE__) == FL_AES_OPERATION_MODE_ENCRYPTION)||\
((__VALUE__) == FL_AES_OPERATION_MODE_KEYDERIVATION)||\
((__VALUE__) == FL_AES_OPERATION_MODE_DECRYPTION)||\
((__VALUE__) == FL_AES_OPERATION_MODE_KEYDERIVATION_DECRYPTION))
#define IS_FL_AES_DATATYPE(__VALUE__) (((__VALUE__) == FL_AES_DATA_TYPE_32B)||\
((__VALUE__) == FL_AES_DATA_TYPE_16B)||\
((__VALUE__) == FL_AES_DATA_TYPE_8B)||\
((__VALUE__) == FL_AES_DATA_TYPE_1B))
/**
* @}
*/
/** @addtogroup AES_FL_EF_Init
* @{
*/
/**
* @brief 复位AES外设
* @retval 错误状态,可能值:
* -FL_PASS 外设寄存器值恢复复位值
* -FL_FAIL 未成功执行
*/
FL_ErrorStatus FL_AES_DeInit(void)
{
/* 外设复位使能 */
FL_RCC_EnablePeripheralReset();
/* 复位AES */
FL_RCC_EnableResetAPB2Peripheral(FL_RCC_RSTAPB_AES);
FL_RCC_DisableResetAPB2Peripheral(FL_RCC_RSTAPB_AES);
/* 关闭总线时钟 */
FL_RCC_DisableGroup2BusClock(FL_RCC_GROUP2_BUSCLK_AES);
/* 锁定外设复位功能 */
FL_RCC_DisablePeripheralReset();
return FL_PASS;
}
/**
* @brief 根据 AES_InitStructer 初始化对应外设入口地址的寄存器值.
*
* @param AESx 外设入口地址
* @param AES_InitStructer 指向 @ref FL_AES_InitTypeDef 结构体的指针
*
* @retval 错误状态,可能值:
* -FL_PASS 配置成功
* -FL_FAIL 配置过程发生错误
*/
FL_ErrorStatus FL_AES_Init(AES_Type *AESx, FL_AES_InitTypeDef *AES_InitStructer)
{
/* 入口合法性检查 */
assert_param(IS_FL_AES_INSTANCE(AESx));
assert_param(IS_FL_AES_KEYLENGTH(AES_InitStructer->keyLength));
assert_param(IS_FL_AES_CIPHERMODE(AES_InitStructer->cipherMode));
assert_param(IS_FL_AES_OPERATIONMODE(AES_InitStructer->operationMode));
assert_param(IS_FL_AES_DATATYPE(AES_InitStructer->dataType));
FL_AES_Disable(AES);
if(FL_AES_IsEnabled(AESx) == 0)
{
/* 开启总线时钟 */
FL_RCC_EnableGroup2BusClock(FL_RCC_GROUP2_BUSCLK_AES);
/* key长度 */
FL_AES_SetKeySize(AESx, AES_InitStructer->keyLength);
/* 数据流处理模式 */
FL_AES_SetCipherMode(AESx, AES_InitStructer->cipherMode);
/* 操作模式 */
FL_AES_SetOperationMode(AESx, AES_InitStructer->operationMode);
/* 数据类型 */
FL_AES_SetDataType(AESx, AES_InitStructer->dataType);
}
else
{
return FL_FAIL;
}
return FL_PASS;
}
/**
* @brief 将 @ref FL_AES_InitTypeDef 结构体初始化为默认配置
* @param AES_InitStructer 指向 @ref FL_AES_InitTypeDef 结构体的指针
*
* @retval None
*/
void FL_AES_StructInit(FL_AES_InitTypeDef *AES_InitStructer)
{
AES_InitStructer->keyLength = FL_AES_KEY_LENGTH_128B;
AES_InitStructer->cipherMode = FL_AES_CIPHER_ECB;
AES_InitStructer->operationMode = FL_AES_OPERATION_MODE_ENCRYPTION;
AES_InitStructer->dataType = FL_AES_DATA_TYPE_32B;
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/******************************************* END OF FILE *******************************************/
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,151 @@
/**
*******************************************************************************************************
* @file fm33lc0xx_fl_bstim32.c
* @author FMSH Application Team
* @brief Src file of BSTIM32 FL Module
*******************************************************************************************************
* @attention
*
* Copyright (c) [2019] [Fudan Microelectronics]
* THIS SOFTWARE is licensed under the Mulan PSL v1.
* can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
*
*******************************************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "fm33lc0xx_fl_rcc.h"
#include "fm33lc0xx_fl_rmu.h"
#include "fm33lc0xx_fl_bstim32.h"
#include "fm33_assert.h"
/** @addtogroup FM33LC0XX_FL_Driver
* @{
*/
/** @addtogroup BSTIM32
* @{
*/
/* Private macros ------------------------------------------------------------------*/
/** @addtogroup BSTIM32_FL_Private_Macros
* @{
*/
#define IS_FL_BSTIM32_INSTANCE(INSTANCE) ((INSTANCE) == BSTIM32)
#define IS_FL_BSTIM32_AUTORELOAD_MODE(__VALUE__) (((__VALUE__) == FL_ENABLE)||\
((__VALUE__) == FL_DISABLE))
#define IS_FL_BSTIM32_CLOCK_SRC(__VALUE__) (((__VALUE__) == FL_RCC_BSTIM32_CLK_SOURCE_APB1CLK)||\
((__VALUE__) == FL_RCC_BSTIM32_CLK_SOURCE_LSCLK)||\
((__VALUE__) == FL_RCC_BSTIM32_CLK_SOURCE_RCLP)||\
((__VALUE__) == FL_RCC_BSTIM32_CLK_SOURCE_RCMF_PSC))
/**
* @}
*/
/** @addtogroup BSTIM32_FL_EF_Init
* @{
*/
/**
* @brief 复位BSTIM32外设
* @param BSTIM32x 外设入口地址
* @retval 错误状态,可能值:
* -FL_PASS 外设寄存器值恢复复位值
* -FL_FAIL 未成功执行
*/
FL_ErrorStatus FL_BSTIM32_DeInit(BSTIM32_Type *BSTIM32x)
{
assert_param(IS_FL_BSTIM32_INSTANCE(BSTIM32x));
/* 使能外设复位 */
FL_RCC_EnablePeripheralReset();
/* 复位外设寄存器 */
FL_RCC_EnableResetAPB2Peripheral(FL_RCC_RSTAPB_BSTIM32);
FL_RCC_EnableResetAPB2Peripheral(FL_RCC_RSTAPB_BSTIM32);
/* 关闭外设总线始时钟和工作时钟 */
FL_RCC_DisableGroup4BusClock(FL_RCC_GROUP4_BUSCLK_BSTIM32);
FL_RCC_DisableGroup2OperationClock(FL_RCC_GROUP2_OPCLK_BSTIM32);
/* 锁定外设复位 */
FL_RCC_DisablePeripheralReset();
return FL_PASS;
}
/**
* @brief 配置BSTIM32工作在定时器模式
* @param BSTIM32x 外设入口地址
* @param initStruct 指向 @ref FL_BSTIM32_InitTypeDef 结构体的指针
*
* @retval 错误状态,可能值:
* -FL_PASS 外设寄存器值恢复复位值
* -FL_FAIL 未成功执行
*/
FL_ErrorStatus FL_BSTIM32_Init(BSTIM32_Type *BSTIM32x, FL_BSTIM32_InitTypeDef *initStruct)
{
uint32_t i = 4000;
/* 参数检查 */
assert_param(IS_FL_BSTIM32_INSTANCE(BSTIM32x));
assert_param(IS_FL_BSTIM32_CLOCK_SRC(initStruct->clockSource));
assert_param(IS_FL_BSTIM32_AUTORELOAD_MODE(initStruct->autoReloadState));
/* 时钟使能 */
FL_RCC_EnableGroup4BusClock(FL_RCC_GROUP4_BUSCLK_BSTIM32);
/* 选择时钟源 */
FL_RCC_SetBSTIM32ClockSource(initStruct->clockSource);
FL_RCC_EnableGroup2OperationClock(FL_RCC_GROUP2_OPCLK_BSTIM32);
/* 分频系数 */
FL_BSTIM32_WritePrescaler(BSTIM32x, initStruct->prescaler);
/* 自动重装载值 */
FL_BSTIM32_EnableUpdateEvent(BSTIM32x);
FL_BSTIM32_WriteAutoReload(BSTIM32x, initStruct->autoReload);
if(initStruct->autoReloadState == FL_ENABLE)
{
FL_BSTIM32_EnableARRPreload(BSTIM32x);
}
else
{
FL_BSTIM32_DisableARRPreload(BSTIM32x);
}
/* 手动触发更新事件,将配置值写入 */
FL_BSTIM32_GenerateUpdateEvent(BSTIM32x);
while((!FL_BSTIM32_IsActiveFlag_Update(BSTIM32x))&i)
{
i--;
}
/*清除UIF标志,防止产生UG事件中断*/
FL_BSTIM32_ClearFlag_Update(BSTIM32x);
return FL_PASS;
}
/**
* @brief 将 @ref FL_BSTIM32_InitTypeDef 结构体初始化为默认配置
* @param initStruct 指向 @ref FL_BSTIM32_InitTypeDef 结构体的指针
*
* @retval None
*/
void FL_BSTIM32_StructInit(FL_BSTIM32_InitTypeDef *initStruct)
{
initStruct->prescaler = 0;
initStruct->autoReload = 0xFFFFFFFF;
initStruct->autoReloadState = FL_ENABLE;
initStruct->clockSource = FL_RCC_BSTIM32_CLK_SOURCE_APB1CLK;
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/******************************************* END OF FILE *******************************************/
@@ -0,0 +1,178 @@
/**
****************************************************************************************************
* @file fm33lc0xx_fl_comp.c
* @author FMSH Application Team
* @brief Src file of COMP FL Module
****************************************************************************************************
* @attention
*
* Copyright (c) [2019] [Fudan Microelectronics]
* THIS SOFTWARE is licensed under the Mulan PSL v1.
* can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
*
****************************************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "fm33lc0xx_fl_comp.h"
#include "fm33lc0xx_fl_rmu.h"
#include "fm33lc0xx_fl_rcc.h"
#include "fm33lc0xx_fl_opa.h"
#include "fm33_assert.h"
/** @addtogroup FM33LC0XX_FL_Driver
* @{
*/
/** @addtogroup COMP
* @{
*/
/* Private macros ------------------------------------------------------------*/
/** @addtogroup COMP_FL_Private_Macros
* @{
*/
#define IS_COMP_ALL_INSTANCE(INTENCE) (((INTENCE) == COMP1)||\
((INTENCE) == COMP2))
#define IS_FL_COMP_POSITIVEINPUT(__VALUE__) (((__VALUE__) == FL_COMP_INP_SOURCE_INP1)||\
((__VALUE__) == FL_COMP_INP_SOURCE_INP2)||\
((__VALUE__) == FL_COMP_INP_SOURCE_INP3))
#define IS_FL_COMP_NEGATIVEINPUT(__VALUE__) (((__VALUE__) == FL_COMP_INN_SOURCE_INN1)||\
((__VALUE__) == FL_COMP_INN_SOURCE_INN2)||\
((__VALUE__) == FL_COMP_INN_SOURCE_VREF)||\
((__VALUE__) == FL_COMP_INN_SOURCE_VREF_DIV_2))
#define IS_FL_COMP_POLARITY(__VALUE__) (((__VALUE__) == FL_COMP_OUTPUT_POLARITY_NORMAL)||\
((__VALUE__) == FL_COMP_OUTPUT_POLARITY_INVERT))
#define IS_FL_COMP_EDGE(__VALUE__) (((__VALUE__) == FL_COMP_INTERRUPT_EDGE_BOTH)||\
((__VALUE__) == FL_COMP_INTERRUPT_EDGE_RISING )||\
((__VALUE__) == FL_COMP_INTERRUPT_EDGE_FALLING))
#define IS_FL_COMP_DIGITAL_FILTER(__VALUE__) (((__VALUE__) == FL_DISABLE)||\
((__VALUE__) == FL_ENABLE))
/**
* @}
*/
/** @addtogroup COMP_FL_EF_Init
* @{
*/
/**
* @brief 复位COMP外设
* @param COMPx 外设入口地址
* @retval 错误状态,可能值:
* -FL_PASS 外设寄存器值恢复复位值
* -FL_FAIL 未成功执行
*/
FL_ErrorStatus FL_COMP_DeInit(COMP_Type *COMPx)
{
/* 入口参数检查 */
assert_param(IS_COMP_ALL_INSTANCE(COMPx));
/* 恢复寄存器值为默认值 */
COMPx->CR = 0x00000000U;
/* 关闭外设总线时钟和工作时钟 */
FL_RCC_DisableGroup1BusClock(FL_RCC_GROUP1_BUSCLK_ANAC);
/* 锁定外设复位 */
FL_RCC_DisablePeripheralReset();
return FL_PASS;
}
/**
* @brief 根据 COMP_InitStruct 的配置信息初始化对应外设.
* @param COMPx 外设入口地址
* @param initStruct 指向 @ref FL_COMP_InitTypeDef 结构体的指针
* @retval 错误状态,可能值:
* -FL_PASS 配置成功
* -FL_FAIL 配置过程发生错误
*/
FL_ErrorStatus FL_COMP_Init(COMP_Type *COMPx, FL_COMP_InitTypeDef *initStruct)
{
/* 入口参数检查 */
assert_param(IS_COMP_ALL_INSTANCE(COMPx));
assert_param(IS_FL_COMP_EDGE(initStruct->edge));
assert_param(IS_FL_COMP_POLARITY(initStruct->polarity));
assert_param(IS_FL_COMP_POSITIVEINPUT(initStruct->positiveInput));
assert_param(IS_FL_COMP_NEGATIVEINPUT(initStruct->negativeInput));
assert_param(IS_FL_COMP_DIGITAL_FILTER(initStruct->digitalFilter));
/* 使能时钟总线 */
FL_RCC_EnableGroup1BusClock(FL_RCC_GROUP1_BUSCLK_ANAC);
/* 比较器输出极性选择 */
FL_COMP_SetOutputPolarity(COMPx, initStruct->polarity);
/* 比较器正向输入选择 */
FL_COMP_SetINPSource(COMPx, initStruct->positiveInput);
/* 比较器反向输入选择 */
FL_COMP_SetINNSource(COMPx, initStruct->negativeInput);
/* 比较器使用vref 打开vref_buf */
if((initStruct->negativeInput == FL_COMP_INN_SOURCE_VREF) || (initStruct->negativeInput == FL_COMP_INN_SOURCE_VREF_DIV_2))
{
FL_OPA_EnableVrefBuffer(OPA1);//使能
FL_OPA_DisableBypassVrefBuffer(OPA1);//不bypass
}
if(COMPx == COMP1)
{
/* 比较器中断边沿选择 */
FL_COMP_SetComparator1InterruptEdge(COMP, initStruct->edge);
}
else
{
/* 比较器中断边沿选择 */
FL_COMP_SetComparator2InterruptEdge(COMP, initStruct->edge);
}
/* 滤波 */
if(initStruct->digitalFilter)
{
if(COMPx == COMP1)
{ FL_COMP_EnableComparator1OutputFilter(COMP); }
else
{ FL_COMP_EnableComparator2OutputFilter(COMP); }
}
else
{
if(COMPx == COMP1)
{ FL_COMP_DisableComparator1OutputFilter(COMP); }
else
{ FL_COMP_DisableComparator2OutputFilter(COMP); }
}
return FL_PASS;
}
/**
* @brief 将 @ref FL_COMP_InitTypeDef 结构体初始化为默认配置
* @param initStruct 指向 @ref FL_COMP_InitTypeDef 结构体的指针
*
* @retval None
*/
void FL_COMP_StructInit(FL_COMP_InitTypeDef *initStruct)
{
/* 复位配置信息 */
initStruct->edge = FL_COMP_INTERRUPT_EDGE_BOTH;
initStruct->polarity = FL_COMP_OUTPUT_POLARITY_NORMAL;
initStruct->negativeInput = FL_COMP_INN_SOURCE_INN1;
initStruct->positiveInput = FL_COMP_INP_SOURCE_INP1;
initStruct->digitalFilter = FL_ENABLE;
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/*************************************************************END OF FILE************************************************************/
@@ -0,0 +1,161 @@
/**
*******************************************************************************************************
* @file fm33lc0xx_fl_crc.c
* @author FMSH Application Team
* @brief Src file of CRC FL Module
*******************************************************************************************************
* @attention
*
* Copyright (c) [2019] [Fudan Microelectronics]
* THIS SOFTWARE is licensed under the Mulan PSL v1.
* can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
*
*******************************************************************************************************
*/
#include "fm33lc0xx_fl_rcc.h"
#include "fm33lc0xx_fl_crc.h"
#include "fm33_assert.h"
/** @addtogroup FM33LC0XX_FL_Driver
* @{
*/
/** @addtogroup CRC
* @{
*/
/* Private macros ------------------------------------------------------------*/
/** @addtogroup CRC_FL_Private_Macros
* @{
*/
#define IS_FL_CRC_INSTANCE(INTANCE) ((INTANCE) == CRC)
#define IS_FL_CRC_POLYNOMIAL_WIDTH(__VALUE__) (((__VALUE__) == FL_CRC_POLYNOMIAL_16B)||\
((__VALUE__) == FL_CRC_POLYNOMIAL_32B)||\
((__VALUE__) == FL_CRC_POLYNOMIAL_8B)||\
((__VALUE__) == FL_CRC_POLYNOMIAL_7B))
#define IS_FL_CRC_DR_WIDTH(__VALUE__) (((__VALUE__) == FL_CRC_DATA_WIDTH_8B)||\
((__VALUE__) == FL_CRC_DATA_WIDTH_32B))
#define IS_FL_CRC_OUPUT_REFLECTE_MODE(__VALUE__) (((__VALUE__) == FL_CRC_OUPUT_INVERT_NONE)||\
((__VALUE__) == FL_CRC_OUPUT_INVERT_BYTE))
#define IS_FL_CRC_INPUT_REFLECTE_MODE(__VALUE__) (((__VALUE__) == FL_CRC_INPUT_INVERT_NONE)||\
((__VALUE__) == FL_CRC_INPUT_INVERT_BYTE)||\
((__VALUE__) == FL_CRC_INPUT_INVERT_HALF_WORD)||\
((__VALUE__) == FL_CRC_INPUT_INVERT_WORD))
#define IS_FL_CRC_CALCULA_MODE(__VALUE__) (((__VALUE__) == FL_CRC_CALCULATE_SERIAL)||\
((__VALUE__) == FL_CRC_CALCULATE_PARALLEL))
/**
* @}
*/
/** @addtogroup CRC_FL_EF_Init
* @{
*/
/**
* @brief 复位CRC外设
* @param CRCx 外设入口地址
* @retval 错误状态,可能值:
* -FL_PASS 外设寄存器值恢复复位值
* -FL_FAIL 未成功执行
*/
FL_ErrorStatus FL_CRC_DeInit(CRC_Type *CRCx)
{
assert_param(IS_FL_CRC_INSTANCE(CRCx));
/* 外设复位使能 */
FL_RCC_EnablePeripheralReset();
/* 复位外设寄存器 */
FL_RCC_EnableResetAPB2Peripheral(FL_RCC_RSTAPB_CRC);
FL_RCC_DisableResetAPB2Peripheral(FL_RCC_RSTAPB_CRC);
/* 关闭总线时钟 */
FL_RCC_DisableGroup2BusClock(FL_RCC_GROUP2_BUSCLK_CRC);
/* 锁定外设复位功能 */
FL_RCC_DisablePeripheralReset();
return FL_PASS;
}
/**
* @brief 根据 CRC_InitStruct 的配置信息初始化对应外设入口地址的寄存器值.
*
* @param CRCx 外设入口地址
* @param CRC_InitStruct 指向一个 @ref FL_CRC_InitTypeDef 结构体其中包含了外设的相关配置信息.
*
* @retval 错误状态,可能值:
* -FL_PASS 配置成功
* -FL_FAIL 配置过程发生错误
*/
FL_ErrorStatus FL_CRC_Init(CRC_Type *CRCx, FL_CRC_InitTypeDef *CRC_InitStruct)
{
/* 参数检查 */
assert_param(IS_FL_CRC_INSTANCE(CRCx));
assert_param(IS_FL_CRC_DR_WIDTH(CRC_InitStruct->dataWidth));
assert_param(IS_FL_CRC_CALCULA_MODE(CRC_InitStruct->calculatMode));
assert_param(IS_FL_CRC_POLYNOMIAL_WIDTH(CRC_InitStruct->polynomialWidth));
assert_param(IS_FL_CRC_INPUT_REFLECTE_MODE(CRC_InitStruct->reflectIn));
assert_param(IS_FL_CRC_OUPUT_REFLECTE_MODE(CRC_InitStruct->reflectOut));
FL_RCC_EnableGroup2BusClock(FL_RCC_GROUP2_BUSCLK_CRC);
FL_CRC_SetCalculateMode(CRCx, CRC_InitStruct->calculatMode);
FL_CRC_SetInputInvertMode(CRCx, CRC_InitStruct->reflectIn);
FL_CRC_SetOutputInvertMode(CRCx, CRC_InitStruct->reflectOut);
FL_CRC_SetPolynomialWidth(CRCx, CRC_InitStruct->polynomialWidth);
FL_CRC_WriteXORValue(CRCx, CRC_InitStruct->xorReg);
FL_CRC_WritePolynominalParam(CRCx, CRC_InitStruct->polynomial);
FL_CRC_WriteInitialValue(CRCx, CRC_InitStruct->initVal);
FL_CRC_SetDataWidth(CRCx, CRC_InitStruct->dataWidth);
if(CRC_InitStruct->xorRegState == FL_ENABLE)
{
FL_CRC_EnableOutputXOR(CRCx);
}
else
{
FL_CRC_DisableOutputXOR(CRCx);
}
return FL_PASS;
}
/**
* @brief 将 @ref FL_CRC_InitTypeDef 结构体初始化为默认配置
* @param CRC_InitStruct 指向 @ref FL_CRC_InitTypeDef 结构体的指针
*
* @retval None
*/
void FL_CRC_StructInit(FL_CRC_InitTypeDef *CRC_InitStruct)
{
CRC_InitStruct->polynomial = 0x00000000;
CRC_InitStruct->polynomialWidth = FL_CRC_POLYNOMIAL_16B;
CRC_InitStruct->dataWidth = FL_CRC_DATA_WIDTH_8B;
CRC_InitStruct->calculatMode = FL_CRC_CALCULATE_SERIAL;
CRC_InitStruct->reflectIn = FL_CRC_INPUT_INVERT_NONE;
CRC_InitStruct->reflectOut = FL_CRC_OUPUT_INVERT_NONE;
CRC_InitStruct->xorReg = 0x00000000;
CRC_InitStruct->xorRegState = FL_DISABLE;
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/******************************************* END OF FILE *******************************************/
@@ -0,0 +1,155 @@
/**
*******************************************************************************************************
* @file fm33lc0xx_fl_divas.c
* @author FMSH Application Team
* @brief Src file of DIVAS FL Module
*******************************************************************************************************
* @attention
*
* Copyright (c) [2019] [Fudan Microelectronics]
* THIS SOFTWARE is licensed under the Mulan PSL v1.
* can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
*
*******************************************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "fm33lc0xx_fl_rcc.h"
#include "fm33lc0xx_fl_divas.h"
#include "fm33_assert.h"
/** @addtogroup FM33LC0XX_FL_Driver
* @{
*/
/** @addtogroup DIVAS
* @{
*/
/* Private macros ------------------------------------------------------------*/
/** @addtogroup DIVAS_FL_Private_Macros
* @{
*/
#define IS_DIVAS_ALL_INSTANCE(INTENCE) ((INTENCE) == DIV)
#define IS_FL_DIVAS_DIVISOR(__VALUE__) (((__VALUE__) != 0))
/**
* @}
*/
/** @addtogroup DIVAS_FL_EF_Init
* @{
*/
/**
* @brief 复位DIVAS外设
*
* @param DIVx 外设入口地址
*
* @retval 错误状态,可能值:
* -FL_PASS 外设寄存器值恢复复位值
* -FL_FAIL 未成功执行
*/
FL_ErrorStatus FL_DIVAS_DeInit(DIV_Type *DIVx)
{
/* 入口参数检查 */
assert_param(IS_DIVAS_ALL_INSTANCE(DIVx));
/* 外设复位使能 */
FL_RCC_EnablePeripheralReset();
/* 恢复寄存器值为默认值 */
FL_RCC_EnableResetAPB2Peripheral(FL_RCC_RSTAPB_DIVAS);
FL_RCC_DisableResetAPB2Peripheral(FL_RCC_RSTAPB_DIVAS);
/* 关闭总线时钟 */
FL_RCC_DisableGroup2BusClock(FL_RCC_GROUP2_BUSCLK_HDIV);
/* 锁定外设复位功能 */
FL_RCC_DisablePeripheralReset();
return FL_PASS;
}
/**
* @brief 配置DIVAS外设的DIV模块
*
* @param DIVx 外设入口地址
*
* @retval 错误状态,可能值:
* -FL_PASS 配置成功
* -FL_FAIL 配置过程发生错误
*/
FL_ErrorStatus FL_DIVAS_Init(DIV_Type *DIVx)
{
/* 入口参数检查 */
assert_param(IS_DIVAS_ALL_INSTANCE(DIVx));
/* 使能时钟总线 */
FL_RCC_EnableGroup2BusClock(FL_RCC_GROUP2_BUSCLK_HDIV);
return FL_PASS;
}
/**
* @}
*/
/** @addtogroup DIVAS_FL_EF_Operation
* @{
*/
/**
* @brief 硬件除法器计算
*
* @param DIVx 外设入口地址
* @param DivisorEnd 32位有符号被除数
* @param Divisor 16位有符号除数,注意不能为0
* @param Quotient 指向 @ref int32_t 指针 保存商的地址
* @param Residue 指向 @ref int16_t 指针 保存余数的地址
*
* @retval 计算正确性与否
* -0 计算结果正确
* -非0 计算过程发生错误
*/
uint32_t FL_DIVAS_Hdiv_Calculation(DIV_Type *DIVx, int32_t DivisorEnd, int16_t Divisor, int32_t *Quotient, int16_t *Residue)
{
uint32_t TimeOut ;
FL_DIV_WriteDividend_S32(DIVx, DivisorEnd);
FL_DIV_WriteDivisor_S16(DIVx, Divisor);
if(FL_DIV_IsActiveFlag_DividedZero(DIVx))
{
/*除数为0 */
*Quotient = 0;
*Residue = 0;
return 1;
}
TimeOut = FL_DIVAS_SR_BUSY_TIMEOUT;
while(FL_DIV_IsActiveFlag_Busy(DIVx))
{
TimeOut--;
if(TimeOut == 0)
{
/* 计算超时*/
*Quotient = 0;
*Residue = 0;
return 3;
}
}
*Quotient = FL_DIV_ReadQuotient_S32(DIVx);
*Residue = FL_DIV_ReadResidue_S16(DIVx);
return 0;
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/******************************************* END OF FILE *******************************************/
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,131 @@
/**
****************************************************************************************************
* @file fm33lc0xx_fl_iwdt.c
* @author FMSH Application Team
* @brief Src file of IWDT FL Module
****************************************************************************************************
* @attention
*
* Copyright (c) [2019] [Fudan Microelectronics]
* THIS SOFTWARE is licensed under the Mulan PSL v1.
* can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
*
****************************************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "fm33lc0xx_fl_rcc.h"
#include "fm33lc0xx_fl_iwdt.h"
#include "fm33_assert.h"
/** @addtogroup FM33LC0XX_FL_Driver
* @{
*/
/** @addtogroup IWDT
* @{
*/
/* Private macros ------------------------------------------------------------*/
/** @addtogroup IWDT_FL_Private_Macros
* @{
*/
#define IS_IWDT_INSTANCE(INTANCE) ((INTANCE) == IWDT)
#define IS_FL_IWDT_WINDOWSVEL(__VALUE__) ((__VALUE__) < 0xFFF)
#define IS_FL_IWDT_OVERFLOWPERIOD(__VALUE__) (((__VALUE__) == FL_IWDT_PERIOD_125MS)||\
((__VALUE__) == FL_IWDT_PERIOD_250MS)||\
((__VALUE__) == FL_IWDT_PERIOD_500MS)||\
((__VALUE__) == FL_IWDT_PERIOD_1000MS)||\
((__VALUE__) == FL_IWDT_PERIOD_2000MS)||\
((__VALUE__) == FL_IWDT_PERIOD_4000MS)||\
((__VALUE__) == FL_IWDT_PERIOD_8000MS)||\
((__VALUE__) == FL_IWDT_PERIOD_16000MS))
/**
* @}
*/
/** @addtogroup IWDT_FL_EF_Init
* @{
*/
/**
* @brief 复位IWDT外设
*
* @note 此函数只能用于配制前复位外设,因为IWDT开启后不可以关闭
*
* @param IWDTx 外设入口地址
*
* @retval 错误状态,可能值:
* -FL_PASS 外设寄存器值恢复复位值
* -FL_FAIL 未成功执行
*/
FL_ErrorStatus FL_IWDT_DeInit(IWDT_Type *IWDTx)
{
assert_param(IS_IWDT_INSTANCE(IWDTx));
return FL_PASS;
}
/**
* @brief 配置IWDT
*
* @note IWTD使能后将无法关闭,直到下一次芯片复位
*
* @param IWDTx 外设入口地址
* @param IWDT_InitStruct 指向 @ref FL_IWDT_InitTypeDef 结构体的指针
*
* @retval 错误状态,可能值:
* -FL_PASS 配置成功
* -FL_FAIL 配置过程发生错误
*/
FL_ErrorStatus FL_IWDT_Init(IWDT_Type *IWDTx, FL_IWDT_InitTypeDef *IWDT_InitStruct)
{
FL_ErrorStatus status = FL_PASS;
/* 入口参数检查 */
assert_param(IS_IWDT_INSTANCE(IWDTx));
assert_param(IS_FL_IWDT_WINDOWSVEL(IWDT_InitStruct->iwdtWindows));
assert_param(IS_FL_IWDT_OVERFLOWPERIOD(IWDT_InitStruct->overflowPeriod));
/* 开启总线时钟 */
FL_RCC_EnableGroup1BusClock(FL_RCC_GROUP1_BUSCLK_IWDT);
/* 配置独立看门狗溢出周期 */
FL_IWDT_SetPeriod(IWDTx, IWDT_InitStruct->overflowPeriod);
/* 配置独立看门狗清狗窗口*/
FL_IWDT_WriteWindow(IWDTx, IWDT_InitStruct->iwdtWindows);
/* 启动看门狗 */
FL_IWDT_ReloadCounter(IWDTx);
return status;
}
/**
* @brief 将 @ref FL_IWDT_InitTypeDef 结构体初始化为默认配置
* @param IWDT_InitStruct 指向 @ref FL_IWDT_InitTypeDef 结构体的指针
*
* @retval None
*/
void FL_IWDT_StructInit(FL_IWDT_InitTypeDef *IWDT_InitStruct)
{
/* 默认不使用窗口 */
IWDT_InitStruct->iwdtWindows = 0;
/*最长溢出时间*/
IWDT_InitStruct->overflowPeriod = FL_IWDT_PERIOD_500MS;
}
/**
*@}
*/
/**
*@}
*/
/**
*@}
*/
/******************************************* END OF FILE *******************************************/
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,182 @@
/**
*******************************************************************************************************
* @file fm33lc0xx_fl_opa.c
* @author FMSH Application Team
* @brief Src file of OPA FL Module
*******************************************************************************************************
* @attention
*
* Copyright (c) [2019] [Fudan Microelectronics]
* THIS SOFTWARE is licensed under the Mulan PSL v1.
* can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
*
*******************************************************************************************************
*/
#include "fm33lc0xx_fl_rcc.h"
#include "fm33lc0xx_fl_rmu.h"
#include "fm33lc0xx_fl_opa.h"
#include "fm33_assert.h"
/** @addtogroup FM33LC0XX_FL_Driver
* @{
*/
/** @addtogroup OPA
* @{
*/
/* Private macros ------------------------------------------------------------*/
/** @addtogroup OPA_FL_Private_Macros
* @{
*/
#define IS_OPA_ALL_INSTANCE(INTENCE) (((INTENCE) == OPA1)||\
((INTENCE) == OPA2))
#define IS_FL_OPA_INP_CHANNAL(__VALUE__) (((__VALUE__) == FL_OPA_INP_SOURCE_INP1)||\
((__VALUE__) == FL_OPA_INP_SOURCE_INP2))
#define IS_FL_OPA_INN_CHANNAL(__VALUE__) (((__VALUE__) == FL_OPA_INN_SOURCE_INN1)||\
((__VALUE__) == FL_OPA_INN_SOURCE_INN2)||\
((__VALUE__) == FL_OPA_INN_SOURCE_VREF)||\
((__VALUE__) == FL_OPA_INN_SOURCE_THREE_QUARTERS_VREF)||\
((__VALUE__) == FL_OPA_INN_SOURCE_HALF_VREF)||\
((__VALUE__) == FL_OPA_INN_SOURCE_ONE_QUARTER_VREF)||\
((__VALUE__) == FL_OPA_INN_SOURCE_ONE_EIGHTH_VREF))
#define IS_FL_OPA_MODE(__VALUE__) (((__VALUE__) == FL_OPA_MODE_STANDALONE)||\
((__VALUE__) == FL_OPA_MODE_COMPARATOR)||\
((__VALUE__) == FL_OPA_MODE_PGA)||\
((__VALUE__) == FL_OPA_MODE_BUFFER))
#define IS_FL_OPA_DIGITALFILTER(__VALUE__) (((__VALUE__) == FL_DISABLE)||\
((__VALUE__) == FL_ENABLE))
#define IS_FL_OPA_NEGTIVE_TO_PIN(__VALUE__) (((__VALUE__) == FL_DISABLE)||\
((__VALUE__) == FL_ENABLE))
#define IS_FL_OPA_LOW_POWER_MODE(__VALUE__) (((__VALUE__) == FL_DISABLE)||\
((__VALUE__) == FL_ENABLE))
#define IS_FL_OPA_GAIN(__VALUE__) (((__VALUE__) == FL_OPA_GAIN_X2)||\
((__VALUE__) == FL_OPA_GAIN_X4)||\
((__VALUE__) == FL_OPA_GAIN_X8)||\
((__VALUE__) == FL_OPA_GAIN_X16))
/**
* @}
*/
/** @addtogroup OPA_FL_EF_Init
* @{
*/
/**
* @brief 复位OPA
* @param OPAx 外设入口地址
* @retval 错误状态,可能值:
* -FL_PASS 外设寄存器值恢复复位值
* -FL_FAIL 未成功执行
*/
FL_ErrorStatus FL_OPA_DeInit(OPA_Type *OPAx)
{
/* 入口参数合法性断言 */
assert_param(IS_OPA_ALL_INSTANCE(OPAx));
/* 使能外设复位 */
FL_RCC_EnablePeripheralReset();
/* 复位外设寄存器 */
FL_RCC_EnableResetAPB2Peripheral(FL_RCC_RSTAPB_OPA);
FL_RCC_DisableResetAPB2Peripheral(FL_RCC_RSTAPB_OPA);
/* 关闭外设总线时钟和工作时钟 */
FL_RCC_DisableGroup1BusClock(FL_RCC_GROUP1_BUSCLK_ANAC);
/* 锁定外设复位 */
FL_RCC_DisablePeripheralReset();
return FL_PASS;
}
/**
* @brief 配置OPA
*
* @param OPAx 外设入口地址
* @param initStruct 指向 @ref FL_OPA_InitTypeDef 结构体的指针
*
* @retval 错误状态,可能值:
* -FL_PASS 配置成功
* -FL_FAIL 配置过程发生错误
*/
FL_ErrorStatus FL_OPA_Init(OPA_Type *OPAx, FL_OPA_InitTypeDef *initStruct)
{
FL_ErrorStatus status = FL_PASS;
/* 入口参数检查 */
assert_param(IS_OPA_ALL_INSTANCE(OPAx));
assert_param(IS_FL_OPA_INP_CHANNAL(initStruct->INP));
assert_param(IS_FL_OPA_INN_CHANNAL(initStruct->INN));
assert_param(IS_FL_OPA_MODE(initStruct->mode));
assert_param(IS_FL_OPA_DIGITALFILTER(initStruct->digitalFilter));
assert_param(IS_FL_OPA_NEGTIVE_TO_PIN(initStruct->negtiveToPin));
assert_param(IS_FL_OPA_LOW_POWER_MODE(initStruct->lowPowermode));
assert_param(IS_FL_OPA_GAIN(initStruct->gain));
/*总线时钟使能*/
FL_RCC_EnableGroup1BusClock(FL_RCC_GROUP1_BUSCLK_ANAC);
/*配置模式*/
FL_OPA_SetMode(OPAx, initStruct->mode);
/*配置反向输入*/
FL_OPA_SetINNSource(OPAx, initStruct->INN);
/*配置正向输入*/
FL_OPA_SetINPSource(OPAx, initStruct->INP);
/*配置低功耗模式*/
if(initStruct->lowPowermode == FL_ENABLE)
{
FL_OPA_EnableLowPowerMode(OPAx);
}
if(initStruct->mode == FL_OPA_MODE_PGA)
{
/*配置PGA增益*/
FL_OPA_PGA_SetGain(OPAx, initStruct->gain);
if(initStruct->negtiveToPin == FL_ENABLE)
{
/*配置PGA模式下反向输入端接到PIN*/
FL_OPA_PGA_EnableINNConnectToPin(OPAx);
}
}
return status;
}
/**
* @brief 将 @ref FL_OPA_InitTypeDef 结构体初始化为默认配置
* @param initStruct 指向 @ref FL_OPA_InitTypeDef 结构体的指针
*
* @retval None
*/
void FL_OPA_StructInit(FL_OPA_InitTypeDef *initStruct)
{
initStruct->INP = FL_OPA_INP_SOURCE_INP1;
initStruct->INN = FL_OPA_INN_SOURCE_INN1;
initStruct->mode = FL_OPA_MODE_STANDALONE;
initStruct->digitalFilter = FL_DISABLE;
initStruct->negtiveToPin = FL_DISABLE;
initStruct->gain = FL_OPA_GAIN_X2;
initStruct->lowPowermode = FL_DISABLE;
}
/**
*@}
*/
/**
*@}
*/
/**
*@}
*/
/******************************************* END OF FILE *******************************************/
@@ -0,0 +1,144 @@
/**
****************************************************************************************************
* @file fm33lc0xx_fl_pmu.c
* @author FMSH Application Team
* @brief Src file of PMU FL Module
****************************************************************************************************
* @attention
*
* Copyright (c) [2019] [Fudan Microelectronics]
* THIS SOFTWARE is licensed under the Mulan PSL v1.
* can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
*
****************************************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "fm33lc0xx_fl_rmu.h"
#include "fm33lc0xx_fl_pmu.h"
#include "fm33_assert.h"
#define IS_FL_PMU_INSTANCE(INSTANCE) (((INSTANCE) == PMU))
#define IS_FL_PMU_MODE(__VALUE__) (((__VALUE__) == FL_PMU_POWER_MODE_ACTIVE_OR_LPACTIVE)||\
((__VALUE__) == FL_PMU_POWER_MODE_LPRUN_ONLY)||\
((__VALUE__) == FL_PMU_POWER_MODE_SLEEP_OR_DEEPSLEEP))
#define IS_FL_PMU_COREVOLTAGESCALING(__VALUE__) (((__VALUE__) == FL_DISABLE)||\
((__VALUE__) == FL_ENABLE))
#define IS_FL_PMU_DEEPSLEEP(__VALUE__) (((__VALUE__) == FL_PMU_SLEEP_MODE_DEEP)||\
((__VALUE__) == FL_PMU_SLEEP_MODE_NORMAL))
#define IS_FL_PMU_WAKEUPFREQUENCY(__VALUE__) (((__VALUE__) == FL_PMU_RCHF_WAKEUP_FREQ_8MHZ)||\
((__VALUE__) == FL_PMU_RCHF_WAKEUP_FREQ_16MHZ)||\
((__VALUE__) == FL_PMU_RCHF_WAKEUP_FREQ_24MHZ))
#define IS_FL_PMU_LDOLOWMODE(__VALUE__) (((__VALUE__) == FL_PMU_LDO_LPM_DISABLE)||\
((__VALUE__) == FL_PMU_LDO_LPM_ENABLE))
#define IS_FL_PMU_WAKEUPDELAY(__VALUE__) (((__VALUE__) == FL_PMU_WAKEUP_DELAY_0US)||\
((__VALUE__) == FL_PMU_WAKEUP_DELAY_2US)||\
((__VALUE__) == FL_PMU_WAKEUP_DELAY_4US)||\
((__VALUE__) == FL_PMU_WAKEUP_DELAY_8US))
/**
*@}
*/
/** @addtogroup PMU_FL_EF_Init
* @{
*/
/**
* @brief 复位PMU外设
*
* @param 外设入口地址
*
* @retval 返回错误状态,可能值:
* -FL_PASS 外设寄存器值恢复复位值
* -FL_FAIL 未成功执行
*/
FL_ErrorStatus FL_PMU_Sleep_DeInit(PMU_Type *PMUx)
{
FL_ErrorStatus status = FL_FAIL;
/* 参数合法性检查 */
assert_param(IS_FL_PMU_INSTANCE(PMUx));
PMUx->CR = 0x00060000U;
PMUx->WKTR = 0xC0000001U;
PMUx->IER = 0x00000000U;
status = FL_PASS;
return status;
}
/**
* @brief 根据LPM_InitStruct结构体包含的配置信息配置PMU寄存器
*
* @note 为更好的睡眠功耗用户可能需要根据实际应用,调用 @ref fm33lc0xx_fl_pmu.h中的其他接口
* 来完成睡眠前的模式配置,包括睡眠行为和唤醒后的行为(注:此函数会关闭BOR)
* @param PMUx 外设入口地址
* @param LPM_InitStruct 指向一个 @ref LL_PMU_SleepInitTypeDef 类型的结构体,它包含指定LPUART外设的配置信息
*
* @retval ErrorStatus枚举值
* -FL_FAIL 配置过程发生错误
* -FL_PASS LPUART配置成功
*/
FL_ErrorStatus FL_PMU_Sleep_Init(PMU_Type *PMUx, FL_PMU_SleepInitTypeDef *LPM_InitStruct)
{
FL_ErrorStatus status = FL_FAIL;
/* 参数合法性检查 */
assert_param(IS_FL_PMU_INSTANCE(PMUx));
assert_param(IS_FL_PMU_LDOLOWMODE(LPM_InitStruct->LDOLowPowerMode));
assert_param(IS_FL_PMU_COREVOLTAGESCALING(LPM_InitStruct->coreVoltageScaling));
assert_param(IS_FL_PMU_DEEPSLEEP(LPM_InitStruct->deepSleep));
assert_param(IS_FL_PMU_WAKEUPFREQUENCY(LPM_InitStruct->wakeupFrequency));
assert_param(IS_FL_PMU_WAKEUPDELAY(LPM_InitStruct->wakeupDelay));
/* 唤醒延时 */
FL_PMU_SetWakeupDelay(PMUx, LPM_InitStruct->wakeupDelay);
/* 唤醒后RCHF的频率 */
FL_PMU_SetRCHFWakeupFrequency(PMUx, LPM_InitStruct->wakeupFrequency);
/* 睡眠下内核电压配置 */
if(LPM_InitStruct->coreVoltageScaling == FL_ENABLE)
{
FL_PMU_EnableCoreVoltageScaling(PMUx);
}
else
{
FL_PMU_DisableCoreVoltageScaling(PMUx);
}
/* M0系统控制器,一般配置为0即可*/
SCB->SCR = 0;
/* 睡眠模式 */
FL_PMU_SetSleepMode(PMUx, LPM_InitStruct->deepSleep);
status = FL_PASS;
return status;
}
/**
* @brief LPM_InitStruct 为默认配置
* @param LPM_InitStruct 指向需要将值设置为默认配置的结构体 @ref FL_PMU_SleepInitTypeDef structure
* 结构体
* @retval None
*/
void FL_PMU_StructInit(FL_PMU_SleepInitTypeDef *LPM_InitStruct)
{
LPM_InitStruct->deepSleep = FL_PMU_SLEEP_MODE_NORMAL;
LPM_InitStruct->LDOLowPowerMode = FL_PMU_LDO_LPM_DISABLE;
LPM_InitStruct->wakeupFrequency = FL_PMU_RCHF_WAKEUP_FREQ_8MHZ;
LPM_InitStruct->wakeupDelay = FL_PMU_WAKEUP_DELAY_2US;
LPM_InitStruct->coreVoltageScaling = FL_DISABLE;
}
/**
*@}
*/
/**
*@}
*/
/*********************** (C) COPYRIGHT Fudan Microelectronics *****END OF FILE************************/
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,190 @@
/**
*******************************************************************************************************
* @file fm33lc0xx_fl_rng.c
* @author FMSH Application Team
* @brief Src file of RNG FL Module
*******************************************************************************************************
* @attention
*
* Copyright (c) [2019] [Fudan Microelectronics]
* THIS SOFTWARE is licensed under the Mulan PSL v1.
* can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
*
*******************************************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "fm33lc0xx_fl_rcc.h"
#include "fm33lc0xx_fl_rng.h"
#include "fm33_assert.h"
/** @addtogroup FM33LC0XX_FL_Driver
* @{
*/
/** @addtogroup RNG
* @{
*/
/* Private macros ------------------------------------------------------------*/
/** @addtogroup RNG_FL_Private_Macros
* @{
*/
#define IS_FL_RNG_INSTANCE(INTANCE) ((INTANCE) == RNG)
#define IS_FL_RNG_CLOCK_PRESCALER(__VALUE__) (((__VALUE__) == FL_RCC_RNG_PSC_DIV1)||\
((__VALUE__) == FL_RCC_RNG_PSC_DIV2)||\
((__VALUE__) == FL_RCC_RNG_PSC_DIV4)||\
((__VALUE__) == FL_RCC_RNG_PSC_DIV8)||\
((__VALUE__) == FL_RCC_RNG_PSC_DIV16)||\
((__VALUE__) == FL_RCC_RNG_PSC_DIV32))
/**
*@}
*/
/** @addtogroup RNG_FL_EF_Init
* @{
*/
/**
* @brief 复位RNG
*
* @param RNGx 外设入口地址
*
* @retval 错误状态,可能值:
* -FL_PASS 外设寄存器值恢复复位值
* -FL_FAIL 未成功执行
*/
FL_ErrorStatus FL_RNG_DeInit(RNG_Type *RNGx)
{
assert_param(IS_FL_RNG_INSTANCE(RNGx));
/* 使能外设复位 */
FL_RCC_EnablePeripheralReset();
/* 复位外设寄存器 */
FL_RCC_EnableResetAPB2Peripheral(FL_RCC_RSTAPB_RNG);
FL_RCC_DisableResetAPB2Peripheral(FL_RCC_RSTAPB_RNG);
/* 关闭外设总线始时钟和工作时钟 */
FL_RCC_DisableGroup2BusClock(FL_RCC_GROUP2_BUSCLK_RNG);
/* 锁定外设复位 */
FL_RCC_DisablePeripheralReset();
return FL_PASS;
}
/**
* @brief 配置RNG
*
* @param RNGx 外设入口地址
* @param initStruct 指向 @ref FL_RNG_InitTypeDef 结构体的指针
*
* @note RNG使用RCHF默认的8M作为时钟输入,经2分频后4M提供给RNG
*
* @retval 错误状态,可能值:
* -FL_PASS 配置成功
* -FL_FAIL 配置过程发生错误
*/
FL_ErrorStatus FL_RNG_Init(RNG_Type *RNGx)
{
assert_param(IS_FL_RNG_INSTANCE(RNGx));
/* RNG 使用RCHF作为工作时钟因此必须确认RCHF使能*/
if(FL_RCC_RCHF_IsEnabled() != FL_SET)
{
FL_RCC_RCHF_Enable();
}
FL_RCC_EnableGroup2BusClock(FL_RCC_GROUP2_BUSCLK_RNG);
/* RNG 工作时钟预分频*/
switch(FL_RCC_RCHF_GetFrequency())
{
case FL_RCC_RCHF_FREQUENCY_8MHZ:
FL_RCC_SetRNGPrescaler(FL_RCC_RNG_PSC_DIV2);
break;
case FL_RCC_RCHF_FREQUENCY_16MHZ:
FL_RCC_SetRNGPrescaler(FL_RCC_RNG_PSC_DIV4);
break;
case FL_RCC_RCHF_FREQUENCY_24MHZ:
FL_RCC_SetRNGPrescaler(FL_RCC_RNG_PSC_DIV8);
break;
default:
FL_RCC_SetRNGPrescaler(FL_RCC_RNG_PSC_DIV2);
break;
}
/* RNG 工作时钟使能*/
FL_RCC_EnableGroup2OperationClock(FL_RCC_GROUP2_OPCLK_RNG);
return FL_PASS;
}
/**
* @brief 获取一次随机数
*
* @note 如果返回值为0xFFFFFFFF 则说明随机数生成失败,请用户检查此函数的返回值,失败时重新生成
*
* @retval 生成的随机数,生成失败返回0xFFFFFFFF
*
*/
uint32_t GetRandomNumber(void)
{
uint32_t rn32;
FL_RNG_ClearFlag_RandomFail(RNG);
FL_RNG_Enable(RNGCTL);
/* 由于LFSR循环移位周期是32cycle,为保证随机数质量,应用应保证两次读取RNGOUT之间的间隔大于32个TRNG_CLK周期 */
FL_DelayUs(12);
FL_RNG_Disable(RNGCTL);
rn32 = FL_RNG_ReadData(RNG);
if(FL_RNG_IsActiveFlag_RandomFail(RNG))
{
FL_RNG_ClearFlag_RandomFail(RNG);
return 0xFFFFFFFF;
}
return rn32;
}
/**
* @brief 获取CRC32
*
* @param dataIn 待计算的数据
*
* @retval 计算得到的CRC32,计算失败返回0xFFFFFFFF
*
*/
uint32_t GetCrc32(uint32_t dataIn)
{
uint32_t i = 0;
uint32_t crc32 = 0;
FL_RNG_CRC_WriteData(RNG, dataIn);
FL_RNG_ClearFlag_CRCComplete(RNG);
FL_RNG_CRC_Enable(RNG);
while(0 == FL_RNG_IsActiveFlag_CRCComplete(RNG))
{
i++;
if(i > 600)
{ break; }
}
if(i >= 600)
{
FL_RNG_ClearFlag_CRCComplete(RNG);
FL_RNG_Disable(RNGCTL);
return 0xFFFFFFFF;
}
FL_RNG_ClearFlag_CRCComplete(RNG);
crc32 = FL_RNG_ReadData(RNG);
FL_RNG_Disable(RNGCTL);
return crc32;
}
/**
*@}
*/
/**
*@}
*/
/**
*@}
*/
/******************************************* END OF FILE *******************************************/
@@ -0,0 +1,185 @@
/**
*******************************************************************************************************
* @file fm33lc0xx_fl_rtc.c
* @author FMSH Application Team
* @brief Src file of RTC FL Module
*******************************************************************************************************
* @attention
*
* Copyright (c) [2019] [Fudan Microelectronics]
* THIS SOFTWARE is licensed under the Mulan PSL v1.
* can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
*
*******************************************************************************************************
*/
#include "fm33lc0xx_fl_rcc.h"
#include "fm33lc0xx_fl_rmu.h"
#include "fm33lc0xx_fl_rtc.h"
#include "fm33_assert.h"
/** @addtogroup FM33LC0XX_FL_Driver
* @{
*/
/** @addtogroup RTC
* @{
*/
/* Private macros ------------------------------------------------------------*/
/** @addtogroup RTC_FL_Private_Macros
* @{
*/
#define IS_RTC_INSTANCE(RTCx) ((RTCx) == RTC)
/**
* @}
*/
/** @addtogroup RTC_FL_EF_Init
* @{
*/
/**
* @brief 复位RTC
* @param RTCx 外设入口地址
* @retval 错误状态,可能值:
* -FL_PASS 外设寄存器值恢复复位值
* -FL_FAIL 未成功执行
*/
FL_ErrorStatus FL_RTC_DeInit(RTC_Type *RTCx)
{
FL_ErrorStatus result = FL_PASS;
/* Check the parameters */
assert_param(IS_RTC_INSTANCE(RTCx));
RTCx->IER = 0x00000000U;
RTCx->WER = 0x00000000U;
RTCx->ADJUST = 0x00000000U;
RTCx->ADSIGN = 0x00000000U;
RTCx->ALARM = 0x00000000U;
RTCx->BCDDAY = 0x00000000U;
RTCx->BCDHOUR = 0x00000000U;
RTCx->BCDMIN = 0x00000000U;
RTCx->BCDMONTH = 0x00000000U;
RTCx->BCDSEC = 0x00000000U;
RTCx->BCDWEEK = 0x00000000U;
RTCx->BCDYEAR = 0x00000000U;
RTCx->SBSCNT = 0x00000000U;
RTCx->TMSEL = 0x00000000U;
RTCx->WER = 0x00000000U;
return result;
}
/**
* @brief 配置RTC
* @param RTCx 外设入口地址
* @param initStruct 指向 @ref FL_RTC_InitTypeDef 结构体的指针
* @retval 错误状态,可能值:
* -FL_PASS 配置成功
* -FL_FAIL 配置过程发生错误
*/
FL_ErrorStatus FL_RTC_Init(RTC_Type *RTCx, FL_RTC_InitTypeDef *initStruct)
{
/* 参数检查 */
assert_param(IS_RTC_INSTANCE(RTCx));
/* 时钟总线使能配置 */
FL_RCC_EnableGroup1BusClock(FL_RCC_GROUP1_BUSCLK_RTC);
/* 配置时间 */
FL_RTC_ConfigTime(RTCx, initStruct);
return FL_PASS;
}
/**
* @brief 设置RTC实时时间
* @param RTCx 外设入口地址
* @param initStruct 指向 @ref FL_RTC_InitTypeDef 结构体的指针
* @retval 错误状态,可能值:
* -FL_PASS 配置成功
* -FL_FAIL 配置过程发生错误
*/
FL_ErrorStatus FL_RTC_ConfigTime(RTC_Type *RTCx, FL_RTC_InitTypeDef *initStruct)
{
/* 使能时间配置 */
FL_RTC_WriteEnable(RTCx);
/* 配置秒 */
FL_RTC_WriteSecond(RTCx, initStruct->second);
/* 配置分钟 */
FL_RTC_WriteMinute(RTCx, initStruct->minute);
/* 配置小时 */
FL_RTC_WriteHour(RTCx, initStruct->hour);
/* 配置日期 */
FL_RTC_WriteDay(RTCx, initStruct->day);
/* 配置周 */
FL_RTC_WriteWeek(RTCx, initStruct->week);
/* 配置月 */
FL_RTC_WriteMonth(RTCx, initStruct->month);
/* 配置年 */
FL_RTC_WriteYear(RTCx, initStruct->year);
/* 锁定时间配置 */
FL_RTC_WriteDisable(RTCx);
return FL_PASS;
}
/**
* @brief 获取RTC实时时间并保存到指定结构体中
* @param RTCx 外设入口地址
* @param initStruct 指向 @ref FL_RTC_InitTypeDef 结构体的指针
* @retval 错误状态,可能值:
* -FL_PASS 获取成功
* -FL_FAIL 获取过程发生错误
*/
FL_ErrorStatus FL_RTC_GetTime(RTC_Type *RTCx, FL_RTC_InitTypeDef *initStruct)
{
/* 配置秒 */
initStruct->second = FL_RTC_ReadSecond(RTCx);
/* 配置分钟 */
initStruct->minute = FL_RTC_ReadMinute(RTCx);
/* 配置小时 */
initStruct->hour = FL_RTC_ReadHour(RTCx);
/* 配置日期 */
initStruct->day = FL_RTC_ReadDay(RTCx);
/* 配置周 */
initStruct->week = FL_RTC_ReadWeek(RTCx);
/* 配置月 */
initStruct->month = FL_RTC_ReadMonth(RTCx);
/* 配置年 */
initStruct->year = FL_RTC_ReadYear(RTCx);
return FL_PASS;
}
/**
* @brief 将 @ref FL_RTC_InitTypeDef 结构体初始化为默认配置
* @param initStruct 指向 @ref FL_RTC_InitTypeDef 结构体的指针
*
* @retval None
*/
void FL_RTC_StructInit(FL_RTC_InitTypeDef *initStruct)
{
initStruct->year = 0x00;
initStruct->month = 0x00;
initStruct->day = 0x00;
initStruct->week = 0x00;
initStruct->hour = 0x00;
initStruct->minute = 0x00;
initStruct->second = 0x00;
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/******************************************* END OF FILE *******************************************/
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,166 @@
/**
****************************************************************************************************
* @file fm33lc0xx_fl_svd.c
* @author FMSH Application Team
* @brief Src file of SVD FL Module
****************************************************************************************************
* @attention
*
* Copyright (c) [2019] [Fudan Microelectronics]
* THIS SOFTWARE is licensed under the Mulan PSL v1.
* can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
*
****************************************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "fm33lc0xx_fl_rcc.h"
#include "fm33lc0xx_fl_rmu.h"
#include "fm33lc0xx_fl_svd.h"
#include "fm33_assert.h"
/** @addtogroup FM33LC0XX_FL_Driver
* @{
*/
/** @addtogroup SVD
* @{
*/
/* Private macros ------------------------------------------------------------*/
/** @addtogroup SVD_FL_Private_Macros
* @{
*/
#define IS_SVD_INSTANCE(INSTANCE) (((INSTANCE) == SVD))
#define IS_FL_SVD_WARNING_THRESHOLD_LEVEL(__VALUE__) (((__VALUE__) == FL_SVD_WARNING_THRESHOLD_GROUP0)||\
((__VALUE__) == FL_SVD_WARNING_THRESHOLD_GROUP1)||\
((__VALUE__) == FL_SVD_WARNING_THRESHOLD_GROUP2)||\
((__VALUE__) == FL_SVD_WARNING_THRESHOLD_GROUP3)||\
((__VALUE__) == FL_SVD_WARNING_THRESHOLD_GROUP4)||\
((__VALUE__) == FL_SVD_WARNING_THRESHOLD_GROUP5)||\
((__VALUE__) == FL_SVD_WARNING_THRESHOLD_GROUP6)||\
((__VALUE__) == FL_SVD_WARNING_THRESHOLD_GROUP7)||\
((__VALUE__) == FL_SVD_WARNING_THRESHOLD_GROUP8)||\
((__VALUE__) == FL_SVD_WARNING_THRESHOLD_GROUP9)||\
((__VALUE__) == FL_SVD_WARNING_THRESHOLD_GROUP10)||\
((__VALUE__) == FL_SVD_WARNING_THRESHOLD_GROUP11)||\
((__VALUE__) == FL_SVD_WARNING_THRESHOLD_GROUP12)||\
((__VALUE__) == FL_SVD_WARNING_THRESHOLD_GROUP13)||\
((__VALUE__) == FL_SVD_WARNING_THRESHOLD_GROUP14)||\
((__VALUE__) == FL_SVD_WARNING_THRESHOLD_GROUP15))
#define IS_FL_SVD_SVSCONFIG(__VALUE__) (((__VALUE__) == FL_DISABLE)||\
((__VALUE__) == FL_ENABLE))
#define IS_FL_SVD_REFERENCE_VOLTAGE(__VALUE__) (((__VALUE__) == FL_SVD_REFERENCE_1P2V)||\
((__VALUE__) == FL_SVD_REFERENCE_1P1V)||\
((__VALUE__) == FL_SVD_REFERENCE_1P0V))
#define IS_FL_SVD_DIGITAL_FILTER(__VALUE__) (((__VALUE__) == FL_DISABLE)||\
((__VALUE__) == FL_ENABLE))
/**
*@}
*/
/** @addtogroup SVD_FL_EF_Init
* @{
*/
/**
* @brief 复位SVD外设
* @param SVDx 外设入口地址
* @retval 错误状态,可能值:
* -FL_PASS 外设寄存器值恢复复位值
* -FL_FAIL 未成功执行
*/
FL_ErrorStatus FL_SVD_DeInit(SVD_Type *SVDx)
{
FL_ErrorStatus status = FL_PASS;
/* 入口参数合法性断言 */
assert_param(IS_SVD_INSTANCE(SVDx));
SVDx->CFGR = 0x00000C08U;
SVDx->CR = 0x00000000U;
SVDx->IER = 0x00000000U;
SVDx->VSR = 0x00000004U;
return (status);
}
/**
* @brief 配置SVD
* @param SVDx 外设入口地址
* @param initStruct 指向 @ref FL_SVD_InitTypeDef 结构体的指针
*
* @retval 错误状态,可能值:
* -FL_PASS 配置成功
* -FL_FAIL 配置过程发生错误
*/
FL_ErrorStatus FL_SVD_Init(SVD_Type *SVDx, FL_SVD_InitTypeDef *initStruct)
{
FL_ErrorStatus status = FL_FAIL;
/* 参数合法性检查 */
assert_param(IS_SVD_INSTANCE(SVDx));
assert_param(IS_FL_SVD_WARNING_THRESHOLD_LEVEL(initStruct->warningThreshold));
assert_param(IS_FL_SVD_SVSCONFIG(initStruct->SVSChannel));
assert_param(IS_FL_SVD_REFERENCE_VOLTAGE(initStruct->referenceVoltage));
assert_param(IS_FL_SVD_DIGITAL_FILTER(initStruct->digitalFilter));
/* 使能工作时钟 */
FL_RCC_EnableGroup1BusClock(FL_RCC_GROUP1_BUSCLK_ANAC);
/* 检测阈值 */
FL_SVD_SetWarningThreshold(SVDx, initStruct->warningThreshold);
/* 参考电压通道选择 */
FL_SVD_EnableReference(SVD, initStruct->referenceVoltage);
/* 外部通道配置 */
if(initStruct->SVSChannel == FL_ENABLE)
{
FL_SVD_EnableSVSChannel(SVDx);
}
else
{
FL_SVD_DisableSVSChannel(SVDx);
}
/* 数字滤波配置 */
if(initStruct->digitalFilter == FL_ENABLE)
{
FL_SVD_EnableDigitalFilter(SVDx);
}
else
{
FL_SVD_DisableDigitalFilter(SVDx);
}
status = FL_PASS;
return status;
}
/**
* @brief 将 @ref FL_SVD_InitTypeDef 结构体初始化为默认配置
* @param initStruct 指向 @ref FL_SVD_InitTypeDef 结构体的指针
*
* @retval None
*/
void FL_SVD_StructInit(FL_SVD_InitTypeDef *initStruct)
{
initStruct->SVSChannel = FL_DISABLE;
initStruct->digitalFilter = FL_ENABLE;
initStruct->referenceVoltage = FL_SVD_REFERENCE_1P0V;
initStruct->warningThreshold = FL_SVD_WARNING_THRESHOLD_GROUP0;
}
/**
*@}
*/
/**
*@}
*/
/**
*@}
*/
/******************************************* END OF FILE *******************************************/
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,125 @@
/**
****************************************************************************************************
* @file fm33lc0xx_fl_wwdt.c
* @author FMSH Application Team
* @brief Src file of WWDT FL Module
****************************************************************************************************
* @attention
*
* Copyright (c) [2019] [Fudan Microelectronics]
* THIS SOFTWARE is licensed under the Mulan PSL v1.
* can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
*
****************************************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "fm33lc0xx_fl_rcc.h"
#include "fm33lc0xx_fl_wwdt.h"
#include "fm33_assert.h"
/** @addtogroup FM33LC0XX_FL_Driver
* @{
*/
/** @addtogroup WWDT
* @{
*/
/* Private macros ------------------------------------------------------------*/
/** @addtogroup WWDT_FL_Private_Macros
* @{
*/
#define IS_WWDT_INSTANCE(INTANCE) ((INTANCE) == WWDT)
#define IS_FL_WWDT_OVERFLOWPERIOD(__VALUE__) (((__VALUE__) == FL_WWDT_PERIOD_1CNT)||\
((__VALUE__) == FL_WWDT_PERIOD_4CNT)||\
((__VALUE__) == FL_WWDT_PERIOD_16CNT)||\
((__VALUE__) == FL_WWDT_PERIOD_64CNT)||\
((__VALUE__) == FL_WWDT_PERIOD_128CNT)||\
((__VALUE__) == FL_WWDT_PERIOD_256CNT)||\
((__VALUE__) == FL_WWDT_PERIOD_512CNT)||\
((__VALUE__) == FL_WWDT_PERIOD_1024CNT))
/**
* @}
*/
/** @addtogroup WWDT_FL_EF_Init
* @{
*/
/**
* @brief 关闭WWDT外设总线时钟
*
* @param WWDTx 外设入口地址
*
* @retval 错误状态,可能值:
* -FL_PASS 外设寄存器值恢复复位值
* -FL_FAIL 未成功执行
*/
FL_ErrorStatus FL_WWDT_DeInit(WWDT_Type *WWDTx)
{
assert_param(IS_WWDT_INSTANCE(WWDTx));
return FL_PASS;
}
/**
* @brief 根据 WWDT_InitStruct初始化对应外设入口地址的寄存器值.
*
* @note WWTD使能后将无法关闭,直到下一次芯片复位
*
* @param WWDTx 外设入口地址
*
* @param WWDT_InitStruct 指向 @ref FL_WWDT_InitTypeDef 结构体的指针
*
* @retval 错误状态,可能值:
* -FL_PASS 配置成功
* -FL_FAIL 配置过程发生错误
*/
FL_ErrorStatus FL_WWDT_Init(WWDT_Type *WWDTx, FL_WWDT_InitTypeDef *WWDT_InitStruct)
{
FL_ErrorStatus status = FL_PASS;
/* 入口参数检查 */
assert_param(IS_WWDT_INSTANCE(WWDTx));
assert_param(IS_FL_WWDT_OVERFLOWPERIOD(WWDT_InitStruct->overflowPeriod));
/* 开启总线时钟 */
FL_RCC_EnableGroup2BusClock(FL_RCC_GROUP2_BUSCLK_WWDT);
/* 配置独立看门狗溢出周期 */
FL_WWDT_SetPeriod(WWDTx, WWDT_InitStruct->overflowPeriod);
/* 启动看门狗 */
FL_WWDT_Enable(WWDTx);
return status;
}
/**
* @brief 设置 WWDT_InitStruct 为默认配置
*
* @param WWDT_InitStruct 指向 @ref FL_WWDT_InitTypeDef 结构体的指针
*
* @retval None
*/
void FL_WWDT_StructInit(FL_WWDT_InitTypeDef *WWDT_InitStruct)
{
/* 默认最长溢出周期 */
WWDT_InitStruct->overflowPeriod = FL_WWDT_PERIOD_1024CNT;
}
/**
*@}
*/
/**
*@}
*/
/**
*@}
*/
/******************************************* END OF FILE *******************************************/
@@ -0,0 +1,62 @@
if BSP_USING_USBD
config BSP_USBD_TYPE_FS
bool
# "USB Full Speed (FS) Core"
config BSP_USBD_TYPE_HS
bool
# "USB High Speed (HS) Core"
config BSP_USBD_SPEED_HS
bool
# "USB High Speed (HS) Mode"
config BSP_USBD_SPEED_HSINFS
bool
# "USB High Speed (HS) Core in FS mode"
config BSP_USBD_PHY_EMBEDDED
bool
# "Using Embedded phy interface"
config BSP_USBD_PHY_UTMI
bool
# "UTMI: USB 2.0 Transceiver Macrocell Interace"
config BSP_USBD_PHY_ULPI
bool
# "ULPI: UTMI+ Low Pin Interface"
endif
config BSP_USING_CRC
bool "Enable CRC (CRC-32 0x04C11DB7 Polynomial)"
select RT_USING_HWCRYPTO
select RT_HWCRYPTO_USING_CRC
# "Crypto device frame dose not support above 8-bits granularity"
# "Reserve progress, running well, about 32-bits granularity, such as stm32f1, stm32f4"
depends on (SOC_SERIES_STM32L4 || SOC_SERIES_STM32F0 || SOC_SERIES_STM32F7 || SOC_SERIES_STM32H7 || SOC_SERIES_STM32MP1)
default n
config BSP_USING_RNG
bool "Enable RNG (Random Number Generator)"
select RT_USING_HWCRYPTO
select RT_HWCRYPTO_USING_RNG
depends on (SOC_SERIES_STM32L4 || SOC_SERIES_STM32F4 || SOC_SERIES_STM32F7 || \
SOC_SERIES_STM32H7 || SOC_SERIES_STM32MP1)
default n
config BSP_USING_HASH
bool "Enable HASH (Hash House Harriers)"
select RT_USING_HWCRYPTO
select RT_HWCRYPTO_USING_HASH
depends on (SOC_SERIES_STM32MP1)
default n
config BSP_USING_CRYP
bool "Enable CRYP (Encrypt And Decrypt Data)"
select RT_USING_HWCRYPTO
select RT_HWCRYPTO_USING_CRYP
depends on (SOC_SERIES_STM32MP1)
default n
config BSP_USING_UDID
bool "Enable UDID (Unique Device Identifier)"
select RT_USING_HWCRYPTO
default n

Some files were not shown because too many files have changed in this diff Show More